Commit 6a31e5b4 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

[CompositeAfterPaint] Make FrameThrottlingTest and ScrollingCoordinatorTest pass

Bug: 809638, 922419

Change-Id: Id941247287731cd47214f5b362e9e89f1be27551
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931796
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722725}
parent 27fc778a
...@@ -26,7 +26,7 @@ namespace cc { ...@@ -26,7 +26,7 @@ namespace cc {
std::unique_ptr<LayerImpl> PaintedOverlayScrollbarLayer::CreateLayerImpl( std::unique_ptr<LayerImpl> PaintedOverlayScrollbarLayer::CreateLayerImpl(
LayerTreeImpl* tree_impl) { LayerTreeImpl* tree_impl) {
return PaintedOverlayScrollbarLayerImpl::Create( return PaintedOverlayScrollbarLayerImpl::Create(
tree_impl, id(), orientation_, is_left_side_vertical_scrollbar_); tree_impl, id(), orientation(), is_left_side_vertical_scrollbar());
} }
scoped_refptr<PaintedOverlayScrollbarLayer> scoped_refptr<PaintedOverlayScrollbarLayer>
...@@ -37,10 +37,9 @@ PaintedOverlayScrollbarLayer::Create(scoped_refptr<Scrollbar> scrollbar) { ...@@ -37,10 +37,9 @@ PaintedOverlayScrollbarLayer::Create(scoped_refptr<Scrollbar> scrollbar) {
PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer( PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer(
scoped_refptr<Scrollbar> scrollbar) scoped_refptr<Scrollbar> scrollbar)
: scrollbar_(std::move(scrollbar)), : ScrollbarLayerBase(scrollbar->Orientation(),
orientation_(scrollbar_->Orientation()), scrollbar->IsLeftSideVerticalScrollbar()),
is_left_side_vertical_scrollbar_( scrollbar_(std::move(scrollbar)) {
scrollbar_->IsLeftSideVerticalScrollbar()) {
DCHECK(scrollbar_->HasThumb()); DCHECK(scrollbar_->HasThumb());
DCHECK(scrollbar_->IsOverlay()); DCHECK(scrollbar_->IsOverlay());
DCHECK(scrollbar_->UsesNinePatchThumbResource()); DCHECK(scrollbar_->UsesNinePatchThumbResource());
...@@ -58,7 +57,7 @@ void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { ...@@ -58,7 +57,7 @@ void PaintedOverlayScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
PaintedOverlayScrollbarLayerImpl* scrollbar_layer = PaintedOverlayScrollbarLayerImpl* scrollbar_layer =
static_cast<PaintedOverlayScrollbarLayerImpl*>(layer); static_cast<PaintedOverlayScrollbarLayerImpl*>(layer);
if (orientation_ == HORIZONTAL) { if (orientation() == HORIZONTAL) {
scrollbar_layer->SetThumbThickness(thumb_size_.height()); scrollbar_layer->SetThumbThickness(thumb_size_.height());
scrollbar_layer->SetThumbLength(thumb_size_.width()); scrollbar_layer->SetThumbLength(thumb_size_.width());
scrollbar_layer->SetTrackStart(track_rect_.x()); scrollbar_layer->SetTrackStart(track_rect_.x());
...@@ -101,8 +100,8 @@ void PaintedOverlayScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) { ...@@ -101,8 +100,8 @@ void PaintedOverlayScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) {
bool PaintedOverlayScrollbarLayer::Update() { bool PaintedOverlayScrollbarLayer::Update() {
// These properties should never change. // These properties should never change.
DCHECK_EQ(orientation_, scrollbar_->Orientation()); DCHECK_EQ(orientation(), scrollbar_->Orientation());
DCHECK_EQ(is_left_side_vertical_scrollbar_, DCHECK_EQ(is_left_side_vertical_scrollbar(),
scrollbar_->IsLeftSideVerticalScrollbar()); scrollbar_->IsLeftSideVerticalScrollbar());
DCHECK(scrollbar_->HasThumb()); DCHECK(scrollbar_->HasThumb());
DCHECK(scrollbar_->IsOverlay()); DCHECK(scrollbar_->IsOverlay());
......
...@@ -53,9 +53,6 @@ class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerBase { ...@@ -53,9 +53,6 @@ class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerBase {
gfx::Rect track_rect_; gfx::Rect track_rect_;
gfx::Rect aperture_; gfx::Rect aperture_;
const ScrollbarOrientation orientation_;
const bool is_left_side_vertical_scrollbar_;
std::unique_ptr<ScopedUIResource> thumb_resource_; std::unique_ptr<ScopedUIResource> thumb_resource_;
std::unique_ptr<ScopedUIResource> track_resource_; std::unique_ptr<ScopedUIResource> track_resource_;
}; };
......
...@@ -15,8 +15,8 @@ namespace cc { ...@@ -15,8 +15,8 @@ namespace cc {
std::unique_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl( std::unique_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl(
LayerTreeImpl* tree_impl) { LayerTreeImpl* tree_impl) {
return PaintedScrollbarLayerImpl::Create(tree_impl, id(), orientation_, return PaintedScrollbarLayerImpl::Create(tree_impl, id(), orientation(),
is_left_side_vertical_scrollbar_, is_left_side_vertical_scrollbar(),
is_overlay_); is_overlay_);
} }
...@@ -26,15 +26,14 @@ scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create( ...@@ -26,15 +26,14 @@ scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create(
} }
PaintedScrollbarLayer::PaintedScrollbarLayer(scoped_refptr<Scrollbar> scrollbar) PaintedScrollbarLayer::PaintedScrollbarLayer(scoped_refptr<Scrollbar> scrollbar)
: scrollbar_(std::move(scrollbar)), : ScrollbarLayerBase(scrollbar->Orientation(),
scrollbar->IsLeftSideVerticalScrollbar()),
scrollbar_(std::move(scrollbar)),
internal_contents_scale_(1.f), internal_contents_scale_(1.f),
thumb_opacity_(scrollbar_->ThumbOpacity()), thumb_opacity_(scrollbar_->ThumbOpacity()),
has_thumb_(scrollbar_->HasThumb()), has_thumb_(scrollbar_->HasThumb()),
supports_drag_snap_back_(scrollbar_->SupportsDragSnapBack()), supports_drag_snap_back_(scrollbar_->SupportsDragSnapBack()),
is_left_side_vertical_scrollbar_( is_overlay_(scrollbar_->IsOverlay()) {}
scrollbar_->IsLeftSideVerticalScrollbar()),
is_overlay_(scrollbar_->IsOverlay()),
orientation_(scrollbar_->Orientation()) {}
PaintedScrollbarLayer::~PaintedScrollbarLayer() = default; PaintedScrollbarLayer::~PaintedScrollbarLayer() = default;
...@@ -55,7 +54,7 @@ void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { ...@@ -55,7 +54,7 @@ void PaintedScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
scrollbar_layer->SetBackButtonRect(back_button_rect_); scrollbar_layer->SetBackButtonRect(back_button_rect_);
scrollbar_layer->SetForwardButtonRect(forward_button_rect_); scrollbar_layer->SetForwardButtonRect(forward_button_rect_);
scrollbar_layer->SetTrackRect(track_rect_); scrollbar_layer->SetTrackRect(track_rect_);
if (orientation_ == HORIZONTAL) { if (orientation() == HORIZONTAL) {
scrollbar_layer->SetThumbThickness(thumb_size_.height()); scrollbar_layer->SetThumbThickness(thumb_size_.height());
scrollbar_layer->SetThumbLength(thumb_size_.width()); scrollbar_layer->SetThumbLength(thumb_size_.width());
} else { } else {
...@@ -100,10 +99,10 @@ gfx::Size PaintedScrollbarLayer::LayerSizeToContentSize( ...@@ -100,10 +99,10 @@ gfx::Size PaintedScrollbarLayer::LayerSizeToContentSize(
void PaintedScrollbarLayer::UpdateThumbAndTrackGeometry() { void PaintedScrollbarLayer::UpdateThumbAndTrackGeometry() {
// These properties should never change. // These properties should never change.
DCHECK_EQ(supports_drag_snap_back_, scrollbar_->SupportsDragSnapBack()); DCHECK_EQ(supports_drag_snap_back_, scrollbar_->SupportsDragSnapBack());
DCHECK_EQ(is_left_side_vertical_scrollbar_, DCHECK_EQ(is_left_side_vertical_scrollbar(),
scrollbar_->IsLeftSideVerticalScrollbar()); scrollbar_->IsLeftSideVerticalScrollbar());
DCHECK_EQ(is_overlay_, scrollbar_->IsOverlay()); DCHECK_EQ(is_overlay_, scrollbar_->IsOverlay());
DCHECK_EQ(orientation_, scrollbar_->Orientation()); DCHECK_EQ(orientation(), scrollbar_->Orientation());
UpdateProperty(scrollbar_->TrackRect(), &track_rect_); UpdateProperty(scrollbar_->TrackRect(), &track_rect_);
UpdateProperty(scrollbar_->BackButtonRect(), &back_button_rect_); UpdateProperty(scrollbar_->BackButtonRect(), &back_button_rect_);
......
...@@ -79,9 +79,7 @@ class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerBase { ...@@ -79,9 +79,7 @@ class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerBase {
bool has_thumb_; bool has_thumb_;
const bool supports_drag_snap_back_; const bool supports_drag_snap_back_;
const bool is_left_side_vertical_scrollbar_;
const bool is_overlay_; const bool is_overlay_;
const ScrollbarOrientation orientation_;
std::unique_ptr<ScopedUIResource> track_resource_; std::unique_ptr<ScopedUIResource> track_resource_;
std::unique_ptr<ScopedUIResource> thumb_resource_; std::unique_ptr<ScopedUIResource> thumb_resource_;
......
...@@ -8,7 +8,10 @@ ...@@ -8,7 +8,10 @@
namespace cc { namespace cc {
ScrollbarLayerBase::ScrollbarLayerBase() { ScrollbarLayerBase::ScrollbarLayerBase(ScrollbarOrientation orientation,
bool is_left_side_vertical_scrollbar)
: orientation_(orientation),
is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar) {
SetIsScrollbar(true); SetIsScrollbar(true);
} }
...@@ -24,8 +27,12 @@ void ScrollbarLayerBase::SetScrollElementId(ElementId element_id) { ...@@ -24,8 +27,12 @@ void ScrollbarLayerBase::SetScrollElementId(ElementId element_id) {
void ScrollbarLayerBase::PushPropertiesTo(LayerImpl* layer) { void ScrollbarLayerBase::PushPropertiesTo(LayerImpl* layer) {
Layer::PushPropertiesTo(layer); Layer::PushPropertiesTo(layer);
static_cast<ScrollbarLayerImplBase*>(layer)->SetScrollElementId(
scroll_element_id_); auto* scrollbar_layer_impl = static_cast<ScrollbarLayerImplBase*>(layer);
DCHECK_EQ(scrollbar_layer_impl->orientation(), orientation_);
DCHECK_EQ(scrollbar_layer_impl->is_left_side_vertical_scrollbar(),
is_left_side_vertical_scrollbar_);
scrollbar_layer_impl->SetScrollElementId(scroll_element_id_);
} }
} // namespace cc } // namespace cc
...@@ -13,14 +13,23 @@ namespace cc { ...@@ -13,14 +13,23 @@ namespace cc {
class CC_EXPORT ScrollbarLayerBase : public Layer { class CC_EXPORT ScrollbarLayerBase : public Layer {
public: public:
void SetScrollElementId(ElementId element_id); void SetScrollElementId(ElementId element_id);
ElementId scroll_element_id() const { return scroll_element_id_; }
ScrollbarOrientation orientation() const { return orientation_; }
bool is_left_side_vertical_scrollbar() const {
return is_left_side_vertical_scrollbar_;
}
void PushPropertiesTo(LayerImpl* layer) override; void PushPropertiesTo(LayerImpl* layer) override;
protected: protected:
ScrollbarLayerBase(); ScrollbarLayerBase(ScrollbarOrientation orientation,
bool is_left_side_vertical_scrollbar);
~ScrollbarLayerBase() override; ~ScrollbarLayerBase() override;
private: private:
const ScrollbarOrientation orientation_;
const bool is_left_side_vertical_scrollbar_;
ElementId scroll_element_id_; ElementId scroll_element_id_;
}; };
......
...@@ -13,9 +13,9 @@ namespace cc { ...@@ -13,9 +13,9 @@ namespace cc {
std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl( std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl(
LayerTreeImpl* tree_impl) { LayerTreeImpl* tree_impl) {
return SolidColorScrollbarLayerImpl::Create(tree_impl, id(), orientation_, return SolidColorScrollbarLayerImpl::Create(
thumb_thickness_, track_start_, tree_impl, id(), orientation(), thumb_thickness_, track_start_,
is_left_side_vertical_scrollbar_); is_left_side_vertical_scrollbar());
} }
scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create( scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create(
...@@ -33,10 +33,9 @@ SolidColorScrollbarLayer::SolidColorScrollbarLayer( ...@@ -33,10 +33,9 @@ SolidColorScrollbarLayer::SolidColorScrollbarLayer(
int thumb_thickness, int thumb_thickness,
int track_start, int track_start,
bool is_left_side_vertical_scrollbar) bool is_left_side_vertical_scrollbar)
: orientation_(orientation), : ScrollbarLayerBase(orientation, is_left_side_vertical_scrollbar),
thumb_thickness_(thumb_thickness), thumb_thickness_(thumb_thickness),
track_start_(track_start), track_start_(track_start) {
is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar) {
Layer::SetOpacity(0.f); Layer::SetOpacity(0.f);
} }
......
...@@ -37,10 +37,8 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerBase { ...@@ -37,10 +37,8 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerBase {
bool is_left_side_vertical_scrollbar); bool is_left_side_vertical_scrollbar);
~SolidColorScrollbarLayer() override; ~SolidColorScrollbarLayer() override;
ScrollbarOrientation orientation_;
int thumb_thickness_; int thumb_thickness_;
int track_start_; int track_start_;
bool is_left_side_vertical_scrollbar_;
}; };
} // namespace cc } // namespace cc
......
...@@ -37,8 +37,6 @@ class CORE_EXPORT FragmentData { ...@@ -37,8 +37,6 @@ class CORE_EXPORT FragmentData {
} }
// The visual rect computed by the latest paint invalidation. // The visual rect computed by the latest paint invalidation.
// This rect does *not* account for composited scrolling. See LayoutObject::
// AdjustVisualRectForCompositedScrolling().
// It's location may be different from PaintOffset when there is visual (ink) // It's location may be different from PaintOffset when there is visual (ink)
// overflow to the top and/or the left. // overflow to the top and/or the left.
IntRect VisualRect() const { return visual_rect_; } IntRect VisualRect() const { return visual_rect_; }
......
...@@ -2349,18 +2349,19 @@ bool PaintLayerScrollableArea::ShouldScrollOnMainThread() const { ...@@ -2349,18 +2349,19 @@ bool PaintLayerScrollableArea::ShouldScrollOnMainThread() const {
if (HasNonCompositedStickyDescendants()) if (HasNonCompositedStickyDescendants())
return true; return true;
if (GraphicsLayer* layer = GraphicsLayerForScrolling()) { // Property tree state is not available until the PrePaint lifecycle stage.
// Property tree state is not available until the PrePaint lifecycle stage. DCHECK_GE(GetDocument()->Lifecycle().GetState(),
DCHECK_GE(GetDocument()->Lifecycle().GetState(), DocumentLifecycle::kPrePaintClean);
DocumentLifecycle::kPrePaintClean); const auto* properties = GetLayoutBox()->FirstFragment().PaintProperties();
const auto* scroll = layer->GetPropertyTreeState() if (!properties || !properties->Scroll() ||
.Transform() properties->Scroll()->GetMainThreadScrollingReasons())
.NearestScrollTranslationNode() return true;
.ScrollNode();
DCHECK(scroll); DCHECK(properties->ScrollTranslation());
return scroll->GetMainThreadScrollingReasons() != 0; if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
} return !properties->ScrollTranslation()->HasDirectCompositingReasons();
return true;
return !GraphicsLayerForScrolling();
} }
static bool LayerNodeMayNeedCompositedScrolling(const PaintLayer* layer) { static bool LayerNodeMayNeedCompositedScrolling(const PaintLayer* layer) {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "third_party/blink/renderer/core/testing/sim/sim_test.h" #include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h" #include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h"
#include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h" #include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h"
#include "third_party/blink/renderer/platform/testing/find_cc_layer.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h" #include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h" #include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
...@@ -56,25 +57,13 @@ class FrameThrottlingTest : public PaintTestConfigurations, public SimTest { ...@@ -56,25 +57,13 @@ class FrameThrottlingTest : public PaintTestConfigurations, public SimTest {
// Number of rectangles that make up the root layer's touch handler region. // Number of rectangles that make up the root layer's touch handler region.
size_t TouchHandlerRegionSize() { size_t TouchHandlerRegionSize() {
size_t result = 0; const auto* frame_view = WebView().MainFrameImpl()->GetFrameView();
PaintLayer* layer = return CcLayerByScrollElementId(
WebView().MainFrameImpl()->GetFrame()->ContentLayoutObject()->Layer(); frame_view->RootCcLayer(),
GraphicsLayer* own_graphics_layer = frame_view->LayoutViewport()->GetScrollElementId())
layer->GraphicsLayerBacking(&layer->GetLayoutObject()); ->touch_action_region()
if (own_graphics_layer) { .GetAllRegions()
result += own_graphics_layer->CcLayer() .GetRegionComplexity();
->touch_action_region()
.GetAllRegions()
.GetRegionComplexity();
}
GraphicsLayer* child_graphics_layer = layer->GraphicsLayerBacking();
if (child_graphics_layer && child_graphics_layer != own_graphics_layer) {
result += child_graphics_layer->CcLayer()
->touch_action_region()
.GetAllRegions()
.GetRegionComplexity();
}
return result;
} }
void UpdateAllLifecyclePhases() { void UpdateAllLifecyclePhases() {
...@@ -577,10 +566,6 @@ TEST_P(FrameThrottlingTest, ThrottledFrameWithFocus) { ...@@ -577,10 +566,6 @@ TEST_P(FrameThrottlingTest, ThrottledFrameWithFocus) {
} }
TEST_P(FrameThrottlingTest, ScrollingCoordinatorShouldSkipThrottledFrame) { TEST_P(FrameThrottlingTest, ScrollingCoordinatorShouldSkipThrottledFrame) {
// TODO(crbug.com/809638): Make this test pass for CAP.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
// Create a hidden frame which is throttled. // Create a hidden frame which is throttled.
SimRequest main_resource("https://example.com/", "text/html"); SimRequest main_resource("https://example.com/", "text/html");
SimRequest frame_resource("https://example.com/iframe.html", "text/html"); SimRequest frame_resource("https://example.com/iframe.html", "text/html");
...@@ -687,10 +672,6 @@ TEST_P(FrameThrottlingTest, ScrollingCoordinatorShouldSkipThrottledLayer) { ...@@ -687,10 +672,6 @@ TEST_P(FrameThrottlingTest, ScrollingCoordinatorShouldSkipThrottledLayer) {
TEST_P(FrameThrottlingTest, TEST_P(FrameThrottlingTest,
ScrollingCoordinatorShouldSkipCompositedThrottledFrame) { ScrollingCoordinatorShouldSkipCompositedThrottledFrame) {
// TODO(crbug.com/922419): The test is broken for LayoutNG.
if (RuntimeEnabledFeatures::LayoutNGEnabled())
return;
WebView().GetSettings()->SetPreferCompositingToLCDTextEnabled(true); WebView().GetSettings()->SetPreferCompositingToLCDTextEnabled(true);
// Create a hidden frame which is throttled. // Create a hidden frame which is throttled.
...@@ -736,18 +717,10 @@ TEST_P(FrameThrottlingTest, ...@@ -736,18 +717,10 @@ TEST_P(FrameThrottlingTest,
EXPECT_FALSE( EXPECT_FALSE(
frame_element->contentDocument()->View()->ShouldThrottleRendering()); frame_element->contentDocument()->View()->ShouldThrottleRendering());
CompositeFrame(); // Handle the pending visual update of the unthrottled // Handle the pending visual update of the unthrottled frame.
// frame. CompositeFrame();
EXPECT_EQ(DocumentLifecycle::kPaintClean, EXPECT_EQ(DocumentLifecycle::kPaintClean,
frame_element->contentDocument()->Lifecycle().GetState()); frame_element->contentDocument()->Lifecycle().GetState());
// TODO(szager): Re-enable this check for CAP when it properly sets the
// bits for composited scrolling.
if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) {
EXPECT_TRUE(frame_element->contentDocument()
->View()
->LayoutViewport()
->UsesCompositedScrolling());
}
} }
TEST_P(FrameThrottlingTest, UnthrottleByTransformingWithoutLayout) { TEST_P(FrameThrottlingTest, UnthrottleByTransformingWithoutLayout) {
...@@ -777,10 +750,6 @@ TEST_P(FrameThrottlingTest, UnthrottleByTransformingWithoutLayout) { ...@@ -777,10 +750,6 @@ TEST_P(FrameThrottlingTest, UnthrottleByTransformingWithoutLayout) {
} }
TEST_P(FrameThrottlingTest, ThrottledTopLevelEventHandlerIgnored) { TEST_P(FrameThrottlingTest, ThrottledTopLevelEventHandlerIgnored) {
// TODO(crbug.com/809638): Make this test pass for CAP.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
WebView().GetSettings()->SetJavaScriptEnabled(true); WebView().GetSettings()->SetJavaScriptEnabled(true);
EXPECT_EQ(0u, TouchHandlerRegionSize()); EXPECT_EQ(0u, TouchHandlerRegionSize());
...@@ -828,10 +797,6 @@ TEST_P(FrameThrottlingTest, ThrottledTopLevelEventHandlerIgnored) { ...@@ -828,10 +797,6 @@ TEST_P(FrameThrottlingTest, ThrottledTopLevelEventHandlerIgnored) {
} }
TEST_P(FrameThrottlingTest, ThrottledEventHandlerIgnored) { TEST_P(FrameThrottlingTest, ThrottledEventHandlerIgnored) {
// TODO(crbug.com/809638): Make this test pass for CAP.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
WebView().GetSettings()->SetJavaScriptEnabled(true); WebView().GetSettings()->SetJavaScriptEnabled(true);
EXPECT_EQ(0u, TouchHandlerRegionSize()); EXPECT_EQ(0u, TouchHandlerRegionSize());
...@@ -908,6 +873,7 @@ TEST_P(FrameThrottlingTest, DumpThrottledFrame) { ...@@ -908,6 +873,7 @@ TEST_P(FrameThrottlingTest, DumpThrottledFrame) {
} }
TEST_P(FrameThrottlingTest, PaintingViaGraphicsLayerIsThrottled) { TEST_P(FrameThrottlingTest, PaintingViaGraphicsLayerIsThrottled) {
// GraphicsLayers are not created with CompositeAfterPaint.
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled()) if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return; return;
...@@ -944,9 +910,6 @@ TEST_P(FrameThrottlingTest, PaintingViaGraphicsLayerIsThrottled) { ...@@ -944,9 +910,6 @@ TEST_P(FrameThrottlingTest, PaintingViaGraphicsLayerIsThrottled) {
} }
TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) { TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) {
if (RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
WebView().GetSettings()->SetPreferCompositingToLCDTextEnabled(true); WebView().GetSettings()->SetPreferCompositingToLCDTextEnabled(true);
// Create a hidden frame which is throttled. // Create a hidden frame which is throttled.
...@@ -961,13 +924,13 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) { ...@@ -961,13 +924,13 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) {
auto* frame_element = auto* frame_element =
To<HTMLIFrameElement>(GetDocument().getElementById("frame")); To<HTMLIFrameElement>(GetDocument().getElementById("frame"));
auto* root_layer = WebView().MainFrameImpl()->GetFrameView()->RootCcLayer();
// The inner div is composited. // The inner div is composited.
auto* inner_div = frame_element->contentDocument()->getElementById("div"); EXPECT_EQ(1u, CcLayersByDOMElementId(root_layer, "div").size());
EXPECT_NE(nullptr,
inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
// Before the iframe is throttled, we should create all drawing commands. // Before the iframe is throttled, we should create all drawing commands.
EXPECT_EQ(7u, commands_not_throttled.DrawCount()); unsigned full_draw_count = 7u;
EXPECT_EQ(full_draw_count, commands_not_throttled.DrawCount());
// Move the frame offscreen to throttle it. // Move the frame offscreen to throttle it.
frame_element->setAttribute(kStyleAttr, "transform: translateY(480px)"); frame_element->setAttribute(kStyleAttr, "transform: translateY(480px)");
...@@ -976,15 +939,15 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) { ...@@ -976,15 +939,15 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) {
CompositeFrame(); CompositeFrame();
EXPECT_TRUE(frame_element->contentDocument()->View()->CanThrottleRendering()); EXPECT_TRUE(frame_element->contentDocument()->View()->CanThrottleRendering());
// The inner div should still be composited. // The inner div should still be composited.
EXPECT_NE(nullptr, EXPECT_EQ(1u, CcLayersByDOMElementId(root_layer, "div").size());
inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
// If painting of the iframe is throttled, we should only receive drawing // If painting of the iframe is throttled, we should only receive drawing
// commands for the main frame. // commands for the main frame.
auto commands_throttled = Compositor().PaintFrame(); auto commands_throttled = Compositor().PaintFrame();
EXPECT_EQ(5u, commands_throttled.DrawCount()); EXPECT_LT(commands_throttled.DrawCount(), full_draw_count);
// Remove compositing trigger of inner_div. // Remove compositing trigger of inner_div.
auto* inner_div = frame_element->contentDocument()->getElementById("div");
inner_div->setAttribute(kStyleAttr, "background: yellow; overflow: hidden"); inner_div->setAttribute(kStyleAttr, "background: yellow; overflow: hidden");
// Do an unthrottled style and layout update, simulating the situation // Do an unthrottled style and layout update, simulating the situation
// triggered by script style/layout access. // triggered by script style/layout access.
...@@ -995,17 +958,11 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) { ...@@ -995,17 +958,11 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) {
GetDocument().Lifecycle()); GetDocument().Lifecycle());
UpdateAllLifecyclePhases(); UpdateAllLifecyclePhases();
} }
// The inner div should still be composited because compositing update is // The inner div is no longer composited.
// throttled, though the inner_div's self-painting status has been updated. EXPECT_EQ(0u, CcLayersByDOMElementId(root_layer, "div").size());
EXPECT_FALSE(inner_div->GetLayoutBox()->Layer()->IsSelfPaintingLayer());
{
DisableCompositingQueryAsserts disabler;
EXPECT_NE(nullptr,
inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
}
auto commands_throttled1 = CompositeFrame(); auto commands_throttled1 = CompositeFrame();
EXPECT_EQ(5u, commands_throttled1.DrawCount()); EXPECT_LT(commands_throttled1.DrawCount(), full_draw_count);
// Move the frame back on screen. // Move the frame back on screen.
frame_element->setAttribute(kStyleAttr, ""); frame_element->setAttribute(kStyleAttr, "");
...@@ -1013,19 +970,14 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) { ...@@ -1013,19 +970,14 @@ TEST_P(FrameThrottlingTest, ThrottleInnerCompositedLayer) {
EXPECT_FALSE( EXPECT_FALSE(
frame_element->contentDocument()->View()->CanThrottleRendering()); frame_element->contentDocument()->View()->CanThrottleRendering());
auto commands_not_throttled1 = CompositeFrame(); auto commands_not_throttled1 = CompositeFrame();
// The inner div is no longer composited. // The inner div is still not composited.
EXPECT_EQ(nullptr, EXPECT_EQ(0u, CcLayersByDOMElementId(root_layer, "div").size());
inner_div->GetLayoutBox()->Layer()->GraphicsLayerBacking());
// After the iframe is unthrottled, we should create all drawing items. // After the iframe is unthrottled, we should create all drawing items.
EXPECT_EQ(7u, commands_not_throttled1.DrawCount()); EXPECT_EQ(commands_not_throttled1.DrawCount(), full_draw_count);
} }
TEST_P(FrameThrottlingTest, ThrottleSubtreeAtomically) { TEST_P(FrameThrottlingTest, ThrottleSubtreeAtomically) {
// TODO(crbug.com/922419): The test is broken for LayoutNG.
if (RuntimeEnabledFeatures::LayoutNGEnabled())
return;
// Create two nested frames which are throttled. // Create two nested frames which are throttled.
SimRequest main_resource("https://example.com/", "text/html"); SimRequest main_resource("https://example.com/", "text/html");
SimRequest frame_resource("https://example.com/iframe.html", "text/html"); SimRequest frame_resource("https://example.com/iframe.html", "text/html");
......
...@@ -380,6 +380,8 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin { ...@@ -380,6 +380,8 @@ class CORE_EXPORT ScrollableArea : public GarbageCollectedMixin {
MaximumScrollOffset(orientation)); MaximumScrollOffset(orientation));
} }
// Note that in CompositeAfterPaint, these methods always return nullptr
// except for VisualViewport.
virtual cc::Layer* LayerForScrolling() const { return nullptr; } virtual cc::Layer* LayerForScrolling() const { return nullptr; }
virtual cc::Layer* LayerForHorizontalScrollbar() const { return nullptr; } virtual cc::Layer* LayerForHorizontalScrollbar() const { return nullptr; }
virtual cc::Layer* LayerForVerticalScrollbar() const { return nullptr; } virtual cc::Layer* LayerForVerticalScrollbar() const { return nullptr; }
......
...@@ -1633,6 +1633,8 @@ jumbo_static_library("test_support") { ...@@ -1633,6 +1633,8 @@ jumbo_static_library("test_support") {
"testing/fake_display_item_client.h", "testing/fake_display_item_client.h",
"testing/fake_graphics_layer.h", "testing/fake_graphics_layer.h",
"testing/fake_graphics_layer_client.h", "testing/fake_graphics_layer_client.h",
"testing/find_cc_layer.cc",
"testing/find_cc_layer.h",
"testing/font_test_helpers.cc", "testing/font_test_helpers.cc",
"testing/font_test_helpers.h", "testing/font_test_helpers.h",
"testing/histogram_tester.cc", "testing/histogram_tester.cc",
......
// Copyright 2019 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/testing/find_cc_layer.h"
#include "cc/layers/layer.h"
#include "cc/layers/scrollbar_layer_base.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/property_tree.h"
#include "cc/trees/scroll_node.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace blink {
Vector<const cc::Layer*> CcLayersByName(const cc::Layer* root,
const String& name_regex) {
Vector<const cc::Layer*> layers;
::testing::Matcher<std::string> matcher(
::testing::ContainsRegex(name_regex.Utf8()));
for (auto& layer : root->children()) {
if (matcher.Matches(layer->DebugName()))
layers.push_back(layer.get());
}
return layers;
}
Vector<const cc::Layer*> CcLayersByDOMElementId(const cc::Layer* root,
const String& dom_id) {
return CcLayersByName(root, String("id='") + dom_id + "'");
}
const cc::Layer* CcLayerByCcElementId(const cc::Layer* root,
const CompositorElementId& element_id) {
return root->layer_tree_host()->LayerByElementId(element_id);
}
const cc::Layer* CcLayerByScrollElementId(
const cc::Layer* root,
const CompositorElementId& scroll_element_id) {
const auto& scroll_tree =
root->layer_tree_host()->property_trees()->scroll_tree;
for (auto& layer : root->children()) {
const auto* scroll_node = scroll_tree.Node(layer->scroll_tree_index());
if (scroll_node && scroll_node->element_id == scroll_element_id &&
scroll_node->transform_id == layer->transform_tree_index())
return layer.get();
}
return nullptr;
}
const cc::ScrollbarLayerBase* ScrollbarLayerForScrollNode(
const cc::Layer* root,
const cc::ScrollNode* scroll_node,
cc::ScrollbarOrientation orientation) {
if (!scroll_node)
return nullptr;
for (auto& layer : root->children()) {
if (!layer->is_scrollbar())
continue;
const auto* scrollbar_layer =
static_cast<const cc::ScrollbarLayerBase*>(layer.get());
if (scrollbar_layer->scroll_element_id() == scroll_node->element_id &&
scrollbar_layer->orientation() == orientation)
return scrollbar_layer;
}
return nullptr;
}
} // namespace blink
// Copyright 2019 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_TESTING_FIND_CC_LAYER_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_FIND_CC_LAYER_H_
#include <string>
#include "cc/input/scrollbar.h"
#include "third_party/blink/renderer/platform/graphics/compositor_element_id.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace cc {
class Layer;
class ScrollbarLayerBase;
struct ScrollNode;
} // namespace cc
namespace blink {
// Finds all cc layers whose DebugName()s contain regular expression
// |name_regex|.
Vector<const cc::Layer*> CcLayersByName(const cc::Layer* root,
const String& name_regex);
Vector<const cc::Layer*> CcLayersByDOMElementId(const cc::Layer* root,
const String& dom_id);
const cc::Layer* CcLayerByCcElementId(const cc::Layer* root,
const CompositorElementId&);
const cc::Layer* CcLayerByScrollElementId(
const cc::Layer* root,
const CompositorElementId& scroll_element_id);
const cc::ScrollbarLayerBase* ScrollbarLayerForScrollNode(
const cc::Layer* root,
const cc::ScrollNode* scroll_node,
cc::ScrollbarOrientation orientation);
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_TESTING_FIND_CC_LAYER_H_
...@@ -56,10 +56,10 @@ crbug.com/1008501 compositing/culling/filter-occlusion-blur.html [ Failure ] ...@@ -56,10 +56,10 @@ crbug.com/1008501 compositing/culling/filter-occlusion-blur.html [ Failure ]
crbug.com/1008501 compositing/reflections/deeply-nested-reflections.html [ Failure ] crbug.com/1008501 compositing/reflections/deeply-nested-reflections.html [ Failure ]
# Wrong contentsOpaque or background color. # Wrong contentsOpaque or background color.
Bug(none) compositing/contents-opaque/control-layer.html [ Failure ] crbug.com/1029620 compositing/contents-opaque/control-layer.html [ Failure ]
Bug(none) compositing/contents-opaque/layer-opacity.html [ Failure ] crbug.com/1029620 compositing/contents-opaque/layer-opacity.html [ Failure ]
# Flaky result of contentsOpqaue. # Flaky result of contentsOpqaue.
Bug(none) paint/invalidation/window-resize/window-resize-child-background-image-fixed-centered.html [ Pass Failure ] crbug.com/1029620 paint/invalidation/window-resize/window-resize-child-background-image-fixed-centered.html [ Pass Failure ]
# Needs to implement logic for CompositingReasons::kAssumedOverlap. # Needs to implement logic for CompositingReasons::kAssumedOverlap.
Bug(none) compositing/layer-creation/overlap-animation-clipping.html [ Failure ] Bug(none) compositing/layer-creation/overlap-animation-clipping.html [ Failure ]
......
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