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

Unified Diff: cc/layers/scrollbar_layer_impl_base.cc

Issue 23983047: Pinch/Zoom Infrastructure & Plumbing CL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Draft for review. Created 7 years, 1 month 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: cc/layers/scrollbar_layer_impl_base.cc
diff --git a/cc/layers/scrollbar_layer_impl_base.cc b/cc/layers/scrollbar_layer_impl_base.cc
index 362465be3b09f3d4b33d38f9404de2b55ae106b5..7b22d7049edcaf423e7c90ca8eea8e800c748a55 100644
--- a/cc/layers/scrollbar_layer_impl_base.cc
+++ b/cc/layers/scrollbar_layer_impl_base.cc
@@ -5,7 +5,7 @@
#include "cc/layers/scrollbar_layer_impl_base.h"
#include <algorithm>
-#include "cc/layers/layer.h"
+#include "cc/trees/layer_tree_impl.h"
#include "ui/gfx/rect_conversions.h"
namespace cc {
@@ -14,10 +14,12 @@ ScrollbarLayerImplBase::ScrollbarLayerImplBase(
LayerTreeImpl* tree_impl,
int id,
ScrollbarOrientation orientation,
- bool is_left_side_vertical_scrollbar)
+ bool is_left_side_vertical_scrollbar,
+ bool is_overlay)
: LayerImpl(tree_impl, id),
- scroll_layer_id_(Layer::INVALID_ID),
- is_overlay_scrollbar_(false),
+ scroll_layer_(NULL),
+ clip_layer_(NULL),
+ is_overlay_scrollbar_(is_overlay),
thumb_thickness_scale_factor_(1.f),
current_pos_(0.f),
maximum_(0),
@@ -26,14 +28,50 @@ ScrollbarLayerImplBase::ScrollbarLayerImplBase(
vertical_adjust_(0.f),
visible_to_total_length_ratio_(1.f) {}
+ScrollbarLayerImplBase::~ScrollbarLayerImplBase() {
+}
+
void ScrollbarLayerImplBase::PushPropertiesTo(LayerImpl* layer) {
LayerImpl::PushPropertiesTo(layer);
+ DCHECK(layer->ToScrollbarLayer());
+ layer->ToScrollbarLayer()->set_is_overlay_scrollbar(is_overlay_scrollbar_);
+ PushScrollClipPropertiesTo(layer);
+}
+
+void ScrollbarLayerImplBase::PushScrollClipPropertiesTo(LayerImpl* layer) {
+ DCHECK(layer->ToScrollbarLayer());
+ layer->ToScrollbarLayer()->SetScrollLayerById(ScrollLayerId());
+ layer->ToScrollbarLayer()->SetClipLayerById(ClipLayerId());
}
ScrollbarLayerImplBase* ScrollbarLayerImplBase::ToScrollbarLayer() {
return this;
}
+void ScrollbarLayerImplBase::SetScrollLayerById(int id) {
+ LayerImpl* scroll_layer = layer_tree_impl()->LayerById(id);
+ if (scroll_layer_ == scroll_layer)
+ return;
+
+ if (scroll_layer_)
+ scroll_layer_->RemoveScrollbar(this);
+ scroll_layer_ = scroll_layer;
+ if (scroll_layer_)
+ scroll_layer_->AddScrollbar(this);
+}
+
+void ScrollbarLayerImplBase::SetClipLayerById(int id) {
+ LayerImpl* clip_layer = layer_tree_impl()->LayerById(id);
+ if (clip_layer_ == clip_layer)
+ return;
+
+ if (clip_layer_)
+ clip_layer_->RemoveScrollbar(this);
+ clip_layer_ = clip_layer;
+ if (clip_layer_)
+ clip_layer_->AddScrollbar(this);
+}
+
gfx::Rect ScrollbarLayerImplBase::ScrollbarLayerRectToContentRect(
gfx::RectF layer_rect) const {
// Don't intersect with the bounds as in LayerRectToContentRect() because
@@ -174,4 +212,11 @@ gfx::Rect ScrollbarLayerImplBase::ComputeThumbQuadRect() const {
return ScrollbarLayerRectToContentRect(thumb_rect);
}
+void ScrollbarLayerImplBase::ScrollbarParametersDidChange() {
+ if (!clip_layer_ || !scroll_layer_)
+ return;
+
+ scroll_layer_->SetScrollbarPosition(this, clip_layer_);
+}
+
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698