Chromium Code Reviews| 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)); |