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

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

Issue 2621193006: Reduce PropertyTreeState construction and copies (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/paint/PaintPropertyTreeBuilderTest.h" 5 #include "core/paint/PaintPropertyTreeBuilderTest.h"
6 6
7 #include "core/html/HTMLIFrameElement.h" 7 #include "core/html/HTMLIFrameElement.h"
8 #include "core/layout/LayoutTreeAsText.h" 8 #include "core/layout/LayoutTreeAsText.h"
9 #include "core/paint/ObjectPaintProperties.h" 9 #include "core/paint/ObjectPaintProperties.h"
10 #include "core/paint/PaintPropertyTreePrinter.h" 10 #include "core/paint/PaintPropertyTreePrinter.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 Settings::setMockScrollbarsEnabled(false); 70 Settings::setMockScrollbarsEnabled(false);
71 } 71 }
72 72
73 #define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, \ 73 #define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, \
74 slopFactor) \ 74 slopFactor) \
75 do { \ 75 do { \
76 GeometryMapper geometryMapper; \ 76 GeometryMapper geometryMapper; \
77 LayoutRect source((sourceLayoutObject)->localVisualRect()); \ 77 LayoutRect source((sourceLayoutObject)->localVisualRect()); \
78 source.moveBy((sourceLayoutObject)->paintOffset()); \ 78 source.moveBy((sourceLayoutObject)->paintOffset()); \
79 bool success = false; \ 79 bool success = false; \
80 auto contentsProperties = \ 80 const auto& contentsProperties = \
81 (ancestorLayoutObject)->paintProperties()->contentsProperties(); \ 81 *(ancestorLayoutObject)->paintProperties()->contentsProperties(); \
82 LayoutRect actual = \ 82 LayoutRect actual = \
83 LayoutRect(geometryMapper.sourceToDestinationVisualRect( \ 83 LayoutRect(geometryMapper.sourceToDestinationVisualRect( \
84 FloatRect(source), *(sourceLayoutObject) \ 84 FloatRect(source), *(sourceLayoutObject) \
85 ->paintProperties() \ 85 ->paintProperties() \
86 ->localBorderBoxProperties(), \ 86 ->localBorderBoxProperties(), \
87 contentsProperties, success)); \ 87 contentsProperties, success)); \
88 ASSERT_TRUE(success); \ 88 ASSERT_TRUE(success); \
89 actual.moveBy(-(ancestorLayoutObject)->paintOffset()); \ 89 actual.moveBy(-(ancestorLayoutObject)->paintOffset()); \
90 EXPECT_EQ(expected, actual) \ 90 EXPECT_EQ(expected, actual) \
91 << "GeometryMapper: expected: " << expected.toString() \ 91 << "GeometryMapper: expected: " << expected.toString() \
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 const ObjectPaintProperties* childProperties = child->paintProperties(); 2343 const ObjectPaintProperties* childProperties = child->paintProperties();
2344 2344
2345 // No scroll translation because the document does not scroll (not enough 2345 // No scroll translation because the document does not scroll (not enough
2346 // content). 2346 // content).
2347 EXPECT_TRUE(!frameScrollTranslation()); 2347 EXPECT_TRUE(!frameScrollTranslation());
2348 EXPECT_EQ(framePreTranslation(), 2348 EXPECT_EQ(framePreTranslation(),
2349 clipProperties->localBorderBoxProperties()->transform()); 2349 clipProperties->localBorderBoxProperties()->transform());
2350 EXPECT_EQ(frameContentClip(), 2350 EXPECT_EQ(frameContentClip(),
2351 clipProperties->localBorderBoxProperties()->clip()); 2351 clipProperties->localBorderBoxProperties()->clip());
2352 2352
2353 auto contentsProperties = clipProperties->contentsProperties(); 2353 const auto& contentsProperties = *clipProperties->contentsProperties();
2354 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset()); 2354 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2355 EXPECT_EQ(framePreTranslation(), contentsProperties.transform()); 2355 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2356 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip()); 2356 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip());
2357 2357
2358 EXPECT_EQ(framePreTranslation(), 2358 EXPECT_EQ(framePreTranslation(),
2359 childProperties->localBorderBoxProperties()->transform()); 2359 childProperties->localBorderBoxProperties()->transform());
2360 EXPECT_EQ(clipProperties->overflowClip(), 2360 EXPECT_EQ(clipProperties->overflowClip(),
2361 childProperties->localBorderBoxProperties()->clip()); 2361 childProperties->localBorderBoxProperties()->clip());
2362 2362
2363 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->effect()); 2363 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->effect());
(...skipping 16 matching lines...) Expand all
2380 const ObjectPaintProperties* childProperties = child->paintProperties(); 2380 const ObjectPaintProperties* childProperties = child->paintProperties();
2381 2381
2382 // No scroll translation because the document does not scroll (not enough 2382 // No scroll translation because the document does not scroll (not enough
2383 // content). 2383 // content).
2384 EXPECT_TRUE(!frameScrollTranslation()); 2384 EXPECT_TRUE(!frameScrollTranslation());
2385 EXPECT_EQ(framePreTranslation(), 2385 EXPECT_EQ(framePreTranslation(),
2386 clipProperties->localBorderBoxProperties()->transform()); 2386 clipProperties->localBorderBoxProperties()->transform());
2387 EXPECT_EQ(frameContentClip(), 2387 EXPECT_EQ(frameContentClip(),
2388 clipProperties->localBorderBoxProperties()->clip()); 2388 clipProperties->localBorderBoxProperties()->clip());
2389 2389
2390 auto contentsProperties = clipProperties->contentsProperties(); 2390 const auto& contentsProperties = *clipProperties->contentsProperties();
2391 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset()); 2391 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2392 EXPECT_EQ(framePreTranslation(), contentsProperties.transform()); 2392 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2393 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip()); 2393 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip());
2394 2394
2395 EXPECT_EQ(framePreTranslation(), 2395 EXPECT_EQ(framePreTranslation(),
2396 childProperties->localBorderBoxProperties()->transform()); 2396 childProperties->localBorderBoxProperties()->transform());
2397 EXPECT_EQ(clipProperties->overflowClip(), 2397 EXPECT_EQ(clipProperties->overflowClip(),
2398 childProperties->localBorderBoxProperties()->clip()); 2398 childProperties->localBorderBoxProperties()->clip());
2399 2399
2400 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->effect()); 2400 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->effect());
(...skipping 20 matching lines...) Expand all
2421 toLayoutBoxModelObject(clipperElement->layoutObject()); 2421 toLayoutBoxModelObject(clipperElement->layoutObject());
2422 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); 2422 const ObjectPaintProperties* clipProperties = clipper->paintProperties();
2423 LayoutObject* child = document().getElementById("child")->layoutObject(); 2423 LayoutObject* child = document().getElementById("child")->layoutObject();
2424 const ObjectPaintProperties* childProperties = child->paintProperties(); 2424 const ObjectPaintProperties* childProperties = child->paintProperties();
2425 2425
2426 EXPECT_EQ(frameScrollTranslation(), 2426 EXPECT_EQ(frameScrollTranslation(),
2427 clipProperties->localBorderBoxProperties()->transform()); 2427 clipProperties->localBorderBoxProperties()->transform());
2428 EXPECT_EQ(frameContentClip(), 2428 EXPECT_EQ(frameContentClip(),
2429 clipProperties->localBorderBoxProperties()->clip()); 2429 clipProperties->localBorderBoxProperties()->clip());
2430 2430
2431 auto contentsProperties = clipProperties->contentsProperties(); 2431 const auto& contentsProperties = *clipProperties->contentsProperties();
2432 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset()); 2432 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2433 EXPECT_EQ(clipProperties->scrollTranslation(), 2433 EXPECT_EQ(clipProperties->scrollTranslation(),
2434 contentsProperties.transform()); 2434 contentsProperties.transform());
2435 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip()); 2435 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip());
2436 2436
2437 EXPECT_EQ(clipProperties->scrollTranslation(), 2437 EXPECT_EQ(clipProperties->scrollTranslation(),
2438 childProperties->localBorderBoxProperties()->transform()); 2438 childProperties->localBorderBoxProperties()->transform());
2439 EXPECT_EQ(clipProperties->overflowClip(), 2439 EXPECT_EQ(clipProperties->overflowClip(),
2440 childProperties->localBorderBoxProperties()->clip()); 2440 childProperties->localBorderBoxProperties()->clip());
2441 2441
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2506 2506
2507 // No scroll translation because the document does not scroll (not enough 2507 // No scroll translation because the document does not scroll (not enough
2508 // content). 2508 // content).
2509 EXPECT_TRUE(!frameScrollTranslation()); 2509 EXPECT_TRUE(!frameScrollTranslation());
2510 EXPECT_EQ(framePreTranslation(), 2510 EXPECT_EQ(framePreTranslation(),
2511 clipProperties->localBorderBoxProperties()->transform()); 2511 clipProperties->localBorderBoxProperties()->transform());
2512 // CSS clip on an element causes it to clip itself, not just descendants. 2512 // CSS clip on an element causes it to clip itself, not just descendants.
2513 EXPECT_EQ(clipProperties->cssClip(), 2513 EXPECT_EQ(clipProperties->cssClip(),
2514 clipProperties->localBorderBoxProperties()->clip()); 2514 clipProperties->localBorderBoxProperties()->clip());
2515 2515
2516 auto contentsProperties = clipProperties->contentsProperties(); 2516 const auto& contentsProperties = *clipProperties->contentsProperties();
2517 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset()); 2517 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2518 EXPECT_EQ(framePreTranslation(), contentsProperties.transform()); 2518 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2519 EXPECT_EQ(clipProperties->cssClip(), contentsProperties.clip()); 2519 EXPECT_EQ(clipProperties->cssClip(), contentsProperties.clip());
2520 2520
2521 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); 2521 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper);
2522 } 2522 }
2523 2523
2524 TEST_P(PaintPropertyTreeBuilderTest, 2524 TEST_P(PaintPropertyTreeBuilderTest,
2525 SvgLocalToBorderBoxTransformContentsTreeState) { 2525 SvgLocalToBorderBoxTransformContentsTreeState) {
2526 setBodyInnerHTML( 2526 setBodyInnerHTML(
(...skipping 14 matching lines...) Expand all
2541 "</svg>"); 2541 "</svg>");
2542 2542
2543 LayoutObject& svgWithViewBox = 2543 LayoutObject& svgWithViewBox =
2544 *document().getElementById("svgWithViewBox")->layoutObject(); 2544 *document().getElementById("svgWithViewBox")->layoutObject();
2545 const ObjectPaintProperties* svgWithViewBoxProperties = 2545 const ObjectPaintProperties* svgWithViewBoxProperties =
2546 svgWithViewBox.paintProperties(); 2546 svgWithViewBox.paintProperties();
2547 2547
2548 EXPECT_EQ(framePreTranslation(), 2548 EXPECT_EQ(framePreTranslation(),
2549 svgWithViewBoxProperties->localBorderBoxProperties()->transform()); 2549 svgWithViewBoxProperties->localBorderBoxProperties()->transform());
2550 2550
2551 auto contentsProperties = svgWithViewBoxProperties->contentsProperties(); 2551 const auto& contentsProperties =
2552 *svgWithViewBoxProperties->contentsProperties();
2552 EXPECT_EQ(LayoutPoint(30, 20), svgWithViewBox.paintOffset()); 2553 EXPECT_EQ(LayoutPoint(30, 20), svgWithViewBox.paintOffset());
2553 EXPECT_EQ(framePreTranslation(), contentsProperties.transform()); 2554 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2554 } 2555 }
2555 2556
2556 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) { 2557 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) {
2557 setBodyInnerHTML( 2558 setBodyInnerHTML(
2558 "<style>" 2559 "<style>"
2559 " body {" 2560 " body {"
2560 " margin: 0px;" 2561 " margin: 0px;"
2561 " }" 2562 " }"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
3142 3143
3143 LayoutObject* target = getLayoutObjectByElementId("target"); 3144 LayoutObject* target = getLayoutObjectByElementId("target");
3144 const auto* localBorderBoxProperties = 3145 const auto* localBorderBoxProperties =
3145 target->paintProperties()->localBorderBoxProperties(); 3146 target->paintProperties()->localBorderBoxProperties();
3146 ASSERT_TRUE(localBorderBoxProperties); 3147 ASSERT_TRUE(localBorderBoxProperties);
3147 EXPECT_EQ(LayoutPoint(66, 55), target->paintOffset()); 3148 EXPECT_EQ(LayoutPoint(66, 55), target->paintOffset());
3148 EXPECT_EQ(effect, localBorderBoxProperties->effect()); 3149 EXPECT_EQ(effect, localBorderBoxProperties->effect());
3149 } 3150 }
3150 3151
3151 } // namespace blink 3152 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintLayer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698