| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 FrameView* frameView = document().view(); | 40 FrameView* frameView = document().view(); |
| 41 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) | 41 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) |
| 42 return frameView->layoutView()->paintProperties()->overflowClip(); | 42 return frameView->layoutView()->paintProperties()->overflowClip(); |
| 43 return frameView->contentClip(); | 43 return frameView->contentClip(); |
| 44 } | 44 } |
| 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 const auto* scrollTranslation = |
| 52 return frameView->scroll(); | 52 frameView->layoutView()->paintProperties()->scrollTranslation(); |
| 53 return scrollTranslation ? scrollTranslation->scrollNode() : nullptr; |
| 54 } |
| 55 return frameView->scrollTranslation() |
| 56 ? frameView->scrollTranslation()->scrollNode() |
| 57 : nullptr; |
| 53 } | 58 } |
| 54 | 59 |
| 55 const ObjectPaintProperties* | 60 const ObjectPaintProperties* |
| 56 PaintPropertyTreeBuilderTest::paintPropertiesForElement(const char* name) { | 61 PaintPropertyTreeBuilderTest::paintPropertiesForElement(const char* name) { |
| 57 return document().getElementById(name)->layoutObject()->paintProperties(); | 62 return document().getElementById(name)->layoutObject()->paintProperties(); |
| 58 } | 63 } |
| 59 | 64 |
| 60 void PaintPropertyTreeBuilderTest::SetUp() { | 65 void PaintPropertyTreeBuilderTest::SetUp() { |
| 61 Settings::setMockScrollbarsEnabled(true); | 66 Settings::setMockScrollbarsEnabled(true); |
| 62 | 67 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // target1 should not have its own scroll node and instead should inherit | 147 // target1 should not have its own scroll node and instead should inherit |
| 143 // positionedScroll's. | 148 // positionedScroll's. |
| 144 const ObjectPaintProperties* positionedScrollProperties = | 149 const ObjectPaintProperties* positionedScrollProperties = |
| 145 positionedScroll->layoutObject()->paintProperties(); | 150 positionedScroll->layoutObject()->paintProperties(); |
| 146 auto* positionedScrollTranslation = | 151 auto* positionedScrollTranslation = |
| 147 positionedScrollProperties->scrollTranslation(); | 152 positionedScrollProperties->scrollTranslation(); |
| 148 auto* positionedScrollNode = positionedScrollTranslation->scrollNode(); | 153 auto* positionedScrollNode = positionedScrollTranslation->scrollNode(); |
| 149 EXPECT_TRUE(positionedScrollNode->parent()->isRoot()); | 154 EXPECT_TRUE(positionedScrollNode->parent()->isRoot()); |
| 150 EXPECT_EQ(TransformationMatrix().translate(0, -3), | 155 EXPECT_EQ(TransformationMatrix().translate(0, -3), |
| 151 positionedScrollTranslation->matrix()); | 156 positionedScrollTranslation->matrix()); |
| 152 EXPECT_EQ(nullptr, target1Properties->scroll()); | 157 EXPECT_EQ(nullptr, target1Properties->scrollTranslation()); |
| 153 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), | 158 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), |
| 154 target1->layoutObject(), frameView->layoutView()); | 159 target1->layoutObject(), frameView->layoutView()); |
| 155 | 160 |
| 156 // target2 is a fixed-position element inside a transformed scrolling element. | 161 // target2 is a fixed-position element inside a transformed scrolling element. |
| 157 // It should be attached under the scrolled box of the transformed element. | 162 // It should be attached under the scrolled box of the transformed element. |
| 158 Element* target2 = document().getElementById("target2"); | 163 Element* target2 = document().getElementById("target2"); |
| 159 const ObjectPaintProperties* target2Properties = | 164 const ObjectPaintProperties* target2Properties = |
| 160 target2->layoutObject()->paintProperties(); | 165 target2->layoutObject()->paintProperties(); |
| 161 Element* scroller = document().getElementById("transformedScroll"); | 166 Element* scroller = document().getElementById("transformedScroll"); |
| 162 const ObjectPaintProperties* scrollerProperties = | 167 const ObjectPaintProperties* scrollerProperties = |
| 163 scroller->layoutObject()->paintProperties(); | 168 scroller->layoutObject()->paintProperties(); |
| 164 EXPECT_EQ(FloatRoundedRect(200, 150, 100, 100), | 169 EXPECT_EQ(FloatRoundedRect(200, 150, 100, 100), |
| 165 target2Properties->overflowClip()->clipRect()); | 170 target2Properties->overflowClip()->clipRect()); |
| 166 EXPECT_EQ(scrollerProperties->overflowClip(), | 171 EXPECT_EQ(scrollerProperties->overflowClip(), |
| 167 target2Properties->overflowClip()->parent()); | 172 target2Properties->overflowClip()->parent()); |
| 168 // target2 should not have it's own scroll node and instead should inherit | 173 // target2 should not have it's own scroll node and instead should inherit |
| 169 // transformedScroll's. | 174 // transformedScroll's. |
| 170 const ObjectPaintProperties* transformedScrollProperties = | 175 const ObjectPaintProperties* transformedScrollProperties = |
| 171 transformedScroll->layoutObject()->paintProperties(); | 176 transformedScroll->layoutObject()->paintProperties(); |
| 172 auto* transformedScrollTranslation = | 177 auto* transformedScrollTranslation = |
| 173 transformedScrollProperties->scrollTranslation(); | 178 transformedScrollProperties->scrollTranslation(); |
| 174 auto* transformedScrollNode = transformedScrollTranslation->scrollNode(); | 179 auto* transformedScrollNode = transformedScrollTranslation->scrollNode(); |
| 175 EXPECT_TRUE(transformedScrollNode->parent()->isRoot()); | 180 EXPECT_TRUE(transformedScrollNode->parent()->isRoot()); |
| 176 EXPECT_EQ(TransformationMatrix().translate(0, -5), | 181 EXPECT_EQ(TransformationMatrix().translate(0, -5), |
| 177 transformedScrollTranslation->matrix()); | 182 transformedScrollTranslation->matrix()); |
| 178 EXPECT_EQ(nullptr, target2Properties->scroll()); | 183 EXPECT_EQ(nullptr, target2Properties->scrollTranslation()); |
| 179 | 184 |
| 180 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 153, 200, 100), | 185 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 153, 200, 100), |
| 181 target2->layoutObject(), frameView->layoutView()); | 186 target2->layoutObject(), frameView->layoutView()); |
| 182 } | 187 } |
| 183 | 188 |
| 184 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) { | 189 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) { |
| 185 loadTestData("position-and-scroll.html"); | 190 loadTestData("position-and-scroll.html"); |
| 186 | 191 |
| 187 Element* scroller = document().getElementById("scroller"); | 192 Element* scroller = document().getElementById("scroller"); |
| 188 scroller->scrollTo(0, 100); | 193 scroller->scrollTo(0, 100); |
| 189 FrameView* frameView = document().view(); | 194 FrameView* frameView = document().view(); |
| 190 frameView->updateAllLifecyclePhases(); | 195 frameView->updateAllLifecyclePhases(); |
| 191 const ObjectPaintProperties* scrollerProperties = | 196 const ObjectPaintProperties* scrollerProperties = |
| 192 scroller->layoutObject()->paintProperties(); | 197 scroller->layoutObject()->paintProperties(); |
| 193 EXPECT_EQ(TransformationMatrix().translate(0, -100), | 198 EXPECT_EQ(TransformationMatrix().translate(0, -100), |
| 194 scrollerProperties->scrollTranslation()->matrix()); | 199 scrollerProperties->scrollTranslation()->matrix()); |
| 195 EXPECT_EQ(frameScrollTranslation(), | 200 EXPECT_EQ(frameScrollTranslation(), |
| 196 scrollerProperties->scrollTranslation()->parent()); | 201 scrollerProperties->scrollTranslation()->parent()); |
| 197 EXPECT_EQ(frameScrollTranslation(), | 202 EXPECT_EQ(frameScrollTranslation(), |
| 198 scrollerProperties->overflowClip()->localTransformSpace()); | 203 scrollerProperties->overflowClip()->localTransformSpace()); |
| 199 EXPECT_EQ(frameScroll(), scrollerProperties->scroll()->parent()); | 204 const auto* scroll = scrollerProperties->scrollTranslation()->scrollNode(); |
| 200 EXPECT_EQ(FloatSize(413, 317), scrollerProperties->scroll()->clip()); | 205 EXPECT_EQ(frameScroll(), scroll->parent()); |
| 201 EXPECT_EQ(FloatSize(660, 10200), scrollerProperties->scroll()->bounds()); | 206 EXPECT_EQ(FloatSize(413, 317), scroll->clip()); |
| 202 EXPECT_FALSE(scrollerProperties->scroll()->userScrollableHorizontal()); | 207 EXPECT_EQ(FloatSize(660, 10200), scroll->bounds()); |
| 203 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical()); | 208 EXPECT_FALSE(scroll->userScrollableHorizontal()); |
| 209 EXPECT_TRUE(scroll->userScrollableVertical()); |
| 204 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), | 210 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), |
| 205 scrollerProperties->overflowClip()->clipRect()); | 211 scrollerProperties->overflowClip()->clipRect()); |
| 206 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); | 212 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); |
| 207 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), | 213 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), |
| 208 scroller->layoutObject(), frameView->layoutView()); | 214 scroller->layoutObject(), frameView->layoutView()); |
| 209 | 215 |
| 210 // The relative-positioned element should have accumulated box offset (exclude | 216 // The relative-positioned element should have accumulated box offset (exclude |
| 211 // scrolling), and should be affected by ancestor scroll transforms. | 217 // scrolling), and should be affected by ancestor scroll transforms. |
| 212 Element* relPos = document().getElementById("rel-pos"); | 218 Element* relPos = document().getElementById("rel-pos"); |
| 213 const ObjectPaintProperties* relPosProperties = | 219 const ObjectPaintProperties* relPosProperties = |
| (...skipping 2500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2714 | 2720 |
| 2715 document().view()->updateAllLifecyclePhases(); | 2721 document().view()->updateAllLifecyclePhases(); |
| 2716 | 2722 |
| 2717 // The frame should scroll due to the "forceScroll" element. | 2723 // The frame should scroll due to the "forceScroll" element. |
| 2718 EXPECT_NE(nullptr, frameScroll()); | 2724 EXPECT_NE(nullptr, frameScroll()); |
| 2719 | 2725 |
| 2720 const ObjectPaintProperties* overflowScrollProperties = | 2726 const ObjectPaintProperties* overflowScrollProperties = |
| 2721 overflow->layoutObject()->paintProperties(); | 2727 overflow->layoutObject()->paintProperties(); |
| 2722 auto* scrollTranslation = overflowScrollProperties->scrollTranslation(); | 2728 auto* scrollTranslation = overflowScrollProperties->scrollTranslation(); |
| 2723 auto* overflowScrollNode = scrollTranslation->scrollNode(); | 2729 auto* overflowScrollNode = scrollTranslation->scrollNode(); |
| 2724 EXPECT_EQ(frameScroll(), overflowScrollProperties->scroll()->parent()); | 2730 EXPECT_EQ( |
| 2731 frameScroll(), |
| 2732 overflowScrollProperties->scrollTranslation()->scrollNode()->parent()); |
| 2725 EXPECT_EQ(TransformationMatrix().translate(0, -37), | 2733 EXPECT_EQ(TransformationMatrix().translate(0, -37), |
| 2726 scrollTranslation->matrix()); | 2734 scrollTranslation->matrix()); |
| 2727 EXPECT_EQ(IntSize(5, 3), overflowScrollNode->clip()); | 2735 EXPECT_EQ(IntSize(5, 3), overflowScrollNode->clip()); |
| 2728 // The height should be 4000px because the (dom-order) overflow children are | 2736 // The height should be 4000px because the (dom-order) overflow children are |
| 2729 // positioned and do not contribute to the height. Only the 4000px | 2737 // positioned and do not contribute to the height. Only the 4000px |
| 2730 // "forceScroll" height is present. | 2738 // "forceScroll" height is present. |
| 2731 EXPECT_EQ(IntSize(5, 4000), overflowScrollNode->bounds()); | 2739 EXPECT_EQ(IntSize(5, 4000), overflowScrollNode->bounds()); |
| 2732 | 2740 |
| 2733 const ObjectPaintProperties* absposOverflowScrollProperties = | 2741 const ObjectPaintProperties* absposOverflowScrollProperties = |
| 2734 absposOverflow->layoutObject()->paintProperties(); | 2742 absposOverflow->layoutObject()->paintProperties(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2869 " height: 4000px;" | 2877 " height: 4000px;" |
| 2870 " }" | 2878 " }" |
| 2871 "</style>" | 2879 "</style>" |
| 2872 "<div id='overflow'>" | 2880 "<div id='overflow'>" |
| 2873 " <div class='backgroundAttachmentFixed'></div>" | 2881 " <div class='backgroundAttachmentFixed'></div>" |
| 2874 "</div>" | 2882 "</div>" |
| 2875 "<div class='forceScroll'></div>"); | 2883 "<div class='forceScroll'></div>"); |
| 2876 Element* overflow = document().getElementById("overflow"); | 2884 Element* overflow = document().getElementById("overflow"); |
| 2877 EXPECT_TRUE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); | 2885 EXPECT_TRUE(frameScroll()->hasBackgroundAttachmentFixedDescendants()); |
| 2878 // No scroll node is needed. | 2886 // No scroll node is needed. |
| 2879 EXPECT_EQ(overflow->layoutObject()->paintProperties()->scroll(), nullptr); | 2887 EXPECT_EQ(overflow->layoutObject()->paintProperties()->scrollTranslation(), |
| 2888 nullptr); |
| 2880 } | 2889 } |
| 2881 | 2890 |
| 2882 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetsUnderMultiColumn) { | 2891 TEST_P(PaintPropertyTreeBuilderTest, PaintOffsetsUnderMultiColumn) { |
| 2883 setBodyInnerHTML( | 2892 setBodyInnerHTML( |
| 2884 "<style>" | 2893 "<style>" |
| 2885 " body { margin: 0; }" | 2894 " body { margin: 0; }" |
| 2886 " .space { height: 30px; }" | 2895 " .space { height: 30px; }" |
| 2887 " .abs { position: absolute; width: 20px; height: 20px; }" | 2896 " .abs { position: absolute; width: 20px; height: 20px; }" |
| 2888 "</style>" | 2897 "</style>" |
| 2889 "<div style='columns:2; width: 200px; column-gap: 0'>" | 2898 "<div style='columns:2; width: 200px; column-gap: 0'>" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3157 "<div id='target' style='overflow: auto; width: 100px; height: 100px'>" | 3166 "<div id='target' style='overflow: auto; width: 100px; height: 100px'>" |
| 3158 " <div style='width: 200px; height: 200px'></div>" | 3167 " <div style='width: 200px; height: 200px'></div>" |
| 3159 "</div>"); | 3168 "</div>"); |
| 3160 | 3169 |
| 3161 const ObjectPaintProperties* properties = paintPropertiesForElement("target"); | 3170 const ObjectPaintProperties* properties = paintPropertiesForElement("target"); |
| 3162 EXPECT_NE(CompositorElementId(), | 3171 EXPECT_NE(CompositorElementId(), |
| 3163 properties->scrollTranslation()->compositorElementId()); | 3172 properties->scrollTranslation()->compositorElementId()); |
| 3164 } | 3173 } |
| 3165 | 3174 |
| 3166 } // namespace blink | 3175 } // namespace blink |
| OLD | NEW |