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

Unified Diff: third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp

Issue 2401903002: Compute and include the offset of the sticky box to its enclosing composited layer. (Closed)
Patch Set: Merge with master and fix long line. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp
index f3d36dc1736034febf28c85e2cc2e593ad5d4d5d..a2194782061ed57c8b036b8c1d5418d3dfd5a2c3 100644
--- a/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp
+++ b/third_party/WebKit/Source/web/tests/ScrollingCoordinatorTest.cpp
@@ -34,6 +34,8 @@
#include "core/layout/compositing/CompositedLayerMapping.h"
#include "core/layout/compositing/PaintLayerCompositor.h"
#include "core/page/Page.h"
+#include "platform/geometry/IntPoint.h"
+#include "platform/geometry/IntRect.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/testing/URLTestHelpers.h"
#include "public/platform/Platform.h"
@@ -328,6 +330,112 @@ TEST_F(ScrollingCoordinatorTest, fastScrollingForFixedPosition) {
}
}
+TEST_F(ScrollingCoordinatorTest, fastScrollingForStickyPosition) {
+ registerMockedHttpURLLoad("sticky-position.html");
+ navigateTo(m_baseURL + "sticky-position.html");
+ forceFullCompositingUpdate();
+
+ // Sticky position should not fall back to main thread scrolling.
+ WebLayer* rootScrollLayer = getRootScrollLayer();
+ EXPECT_FALSE(rootScrollLayer->shouldScrollOnMainThread());
+
+ Document* document = frame()->document();
+ {
+ Element* element = document->getElementById("div-tl");
+ ASSERT_TRUE(element);
+ WebLayer* layer = webLayerFromElement(element);
+ ASSERT_TRUE(layer);
+ WebLayerStickyPositionConstraint constraint =
+ layer->stickyPositionConstraint();
+ ASSERT_TRUE(constraint.isSticky);
+ EXPECT_TRUE(constraint.isAnchoredTop && constraint.isAnchoredLeft &&
+ !constraint.isAnchoredRight && !constraint.isAnchoredBottom);
+ EXPECT_EQ(1.f, constraint.topOffset);
+ EXPECT_EQ(1.f, constraint.leftOffset);
+ EXPECT_EQ(IntRect(100, 100, 10, 10),
+ IntRect(constraint.scrollContainerRelativeStickyBoxRect));
+ EXPECT_EQ(IntRect(100, 100, 200, 200),
+ IntRect(constraint.scrollContainerRelativeContainingBlockRect));
+ EXPECT_EQ(IntPoint(100, 100),
+ IntPoint(constraint.parentRelativeStickyBoxOffset));
+ }
+ {
+ Element* element = document->getElementById("div-tr");
+ ASSERT_TRUE(element);
+ WebLayer* layer = webLayerFromElement(element);
+ ASSERT_TRUE(layer);
+ WebLayerStickyPositionConstraint constraint =
+ layer->stickyPositionConstraint();
+ ASSERT_TRUE(constraint.isSticky);
+ EXPECT_TRUE(constraint.isAnchoredTop && !constraint.isAnchoredLeft &&
+ constraint.isAnchoredRight && !constraint.isAnchoredBottom);
+ }
+ {
+ Element* element = document->getElementById("div-bl");
+ ASSERT_TRUE(element);
+ WebLayer* layer = webLayerFromElement(element);
+ ASSERT_TRUE(layer);
+ WebLayerStickyPositionConstraint constraint =
+ layer->stickyPositionConstraint();
+ ASSERT_TRUE(constraint.isSticky);
+ EXPECT_TRUE(!constraint.isAnchoredTop && constraint.isAnchoredLeft &&
+ !constraint.isAnchoredRight && constraint.isAnchoredBottom);
+ }
+ {
+ Element* element = document->getElementById("div-br");
+ ASSERT_TRUE(element);
+ WebLayer* layer = webLayerFromElement(element);
+ ASSERT_TRUE(layer);
+ WebLayerStickyPositionConstraint constraint =
+ layer->stickyPositionConstraint();
+ ASSERT_TRUE(constraint.isSticky);
+ EXPECT_TRUE(!constraint.isAnchoredTop && !constraint.isAnchoredLeft &&
+ constraint.isAnchoredRight && constraint.isAnchoredBottom);
+ }
+ {
+ Element* element = document->getElementById("span-tl");
+ ASSERT_TRUE(element);
+ WebLayer* layer = webLayerFromElement(element);
+ ASSERT_TRUE(layer);
+ WebLayerStickyPositionConstraint constraint =
+ layer->stickyPositionConstraint();
+ ASSERT_TRUE(constraint.isSticky);
+ EXPECT_TRUE(constraint.isAnchoredTop && constraint.isAnchoredLeft &&
+ !constraint.isAnchoredRight && !constraint.isAnchoredBottom);
+ }
+ {
+ Element* element = document->getElementById("span-tlbr");
+ ASSERT_TRUE(element);
+ WebLayer* layer = webLayerFromElement(element);
+ ASSERT_TRUE(layer);
+ WebLayerStickyPositionConstraint constraint =
+ layer->stickyPositionConstraint();
+ ASSERT_TRUE(constraint.isSticky);
+ EXPECT_TRUE(constraint.isAnchoredTop && constraint.isAnchoredLeft &&
+ constraint.isAnchoredRight && constraint.isAnchoredBottom);
+ EXPECT_EQ(1.f, constraint.topOffset);
+ EXPECT_EQ(1.f, constraint.leftOffset);
+ EXPECT_EQ(1.f, constraint.rightOffset);
+ EXPECT_EQ(1.f, constraint.bottomOffset);
+ }
+ {
+ Element* element = document->getElementById("composited-top");
+ ASSERT_TRUE(element);
+ WebLayer* layer = webLayerFromElement(element);
+ ASSERT_TRUE(layer);
+ WebLayerStickyPositionConstraint constraint =
+ layer->stickyPositionConstraint();
+ ASSERT_TRUE(constraint.isSticky);
+ EXPECT_TRUE(constraint.isAnchoredTop);
+ EXPECT_EQ(IntRect(100, 110, 10, 10),
+ IntRect(constraint.scrollContainerRelativeStickyBoxRect));
+ EXPECT_EQ(IntRect(100, 100, 200, 200),
+ IntRect(constraint.scrollContainerRelativeContainingBlockRect));
+ EXPECT_EQ(IntPoint(0, 10),
+ IntPoint(constraint.parentRelativeStickyBoxOffset));
+ }
+}
+
TEST_F(ScrollingCoordinatorTest, touchEventHandler) {
registerMockedHttpURLLoad("touch-event-handler.html");
navigateTo(m_baseURL + "touch-event-handler.html");

Powered by Google App Engine
This is Rietveld 408576698