OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/scrollbar_geometry_fixed_thumb.h" | 5 #include "cc/layers/scrollbar_geometry_fixed_thumb.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" | 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebRect.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 float pos = | 47 float pos = |
48 (trackLength(scrollbar) - thumbLength(scrollbar)) * value / size; | 48 (trackLength(scrollbar) - thumbLength(scrollbar)) * value / size; |
49 return static_cast<int>(floorf((pos < 1 && pos > 0) ? 1 : pos)); | 49 return static_cast<int>(floorf((pos < 1 && pos > 0) ? 1 : pos)); |
50 } | 50 } |
51 void ScrollbarGeometryFixedThumb::splitTrack( | 51 void ScrollbarGeometryFixedThumb::splitTrack( |
52 WebScrollbar* scrollbar, | 52 WebScrollbar* scrollbar, |
53 const WebRect& unconstrained_track_rect, | 53 const WebRect& unconstrained_track_rect, |
54 WebRect& before_thumb_rect, | 54 WebRect& before_thumb_rect, |
55 WebRect& thumb_rect, | 55 WebRect& thumb_rect, |
56 WebRect& after_thumb_rect) { | 56 WebRect& after_thumb_rect) { |
57 // This is a reimplementation of ScrollbarThemeComposite::splitTrack. | 57 // This is a reimplementation of ScrollbarThemeComposite::splitTrack(). |
58 // Because the WebScrollbarThemeGeometry functions call down to native | 58 // Because the WebScrollbarThemeGeometry functions call down to native |
59 // ScrollbarThemeComposite code which uses ScrollbarThemeComposite virtual | 59 // ScrollbarThemeComposite code which uses ScrollbarThemeComposite virtual |
60 // helpers, there's no way to override a helper like thumbLength from | 60 // helpers, there's no way to override a helper like thumbLength() from |
61 // the WebScrollbarThemeGeometry level. So, these three functions | 61 // the WebScrollbarThemeGeometry level. So, these three functions |
62 // (splitTrack, thumb_position, thumbLength) are copied here so that the | 62 // (splitTrack(), thumbPosition(), thumbLength()) are copied here so that |
63 // WebScrollbarThemeGeometry helper functions are used instead and | 63 // the WebScrollbarThemeGeometry helper functions are used instead and |
64 // a fixed size thumbLength can be used. | 64 // a fixed size thumbLength() can be used. |
65 | 65 |
66 WebRect track_rect = | 66 WebRect track_rect = |
67 constrainTrackRectToTrackPieces(scrollbar, unconstrained_track_rect); | 67 constrainTrackRectToTrackPieces(scrollbar, unconstrained_track_rect); |
68 int thickness = scrollbar->orientation() == WebScrollbar::Horizontal | 68 int thickness = scrollbar->orientation() == WebScrollbar::Horizontal |
69 ? scrollbar->size().height | 69 ? scrollbar->size().height |
70 : scrollbar->size().width; | 70 : scrollbar->size().width; |
71 int thumb_pos = thumbPosition(scrollbar); | 71 int thumb_pos = thumbPosition(scrollbar); |
72 if (scrollbar->orientation() == WebScrollbar::Horizontal) { | 72 if (scrollbar->orientation() == WebScrollbar::Horizontal) { |
73 thumb_rect = WebRect(track_rect.x + thumb_pos, | 73 thumb_rect = WebRect(track_rect.x + thumb_pos, |
74 track_rect.y + (track_rect.height - thickness) / 2, | 74 track_rect.y + (track_rect.height - thickness) / 2, |
(...skipping 24 matching lines...) Expand all Loading... |
99 track_rect.y + track_rect.height - before_thumb_rect.y - | 99 track_rect.y + track_rect.height - before_thumb_rect.y - |
100 before_thumb_rect.height); | 100 before_thumb_rect.height); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 ScrollbarGeometryFixedThumb::ScrollbarGeometryFixedThumb( | 104 ScrollbarGeometryFixedThumb::ScrollbarGeometryFixedThumb( |
105 scoped_ptr<WebScrollbarThemeGeometry> geometry) | 105 scoped_ptr<WebScrollbarThemeGeometry> geometry) |
106 : ScrollbarGeometryStub(geometry.Pass()) {} | 106 : ScrollbarGeometryStub(geometry.Pass()) {} |
107 | 107 |
108 } // namespace cc | 108 } // namespace cc |
OLD | NEW |