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

Unified Diff: ui/compositor/layer.cc

Issue 2188133002: Scroll with Layers in views::ScrollView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-ScrollTrack
Patch Set: Add a test for the transform goop Created 4 years, 4 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..22f162381d67866ab4131d730fd5261154a2c5c4 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -756,6 +756,36 @@ void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) {
delegate_->OnDelegatedFrameDamage(damage_rect_in_dip);
}
+void Layer::SetScrollable(Layer* parent_clip_layer,
+ const base::Closure& on_scroll) {
+ cc_layer_->SetScrollParent(parent_clip_layer->cc_layer_);
Ian Vollick 2016/08/09 14:00:49 This should not be necessary. The concept of "scro
tapted 2016/08/10 05:39:04 Done.
+ cc_layer_->SetIsContainerForFixedPositionLayers(true);
Ian Vollick 2016/08/09 14:00:49 Do we used fixed pos layers in ui::?
tapted 2016/08/10 05:39:04 Ah, I must have added this in a very early iterati
+ cc_layer_->SetScrollClipLayerId(parent_clip_layer->cc_layer_->id());
+ cc_layer_->set_did_scroll_callback(on_scroll);
+ cc_layer_->SetUserScrollable(true, true);
+}
+
+gfx::ScrollOffset Layer::CurrentScrollOffset() const {
+ const Compositor* compositor = GetCompositor();
+ gfx::ScrollOffset offset;
+ if (compositor &&
+ compositor->GetScrollOffsetForLayer(cc_layer_->id(), &offset))
+ return offset;
+ 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::RequestCopyOfOutput(
std::unique_ptr<cc::CopyOutputRequest> request) {
cc_layer_->RequestCopyOfOutput(std::move(request));

Powered by Google App Engine
This is Rietveld 408576698