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

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

Issue 2614093002: Combine LayoutObject::previousPaintOffset and paintOffset in paint properties (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
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 const ScrollPaintPropertyNode* PaintPropertyTreeBuilderTest::frameScroll( 46 const ScrollPaintPropertyNode* PaintPropertyTreeBuilderTest::frameScroll(
47 FrameView* frameView) { 47 FrameView* frameView) {
48 if (!frameView) 48 if (!frameView)
49 frameView = document().view(); 49 frameView = document().view();
50 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 50 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
51 return frameView->layoutView()->paintProperties()->scroll(); 51 return frameView->layoutView()->paintProperties()->scroll();
52 return frameView->scroll(); 52 return frameView->scroll();
53 } 53 }
54 54
55 LayoutPoint PaintPropertyTreeBuilderTest::paintOffset(
56 const LayoutObject* object) {
57 return object->paintProperties()->localBorderBoxProperties()->paintOffset;
58 }
59
60 const ObjectPaintProperties* 55 const ObjectPaintProperties*
61 PaintPropertyTreeBuilderTest::paintPropertiesForElement(const char* name) { 56 PaintPropertyTreeBuilderTest::paintPropertiesForElement(const char* name) {
62 return document().getElementById(name)->layoutObject()->paintProperties(); 57 return document().getElementById(name)->layoutObject()->paintProperties();
63 } 58 }
64 59
65 void PaintPropertyTreeBuilderTest::SetUp() { 60 void PaintPropertyTreeBuilderTest::SetUp() {
66 Settings::setMockScrollbarsEnabled(true); 61 Settings::setMockScrollbarsEnabled(true);
67 62
68 RenderingTest::SetUp(); 63 RenderingTest::SetUp();
69 enableCompositing(); 64 enableCompositing();
70 } 65 }
71 66
72 void PaintPropertyTreeBuilderTest::TearDown() { 67 void PaintPropertyTreeBuilderTest::TearDown() {
73 RenderingTest::TearDown(); 68 RenderingTest::TearDown();
74 69
75 Settings::setMockScrollbarsEnabled(false); 70 Settings::setMockScrollbarsEnabled(false);
76 } 71 }
77 72
78 #define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, \ 73 #define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, \
79 slopFactor) \ 74 slopFactor) \
80 do { \ 75 do { \
81 GeometryMapper geometryMapper; \ 76 GeometryMapper geometryMapper; \
82 LayoutRect source((sourceLayoutObject)->localVisualRect()); \ 77 LayoutRect source((sourceLayoutObject)->localVisualRect()); \
83 source.moveBy((sourceLayoutObject) \ 78 source.moveBy((sourceLayoutObject)->paintOffset()); \
84 ->paintProperties() \
85 ->localBorderBoxProperties() \
86 ->paintOffset); \
87 bool success = false; \ 79 bool success = false; \
88 auto contentsProperties = \ 80 auto contentsProperties = \
89 (ancestorLayoutObject)->paintProperties()->contentsProperties(); \ 81 (ancestorLayoutObject)->paintProperties()->contentsProperties(); \
90 LayoutRect actual = \ 82 LayoutRect actual = \
91 LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( \ 83 LayoutRect(geometryMapper.mapToVisualRectInDestinationSpace( \
92 FloatRect(source), (sourceLayoutObject) \ 84 FloatRect(source), *(sourceLayoutObject) \
93 ->paintProperties() \ 85 ->paintProperties() \
94 ->localBorderBoxProperties() \ 86 ->localBorderBoxProperties(), \
95 ->propertyTreeState, \ 87 contentsProperties, success)); \
96 contentsProperties.propertyTreeState, success)); \
97 ASSERT_TRUE(success); \ 88 ASSERT_TRUE(success); \
98 actual.moveBy(-contentsProperties.paintOffset); \ 89 actual.moveBy(-(ancestorLayoutObject)->paintOffset()); \
99 EXPECT_EQ(expected, actual) \ 90 EXPECT_EQ(expected, actual) \
100 << "GeometryMapper: expected: " << expected.toString() \ 91 << "GeometryMapper: expected: " << expected.toString() \
101 << ", actual: " << actual.toString(); \ 92 << ", actual: " << actual.toString(); \
102 \ 93 \
103 if (slopFactor == LayoutUnit::max()) \ 94 if (slopFactor == LayoutUnit::max()) \
104 break; \ 95 break; \
105 LayoutRect slowPathRect = (sourceLayoutObject)->localVisualRect(); \ 96 LayoutRect slowPathRect = (sourceLayoutObject)->localVisualRect(); \
106 (sourceLayoutObject) \ 97 (sourceLayoutObject) \
107 ->mapToVisualRectInAncestorSpace(ancestorLayoutObject, slowPathRect); \ 98 ->mapToVisualRectInAncestorSpace(ancestorLayoutObject, slowPathRect); \
108 if (slopFactor) { \ 99 if (slopFactor) { \
(...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 containerProperties->transform()->matrix()); 1030 containerProperties->transform()->matrix());
1040 EXPECT_EQ(svgProperties->transform(), 1031 EXPECT_EQ(svgProperties->transform(),
1041 containerProperties->transform()->parent()); 1032 containerProperties->transform()->parent());
1042 1033
1043 Element* fixed = document().getElementById("fixed"); 1034 Element* fixed = document().getElementById("fixed");
1044 const ObjectPaintProperties* fixedProperties = 1035 const ObjectPaintProperties* fixedProperties =
1045 fixed->layoutObject()->paintProperties(); 1036 fixed->layoutObject()->paintProperties();
1046 // Ensure the fixed position element is rooted at the nearest transform 1037 // Ensure the fixed position element is rooted at the nearest transform
1047 // container. 1038 // container.
1048 EXPECT_EQ(containerProperties->transform(), 1039 EXPECT_EQ(containerProperties->transform(),
1049 fixedProperties->localBorderBoxProperties() 1040 fixedProperties->localBorderBoxProperties()->transform());
1050 ->propertyTreeState.transform());
1051 } 1041 }
1052 1042
1053 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) { 1043 TEST_P(PaintPropertyTreeBuilderTest, ControlClip) {
1054 setBodyInnerHTML( 1044 setBodyInnerHTML(
1055 "<style>" 1045 "<style>"
1056 " body {" 1046 " body {"
1057 " margin: 0;" 1047 " margin: 0;"
1058 " }" 1048 " }"
1059 " input {" 1049 " input {"
1060 " border-width: 5px;" 1050 " border-width: 5px;"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 " <div style='height:10000px;'></div>" 1274 " <div style='height:10000px;'></div>"
1285 "</div>"); 1275 "</div>");
1286 FrameView* frameView = document().view(); 1276 FrameView* frameView = document().view();
1287 1277
1288 LayoutObject* scroller = 1278 LayoutObject* scroller =
1289 document().getElementById("scroller")->layoutObject(); 1279 document().getElementById("scroller")->layoutObject();
1290 const ObjectPaintProperties* scrollerProperties = scroller->paintProperties(); 1280 const ObjectPaintProperties* scrollerProperties = scroller->paintProperties();
1291 LayoutObject* child = document().getElementById("child")->layoutObject(); 1281 LayoutObject* child = document().getElementById("child")->layoutObject();
1292 const ObjectPaintProperties* childProperties = child->paintProperties(); 1282 const ObjectPaintProperties* childProperties = child->paintProperties();
1293 1283
1294 EXPECT_EQ( 1284 EXPECT_EQ(scrollerProperties->overflowClip(),
1295 scrollerProperties->overflowClip(), 1285 childProperties->localBorderBoxProperties()->clip());
1296 childProperties->localBorderBoxProperties()->propertyTreeState.clip());
1297 EXPECT_EQ(scrollerProperties->scrollTranslation(), 1286 EXPECT_EQ(scrollerProperties->scrollTranslation(),
1298 childProperties->localBorderBoxProperties() 1287 childProperties->localBorderBoxProperties()->transform());
1299 ->propertyTreeState.transform()); 1288 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->effect());
1300 EXPECT_NE(
1301 nullptr,
1302 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
1303 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller, 1289 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 300), scroller,
1304 frameView->layoutView()); 1290 frameView->layoutView());
1305 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child, 1291 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), child,
1306 frameView->layoutView()); 1292 frameView->layoutView());
1307 } 1293 }
1308 1294
1309 TEST_P(PaintPropertyTreeBuilderTest, 1295 TEST_P(PaintPropertyTreeBuilderTest,
1310 TreeContextUnclipFromParentStackingContext) { 1296 TreeContextUnclipFromParentStackingContext) {
1311 // This test verifies the tree builder correctly computes and records the 1297 // This test verifies the tree builder correctly computes and records the
1312 // property tree context for a (pseudo) stacking context that has a scrolling 1298 // property tree context for a (pseudo) stacking context that has a scrolling
(...skipping 18 matching lines...) Expand all
1331 "<div id='scroller'>" 1317 "<div id='scroller'>"
1332 " <div id='child'></div>" 1318 " <div id='child'></div>"
1333 " <div id='forceScroll' style='height:10000px;'></div>" 1319 " <div id='forceScroll' style='height:10000px;'></div>"
1334 "</div>"); 1320 "</div>");
1335 1321
1336 auto& scroller = *document().getElementById("scroller")->layoutObject(); 1322 auto& scroller = *document().getElementById("scroller")->layoutObject();
1337 const ObjectPaintProperties* scrollerProperties = scroller.paintProperties(); 1323 const ObjectPaintProperties* scrollerProperties = scroller.paintProperties();
1338 LayoutObject& child = *document().getElementById("child")->layoutObject(); 1324 LayoutObject& child = *document().getElementById("child")->layoutObject();
1339 const ObjectPaintProperties* childProperties = child.paintProperties(); 1325 const ObjectPaintProperties* childProperties = child.paintProperties();
1340 1326
1341 EXPECT_EQ( 1327 EXPECT_EQ(frameContentClip(),
1342 frameContentClip(), 1328 childProperties->localBorderBoxProperties()->clip());
1343 childProperties->localBorderBoxProperties()->propertyTreeState.clip());
1344 EXPECT_EQ(frameScrollTranslation(), 1329 EXPECT_EQ(frameScrollTranslation(),
1345 childProperties->localBorderBoxProperties() 1330 childProperties->localBorderBoxProperties()->transform());
1346 ->propertyTreeState.transform()); 1331 EXPECT_EQ(scrollerProperties->effect(),
1347 EXPECT_EQ( 1332 childProperties->localBorderBoxProperties()->effect());
1348 scrollerProperties->effect(),
1349 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
1350 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller, 1333 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 800, 10000), &scroller,
1351 document().view()->layoutView()); 1334 document().view()->layoutView());
1352 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child, 1335 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 100, 200), &child,
1353 document().view()->layoutView()); 1336 document().view()->layoutView());
1354 } 1337 }
1355 1338
1356 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) { 1339 TEST_P(PaintPropertyTreeBuilderTest, TableCellLayoutLocation) {
1357 // This test verifies that the border box space of a table cell is being 1340 // This test verifies that the border box space of a table cell is being
1358 // correctly computed. Table cells have weird location adjustment in our 1341 // correctly computed. Table cells have weird location adjustment in our
1359 // layout/paint implementation. 1342 // layout/paint implementation.
(...skipping 20 matching lines...) Expand all
1380 " }" 1363 " }"
1381 "</style>" 1364 "</style>"
1382 "<table>" 1365 "<table>"
1383 " <tr><td></td><td></td></tr>" 1366 " <tr><td></td><td></td></tr>"
1384 " <tr><td></td><td><div id='target'></div></td></tr>" 1367 " <tr><td></td><td><div id='target'></div></td></tr>"
1385 "</table>"); 1368 "</table>");
1386 1369
1387 LayoutObject& target = *document().getElementById("target")->layoutObject(); 1370 LayoutObject& target = *document().getElementById("target")->layoutObject();
1388 const ObjectPaintProperties* targetProperties = target.paintProperties(); 1371 const ObjectPaintProperties* targetProperties = target.paintProperties();
1389 1372
1390 EXPECT_EQ(LayoutPoint(170, 170), 1373 EXPECT_EQ(LayoutPoint(170, 170), target.paintOffset());
1391 targetProperties->localBorderBoxProperties()->paintOffset); 1374 EXPECT_EQ(framePreTranslation(),
1392 EXPECT_EQ(framePreTranslation(), targetProperties->localBorderBoxProperties() 1375 targetProperties->localBorderBoxProperties()->transform());
1393 ->propertyTreeState.transform());
1394 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target, 1376 CHECK_EXACT_VISUAL_RECT(LayoutRect(170, 170, 100, 100), &target,
1395 document().view()->layoutView()); 1377 document().view()->layoutView());
1396 } 1378 }
1397 1379
1398 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) { 1380 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendant) {
1399 // This test verifies that clip tree hierarchy being generated correctly for 1381 // This test verifies that clip tree hierarchy being generated correctly for
1400 // the hard case such that a fixed position element getting clipped by an 1382 // the hard case such that a fixed position element getting clipped by an
1401 // absolute position CSS clip. 1383 // absolute position CSS clip.
1402 setBodyInnerHTML( 1384 setBodyInnerHTML(
1403 "<style>" 1385 "<style>"
(...skipping 25 matching lines...) Expand all
1429 clipProperties->cssClip()->localTransformSpace()); 1411 clipProperties->cssClip()->localTransformSpace());
1430 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), 1412 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)),
1431 clipProperties->cssClip()->clipRect()); 1413 clipProperties->cssClip()->clipRect());
1432 CHECK_VISUAL_RECT(absoluteClipRect, &clip, document().view()->layoutView(), 1414 CHECK_VISUAL_RECT(absoluteClipRect, &clip, document().view()->layoutView(),
1433 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() 1415 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace()
1434 // doesn't apply css clip on the object itself. 1416 // doesn't apply css clip on the object itself.
1435 LayoutUnit::max()); 1417 LayoutUnit::max());
1436 1418
1437 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 1419 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1438 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); 1420 const ObjectPaintProperties* fixedProperties = fixed->paintProperties();
1439 EXPECT_EQ( 1421 EXPECT_EQ(clipProperties->cssClip(),
1440 clipProperties->cssClip(), 1422 fixedProperties->localBorderBoxProperties()->clip());
1441 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1423 EXPECT_EQ(framePreTranslation(),
1442 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() 1424 fixedProperties->localBorderBoxProperties()->transform());
1443 ->propertyTreeState.transform()); 1425 EXPECT_EQ(LayoutPoint(654, 321), fixed->paintOffset());
1444 EXPECT_EQ(LayoutPoint(654, 321),
1445 fixedProperties->localBorderBoxProperties()->paintOffset);
1446 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), 1426 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
1447 // TODO(crbug.com/599939): CSS clip of fixed-position 1427 // TODO(crbug.com/599939): CSS clip of fixed-position
1448 // descendants is broken in 1428 // descendants is broken in
1449 // mapToVisualRectInAncestorSpace(). 1429 // mapToVisualRectInAncestorSpace().
1450 LayoutUnit::max()); 1430 LayoutUnit::max());
1451 } 1431 }
1452 1432
1453 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) { 1433 TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) {
1454 // This test verifies that clip tree hierarchy being generated correctly for 1434 // This test verifies that clip tree hierarchy being generated correctly for
1455 // the hard case such that a fixed position element getting clipped by an 1435 // the hard case such that a fixed position element getting clipped by an
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 clipProperties->cssClip()->localTransformSpace()); 1468 clipProperties->cssClip()->localTransformSpace());
1489 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), 1469 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)),
1490 clipProperties->cssClip()->clipRect()); 1470 clipProperties->cssClip()->clipRect());
1491 CHECK_VISUAL_RECT(absoluteClipRect, clip, document().view()->layoutView(), 1471 CHECK_VISUAL_RECT(absoluteClipRect, clip, document().view()->layoutView(),
1492 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace() 1472 // TODO(crbug.com/599939): mapToVisualRectInAncestorSpace()
1493 // doesn't apply css clip on the object itself. 1473 // doesn't apply css clip on the object itself.
1494 LayoutUnit::max()); 1474 LayoutUnit::max());
1495 1475
1496 auto* absolute = document().getElementById("absolute")->layoutObject(); 1476 auto* absolute = document().getElementById("absolute")->layoutObject();
1497 const ObjectPaintProperties* absPosProperties = absolute->paintProperties(); 1477 const ObjectPaintProperties* absPosProperties = absolute->paintProperties();
1498 EXPECT_EQ( 1478 EXPECT_EQ(clipProperties->cssClip(),
1499 clipProperties->cssClip(), 1479 absPosProperties->localBorderBoxProperties()->clip());
1500 absPosProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1480 EXPECT_EQ(framePreTranslation(),
1501 EXPECT_EQ(framePreTranslation(), absPosProperties->localBorderBoxProperties() 1481 absPosProperties->localBorderBoxProperties()->transform());
1502 ->propertyTreeState.transform()); 1482 EXPECT_EQ(LayoutPoint(123, 456), absolute->paintOffset());
1503 EXPECT_EQ(LayoutPoint(123, 456),
1504 absPosProperties->localBorderBoxProperties()->paintOffset);
1505 CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(), 1483 CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(),
1506 // TODO(crbug.com/599939): CSS clip of fixed-position 1484 // TODO(crbug.com/599939): CSS clip of fixed-position
1507 // descendants is broken in 1485 // descendants is broken in
1508 // mapToVisualRectInAncestorSpace(). 1486 // mapToVisualRectInAncestorSpace().
1509 LayoutUnit::max()); 1487 LayoutUnit::max());
1510 } 1488 }
1511 1489
1512 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) { 1490 TEST_P(PaintPropertyTreeBuilderTest, CSSClipFixedPositionDescendantNonShared) {
1513 // This test is similar to CSSClipFixedPositionDescendant above, except that 1491 // This test is similar to CSSClipFixedPositionDescendant above, except that
1514 // now we have a parent overflow clip that should be escaped by the fixed 1492 // now we have a parent overflow clip that should be escaped by the fixed
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 EXPECT_EQ(frameContentClip(), 1544 EXPECT_EQ(frameContentClip(),
1567 clipProperties->cssClipFixedPosition()->parent()); 1545 clipProperties->cssClipFixedPosition()->parent());
1568 EXPECT_EQ(overflowProperties->scrollTranslation(), 1546 EXPECT_EQ(overflowProperties->scrollTranslation(),
1569 clipProperties->cssClipFixedPosition()->localTransformSpace()); 1547 clipProperties->cssClipFixedPosition()->localTransformSpace());
1570 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)), 1548 EXPECT_EQ(FloatRoundedRect(FloatRect(absoluteClipRect)),
1571 clipProperties->cssClipFixedPosition()->clipRect()); 1549 clipProperties->cssClipFixedPosition()->clipRect());
1572 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView()); 1550 CHECK_EXACT_VISUAL_RECT(LayoutRect(), clip, document().view()->layoutView());
1573 1551
1574 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 1552 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1575 const ObjectPaintProperties* fixedProperties = fixed->paintProperties(); 1553 const ObjectPaintProperties* fixedProperties = fixed->paintProperties();
1576 EXPECT_EQ( 1554 EXPECT_EQ(clipProperties->cssClipFixedPosition(),
1577 clipProperties->cssClipFixedPosition(), 1555 fixedProperties->localBorderBoxProperties()->clip());
1578 fixedProperties->localBorderBoxProperties()->propertyTreeState.clip()); 1556 EXPECT_EQ(framePreTranslation(),
1579 EXPECT_EQ(framePreTranslation(), fixedProperties->localBorderBoxProperties() 1557 fixedProperties->localBorderBoxProperties()->transform());
1580 ->propertyTreeState.transform()); 1558 EXPECT_EQ(LayoutPoint(654, 321), fixed->paintOffset());
1581 EXPECT_EQ(LayoutPoint(654, 321),
1582 fixedProperties->localBorderBoxProperties()->paintOffset);
1583 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(), 1559 CHECK_VISUAL_RECT(LayoutRect(), fixed, document().view()->layoutView(),
1584 // TODO(crbug.com/599939): CSS clip of fixed-position 1560 // TODO(crbug.com/599939): CSS clip of fixed-position
1585 // descendants is broken in geometry mapping. 1561 // descendants is broken in geometry mapping.
1586 LayoutUnit::max()); 1562 LayoutUnit::max());
1587 } 1563 }
1588 1564
1589 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) { 1565 TEST_P(PaintPropertyTreeBuilderTest, ColumnSpannerUnderRelativePositioned) {
1590 setBodyInnerHTML( 1566 setBodyInnerHTML(
1591 "<style>" 1567 "<style>"
1592 " #spanner {" 1568 " #spanner {"
1593 " column-span: all;" 1569 " column-span: all;"
1594 " opacity: 0.5;" 1570 " opacity: 0.5;"
1595 " width: 100px;" 1571 " width: 100px;"
1596 " height: 100px;" 1572 " height: 100px;"
1597 " }" 1573 " }"
1598 "</style>" 1574 "</style>"
1599 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>" 1575 "<div style='columns: 3; position: absolute; top: 44px; left: 55px;'>"
1600 " <div style='position: relative; top: 100px; left: 100px'>" 1576 " <div style='position: relative; top: 100px; left: 100px'>"
1601 " <div id='spanner'></div>" 1577 " <div id='spanner'></div>"
1602 " </div>" 1578 " </div>"
1603 "</div>"); 1579 "</div>");
1604 1580
1605 LayoutObject* spanner = getLayoutObjectByElementId("spanner"); 1581 LayoutObject* spanner = getLayoutObjectByElementId("spanner");
1606 EXPECT_EQ( 1582 EXPECT_EQ(LayoutPoint(55, 44), spanner->paintOffset());
1607 LayoutPoint(55, 44),
1608 spanner->paintProperties()->localBorderBoxProperties()->paintOffset);
1609 CHECK_EXACT_VISUAL_RECT(LayoutRect(55, 44, 100, 100), spanner, 1583 CHECK_EXACT_VISUAL_RECT(LayoutRect(55, 44, 100, 100), spanner,
1610 document().view()->layoutView()); 1584 document().view()->layoutView());
1611 } 1585 }
1612 1586
1613 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset) { 1587 TEST_P(PaintPropertyTreeBuilderTest, FractionalPaintOffset) {
1614 setBodyInnerHTML( 1588 setBodyInnerHTML(
1615 "<style>" 1589 "<style>"
1616 " * { margin: 0; }" 1590 " * { margin: 0; }"
1617 " div { position: absolute; }" 1591 " div { position: absolute; }"
1618 " #a {" 1592 " #a {"
1619 " width: 70px;" 1593 " width: 70px;"
1620 " height: 70px;" 1594 " height: 70px;"
1621 " left: 0.1px;" 1595 " left: 0.1px;"
1622 " top: 0.3px;" 1596 " top: 0.3px;"
1623 " }" 1597 " }"
1624 " #b {" 1598 " #b {"
1625 " width: 40px;" 1599 " width: 40px;"
1626 " height: 40px;" 1600 " height: 40px;"
1627 " left: 0.5px;" 1601 " left: 0.5px;"
1628 " top: 11.1px;" 1602 " top: 11.1px;"
1629 " }" 1603 " }"
1630 "</style>" 1604 "</style>"
1631 "<div id='a'>" 1605 "<div id='a'>"
1632 " <div id='b'></div>" 1606 " <div id='b'></div>"
1633 "</div>"); 1607 "</div>");
1634 FrameView* frameView = document().view(); 1608 FrameView* frameView = document().view();
1635 1609
1636 LayoutObject* a = document().getElementById("a")->layoutObject(); 1610 LayoutObject* a = document().getElementById("a")->layoutObject();
1637 const ObjectPaintProperties* aProperties = a->paintProperties();
1638 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3)); 1611 LayoutPoint aPaintOffset = LayoutPoint(FloatPoint(0.1, 0.3));
1639 EXPECT_EQ(aPaintOffset, aProperties->localBorderBoxProperties()->paintOffset); 1612 EXPECT_EQ(aPaintOffset, a->paintOffset());
1640 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), 1613 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3),
1641 LayoutUnit(70), LayoutUnit(70)), 1614 LayoutUnit(70), LayoutUnit(70)),
1642 a, frameView->layoutView()); 1615 a, frameView->layoutView());
1643 1616
1644 LayoutObject* b = document().getElementById("b")->layoutObject(); 1617 LayoutObject* b = document().getElementById("b")->layoutObject();
1645 const ObjectPaintProperties* bProperties = b->paintProperties();
1646 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1)); 1618 LayoutPoint bPaintOffset = aPaintOffset + LayoutPoint(FloatPoint(0.5, 11.1));
1647 EXPECT_EQ(bPaintOffset, bProperties->localBorderBoxProperties()->paintOffset); 1619 EXPECT_EQ(bPaintOffset, b->paintOffset());
1648 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3), 1620 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.1), LayoutUnit(0.3),
1649 LayoutUnit(70), LayoutUnit(70)), 1621 LayoutUnit(70), LayoutUnit(70)),
1650 a, frameView->layoutView()); 1622 a, frameView->layoutView());
1651 } 1623 }
1652 1624
1653 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) { 1625 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithBasicPixelSnapping) {
1654 setBodyInnerHTML( 1626 setBodyInnerHTML(
1655 "<style>" 1627 "<style>"
1656 " * { margin: 0; }" 1628 " * { margin: 0; }"
1657 " div { position: relative; }" 1629 " div { position: relative; }"
(...skipping 24 matching lines...) Expand all
1682 1654
1683 LayoutObject* b = document().getElementById("b")->layoutObject(); 1655 LayoutObject* b = document().getElementById("b")->layoutObject();
1684 const ObjectPaintProperties* bProperties = b->paintProperties(); 1656 const ObjectPaintProperties* bProperties = b->paintProperties();
1685 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), 1657 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0),
1686 bProperties->transform()->matrix()); 1658 bProperties->transform()->matrix());
1687 // The paint offset transform should be snapped from (0.3,0.3) to (0,0). 1659 // The paint offset transform should be snapped from (0.3,0.3) to (0,0).
1688 EXPECT_EQ(TransformationMatrix().translate(0, 0), 1660 EXPECT_EQ(TransformationMatrix().translate(0, 0),
1689 bProperties->transform()->parent()->matrix()); 1661 bProperties->transform()->parent()->matrix());
1690 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3). 1662 // The residual subpixel adjustment should be (0.3,0.3) - (0,0) = (0.3,0.3).
1691 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3)); 1663 LayoutPoint subpixelAccumulation = LayoutPoint(FloatPoint(0.3, 0.3));
1692 EXPECT_EQ(subpixelAccumulation, 1664 EXPECT_EQ(subpixelAccumulation, b->paintOffset());
1693 bProperties->localBorderBoxProperties()->paintOffset);
1694 CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b, 1665 CHECK_EXACT_VISUAL_RECT(LayoutRect(FloatRect(0.3, 0.3, 40, 40)), b,
1695 frameView->layoutView()); 1666 frameView->layoutView());
1696 1667
1697 // c's painted should start at subpixelAccumulation + (0.1,0.1) = (0.4,0.4). 1668 // c's painted should start at subpixelAccumulation + (0.1,0.1) = (0.4,0.4).
1698 LayoutObject* c = document().getElementById("c")->layoutObject(); 1669 LayoutObject* c = document().getElementById("c")->layoutObject();
1699 LayoutPoint cPaintOffset = 1670 LayoutPoint cPaintOffset =
1700 subpixelAccumulation + LayoutPoint(FloatPoint(0.1, 0.1)); 1671 subpixelAccumulation + LayoutPoint(FloatPoint(0.1, 0.1));
1701 const ObjectPaintProperties* cProperties = c->paintProperties(); 1672 EXPECT_EQ(cPaintOffset, c->paintOffset());
1702 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset);
1703 // Visual rects via the non-paint properties system use enclosingIntRect 1673 // Visual rects via the non-paint properties system use enclosingIntRect
1704 // before applying transforms, because they are computed bottom-up and 1674 // before applying transforms, because they are computed bottom-up and
1705 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. 1675 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1706 CHECK_VISUAL_RECT(LayoutRect(FloatRect(0.4, 0.4, 40, 40)), c, 1676 CHECK_VISUAL_RECT(LayoutRect(FloatRect(0.4, 0.4, 40, 40)), c,
1707 frameView->layoutView(), 1); 1677 frameView->layoutView(), 1);
1708 } 1678 }
1709 1679
1710 TEST_P(PaintPropertyTreeBuilderTest, 1680 TEST_P(PaintPropertyTreeBuilderTest,
1711 PaintOffsetWithPixelSnappingThroughTransform) { 1681 PaintOffsetWithPixelSnappingThroughTransform) {
1712 setBodyInnerHTML( 1682 setBodyInnerHTML(
(...skipping 28 matching lines...) Expand all
1741 LayoutObject* b = document().getElementById("b")->layoutObject(); 1711 LayoutObject* b = document().getElementById("b")->layoutObject();
1742 const ObjectPaintProperties* bProperties = b->paintProperties(); 1712 const ObjectPaintProperties* bProperties = b->paintProperties();
1743 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0), 1713 EXPECT_EQ(TransformationMatrix().translate3d(0, 0, 0),
1744 bProperties->transform()->matrix()); 1714 bProperties->transform()->matrix());
1745 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). 1715 // The paint offset transform should be snapped from (0.7,0.7) to (1,1).
1746 EXPECT_EQ(TransformationMatrix().translate(1, 1), 1716 EXPECT_EQ(TransformationMatrix().translate(1, 1),
1747 bProperties->transform()->parent()->matrix()); 1717 bProperties->transform()->parent()->matrix());
1748 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). 1718 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3).
1749 LayoutPoint subpixelAccumulation = 1719 LayoutPoint subpixelAccumulation =
1750 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); 1720 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1));
1751 EXPECT_EQ(subpixelAccumulation, 1721 EXPECT_EQ(subpixelAccumulation, b->paintOffset());
1752 bProperties->localBorderBoxProperties()->paintOffset);
1753 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7), 1722 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0.7),
1754 LayoutUnit(40), LayoutUnit(40)), 1723 LayoutUnit(40), LayoutUnit(40)),
1755 b, frameView->layoutView()); 1724 b, frameView->layoutView());
1756 1725
1757 // c's painting should start at subpixelAccumulation + (0.7,0.7) = (0.4,0.4). 1726 // c's painting should start at subpixelAccumulation + (0.7,0.7) = (0.4,0.4).
1758 LayoutObject* c = document().getElementById("c")->layoutObject(); 1727 LayoutObject* c = document().getElementById("c")->layoutObject();
1759 LayoutPoint cPaintOffset = 1728 LayoutPoint cPaintOffset =
1760 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); 1729 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7));
1761 const ObjectPaintProperties* cProperties = c->paintProperties(); 1730 EXPECT_EQ(cPaintOffset, c->paintOffset());
1762 EXPECT_EQ(cPaintOffset, cProperties->localBorderBoxProperties()->paintOffset);
1763 // Visual rects via the non-paint properties system use enclosingIntRect 1731 // Visual rects via the non-paint properties system use enclosingIntRect
1764 // before applying transforms, because they are computed bottom-up and 1732 // before applying transforms, because they are computed bottom-up and
1765 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. 1733 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1766 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), 1734 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7),
1767 LayoutUnit(0.7) + LayoutUnit(0.7), 1735 LayoutUnit(0.7) + LayoutUnit(0.7),
1768 LayoutUnit(40), LayoutUnit(40)), 1736 LayoutUnit(40), LayoutUnit(40)),
1769 c, frameView->layoutView(), 1); 1737 c, frameView->layoutView(), 1);
1770 } 1738 }
1771 1739
1772 TEST_P(PaintPropertyTreeBuilderTest, 1740 TEST_P(PaintPropertyTreeBuilderTest,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1810 LayoutObject* b = document().getElementById("b")->layoutObject(); 1778 LayoutObject* b = document().getElementById("b")->layoutObject();
1811 const ObjectPaintProperties* bProperties = b->paintProperties(); 1779 const ObjectPaintProperties* bProperties = b->paintProperties();
1812 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0), 1780 EXPECT_EQ(TransformationMatrix().translate3d(5, 7, 0),
1813 bProperties->transform()->matrix()); 1781 bProperties->transform()->matrix());
1814 // The paint offset transform should be snapped from (0.7,0.7) to (1,1). 1782 // The paint offset transform should be snapped from (0.7,0.7) to (1,1).
1815 EXPECT_EQ(TransformationMatrix().translate(1, 1), 1783 EXPECT_EQ(TransformationMatrix().translate(1, 1),
1816 bProperties->transform()->parent()->matrix()); 1784 bProperties->transform()->parent()->matrix());
1817 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3). 1785 // The residual subpixel adjustment should be (0.7,0.7) - (1,1) = (-0.3,-0.3).
1818 LayoutPoint subpixelAccumulation = 1786 LayoutPoint subpixelAccumulation =
1819 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1)); 1787 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0.7)) - LayoutPoint(1, 1));
1820 EXPECT_EQ(subpixelAccumulation, 1788 EXPECT_EQ(subpixelAccumulation, b->paintOffset());
1821 bProperties->localBorderBoxProperties()->paintOffset);
1822 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(5.7), LayoutUnit(7.7), 1789 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(5.7), LayoutUnit(7.7),
1823 LayoutUnit(40), LayoutUnit(40)), 1790 LayoutUnit(40), LayoutUnit(40)),
1824 b, frameView->layoutView()); 1791 b, frameView->layoutView());
1825 1792
1826 LayoutObject* c = document().getElementById("c")->layoutObject(); 1793 LayoutObject* c = document().getElementById("c")->layoutObject();
1827 const ObjectPaintProperties* cProperties = c->paintProperties(); 1794 const ObjectPaintProperties* cProperties = c->paintProperties();
1828 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0), 1795 EXPECT_EQ(TransformationMatrix().translate3d(11, 13, 0),
1829 cProperties->transform()->matrix()); 1796 cProperties->transform()->matrix());
1830 // The paint offset should be (-0.3,-0.3) but the paint offset transform 1797 // The paint offset should be (-0.3,-0.3) but the paint offset transform
1831 // should still be at (0,0) because it should be snapped. 1798 // should still be at (0,0) because it should be snapped.
1832 EXPECT_EQ(TransformationMatrix().translate(0, 0), 1799 EXPECT_EQ(TransformationMatrix().translate(0, 0),
1833 cProperties->transform()->parent()->matrix()); 1800 cProperties->transform()->parent()->matrix());
1834 // The residual subpixel adjustment should still be (-0.3,-0.3). 1801 // The residual subpixel adjustment should still be (-0.3,-0.3).
1835 EXPECT_EQ(subpixelAccumulation, 1802 EXPECT_EQ(subpixelAccumulation, c->paintOffset());
1836 cProperties->localBorderBoxProperties()->paintOffset);
1837 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(16.7), LayoutUnit(20.7), 1803 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(16.7), LayoutUnit(20.7),
1838 LayoutUnit(40), LayoutUnit(40)), 1804 LayoutUnit(40), LayoutUnit(40)),
1839 c, frameView->layoutView()); 1805 c, frameView->layoutView());
1840 1806
1841 // d should be painted starting at subpixelAccumulation + (0.7,0.7) = 1807 // d should be painted starting at subpixelAccumulation + (0.7,0.7) =
1842 // (0.4,0.4). 1808 // (0.4,0.4).
1843 LayoutObject* d = document().getElementById("d")->layoutObject(); 1809 LayoutObject* d = document().getElementById("d")->layoutObject();
1844 LayoutPoint dPaintOffset = 1810 LayoutPoint dPaintOffset =
1845 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7)); 1811 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0.7));
1846 const ObjectPaintProperties* dProperties = d->paintProperties(); 1812 EXPECT_EQ(dPaintOffset, d->paintOffset());
1847 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset);
1848 // Visual rects via the non-paint properties system use enclosingIntRect 1813 // Visual rects via the non-paint properties system use enclosingIntRect
1849 // before applying transforms, because they are computed bottom-up and 1814 // before applying transforms, because they are computed bottom-up and
1850 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. 1815 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1851 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(16.7) + LayoutUnit(0.7), 1816 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(16.7) + LayoutUnit(0.7),
1852 LayoutUnit(20.7) + LayoutUnit(0.7), 1817 LayoutUnit(20.7) + LayoutUnit(0.7),
1853 LayoutUnit(40), LayoutUnit(40)), 1818 LayoutUnit(40), LayoutUnit(40)),
1854 d, frameView->layoutView(), 1); 1819 d, frameView->layoutView(), 1);
1855 } 1820 }
1856 1821
1857 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) { 1822 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetWithPixelSnappingWithFixedPos) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 LayoutObject* b = document().getElementById("b")->layoutObject(); 1859 LayoutObject* b = document().getElementById("b")->layoutObject();
1895 const ObjectPaintProperties* bProperties = b->paintProperties(); 1860 const ObjectPaintProperties* bProperties = b->paintProperties();
1896 EXPECT_EQ(TransformationMatrix().translate(0, 0), 1861 EXPECT_EQ(TransformationMatrix().translate(0, 0),
1897 bProperties->transform()->matrix()); 1862 bProperties->transform()->matrix());
1898 // The paint offset transform should be snapped from (0.7,0) to (1,0). 1863 // The paint offset transform should be snapped from (0.7,0) to (1,0).
1899 EXPECT_EQ(TransformationMatrix().translate(1, 0), 1864 EXPECT_EQ(TransformationMatrix().translate(1, 0),
1900 bProperties->transform()->parent()->matrix()); 1865 bProperties->transform()->parent()->matrix());
1901 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0). 1866 // The residual subpixel adjustment should be (0.7,0) - (1,0) = (-0.3,0).
1902 LayoutPoint subpixelAccumulation = 1867 LayoutPoint subpixelAccumulation =
1903 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0)) - LayoutPoint(1, 0)); 1868 LayoutPoint(LayoutPoint(FloatPoint(0.7, 0)) - LayoutPoint(1, 0));
1904 EXPECT_EQ(subpixelAccumulation, 1869 EXPECT_EQ(subpixelAccumulation, b->paintOffset());
1905 bProperties->localBorderBoxProperties()->paintOffset);
1906 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), 1870 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0),
1907 LayoutUnit(40), LayoutUnit(40)), 1871 LayoutUnit(40), LayoutUnit(40)),
1908 b, frameView->layoutView()); 1872 b, frameView->layoutView());
1909 1873
1910 LayoutObject* fixed = document().getElementById("fixed")->layoutObject(); 1874 LayoutObject* fixed = document().getElementById("fixed")->layoutObject();
1911 const ObjectPaintProperties* fixedProperties = fixed->paintProperties();
1912 // The residual subpixel adjustment should still be (-0.3,0). 1875 // The residual subpixel adjustment should still be (-0.3,0).
1913 EXPECT_EQ(subpixelAccumulation, 1876 EXPECT_EQ(subpixelAccumulation, fixed->paintOffset());
1914 fixedProperties->localBorderBoxProperties()->paintOffset);
1915 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0), 1877 CHECK_EXACT_VISUAL_RECT(LayoutRect(LayoutUnit(0.7), LayoutUnit(0),
1916 LayoutUnit(40), LayoutUnit(40)), 1878 LayoutUnit(40), LayoutUnit(40)),
1917 fixed, frameView->layoutView()); 1879 fixed, frameView->layoutView());
1918 1880
1919 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0). 1881 // d should be painted starting at subpixelAccumulation + (0.7,0) = (0.4,0).
1920 LayoutObject* d = document().getElementById("d")->layoutObject(); 1882 LayoutObject* d = document().getElementById("d")->layoutObject();
1921 LayoutPoint dPaintOffset = 1883 LayoutPoint dPaintOffset =
1922 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0)); 1884 subpixelAccumulation + LayoutPoint(FloatPoint(0.7, 0));
1923 const ObjectPaintProperties* dProperties = d->paintProperties(); 1885 EXPECT_EQ(dPaintOffset, d->paintOffset());
1924 EXPECT_EQ(dPaintOffset, dProperties->localBorderBoxProperties()->paintOffset);
1925 // Visual rects via the non-paint properties system use enclosingIntRect 1886 // Visual rects via the non-paint properties system use enclosingIntRect
1926 // before applying transforms, because they are computed bottom-up and 1887 // before applying transforms, because they are computed bottom-up and
1927 // therefore can't apply pixel snapping. Therefore apply a slop of 1px. 1888 // therefore can't apply pixel snapping. Therefore apply a slop of 1px.
1928 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit(), 1889 CHECK_VISUAL_RECT(LayoutRect(LayoutUnit(0.7) + LayoutUnit(0.7), LayoutUnit(),
1929 LayoutUnit(40), LayoutUnit(40)), 1890 LayoutUnit(40), LayoutUnit(40)),
1930 d, frameView->layoutView(), 1); 1891 d, frameView->layoutView(), 1);
1931 } 1892 }
1932 1893
1933 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) { 1894 TEST_P(PaintPropertyTreeBuilderTest, SvgPixelSnappingShouldResetPaintOffset) {
1934 setBodyInnerHTML( 1895 setBodyInnerHTML(
1935 "<style>" 1896 "<style>"
1936 " #svg {" 1897 " #svg {"
1937 " position: relative;" 1898 " position: relative;"
1938 " left: 0.1px;" 1899 " left: 0.1px;"
1939 " transform: matrix(1, 0, 0, 1, 0, 0);" 1900 " transform: matrix(1, 0, 0, 1, 0, 0);"
1940 " }" 1901 " }"
1941 "</style>" 1902 "</style>"
1942 "<svg id='svg'>" 1903 "<svg id='svg'>"
1943 " <rect id='rect' transform='translate(1, 1)'/>" 1904 " <rect id='rect' transform='translate(1, 1)'/>"
1944 "</svg>"); 1905 "</svg>");
1945 1906
1946 LayoutObject& svgWithTransform = 1907 LayoutObject& svgWithTransform =
1947 *document().getElementById("svg")->layoutObject(); 1908 *document().getElementById("svg")->layoutObject();
1948 const ObjectPaintProperties* svgWithTransformProperties = 1909 const ObjectPaintProperties* svgWithTransformProperties =
1949 svgWithTransform.paintProperties(); 1910 svgWithTransform.paintProperties();
1950 EXPECT_EQ(TransformationMatrix(), 1911 EXPECT_EQ(TransformationMatrix(),
1951 svgWithTransformProperties->transform()->matrix()); 1912 svgWithTransformProperties->transform()->matrix());
1952 EXPECT_EQ( 1913 EXPECT_EQ(LayoutPoint(FloatPoint(0.1, 0)), svgWithTransform.paintOffset());
1953 LayoutPoint(FloatPoint(0.1, 0)),
1954 svgWithTransformProperties->localBorderBoxProperties()->paintOffset);
1955 EXPECT_EQ(nullptr, 1914 EXPECT_EQ(nullptr,
1956 svgWithTransformProperties->svgLocalToBorderBoxTransform()); 1915 svgWithTransformProperties->svgLocalToBorderBoxTransform());
1957 1916
1958 LayoutObject& rectWithTransform = 1917 LayoutObject& rectWithTransform =
1959 *document().getElementById("rect")->layoutObject(); 1918 *document().getElementById("rect")->layoutObject();
1960 const ObjectPaintProperties* rectWithTransformProperties = 1919 const ObjectPaintProperties* rectWithTransformProperties =
1961 rectWithTransform.paintProperties(); 1920 rectWithTransform.paintProperties();
1962 EXPECT_EQ(TransformationMatrix().translate(1, 1), 1921 EXPECT_EQ(TransformationMatrix().translate(1, 1),
1963 rectWithTransformProperties->transform()->matrix()); 1922 rectWithTransformProperties->transform()->matrix());
1964 1923
1965 // Ensure there is no PaintOffset transform between the rect and the svg's 1924 // Ensure there is no PaintOffset transform between the rect and the svg's
1966 // transform. 1925 // transform.
1967 EXPECT_EQ(svgWithTransformProperties->transform(), 1926 EXPECT_EQ(svgWithTransformProperties->transform(),
1968 rectWithTransformProperties->transform()->parent()); 1927 rectWithTransformProperties->transform()->parent());
1969 } 1928 }
1970 1929
1971 TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) { 1930 TEST_P(PaintPropertyTreeBuilderTest, SvgRootAndForeignObjectPixelSnapping) {
1972 setBodyInnerHTML( 1931 setBodyInnerHTML(
1973 "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>" 1932 "<svg id=svg style='position: relative; left: 0.6px; top: 0.3px'>"
1974 " <foreignObject id=foreign x='3.5' y='5.4' transform='translate(1, 1)'>" 1933 " <foreignObject id=foreign x='3.5' y='5.4' transform='translate(1, 1)'>"
1975 " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>" 1934 " <div id=div style='position: absolute; left: 5.6px; top: 7.3px'>"
1976 " </div>" 1935 " </div>"
1977 " </foreignObject>" 1936 " </foreignObject>"
1978 "</svg>"); 1937 "</svg>");
1979 1938
1980 const auto* svgProperties = 1939 const auto* svg = getLayoutObjectByElementId("svg");
1981 getLayoutObjectByElementId("svg")->paintProperties(); 1940 const auto* svgProperties = svg->paintProperties();
1982 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation()); 1941 EXPECT_EQ(nullptr, svgProperties->paintOffsetTranslation());
1983 EXPECT_EQ(LayoutPoint(LayoutUnit(8.6), LayoutUnit(8.3)), 1942 EXPECT_EQ(LayoutPoint(LayoutUnit(8.6), LayoutUnit(8.3)), svg->paintOffset());
1984 svgProperties->localBorderBoxProperties()->paintOffset);
1985 // Paint offset of SVGRoot is baked into svgLocalToBorderBoxTransform after 1943 // Paint offset of SVGRoot is baked into svgLocalToBorderBoxTransform after
1986 // snapped to pixels. 1944 // snapped to pixels.
1987 EXPECT_EQ(TransformationMatrix().translate(9, 8), 1945 EXPECT_EQ(TransformationMatrix().translate(9, 8),
1988 svgProperties->svgLocalToBorderBoxTransform()->matrix()); 1946 svgProperties->svgLocalToBorderBoxTransform()->matrix());
1989 1947
1990 const auto* foreignObjectProperties = 1948 const auto* foreignObject = getLayoutObjectByElementId("foreign");
1991 getLayoutObjectByElementId("foreign")->paintProperties(); 1949 const auto* foreignObjectProperties = foreignObject->paintProperties();
1992 EXPECT_EQ(nullptr, foreignObjectProperties->paintOffsetTranslation()); 1950 EXPECT_EQ(nullptr, foreignObjectProperties->paintOffsetTranslation());
1993 // Paint offset of foreignObject should be originated from SVG root and 1951 // Paint offset of foreignObject should be originated from SVG root and
1994 // snapped to pixels. 1952 // snapped to pixels.
1995 EXPECT_EQ(LayoutPoint(4, 5), 1953 EXPECT_EQ(LayoutPoint(4, 5), foreignObject->paintOffset());
1996 foreignObjectProperties->localBorderBoxProperties()->paintOffset);
1997 1954
1998 const auto* divProperties = 1955 const auto* div = getLayoutObjectByElementId("div");
1999 getLayoutObjectByElementId("div")->paintProperties();
2000 // Paint offset of descendant of foreignObject accumulates on paint offset of 1956 // Paint offset of descendant of foreignObject accumulates on paint offset of
2001 // foreignObject. 1957 // foreignObject.
2002 EXPECT_EQ(LayoutPoint(LayoutUnit(4 + 5.6), LayoutUnit(5 + 7.3)), 1958 EXPECT_EQ(LayoutPoint(LayoutUnit(4 + 5.6), LayoutUnit(5 + 7.3)),
2003 divProperties->localBorderBoxProperties()->paintOffset); 1959 div->paintOffset());
2004 } 1960 }
2005 1961
2006 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) { 1962 TEST_P(PaintPropertyTreeBuilderTest, NoRenderingContextByDefault) {
2007 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>"); 1963 setBodyInnerHTML("<div style='transform: translateZ(0)'></div>");
2008 1964
2009 const ObjectPaintProperties* properties = 1965 const ObjectPaintProperties* properties =
2010 document().body()->firstChild()->layoutObject()->paintProperties(); 1966 document().body()->firstChild()->layoutObject()->paintProperties();
2011 ASSERT_TRUE(properties->transform()); 1967 ASSERT_TRUE(properties->transform());
2012 EXPECT_FALSE(properties->transform()->hasRenderingContext()); 1968 EXPECT_FALSE(properties->transform()->hasRenderingContext());
2013 } 1969 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
2382 2338
2383 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( 2339 LayoutBoxModelObject* clipper = toLayoutBoxModelObject(
2384 document().getElementById("clipper")->layoutObject()); 2340 document().getElementById("clipper")->layoutObject());
2385 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); 2341 const ObjectPaintProperties* clipProperties = clipper->paintProperties();
2386 LayoutObject* child = document().getElementById("child")->layoutObject(); 2342 LayoutObject* child = document().getElementById("child")->layoutObject();
2387 const ObjectPaintProperties* childProperties = child->paintProperties(); 2343 const ObjectPaintProperties* childProperties = child->paintProperties();
2388 2344
2389 // No scroll translation because the document does not scroll (not enough 2345 // No scroll translation because the document does not scroll (not enough
2390 // content). 2346 // content).
2391 EXPECT_TRUE(!frameScrollTranslation()); 2347 EXPECT_TRUE(!frameScrollTranslation());
2392 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() 2348 EXPECT_EQ(framePreTranslation(),
2393 ->propertyTreeState.transform()); 2349 clipProperties->localBorderBoxProperties()->transform());
2394 EXPECT_EQ( 2350 EXPECT_EQ(frameContentClip(),
2395 frameContentClip(), 2351 clipProperties->localBorderBoxProperties()->clip());
2396 clipProperties->localBorderBoxProperties()->propertyTreeState.clip());
2397 2352
2398 auto contentsProperties = clipProperties->contentsProperties(); 2353 auto contentsProperties = clipProperties->contentsProperties();
2399 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2354 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2355 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2356 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip());
2357
2400 EXPECT_EQ(framePreTranslation(), 2358 EXPECT_EQ(framePreTranslation(),
2401 contentsProperties.propertyTreeState.transform()); 2359 childProperties->localBorderBoxProperties()->transform());
2402 EXPECT_EQ(clipProperties->overflowClip(), 2360 EXPECT_EQ(clipProperties->overflowClip(),
2403 contentsProperties.propertyTreeState.clip()); 2361 childProperties->localBorderBoxProperties()->clip());
2404 2362
2405 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties() 2363 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->effect());
2406 ->propertyTreeState.transform());
2407 EXPECT_EQ(
2408 clipProperties->overflowClip(),
2409 childProperties->localBorderBoxProperties()->propertyTreeState.clip());
2410
2411 EXPECT_NE(
2412 nullptr,
2413 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
2414 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); 2364 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper);
2415 } 2365 }
2416 2366
2417 TEST_P(PaintPropertyTreeBuilderTest, ContainsPaintContentsTreeState) { 2367 TEST_P(PaintPropertyTreeBuilderTest, ContainsPaintContentsTreeState) {
2418 setBodyInnerHTML( 2368 setBodyInnerHTML(
2419 "<style>body { margin: 20px 30px; }</style>" 2369 "<style>body { margin: 20px 30px; }</style>"
2420 "<div id='clipper'" 2370 "<div id='clipper'"
2421 " style='contain: paint; width: 300px; height: 200px;'>" 2371 " style='contain: paint; width: 300px; height: 200px;'>"
2422 " <div id='child'" 2372 " <div id='child'"
2423 " style='position: relative; width: 400px; height: 500px;'></div>" 2373 " style='position: relative; width: 400px; height: 500px;'></div>"
2424 "</div>"); 2374 "</div>");
2425 2375
2426 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( 2376 LayoutBoxModelObject* clipper = toLayoutBoxModelObject(
2427 document().getElementById("clipper")->layoutObject()); 2377 document().getElementById("clipper")->layoutObject());
2428 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); 2378 const ObjectPaintProperties* clipProperties = clipper->paintProperties();
2429 LayoutObject* child = document().getElementById("child")->layoutObject(); 2379 LayoutObject* child = document().getElementById("child")->layoutObject();
2430 const ObjectPaintProperties* childProperties = child->paintProperties(); 2380 const ObjectPaintProperties* childProperties = child->paintProperties();
2431 2381
2432 // No scroll translation because the document does not scroll (not enough 2382 // No scroll translation because the document does not scroll (not enough
2433 // content). 2383 // content).
2434 EXPECT_TRUE(!frameScrollTranslation()); 2384 EXPECT_TRUE(!frameScrollTranslation());
2435 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() 2385 EXPECT_EQ(framePreTranslation(),
2436 ->propertyTreeState.transform()); 2386 clipProperties->localBorderBoxProperties()->transform());
2437 EXPECT_EQ( 2387 EXPECT_EQ(frameContentClip(),
2438 frameContentClip(), 2388 clipProperties->localBorderBoxProperties()->clip());
2439 clipProperties->localBorderBoxProperties()->propertyTreeState.clip());
2440 2389
2441 auto contentsProperties = clipProperties->contentsProperties(); 2390 auto contentsProperties = clipProperties->contentsProperties();
2442 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2391 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2392 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2393 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip());
2394
2443 EXPECT_EQ(framePreTranslation(), 2395 EXPECT_EQ(framePreTranslation(),
2444 contentsProperties.propertyTreeState.transform()); 2396 childProperties->localBorderBoxProperties()->transform());
2445 EXPECT_EQ(clipProperties->overflowClip(), 2397 EXPECT_EQ(clipProperties->overflowClip(),
2446 contentsProperties.propertyTreeState.clip()); 2398 childProperties->localBorderBoxProperties()->clip());
2447 2399
2448 EXPECT_EQ(framePreTranslation(), childProperties->localBorderBoxProperties() 2400 EXPECT_NE(nullptr, childProperties->localBorderBoxProperties()->effect());
2449 ->propertyTreeState.transform());
2450 EXPECT_EQ(
2451 clipProperties->overflowClip(),
2452 childProperties->localBorderBoxProperties()->propertyTreeState.clip());
2453
2454 EXPECT_NE(
2455 nullptr,
2456 childProperties->localBorderBoxProperties()->propertyTreeState.effect());
2457 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); 2401 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper);
2458 } 2402 }
2459 2403
2460 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsTreeState) { 2404 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollContentsTreeState) {
2461 // This test verifies the tree builder correctly computes and records the 2405 // This test verifies the tree builder correctly computes and records the
2462 // property tree context for a (pseudo) stacking context that is scrolled by a 2406 // property tree context for a (pseudo) stacking context that is scrolled by a
2463 // containing block that is not one of the painting ancestors. 2407 // containing block that is not one of the painting ancestors.
2464 setBodyInnerHTML( 2408 setBodyInnerHTML(
2465 "<style>body { margin: 20px 30px; }</style>" 2409 "<style>body { margin: 20px 30px; }</style>"
2466 "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>" 2410 "<div id='clipper' style='overflow:scroll; width:400px; height:300px;'>"
2467 " <div id='child'" 2411 " <div id='child'"
2468 " style='position:relative; width:500px; height: 600px;'></div>" 2412 " style='position:relative; width:500px; height: 600px;'></div>"
2469 " <div style='width: 200px; height: 10000px'></div>" 2413 " <div style='width: 200px; height: 10000px'></div>"
2470 "</div>" 2414 "</div>"
2471 "<div id='forceScroll' style='height: 4000px;'></div>"); 2415 "<div id='forceScroll' style='height: 4000px;'></div>");
2472 2416
2473 Element* clipperElement = document().getElementById("clipper"); 2417 Element* clipperElement = document().getElementById("clipper");
2474 clipperElement->scrollTo(1, 2); 2418 clipperElement->scrollTo(1, 2);
2475 2419
2476 LayoutBoxModelObject* clipper = 2420 LayoutBoxModelObject* clipper =
2477 toLayoutBoxModelObject(clipperElement->layoutObject()); 2421 toLayoutBoxModelObject(clipperElement->layoutObject());
2478 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); 2422 const ObjectPaintProperties* clipProperties = clipper->paintProperties();
2479 LayoutObject* child = document().getElementById("child")->layoutObject(); 2423 LayoutObject* child = document().getElementById("child")->layoutObject();
2480 const ObjectPaintProperties* childProperties = child->paintProperties(); 2424 const ObjectPaintProperties* childProperties = child->paintProperties();
2481 2425
2482 EXPECT_EQ(frameScrollTranslation(), clipProperties->localBorderBoxProperties() 2426 EXPECT_EQ(frameScrollTranslation(),
2483 ->propertyTreeState.transform()); 2427 clipProperties->localBorderBoxProperties()->transform());
2484 EXPECT_EQ( 2428 EXPECT_EQ(frameContentClip(),
2485 frameContentClip(), 2429 clipProperties->localBorderBoxProperties()->clip());
2486 clipProperties->localBorderBoxProperties()->propertyTreeState.clip());
2487 2430
2488 auto contentsProperties = clipProperties->contentsProperties(); 2431 auto contentsProperties = clipProperties->contentsProperties();
2489 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2432 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2490 EXPECT_EQ(clipProperties->scrollTranslation(), 2433 EXPECT_EQ(clipProperties->scrollTranslation(),
2491 contentsProperties.propertyTreeState.transform()); 2434 contentsProperties.transform());
2492 EXPECT_EQ(clipProperties->overflowClip(), 2435 EXPECT_EQ(clipProperties->overflowClip(), contentsProperties.clip());
2493 contentsProperties.propertyTreeState.clip());
2494 2436
2495 EXPECT_EQ(clipProperties->scrollTranslation(), 2437 EXPECT_EQ(clipProperties->scrollTranslation(),
2496 childProperties->localBorderBoxProperties() 2438 childProperties->localBorderBoxProperties()->transform());
2497 ->propertyTreeState.transform()); 2439 EXPECT_EQ(clipProperties->overflowClip(),
2498 EXPECT_EQ( 2440 childProperties->localBorderBoxProperties()->clip());
2499 clipProperties->overflowClip(),
2500 childProperties->localBorderBoxProperties()->propertyTreeState.clip());
2501 2441
2502 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper); 2442 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 500, 600), child, clipper);
2503 } 2443 }
2504 2444
2505 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollWithRoundedRect) { 2445 TEST_P(PaintPropertyTreeBuilderTest, OverflowScrollWithRoundedRect) {
2506 setBodyInnerHTML( 2446 setBodyInnerHTML(
2507 "<style>" 2447 "<style>"
2508 " * { margin: 0; }" 2448 " * { margin: 0; }"
2509 " ::-webkit-scrollbar {" 2449 " ::-webkit-scrollbar {"
2510 " width: 13px;" 2450 " width: 13px;"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 "</div>"); 2500 "</div>");
2561 2501
2562 LayoutBoxModelObject* clipper = toLayoutBoxModelObject( 2502 LayoutBoxModelObject* clipper = toLayoutBoxModelObject(
2563 document().getElementById("clipper")->layoutObject()); 2503 document().getElementById("clipper")->layoutObject());
2564 const ObjectPaintProperties* clipProperties = clipper->paintProperties(); 2504 const ObjectPaintProperties* clipProperties = clipper->paintProperties();
2565 LayoutObject* child = document().getElementById("child")->layoutObject(); 2505 LayoutObject* child = document().getElementById("child")->layoutObject();
2566 2506
2567 // No scroll translation because the document does not scroll (not enough 2507 // No scroll translation because the document does not scroll (not enough
2568 // content). 2508 // content).
2569 EXPECT_TRUE(!frameScrollTranslation()); 2509 EXPECT_TRUE(!frameScrollTranslation());
2570 EXPECT_EQ(framePreTranslation(), clipProperties->localBorderBoxProperties() 2510 EXPECT_EQ(framePreTranslation(),
2571 ->propertyTreeState.transform()); 2511 clipProperties->localBorderBoxProperties()->transform());
2572 // 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.
2573 EXPECT_EQ( 2513 EXPECT_EQ(clipProperties->cssClip(),
2574 clipProperties->cssClip(), 2514 clipProperties->localBorderBoxProperties()->clip());
2575 clipProperties->localBorderBoxProperties()->propertyTreeState.clip());
2576 2515
2577 auto contentsProperties = clipProperties->contentsProperties(); 2516 auto contentsProperties = clipProperties->contentsProperties();
2578 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2517 EXPECT_EQ(LayoutPoint(30, 20), clipper->paintOffset());
2579 EXPECT_EQ(framePreTranslation(), 2518 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2580 contentsProperties.propertyTreeState.transform()); 2519 EXPECT_EQ(clipProperties->cssClip(), contentsProperties.clip());
2581 EXPECT_EQ(clipProperties->cssClip(),
2582 contentsProperties.propertyTreeState.clip());
2583 2520
2584 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper); 2521 CHECK_EXACT_VISUAL_RECT(LayoutRect(0, 0, 400, 500), child, clipper);
2585 } 2522 }
2586 2523
2587 TEST_P(PaintPropertyTreeBuilderTest, 2524 TEST_P(PaintPropertyTreeBuilderTest,
2588 SvgLocalToBorderBoxTransformContentsTreeState) { 2525 SvgLocalToBorderBoxTransformContentsTreeState) {
2589 setBodyInnerHTML( 2526 setBodyInnerHTML(
2590 "<style>" 2527 "<style>"
2591 " body {" 2528 " body {"
2592 " margin: 20px 30px;" 2529 " margin: 20px 30px;"
2593 " }" 2530 " }"
2594 " svg {" 2531 " svg {"
2595 " position: absolute;" 2532 " position: absolute;"
2596 " }" 2533 " }"
2597 " rect {" 2534 " rect {"
2598 " transform: translate(100px, 100px);" 2535 " transform: translate(100px, 100px);"
2599 " }" 2536 " }"
2600 "</style>" 2537 "</style>"
2601 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 " 2538 "<svg id='svgWithViewBox' width='100px' height='100px' viewBox='50 50 "
2602 "100 100'>" 2539 "100 100'>"
2603 " <rect id='rect' width='100px' height='100px' />" 2540 " <rect id='rect' width='100px' height='100px' />"
2604 "</svg>"); 2541 "</svg>");
2605 2542
2606 LayoutObject& svgWithViewBox = 2543 LayoutObject& svgWithViewBox =
2607 *document().getElementById("svgWithViewBox")->layoutObject(); 2544 *document().getElementById("svgWithViewBox")->layoutObject();
2608 const ObjectPaintProperties* svgWithViewBoxProperties = 2545 const ObjectPaintProperties* svgWithViewBoxProperties =
2609 svgWithViewBox.paintProperties(); 2546 svgWithViewBox.paintProperties();
2610 2547
2611 EXPECT_EQ(framePreTranslation(), 2548 EXPECT_EQ(framePreTranslation(),
2612 svgWithViewBoxProperties->localBorderBoxProperties() 2549 svgWithViewBoxProperties->localBorderBoxProperties()->transform());
2613 ->propertyTreeState.transform());
2614 2550
2615 auto contentsProperties = svgWithViewBoxProperties->contentsProperties(); 2551 auto contentsProperties = svgWithViewBoxProperties->contentsProperties();
2616 EXPECT_EQ(LayoutPoint(30, 20), contentsProperties.paintOffset); 2552 EXPECT_EQ(LayoutPoint(30, 20), svgWithViewBox.paintOffset());
2617 EXPECT_EQ(framePreTranslation(), 2553 EXPECT_EQ(framePreTranslation(), contentsProperties.transform());
2618 contentsProperties.propertyTreeState.transform());
2619 } 2554 }
2620 2555
2621 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) { 2556 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties) {
2622 setBodyInnerHTML( 2557 setBodyInnerHTML(
2623 "<style>" 2558 "<style>"
2624 " body {" 2559 " body {"
2625 " margin: 0px;" 2560 " margin: 0px;"
2626 " }" 2561 " }"
2627 " #overflowHidden {" 2562 " #overflowHidden {"
2628 " overflow: hidden;" 2563 " overflow: hidden;"
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 " <div id=top-left class=abs style='top: 0; left: 0'></div>" 2895 " <div id=top-left class=abs style='top: 0; left: 0'></div>"
2961 " <div id=bottom-right class=abs style='bottom: 0; right: 0'></div>" 2896 " <div id=bottom-right class=abs style='bottom: 0; right: 0'></div>"
2962 " </div>" 2897 " </div>"
2963 " <div id=space3 class=space></div>" 2898 " <div id=space3 class=space></div>"
2964 " <div id=space4 class=space></div>" 2899 " <div id=space4 class=space></div>"
2965 " </div>" 2900 " </div>"
2966 "</div>"); 2901 "</div>");
2967 2902
2968 // Above the spanner. 2903 // Above the spanner.
2969 // Column 1. 2904 // Column 1.
2970 EXPECT_EQ(LayoutPoint(), paintOffset(getLayoutObjectByElementId("space1"))); 2905 EXPECT_EQ(LayoutPoint(), getLayoutObjectByElementId("space1")->paintOffset());
2971 // Column 2. TODO(crbug.com/648274): This is incorrect. Should be (100, 0). 2906 // Column 2. TODO(crbug.com/648274): This is incorrect. Should be (100, 0).
2972 EXPECT_EQ(LayoutPoint(0, 30), 2907 EXPECT_EQ(LayoutPoint(0, 30),
2973 paintOffset(getLayoutObjectByElementId("space2"))); 2908 getLayoutObjectByElementId("space2")->paintOffset());
2974 2909
2975 // The spanner's normal flow. 2910 // The spanner's normal flow.
2976 EXPECT_EQ(LayoutPoint(0, 30), 2911 EXPECT_EQ(LayoutPoint(0, 30),
2977 paintOffset(getLayoutObjectByElementId("spanner"))); 2912 getLayoutObjectByElementId("spanner")->paintOffset());
2978 EXPECT_EQ(LayoutPoint(0, 30), 2913 EXPECT_EQ(LayoutPoint(0, 30),
2979 paintOffset(getLayoutObjectByElementId("normal"))); 2914 getLayoutObjectByElementId("normal")->paintOffset());
2980 2915
2981 // Below the spanner. 2916 // Below the spanner.
2982 // Column 1. TODO(crbug.com/648274): This is incorrect. Should be (0, 80). 2917 // Column 1. TODO(crbug.com/648274): This is incorrect. Should be (0, 80).
2983 EXPECT_EQ(LayoutPoint(0, 60), 2918 EXPECT_EQ(LayoutPoint(0, 60),
2984 paintOffset(getLayoutObjectByElementId("space3"))); 2919 getLayoutObjectByElementId("space3")->paintOffset());
2985 // Column 2. TODO(crbug.com/648274): This is incorrect. Should be (100, 80). 2920 // Column 2. TODO(crbug.com/648274): This is incorrect. Should be (100, 80).
2986 EXPECT_EQ(LayoutPoint(0, 90), 2921 EXPECT_EQ(LayoutPoint(0, 90),
2987 paintOffset(getLayoutObjectByElementId("space4"))); 2922 getLayoutObjectByElementId("space4")->paintOffset());
2988 2923
2989 // Out-of-flow positioned descendants of the spanner. They are laid out in 2924 // Out-of-flow positioned descendants of the spanner. They are laid out in
2990 // the relative-position container. 2925 // the relative-position container.
2991 2926
2992 // "top-left" should be aligned to the top-left corner of space1. 2927 // "top-left" should be aligned to the top-left corner of space1.
2993 EXPECT_EQ(LayoutPoint(0, 0), 2928 EXPECT_EQ(LayoutPoint(0, 0),
2994 paintOffset(getLayoutObjectByElementId("top-left"))); 2929 getLayoutObjectByElementId("top-left")->paintOffset());
2995 2930
2996 // "bottom-right" should be aligned to the bottom-right corner of space4. 2931 // "bottom-right" should be aligned to the bottom-right corner of space4.
2997 // TODO(crbug.com/648274): This is incorrect. Should be (180, 90). 2932 // TODO(crbug.com/648274): This is incorrect. Should be (180, 90).
2998 EXPECT_EQ(LayoutPoint(80, 100), 2933 EXPECT_EQ(LayoutPoint(80, 100),
2999 paintOffset(getLayoutObjectByElementId("bottom-right"))); 2934 getLayoutObjectByElementId("bottom-right")->paintOffset());
3000 } 2935 }
3001 2936
3002 // Ensures no crash with multi-column containing relative-position inline with 2937 // Ensures no crash with multi-column containing relative-position inline with
3003 // spanner with absolute-position children. 2938 // spanner with absolute-position children.
3004 TEST_P(PaintPropertyTreeBuilderTest, 2939 TEST_P(PaintPropertyTreeBuilderTest,
3005 MultiColumnInlineRelativeAndSpannerAndAbsPos) { 2940 MultiColumnInlineRelativeAndSpannerAndAbsPos) {
3006 setBodyInnerHTML( 2941 setBodyInnerHTML(
3007 "<div style='columns:2; width: 200px; column-gap: 0'>" 2942 "<div style='columns:2; width: 200px; column-gap: 0'>"
3008 " <span style='position: relative'>" 2943 " <span style='position: relative'>"
3009 " <span id=spanner style='column-span: all'>" 2944 " <span id=spanner style='column-span: all'>"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3050 const ObjectPaintProperties* clipProperties = 2985 const ObjectPaintProperties* clipProperties =
3051 getLayoutObjectByElementId("clip")->paintProperties(); 2986 getLayoutObjectByElementId("clip")->paintProperties();
3052 const ObjectPaintProperties* filterProperties = 2987 const ObjectPaintProperties* filterProperties =
3053 getLayoutObjectByElementId("filter")->paintProperties(); 2988 getLayoutObjectByElementId("filter")->paintProperties();
3054 EXPECT_TRUE(filterProperties->effect()->parent()->isRoot()); 2989 EXPECT_TRUE(filterProperties->effect()->parent()->isRoot());
3055 EXPECT_EQ(frameScrollTranslation(), 2990 EXPECT_EQ(frameScrollTranslation(),
3056 filterProperties->effect()->localTransformSpace()); 2991 filterProperties->effect()->localTransformSpace());
3057 EXPECT_EQ(clipProperties->overflowClip(), 2992 EXPECT_EQ(clipProperties->overflowClip(),
3058 filterProperties->effect()->outputClip()); 2993 filterProperties->effect()->outputClip());
3059 2994
3060 const ObjectPaintProperties* childProperties =
3061 getLayoutObjectByElementId("child")->paintProperties();
3062 const PropertyTreeState& childPaintState = 2995 const PropertyTreeState& childPaintState =
3063 childProperties->localBorderBoxProperties()->propertyTreeState; 2996 *getLayoutObjectByElementId("child")
2997 ->paintProperties()
2998 ->localBorderBoxProperties();
3064 2999
3065 // This will change once we added clip expansion node. 3000 // This will change once we added clip expansion node.
3066 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip()); 3001 EXPECT_EQ(filterProperties->effect()->outputClip(), childPaintState.clip());
3067 EXPECT_EQ(filterProperties->effect(), childPaintState.effect()); 3002 EXPECT_EQ(filterProperties->effect(), childPaintState.effect());
3068 } 3003 }
3069 3004
3070 TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutTransform) { 3005 TEST_P(PaintPropertyTreeBuilderTest, TransformOriginWithAndWithoutTransform) {
3071 setBodyInnerHTML( 3006 setBodyInnerHTML(
3072 "<style>" 3007 "<style>"
3073 " body { margin: 0 }" 3008 " body { margin: 0 }"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 " #ancestor { position: absolute; overflow: hidden }" 3078 " #ancestor { position: absolute; overflow: hidden }"
3144 " #descendant { position: absolute }" 3079 " #descendant { position: absolute }"
3145 "</style>" 3080 "</style>"
3146 "<div id='ancestor'>" 3081 "<div id='ancestor'>"
3147 " <div id='descendant'></div>" 3082 " <div id='descendant'></div>"
3148 "</div>"); 3083 "</div>");
3149 3084
3150 LayoutObject* ancestor = getLayoutObjectByElementId("ancestor"); 3085 LayoutObject* ancestor = getLayoutObjectByElementId("ancestor");
3151 LayoutObject* descendant = getLayoutObjectByElementId("descendant"); 3086 LayoutObject* descendant = getLayoutObjectByElementId("descendant");
3152 EXPECT_EQ(ancestor->paintProperties()->overflowClip(), 3087 EXPECT_EQ(ancestor->paintProperties()->overflowClip(),
3153 descendant->paintProperties() 3088 descendant->paintProperties()->localBorderBoxProperties()->clip());
3154 ->localBorderBoxProperties()
3155 ->propertyTreeState.clip());
3156 3089
3157 toElement(ancestor->node()) 3090 toElement(ancestor->node())
3158 ->setAttribute(HTMLNames::styleAttr, "position: static"); 3091 ->setAttribute(HTMLNames::styleAttr, "position: static");
3159 document().view()->updateAllLifecyclePhases(); 3092 document().view()->updateAllLifecyclePhases();
3160 EXPECT_NE(ancestor->paintProperties()->overflowClip(), 3093 EXPECT_NE(ancestor->paintProperties()->overflowClip(),
3161 descendant->paintProperties() 3094 descendant->paintProperties()->localBorderBoxProperties()->clip());
3162 ->localBorderBoxProperties()
3163 ->propertyTreeState.clip());
3164 } 3095 }
3165 3096
3166 TEST_P(PaintPropertyTreeBuilderTest, 3097 TEST_P(PaintPropertyTreeBuilderTest,
3167 TransformNodeNotAnimatedHasNoCompositorElementId) { 3098 TransformNodeNotAnimatedHasNoCompositorElementId) {
3168 setBodyInnerHTML("<div id='target' style='transform: translateX(2em)'></div"); 3099 setBodyInnerHTML("<div id='target' style='transform: translateX(2em)'></div");
3169 const ObjectPaintProperties* properties = paintPropertiesForElement("target"); 3100 const ObjectPaintProperties* properties = paintPropertiesForElement("target");
3170 EXPECT_TRUE(properties->transform()); 3101 EXPECT_TRUE(properties->transform());
3171 EXPECT_EQ(CompositorElementId(), 3102 EXPECT_EQ(CompositorElementId(),
3172 properties->transform()->compositorElementId()); 3103 properties->transform()->compositorElementId());
3173 } 3104 }
(...skipping 16 matching lines...) Expand all
3190 } 3121 }
3191 3122
3192 TEST_P(PaintPropertyTreeBuilderTest, EffectNodeAnimatedHasCompositorElementId) { 3123 TEST_P(PaintPropertyTreeBuilderTest, EffectNodeAnimatedHasCompositorElementId) {
3193 loadTestData("opacity-animation.html"); 3124 loadTestData("opacity-animation.html");
3194 const ObjectPaintProperties* properties = paintPropertiesForElement("target"); 3125 const ObjectPaintProperties* properties = paintPropertiesForElement("target");
3195 EXPECT_TRUE(properties->effect()); 3126 EXPECT_TRUE(properties->effect());
3196 EXPECT_NE(CompositorElementId(), properties->effect()->compositorElementId()); 3127 EXPECT_NE(CompositorElementId(), properties->effect()->compositorElementId());
3197 } 3128 }
3198 3129
3199 } // namespace blink 3130 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698