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

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

Issue 2353843002: Add position sticky main thread scrolling reason [spv2] (Closed)
Patch Set: 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"
(...skipping 1991 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 TEST_P(PaintPropertyTreeBuilderTest, SVGRootNoClip) 2002 TEST_P(PaintPropertyTreeBuilderTest, SVGRootNoClip)
2003 { 2003 {
2004 setBodyInnerHTML( 2004 setBodyInnerHTML(
2005 "<svg id='svg' xmlns='http://www.w3.org/2000/svg' width='100px' height=' 100px' style='overflow: visible'>" 2005 "<svg id='svg' xmlns='http://www.w3.org/2000/svg' width='100px' height=' 100px' style='overflow: visible'>"
2006 " <rect width='200' height='200' fill='red' />" 2006 " <rect width='200' height='200' fill='red' />"
2007 "</svg>"); 2007 "</svg>");
2008 2008
2009 EXPECT_FALSE(getLayoutObjectByElementId("svg")->objectPaintProperties()->ove rflowClip()); 2009 EXPECT_FALSE(getLayoutObjectByElementId("svg")->objectPaintProperties()->ove rflowClip());
2010 } 2010 }
2011 2011
2012 TEST_P(PaintPropertyTreeBuilderTest, MainThreadScrollReasonsWithNestedScrollers) 2012 TEST_P(PaintPropertyTreeBuilderTest, BackgroundAttachmentFixedMainThreadScrollRe asonsWithNestedScrollers)
2013 { 2013 {
2014 setBodyInnerHTML( 2014 setBodyInnerHTML(
2015 "<style>" 2015 "<style>"
2016 " #overflowA {" 2016 " #overflowA {"
2017 " position: absolute;" 2017 " position: absolute;"
2018 " overflow: scroll;" 2018 " overflow: scroll;"
2019 " width: 20px;" 2019 " width: 20px;"
2020 " height: 20px;" 2020 " height: 20px;"
2021 " }" 2021 " }"
2022 " #overflowB {" 2022 " #overflowB {"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects)); 2055 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects));
2056 2056
2057 // Adding a main thread scrolling reason should update the entire tree. 2057 // Adding a main thread scrolling reason should update the entire tree.
2058 overflowB->setAttribute(HTMLNames::classAttr, "backgroundAttachmentFixed"); 2058 overflowB->setAttribute(HTMLNames::classAttr, "backgroundAttachmentFixed");
2059 document().view()->updateAllLifecyclePhases(); 2059 document().view()->updateAllLifecyclePhases();
2060 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons(MainThreadScrolling Reason::kHasBackgroundAttachmentFixedObjects)); 2060 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons(MainThreadScrolling Reason::kHasBackgroundAttachmentFixedObjects));
2061 EXPECT_TRUE(overflowA->layoutObject()->objectPaintProperties()->scroll()->ha sMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachmentF ixedObjects)); 2061 EXPECT_TRUE(overflowA->layoutObject()->objectPaintProperties()->scroll()->ha sMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachmentF ixedObjects));
2062 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects)); 2062 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects));
2063 } 2063 }
2064 2064
2065 TEST_P(PaintPropertyTreeBuilderTest, MainThreadScrollReasonsWithFixedScroller) 2065 TEST_P(PaintPropertyTreeBuilderTest, BackgroundAttachmentFixedMainThreadScrollRe asonsWithFixedScroller)
2066 { 2066 {
2067 setBodyInnerHTML( 2067 setBodyInnerHTML(
2068 "<style>" 2068 "<style>"
2069 " #overflowA {" 2069 " #overflowA {"
2070 " position: absolute;" 2070 " position: absolute;"
2071 " overflow: scroll;" 2071 " overflow: scroll;"
2072 " width: 20px;" 2072 " width: 20px;"
2073 " height: 20px;" 2073 " height: 20px;"
2074 " }" 2074 " }"
2075 " #overflowB {" 2075 " #overflowB {"
(...skipping 25 matching lines...) Expand all
2101 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects)); 2101 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects));
2102 2102
2103 // Removing a main thread scrolling reason should update the entire tree. 2103 // Removing a main thread scrolling reason should update the entire tree.
2104 overflowB->removeAttribute("class"); 2104 overflowB->removeAttribute("class");
2105 document().view()->updateAllLifecyclePhases(); 2105 document().view()->updateAllLifecyclePhases();
2106 EXPECT_FALSE(rootScroll()->hasMainThreadScrollingReasons(MainThreadScrolling Reason::kHasBackgroundAttachmentFixedObjects)); 2106 EXPECT_FALSE(rootScroll()->hasMainThreadScrollingReasons(MainThreadScrolling Reason::kHasBackgroundAttachmentFixedObjects));
2107 EXPECT_FALSE(overflowA->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects)); 2107 EXPECT_FALSE(overflowA->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects));
2108 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects)); 2108 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasBackgroundAttachment FixedObjects));
2109 } 2109 }
2110 2110
2111 TEST_P(PaintPropertyTreeBuilderTest, PositionStickyMainThreadScrollReasonsWithNe stedScrollers)
2112 {
2113 setBodyInnerHTML(
2114 "<style>"
2115 " #overflowA {"
2116 " overflow: scroll;"
2117 " width: 20px;"
2118 " height: 20px;"
2119 " }"
2120 " #overflowB {"
2121 " overflow: scroll;"
2122 " width: 5px;"
2123 " height: 3px;"
2124 " }"
2125 " .positionSticky {"
2126 " position: sticky;"
2127 " top: 0;"
2128 " left: 0;"
2129 " }"
2130 " .forceScroll {"
2131 " height: 4000px;"
2132 " }"
2133 "</style>"
2134 "<div id='overflowA'>"
2135 " <div id='overflowB' class='positionSticky'>"
chrishtr 2016/09/20 19:45:57 It's a little weird that you put position:sticky o
pdr. 2016/09/20 20:16:57 It is weird and I doubt anyone will do it, but I t
chrishtr 2016/09/20 20:29:35 Ok makes sense. Please also add a test for an elem
2136 " <div class='forceScroll'></div>"
2137 " </div>"
2138 " <div class='forceScroll'></div>"
2139 "</div>"
2140 "<div class='forceScroll'></div>");
2141 Element* overflowA = document().getElementById("overflowA");
2142 Element* overflowB = document().getElementById("overflowB");
2143
2144 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons(MainThreadScrolling Reason::kHasStickyPositionObjects));
2145 EXPECT_TRUE(overflowA->layoutObject()->objectPaintProperties()->scroll()->ha sMainThreadScrollingReasons(MainThreadScrollingReason::kHasStickyPositionObjects ));
2146 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasStickyPositionObject s));
2147
2148 // Removing a main thread scrolling reason should update the entire tree.
2149 overflowB->removeAttribute("class");
2150 document().view()->updateAllLifecyclePhases();
2151 EXPECT_FALSE(frameScroll()->hasMainThreadScrollingReasons(MainThreadScrollin gReason::kHasStickyPositionObjects));
2152 EXPECT_FALSE(overflowA->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasStickyPositionObject s));
2153 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasStickyPositionObject s));
2154
2155 // Adding a main thread scrolling reason should update the entire tree.
2156 overflowB->setAttribute(HTMLNames::classAttr, "positionSticky");
2157 document().view()->updateAllLifecyclePhases();
2158 EXPECT_TRUE(frameScroll()->hasMainThreadScrollingReasons(MainThreadScrolling Reason::kHasStickyPositionObjects));
2159 EXPECT_TRUE(overflowA->layoutObject()->objectPaintProperties()->scroll()->ha sMainThreadScrollingReasons(MainThreadScrollingReason::kHasStickyPositionObjects ));
2160 EXPECT_FALSE(overflowB->layoutObject()->objectPaintProperties()->scroll()->h asMainThreadScrollingReasons(MainThreadScrollingReason::kHasStickyPositionObject s));
2161 }
2162
2111 } // namespace blink 2163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698