summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorwjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-20 14:53:03 +0000
committerwjmaclean@chromium.org <wjmaclean@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-20 14:53:03 +0000
commit65213e019835542bf7a8fcd3fa6222ca788bdaaa (patch)
tree271f62e7a852e281d5bf7d9da210e04309d85f13 /cc
parent07cd37385dc9d907a30743af6173eb4a4bbcc15a (diff)
downloadchromium_src-65213e019835542bf7a8fcd3fa6222ca788bdaaa.zip
chromium_src-65213e019835542bf7a8fcd3fa6222ca788bdaaa.tar.gz
chromium_src-65213e019835542bf7a8fcd3fa6222ca788bdaaa.tar.bz2
Chromify scrollbar_geometry_fixed_thumb.*
BUG=none Review URL: https://chromiumcodereview.appspot.com/12617018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189274 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc2
-rw-r--r--cc/layers/scrollbar_geometry_fixed_thumb.cc109
-rw-r--r--cc/layers/scrollbar_geometry_fixed_thumb.h38
-rw-r--r--cc/layers/scrollbar_layer.cc2
-rw-r--r--cc/layers/scrollbar_layer_impl.cc2
5 files changed, 92 insertions, 61 deletions
diff --git a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
index b791f39..08e80b0 100644
--- a/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
+++ b/cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc
@@ -22,7 +22,7 @@ class ScrollbarAnimationControllerLinearFadeTest : public testing::Test {
virtual void SetUp() {
scroll_layer_ = LayerImpl::Create(host_impl_.active_tree(), 1);
scoped_ptr<ScrollbarGeometryFixedThumb> geometry(
- ScrollbarGeometryFixedThumb::create(
+ ScrollbarGeometryFixedThumb::Create(
FakeWebScrollbarThemeGeometry::create(false)));
scrollbar_layer_ = ScrollbarLayerImpl::Create(
host_impl_.active_tree(), 2, geometry.Pass());
diff --git a/cc/layers/scrollbar_geometry_fixed_thumb.cc b/cc/layers/scrollbar_geometry_fixed_thumb.cc
index 07c1cb5..aaca66e 100644
--- a/cc/layers/scrollbar_geometry_fixed_thumb.cc
+++ b/cc/layers/scrollbar_geometry_fixed_thumb.cc
@@ -4,6 +4,7 @@
#include "cc/layers/scrollbar_geometry_fixed_thumb.h"
+#include <algorithm>
#include <cmath>
#include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h"
@@ -15,69 +16,93 @@ using WebKit::WebScrollbarThemeGeometry;
namespace cc {
-scoped_ptr<ScrollbarGeometryFixedThumb> ScrollbarGeometryFixedThumb::create(scoped_ptr<WebScrollbarThemeGeometry> geometry)
-{
- return make_scoped_ptr(new ScrollbarGeometryFixedThumb(geometry.Pass()));
+scoped_ptr<ScrollbarGeometryFixedThumb> ScrollbarGeometryFixedThumb::Create(
+ scoped_ptr<WebScrollbarThemeGeometry> geometry) {
+ return make_scoped_ptr(new ScrollbarGeometryFixedThumb(geometry.Pass()));
}
-ScrollbarGeometryFixedThumb::~ScrollbarGeometryFixedThumb()
-{
-}
+ScrollbarGeometryFixedThumb::~ScrollbarGeometryFixedThumb() {}
-WebScrollbarThemeGeometry* ScrollbarGeometryFixedThumb::clone() const
-{
- ScrollbarGeometryFixedThumb* geometry = new ScrollbarGeometryFixedThumb(make_scoped_ptr(ScrollbarGeometryStub::clone()));
- geometry->m_thumbSize = m_thumbSize;
- return geometry;
+WebScrollbarThemeGeometry* ScrollbarGeometryFixedThumb::clone() const {
+ ScrollbarGeometryFixedThumb* geometry = new ScrollbarGeometryFixedThumb(
+ make_scoped_ptr(ScrollbarGeometryStub::clone()));
+ geometry->thumb_size_ = thumb_size_;
+ return geometry;
}
-int ScrollbarGeometryFixedThumb::thumbLength(WebScrollbar* scrollbar)
-{
- if (scrollbar->orientation() == WebScrollbar::Horizontal)
- return m_thumbSize.width();
- return m_thumbSize.height();
+int ScrollbarGeometryFixedThumb::thumbLength(WebScrollbar* scrollbar) {
+ if (scrollbar->orientation() == WebScrollbar::Horizontal)
+ return thumb_size_.width();
+ return thumb_size_.height();
}
-int ScrollbarGeometryFixedThumb::thumbPosition(WebScrollbar* scrollbar)
-{
- if (scrollbar->enabled()) {
- float size = scrollbar->maximum();
- if (!size)
- return 1;
- int value = std::min(std::max(0, scrollbar->value()), scrollbar->maximum());
- float pos = (trackLength(scrollbar) - thumbLength(scrollbar)) * value / size;
- return static_cast<int>(floorf((pos < 1 && pos > 0) ? 1 : pos));
- }
+int ScrollbarGeometryFixedThumb::thumbPosition(WebScrollbar* scrollbar) {
+ if (!scrollbar->enabled())
return 0;
+
+ float size = scrollbar->maximum();
+ if (!size)
+ return 1;
+ int value = std::min(std::max(0, scrollbar->value()), scrollbar->maximum());
+ float pos =
+ (trackLength(scrollbar) - thumbLength(scrollbar)) * value / size;
+ return static_cast<int>(floorf((pos < 1 && pos > 0) ? 1 : pos));
}
-void ScrollbarGeometryFixedThumb::splitTrack(WebScrollbar* scrollbar, const WebRect& unconstrainedTrackRect, WebRect& beforeThumbRect, WebRect& thumbRect, WebRect& afterThumbRect)
-{
+void ScrollbarGeometryFixedThumb::splitTrack(
+ WebScrollbar* scrollbar,
+ const WebRect& unconstrained_track_rect,
+ WebRect& before_thumb_rect,
+ WebRect& thumb_rect,
+ WebRect& after_thumb_rect) {
// This is a reimplementation of ScrollbarThemeComposite::splitTrack.
// Because the WebScrollbarThemeGeometry functions call down to native
// ScrollbarThemeComposite code which uses ScrollbarThemeComposite virtual
// helpers, there's no way to override a helper like thumbLength from
// the WebScrollbarThemeGeometry level. So, these three functions
- // (splitTrack, thumbPosition, thumbLength) are copied here so that the
+ // (splitTrack, thumb_position, thumbLength) are copied here so that the
// WebScrollbarThemeGeometry helper functions are used instead and
// a fixed size thumbLength can be used.
- WebRect trackRect = constrainTrackRectToTrackPieces(scrollbar, unconstrainedTrackRect);
- int thickness = scrollbar->orientation() == WebScrollbar::Horizontal ? scrollbar->size().height : scrollbar->size().width;
- int thumbPos = thumbPosition(scrollbar);
+ WebRect track_rect =
+ constrainTrackRectToTrackPieces(scrollbar, unconstrained_track_rect);
+ int thickness = scrollbar->orientation() == WebScrollbar::Horizontal
+ ? scrollbar->size().height
+ : scrollbar->size().width;
+ int thumb_pos = thumbPosition(scrollbar);
if (scrollbar->orientation() == WebScrollbar::Horizontal) {
- thumbRect = WebRect(trackRect.x + thumbPos, trackRect.y + (trackRect.height - thickness) / 2, thumbLength(scrollbar), thickness);
- beforeThumbRect = WebRect(trackRect.x, trackRect.y, thumbPos + thumbRect.width / 2, trackRect.height);
- afterThumbRect = WebRect(trackRect.x + beforeThumbRect.width, trackRect.y, trackRect.x + trackRect.width - beforeThumbRect.x - beforeThumbRect.width, trackRect.height);
+ thumb_rect = WebRect(track_rect.x + thumb_pos,
+ track_rect.y + (track_rect.height - thickness) / 2,
+ thumbLength(scrollbar),
+ thickness);
+ before_thumb_rect = WebRect(track_rect.x,
+ track_rect.y,
+ thumb_pos + thumb_rect.width / 2,
+ track_rect.height);
+ after_thumb_rect = WebRect(track_rect.x + before_thumb_rect.width,
+ track_rect.y,
+ track_rect.x + track_rect.width -
+ before_thumb_rect.x - before_thumb_rect.width,
+ track_rect.height);
} else {
- thumbRect = WebRect(trackRect.x + (trackRect.width - thickness) / 2, trackRect.y + thumbPos, thickness, thumbLength(scrollbar));
- beforeThumbRect = WebRect(trackRect.x, trackRect.y, trackRect.width, thumbPos + thumbRect.height / 2);
- afterThumbRect = WebRect(trackRect.x, trackRect.y + beforeThumbRect.height, trackRect.width, trackRect.y + trackRect.height - beforeThumbRect.y - beforeThumbRect.height);
+ thumb_rect = WebRect(track_rect.x + (track_rect.width - thickness) / 2,
+ track_rect.y + thumb_pos,
+ thickness,
+ thumbLength(scrollbar));
+ before_thumb_rect = WebRect(track_rect.x,
+ track_rect.y,
+ track_rect.width,
+ thumb_pos + thumb_rect.height / 2);
+ after_thumb_rect =
+ WebRect(track_rect.x,
+ track_rect.y + before_thumb_rect.height,
+ track_rect.width,
+ track_rect.y + track_rect.height - before_thumb_rect.y -
+ before_thumb_rect.height);
}
}
-ScrollbarGeometryFixedThumb::ScrollbarGeometryFixedThumb(scoped_ptr<WebScrollbarThemeGeometry> geometry)
- : ScrollbarGeometryStub(geometry.Pass())
-{
-}
+ScrollbarGeometryFixedThumb::ScrollbarGeometryFixedThumb(
+ scoped_ptr<WebScrollbarThemeGeometry> geometry)
+ : ScrollbarGeometryStub(geometry.Pass()) {}
} // namespace cc
diff --git a/cc/layers/scrollbar_geometry_fixed_thumb.h b/cc/layers/scrollbar_geometry_fixed_thumb.h
index f941104..983a70c 100644
--- a/cc/layers/scrollbar_geometry_fixed_thumb.h
+++ b/cc/layers/scrollbar_geometry_fixed_thumb.h
@@ -16,22 +16,28 @@ namespace cc {
// the total size of the scrollable area, changing the thumb length) while not
// requiring the thumb resource to be repainted.
class CC_EXPORT ScrollbarGeometryFixedThumb : public ScrollbarGeometryStub {
-public:
- static scoped_ptr<ScrollbarGeometryFixedThumb> create(scoped_ptr<WebKit::WebScrollbarThemeGeometry>);
- virtual ~ScrollbarGeometryFixedThumb();
-
- void setThumbSize(gfx::Size size) { m_thumbSize = size; }
-
- // WebScrollbarThemeGeometry interface
- virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE;
- virtual int thumbLength(WebKit::WebScrollbar*) OVERRIDE;
- virtual int thumbPosition(WebKit::WebScrollbar*) OVERRIDE;
- virtual void splitTrack(WebKit::WebScrollbar*, const WebKit::WebRect& track, WebKit::WebRect& startTrack, WebKit::WebRect& thumb, WebKit::WebRect& endTrack) OVERRIDE;
-
-private:
- explicit ScrollbarGeometryFixedThumb(scoped_ptr<WebKit::WebScrollbarThemeGeometry>);
-
- gfx::Size m_thumbSize;
+ public:
+ static scoped_ptr<ScrollbarGeometryFixedThumb> Create(
+ scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry);
+ virtual ~ScrollbarGeometryFixedThumb();
+
+ void set_thumb_size(gfx::Size size) { thumb_size_ = size; }
+
+ // WebScrollbarThemeGeometry interface
+ virtual WebKit::WebScrollbarThemeGeometry* clone() const OVERRIDE;
+ virtual int thumbLength(WebKit::WebScrollbar* scrollbar) OVERRIDE;
+ virtual int thumbPosition(WebKit::WebScrollbar* scrollbar) OVERRIDE;
+ virtual void splitTrack(WebKit::WebScrollbar* scrollbar,
+ const WebKit::WebRect& track,
+ WebKit::WebRect& start_track,
+ WebKit::WebRect& thumb,
+ WebKit::WebRect& end_track) OVERRIDE;
+
+ private:
+ explicit ScrollbarGeometryFixedThumb(
+ scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry);
+
+ gfx::Size thumb_size_;
};
}
diff --git a/cc/layers/scrollbar_layer.cc b/cc/layers/scrollbar_layer.cc
index 4f648e6..1681b6f 100644
--- a/cc/layers/scrollbar_layer.cc
+++ b/cc/layers/scrollbar_layer.cc
@@ -22,7 +22,7 @@ scoped_ptr<LayerImpl> ScrollbarLayer::CreateLayerImpl(
return ScrollbarLayerImpl::Create(
tree_impl,
id(),
- ScrollbarGeometryFixedThumb::create(make_scoped_ptr(geometry_->clone())))
+ ScrollbarGeometryFixedThumb::Create(make_scoped_ptr(geometry_->clone())))
.PassAs<LayerImpl>();
}
diff --git a/cc/layers/scrollbar_layer_impl.cc b/cc/layers/scrollbar_layer_impl.cc
index 63a17cc..affc4b7 100644
--- a/cc/layers/scrollbar_layer_impl.cc
+++ b/cc/layers/scrollbar_layer_impl.cc
@@ -83,7 +83,7 @@ void ScrollbarLayerImpl::SetThumbSize(gfx::Size size) {
DCHECK(layer_tree_impl()->IsPendingTree());
return;
}
- geometry_->setThumbSize(size);
+ geometry_->set_thumb_size(size);
}
void ScrollbarLayerImpl::SetViewportWithinScrollableArea(