Commit c1895d6c authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Move SetRootLayer into base.

Collapse root layer implementation into a common implementation. One
subtle difference is that the root layer on the child root frames is now
set to null during destruction, I believe this is more correct.

BUG=1097816

Change-Id: I5556680d0170280918a21027ff602c37b16d5598
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542757
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatardanakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828939}
parent 72797844
......@@ -3431,6 +3431,10 @@ bool WebViewImpl::TabsToLinks() const {
}
void WebViewImpl::DidChangeRootLayer(bool root_layer_exists) {
// The Layer is removed when the main frame's `Document` changes. It also is
// removed when the whole `LocalFrame` goes away, in which case we don't
// need to DeferMainFrameUpdate() as we will do so if a local MainFrame is
// attached in the future.
if (!MainFrameImpl()) {
DCHECK(!root_layer_exists);
return;
......
......@@ -498,6 +498,9 @@ class CORE_EXPORT WebViewImpl final : public WebView,
// code should eventually move out of WebView into somewhere else.
void ApplyViewportChanges(const ApplyViewportChangesArgs& args);
// Indication that the root layer for the main frame widget has changed.
void DidChangeRootLayer(bool root_layer_exists);
// This method is used for testing.
// Resizes the unscaled (page scale = 1.0) visual viewport. Normally the
// unscaled visual viewport is the same size as the main frame. The passed
......@@ -596,8 +599,6 @@ class CORE_EXPORT WebViewImpl final : public WebView,
float DeviceScaleFactor() const;
void DidChangeRootLayer(bool root_layer_exists);
LocalFrame* FocusedLocalFrameInWidget() const;
// Clear focus and text input state of the page. If there was a focused
......
......@@ -2174,6 +2174,33 @@ void WebFrameWidgetBase::RequestAnimationAfterDelay(
}
}
void WebFrameWidgetBase::SetRootLayer(scoped_refptr<cc::Layer> layer) {
if (!View()->does_composite()) {
DCHECK(ForMainFrame());
DCHECK(!layer);
return;
}
// Set up some initial state before we are setting the layer.
if (ForSubframe() && layer) {
// Child local roots will always have a transparent background color.
widget_base_->LayerTreeHost()->set_background_color(SK_ColorTRANSPARENT);
// Pass the limits even though this is for subframes, as the limits will
// be needed in setting the raster scale.
SetPageScaleStateAndLimits(1.f, false /* is_pinch_gesture_active */,
View()->MinimumPageScaleFactor(),
View()->MaximumPageScaleFactor());
}
bool root_layer_exists = !!layer;
widget_base_->LayerTreeHost()->SetRootLayer(std::move(layer));
// Notify the WebView that we did set a layer.
if (ForMainFrame()) {
View()->DidChangeRootLayer(root_layer_exists);
}
}
void WebFrameWidgetBase::RequestAnimationAfterDelayTimerFired(TimerBase*) {
if (client_)
client_->ScheduleAnimation();
......
......@@ -147,6 +147,7 @@ class CORE_EXPORT WebFrameWidgetBase
void SetOverscrollBehavior(
const cc::OverscrollBehavior& overscroll_behavior) final;
void RequestAnimationAfterDelay(const base::TimeDelta&) final;
void SetRootLayer(scoped_refptr<cc::Layer>) override;
void RegisterSelection(cc::LayerSelection selection) final;
void RequestDecode(const cc::PaintImage&,
base::OnceCallback<void(bool)>) final;
......
......@@ -454,25 +454,6 @@ PaintLayerCompositor* WebFrameWidgetImpl::Compositor() const {
return frame->GetDocument()->GetLayoutView()->Compositor();
}
void WebFrameWidgetImpl::SetRootLayer(scoped_refptr<cc::Layer> layer) {
if (!layer) {
// This notifies the WebFrameWidgetImpl that its LocalFrame tree is being
// detached.
return;
}
// WebFrameWidgetImpl is used for child frames, which always have a
// transparent background color.
widget_base_->LayerTreeHost()->set_background_color(SK_ColorTRANSPARENT);
// Pass the limits even though this is for subframes, as the limits will
// be needed in setting the raster scale.
SetPageScaleStateAndLimits(1.f, false /* is_pinch_gesture_active */,
View()->MinimumPageScaleFactor(),
View()->MaximumPageScaleFactor());
widget_base_->LayerTreeHost()->SetRootLayer(layer);
}
void WebFrameWidgetImpl::DidCreateLocalRootView() {
// If this WebWidget still hasn't received its size from the embedder, block
// the parser. This is necessary, because the parser can cause layout to
......
......@@ -50,10 +50,6 @@
#include "third_party/blink/renderer/platform/heap/self_keep_alive.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
namespace cc {
class Layer;
}
namespace blink {
class Element;
class PaintLayerCompositor;
......@@ -101,7 +97,6 @@ class WebFrameWidgetImpl final : public WebFrameWidgetBase {
const VisualProperties& visual_properties) override;
// FrameWidget overrides:
void SetRootLayer(scoped_refptr<cc::Layer>) override;
bool ShouldHandleImeEvents() override;
// WidgetBaseClient overrides:
......
......@@ -114,16 +114,6 @@ bool WebViewFrameWidget::ScrollFocusedEditableElementIntoView() {
return web_view_->ScrollFocusedEditableElementIntoView();
}
void WebViewFrameWidget::SetRootLayer(scoped_refptr<cc::Layer> root_layer) {
if (!web_view_->does_composite()) {
DCHECK(!root_layer);
return;
}
cc::LayerTreeHost* layer_tree_host = widget_base_->LayerTreeHost();
layer_tree_host->SetRootLayer(root_layer);
web_view_->DidChangeRootLayer(!!root_layer);
}
WebInputEventResult WebViewFrameWidget::HandleGestureEvent(
const WebGestureEvent& event) {
if (!web_view_->Client() || !web_view_->Client()->CanHandleGestureEvent()) {
......
......@@ -73,7 +73,6 @@ class CORE_EXPORT WebViewFrameWidget : public WebFrameWidgetBase {
const VisualProperties& visual_properties) override;
// FrameWidget overrides:
void SetRootLayer(scoped_refptr<cc::Layer>) override;
bool ShouldHandleImeEvents() override;
// WidgetBaseClient overrides:
......
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