Commit a172727c authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Misc core/ cleanup of ExecutionContextClient frame-variant usage

Change-Id: I212fd68b99ac07343dafc2ae65ca2a6e24b6ccac
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487697
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Auto-Submit: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819174}
parent 52cbd3b6
...@@ -34,31 +34,28 @@ ...@@ -34,31 +34,28 @@
namespace blink { namespace blink {
StyleMedia::StyleMedia(LocalFrame* frame) : ExecutionContextClient(frame) {} StyleMedia::StyleMedia(LocalDOMWindow* window)
: ExecutionContextClient(window) {}
AtomicString StyleMedia::type() const { AtomicString StyleMedia::type() const {
LocalFrameView* view = GetFrame() ? GetFrame()->View() : nullptr; if (!DomWindow())
if (view) return g_null_atom;
return view->MediaType(); return DomWindow()->GetFrame()->View()->MediaType();
return g_null_atom;
} }
bool StyleMedia::matchMedium(const String& query) const { bool StyleMedia::matchMedium(const String& query) const {
if (!GetFrame()) if (!DomWindow())
return false; return false;
Document* document = GetFrame()->GetDocument(); Element* document_element = DomWindow()->document()->documentElement();
DCHECK(document);
Element* document_element = document->documentElement();
if (!document_element) if (!document_element)
return false; return false;
scoped_refptr<MediaQuerySet> media = MediaQuerySet::Create(); scoped_refptr<MediaQuerySet> media = MediaQuerySet::Create();
if (!media->Set(query, GetFrame()->DomWindow())) if (!media->Set(query, DomWindow()))
return false; return false;
MediaQueryEvaluator screen_eval(GetFrame()); MediaQueryEvaluator screen_eval(DomWindow()->GetFrame());
return screen_eval.Eval(*media); return screen_eval.Eval(*media);
} }
......
...@@ -34,13 +34,13 @@ ...@@ -34,13 +34,13 @@
namespace blink { namespace blink {
class LocalFrame; class LocalDOMWindow;
class StyleMedia final : public ScriptWrappable, public ExecutionContextClient { class StyleMedia final : public ScriptWrappable, public ExecutionContextClient {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
explicit StyleMedia(LocalFrame*); explicit StyleMedia(LocalDOMWindow*);
AtomicString type() const; AtomicString type() const;
bool matchMedium(const String&) const; bool matchMedium(const String&) const;
......
...@@ -819,7 +819,6 @@ bool WebPluginContainerImpl::WantsWheelEvents() const { ...@@ -819,7 +819,6 @@ bool WebPluginContainerImpl::WantsWheelEvents() const {
WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement& element, WebPluginContainerImpl::WebPluginContainerImpl(HTMLPlugInElement& element,
WebPlugin* web_plugin) WebPlugin* web_plugin)
: EmbeddedContentView(IntRect()), : EmbeddedContentView(IntRect()),
ExecutionContextClient(element.GetDocument().GetFrame()),
element_(element), element_(element),
web_plugin_(web_plugin), web_plugin_(web_plugin),
layer_(nullptr), layer_(nullptr),
...@@ -875,7 +874,6 @@ void WebPluginContainerImpl::SetFrameRect(const IntRect& rect) { ...@@ -875,7 +874,6 @@ void WebPluginContainerImpl::SetFrameRect(const IntRect& rect) {
void WebPluginContainerImpl::Trace(Visitor* visitor) const { void WebPluginContainerImpl::Trace(Visitor* visitor) const {
visitor->Trace(element_); visitor->Trace(element_);
visitor->Trace(mouse_lock_lost_listener_); visitor->Trace(mouse_lock_lost_listener_);
ExecutionContextClient::Trace(visitor);
} }
void WebPluginContainerImpl::HandleMouseEvent(MouseEvent& event) { void WebPluginContainerImpl::HandleMouseEvent(MouseEvent& event) {
......
...@@ -71,8 +71,7 @@ struct WebPrintPresetOptions; ...@@ -71,8 +71,7 @@ struct WebPrintPresetOptions;
class CORE_EXPORT WebPluginContainerImpl final class CORE_EXPORT WebPluginContainerImpl final
: public GarbageCollected<WebPluginContainerImpl>, : public GarbageCollected<WebPluginContainerImpl>,
public EmbeddedContentView, public EmbeddedContentView,
public WebPluginContainer, public WebPluginContainer {
public ExecutionContextClient {
USING_PRE_FINALIZER(WebPluginContainerImpl, PreFinalize); USING_PRE_FINALIZER(WebPluginContainerImpl, PreFinalize);
public: public:
......
...@@ -925,7 +925,7 @@ ApplicationCache* LocalDOMWindow::applicationCache() { ...@@ -925,7 +925,7 @@ ApplicationCache* LocalDOMWindow::applicationCache() {
this, WebFeature::kApplicationCacheAPIInsecureOrigin); this, WebFeature::kApplicationCacheAPIInsecureOrigin);
} }
if (!application_cache_) if (!application_cache_)
application_cache_ = MakeGarbageCollected<ApplicationCache>(GetFrame()); application_cache_ = MakeGarbageCollected<ApplicationCache>(this);
return application_cache_.Get(); return application_cache_.Get();
} }
...@@ -1447,9 +1447,9 @@ Document* LocalDOMWindow::document() const { ...@@ -1447,9 +1447,9 @@ Document* LocalDOMWindow::document() const {
return document_.Get(); return document_.Get();
} }
StyleMedia* LocalDOMWindow::styleMedia() const { StyleMedia* LocalDOMWindow::styleMedia() {
if (!media_) if (!media_)
media_ = MakeGarbageCollected<StyleMedia>(GetFrame()); media_ = MakeGarbageCollected<StyleMedia>(this);
return media_.Get(); return media_.Get();
} }
......
...@@ -238,7 +238,7 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow, ...@@ -238,7 +238,7 @@ class CORE_EXPORT LocalDOMWindow final : public DOMWindow,
Document* document() const; Document* document() const;
// CSSOM View Module // CSSOM View Module
StyleMedia* styleMedia() const; StyleMedia* styleMedia();
// WebKit extensions // WebKit extensions
double devicePixelRatio() const; double devicePixelRatio() const;
......
...@@ -156,7 +156,7 @@ Screen::Screen(display::mojom::blink::DisplayPtr display, ...@@ -156,7 +156,7 @@ Screen::Screen(display::mojom::blink::DisplayPtr display,
bool internal, bool internal,
bool primary, bool primary,
const String& id) const String& id)
: ExecutionContextClient(static_cast<LocalFrame*>(nullptr)), : ExecutionContextClient(static_cast<ExecutionContext*>(nullptr)),
display_(std::move(display)), display_(std::move(display)),
internal_(internal), internal_(internal),
primary_(primary), primary_(primary),
......
...@@ -30,18 +30,16 @@ ...@@ -30,18 +30,16 @@
#include "third_party/blink/renderer/core/dom/events/event_listener.h" #include "third_party/blink/renderer/core/dom/events/event_listener.h"
#include "third_party/blink/renderer/core/frame/deprecation.h" #include "third_party/blink/renderer/core/frame/deprecation.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h" #include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/loader/appcache/application_cache_host_for_frame.h" #include "third_party/blink/renderer/core/loader/appcache/application_cache_host_for_frame.h"
#include "third_party/blink/renderer/core/loader/document_loader.h" #include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
namespace blink { namespace blink {
ApplicationCache::ApplicationCache(LocalFrame* frame) ApplicationCache::ApplicationCache(LocalDOMWindow* window)
: ExecutionContextClient(frame) { : ExecutionContextClient(window) {
DCHECK(RuntimeEnabledFeatures::AppCacheEnabled(frame->DomWindow())); DCHECK(RuntimeEnabledFeatures::AppCacheEnabled(window));
ApplicationCacheHostForFrame* cache_host = GetApplicationCacheHost(); ApplicationCacheHostForFrame* cache_host = GetApplicationCacheHost();
if (cache_host) if (cache_host)
cache_host->SetApplicationCache(this); cache_host->SetApplicationCache(this);
...@@ -54,9 +52,9 @@ void ApplicationCache::Trace(Visitor* visitor) const { ...@@ -54,9 +52,9 @@ void ApplicationCache::Trace(Visitor* visitor) const {
ApplicationCacheHostForFrame* ApplicationCache::GetApplicationCacheHost() ApplicationCacheHostForFrame* ApplicationCache::GetApplicationCacheHost()
const { const {
if (!GetFrame() || !GetFrame()->Loader().GetDocumentLoader()) if (!DomWindow())
return nullptr; return nullptr;
return GetFrame()->Loader().GetDocumentLoader()->GetApplicationCacheHost(); return DomWindow()->document()->Loader()->GetApplicationCacheHost();
} }
uint16_t ApplicationCache::status() const { uint16_t ApplicationCache::status() const {
...@@ -120,7 +118,7 @@ const AtomicString& ApplicationCache::InterfaceName() const { ...@@ -120,7 +118,7 @@ const AtomicString& ApplicationCache::InterfaceName() const {
} }
ExecutionContext* ApplicationCache::GetExecutionContext() const { ExecutionContext* ApplicationCache::GetExecutionContext() const {
return GetFrame() ? GetFrame()->DomWindow() : nullptr; return ExecutionContextClient::GetExecutionContext();
} }
const AtomicString& ApplicationCache::ToEventType(mojom::AppCacheEventID id) { const AtomicString& ApplicationCache::ToEventType(mojom::AppCacheEventID id) {
...@@ -147,11 +145,10 @@ const AtomicString& ApplicationCache::ToEventType(mojom::AppCacheEventID id) { ...@@ -147,11 +145,10 @@ const AtomicString& ApplicationCache::ToEventType(mojom::AppCacheEventID id) {
} }
void ApplicationCache::RecordAPIUseType() const { void ApplicationCache::RecordAPIUseType() const {
if (!GetFrame()) if (!DomWindow())
return; return;
LocalDOMWindow* window = GetFrame()->DomWindow(); CHECK(DomWindow()->IsSecureContext());
CHECK(GetFrame()->DomWindow()->IsSecureContext()); Deprecation::CountDeprecation(DomWindow(),
Deprecation::CountDeprecation(window,
WebFeature::kApplicationCacheAPISecureOrigin); WebFeature::kApplicationCacheAPISecureOrigin);
} }
......
...@@ -36,14 +36,14 @@ namespace blink { ...@@ -36,14 +36,14 @@ namespace blink {
class ApplicationCacheHostForFrame; class ApplicationCacheHostForFrame;
class ExceptionState; class ExceptionState;
class LocalFrame; class LocalDOMWindow;
class ApplicationCache final : public EventTargetWithInlineData, class ApplicationCache final : public EventTargetWithInlineData,
public ExecutionContextClient { public ExecutionContextClient {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
explicit ApplicationCache(LocalFrame*); explicit ApplicationCache(LocalDOMWindow*);
~ApplicationCache() override = default; ~ApplicationCache() override = default;
uint16_t status() const; uint16_t status() const;
......
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