Commit 099e6ff1 authored by danakj's avatar danakj Committed by Commit Bot

Introduce LocalFrame::GetWidgetForLocalRoot()

For LocalFrames that are in a Page owned by a WebView, each LocalFrame
has a WebLocalFrameImpl which has a WebFrameWidget. This is always
present except very early during initialization which most code can
ignore.

For LocalFrames in non-ordinary Pages, which live without a WebView
(such as WebPagePopupImpl, devtools agent, unit tests) the LocalFrame
has an EmptyLocalFrameClient instead of WebLocalFrameImpl and thus
there are no WebFrameWidgets.

Currently parts of core/ can not get to the WebFrameWidget because
WebLocalFrameImpl is banned due to the layering mess being unresolved.
It is also difficult to find the path there as going from LocalFrame
requires:

WebLocalFrameImpl::FromFrame(local_frame)->LocalRootFrameWidget()

Since the conversion to WebLocalFrameImpl isn't a member of LocalFrame
it's very hard to find and remember this path!

We introduce here a well-lit road from LocalFrame to its WebFrameWidget
and use it throughout ChromeClientImpl.

While updating ChromeClientImpl we note that it was early-outting on
WebViewImpl::does_composite() due to a null WebWidgetClient which it
is no longer using, as it defers to the WebFrameWidget. Since
ChromeClient means we have a WebView, we also know that WebFrameWidget
does exist, and it is a better place to early out. So these are moved.

This change will allow my display-mode CL for 1060336 to find the
WebFrameWidget from code in core/css/ without changing blink layering
more dramatically. And it is a long time coming to make this path
clearer.

R=dtapuska@chromium.org

