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

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

Issue 2144823006: Reuse existing paint property node is possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 5 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/layout/LayoutTestHelper.h" 5 #include "core/layout/LayoutTestHelper.h"
6 #include "core/layout/LayoutTreeAsText.h" 6 #include "core/layout/LayoutTreeAsText.h"
7 #include "core/layout/api/LayoutViewItem.h" 7 #include "core/layout/api/LayoutViewItem.h"
8 #include "core/paint/ObjectPaintProperties.h" 8 #include "core/paint/ObjectPaintProperties.h"
9 #include "platform/graphics/paint/GeometryMapper.h" 9 #include "platform/graphics/paint/GeometryMapper.h"
10 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 10 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
(...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform( )); 1102 EXPECT_EQ(nullptr, svgWithTransformProperties->svgLocalToBorderBoxTransform( ));
1103 1103
1104 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout Object(); 1104 LayoutObject& rectWithTransform = *document().getElementById("rect")->layout Object();
1105 ObjectPaintProperties* rectWithTransformProperties = rectWithTransform.objec tPaintProperties(); 1105 ObjectPaintProperties* rectWithTransformProperties = rectWithTransform.objec tPaintProperties();
1106 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie s->transform()->matrix()); 1106 EXPECT_EQ(TransformationMatrix().translate(1, 1), rectWithTransformPropertie s->transform()->matrix());
1107 1107
1108 // Ensure there is no PaintOffset transform between the rect and the svg's t ransform. 1108 // Ensure there is no PaintOffset transform between the rect and the svg's t ransform.
1109 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti es->transform()->parent()); 1109 EXPECT_EQ(svgWithTransformProperties->transform(), rectWithTransformProperti es->transform()->parent());
1110 } 1110 }
1111 1111
1112 TEST_F(PaintPropertyTreeBuilderTest, CachedProperties)
1113 {
1114 setBodyInnerHTML(
1115 "<div id='a' style='transform: translate(33px, 44px)'>"
1116 " <div id='b' style='transform: translate(55px, 66px)'>"
1117 " <div id='c' style='transform: translate(77px, 88px)'>C<div>"
1118 " </div>"
1119 "</div>");
1120
1121 Element* a = document().getElementById("a");
1122 ObjectPaintProperties* aProperties = a->layoutObject()->objectPaintPropertie s();
1123 TransformPaintPropertyNode* aTransformNode = aProperties->transform();
1124 EXPECT_EQ(TransformationMatrix().translate(33, 44), aTransformNode->matrix() );
1125
1126 Element* b = document().getElementById("b");
1127 ObjectPaintProperties* bProperties = b->layoutObject()->objectPaintPropertie s();
1128 TransformPaintPropertyNode* bTransformNode = bProperties->transform();
1129 EXPECT_EQ(TransformationMatrix().translate(55, 66), bTransformNode->matrix() );
1130
1131 Element* c = document().getElementById("c");
1132 ObjectPaintProperties* cProperties = c->layoutObject()->objectPaintPropertie s();
1133 TransformPaintPropertyNode* cTransformNode = cProperties->transform();
1134 EXPECT_EQ(TransformationMatrix().translate(77, 88), cTransformNode->matrix() );
1135
1136 // Change transform of b. B's transform node should be a new node with the n ew value,
1137 // and a and c's transform nodes should be unchanged (with c's parent adjust ed).
1138 b->setAttribute(HTMLNames::styleAttr, "transform: translate(111px, 222px)");
1139 document().view()->updateAllLifecyclePhases();
1140
1141 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1142 EXPECT_EQ(aTransformNode, aProperties->transform());
1143
1144 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1145 bTransformNode = bProperties->transform();
1146 EXPECT_EQ(TransformationMatrix().translate(111, 222), bTransformNode->matrix ());
1147 EXPECT_EQ(aTransformNode, bTransformNode->parent());
1148
1149 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1150 EXPECT_EQ(cTransformNode, cProperties->transform());
1151 EXPECT_EQ(bTransformNode, cTransformNode->parent());
1152
1153 // Remove transform from b. B's transform node should be removed from the tr ee,
1154 // and a and c's transform nodes should be unchanged (with c's parent adjust ed).
1155 b->setAttribute(HTMLNames::styleAttr, "");
1156 document().view()->updateAllLifecyclePhases();
1157
1158 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1159 EXPECT_EQ(aTransformNode, aProperties->transform());
1160
1161 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1162 EXPECT_EQ(nullptr, bProperties->transform());
1163
1164 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1165 EXPECT_EQ(cTransformNode, cProperties->transform());
1166 EXPECT_EQ(aTransformNode, cTransformNode->parent());
1167
1168 // Re-add transform to b. B's transform node should be inserted into the tre e,
1169 // and a and c's transform nodes should be unchanged (with c's parent adjust ed).
1170 b->setAttribute(HTMLNames::styleAttr, "transform: translate(4px, 5px)");
1171 document().view()->updateAllLifecyclePhases();
1172
1173 EXPECT_EQ(aProperties, a->layoutObject()->objectPaintProperties());
1174 EXPECT_EQ(aTransformNode, aProperties->transform());
1175
1176 EXPECT_EQ(bProperties, b->layoutObject()->objectPaintProperties());
1177 bTransformNode = bProperties->transform();
1178 EXPECT_EQ(TransformationMatrix().translate(4, 5), bTransformNode->matrix());
1179 EXPECT_EQ(aTransformNode, bTransformNode->parent());
1180
1181 EXPECT_EQ(cProperties, c->layoutObject()->objectPaintProperties());
1182 EXPECT_EQ(cTransformNode, cProperties->transform());
1183 EXPECT_EQ(bTransformNode, cTransformNode->parent());
1184 }
1185
1112 } // namespace blink 1186 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698