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

Unified Diff: cc/layers/scrollbar_layer.cc

Issue 18341009: Refactor cc scrollbar layers to separate solid-color vs desktop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments; plumb scrollbar color via flag. Created 7 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: cc/layers/scrollbar_layer.cc
diff --git a/cc/layers/scrollbar_layer.cc b/cc/layers/scrollbar_layer.cc
index a2fdd58ee36ac859f388cff2325df445a56b432f..d999ddce4b678e443d72203d8f8ae849df9ec881 100644
--- a/cc/layers/scrollbar_layer.cc
+++ b/cc/layers/scrollbar_layer.cc
@@ -36,8 +36,8 @@ scoped_refptr<ScrollbarLayer> ScrollbarLayer::Create(
ScrollbarLayer::ScrollbarLayer(
scoped_ptr<Scrollbar> scrollbar,
int scroll_layer_id)
- : scrollbar_(scrollbar.Pass()),
- scroll_layer_id_(scroll_layer_id) {
+ : scroll_layer_id_(scroll_layer_id),
+ scrollbar_(scrollbar.Pass()) {
if (!scrollbar_->IsOverlay())
SetShouldScrollOnMainThread(true);
}
@@ -56,8 +56,8 @@ bool ScrollbarLayer::OpacityCanAnimateOnImplThread() const {
return scrollbar_->IsOverlay();
}
-ScrollbarOrientation ScrollbarLayer::Orientation() const {
- return scrollbar_->Orientation();
+ScrollbarLayerInterface* ScrollbarLayer::ToScrollbarLayer() {
+ return this;
}
int ScrollbarLayer::MaxTextureSize() {
@@ -65,10 +65,15 @@ int ScrollbarLayer::MaxTextureSize() {
return layer_tree_host()->GetRendererCapabilities().max_texture_size;
}
-float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) {
- if (layer_tree_host()->settings().solid_color_scrollbars)
- return scale;
+int ScrollbarLayer::ScrollLayerId() const {
+ return scroll_layer_id_;
+}
+
+ScrollbarOrientation ScrollbarLayer::orientation() const {
+ return scrollbar_->Orientation();
+}
+float ScrollbarLayer::ClampScaleToMaxTextureSize(float scale) {
// If the scaled content_bounds() is bigger than the max texture size of the
// device, we need to clamp it by rescaling, since content_bounds() is used
// below to set the texture size.
@@ -105,23 +110,9 @@ void ScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
ScrollbarLayerImpl* scrollbar_layer = static_cast<ScrollbarLayerImpl*>(layer);
- if (layer_tree_host() &&
- layer_tree_host()->settings().solid_color_scrollbars) {
- int thickness_override =
- layer_tree_host()->settings().solid_color_scrollbar_thickness_dip;
- if (thickness_override != -1) {
- scrollbar_layer->SetThumbThickness(thickness_override);
- } else {
- if (Orientation() == HORIZONTAL)
- scrollbar_layer->SetThumbThickness(bounds().height());
- else
- scrollbar_layer->SetThumbThickness(bounds().width());
- }
- } else {
- scrollbar_layer->SetThumbThickness(thumb_thickness_);
- }
+ scrollbar_layer->SetThumbThickness(thumb_thickness_);
scrollbar_layer->SetThumbLength(thumb_length_);
- if (Orientation() == HORIZONTAL) {
+ if (orientation() == HORIZONTAL) {
scrollbar_layer->SetTrackStart(track_rect_.x());
scrollbar_layer->SetTrackLength(track_rect_.width());
} else {
@@ -140,10 +131,6 @@ void ScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
needs_push_properties_ = true;
}
-ScrollbarLayer* ScrollbarLayer::ToScrollbarLayer() {
- return this;
-}
-
void ScrollbarLayer::SetLayerTreeHost(LayerTreeHost* host) {
// When the LTH is set to null or has changed, then this layer should remove
// all of its associated resources.
@@ -170,7 +157,7 @@ gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect(
gfx::Rect ScrollbarLayer::OriginThumbRect() const {
gfx::Size thumb_size;
- if (Orientation() == HORIZONTAL) {
+ if (orientation() == HORIZONTAL) {
thumb_size =
gfx::Size(scrollbar_->ThumbLength(), scrollbar_->ThumbThickness());
} else {
@@ -186,8 +173,7 @@ bool ScrollbarLayer::Update(ResourceUpdateQueue* queue,
gfx::Rect scaled_track_rect = ScrollbarLayerRectToContentRect(
gfx::Rect(scrollbar_->Location(), bounds()));
- if (layer_tree_host()->settings().solid_color_scrollbars ||
- track_rect_.IsEmpty() || scaled_track_rect.IsEmpty())
+ if (track_rect_.IsEmpty() || scaled_track_rect.IsEmpty())
return false;
{
@@ -213,7 +199,6 @@ bool ScrollbarLayer::Update(ResourceUpdateQueue* queue,
scoped_refptr<UIResourceBitmap> ScrollbarLayer::RasterizeScrollbarPart(
gfx::Rect rect,
ScrollbarPart part) {
- DCHECK(!layer_tree_host()->settings().solid_color_scrollbars);
DCHECK(!rect.size().IsEmpty());
scoped_refptr<UIResourceBitmap> bitmap =

Powered by Google App Engine
This is Rietveld 408576698