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

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: bugref, scale_delta DCHECK + comment 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
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/events/blink/input_handler_proxy_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 5161068feaeac779a256c3f3619e7dcbeb787e84..9accc1f3ab920799ae5b7c0e3e99037543cf1686 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -756,6 +756,34 @@ 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_->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));
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/events/blink/input_handler_proxy_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698