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

Unified Diff: ui/compositor/layer.cc

Issue 2189583004: [not for review - epic CL] Adding Elastic+Momentum+Layered scrolling to views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Combined rebase Created 4 years, 5 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: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 7dcf17724f2ca838e763b2198a5a347d6f13a22a..dd02128d0ff9cc9ae4d44dd4b503135d4ca79041 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -528,6 +528,36 @@ void Layer::SwitchCCLayerForTest() {
content_layer_ = new_layer;
}
+gfx::ScrollOffset Layer::CurrentScrollOffset() const {
+ const Compositor* compositor = GetCompositor();
+ if (compositor)
+ return compositor->GetScrollOffsetForLayer(cc_layer_->id());
+ return cc_layer_->scroll_offset();
+}
+
+void Layer::SetScrollOffset(const gfx::ScrollOffset& offset) {
+ Compositor* compositor = GetCompositor();
+ bool scrolled_on_impl_side =
+ compositor && compositor->ScrollLayerTo(cc_layer_->id(), offset);
+
+ if (!scrolled_on_impl_side)
+ cc_layer_->SetScrollOffset(offset);
+
+ DCHECK_EQ(offset.x(), CurrentScrollOffset().x());
+ DCHECK_EQ(offset.y(), CurrentScrollOffset().y());
+}
+
+void Layer::SetScrollable(Layer* parent_clip_layer,
+ bool can_overscroll,
+ const base::Closure& on_scroll) {
+ cc_layer_->SetScrollParent(parent_clip_layer->cc_layer_);
+ cc_layer_->SetIsContainerForFixedPositionLayers(true);
+ cc_layer_->SetScrollClipAndCanOverscroll(parent_clip_layer->cc_layer_->id(),
+ can_overscroll);
+ cc_layer_->set_did_scroll_callback(on_scroll);
+ cc_layer_->SetUserScrollable(true, true);
+}
+
void Layer::SetTextureMailbox(
const cc::TextureMailbox& mailbox,
std::unique_ptr<cc::SingleReleaseCallback> release_callback,

Powered by Google App Engine
This is Rietveld 408576698