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

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

Issue 1651153003: [SPv2] Adds pre-computed paint property context to PaintLayer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: renamed the cache. revised comments. Created 4 years, 10 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/PaintPropertyTreeBuilder.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/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/LayoutView.h" 7 #include "core/layout/LayoutView.h"
8 #include "core/paint/ObjectPaintProperties.h" 8 #include "core/paint/ObjectPaintProperties.h"
9 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 9 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
10 #include "platform/testing/UnitTestHelpers.h" 10 #include "platform/testing/UnitTestHelpers.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix()); 127 EXPECT_EQ(TransformationMatrix(), frameView->preTranslation()->matrix());
128 EXPECT_EQ(nullptr, frameView->preTranslation()->parent()); 128 EXPECT_EQ(nullptr, frameView->preTranslation()->parent());
129 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl ation()->matrix()); 129 EXPECT_EQ(TransformationMatrix().translate(0, -100), frameView->scrollTransl ation()->matrix());
130 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t()); 130 EXPECT_EQ(frameView->preTranslation(), frameView->scrollTranslation()->paren t());
131 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf ormSpace()); 131 EXPECT_EQ(frameView->preTranslation(), frameView->contentClip()->localTransf ormSpace());
132 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe ct()); 132 EXPECT_EQ(FloatRoundedRect(0, 0, 800, 600), frameView->contentClip()->clipRe ct());
133 EXPECT_EQ(nullptr, frameView->contentClip()->parent()); 133 EXPECT_EQ(nullptr, frameView->contentClip()->parent());
134 134
135 LayoutView* layoutView = document().layoutView(); 135 LayoutView* layoutView = document().layoutView();
136 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert ies(); 136 ObjectPaintProperties* layoutViewProperties = layoutView->objectPaintPropert ies();
137 EXPECT_EQ(nullptr, layoutViewProperties); 137 EXPECT_EQ(nullptr, layoutViewProperties->scrollTranslation());
138 } 138 }
139 139
140 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created. 140 // TODO(trchen): Settings::rootLayerScrolls cannot be switched after main frame being created.
141 // Need to set it during test setup. Besides that, the test still won't work bec ause 141 // Need to set it during test setup. Besides that, the test still won't work bec ause
142 // root layer scrolling mode is not compatible with SPv2 at this moment. 142 // root layer scrolling mode is not compatible with SPv2 at this moment.
143 // (Duplicate display item ID for FrameView and LayoutView.) 143 // (Duplicate display item ID for FrameView and LayoutView.)
144 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls) 144 TEST_F(PaintPropertyTreeBuilderTest, DISABLED_FrameScrollingRootLayerScrolls)
145 { 145 {
146 document().settings()->setRootLayerScrolls(true); 146 document().settings()->setRootLayerScrolls(true);
147 147
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 " </div>" 269 " </div>"
270 "</div>"); 270 "</div>");
271 271
272 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject(); 272 LayoutObject& nodeWithOpacity = *document().getElementById("nodeWithOpacity" )->layoutObject();
273 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai ntProperties(); 273 ObjectPaintProperties* nodeWithOpacityProperties = nodeWithOpacity.objectPai ntProperties();
274 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity()); 274 EXPECT_EQ(0.6f, nodeWithOpacityProperties->effect()->opacity());
275 EXPECT_EQ(nullptr, nodeWithOpacityProperties->effect()->parent()); 275 EXPECT_EQ(nullptr, nodeWithOpacityProperties->effect()->parent());
276 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform()); 276 EXPECT_EQ(nullptr, nodeWithOpacityProperties->transform());
277 277
278 LayoutObject& childWithStackingContext = *document().getElementById("childWi thStackingContext")->layoutObject(); 278 LayoutObject& childWithStackingContext = *document().getElementById("childWi thStackingContext")->layoutObject();
279 EXPECT_EQ(nullptr, childWithStackingContext.objectPaintProperties()); 279 ObjectPaintProperties* childWithStackingContextProperties = childWithStackin gContext.objectPaintProperties();
280 EXPECT_EQ(nullptr, childWithStackingContextProperties->effect());
281 EXPECT_EQ(nullptr, childWithStackingContextProperties->transform());
280 282
281 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject(); 283 LayoutObject& grandChildWithOpacity = *document().getElementById("grandChild WithOpacity")->layoutObject();
282 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci ty.objectPaintProperties(); 284 ObjectPaintProperties* grandChildWithOpacityProperties = grandChildWithOpaci ty.objectPaintProperties();
283 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity()); 285 EXPECT_EQ(0.4f, grandChildWithOpacityProperties->effect()->opacity());
284 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent()); 286 EXPECT_EQ(nodeWithOpacityProperties->effect(), grandChildWithOpacityProperti es->effect()->parent());
285 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform()); 287 EXPECT_EQ(nullptr, grandChildWithOpacityProperties->transform());
286 } 288 }
287 289
288 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG) 290 TEST_F(PaintPropertyTreeBuilderTest, EffectNodesInSVG)
289 { 291 {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 569
568 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject(); 570 LayoutObject& divWithTransform = *document().getElementById("divWithTransfor m")->layoutObject();
569 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP aintProperties(); 571 ObjectPaintProperties* divWithTransformProperties = divWithTransform.objectP aintProperties();
570 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope rties->transform()->matrix()); 572 EXPECT_EQ(TransformationMatrix().translate3d(1, 2, 3), divWithTransformPrope rties->transform()->matrix());
571 573
572 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject(); 574 LayoutObject* innerDivWithTransform = frameDocument.getElementById("transfor m")->layoutObject();
573 ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithTransfo rm->objectPaintProperties(); 575 ObjectPaintProperties* innerDivWithTransformProperties = innerDivWithTransfo rm->objectPaintProperties();
574 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivWithTransform Properties->transform()->matrix()); 576 EXPECT_EQ(TransformationMatrix().translate3d(4, 5, 6), innerDivWithTransform Properties->transform()->matrix());
575 } 577 }
576 578
579 TEST_F(PaintPropertyTreeBuilderTest, TreeContextClipByNonStackingContext)
580 {
581 // This test verifies the tree builder correctly computes and records the pr operty tree context
582 // for a (pseudo) stacking context that is scrolled by a containing block th at is not one of
583 // the painting ancestors.
584 setBodyInnerHTML(
585 "<style>body { margin: 0; }</style>"
586 "<div id='scroller' style='overflow:scroll; width:400px; height:300px;'> "
587 " <div id='child' style='position:relative;'></div>"
588 " <div style='height:10000px;'></div>"
589 "</div>"
590 );
591
592 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t();
593 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties() ;
594 LayoutObject& child = *document().getElementById("child")->layoutObject();
595 ObjectPaintProperties* childProperties = child.objectPaintProperties();
596
597 EXPECT_EQ(scrollerProperties->overflowClip(), childProperties->localBorderBo xProperties()->properties.clip);
598 EXPECT_EQ(scrollerProperties->scrollTranslation(), childProperties->localBor derBoxProperties()->properties.transform);
599 EXPECT_EQ(nullptr, childProperties->localBorderBoxProperties()->properties.e ffect);
600 }
601
602 TEST_F(PaintPropertyTreeBuilderTest, TreeContextUnclipFromParentStackingContext)
603 {
604 // This test verifies the tree builder correctly computes and records the pr operty tree context
605 // for a (pseudo) stacking context that has a scrolling painting ancestor th at is not its
606 // containing block (thus should not be scrolled by it).
607
608 setBodyInnerHTML(
609 "<style>body { margin: 0; }</style>"
610 "<div id='scroller' style='overflow:scroll; opacity:0.5;'>"
611 " <div id='child' style='position:absolute; left:0; top:0;'></div>"
612 " <div style='height:10000px;'></div>"
613 "</div>"
614 );
615
616 FrameView* frameView = document().view();
617 LayoutObject& scroller = *document().getElementById("scroller")->layoutObjec t();
618 ObjectPaintProperties* scrollerProperties = scroller.objectPaintProperties() ;
619 LayoutObject& child = *document().getElementById("child")->layoutObject();
620 ObjectPaintProperties* childProperties = child.objectPaintProperties();
621
622 EXPECT_EQ(frameView->contentClip(), childProperties->localBorderBoxPropertie s()->properties.clip);
623 EXPECT_EQ(frameView->scrollTranslation(), childProperties->localBorderBoxPro perties()->properties.transform);
624 EXPECT_EQ(scrollerProperties->effect(), childProperties->localBorderBoxPrope rties()->properties.effect);
625 }
626
577 } // namespace blink 627 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/PaintPropertyTreeBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698