Commit 11511f6b authored by slangley's avatar slangley Committed by Commit bot

Move more methods from WebViewImpl to WebViewBase, and cut dependencies.

The work continues the effort to remove direct dependencies on web/WebViewImpl.h
by moving methods to a pure virtual base class, and updating references to use
the base class rather than the implementation.

We need to break cyclic dependencies in web/ to allow us to move files up into
core/ and modules/.

BUG=712963

Review-Url: https://codereview.chromium.org/2851993002
Cr-Commit-Position: refs/heads/master@{#468307}
parent 70929846
...@@ -17,7 +17,11 @@ class CompositorAnimationTimeline; ...@@ -17,7 +17,11 @@ class CompositorAnimationTimeline;
class ContextMenuProvider; class ContextMenuProvider;
class DevToolsEmulator; class DevToolsEmulator;
class Frame; class Frame;
class GraphicsLayer;
class Page; class Page;
class PaintLayerCompositor;
class PagePopup;
class PagePopupClient;
class PageScaleConstraintsSet; class PageScaleConstraintsSet;
class WebInputEvent; class WebInputEvent;
class WebKeyboardEvent; class WebKeyboardEvent;
...@@ -48,6 +52,7 @@ class WebViewBase : public WebView { ...@@ -48,6 +52,7 @@ class WebViewBase : public WebView {
virtual Page* GetPage() const = 0; virtual Page* GetPage() const = 0;
virtual Frame* FocusedCoreFrame() const = 0; virtual Frame* FocusedCoreFrame() const = 0;
static WebViewBase* FromPage(Page*);
// Returns the main frame associated with this view. This may be null when // Returns the main frame associated with this view. This may be null when
// the page is shutting down, but will be valid at all other times. // the page is shutting down, but will be valid at all other times.
...@@ -105,6 +110,41 @@ class WebViewBase : public WebView { ...@@ -105,6 +110,41 @@ class WebViewBase : public WebView {
virtual WebSettingsImpl* SettingsImpl() = 0; virtual WebSettingsImpl* SettingsImpl() = 0;
virtual PagePopup* OpenPagePopup(PagePopupClient*) = 0;
virtual void ClosePagePopup(PagePopup*) = 0;
virtual void CleanupPagePopup() = 0;
virtual LocalDOMWindow* PagePopupWindow() const = 0;
virtual void InvalidateRect(const IntRect&) = 0;
// Indicates two things:
// 1) This view may have a new layout now.
// 2) Calling updateAllLifecyclePhases() is a no-op.
// After calling WebWidget::updateAllLifecyclePhases(), expect to get this
// notification unless the view did not need a layout.
virtual void LayoutUpdated(WebLocalFrameImpl*) = 0;
virtual void ResizeAfterLayout(WebLocalFrameImpl*) = 0;
virtual void UpdatePageDefinedViewportConstraints(
const ViewportDescription&) = 0;
virtual void EnterFullscreen(LocalFrame&) = 0;
virtual void ExitFullscreen(LocalFrame&) = 0;
virtual void FullscreenElementChanged(Element*, Element*) = 0;
virtual bool HasOpenedPopup() const = 0;
// Returns true if popup menus should be rendered by the browser, false if
// they should be rendered by WebKit (which is the default).
static bool UseExternalPopupMenus();
virtual GraphicsLayer* RootGraphicsLayer() = 0;
virtual void RegisterViewportLayersWithCompositor() = 0;
virtual PaintLayerCompositor* Compositor() const = 0;
virtual void DidUpdateBrowserControls() = 0;
virtual FloatSize ElasticOverscroll() const = 0;
virtual double LastFrameTimeMonotonic() const = 0;
static const WebInputEvent* CurrentInputEvent(); static const WebInputEvent* CurrentInputEvent();
}; };
} }
......
...@@ -171,14 +171,14 @@ static WebAXEvent ToWebAXEvent(AXObjectCache::AXNotification notification) { ...@@ -171,14 +171,14 @@ static WebAXEvent ToWebAXEvent(AXObjectCache::AXNotification notification) {
return static_cast<WebAXEvent>(notification); return static_cast<WebAXEvent>(notification);
} }
ChromeClientImpl::ChromeClientImpl(WebViewImpl* web_view) ChromeClientImpl::ChromeClientImpl(WebViewBase* web_view)
: web_view_(web_view), : web_view_(web_view),
cursor_overridden_(false), cursor_overridden_(false),
did_request_non_empty_tool_tip_(false) {} did_request_non_empty_tool_tip_(false) {}
ChromeClientImpl::~ChromeClientImpl() {} ChromeClientImpl::~ChromeClientImpl() {}
ChromeClientImpl* ChromeClientImpl::Create(WebViewImpl* web_view) { ChromeClientImpl* ChromeClientImpl::Create(WebViewBase* web_view) {
return new ChromeClientImpl(web_view); return new ChromeClientImpl(web_view);
} }
...@@ -187,7 +187,7 @@ void* ChromeClientImpl::WebView() const { ...@@ -187,7 +187,7 @@ void* ChromeClientImpl::WebView() const {
} }
void ChromeClientImpl::ChromeDestroyed() { void ChromeClientImpl::ChromeDestroyed() {
// Our lifetime is bound to the WebViewImpl. // Our lifetime is bound to the WebViewBase.
} }
void ChromeClientImpl::SetWindowRect(const IntRect& r, LocalFrame& frame) { void ChromeClientImpl::SetWindowRect(const IntRect& r, LocalFrame& frame) {
...@@ -910,7 +910,7 @@ bool ChromeClientImpl::HasOpenedPopup() const { ...@@ -910,7 +910,7 @@ bool ChromeClientImpl::HasOpenedPopup() const {
PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame, PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame,
HTMLSelectElement& select) { HTMLSelectElement& select) {
NotifyPopupOpeningObservers(); NotifyPopupOpeningObservers();
if (WebViewImpl::UseExternalPopupMenus()) if (WebViewBase::UseExternalPopupMenus())
return new ExternalPopupMenu(frame, select, *web_view_); return new ExternalPopupMenu(frame, select, *web_view_);
DCHECK(RuntimeEnabledFeatures::pagePopupEnabled()); DCHECK(RuntimeEnabledFeatures::pagePopupEnabled());
......
...@@ -42,13 +42,13 @@ namespace blink { ...@@ -42,13 +42,13 @@ namespace blink {
class PagePopup; class PagePopup;
class PagePopupClient; class PagePopupClient;
class WebViewImpl; class WebViewBase;
struct WebCursorInfo; struct WebCursorInfo;
// Handles window-level notifications from core on behalf of a WebView. // Handles window-level notifications from core on behalf of a WebView.
class WEB_EXPORT ChromeClientImpl final : public ChromeClient { class WEB_EXPORT ChromeClientImpl final : public ChromeClient {
public: public:
static ChromeClientImpl* Create(WebViewImpl*); static ChromeClientImpl* Create(WebViewBase*);
~ChromeClientImpl() override; ~ChromeClientImpl() override;
void* WebView() const override; void* WebView() const override;
...@@ -236,13 +236,13 @@ class WEB_EXPORT ChromeClientImpl final : public ChromeClient { ...@@ -236,13 +236,13 @@ class WEB_EXPORT ChromeClientImpl final : public ChromeClient {
WebLayerTreeView* GetWebLayerTreeView(LocalFrame*) override; WebLayerTreeView* GetWebLayerTreeView(LocalFrame*) override;
private: private:
explicit ChromeClientImpl(WebViewImpl*); explicit ChromeClientImpl(WebViewBase*);
bool IsChromeClientImpl() const override { return true; } bool IsChromeClientImpl() const override { return true; }
void SetCursor(const WebCursorInfo&, LocalFrame*); void SetCursor(const WebCursorInfo&, LocalFrame*);
WebViewImpl* web_view_; // Weak pointer. WebViewBase* web_view_; // Weak pointer.
WindowFeatures window_features_; WindowFeatures window_features_;
Vector<PopupOpeningObserver*> popup_opening_observers_; Vector<PopupOpeningObserver*> popup_opening_observers_;
Cursor last_set_mouse_cursor_for_testing_; Cursor last_set_mouse_cursor_for_testing_;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "core/dom/StyleEngine.h" #include "core/dom/StyleEngine.h"
#include "core/dom/TaskRunnerHelper.h" #include "core/dom/TaskRunnerHelper.h"
#include "core/events/ScopedEventQueue.h" #include "core/events/ScopedEventQueue.h"
#include "core/exported/WebViewBase.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/html/HTMLHRElement.h" #include "core/html/HTMLHRElement.h"
...@@ -23,9 +24,9 @@ ...@@ -23,9 +24,9 @@
#include "platform/geometry/IntRect.h" #include "platform/geometry/IntRect.h"
#include "platform/text/PlatformLocale.h" #include "platform/text/PlatformLocale.h"
#include "public/platform/Platform.h" #include "public/platform/Platform.h"
#include "public/platform/WebMouseEvent.h"
#include "public/web/WebColorChooser.h" #include "public/web/WebColorChooser.h"
#include "web/ChromeClientImpl.h" #include "web/ChromeClientImpl.h"
#include "web/WebViewImpl.h"
namespace blink { namespace blink {
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "core/dom/ContextFeatures.h" #include "core/dom/ContextFeatures.h"
#include "core/events/MessageEvent.h" #include "core/events/MessageEvent.h"
#include "core/exported/WebViewBase.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h" #include "core/frame/LocalFrame.h"
#include "core/frame/LocalFrameClient.h" #include "core/frame/LocalFrameClient.h"
...@@ -52,6 +53,7 @@ ...@@ -52,6 +53,7 @@
#include "platform/LayoutTestSupport.h" #include "platform/LayoutTestSupport.h"
#include "platform/ScriptForbiddenScope.h" #include "platform/ScriptForbiddenScope.h"
#include "platform/animation/CompositorAnimationHost.h" #include "platform/animation/CompositorAnimationHost.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/heap/Handle.h" #include "platform/heap/Handle.h"
#include "platform/instrumentation/tracing/TraceEvent.h" #include "platform/instrumentation/tracing/TraceEvent.h"
#include "platform/wtf/PtrUtil.h" #include "platform/wtf/PtrUtil.h"
...@@ -65,7 +67,6 @@ ...@@ -65,7 +67,6 @@
#include "web/WebInputEventConversion.h" #include "web/WebInputEventConversion.h"
#include "web/WebLocalFrameImpl.h" #include "web/WebLocalFrameImpl.h"
#include "web/WebSettingsImpl.h" #include "web/WebSettingsImpl.h"
#include "web/WebViewImpl.h"
namespace blink { namespace blink {
...@@ -268,7 +269,7 @@ WebPagePopupImpl::~WebPagePopupImpl() { ...@@ -268,7 +269,7 @@ WebPagePopupImpl::~WebPagePopupImpl() {
DCHECK(!page_); DCHECK(!page_);
} }
bool WebPagePopupImpl::Initialize(WebViewImpl* web_view, bool WebPagePopupImpl::Initialize(WebViewBase* web_view,
PagePopupClient* popup_client) { PagePopupClient* popup_client) {
DCHECK(web_view); DCHECK(web_view);
DCHECK(popup_client); DCHECK(popup_client);
...@@ -601,10 +602,10 @@ WebPagePopup* WebPagePopup::Create(WebWidgetClient* client) { ...@@ -601,10 +602,10 @@ WebPagePopup* WebPagePopup::Create(WebWidgetClient* client) {
CRASH(); CRASH();
// A WebPagePopupImpl instance usually has two references. // A WebPagePopupImpl instance usually has two references.
// - One owned by the instance itself. It represents the visible widget. // - One owned by the instance itself. It represents the visible widget.
// - One owned by a WebViewImpl. It's released when the WebViewImpl ask the // - One owned by a WebViewBase. It's released when the WebViewBase ask the
// WebPagePopupImpl to close. // WebPagePopupImpl to close.
// We need them because the closing operation is asynchronous and the widget // We need them because the closing operation is asynchronous and the widget
// can be closed while the WebViewImpl is unaware of it. // can be closed while the WebViewBase is unaware of it.
return AdoptRef(new WebPagePopupImpl(client)).LeakRef(); return AdoptRef(new WebPagePopupImpl(client)).LeakRef();
} }
......
...@@ -48,7 +48,7 @@ class PagePopupChromeClient; ...@@ -48,7 +48,7 @@ class PagePopupChromeClient;
class PagePopupClient; class PagePopupClient;
class WebLayerTreeView; class WebLayerTreeView;
class WebLayer; class WebLayer;
class WebViewImpl; class WebViewBase;
class LocalDOMWindow; class LocalDOMWindow;
class WebPagePopupImpl final : public WebPagePopup, class WebPagePopupImpl final : public WebPagePopup,
...@@ -60,7 +60,7 @@ class WebPagePopupImpl final : public WebPagePopup, ...@@ -60,7 +60,7 @@ class WebPagePopupImpl final : public WebPagePopup,
public: public:
~WebPagePopupImpl() override; ~WebPagePopupImpl() override;
bool Initialize(WebViewImpl*, PagePopupClient*); bool Initialize(WebViewBase*, PagePopupClient*);
void ClosePopup(); void ClosePopup();
WebWidgetClient* WidgetClient() const { return widget_client_; } WebWidgetClient* WidgetClient() const { return widget_client_; }
bool HasSamePopupClient(WebPagePopupImpl* other) { bool HasSamePopupClient(WebPagePopupImpl* other) {
...@@ -115,7 +115,7 @@ class WebPagePopupImpl final : public WebPagePopup, ...@@ -115,7 +115,7 @@ class WebPagePopupImpl final : public WebPagePopup,
WebRect WindowRectInScreen() const; WebRect WindowRectInScreen() const;
WebWidgetClient* widget_client_; WebWidgetClient* widget_client_;
WebViewImpl* web_view_; WebViewBase* web_view_;
Persistent<Page> page_; Persistent<Page> page_;
Persistent<PagePopupChromeClient> chrome_client_; Persistent<PagePopupChromeClient> chrome_client_;
PagePopupClient* popup_client_; PagePopupClient* popup_client_;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "core/dom/Fullscreen.h" #include "core/dom/Fullscreen.h"
#include "core/dom/RemoteSecurityContext.h" #include "core/dom/RemoteSecurityContext.h"
#include "core/dom/SecurityContext.h" #include "core/dom/SecurityContext.h"
#include "core/exported/WebViewBase.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/Settings.h" #include "core/frame/Settings.h"
#include "core/frame/csp/ContentSecurityPolicy.h" #include "core/frame/csp/ContentSecurityPolicy.h"
...@@ -28,7 +29,6 @@ ...@@ -28,7 +29,6 @@
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "web/RemoteFrameOwner.h" #include "web/RemoteFrameOwner.h"
#include "web/WebLocalFrameImpl.h" #include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
namespace blink { namespace blink {
...@@ -137,7 +137,7 @@ bool WebRemoteFrameImpl::HasVerticalScrollbar() const { ...@@ -137,7 +137,7 @@ bool WebRemoteFrameImpl::HasVerticalScrollbar() const {
WebView* WebRemoteFrameImpl::View() const { WebView* WebRemoteFrameImpl::View() const {
if (!GetFrame()) if (!GetFrame())
return nullptr; return nullptr;
return WebViewImpl::FromPage(GetFrame()->GetPage()); return WebViewBase::FromPage(GetFrame()->GetPage());
} }
WebDocument WebRemoteFrameImpl::GetDocument() const { WebDocument WebRemoteFrameImpl::GetDocument() const {
......
...@@ -1770,6 +1770,10 @@ Frame* WebViewImpl::FocusedCoreFrame() const { ...@@ -1770,6 +1770,10 @@ Frame* WebViewImpl::FocusedCoreFrame() const {
return page_ ? page_->GetFocusController().FocusedOrMainFrame() : nullptr; return page_ ? page_->GetFocusController().FocusedOrMainFrame() : nullptr;
} }
WebViewBase* WebViewBase::FromPage(Page* page) {
return WebViewImpl::FromPage(page);
}
WebViewImpl* WebViewImpl::FromPage(Page* page) { WebViewImpl* WebViewImpl::FromPage(Page* page) {
return page ? static_cast<WebViewImpl*>(page->GetChromeClient().WebView()) return page ? static_cast<WebViewImpl*>(page->GetChromeClient().WebView())
: nullptr; : nullptr;
...@@ -3725,6 +3729,10 @@ void WebViewImpl::MainFrameScrollOffsetChanged() { ...@@ -3725,6 +3729,10 @@ void WebViewImpl::MainFrameScrollOffsetChanged() {
dev_tools_emulator_->MainFrameScrollOrScaleChanged(); dev_tools_emulator_->MainFrameScrollOrScaleChanged();
} }
bool WebViewBase::UseExternalPopupMenus() {
return WebViewImpl::UseExternalPopupMenus();
}
bool WebViewImpl::UseExternalPopupMenus() { bool WebViewImpl::UseExternalPopupMenus() {
return g_should_use_external_popup_menus; return g_should_use_external_popup_menus;
} }
......
...@@ -268,7 +268,7 @@ class WEB_EXPORT WebViewImpl final ...@@ -268,7 +268,7 @@ class WEB_EXPORT WebViewImpl final
void ResetScaleStateImmediately() override; void ResetScaleStateImmediately() override;
HitTestResult CoreHitTestResultAt(const WebPoint&); HitTestResult CoreHitTestResultAt(const WebPoint&);
void InvalidateRect(const IntRect&); void InvalidateRect(const IntRect&) override;
void SetBaseBackgroundColor(WebColor) override; void SetBaseBackgroundColor(WebColor) override;
void SetBaseBackgroundColorOverride(WebColor) override; void SetBaseBackgroundColorOverride(WebColor) override;
...@@ -352,8 +352,8 @@ class WEB_EXPORT WebViewImpl final ...@@ -352,8 +352,8 @@ class WEB_EXPORT WebViewImpl final
// 2) Calling updateAllLifecyclePhases() is a no-op. // 2) Calling updateAllLifecyclePhases() is a no-op.
// After calling WebWidget::updateAllLifecyclePhases(), expect to get this // After calling WebWidget::updateAllLifecyclePhases(), expect to get this
// notification unless the view did not need a layout. // notification unless the view did not need a layout.
void LayoutUpdated(WebLocalFrameImpl*); void LayoutUpdated(WebLocalFrameImpl*) override;
void ResizeAfterLayout(WebLocalFrameImpl*); void ResizeAfterLayout(WebLocalFrameImpl*) override;
void DidChangeContentsSize() override; void DidChangeContentsSize() override;
void PageScaleFactorChanged() override; void PageScaleFactorChanged() override;
...@@ -370,12 +370,13 @@ class WEB_EXPORT WebViewImpl final ...@@ -370,12 +370,13 @@ class WEB_EXPORT WebViewImpl final
IntSize MaxAutoSize() const override { return max_auto_size_; } IntSize MaxAutoSize() const override { return max_auto_size_; }
void UpdateMainFrameLayoutSize() override; void UpdateMainFrameLayoutSize() override;
void UpdatePageDefinedViewportConstraints(const ViewportDescription&); void UpdatePageDefinedViewportConstraints(
const ViewportDescription&) override;
PagePopup* OpenPagePopup(PagePopupClient*); PagePopup* OpenPagePopup(PagePopupClient*) override;
void ClosePagePopup(PagePopup*); void ClosePagePopup(PagePopup*) override;
void CleanupPagePopup(); void CleanupPagePopup() override;
LocalDOMWindow* PagePopupWindow() const; LocalDOMWindow* PagePopupWindow() const override;
// Returns the input event we're currently processing. This is used in some // Returns the input event we're currently processing. This is used in some
// cases where the WebCore DOM event doesn't have the information we need. // cases where the WebCore DOM event doesn't have the information we need.
...@@ -383,9 +384,9 @@ class WEB_EXPORT WebViewImpl final ...@@ -383,9 +384,9 @@ class WEB_EXPORT WebViewImpl final
return current_input_event_; return current_input_event_;
} }
GraphicsLayer* RootGraphicsLayer(); GraphicsLayer* RootGraphicsLayer() override;
void RegisterViewportLayersWithCompositor(); void RegisterViewportLayersWithCompositor() override;
PaintLayerCompositor* Compositor() const; PaintLayerCompositor* Compositor() const override;
CompositorAnimationTimeline* LinkHighlightsTimeline() const override { CompositorAnimationTimeline* LinkHighlightsTimeline() const override {
return link_highlights_timeline_.get(); return link_highlights_timeline_.get();
} }
...@@ -393,7 +394,7 @@ class WEB_EXPORT WebViewImpl final ...@@ -393,7 +394,7 @@ class WEB_EXPORT WebViewImpl final
WebViewScheduler* Scheduler() const override; WebViewScheduler* Scheduler() const override;
void SetVisibilityState(WebPageVisibilityState, bool) override; void SetVisibilityState(WebPageVisibilityState, bool) override;
bool HasOpenedPopup() const { return page_popup_.Get(); } bool HasOpenedPopup() const override { return page_popup_.Get(); }
// Called by a full frame plugin inside this view to inform it that its // Called by a full frame plugin inside this view to inform it that its
// zoom level has been updated. The plugin should only call this function // zoom level has been updated. The plugin should only call this function
...@@ -438,9 +439,9 @@ class WEB_EXPORT WebViewImpl final ...@@ -438,9 +439,9 @@ class WEB_EXPORT WebViewImpl final
return fake_page_scale_animation_use_anchor_; return fake_page_scale_animation_use_anchor_;
} }
void EnterFullscreen(LocalFrame&); void EnterFullscreen(LocalFrame&) override;
void ExitFullscreen(LocalFrame&); void ExitFullscreen(LocalFrame&) override;
void FullscreenElementChanged(Element*, Element*); void FullscreenElementChanged(Element*, Element*) override;
// Exposed for the purpose of overriding device metrics. // Exposed for the purpose of overriding device metrics.
void SendResizeEventAndRepaint(); void SendResizeEventAndRepaint();
...@@ -476,7 +477,7 @@ class WEB_EXPORT WebViewImpl final ...@@ -476,7 +477,7 @@ class WEB_EXPORT WebViewImpl final
BrowserControls& GetBrowserControls(); BrowserControls& GetBrowserControls();
// Called anytime browser controls layout height or content offset have // Called anytime browser controls layout height or content offset have
// changed. // changed.
void DidUpdateBrowserControls(); void DidUpdateBrowserControls() override;
void ForceNextWebGLContextCreationToFail() override; void ForceNextWebGLContextCreationToFail() override;
void ForceNextDrawingBufferCreationToFail() override; void ForceNextDrawingBufferCreationToFail() override;
...@@ -489,9 +490,11 @@ class WEB_EXPORT WebViewImpl final ...@@ -489,9 +490,11 @@ class WEB_EXPORT WebViewImpl final
PageScaleConstraintsSet& GetPageScaleConstraintsSet() const override; PageScaleConstraintsSet& GetPageScaleConstraintsSet() const override;
FloatSize ElasticOverscroll() const { return elastic_overscroll_; } FloatSize ElasticOverscroll() const override { return elastic_overscroll_; }
double LastFrameTimeMonotonic() const { return last_frame_time_monotonic_; } double LastFrameTimeMonotonic() const override {
return last_frame_time_monotonic_;
}
ChromeClientImpl& ChromeClient() const { return *chrome_client_impl_.Get(); } ChromeClientImpl& ChromeClient() const { return *chrome_client_impl_.Get(); }
......
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