Commit 4cfad706 authored by Tal Pressman's avatar Tal Pressman Committed by Chromium LUCI CQ

Make LocalFrame::DomWindow() const correct.

Before this CL, DomWindow was marked as const, but returned a mutable
LocalDOMWindow*. This CL creates two overloads of DomWindow():
- const LocalDOMWindow* DomWindow() const;
- LocalDOMWindow* DomWindow;

See: https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++-dos-and-donts.md#use-correctly

Change-Id: I786fc68ebe92a81ee1822ac06841aed1445889f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592274Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Tal Pressman <talp@google.com>
Cr-Commit-Position: refs/heads/master@{#837474}
parent 3752a2b1
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
namespace blink { namespace blink {
// static // static
void Intervention::GenerateReport(const LocalFrame* frame, void Intervention::GenerateReport(LocalFrame* frame,
const String& id, const String& id,
const String& message) { const String& message) {
if (!frame || !frame->Client()) if (!frame || !frame->Client())
......
...@@ -23,7 +23,7 @@ class CORE_EXPORT Intervention { ...@@ -23,7 +23,7 @@ class CORE_EXPORT Intervention {
// Generates a intervention report, to be routed to the Reporting API and any // Generates a intervention report, to be routed to the Reporting API and any
// ReportingObservers. Also sends the intervention message to the console. // ReportingObservers. Also sends the intervention message to the console.
static void GenerateReport(const LocalFrame*, static void GenerateReport(LocalFrame*,
const String& id, const String& id,
const String& message); const String& message);
......
...@@ -835,7 +835,11 @@ LocalWindowProxy* LocalFrame::WindowProxy(DOMWrapperWorld& world) { ...@@ -835,7 +835,11 @@ LocalWindowProxy* LocalFrame::WindowProxy(DOMWrapperWorld& world) {
return To<LocalWindowProxy>(Frame::GetWindowProxy(world)); return To<LocalWindowProxy>(Frame::GetWindowProxy(world));
} }
LocalDOMWindow* LocalFrame::DomWindow() const { LocalDOMWindow* LocalFrame::DomWindow() {
return To<LocalDOMWindow>(dom_window_.Get());
}
const LocalDOMWindow* LocalFrame::DomWindow() const {
return To<LocalDOMWindow>(dom_window_.Get()); return To<LocalDOMWindow>(dom_window_.Get());
} }
...@@ -2207,7 +2211,7 @@ void LocalFrame::UpdateActiveSchedulerTrackedFeatures(uint64_t features_mask) { ...@@ -2207,7 +2211,7 @@ void LocalFrame::UpdateActiveSchedulerTrackedFeatures(uint64_t features_mask) {
} }
const base::UnguessableToken& LocalFrame::GetAgentClusterId() const { const base::UnguessableToken& LocalFrame::GetAgentClusterId() const {
if (LocalDOMWindow* window = DomWindow()) { if (const LocalDOMWindow* window = DomWindow()) {
return window->GetAgentClusterID(); return window->GetAgentClusterID();
} }
return base::UnguessableToken::Null(); return base::UnguessableToken::Null();
......
...@@ -222,7 +222,8 @@ class CORE_EXPORT LocalFrame final ...@@ -222,7 +222,8 @@ class CORE_EXPORT LocalFrame final
// corresponding method in the Frame base class to return the // corresponding method in the Frame base class to return the
// LocalFrame-specific subclass. // LocalFrame-specific subclass.
LocalWindowProxy* WindowProxy(DOMWrapperWorld&); LocalWindowProxy* WindowProxy(DOMWrapperWorld&);
LocalDOMWindow* DomWindow() const; LocalDOMWindow* DomWindow();
const LocalDOMWindow* DomWindow() const;
void SetDOMWindow(LocalDOMWindow*); void SetDOMWindow(LocalDOMWindow*);
LocalFrameView* View() const override; LocalFrameView* View() const override;
Document* GetDocument() const; Document* GetDocument() const;
......
...@@ -558,14 +558,14 @@ void ImageLoader::DoUpdateFromElement( ...@@ -558,14 +558,14 @@ void ImageLoader::DoUpdateFromElement(
} }
DCHECK(document.GetFrame()); DCHECK(document.GetFrame());
auto* frame = document.GetFrame();
FetchParameters params(std::move(resource_request), FetchParameters params(std::move(resource_request),
resource_loader_options); resource_loader_options);
ConfigureRequest(params, *element_, ConfigureRequest(params, *element_, frame->GetClientHintsPreferences());
document.GetFrame()->GetClientHintsPreferences());
if (update_behavior != kUpdateForcedReload && if (update_behavior != kUpdateForcedReload &&
lazy_image_load_state_ != LazyImageLoadState::kFullImage) { lazy_image_load_state_ != LazyImageLoadState::kFullImage) {
const auto* frame = document.GetFrame();
if (auto* html_image = DynamicTo<HTMLImageElement>(GetElement())) { if (auto* html_image = DynamicTo<HTMLImageElement>(GetElement())) {
LoadingAttributeValue loading_attr = GetLoadingAttributeValue( LoadingAttributeValue loading_attr = GetLoadingAttributeValue(
html_image->FastGetAttribute(html_names::kLoadingAttr)); html_image->FastGetAttribute(html_names::kLoadingAttr));
......
...@@ -96,7 +96,7 @@ void LazyImageHelper::StopMonitoring(Element* element) { ...@@ -96,7 +96,7 @@ void LazyImageHelper::StopMonitoring(Element* element) {
// static // static
LazyImageHelper::Eligibility LazyImageHelper::Eligibility
LazyImageHelper::DetermineEligibilityAndTrackVisibilityMetrics( LazyImageHelper::DetermineEligibilityAndTrackVisibilityMetrics(
const LocalFrame& frame, LocalFrame& frame,
HTMLImageElement* html_image, HTMLImageElement* html_image,
const KURL& url) { const KURL& url) {
if (!url.ProtocolIsInHTTPFamily()) if (!url.ProtocolIsInHTTPFamily())
......
...@@ -28,7 +28,7 @@ class LazyImageHelper final { ...@@ -28,7 +28,7 @@ class LazyImageHelper final {
static void StopMonitoring(Element* element); static void StopMonitoring(Element* element);
static Eligibility DetermineEligibilityAndTrackVisibilityMetrics( static Eligibility DetermineEligibilityAndTrackVisibilityMetrics(
const LocalFrame& frame, LocalFrame& frame,
HTMLImageElement* html_image, HTMLImageElement* html_image,
const KURL& url); const KURL& url);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment