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;
class ContextMenuProvider;
class DevToolsEmulator;
class Frame;
class GraphicsLayer;
class Page;
class PaintLayerCompositor;
class PagePopup;
class PagePopupClient;
class PageScaleConstraintsSet;
class WebInputEvent;
class WebKeyboardEvent;
......@@ -48,6 +52,7 @@ class WebViewBase : public WebView {
virtual Page* GetPage() const = 0;
virtual Frame* FocusedCoreFrame() const = 0;
static WebViewBase* FromPage(Page*);
// 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.
......@@ -105,6 +110,41 @@ class WebViewBase : public WebView {
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();
};
}
......
......@@ -171,14 +171,14 @@ static WebAXEvent ToWebAXEvent(AXObjectCache::AXNotification notification) {
return static_cast<WebAXEvent>(notification);
}
ChromeClientImpl::ChromeClientImpl(WebViewImpl* web_view)
ChromeClientImpl::ChromeClientImpl(WebViewBase* web_view)
: web_view_(web_view),
cursor_overridden_(false),
did_request_non_empty_tool_tip_(false) {}
ChromeClientImpl::~ChromeClientImpl() {}
ChromeClientImpl* ChromeClientImpl::Create(WebViewImpl* web_view) {
ChromeClientImpl* ChromeClientImpl::Create(WebViewBase* web_view) {
return new ChromeClientImpl(web_view);
}
......@@ -187,7 +187,7 @@ void* ChromeClientImpl::WebView() const {
}
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) {
......@@ -910,7 +910,7 @@ bool ChromeClientImpl::HasOpenedPopup() const {
PopupMenu* ChromeClientImpl::OpenPopupMenu(LocalFrame& frame,
HTMLSelectElement& select) {
NotifyPopupOpeningObservers();
if (WebViewImpl::UseExternalPopupMenus())
if (WebViewBase::UseExternalPopupMenus())
return new ExternalPopupMenu(frame, select, *web_view_);
DCHECK(RuntimeEnabledFeatures::pagePopupEnabled());
......
......@@ -42,13 +42,13 @@ namespace blink {
class PagePopup;
class PagePopupClient;
class WebViewImpl;
class WebViewBase;
struct WebCursorInfo;
// Handles window-level notifications from core on behalf of a WebView.
class WEB_EXPORT ChromeClientImpl final : public ChromeClient {
public:
static ChromeClientImpl* Create(WebViewImpl*);
static ChromeClientImpl* Create(WebViewBase*);
~ChromeClientImpl() override;
void* WebView() const override;
......@@ -236,13 +236,13 @@ class WEB_EXPORT ChromeClientImpl final : public ChromeClient {
WebLayerTreeView* GetWebLayerTreeView(LocalFrame*) override;
private:
explicit ChromeClientImpl(WebViewImpl*);
explicit ChromeClientImpl(WebViewBase*);
bool IsChromeClientImpl() const override { return true; }
void SetCursor(const WebCursorInfo&, LocalFrame*);
WebViewImpl* web_view_; // Weak pointer.
WebViewBase* web_view_; // Weak pointer.
WindowFeatures window_features_;
Vector<PopupOpeningObserver*> popup_opening_observers_;
Cursor last_set_mouse_cursor_for_testing_;
......
......@@ -11,6 +11,7 @@
#include "core/dom/StyleEngine.h"
#include "core/dom/TaskRunnerHelper.h"
#include "core/events/ScopedEventQueue.h"
#include "core/exported/WebViewBase.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/html/HTMLHRElement.h"
......@@ -23,9 +24,9 @@
#include "platform/geometry/IntRect.h"
#include "platform/text/PlatformLocale.h"
#include "public/platform/Platform.h"
#include "public/platform/WebMouseEvent.h"
#include "public/web/WebColorChooser.h"
#include "web/ChromeClientImpl.h"
#include "web/WebViewImpl.h"
namespace blink {
......
......@@ -32,6 +32,7 @@
#include "core/dom/ContextFeatures.h"
#include "core/events/MessageEvent.h"
#include "core/exported/WebViewBase.h"
#include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/LocalFrameClient.h"
......@@ -52,6 +53,7 @@
#include "platform/LayoutTestSupport.h"
#include "platform/ScriptForbiddenScope.h"
#include "platform/animation/CompositorAnimationHost.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/heap/Handle.h"
#include "platform/instrumentation/tracing/TraceEvent.h"
#include "platform/wtf/PtrUtil.h"
......@@ -65,7 +67,6 @@
#include "web/WebInputEventConversion.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebSettingsImpl.h"
#include "web/WebViewImpl.h"
namespace blink {
......@@ -268,7 +269,7 @@ WebPagePopupImpl::~WebPagePopupImpl() {
DCHECK(!page_);
}
bool WebPagePopupImpl::Initialize(WebViewImpl* web_view,
bool WebPagePopupImpl::Initialize(WebViewBase* web_view,
PagePopupClient* popup_client) {
DCHECK(web_view);
DCHECK(popup_client);
......@@ -601,10 +602,10 @@ WebPagePopup* WebPagePopup::Create(WebWidgetClient* client) {
CRASH();
// A WebPagePopupImpl instance usually has two references.
// - 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.
// 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();
}
......
......@@ -48,7 +48,7 @@ class PagePopupChromeClient;
class PagePopupClient;
class WebLayerTreeView;
class WebLayer;
class WebViewImpl;
class WebViewBase;
class LocalDOMWindow;
class WebPagePopupImpl final : public WebPagePopup,
......@@ -60,7 +60,7 @@ class WebPagePopupImpl final : public WebPagePopup,
public:
~WebPagePopupImpl() override;
bool Initialize(WebViewImpl*, PagePopupClient*);
bool Initialize(WebViewBase*, PagePopupClient*);
void ClosePopup();
WebWidgetClient* WidgetClient() const { return widget_client_; }
bool HasSamePopupClient(WebPagePopupImpl* other) {
......@@ -115,7 +115,7 @@ class WebPagePopupImpl final : public WebPagePopup,
WebRect WindowRectInScreen() const;
WebWidgetClient* widget_client_;
WebViewImpl* web_view_;
WebViewBase* web_view_;
Persistent<Page> page_;
Persistent<PagePopupChromeClient> chrome_client_;
PagePopupClient* popup_client_;
......
......@@ -9,6 +9,7 @@
#include "core/dom/Fullscreen.h"
#include "core/dom/RemoteSecurityContext.h"
#include "core/dom/SecurityContext.h"
#include "core/exported/WebViewBase.h"
#include "core/frame/FrameView.h"
#include "core/frame/Settings.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
......@@ -28,7 +29,6 @@
#include "v8/include/v8.h"
#include "web/RemoteFrameOwner.h"
#include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
namespace blink {
......@@ -137,7 +137,7 @@ bool WebRemoteFrameImpl::HasVerticalScrollbar() const {
WebView* WebRemoteFrameImpl::View() const {
if (!GetFrame())
return nullptr;
return WebViewImpl::FromPage(GetFrame()->GetPage());
return WebViewBase::FromPage(GetFrame()->GetPage());
}
WebDocument WebRemoteFrameImpl::GetDocument() const {
......
......@@ -1770,6 +1770,10 @@ Frame* WebViewImpl::FocusedCoreFrame() const {
return page_ ? page_->GetFocusController().FocusedOrMainFrame() : nullptr;
}
WebViewBase* WebViewBase::FromPage(Page* page) {
return WebViewImpl::FromPage(page);
}
WebViewImpl* WebViewImpl::FromPage(Page* page) {
return page ? static_cast<WebViewImpl*>(page->GetChromeClient().WebView())
: nullptr;
......@@ -3725,6 +3729,10 @@ void WebViewImpl::MainFrameScrollOffsetChanged() {
dev_tools_emulator_->MainFrameScrollOrScaleChanged();
}
bool WebViewBase::UseExternalPopupMenus() {
return WebViewImpl::UseExternalPopupMenus();
}
bool WebViewImpl::UseExternalPopupMenus() {
return g_should_use_external_popup_menus;
}
......
......@@ -268,7 +268,7 @@ class WEB_EXPORT WebViewImpl final
void ResetScaleStateImmediately() override;
HitTestResult CoreHitTestResultAt(const WebPoint&);
void InvalidateRect(const IntRect&);
void InvalidateRect(const IntRect&) override;
void SetBaseBackgroundColor(WebColor) override;
void SetBaseBackgroundColorOverride(WebColor) override;
......@@ -352,8 +352,8 @@ class WEB_EXPORT WebViewImpl final
// 2) Calling updateAllLifecyclePhases() is a no-op.
// After calling WebWidget::updateAllLifecyclePhases(), expect to get this
// notification unless the view did not need a layout.
void LayoutUpdated(WebLocalFrameImpl*);
void ResizeAfterLayout(WebLocalFrameImpl*);
void LayoutUpdated(WebLocalFrameImpl*) override;
void ResizeAfterLayout(WebLocalFrameImpl*) override;
void DidChangeContentsSize() override;
void PageScaleFactorChanged() override;
......@@ -370,12 +370,13 @@ class WEB_EXPORT WebViewImpl final
IntSize MaxAutoSize() const override { return max_auto_size_; }
void UpdateMainFrameLayoutSize() override;
void UpdatePageDefinedViewportConstraints(const ViewportDescription&);
void UpdatePageDefinedViewportConstraints(
const ViewportDescription&) override;
PagePopup* OpenPagePopup(PagePopupClient*);
void ClosePagePopup(PagePopup*);
void CleanupPagePopup();
LocalDOMWindow* PagePopupWindow() const;
PagePopup* OpenPagePopup(PagePopupClient*) override;
void ClosePagePopup(PagePopup*) override;
void CleanupPagePopup() override;
LocalDOMWindow* PagePopupWindow() const override;
// 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.
......@@ -383,9 +384,9 @@ class WEB_EXPORT WebViewImpl final
return current_input_event_;
}
GraphicsLayer* RootGraphicsLayer();
void RegisterViewportLayersWithCompositor();
PaintLayerCompositor* Compositor() const;
GraphicsLayer* RootGraphicsLayer() override;
void RegisterViewportLayersWithCompositor() override;
PaintLayerCompositor* Compositor() const override;
CompositorAnimationTimeline* LinkHighlightsTimeline() const override {
return link_highlights_timeline_.get();
}
......@@ -393,7 +394,7 @@ class WEB_EXPORT WebViewImpl final
WebViewScheduler* Scheduler() const 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
// zoom level has been updated. The plugin should only call this function
......@@ -438,9 +439,9 @@ class WEB_EXPORT WebViewImpl final
return fake_page_scale_animation_use_anchor_;
}
void EnterFullscreen(LocalFrame&);
void ExitFullscreen(LocalFrame&);
void FullscreenElementChanged(Element*, Element*);
void EnterFullscreen(LocalFrame&) override;
void ExitFullscreen(LocalFrame&) override;
void FullscreenElementChanged(Element*, Element*) override;
// Exposed for the purpose of overriding device metrics.
void SendResizeEventAndRepaint();
......@@ -476,7 +477,7 @@ class WEB_EXPORT WebViewImpl final
BrowserControls& GetBrowserControls();
// Called anytime browser controls layout height or content offset have
// changed.
void DidUpdateBrowserControls();
void DidUpdateBrowserControls() override;
void ForceNextWebGLContextCreationToFail() override;
void ForceNextDrawingBufferCreationToFail() override;
......@@ -489,9 +490,11 @@ class WEB_EXPORT WebViewImpl final
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(); }
......
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