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

Unified Diff: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp

Issue 2750463003: Reduce the number of ObjectPaintProperties (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
diff --git a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
index a2c6de287b2910940ec08b3aca70e9526c64b7de..d8ed4c874b9605f68ad15f4a18e31d9ac95a8011 100644
--- a/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
+++ b/third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilderTest.cpp
@@ -75,49 +75,47 @@ void PaintPropertyTreeBuilderTest::TearDown() {
Settings::setMockScrollbarsEnabled(false);
}
-#define CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, \
- slopFactor) \
- do { \
- std::unique_ptr<GeometryMapper> geometryMapper = GeometryMapper::create(); \
- LayoutRect source((sourceLayoutObject)->localVisualRect()); \
- source.moveBy((sourceLayoutObject)->paintOffset()); \
- const auto& contentsProperties = \
- *(ancestorLayoutObject)->paintProperties()->contentsProperties(); \
- FloatRect actualFloatRect(source); \
- geometryMapper->sourceToDestinationVisualRect( \
- *(sourceLayoutObject)->paintProperties()->localBorderBoxProperties(), \
- contentsProperties, actualFloatRect); \
- LayoutRect actual(actualFloatRect); \
- actual.moveBy(-(ancestorLayoutObject)->paintOffset()); \
- EXPECT_EQ(expected, actual) \
- << "GeometryMapper: expected: " << expected.toString() \
- << ", actual: " << actual.toString(); \
- \
- if (slopFactor == LayoutUnit::max()) \
- break; \
- LayoutRect slowPathRect = (sourceLayoutObject)->localVisualRect(); \
- (sourceLayoutObject) \
- ->mapToVisualRectInAncestorSpace(ancestorLayoutObject, slowPathRect); \
- if (slopFactor) { \
- LayoutRect inflatedActual = LayoutRect(actual); \
- inflatedActual.inflate(slopFactor); \
- SCOPED_TRACE( \
- String::format("Old path rect: %s, Actual: %s, Inflated actual: %s", \
- slowPathRect.toString().ascii().data(), \
- actual.toString().ascii().data(), \
- inflatedActual.toString().ascii().data())); \
- EXPECT_TRUE(slowPathRect.contains(LayoutRect(actual))); \
- EXPECT_TRUE(inflatedActual.contains(slowPathRect)); \
- } else { \
- EXPECT_EQ(expected, slowPathRect) \
- << "Slow path: expected: " << slowPathRect.toString() \
- << ", actual: " << actual.toString().ascii().data(); \
- } \
+#define CHECK_VISUAL_RECT(expected, sourceObject, ancestorObject, slopFactor) \
+ do { \
+ if ((sourceObject)->hasLayer() && (ancestorObject)->hasLayer()) { \
+ auto geometryMapper = GeometryMapper::create(); \
+ LayoutRect source((sourceObject)->localVisualRect()); \
+ source.moveBy((sourceObject)->paintOffset()); \
+ const auto& contentsProperties = \
+ *(ancestorObject)->paintProperties()->contentsProperties(); \
+ FloatRect actualFloatRect(source); \
+ geometryMapper->sourceToDestinationVisualRect( \
+ *(sourceObject)->paintProperties()->localBorderBoxProperties(), \
+ contentsProperties, actualFloatRect); \
+ LayoutRect actual(actualFloatRect); \
+ actual.moveBy(-(ancestorObject)->paintOffset()); \
+ SCOPED_TRACE("GeometryMapper: "); \
+ EXPECT_EQ(expected, actual); \
+ } \
+ \
+ if (slopFactor == LayoutUnit::max()) \
+ break; \
+ LayoutRect slowPathRect = (sourceObject)->localVisualRect(); \
+ (sourceObject) \
+ ->mapToVisualRectInAncestorSpace(ancestorObject, slowPathRect); \
+ if (slopFactor) { \
+ LayoutRect inflatedExpected = LayoutRect(expected); \
+ inflatedExpected.inflate(slopFactor); \
+ SCOPED_TRACE(String::format( \
+ "Old path rect: %s, Expected: %s, Inflated expected: %s", \
+ slowPathRect.toString().ascii().data(), \
+ expected.toString().ascii().data(), \
+ inflatedExpected.toString().ascii().data())); \
+ EXPECT_TRUE(slowPathRect.contains(LayoutRect(expected))); \
+ EXPECT_TRUE(inflatedExpected.contains(slowPathRect)); \
+ } else { \
+ SCOPED_TRACE("Slow path: "); \
+ EXPECT_EQ(expected, slowPathRect); \
+ } \
} while (0)
-#define CHECK_EXACT_VISUAL_RECT(expected, sourceLayoutObject, \
- ancestorLayoutObject) \
- CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, 0)
+#define CHECK_EXACT_VISUAL_RECT(expected, sourceObject, ancestorObject) \
+ CHECK_VISUAL_RECT(expected, sourceObject, ancestorObject, 0)
INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreeBuilderTest, ::testing::Bool());
@@ -534,7 +532,7 @@ TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) {
document().getElementById("nodeWithoutOpacity")->layoutObject();
const ObjectPaintProperties* nodeWithoutOpacityProperties =
nodeWithoutOpacity->paintProperties();
- EXPECT_NE(nullptr, nodeWithoutOpacityProperties);
+ EXPECT_EQ(nullptr, nodeWithoutOpacityProperties);
CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 100, 200), nodeWithoutOpacity,
document().view()->layoutView());
@@ -550,7 +548,7 @@ TEST_P(PaintPropertyTreeBuilderTest, NestedOpacityEffect) {
LayoutObject* grandChildWithoutOpacity =
document().getElementById("grandChildWithoutOpacity")->layoutObject();
- EXPECT_NE(nullptr, grandChildWithoutOpacity->paintProperties());
+ EXPECT_EQ(nullptr, grandChildWithoutOpacity->paintProperties());
CHECK_EXACT_VISUAL_RECT(LayoutRect(8, 8, 20, 30), grandChildWithoutOpacity,
document().view()->layoutView());
@@ -1449,7 +1447,7 @@ TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) {
" width: 100px;"
" height: 100px;"
" }"
- " #abs {"
+ " #absolute {"
" position: absolute;"
" left: 654px;"
" top: 321px;"
@@ -1484,7 +1482,7 @@ TEST_P(PaintPropertyTreeBuilderTest, CSSClipAbsPositionDescendant) {
absPosProperties->localBorderBoxProperties()->clip());
EXPECT_EQ(framePreTranslation(),
absPosProperties->localBorderBoxProperties()->transform());
- EXPECT_EQ(LayoutPoint(123, 456), absolute->paintOffset());
+ EXPECT_EQ(LayoutPoint(777, 777), absolute->paintOffset());
CHECK_VISUAL_RECT(LayoutRect(), absolute, document().view()->layoutView(),
// TODO(crbug.com/599939): CSS clip of fixed-position
// descendants is broken in
@@ -3142,9 +3140,10 @@ TEST_P(PaintPropertyTreeBuilderTest, FloatUnderInline) {
"<div style='position: absolute; top: 55px; left: 66px'>"
" <span id='span'"
" style='position: relative; top: 100px; left: 200px; opacity: 0.5'>"
- " <div id='target' style='float: left; width: 33px; height: 44px'>"
+ " <div id='target'"
+ " style='overflow: hidden; float: left; width: 3px; height: 4px'>"
" </div>"
- " </span"
+ " </span>"
"</div>");
LayoutObject* span = getLayoutObjectByElementId("span");

Powered by Google App Engine
This is Rietveld 408576698