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

Unified Diff: third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp

Issue 2292133002: [compositor-worker] root scrolling layer is associated with document scrolling element
Patch Set: Use document instead of documentElement() Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp
index 95ad341795d5e073184585b32d26b3e8a5a8ab20..ee4ebb866e9b152e01b9774e3081078d8f84c6d7 100644
--- a/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp
+++ b/third_party/WebKit/Source/platform/graphics/CompositorMutableStateTest.cpp
@@ -79,7 +79,7 @@ TEST_F(CompositorMutableStateTest, NoMutableState) {
CompositorMutations mutations;
CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations);
std::unique_ptr<CompositorMutableState> state(
- provider.getMutableStateFor(42));
+ provider.getMutableStateFor(42, 42));
EXPECT_FALSE(state);
}
@@ -99,11 +99,13 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) {
SetLayerPropertiesForTesting(layer);
- int primaryId = 12;
+ int mainId = 12;
+ int scrollId = 13;
flackr 2017/03/01 16:31:26 To be accurate to the real implementation, isn't t
+
root->SetElementId(
- createCompositorElementId(primaryId, CompositorSubElementId::Primary));
+ createCompositorElementId(mainId, CompositorSubElementId::Primary));
layer->SetElementId(
- createCompositorElementId(primaryId, CompositorSubElementId::Scroll));
+ createCompositorElementId(scrollId, CompositorSubElementId::Scroll));
root->SetMutableProperties(CompositorMutableProperty::kOpacity |
CompositorMutableProperty::kTransform);
@@ -118,7 +120,7 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) {
CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations);
std::unique_ptr<CompositorMutableState> state(
- provider.getMutableStateFor(primaryId));
+ provider.getMutableStateFor(mainId, scrollId));
EXPECT_TRUE(state.get());
EXPECT_EQ(1.0, rootLayer()->Opacity());
@@ -140,7 +142,7 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) {
// The corresponding mutation should reflect the changed values.
EXPECT_EQ(1ul, mutations.map.size());
- const CompositorMutation& mutation = *mutations.map.find(primaryId)->value;
+ const CompositorMutation& mutation = *mutations.map.find(mainId)->value;
EXPECT_TRUE(mutation.isOpacityMutated());
EXPECT_TRUE(mutation.isTransformMutated());
EXPECT_TRUE(mutation.isScrollLeftMutated());
@@ -152,4 +154,48 @@ TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) {
EXPECT_EQ(1.0, mutation.scrollTop());
}
+TEST_F(CompositorMutableStateTest, MutableStateWithoutScrollLayer) {
+ // There is a main layer with an element id but there is not scroll layer with
+ // and element id. We should have a valid mutable state given but mutating its
+ // scroll properties should have no effect.
+ std::unique_ptr<LayerImpl> root =
+ LayerImpl::Create(hostImpl().active_tree(), 42);
+ SetLayerPropertiesForTesting(root.get());
+
+ root->SetElementId(
+ createCompositorElementId(42, CompositorSubElementId::Primary));
+
+ root->SetMutableProperties(CompositorMutableProperty::kOpacity |
+ CompositorMutableProperty::kTransform);
+
+ hostImpl().SetViewportSize(root->bounds());
+ hostImpl().active_tree()->SetRootLayerForTesting(std::move(root));
+ hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree();
+
+ CompositorMutations mutations;
+ CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations);
+ std::unique_ptr<CompositorMutableState> state(
+ provider.getMutableStateFor(42, 42));
+
+ EXPECT_TRUE(state.get());
+ EXPECT_EQ(1.0, rootLayer()->Opacity());
+ EXPECT_EQ(0.0, rootLayer()->CurrentScrollOffset().x());
+ EXPECT_EQ(0.0, rootLayer()->CurrentScrollOffset().y());
+
+ state->setOpacity(0.5);
+ state->setScrollLeft(1.0);
+ state->setScrollTop(1.0);
+
+ EXPECT_EQ(1ul, mutations.map.size());
+
+ const CompositorMutation& mutation = *mutations.map.find(42)->value;
+ EXPECT_TRUE(mutation.isOpacityMutated());
+ EXPECT_FALSE(mutation.isScrollLeftMutated());
+ EXPECT_FALSE(mutation.isScrollTopMutated());
+
+ EXPECT_EQ(0.5, rootLayer()->Opacity());
+ EXPECT_EQ(0.0, rootLayer()->CurrentScrollOffset().x());
+ EXPECT_EQ(0.0, rootLayer()->CurrentScrollOffset().y());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698