Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(660)

Side by Side Diff: third_party/WebKit/Source/core/paint/PrePaintTreeWalkTest.cpp

Issue 2810503002: Only store previous clip rects for PaintLayers that support subsequences. (Closed)
Patch Set: none Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/LayoutTestHelper.h" 5 #include "core/layout/LayoutTestHelper.h"
6 #include "core/layout/LayoutTreeAsText.h" 6 #include "core/layout/LayoutTreeAsText.h"
7 #include "core/layout/api/LayoutViewItem.h" 7 #include "core/layout/api/LayoutViewItem.h"
8 #include "core/paint/ObjectPaintProperties.h" 8 #include "core/paint/ObjectPaintProperties.h"
9 #include "core/paint/PaintLayer.h" 9 #include "core/paint/PaintLayer.h"
10 #include "core/paint/PaintPropertyTreePrinter.h" 10 #include "core/paint/PaintPropertyTreePrinter.h"
11 #include "core/paint/PrePaintTreeWalk.h"
11 #include "platform/graphics/paint/GeometryMapper.h" 12 #include "platform/graphics/paint/GeometryMapper.h"
12 #include "platform/graphics/paint/ScrollPaintPropertyNode.h" 13 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
13 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 14 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
14 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 15 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
15 #include "platform/testing/UnitTestHelpers.h" 16 #include "platform/testing/UnitTestHelpers.h"
16 #include "platform/text/TextStream.h" 17 #include "platform/text/TextStream.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "wtf/HashMap.h" 19 #include "wtf/HashMap.h"
19 #include "wtf/Vector.h" 20 #include "wtf/Vector.h"
20 21
(...skipping 24 matching lines...) Expand all
45 const TransformPaintPropertyNode* FrameScrollTranslation() { 46 const TransformPaintPropertyNode* FrameScrollTranslation() {
46 FrameView* frame_view = GetDocument().View(); 47 FrameView* frame_view = GetDocument().View();
47 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 48 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
48 return frame_view->GetLayoutView() 49 return frame_view->GetLayoutView()
49 ->PaintProperties() 50 ->PaintProperties()
50 ->ScrollTranslation(); 51 ->ScrollTranslation();
51 } 52 }
52 return frame_view->ScrollTranslation(); 53 return frame_view->ScrollTranslation();
53 } 54 }
54 55
56 protected:
57 PaintLayer* GetPaintLayerByElementId(const char* id) {
58 return ToLayoutBoxModelObject(GetLayoutObjectByElementId(id))->Layer();
59 }
60
55 private: 61 private:
56 void SetUp() override { 62 void SetUp() override {
57 Settings::SetMockScrollbarsEnabled(true); 63 Settings::SetMockScrollbarsEnabled(true);
58 64
59 RenderingTest::SetUp(); 65 RenderingTest::SetUp();
60 EnableCompositing(); 66 EnableCompositing();
61 } 67 }
62 68
63 void TearDown() override { 69 void TearDown() override {
64 RenderingTest::TearDown(); 70 RenderingTest::TearDown();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 EXPECT_TRUE(child_paint_layer->NeedsRepaint()); 211 EXPECT_TRUE(child_paint_layer->NeedsRepaint());
206 } 212 }
207 213
208 TEST_P(PrePaintTreeWalkTest, ClearSubsequenceCachingClipChangePosAbs) { 214 TEST_P(PrePaintTreeWalkTest, ClearSubsequenceCachingClipChangePosAbs) {
209 SetBodyInnerHTML( 215 SetBodyInnerHTML(
210 "<style>" 216 "<style>"
211 " .clip { overflow: hidden }" 217 " .clip { overflow: hidden }"
212 "</style>" 218 "</style>"
213 "<div id='parent' style='transform: translateZ(0); width: 100px;" 219 "<div id='parent' style='transform: translateZ(0); width: 100px;"
214 " height: 100px; position: absolute'>" 220 " height: 100px; position: absolute'>"
215 " <div id='child' style='overflow: hidden; z-index: 0; width: 50px;" 221 " <div id='child' style='overflow: hidden; position: relative;"
216 " height: 50px'>" 222 " z-index: 0; width: 50px; height: 50px'>"
217 " content" 223 " content"
218 " </div>" 224 " </div>"
219 "</div>"); 225 "</div>");
220 226
221 auto* parent = GetDocument().GetElementById("parent"); 227 auto* parent = GetDocument().GetElementById("parent");
222 auto* child = GetDocument().GetElementById("child"); 228 auto* child = GetDocument().GetElementById("child");
223 auto* child_paint_layer = 229 auto* child_paint_layer =
224 ToLayoutBoxModelObject(child->GetLayoutObject())->Layer(); 230 ToLayoutBoxModelObject(child->GetLayoutObject())->Layer();
225 EXPECT_FALSE(child_paint_layer->NeedsRepaint()); 231 EXPECT_FALSE(child_paint_layer->NeedsRepaint());
226 EXPECT_FALSE(child_paint_layer->NeedsPaintPhaseFloat()); 232 EXPECT_FALSE(child_paint_layer->NeedsPaintPhaseFloat());
(...skipping 27 matching lines...) Expand all
254 EXPECT_FALSE(child_paint_layer->NeedsPaintPhaseFloat()); 260 EXPECT_FALSE(child_paint_layer->NeedsPaintPhaseFloat());
255 261
256 // This changes clips for absolute-positioned descendants of "child" but not 262 // This changes clips for absolute-positioned descendants of "child" but not
257 // normal-position ones, which are already clipped to 50x50. 263 // normal-position ones, which are already clipped to 50x50.
258 parent->setAttribute(HTMLNames::classAttr, "clip"); 264 parent->setAttribute(HTMLNames::classAttr, "clip");
259 GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint(); 265 GetDocument().View()->UpdateAllLifecyclePhasesExceptPaint();
260 266
261 EXPECT_TRUE(child_paint_layer->NeedsRepaint()); 267 EXPECT_TRUE(child_paint_layer->NeedsRepaint());
262 } 268 }
263 269
270 TEST_P(PrePaintTreeWalkTest, ClipRects) {
271 SetBodyInnerHTML(
272 "<div id='parent' style='isolation: isolate'>"
273 " <div id='child' style='position: relative'>"
274 " <div id='grandchild' style='isolation: isolate'>"
275 " <div style='position: relative'></div>"
276 " </div>"
277 " </div>"
278 "</div>");
279
280 auto* parent = GetPaintLayerByElementId("parent");
281 auto* child = GetPaintLayerByElementId("child");
282 auto* grandchild = GetPaintLayerByElementId("grandchild");
283
284 EXPECT_TRUE(parent->PreviousPaintingClipRects());
285 EXPECT_FALSE(child->PreviousPaintingClipRects());
286 EXPECT_TRUE(grandchild->PreviousPaintingClipRects());
287
288 grandchild->ClearPreviousPaintingClipRects();
289 GetDocument().View()->UpdateAllLifecyclePhases();
290 // Still no rects, because the walk early-outed at the LayoutView.
291 EXPECT_FALSE(grandchild->PreviousPaintingClipRects());
292
293 GetDocument().View()->GetLayoutView()->SetNeedsPaintPropertyUpdate();
294 GetDocument().View()->UpdateAllLifecyclePhases();
295 EXPECT_TRUE(grandchild->PreviousPaintingClipRects());
296 }
297
264 } // namespace blink 298 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698