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 2320463002: [SPV2] Implement the blink-side scroll property tree (Closed)
Patch Set: Prevent circular reference caught by lsan Created 4 years, 3 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 "core/paint/PaintPropertyTreePrinter.h" 9 #include "core/paint/PaintPropertyTreePrinter.h"
10 #include "platform/graphics/paint/GeometryMapper.h" 10 #include "platform/graphics/paint/GeometryMapper.h"
11 #include "platform/graphics/paint/ScrollPaintPropertyNode.h"
11 #include "platform/graphics/paint/TransformPaintPropertyNode.h" 12 #include "platform/graphics/paint/TransformPaintPropertyNode.h"
12 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" 13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
13 #include "platform/testing/UnitTestHelpers.h" 14 #include "platform/testing/UnitTestHelpers.h"
14 #include "platform/text/TextStream.h" 15 #include "platform/text/TextStream.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "wtf/HashMap.h" 17 #include "wtf/HashMap.h"
17 #include "wtf/Vector.h" 18 #include "wtf/Vector.h"
18 19
19 namespace blink { 20 namespace blink {
20 21
(...skipping 26 matching lines...) Expand all
47 return frameView->rootTransform(); 48 return frameView->rootTransform();
48 } 49 }
49 50
50 const ClipPaintPropertyNode* rootClip() 51 const ClipPaintPropertyNode* rootClip()
51 { 52 {
52 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 53 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
53 return document().view()->layoutView()->objectPaintProperties()->loc alBorderBoxProperties()->propertyTreeState.clip.get(); 54 return document().view()->layoutView()->objectPaintProperties()->loc alBorderBoxProperties()->propertyTreeState.clip.get();
54 return document().view()->rootClip(); 55 return document().view()->rootClip();
55 } 56 }
56 57
58 const ScrollPaintPropertyNode* rootScroll()
59 {
60 FrameView* frameView = document().view();
61 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
62 return frameView->layoutView()->objectPaintProperties()->scroll();
63 return frameView->rootScroll();
64 }
65
57 const TransformPaintPropertyNode* framePreTranslation() 66 const TransformPaintPropertyNode* framePreTranslation()
58 { 67 {
59 FrameView* frameView = document().view(); 68 FrameView* frameView = document().view();
60 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 69 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
61 return frameView->layoutView()->objectPaintProperties()->paintOffset Translation(); 70 return frameView->layoutView()->objectPaintProperties()->paintOffset Translation();
62 return frameView->preTranslation(); 71 return frameView->preTranslation();
63 } 72 }
64 73
65 const TransformPaintPropertyNode* frameScrollTranslation() 74 const TransformPaintPropertyNode* frameScrollTranslation()
66 { 75 {
67 FrameView* frameView = document().view(); 76 FrameView* frameView = document().view();
68 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 77 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
69 return frameView->layoutView()->objectPaintProperties()->scrollTrans lation(); 78 return frameView->layoutView()->objectPaintProperties()->scrollTrans lation();
70 return frameView->scrollTranslation(); 79 return frameView->scrollTranslation();
71 } 80 }
72 81
73 const ClipPaintPropertyNode* frameContentClip() 82 const ClipPaintPropertyNode* frameContentClip()
74 { 83 {
75 FrameView* frameView = document().view(); 84 FrameView* frameView = document().view();
76 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled()) 85 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
77 return frameView->layoutView()->objectPaintProperties()->overflowCli p(); 86 return frameView->layoutView()->objectPaintProperties()->overflowCli p();
78 return frameView->contentClip(); 87 return frameView->contentClip();
79 } 88 }
80 89
90 const ScrollPaintPropertyNode* frameScroll()
91 {
92 FrameView* frameView = document().view();
93 if (RuntimeEnabledFeatures::rootLayerScrollingEnabled())
94 return frameView->layoutView()->objectPaintProperties()->scroll();
95 return frameView->scroll();
96 }
97
81 private: 98 private:
82 void SetUp() override 99 void SetUp() override
83 { 100 {
84 Settings::setMockScrollbarsEnabled(true); 101 Settings::setMockScrollbarsEnabled(true);
85 102
86 RenderingTest::SetUp(); 103 RenderingTest::SetUp();
87 enableCompositing(); 104 enableCompositing();
88 } 105 }
89 106
90 void TearDown() override 107 void TearDown() override
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } while (0) 143 } while (0)
127 144
128 #define CHECK_EXACT_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObje ct) CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, 0) 145 #define CHECK_EXACT_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObje ct) CHECK_VISUAL_RECT(expected, sourceLayoutObject, ancestorLayoutObject, 0)
129 146
130 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreeBuilderTest, ::testing::Bool()); 147 INSTANTIATE_TEST_CASE_P(All, PaintPropertyTreeBuilderTest, ::testing::Bool());
131 148
132 TEST_P(PaintPropertyTreeBuilderTest, FixedPosition) 149 TEST_P(PaintPropertyTreeBuilderTest, FixedPosition)
133 { 150 {
134 loadTestData("fixed-position.html"); 151 loadTestData("fixed-position.html");
135 152
153 Element* positionedScroll = document().getElementById("positionedScroll");
154 positionedScroll->setScrollTop(3);
155 Element* transformedScroll = document().getElementById("transformedScroll");
156 transformedScroll->setScrollTop(5);
157
136 FrameView* frameView = document().view(); 158 FrameView* frameView = document().view();
159 frameView->updateAllLifecyclePhases();
137 160
138 // target1 is a fixed-position element inside an absolute-position scrolling element. 161 // target1 is a fixed-position element inside an absolute-position scrolling element.
139 // It should be attached under the viewport to skip scrolling and offset of the parent. 162 // It should be attached under the viewport to skip scrolling and offset of the parent.
140 Element* target1 = document().getElementById("target1"); 163 Element* target1 = document().getElementById("target1");
141 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob jectPaintProperties(); 164 const ObjectPaintProperties* target1Properties = target1->layoutObject()->ob jectPaintProperties();
142 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix()); 165 EXPECT_EQ(TransformationMatrix().translate(200, 150), target1Properties->pai ntOffsetTranslation()->matrix());
143 EXPECT_EQ(framePreTranslation(), target1Properties->paintOffsetTranslation() ->parent()); 166 EXPECT_EQ(framePreTranslation(), target1Properties->paintOffsetTranslation() ->parent());
144 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace()); 167 EXPECT_EQ(target1Properties->paintOffsetTranslation(), target1Properties->ov erflowClip()->localTransformSpace());
145 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect()); 168 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target1Properties->overflowClip( )->clipRect());
146 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller. 169 // Likewise, it inherits clip from the viewport, skipping overflow clip of t he scroller.
147 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent()); 170 EXPECT_EQ(frameContentClip(), target1Properties->overflowClip()->parent());
171 // target1 should not have it's own scroll node and instead should inherit p ositionedScroll's.
172 const ObjectPaintProperties* positionedScrollProperties = positionedScroll-> layoutObject()->objectPaintProperties();
173 EXPECT_EQ(rootScroll(), positionedScrollProperties->scroll()->parent());
174 EXPECT_EQ(TransformationMatrix().translate(0, -3), positionedScrollPropertie s->scroll()->scrollOffsetTranslation()->matrix());
175 EXPECT_EQ(nullptr, target1Properties->scroll());
176
148 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), target1->layoutObjec t(), frameView->layoutView()); 177 CHECK_EXACT_VISUAL_RECT(LayoutRect(200, 150, 100, 100), target1->layoutObjec t(), frameView->layoutView());
149 178
150 // target2 is a fixed-position element inside a transformed scrolling elemen t. 179 // target2 is a fixed-position element inside a transformed scrolling elemen t.
151 // It should be attached under the scrolled box of the transformed element. 180 // It should be attached under the scrolled box of the transformed element.
152 Element* target2 = document().getElementById("target2"); 181 Element* target2 = document().getElementById("target2");
153 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob jectPaintProperties(); 182 const ObjectPaintProperties* target2Properties = target2->layoutObject()->ob jectPaintProperties();
154 Element* scroller = document().getElementById("scroller"); 183 Element* scroller = document().getElementById("transformedScroll");
155 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties(); 184 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties();
156 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix()); 185 EXPECT_EQ(TransformationMatrix().translate(200, 150), target2Properties->pai ntOffsetTranslation()->matrix());
157 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent()); 186 EXPECT_EQ(scrollerProperties->scrollTranslation(), target2Properties->paintO ffsetTranslation()->parent());
158 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace()); 187 EXPECT_EQ(target2Properties->paintOffsetTranslation(), target2Properties->ov erflowClip()->localTransformSpace());
159 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect()); 188 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 100), target2Properties->overflowClip( )->clipRect());
160 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent()); 189 EXPECT_EQ(scrollerProperties->overflowClip(), target2Properties->overflowCli p()->parent());
161 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 158, 200, 100), target2->layoutObjec t(), frameView->layoutView()); 190 // target2 should not have it's own scroll node and instead should inherit t ransformedScroll's.
191 const ObjectPaintProperties* transformedScrollProperties = transformedScroll ->layoutObject()->objectPaintProperties();
192 EXPECT_EQ(rootScroll(), transformedScrollProperties->scroll()->parent());
193 EXPECT_EQ(TransformationMatrix().translate(0, -5), transformedScrollProperti es->scroll()->scrollOffsetTranslation()->matrix());
194 EXPECT_EQ(nullptr, target2Properties->scroll());
195
196 CHECK_EXACT_VISUAL_RECT(LayoutRect(208, 153, 200, 100), target2->layoutObjec t(), frameView->layoutView());
162 } 197 }
163 198
164 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll) 199 TEST_P(PaintPropertyTreeBuilderTest, PositionAndScroll)
165 { 200 {
166 loadTestData("position-and-scroll.html"); 201 loadTestData("position-and-scroll.html");
167 202
168 Element* scroller = document().getElementById("scroller"); 203 Element* scroller = document().getElementById("scroller");
169 scroller->scrollTo(0, 100); 204 scroller->scrollTo(0, 100);
170 FrameView* frameView = document().view(); 205 FrameView* frameView = document().view();
171 frameView->updateAllLifecyclePhases(); 206 frameView->updateAllLifecyclePhases();
172 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties(); 207 const ObjectPaintProperties* scrollerProperties = scroller->layoutObject()-> objectPaintProperties();
173 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix()); 208 EXPECT_EQ(TransformationMatrix().translate(0, -100), scrollerProperties->scr ollTranslation()->matrix());
174 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->scrollTranslation()- >parent()); 209 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->scrollTranslation()- >parent());
175 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->overflowClip()->loca lTransformSpace()); 210 EXPECT_EQ(frameScrollTranslation(), scrollerProperties->overflowClip()->loca lTransformSpace());
176 EXPECT_EQ(FloatRoundedRect(120, 340, 400, 300), scrollerProperties->overflow Clip()->clipRect()); 211 EXPECT_EQ(frameScroll(), scrollerProperties->scroll()->parent());
212 EXPECT_EQ(FloatSize(413, 317), scrollerProperties->scroll()->clip());
213 EXPECT_EQ(FloatSize(660, 10200), scrollerProperties->scroll()->bounds());
214 EXPECT_FALSE(scrollerProperties->scroll()->userScrollableHorizontal());
215 EXPECT_TRUE(scrollerProperties->scroll()->userScrollableVertical());
216 EXPECT_EQ(FloatRoundedRect(120, 340, 413, 317), scrollerProperties->overflow Clip()->clipRect());
177 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent()); 217 EXPECT_EQ(frameContentClip(), scrollerProperties->overflowClip()->parent());
178 // http://crbug.com/638415 218 // http://crbug.com/638415
179 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) { 219 if (!RuntimeEnabledFeatures::rootLayerScrollingEnabled()) {
180 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 400, 300), scroller->layout Object(), frameView->layoutView()); 220 CHECK_EXACT_VISUAL_RECT(LayoutRect(120, 340, 413, 317), scroller->layout Object(), frameView->layoutView());
181 } 221 }
182 222
183 // The relative-positioned element should have accumulated box offset (exclu de scrolling), 223 // The relative-positioned element should have accumulated box offset (exclu de scrolling),
184 // and should be affected by ancestor scroll transforms. 224 // and should be affected by ancestor scroll transforms.
185 Element* relPos = document().getElementById("rel-pos"); 225 Element* relPos = document().getElementById("rel-pos");
186 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje ctPaintProperties(); 226 const ObjectPaintProperties* relPosProperties = relPos->layoutObject()->obje ctPaintProperties();
187 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai ntOffsetTranslation()->matrix()); 227 EXPECT_EQ(TransformationMatrix().translate(680, 1120), relPosProperties->pai ntOffsetTranslation()->matrix());
188 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf fsetTranslation()->parent()); 228 EXPECT_EQ(scrollerProperties->scrollTranslation(), relPosProperties->paintOf fsetTranslation()->parent());
189 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l ocalTransformSpace()); 229 EXPECT_EQ(relPosProperties->transform(), relPosProperties->overflowClip()->l ocalTransformSpace());
190 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip() ->clipRect()); 230 EXPECT_EQ(FloatRoundedRect(0, 0, 100, 200), relPosProperties->overflowClip() ->clipRect());
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")- >layoutObject(); 1747 LayoutObject& svgWithViewBox = *document().getElementById("svgWithViewBox")- >layoutObject();
1708 const ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objec tPaintProperties(); 1748 const ObjectPaintProperties* svgWithViewBoxProperties = svgWithViewBox.objec tPaintProperties();
1709 1749
1710 EXPECT_EQ(frameScrollTranslation(), svgWithViewBoxProperties->localBorderBox Properties()->propertyTreeState.transform); 1750 EXPECT_EQ(frameScrollTranslation(), svgWithViewBoxProperties->localBorderBox Properties()->propertyTreeState.transform);
1711 1751
1712 PropertyTreeState contentsProperties; 1752 PropertyTreeState contentsProperties;
1713 svgWithViewBoxProperties->getContentsProperties(contentsProperties); 1753 svgWithViewBoxProperties->getContentsProperties(contentsProperties);
1714 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), contents Properties.transform); 1754 EXPECT_EQ(svgWithViewBoxProperties->svgLocalToBorderBoxTransform(), contents Properties.transform);
1715 } 1755 }
1716 1756
1757 TEST_P(PaintPropertyTreeBuilderTest, OverflowHiddenScrollProperties)
1758 {
1759 setBodyInnerHTML(
1760 "<style>"
1761 " body {"
1762 " margin: 0px;"
1763 " }"
1764 " #overflowHidden {"
1765 " overflow: hidden;"
1766 " width: 5px;"
1767 " height: 3px;"
1768 " }"
1769 " .forceScroll {"
1770 " height: 79px;"
1771 " }"
1772 "</style>"
1773 "<div id='overflowHidden'>"
1774 " <div class='forceScroll'></div>"
1775 "</div>");
1776
1777 Element* overflowHidden = document().getElementById("overflowHidden");
1778 overflowHidden->setScrollTop(37);
1779
1780 document().view()->updateAllLifecyclePhases();
1781
1782 const ObjectPaintProperties* overflowHiddenScrollProperties = overflowHidden ->layoutObject()->objectPaintProperties();
1783 // Because the frameView is does not scroll, overflowHidden's scroll should be under the root.
1784 EXPECT_EQ(rootScroll(), overflowHiddenScrollProperties->scroll()->parent());
1785 EXPECT_EQ(TransformationMatrix().translate(0, -37), overflowHiddenScrollProp erties->scroll()->scrollOffsetTranslation()->matrix());
1786 // This should match the overflow's dimensions.
1787 EXPECT_EQ(IntSize(5, 3), overflowHiddenScrollProperties->scroll()->clip());
1788 // The scrolling content's bounds should include both the overflow's dimensi ons (5x3) and the
1789 // 0x79 "forceScroll" object.
1790 EXPECT_EQ(IntSize(5, 79), overflowHiddenScrollProperties->scroll()->bounds() );
1791 // Although overflow: hidden is programmatically scrollable, it is not user scrollable.
1792 EXPECT_FALSE(overflowHiddenScrollProperties->scroll()->userScrollableHorizon tal());
1793 EXPECT_FALSE(overflowHiddenScrollProperties->scroll()->userScrollableVertica l());
1794 }
1795
1796 TEST_P(PaintPropertyTreeBuilderTest, NestedScrollProperties)
1797 {
1798 setBodyInnerHTML(
1799 "<style>"
1800 " * {"
1801 " margin: 0px;"
1802 " }"
1803 " #overflowA {"
1804 " overflow: scroll;"
1805 " width: 5px;"
1806 " height: 3px;"
1807 " }"
1808 " #overflowB {"
1809 " overflow: scroll;"
1810 " width: 9px;"
1811 " height: 7px;"
1812 " }"
1813 " .forceScroll {"
1814 " height: 100px;"
1815 " }"
1816 "</style>"
1817 "<div id='overflowA'>"
1818 " <div id='overflowB'>"
1819 " <div class='forceScroll'></div>"
1820 " </div>"
1821 " <div class='forceScroll'></div>"
1822 "</div>");
1823
1824 Element* overflowA = document().getElementById("overflowA");
1825 overflowA->setScrollTop(37);
1826 Element* overflowB = document().getElementById("overflowB");
1827 overflowB->setScrollTop(41);
1828
1829 document().view()->updateAllLifecyclePhases();
1830
1831 const ObjectPaintProperties* overflowAScrollProperties = overflowA->layoutOb ject()->objectPaintProperties();
1832 // Because the frameView is does not scroll, overflowA's scroll should be un der the root.
1833 EXPECT_EQ(rootScroll(), overflowAScrollProperties->scroll()->parent());
1834 EXPECT_EQ(TransformationMatrix().translate(0, -37), overflowAScrollPropertie s->scroll()->scrollOffsetTranslation()->matrix());
1835 EXPECT_EQ(IntSize(5, 3), overflowAScrollProperties->scroll()->clip());
1836 // 107 is the forceScroll element plus the height of the overflow scroll chi ld (overflowB).
1837 EXPECT_EQ(IntSize(9, 107), overflowAScrollProperties->scroll()->bounds());
1838 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()) ;
1839 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical());
1840
1841 const ObjectPaintProperties* overflowBScrollProperties = overflowB->layoutOb ject()->objectPaintProperties();
1842 // The overflow child's scroll node should be a child of the parent's (overf lowA) scroll node.
1843 EXPECT_EQ(overflowAScrollProperties->scroll(), overflowBScrollProperties->sc roll()->parent());
1844 EXPECT_EQ(TransformationMatrix().translate(0, -41), overflowBScrollPropertie s->scroll()->scrollOffsetTranslation()->matrix());
1845 EXPECT_EQ(IntSize(9, 7), overflowBScrollProperties->scroll()->clip());
1846 EXPECT_EQ(IntSize(9, 100), overflowBScrollProperties->scroll()->bounds());
1847 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()) ;
1848 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical());
1849 }
1850
1851 TEST_P(PaintPropertyTreeBuilderTest, PositionedScrollerIsNotNested)
1852 {
1853 setBodyInnerHTML(
1854 "<style>"
1855 " * {"
1856 " margin: 0px;"
1857 " }"
1858 " #overflow {"
1859 " overflow: scroll;"
1860 " width: 5px;"
1861 " height: 3px;"
1862 " }"
1863 " #absposOverflow {"
1864 " position: absolute;"
1865 " top: 0;"
1866 " left: 0;"
1867 " overflow: scroll;"
1868 " width: 9px;"
1869 " height: 7px;"
1870 " }"
1871 " #fixedOverflow {"
1872 " position: fixed;"
1873 " top: 0;"
1874 " left: 0;"
1875 " overflow: scroll;"
1876 " width: 13px;"
1877 " height: 11px;"
1878 " }"
1879 " .forceScroll {"
1880 " height: 4000px;"
1881 " }"
1882 "</style>"
1883 "<div id='overflow'>"
1884 " <div id='absposOverflow'>"
1885 " <div class='forceScroll'></div>"
1886 " </div>"
1887 " <div id='fixedOverflow'>"
1888 " <div class='forceScroll'></div>"
1889 " </div>"
1890 " <div class='forceScroll'></div>"
1891 "</div>"
1892 "<div class='forceScroll'></div>");
1893
1894 Element* overflow = document().getElementById("overflow");
1895 overflow->setScrollTop(37);
1896 Element* absposOverflow = document().getElementById("absposOverflow");
1897 absposOverflow->setScrollTop(41);
1898 Element* fixedOverflow = document().getElementById("fixedOverflow");
1899 fixedOverflow->setScrollTop(43);
1900
1901 document().view()->updateAllLifecyclePhases();
1902
1903 // The frame should scroll due to the "forceScroll" element.
1904 EXPECT_NE(nullptr, frameScroll());
1905
1906 const ObjectPaintProperties* overflowScrollProperties = overflow->layoutObje ct()->objectPaintProperties();
1907 EXPECT_EQ(frameScroll(), overflowScrollProperties->scroll()->parent());
1908 EXPECT_EQ(TransformationMatrix().translate(0, -37), overflowScrollProperties ->scroll()->scrollOffsetTranslation()->matrix());
1909 EXPECT_EQ(IntSize(5, 3), overflowScrollProperties->scroll()->clip());
1910 // The height should be 4000px because the (dom-order) overflow children are positioned and do not
1911 // contribute to the height. Only the 4000px "forceScroll" height is present .
1912 EXPECT_EQ(IntSize(5, 4000), overflowScrollProperties->scroll()->bounds());
1913
1914 const ObjectPaintProperties* absposOverflowScrollProperties = absposOverflow ->layoutObject()->objectPaintProperties();
1915 // The absolute position overflow scroll node is parented under the frame, n ot the dom-order parent.
1916 EXPECT_EQ(frameScroll(), absposOverflowScrollProperties->scroll()->parent()) ;
1917 EXPECT_EQ(TransformationMatrix().translate(0, -41), absposOverflowScrollProp erties->scroll()->scrollOffsetTranslation()->matrix());
1918 EXPECT_EQ(IntSize(9, 7), absposOverflowScrollProperties->scroll()->clip());
1919 EXPECT_EQ(IntSize(9, 4000), absposOverflowScrollProperties->scroll()->bounds ());
1920
1921 const ObjectPaintProperties* fixedOverflowScrollProperties = fixedOverflow-> layoutObject()->objectPaintProperties();
1922 // The fixed position overflow scroll node is parented under the root, not t he dom-order parent or frame's scroll.
1923 EXPECT_EQ(rootScroll(), fixedOverflowScrollProperties->scroll()->parent());
1924 EXPECT_EQ(TransformationMatrix().translate(0, -43), fixedOverflowScrollPrope rties->scroll()->scrollOffsetTranslation()->matrix());
1925 EXPECT_EQ(IntSize(13, 11), fixedOverflowScrollProperties->scroll()->clip());
1926 EXPECT_EQ(IntSize(13, 4000), fixedOverflowScrollProperties->scroll()->bounds ());
1927 }
1928
1929 TEST_P(PaintPropertyTreeBuilderTest, NestedPositionedScrollProperties)
1930 {
1931 setBodyInnerHTML(
1932 "<style>"
1933 " * {"
1934 " margin: 0px;"
1935 " }"
1936 " #overflowA {"
1937 " position: absolute;"
1938 " top: 7px;"
1939 " left: 11px;"
1940 " overflow: scroll;"
1941 " width: 20px;"
1942 " height: 20px;"
1943 " }"
1944 " #overflowB {"
1945 " position: absolute;"
1946 " top: 1px;"
1947 " left: 3px;"
1948 " overflow: scroll;"
1949 " width: 5px;"
1950 " height: 3px;"
1951 " }"
1952 " .forceScroll {"
1953 " height: 100px;"
1954 " }"
1955 "</style>"
1956 "<div id='overflowA'>"
1957 " <div id='overflowB'>"
1958 " <div class='forceScroll'></div>"
1959 " </div>"
1960 " <div class='forceScroll'></div>"
1961 "</div>");
1962
1963 Element* overflowA = document().getElementById("overflowA");
1964 overflowA->setScrollTop(37);
1965 Element* overflowB = document().getElementById("overflowB");
1966 overflowB->setScrollTop(41);
1967
1968 document().view()->updateAllLifecyclePhases();
1969
1970 const ObjectPaintProperties* overflowAScrollProperties = overflowA->layoutOb ject()->objectPaintProperties();
1971 // Because the frameView is does not scroll, overflowA's scroll should be un der the root.
1972 EXPECT_EQ(rootScroll(), overflowAScrollProperties->scroll()->parent());
1973 EXPECT_EQ(TransformationMatrix().translate(0, -37), overflowAScrollPropertie s->scroll()->scrollOffsetTranslation()->matrix());
1974 EXPECT_EQ(IntSize(20, 20), overflowAScrollProperties->scroll()->clip());
1975 // 100 is the forceScroll element's height because the overflow child does n ot contribute to the height.
1976 EXPECT_EQ(IntSize(20, 100), overflowAScrollProperties->scroll()->bounds());
1977 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableHorizontal()) ;
1978 EXPECT_TRUE(overflowAScrollProperties->scroll()->userScrollableVertical());
1979
1980 const ObjectPaintProperties* overflowBScrollProperties = overflowB->layoutOb ject()->objectPaintProperties();
1981 // The overflow child's scroll node should be a child of the parent's (overf lowA) scroll node.
1982 EXPECT_EQ(overflowAScrollProperties->scroll(), overflowBScrollProperties->sc roll()->parent());
1983 EXPECT_EQ(TransformationMatrix().translate(0, -41), overflowBScrollPropertie s->scroll()->scrollOffsetTranslation()->matrix());
1984 EXPECT_EQ(IntSize(5, 3), overflowBScrollProperties->scroll()->clip());
1985 EXPECT_EQ(IntSize(5, 100), overflowBScrollProperties->scroll()->bounds());
1986 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableHorizontal()) ;
1987 EXPECT_TRUE(overflowBScrollProperties->scroll()->userScrollableVertical());
1988 }
1989
1717 } // namespace blink 1990 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698