Bug: 1060336, 844547, 1058633
Change-Id: Iabb71ebf0c5ebaf7daea924425c9d3a3a2c23d54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2101847Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751064}
parent 43bcd3e4
...@@ -200,17 +200,7 @@ class PagePopupChromeClient final : public EmptyChromeClient { ...@@ -200,17 +200,7 @@ class PagePopupChromeClient final : public EmptyChromeClient {
} }
void SetTouchAction(LocalFrame* frame, TouchAction touch_action) override { void SetTouchAction(LocalFrame* frame, TouchAction touch_action) override {
DCHECK(frame); // Touch action is not used in the compositor for WebPagePopup.
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
// TODO(https://crbug.com/844547): check if we are setting touch action on
// pop up window or not.
if (!web_frame)
return;
WebFrameWidget* widget = web_frame->LocalRoot()->FrameWidget();
if (!widget)
return;
if (WebWidgetClient* client = To<WebFrameWidgetBase>(widget)->Client())
client->SetTouchAction(static_cast<WebTouchAction>(touch_action));
} }
void AttachRootLayer(scoped_refptr<cc::Layer> layer, void AttachRootLayer(scoped_refptr<cc::Layer> layer,
......
...@@ -1315,6 +1315,15 @@ LocalFrameClient* LocalFrame::Client() const { ...@@ -1315,6 +1315,15 @@ LocalFrameClient* LocalFrame::Client() const {
return static_cast<LocalFrameClient*>(Frame::Client()); return static_cast<LocalFrameClient*>(Frame::Client());
} }
FrameWidget* LocalFrame::GetWidgetForLocalRoot() {
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(this);
if (!web_frame)
return nullptr;
// This WebFrameWidgetBase upcasts to a FrameWidget which is the interface
// exposed to Blink core.
return web_frame->LocalRootFrameWidget();
}
WebContentSettingsClient* LocalFrame::GetContentSettingsClient() { WebContentSettingsClient* LocalFrame::GetContentSettingsClient() {
return Client() ? Client()->GetContentSettingsClient() : nullptr; return Client() ? Client()->GetContentSettingsClient() : nullptr;
} }
......
...@@ -89,6 +89,7 @@ class FrameConsole; ...@@ -89,6 +89,7 @@ class FrameConsole;
class FrameOverlay; class FrameOverlay;
// class FrameScheduler; // class FrameScheduler;
class FrameSelection; class FrameSelection;
class FrameWidget;
class InputMethodController; class InputMethodController;
class InspectorTraceEvents; class InspectorTraceEvents;
class CoreProbeSink; class CoreProbeSink;
...@@ -304,6 +305,13 @@ class CORE_EXPORT LocalFrame final : public Frame, ...@@ -304,6 +305,13 @@ class CORE_EXPORT LocalFrame final : public Frame,
LocalFrameClient* Client() const; LocalFrameClient* Client() const;
// Returns the widget for this frame, or from the nearest ancestor which is a
// local root. It is never null for frames in ordinary Pages (which means the
// Page is inside a WebView), except very early in initialization. For frames
// in a non-ordinary Page (without a WebView, such as in unit tests, popups,
// devtools), it will always be null.
FrameWidget* GetWidgetForLocalRoot();
WebContentSettingsClient* GetContentSettingsClient(); WebContentSettingsClient* GetContentSettingsClient();
PluginData* GetPluginData() const; PluginData* GetPluginData() const;
......
...@@ -387,19 +387,27 @@ bool WebFrameWidgetBase::ShouldRecordMainFrameMetrics() { ...@@ -387,19 +387,27 @@ bool WebFrameWidgetBase::ShouldRecordMainFrameMetrics() {
} }
void WebFrameWidgetBase::SetNeedsRecalculateRasterScales() { void WebFrameWidgetBase::SetNeedsRecalculateRasterScales() {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->SetNeedsRecalculateRasterScales(); widget_base_.LayerTreeHost()->SetNeedsRecalculateRasterScales();
} }
void WebFrameWidgetBase::SetBackgroundColor(SkColor color) { void WebFrameWidgetBase::SetBackgroundColor(SkColor color) {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->set_background_color(color); widget_base_.LayerTreeHost()->set_background_color(color);
} }
void WebFrameWidgetBase::SetOverscrollBehavior( void WebFrameWidgetBase::SetOverscrollBehavior(
const cc::OverscrollBehavior& overscroll_behavior) { const cc::OverscrollBehavior& overscroll_behavior) {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->SetOverscrollBehavior(overscroll_behavior); widget_base_.LayerTreeHost()->SetOverscrollBehavior(overscroll_behavior);
} }
void WebFrameWidgetBase::RegisterSelection(cc::LayerSelection selection) { void WebFrameWidgetBase::RegisterSelection(cc::LayerSelection selection) {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->RegisterSelection(selection); widget_base_.LayerTreeHost()->RegisterSelection(selection);
} }
...@@ -413,10 +421,14 @@ void WebFrameWidgetBase::StartPageScaleAnimation( ...@@ -413,10 +421,14 @@ void WebFrameWidgetBase::StartPageScaleAnimation(
} }
void WebFrameWidgetBase::RequestBeginMainFrameNotExpected(bool request) { void WebFrameWidgetBase::RequestBeginMainFrameNotExpected(bool request) {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->RequestBeginMainFrameNotExpected(request); widget_base_.LayerTreeHost()->RequestBeginMainFrameNotExpected(request);
} }
int WebFrameWidgetBase::GetLayerTreeId() { int WebFrameWidgetBase::GetLayerTreeId() {
if (!View()->does_composite())
return 0;
return widget_base_.LayerTreeHost()->GetId(); return widget_base_.LayerTreeHost()->GetId();
} }
...@@ -438,11 +450,15 @@ cc::EventListenerProperties WebFrameWidgetBase::EventListenerProperties( ...@@ -438,11 +450,15 @@ cc::EventListenerProperties WebFrameWidgetBase::EventListenerProperties(
} }
void WebFrameWidgetBase::StartDeferringCommits(base::TimeDelta timeout) { void WebFrameWidgetBase::StartDeferringCommits(base::TimeDelta timeout) {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->StartDeferringCommits(timeout); widget_base_.LayerTreeHost()->StartDeferringCommits(timeout);
} }
void WebFrameWidgetBase::StopDeferringCommits( void WebFrameWidgetBase::StopDeferringCommits(
cc::PaintHoldingCommitTrigger triggger) { cc::PaintHoldingCommitTrigger triggger) {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->StopDeferringCommits(triggger); widget_base_.LayerTreeHost()->StopDeferringCommits(triggger);
} }
...@@ -763,9 +779,18 @@ class ReportTimeSwapPromise : public cc::SwapPromise { ...@@ -763,9 +779,18 @@ class ReportTimeSwapPromise : public cc::SwapPromise {
DISALLOW_COPY_AND_ASSIGN(ReportTimeSwapPromise); DISALLOW_COPY_AND_ASSIGN(ReportTimeSwapPromise);
}; };
void WebFrameWidgetBase::NotifySwapAndPresentationTimeInBlink(
WebReportTimeCallback swap_time_callback,
WebReportTimeCallback presentation_time_callback) {
NotifySwapAndPresentationTime(std::move(swap_time_callback),
std::move(presentation_time_callback));
}
void WebFrameWidgetBase::NotifySwapAndPresentationTime( void WebFrameWidgetBase::NotifySwapAndPresentationTime(
WebReportTimeCallback swap_time_callback, WebReportTimeCallback swap_time_callback,
WebReportTimeCallback presentation_time_callback) { WebReportTimeCallback presentation_time_callback) {
if (!View()->does_composite())
return;
widget_base_.LayerTreeHost()->QueueSwapPromise( widget_base_.LayerTreeHost()->QueueSwapPromise(
std::make_unique<ReportTimeSwapPromise>( std::make_unique<ReportTimeSwapPromise>(
std::move(swap_time_callback), std::move(presentation_time_callback), std::move(swap_time_callback), std::move(presentation_time_callback),
......
...@@ -22,15 +22,11 @@ ...@@ -22,15 +22,11 @@
#include "third_party/blink/renderer/platform/graphics/paint/paint_image.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_image.h"
#include "third_party/blink/renderer/platform/heap/member.h" #include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/widget/frame_widget.h"
#include "third_party/blink/renderer/platform/widget/widget_base.h" #include "third_party/blink/renderer/platform/widget/widget_base.h"
#include "third_party/blink/renderer/platform/widget/widget_base_client.h" #include "third_party/blink/renderer/platform/widget/widget_base_client.h"
#include "third_party/blink/renderer/platform/wtf/casting.h" #include "third_party/blink/renderer/platform/wtf/casting.h"
namespace cc {
class AnimationHost;
class Layer;
}
namespace gfx { namespace gfx {
class Point; class Point;
class PointF; class PointF;
...@@ -51,7 +47,8 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -51,7 +47,8 @@ class CORE_EXPORT WebFrameWidgetBase
: public GarbageCollected<WebFrameWidgetBase>, : public GarbageCollected<WebFrameWidgetBase>,
public WebFrameWidget, public WebFrameWidget,
public WidgetBaseClient, public WidgetBaseClient,
public mojom::blink::FrameWidget { public mojom::blink::FrameWidget,
public FrameWidget {
public: public:
WebFrameWidgetBase( WebFrameWidgetBase(
WebWidgetClient&, WebWidgetClient&,
...@@ -65,7 +62,8 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -65,7 +62,8 @@ class CORE_EXPORT WebFrameWidgetBase
widget); widget);
~WebFrameWidgetBase() override; ~WebFrameWidgetBase() override;
WebWidgetClient* Client() const { return client_; } // Returns the WebFrame that this widget is attached to. It will be a local
// root since only local roots have a widget attached.
WebLocalFrameImpl* LocalRootImpl() const { return local_root_; } WebLocalFrameImpl* LocalRootImpl() const { return local_root_; }
// Returns the bounding box of the block type node touched by the WebPoint. // Returns the bounding box of the block type node touched by the WebPoint.
...@@ -90,13 +88,27 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -90,13 +88,27 @@ class CORE_EXPORT WebFrameWidgetBase
base::WeakPtr<PaintWorkletPaintDispatcher> EnsureCompositorPaintDispatcher( base::WeakPtr<PaintWorkletPaintDispatcher> EnsureCompositorPaintDispatcher(
scoped_refptr<base::SingleThreadTaskRunner>* paint_task_runner); scoped_refptr<base::SingleThreadTaskRunner>* paint_task_runner);
// Sets the root layer. The |layer| can be null when detaching the root layer.
virtual void SetRootLayer(scoped_refptr<cc::Layer> layer) = 0;
cc::AnimationHost* AnimationHost() const;
virtual HitTestResult CoreHitTestResultAt(const gfx::Point&) = 0; virtual HitTestResult CoreHitTestResultAt(const gfx::Point&) = 0;
// FrameWidget implementation.
WebWidgetClient* Client() const final { return client_; }
cc::AnimationHost* AnimationHost() const final;
void SetOverscrollBehavior(
const cc::OverscrollBehavior& overscroll_behavior) final;
void RequestAnimationAfterDelay(const base::TimeDelta&) final;
void RegisterSelection(cc::LayerSelection selection) final;
void RequestDecode(const cc::PaintImage&,
base::OnceCallback<void(bool)>) final;
void NotifySwapAndPresentationTimeInBlink(
WebReportTimeCallback swap_callback,
WebReportTimeCallback presentation_callback) final;
void RequestBeginMainFrameNotExpected(bool request) final;
int GetLayerTreeId() final;
void SetEventListenerProperties(cc::EventListenerClass,
cc::EventListenerProperties) final;
cc::EventListenerProperties EventListenerProperties(
cc::EventListenerClass) const final;
// WebFrameWidget implementation. // WebFrameWidget implementation.
void Close() override; void Close() override;
WebLocalFrame* LocalRoot() const override; WebLocalFrame* LocalRoot() const override;
...@@ -156,9 +168,6 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -156,9 +168,6 @@ class CORE_EXPORT WebFrameWidgetBase
// mojom::blink::FrameWidget methods. // mojom::blink::FrameWidget methods.
void DragSourceSystemDragEnded() override; void DragSourceSystemDragEnded() override;
// Image decode functionality.
void RequestDecode(const PaintImage&, base::OnceCallback<void(bool)>);
// Called when the FrameView for this Widget's local root is created. // Called when the FrameView for this Widget's local root is created.
virtual void DidCreateLocalRootView() {} virtual void DidCreateLocalRootView() {}
...@@ -168,8 +177,6 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -168,8 +177,6 @@ class CORE_EXPORT WebFrameWidgetBase
// focused frame has a different local root. // focused frame has a different local root.
LocalFrame* FocusedLocalFrameInWidget() const; LocalFrame* FocusedLocalFrameInWidget() const;
void RequestAnimationAfterDelay(const base::TimeDelta&);
virtual void Trace(Visitor*); virtual void Trace(Visitor*);
// For when the embedder itself change scales on the page (e.g. devtools) // For when the embedder itself change scales on the page (e.g. devtools)
...@@ -181,14 +188,6 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -181,14 +188,6 @@ class CORE_EXPORT WebFrameWidgetBase
// paint into another widget which has a background color of its own. // paint into another widget which has a background color of its own.
void SetBackgroundColor(SkColor color); void SetBackgroundColor(SkColor color);
// Set the browser's behavior when overscroll happens, e.g. whether to glow
// or navigate.
void SetOverscrollBehavior(const cc::OverscrollBehavior& overscroll_behavior);
// Used to update the active selection bounds. Pass a default-constructed
// LayerSelection to clear it.
void RegisterSelection(cc::LayerSelection selection);
// Starts an animation of the page scale to a target scale factor and scroll // Starts an animation of the page scale to a target scale factor and scroll
// offset. // offset.
// If use_anchor is true, destination is a point on the screen that will // If use_anchor is true, destination is a point on the screen that will
...@@ -199,27 +198,9 @@ class CORE_EXPORT WebFrameWidgetBase ...@@ -199,27 +198,9 @@ class CORE_EXPORT WebFrameWidgetBase
float new_page_scale, float new_page_scale,
base::TimeDelta duration); base::TimeDelta duration);
// Enable or disable BeginMainFrameNotExpected signals from the compositor,
// which are consumed by the blink scheduler.
void RequestBeginMainFrameNotExpected(bool request);
// A stable numeric Id for the local root's compositor. For tracing/debugging
// purposes.
int GetLayerTreeId();
// Called to update if scroll events should be sent. // Called to update if scroll events should be sent.
void SetHaveScrollEventHandlers(bool); void SetHaveScrollEventHandlers(bool);
// Set or get what event handlers exist in the document contained in the
// WebWidget in order to inform the compositor thread if it is able to handle
// an input event, or it needs to pass it to the main thread to be handled.
// The class is the type of input event, and for each class there is a
// properties defining if the compositor thread can handle the event.
void SetEventListenerProperties(cc::EventListenerClass,
cc::EventListenerProperties);
cc::EventListenerProperties EventListenerProperties(
cc::EventListenerClass) const;
// Start deferring commits to the compositor, allowing document lifecycle // Start deferring commits to the compositor, allowing document lifecycle
// updates without committing the layer tree. Commits are deferred // updates without committing the layer tree. Commits are deferred
// until at most the given |timeout| has passed. If multiple calls are made // until at most the given |timeout| has passed. If multiple calls are made
......
...@@ -136,11 +136,12 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase, ...@@ -136,11 +136,12 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase,
bool ForSubframe() const override { return true; } bool ForSubframe() const override { return true; }
void IntrinsicSizingInfoChanged(const IntrinsicSizingInfo&) override; void IntrinsicSizingInfoChanged(const IntrinsicSizingInfo&) override;
void DidCreateLocalRootView() override; void DidCreateLocalRootView() override;
void SetRootLayer(scoped_refptr<cc::Layer>) override;
HitTestResult CoreHitTestResultAt(const gfx::Point&) override; HitTestResult CoreHitTestResultAt(const gfx::Point&) override;
void ZoomToFindInPageRect(const WebRect& rect_in_root_frame) override; void ZoomToFindInPageRect(const WebRect& rect_in_root_frame) override;
// FrameWidget overrides:
void SetRootLayer(scoped_refptr<cc::Layer>) override;
// WidgetBaseClient overrides: // WidgetBaseClient overrides:
void BeginMainFrame(base::TimeTicks last_frame_time) override; void BeginMainFrame(base::TimeTicks last_frame_time) override;
......
...@@ -98,10 +98,12 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase { ...@@ -98,10 +98,12 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
// WebFrameWidgetBase overrides: // WebFrameWidgetBase overrides:
bool ForSubframe() const override { return false; } bool ForSubframe() const override { return false; }
void SetRootLayer(scoped_refptr<cc::Layer>) override;
HitTestResult CoreHitTestResultAt(const gfx::Point&) override; HitTestResult CoreHitTestResultAt(const gfx::Point&) override;
void ZoomToFindInPageRect(const WebRect& rect_in_root_frame) override; void ZoomToFindInPageRect(const WebRect& rect_in_root_frame) override;
// FrameWidget overrides:
void SetRootLayer(scoped_refptr<cc::Layer>) override;
// WidgetBaseClient overrides: // WidgetBaseClient overrides:
void BeginMainFrame(base::TimeTicks last_frame_time) override; void BeginMainFrame(base::TimeTicks last_frame_time) override;
......
...@@ -86,39 +86,33 @@ enum class GlobalObjectReusePolicy; ...@@ -86,39 +86,33 @@ enum class GlobalObjectReusePolicy;
class CORE_EXPORT EmptyChromeClient : public ChromeClient { class CORE_EXPORT EmptyChromeClient : public ChromeClient {
public: public:
~EmptyChromeClient() override = default; ~EmptyChromeClient() override = default;
void ChromeDestroyed() override {}
// ChromeClient implementation.
WebViewImpl* GetWebView() const override { return nullptr; } WebViewImpl* GetWebView() const override { return nullptr; }
void ChromeDestroyed() override {}
void SetWindowRect(const IntRect&, LocalFrame&) override {} void SetWindowRect(const IntRect&, LocalFrame&) override {}
IntRect RootWindowRect(LocalFrame&) override { return IntRect(); } IntRect RootWindowRect(LocalFrame&) override { return IntRect(); }
void Focus(LocalFrame*) override {} void Focus(LocalFrame*) override {}
bool CanTakeFocus(mojom::blink::FocusType) override { return false; } bool CanTakeFocus(mojom::blink::FocusType) override { return false; }
void TakeFocus(mojom::blink::FocusType) override {} void TakeFocus(mojom::blink::FocusType) override {}
void Show(NavigationPolicy) override {} void Show(NavigationPolicy) override {}
void DidOverscroll(const gfx::Vector2dF&, void DidOverscroll(const gfx::Vector2dF&,
const gfx::Vector2dF&, const gfx::Vector2dF&,
const gfx::PointF&, const gfx::PointF&,
const gfx::Vector2dF&) override {} const gfx::Vector2dF&) override {}
void SetOverscrollBehavior(LocalFrame& frame, void SetOverscrollBehavior(LocalFrame& frame,
const cc::OverscrollBehavior&) override {} const cc::OverscrollBehavior&) override {}
void BeginLifecycleUpdates(LocalFrame& main_frame) override {} void BeginLifecycleUpdates(LocalFrame& main_frame) override {}
void StartDeferringCommits(LocalFrame& main_frame, void StartDeferringCommits(LocalFrame& main_frame,
base::TimeDelta timeout) override {} base::TimeDelta timeout) override {}
void StopDeferringCommits(LocalFrame& main_frame, void StopDeferringCommits(LocalFrame& main_frame,
cc::PaintHoldingCommitTrigger) override {} cc::PaintHoldingCommitTrigger) override {}
void StartDragging(LocalFrame*, void StartDragging(LocalFrame*,
const WebDragData&, const WebDragData&,
WebDragOperationsMask, WebDragOperationsMask,
const SkBitmap& drag_image, const SkBitmap& drag_image,
const gfx::Point& drag_image_offset) override {} const gfx::Point& drag_image_offset) override {}
bool AcceptsLoadDrops() const override { return true; } bool AcceptsLoadDrops() const override { return true; }
bool ShouldReportDetailedMessageForSource(LocalFrame&, bool ShouldReportDetailedMessageForSource(LocalFrame&,
const String&) override { const String&) override {
return false; return false;
...@@ -130,14 +124,11 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { ...@@ -130,14 +124,11 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
unsigned, unsigned,
const String&, const String&,
const String&) override {} const String&) override {}
bool CanOpenBeforeUnloadConfirmPanel() override { return false; } bool CanOpenBeforeUnloadConfirmPanel() override { return false; }
bool OpenBeforeUnloadConfirmPanelDelegate(LocalFrame*, bool) override { bool OpenBeforeUnloadConfirmPanelDelegate(LocalFrame*, bool) override {
return true; return true;
} }
void CloseWindowSoon() override {} void CloseWindowSoon() override {}
Page* CreateWindowDelegate(LocalFrame*, Page* CreateWindowDelegate(LocalFrame*,
const FrameLoadRequest&, const FrameLoadRequest&,
const AtomicString&, const AtomicString&,
...@@ -147,7 +138,6 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { ...@@ -147,7 +138,6 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
const SessionStorageNamespaceId&) override { const SessionStorageNamespaceId&) override {
return nullptr; return nullptr;
} }
bool OpenJavaScriptAlertDelegate(LocalFrame*, const String&) override { bool OpenJavaScriptAlertDelegate(LocalFrame*, const String&) override {
return false; return false;
} }
...@@ -160,7 +150,6 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { ...@@ -160,7 +150,6 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
String&) override { String&) override {
return false; return false;
} }
bool HasOpenedPopup() const override { return false; } bool HasOpenedPopup() const override { return false; }
PopupMenu* OpenPopupMenu(LocalFrame&, HTMLSelectElement&) override; PopupMenu* OpenPopupMenu(LocalFrame&, HTMLSelectElement&) override;
PagePopup* OpenPagePopup(PagePopupClient*) override { return nullptr; } PagePopup* OpenPagePopup(PagePopupClient*) override { return nullptr; }
...@@ -172,7 +161,6 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { ...@@ -172,7 +161,6 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
void InvalidateRect(const IntRect&) override {} void InvalidateRect(const IntRect&) override {}
void ScheduleAnimation(const LocalFrameView*, void ScheduleAnimation(const LocalFrameView*,
base::TimeDelta = base::TimeDelta()) override {} base::TimeDelta = base::TimeDelta()) override {}
IntRect ViewportToScreen(const IntRect& r, IntRect ViewportToScreen(const IntRect& r,
const LocalFrameView*) const override { const LocalFrameView*) const override {
return r; return r;
...@@ -184,13 +172,9 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { ...@@ -184,13 +172,9 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
return WebScreenInfo(); return WebScreenInfo();
} }
void ContentsSizeChanged(LocalFrame*, const IntSize&) const override {} void ContentsSizeChanged(LocalFrame*, const IntSize&) const override {}
void ShowMouseOverURL(const HitTestResult&) override {} void ShowMouseOverURL(const HitTestResult&) override {}
void SetToolTip(LocalFrame&, const String&, TextDirection) override {} void SetToolTip(LocalFrame&, const String&, TextDirection) override {}
void PrintDelegate(LocalFrame*) override {} void PrintDelegate(LocalFrame*) override {}
ColorChooser* OpenColorChooser(LocalFrame*, ColorChooser* OpenColorChooser(LocalFrame*,
ColorChooserClient*, ColorChooserClient*,
const Color&) override; const Color&) override;
...@@ -199,18 +183,14 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { ...@@ -199,18 +183,14 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
DateTimeChooserClient*, DateTimeChooserClient*,
const DateTimeChooserParameters&) override; const DateTimeChooserParameters&) override;
void OpenTextDataListChooser(HTMLInputElement&) override; void OpenTextDataListChooser(HTMLInputElement&) override;
void OpenFileChooser(LocalFrame*, scoped_refptr<FileChooser>) override; void OpenFileChooser(LocalFrame*, scoped_refptr<FileChooser>) override;
void SetCursor(const ui::Cursor&, LocalFrame* local_root) override {} void SetCursor(const ui::Cursor&, LocalFrame* local_root) override {}
void SetCursorOverridden(bool) override {} void SetCursorOverridden(bool) override {}
ui::Cursor LastSetCursorForTesting() const override { ui::Cursor LastSetCursorForTesting() const override {
return PointerCursor(); return PointerCursor();
} }
void AttachRootLayer(scoped_refptr<cc::Layer>, void AttachRootLayer(scoped_refptr<cc::Layer>,
LocalFrame* local_root) override; LocalFrame* local_root) override;
void SetEventListenerProperties(LocalFrame*, void SetEventListenerProperties(LocalFrame*,
cc::EventListenerClass, cc::EventListenerClass,
cc::EventListenerProperties) override {} cc::EventListenerProperties) override {}
...@@ -224,32 +204,23 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { ...@@ -224,32 +204,23 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient {
void SetNeedsUnbufferedInputForDebugger(LocalFrame*, bool) override {} void SetNeedsUnbufferedInputForDebugger(LocalFrame*, bool) override {}
void RequestUnbufferedInputEvents(LocalFrame*) override {} void RequestUnbufferedInputEvents(LocalFrame*) override {}
void SetTouchAction(LocalFrame*, TouchAction) override {} void SetTouchAction(LocalFrame*, TouchAction) override {}
void DidAssociateFormControlsAfterLoad(LocalFrame*) override {} void DidAssociateFormControlsAfterLoad(LocalFrame*) override {}
String AcceptLanguages() override; String AcceptLanguages() override;
void RegisterPopupOpeningObserver(PopupOpeningObserver*) override {} void RegisterPopupOpeningObserver(PopupOpeningObserver*) override {}
void UnregisterPopupOpeningObserver(PopupOpeningObserver*) override {} void UnregisterPopupOpeningObserver(PopupOpeningObserver*) override {}
void NotifyPopupOpeningObservers() const override {} void NotifyPopupOpeningObservers() const override {}
void FallbackCursorModeLockCursor(LocalFrame* frame, void FallbackCursorModeLockCursor(LocalFrame* frame,
bool left, bool left,
bool right, bool right,
bool up, bool up,
bool down) override {} bool down) override {}
void FallbackCursorModeSetCursorVisibility(LocalFrame* frame, void FallbackCursorModeSetCursorVisibility(LocalFrame* frame,
bool visible) override {} bool visible) override {}
void RequestBeginMainFrameNotExpected(LocalFrame& frame, void RequestBeginMainFrameNotExpected(LocalFrame& frame,
bool request) override {} bool request) override {}
int GetLayerTreeId(LocalFrame& frame) override { return 0; } int GetLayerTreeId(LocalFrame& frame) override { return 0; }
void SetCursorForPlugin(const ui::Cursor&, LocalFrame*) override {} void SetCursorForPlugin(const ui::Cursor&, LocalFrame*) override {}
void InstallSupplements(LocalFrame&) override {} void InstallSupplements(LocalFrame&) override {}
void MainFrameScrollOffsetChanged(LocalFrame& main_frame) const override {} void MainFrameScrollOffsetChanged(LocalFrame& main_frame) const override {}
}; };
......
...@@ -116,6 +116,8 @@ class CORE_EXPORT ChromeClient : public GarbageCollected<ChromeClient> { ...@@ -116,6 +116,8 @@ class CORE_EXPORT ChromeClient : public GarbageCollected<ChromeClient> {
public: public:
virtual ~ChromeClient() = default; virtual ~ChromeClient() = default;
virtual WebViewImpl* GetWebView() const = 0;
// Converts the scalar value from window coordinates to viewport scale. // Converts the scalar value from window coordinates to viewport scale.
virtual float WindowToViewportScalar(LocalFrame*, virtual float WindowToViewportScalar(LocalFrame*,
const float value) const = 0; const float value) const = 0;
...@@ -263,8 +265,6 @@ class CORE_EXPORT ChromeClient : public GarbageCollected<ChromeClient> { ...@@ -263,8 +265,6 @@ class CORE_EXPORT ChromeClient : public GarbageCollected<ChromeClient> {
String& result); String& result);
virtual bool TabsToLinks() = 0; virtual bool TabsToLinks() = 0;
virtual WebViewImpl* GetWebView() const = 0;
virtual WebScreenInfo GetScreenInfo(LocalFrame& frame) const = 0; virtual WebScreenInfo GetScreenInfo(LocalFrame& frame) const = 0;
virtual void SetCursor(const ui::Cursor&, LocalFrame* local_root) = 0; virtual void SetCursor(const ui::Cursor&, LocalFrame* local_root) = 0;
......
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
#include "third_party/blink/renderer/platform/text/text_direction.h" #include "third_party/blink/renderer/platform/text/text_direction.h"
#include "third_party/blink/renderer/platform/web_test_support.h" #include "third_party/blink/renderer/platform/web_test_support.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h" #include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/widget/frame_widget.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h" #include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h" #include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/string_concatenate.h" #include "third_party/blink/renderer/platform/wtf/text/string_concatenate.h"
...@@ -187,8 +188,7 @@ void ChromeClientImpl::ChromeDestroyed() { ...@@ -187,8 +188,7 @@ void ChromeClientImpl::ChromeDestroyed() {
void ChromeClientImpl::SetWindowRect(const IntRect& r, LocalFrame& frame) { void ChromeClientImpl::SetWindowRect(const IntRect& r, LocalFrame& frame) {
DCHECK_EQ(&frame, web_view_->MainFrameImpl()->GetFrame()); DCHECK_EQ(&frame, web_view_->MainFrameImpl()->GetFrame());
WebWidgetClient* client = WebWidgetClient* client = frame.GetWidgetForLocalRoot()->Client();
WebLocalFrameImpl::FromFrame(frame)->FrameWidgetImpl()->Client();
client->SetWindowRect(r); client->SetWindowRect(r);
} }
...@@ -196,9 +196,7 @@ IntRect ChromeClientImpl::RootWindowRect(LocalFrame& frame) { ...@@ -196,9 +196,7 @@ IntRect ChromeClientImpl::RootWindowRect(LocalFrame& frame) {
// The WindowRect() for each WebWidgetClient will be the same rect of the top // The WindowRect() for each WebWidgetClient will be the same rect of the top
// level window. Since there is not always a WebWidgetClient attached to the // level window. Since there is not always a WebWidgetClient attached to the
// WebView, we ask the WebWidget associated with the |frame|'s local root. // WebView, we ask the WebWidget associated with the |frame|'s local root.
LocalFrame& local_root = frame.LocalFrameRoot(); WebWidgetClient* client = frame.GetWidgetForLocalRoot()->Client();
WebWidgetClient* client =
WebLocalFrameImpl::FromFrame(local_root)->FrameWidgetImpl()->Client();
return IntRect(client->WindowRect()); return IntRect(client->WindowRect());
} }
...@@ -282,9 +280,10 @@ void ChromeClientImpl::DidOverscroll( ...@@ -282,9 +280,10 @@ void ChromeClientImpl::DidOverscroll(
const gfx::Vector2dF& accumulated_overscroll, const gfx::Vector2dF& accumulated_overscroll,
const gfx::PointF& position_in_viewport, const gfx::PointF& position_in_viewport,
const gfx::Vector2dF& velocity_in_viewport) { const gfx::Vector2dF& velocity_in_viewport) {
// WebWidgetClient can be null when not compositing, and this behaviour only
// applies when compositing is enabled.
if (!web_view_->does_composite()) if (!web_view_->does_composite())
return; return;
// TODO(darin): Change caller to pass LocalFrame. // TODO(darin): Change caller to pass LocalFrame.
DCHECK(web_view_->MainFrameImpl()); DCHECK(web_view_->MainFrameImpl());
web_view_->MainFrameImpl()->FrameWidgetImpl()->Client()->DidOverscroll( web_view_->MainFrameImpl()->FrameWidgetImpl()->Client()->DidOverscroll(
...@@ -299,21 +298,17 @@ void ChromeClientImpl::InjectGestureScrollEvent( ...@@ -299,21 +298,17 @@ void ChromeClientImpl::InjectGestureScrollEvent(
ScrollGranularity granularity, ScrollGranularity granularity,
CompositorElementId scrollable_area_element_id, CompositorElementId scrollable_area_element_id,
WebInputEvent::Type injected_type) { WebInputEvent::Type injected_type) {
WebFrameWidgetBase* widget = WebWidgetClient* client = local_frame.GetWidgetForLocalRoot()->Client();
WebLocalFrameImpl::FromFrame(&local_frame)->LocalRootFrameWidget(); client->InjectGestureScrollEvent(device, delta, granularity,
widget->Client()->InjectGestureScrollEvent( scrollable_area_element_id, injected_type);
device, delta, granularity, scrollable_area_element_id, injected_type);
} }
void ChromeClientImpl::SetOverscrollBehavior( void ChromeClientImpl::SetOverscrollBehavior(
LocalFrame& main_frame, LocalFrame& main_frame,
const cc::OverscrollBehavior& overscroll_behavior) { const cc::OverscrollBehavior& overscroll_behavior) {
DCHECK(main_frame.IsMainFrame()); DCHECK(main_frame.IsMainFrame());
if (!web_view_->does_composite()) main_frame.GetWidgetForLocalRoot()->SetOverscrollBehavior(
return; overscroll_behavior);
WebLocalFrameImpl::FromFrame(main_frame)
->FrameWidgetImpl()
->SetOverscrollBehavior(overscroll_behavior);
} }
void ChromeClientImpl::Show(NavigationPolicy navigation_policy) { void ChromeClientImpl::Show(NavigationPolicy navigation_policy) {
...@@ -412,14 +407,12 @@ void ChromeClientImpl::InvalidateRect(const IntRect& update_rect) { ...@@ -412,14 +407,12 @@ void ChromeClientImpl::InvalidateRect(const IntRect& update_rect) {
void ChromeClientImpl::ScheduleAnimation(const LocalFrameView* frame_view, void ChromeClientImpl::ScheduleAnimation(const LocalFrameView* frame_view,
base::TimeDelta delay) { base::TimeDelta delay) {
LocalFrame& frame = frame_view->GetFrame(); LocalFrame& frame = frame_view->GetFrame();
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
DCHECK(web_frame);
// If the frame is still being created, it might not yet have a WebWidget. // If the frame is still being created, it might not yet have a WebWidget.
// TODO(dcheng): Is this the right thing to do? Is there a way to avoid having // TODO(dcheng): Is this the right thing to do? Is there a way to avoid having
// a local frame root that doesn't have a WebWidget? During initialization // a local frame root that doesn't have a WebWidget? During initialization
// there is no content to draw so this call serves no purpose. Maybe the // there is no content to draw so this call serves no purpose. Maybe the
// WebFrameWidget needs to be initialized before initializing the core frame? // WebFrameWidget needs to be initialized before initializing the core frame?
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget(); FrameWidget* widget = frame.GetWidgetForLocalRoot();
if (widget) { if (widget) {
if (delay.is_zero()) { if (delay.is_zero()) {
// LocalRootFrameWidget() is a WebWidget, its client is the embedder. // LocalRootFrameWidget() is a WebWidget, its client is the embedder.
...@@ -438,9 +431,7 @@ IntRect ChromeClientImpl::ViewportToScreen( ...@@ -438,9 +431,7 @@ IntRect ChromeClientImpl::ViewportToScreen(
LocalFrame& frame = frame_view->GetFrame(); LocalFrame& frame = frame_view->GetFrame();
WebWidgetClient* client = WebWidgetClient* client = frame.GetWidgetForLocalRoot()->Client();
WebLocalFrameImpl::FromFrame(frame)->LocalRootFrameWidget()->Client();
// TODO(dcheng): Is this null check needed? // TODO(dcheng): Is this null check needed?
if (client) { if (client) {
client->ConvertViewportToWindow(&screen_rect); client->ConvertViewportToWindow(&screen_rect);
...@@ -464,24 +455,19 @@ float ChromeClientImpl::WindowToViewportScalar(LocalFrame* frame, ...@@ -464,24 +455,19 @@ float ChromeClientImpl::WindowToViewportScalar(LocalFrame* frame,
} }
WebFloatRect viewport_rect(0, 0, scalar_value, 0); WebFloatRect viewport_rect(0, 0, scalar_value, 0);
WebLocalFrameImpl::FromFrame(frame) frame->GetWidgetForLocalRoot()->Client()->ConvertWindowToViewport(
->LocalRootFrameWidget() &viewport_rect);
->Client()
->ConvertWindowToViewport(&viewport_rect);
return viewport_rect.width; return viewport_rect.width;
} }
void ChromeClientImpl::WindowToViewportRect(LocalFrame& frame, void ChromeClientImpl::WindowToViewportRect(LocalFrame& frame,
WebFloatRect* viewport_rect) const { WebFloatRect* viewport_rect) const {
WebLocalFrameImpl::FromFrame(frame) frame.GetWidgetForLocalRoot()->Client()->ConvertWindowToViewport(
->LocalRootFrameWidget() viewport_rect);
->Client()
->ConvertWindowToViewport(viewport_rect);
} }
WebScreenInfo ChromeClientImpl::GetScreenInfo(LocalFrame& frame) const { WebScreenInfo ChromeClientImpl::GetScreenInfo(LocalFrame& frame) const {
WebWidgetClient* client = WebWidgetClient* client = frame.GetWidgetForLocalRoot()->Client();
WebLocalFrameImpl::FromFrame(frame)->LocalRootFrameWidget()->Client();
DCHECK(client); DCHECK(client);
return client->GetScreenInfo(); return client->GetScreenInfo();
} }
...@@ -490,8 +476,7 @@ void ChromeClientImpl::OverrideVisibleRectForMainFrame( ...@@ -490,8 +476,7 @@ void ChromeClientImpl::OverrideVisibleRectForMainFrame(
LocalFrame& frame, LocalFrame& frame,
IntRect* visible_rect) const { IntRect* visible_rect) const {
DCHECK(frame.IsMainFrame()); DCHECK(frame.IsMainFrame());
WebWidgetClient* client = WebWidgetClient* client = frame.GetWidgetForLocalRoot()->Client();
WebLocalFrameImpl::FromFrame(frame)->FrameWidgetImpl()->Client();
return web_view_->GetDevToolsEmulator()->OverrideVisibleRect( return web_view_->GetDevToolsEmulator()->OverrideVisibleRect(
IntRect(client->ViewRect()).Size(), visible_rect); IntRect(client->ViewRect()).Size(), visible_rect);
} }
...@@ -727,8 +712,7 @@ void ChromeClientImpl::SetCursorInternal(const ui::Cursor& cursor, ...@@ -727,8 +712,7 @@ void ChromeClientImpl::SetCursorInternal(const ui::Cursor& cursor,
#endif #endif
// TODO(dcheng): Why is this null check necessary? // TODO(dcheng): Why is this null check necessary?
if (WebFrameWidgetBase* widget = if (FrameWidget* widget = local_frame->GetWidgetForLocalRoot())
WebLocalFrameImpl::FromFrame(local_frame)->LocalRootFrameWidget())
widget->Client()->DidChangeCursor(cursor); widget->Client()->DidChangeCursor(cursor);
} }
...@@ -743,21 +727,21 @@ void ChromeClientImpl::SetCursorOverridden(bool overridden) { ...@@ -743,21 +727,21 @@ void ChromeClientImpl::SetCursorOverridden(bool overridden) {
void ChromeClientImpl::AutoscrollStart(const gfx::PointF& viewport_point, void ChromeClientImpl::AutoscrollStart(const gfx::PointF& viewport_point,
LocalFrame* local_frame) { LocalFrame* local_frame) {
if (WebFrameWidgetBase* widget = // TODO(dcheng): Why is this null check necessary?
WebLocalFrameImpl::FromFrame(local_frame)->LocalRootFrameWidget()) if (FrameWidget* widget = local_frame->GetWidgetForLocalRoot())
widget->Client()->AutoscrollStart(viewport_point); widget->Client()->AutoscrollStart(viewport_point);
} }
void ChromeClientImpl::AutoscrollFling(const gfx::Vector2dF& velocity, void ChromeClientImpl::AutoscrollFling(const gfx::Vector2dF& velocity,
LocalFrame* local_frame) { LocalFrame* local_frame) {
if (WebFrameWidgetBase* widget = // TODO(dcheng): Why is this null check necessary?
WebLocalFrameImpl::FromFrame(local_frame)->LocalRootFrameWidget()) if (FrameWidget* widget = local_frame->GetWidgetForLocalRoot())
widget->Client()->AutoscrollFling(velocity); widget->Client()->AutoscrollFling(velocity);
} }
void ChromeClientImpl::AutoscrollEnd(LocalFrame* local_frame) { void ChromeClientImpl::AutoscrollEnd(LocalFrame* local_frame) {
if (WebFrameWidgetBase* widget = // TODO(dcheng): Why is this null check necessary?
WebLocalFrameImpl::FromFrame(local_frame)->LocalRootFrameWidget()) if (FrameWidget* widget = local_frame->GetWidgetForLocalRoot())
widget->Client()->AutoscrollEnd(); widget->Client()->AutoscrollEnd();
} }
...@@ -767,25 +751,22 @@ String ChromeClientImpl::AcceptLanguages() { ...@@ -767,25 +751,22 @@ String ChromeClientImpl::AcceptLanguages() {
void ChromeClientImpl::AttachRootLayer(scoped_refptr<cc::Layer> root_layer, void ChromeClientImpl::AttachRootLayer(scoped_refptr<cc::Layer> root_layer,
LocalFrame* local_frame) { LocalFrame* local_frame) {
// TODO(dcheng): This seems wrong. Non-local roots shouldn't be calling this DCHECK(local_frame->IsLocalRoot());
// function.
WebLocalFrameImpl* web_frame =
WebLocalFrameImpl::FromFrame(local_frame)->LocalRoot();
DCHECK(WebLocalFrameImpl::FromFrame(local_frame) == web_frame);
// This method is called during Document::Shutdown. For some tests it is // This method is called during Document::Shutdown with a null |root_layer|,
// possible that this a FrameWidget was never created for those. // but a widget may have never been created in some tests, so it would also
DCHECK(web_frame->FrameWidget() || !root_layer); // be null (we don't call here with a valid |root_layer| in those tests).
if (web_frame->FrameWidgetImpl()) FrameWidget* widget = local_frame->GetWidgetForLocalRoot();
web_frame->FrameWidgetImpl()->SetRootLayer(std::move(root_layer)); DCHECK(widget || !root_layer);
if (widget)
widget->SetRootLayer(std::move(root_layer));
} }
void ChromeClientImpl::AttachCompositorAnimationTimeline( void ChromeClientImpl::AttachCompositorAnimationTimeline(
CompositorAnimationTimeline* compositor_timeline, CompositorAnimationTimeline* compositor_timeline,
LocalFrame* local_frame) { LocalFrame* local_frame) {
DCHECK(Platform::Current()->IsThreadedAnimationEnabled()); DCHECK(Platform::Current()->IsThreadedAnimationEnabled());
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(local_frame); FrameWidget* widget = local_frame->GetWidgetForLocalRoot();
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
DCHECK(widget); DCHECK(widget);
widget->AnimationHost()->AddAnimationTimeline( widget->AnimationHost()->AddAnimationTimeline(
compositor_timeline->GetAnimationTimeline()); compositor_timeline->GetAnimationTimeline());
...@@ -795,8 +776,7 @@ void ChromeClientImpl::DetachCompositorAnimationTimeline( ...@@ -795,8 +776,7 @@ void ChromeClientImpl::DetachCompositorAnimationTimeline(
CompositorAnimationTimeline* compositor_timeline, CompositorAnimationTimeline* compositor_timeline,
LocalFrame* local_frame) { LocalFrame* local_frame) {
DCHECK(Platform::Current()->IsThreadedAnimationEnabled()); DCHECK(Platform::Current()->IsThreadedAnimationEnabled());
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(local_frame); FrameWidget* widget = local_frame->GetWidgetForLocalRoot();
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
DCHECK(widget); DCHECK(widget);
widget->AnimationHost()->RemoveAnimationTimeline( widget->AnimationHost()->RemoveAnimationTimeline(
compositor_timeline->GetAnimationTimeline()); compositor_timeline->GetAnimationTimeline());
...@@ -823,21 +803,13 @@ void ChromeClientImpl::AnimateDoubleTapZoom(const gfx::Point& point, ...@@ -823,21 +803,13 @@ void ChromeClientImpl::AnimateDoubleTapZoom(const gfx::Point& point,
} }
void ChromeClientImpl::ClearLayerSelection(LocalFrame* frame) { void ChromeClientImpl::ClearLayerSelection(LocalFrame* frame) {
if (!web_view_->does_composite()) frame->GetWidgetForLocalRoot()->RegisterSelection(cc::LayerSelection());
return;
WebLocalFrameImpl::FromFrame(frame)
->LocalRootFrameWidget()
->RegisterSelection(cc::LayerSelection());
} }
void ChromeClientImpl::UpdateLayerSelection( void ChromeClientImpl::UpdateLayerSelection(
LocalFrame* frame, LocalFrame* frame,
const cc::LayerSelection& selection) { const cc::LayerSelection& selection) {
if (!web_view_->does_composite()) frame->GetWidgetForLocalRoot()->RegisterSelection(selection);
return;
WebLocalFrameImpl::FromFrame(frame)
->LocalRootFrameWidget()
->RegisterSelection(selection);
} }
bool ChromeClientImpl::HasOpenedPopup() const { bool ChromeClientImpl::HasOpenedPopup() const {
...@@ -914,28 +886,23 @@ bool ChromeClientImpl::ShouldOpenUIElementDuringPageDismissal( ...@@ -914,28 +886,23 @@ bool ChromeClientImpl::ShouldOpenUIElementDuringPageDismissal(
} }
viz::FrameSinkId ChromeClientImpl::GetFrameSinkId(LocalFrame* frame) { viz::FrameSinkId ChromeClientImpl::GetFrameSinkId(LocalFrame* frame) {
WebFrameWidgetBase* widget = WebWidgetClient* client = frame->GetWidgetForLocalRoot()->Client();
WebLocalFrameImpl::FromFrame(frame)->LocalRootFrameWidget();
WebWidgetClient* client = widget->Client();
return client->GetFrameSinkId(); return client->GetFrameSinkId();
} }
void ChromeClientImpl::RequestDecode(LocalFrame* frame, void ChromeClientImpl::RequestDecode(LocalFrame* frame,
const PaintImage& image, const PaintImage& image,
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> callback) {
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame); FrameWidget* widget = frame->GetWidgetForLocalRoot();
web_frame->LocalRootFrameWidget()->RequestDecode(image, std::move(callback)); widget->RequestDecode(image, std::move(callback));
} }
void ChromeClientImpl::NotifySwapTime(LocalFrame& frame, void ChromeClientImpl::NotifySwapTime(LocalFrame& frame,
ReportTimeCallback callback) { ReportTimeCallback callback) {
if (!web_view_->does_composite()) FrameWidget* widget = frame.GetWidgetForLocalRoot();
return;
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
if (!widget) if (!widget)
return; return;
widget->NotifySwapAndPresentationTime( widget->NotifySwapAndPresentationTimeInBlink(
base::NullCallback(), ConvertToBaseOnceCallback(std::move(callback))); base::NullCallback(), ConvertToBaseOnceCallback(std::move(callback)));
} }
...@@ -944,47 +911,29 @@ void ChromeClientImpl::FallbackCursorModeLockCursor(LocalFrame* frame, ...@@ -944,47 +911,29 @@ void ChromeClientImpl::FallbackCursorModeLockCursor(LocalFrame* frame,
bool right, bool right,
bool up, bool up,
bool down) { bool down) {
DCHECK(frame); FrameWidget* widget = frame->GetWidgetForLocalRoot();
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
if (!widget) if (!widget)
return; return;
if (WebWidgetClient* client = widget->Client()) if (WebWidgetClient* client = widget->Client())
client->FallbackCursorModeLockCursor(left, right, up, down); client->FallbackCursorModeLockCursor(left, right, up, down);
} }
void ChromeClientImpl::FallbackCursorModeSetCursorVisibility(LocalFrame* frame, void ChromeClientImpl::FallbackCursorModeSetCursorVisibility(LocalFrame* frame,
bool visible) { bool visible) {
DCHECK(frame); FrameWidget* widget = frame->GetWidgetForLocalRoot();
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
if (!widget) if (!widget)
return; return;
if (WebWidgetClient* client = widget->Client()) if (WebWidgetClient* client = widget->Client())
client->FallbackCursorModeSetCursorVisibility(visible); client->FallbackCursorModeSetCursorVisibility(visible);
} }
void ChromeClientImpl::RequestBeginMainFrameNotExpected(LocalFrame& frame, void ChromeClientImpl::RequestBeginMainFrameNotExpected(LocalFrame& frame,
bool request) { bool request) {
// WebWidgetClient can be null when not compositing, and this behaviour only frame.GetWidgetForLocalRoot()->RequestBeginMainFrameNotExpected(request);
// applies when compositing is enabled.
if (!web_view_->does_composite())
return;
WebLocalFrameImpl::FromFrame(frame)
->LocalRootFrameWidget()
->RequestBeginMainFrameNotExpected(request);
} }
int ChromeClientImpl::GetLayerTreeId(LocalFrame& frame) { int ChromeClientImpl::GetLayerTreeId(LocalFrame& frame) {
// WebWidgetClient can be null when not compositing, and this method is only return frame.GetWidgetForLocalRoot()->GetLayerTreeId();
// useful when compositing is enabled.
if (!web_view_->does_composite())
return 0;
return WebLocalFrameImpl::FromFrame(frame)
->LocalRootFrameWidget()
->GetLayerTreeId();
} }
void ChromeClientImpl::SetEventListenerProperties( void ChromeClientImpl::SetEventListenerProperties(
...@@ -1002,12 +951,12 @@ void ChromeClientImpl::SetEventListenerProperties( ...@@ -1002,12 +951,12 @@ void ChromeClientImpl::SetEventListenerProperties(
if (!frame) if (!frame)
return; return;
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame); FrameWidget* widget = frame->GetWidgetForLocalRoot();
WebFrameWidgetBase* widget = web_frame->LocalRootFrameWidget();
// TODO(https://crbug.com/820787): When creating a local root, the widget // TODO(https://crbug.com/820787): When creating a local root, the widget
// won't be set yet. While notifications in this case are technically // won't be set yet. While notifications in this case are technically
// redundant, it adds an awkward special case. // redundant, it adds an awkward special case.
if (!widget) { if (!widget) {
WebLocalFrameImpl* web_frame = WebLocalFrameImpl::FromFrame(frame);
if (web_frame->IsProvisional()) { if (web_frame->IsProvisional()) {
// If we hit a provisional frame, we expect it to be during initialization // If we hit a provisional frame, we expect it to be during initialization
// in which case the |properties| should be 'nothing'. // in which case the |properties| should be 'nothing'.
...@@ -1016,9 +965,9 @@ void ChromeClientImpl::SetEventListenerProperties( ...@@ -1016,9 +965,9 @@ void ChromeClientImpl::SetEventListenerProperties(
return; return;
} }
WebWidgetClient* client = widget->Client();
widget->SetEventListenerProperties(event_class, properties); widget->SetEventListenerProperties(event_class, properties);
WebWidgetClient* client = widget->Client();
if (event_class == cc::EventListenerClass::kTouchStartOrMove || if (event_class == cc::EventListenerClass::kTouchStartOrMove ||
event_class == cc::EventListenerClass::kTouchEndOrCancel) { event_class == cc::EventListenerClass::kTouchEndOrCancel) {
client->SetHasTouchEventHandlers( client->SetHasTouchEventHandlers(
...@@ -1055,10 +1004,6 @@ void ChromeClientImpl::BeginLifecycleUpdates(LocalFrame& main_frame) { ...@@ -1055,10 +1004,6 @@ void ChromeClientImpl::BeginLifecycleUpdates(LocalFrame& main_frame) {
void ChromeClientImpl::StartDeferringCommits(LocalFrame& main_frame, void ChromeClientImpl::StartDeferringCommits(LocalFrame& main_frame,
base::TimeDelta timeout) { base::TimeDelta timeout) {
DCHECK(main_frame.IsMainFrame()); DCHECK(main_frame.IsMainFrame());
// WebWidgetClient can be null when not compositing, and deferring commits
// only applies with a compositor.
if (!web_view_->does_composite())
return;
WebLocalFrameImpl::FromFrame(main_frame) WebLocalFrameImpl::FromFrame(main_frame)
->FrameWidgetImpl() ->FrameWidgetImpl()
->StartDeferringCommits(timeout); ->StartDeferringCommits(timeout);
...@@ -1068,10 +1013,6 @@ void ChromeClientImpl::StopDeferringCommits( ...@@ -1068,10 +1013,6 @@ void ChromeClientImpl::StopDeferringCommits(
LocalFrame& main_frame, LocalFrame& main_frame,
cc::PaintHoldingCommitTrigger trigger) { cc::PaintHoldingCommitTrigger trigger) {
DCHECK(main_frame.IsMainFrame()); DCHECK(main_frame.IsMainFrame());
// WebWidgetClient can be null when not compositing, and deferring commits
// only applies with a compositor.
if (!web_view_->does_composite())
return;
WebLocalFrameImpl::FromFrame(main_frame) WebLocalFrameImpl::FromFrame(main_frame)
->FrameWidgetImpl() ->FrameWidgetImpl()
->StopDeferringCommits(trigger); ->StopDeferringCommits(trigger);
......
...@@ -63,9 +63,8 @@ class CORE_EXPORT ChromeClientImpl final : public ChromeClient { ...@@ -63,9 +63,8 @@ class CORE_EXPORT ChromeClientImpl final : public ChromeClient {
~ChromeClientImpl() override; ~ChromeClientImpl() override;
void Trace(Visitor* visitor) override; void Trace(Visitor* visitor) override;
WebViewImpl* GetWebView() const override;
// ChromeClient methods: // ChromeClient methods:
WebViewImpl* GetWebView() const override;
void ChromeDestroyed() override; void ChromeDestroyed() override;
void SetWindowRect(const IntRect&, LocalFrame&) override; void SetWindowRect(const IntRect&, LocalFrame&) override;
IntRect RootWindowRect(LocalFrame&) override; IntRect RootWindowRect(LocalFrame&) override;
......
...@@ -1442,6 +1442,8 @@ jumbo_component("platform") { ...@@ -1442,6 +1442,8 @@ jumbo_component("platform") {
"webrtc/webrtc_video_frame_adapter.h", "webrtc/webrtc_video_frame_adapter.h",
"webrtc/webrtc_video_utils.cc", "webrtc/webrtc_video_utils.cc",
"webrtc/webrtc_video_utils.h", "webrtc/webrtc_video_utils.h",
"widget/frame_widget.cc",
"widget/frame_widget.h",
"widget/widget_base.cc", "widget/widget_base.cc",
"widget/widget_base.h", "widget/widget_base.h",
"widget/widget_base_client.h", "widget/widget_base_client.h",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/platform/widget/frame_widget.h"
namespace blink {
FrameWidget::~FrameWidget() = default;
} // namespace blink
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_WIDGET_FRAME_WIDGET_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_WIDGET_FRAME_WIDGET_H_
#include "third_party/blink/public/web/web_swap_result.h"
#include "third_party/blink/public/web/web_widget_client.h"
#include "third_party/blink/renderer/platform/platform_export.h"
namespace cc {
class AnimationHost;
class Layer;
class PaintImage;
} // namespace cc
namespace blink {
// In interface exposed within Blink from local root frames that provides
// local-root specific things related to compositing and input.
class PLATFORM_EXPORT FrameWidget {
public:
virtual ~FrameWidget();
// Returns the WebWidgetClient, which is implemented outside of blink.
virtual WebWidgetClient* Client() const = 0;
// Returns the compositors's AnimationHost for the widget.
virtual cc::AnimationHost* AnimationHost() const = 0;
// Set the browser's behavior when overscroll happens, e.g. whether to glow
// or navigate.
virtual void SetOverscrollBehavior(
const cc::OverscrollBehavior& overscroll_behavior) = 0;
// Posts a task with the given delay, then calls ScheduleAnimation() on the
// Client().
virtual void RequestAnimationAfterDelay(const base::TimeDelta&) = 0;
// Sets the root layer. The |layer| can be null when detaching the root layer.
virtual void SetRootLayer(scoped_refptr<cc::Layer> layer) = 0;
// Used to update the active selection bounds. Pass a default-constructed
// LayerSelection to clear it.
virtual void RegisterSelection(cc::LayerSelection selection) = 0;
// Image decode functionality.
virtual void RequestDecode(const cc::PaintImage&,
base::OnceCallback<void(bool)>) = 0;
// Forwards to WebFrameWidget::NotifySwapAndPresentationTime().
// The |callback| will be fired when the corresponding renderer frame is
// submitted (still called "swapped") to the display compositor (either with
// DidSwap or DidNotSwap).
virtual void NotifySwapAndPresentationTimeInBlink(
WebReportTimeCallback swap_callback,
WebReportTimeCallback presentation_callback) = 0;
// Enable or disable BeginMainFrameNotExpected signals from the compositor,
// which are consumed by the blink scheduler.
virtual void RequestBeginMainFrameNotExpected(bool request) = 0;
// A stable numeric Id for the local root's compositor. For tracing/debugging
// purposes.
virtual int GetLayerTreeId() = 0;
// Set or get what event handlers exist in the document contained in the
// WebWidget in order to inform the compositor thread if it is able to handle
// an input event, or it needs to pass it to the main thread to be handled.
// The class is the type of input event, and for each class there is a
// properties defining if the compositor thread can handle the event.
virtual void SetEventListenerProperties(cc::EventListenerClass,
cc::EventListenerProperties) = 0;
virtual cc::EventListenerProperties EventListenerProperties(
cc::EventListenerClass) const = 0;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_WIDGET_FRAME_WIDGET_H_
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