OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "platform/scroll/ScrollbarThemeOverlay.h" | 26 #include "platform/scroll/ScrollbarThemeOverlay.h" |
27 | 27 |
28 #include "platform/PlatformMouseEvent.h" | 28 #include "platform/PlatformMouseEvent.h" |
29 #include "platform/graphics/GraphicsContext.h" | 29 #include "platform/graphics/GraphicsContext.h" |
30 #include "platform/graphics/paint/DrawingRecorder.h" | 30 #include "platform/graphics/paint/DrawingRecorder.h" |
31 #include "platform/scroll/ScrollbarThemeClient.h" | 31 #include "platform/scroll/ScrollbarThemeClient.h" |
32 #include "platform/transforms/TransformationMatrix.h" | 32 #include "platform/transforms/TransformationMatrix.h" |
33 #include "public/platform/Platform.h" | 33 #include "public/platform/Platform.h" |
34 #include "public/platform/WebRect.h" | 34 #include "public/platform/WebRect.h" |
35 #include "public/platform/WebThemeEngine.h" | 35 #include "public/platform/WebThemeEngine.h" |
| 36 #include "wtf/MathExtras.h" |
36 | 37 |
37 #include <algorithm> | 38 #include <algorithm> |
38 | 39 |
39 namespace blink { | 40 namespace blink { |
40 | 41 |
41 ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMa
rgin, HitTestBehavior allowHitTest, Color color) | 42 ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMa
rgin, HitTestBehavior allowHitTest, Color color) |
42 : ScrollbarTheme() | 43 : ScrollbarTheme() |
43 , m_thumbThickness(thumbThickness) | 44 , m_thumbThickness(thumbThickness) |
44 , m_scrollbarMargin(scrollbarMargin) | 45 , m_scrollbarMargin(scrollbarMargin) |
45 , m_allowHitTest(allowHitTest) | 46 , m_allowHitTest(allowHitTest) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 85 |
85 int ScrollbarThemeOverlay::thumbLength(const ScrollbarThemeClient& scrollbar) | 86 int ScrollbarThemeOverlay::thumbLength(const ScrollbarThemeClient& scrollbar) |
86 { | 87 { |
87 int trackLen = trackLength(scrollbar); | 88 int trackLen = trackLength(scrollbar); |
88 | 89 |
89 if (!scrollbar.totalSize()) | 90 if (!scrollbar.totalSize()) |
90 return trackLen; | 91 return trackLen; |
91 | 92 |
92 float proportion = static_cast<float>(scrollbar.visibleSize()) / scrollbar.t
otalSize(); | 93 float proportion = static_cast<float>(scrollbar.visibleSize()) / scrollbar.t
otalSize(); |
93 int length = round(proportion * trackLen); | 94 int length = round(proportion * trackLen); |
94 length = std::min(std::max(length, minimumThumbLength(scrollbar)), trackLen)
; | 95 int minLen = std::min(minimumThumbLength(scrollbar), trackLen); |
| 96 length = clampTo(length, minLen, trackLen); |
95 return length; | 97 return length; |
96 } | 98 } |
97 | 99 |
98 bool ScrollbarThemeOverlay::hasThumb(const ScrollbarThemeClient& scrollbar) | 100 bool ScrollbarThemeOverlay::hasThumb(const ScrollbarThemeClient& scrollbar) |
99 { | 101 { |
100 return true; | 102 return true; |
101 } | 103 } |
102 | 104 |
103 IntRect ScrollbarThemeOverlay::backButtonRect(const ScrollbarThemeClient&, Scrol
lbarPart, bool) | 105 IntRect ScrollbarThemeOverlay::backButtonRect(const ScrollbarThemeClient&, Scrol
lbarPart, bool) |
104 { | 106 { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 return ScrollbarTheme::hitTest(scrollbar, position); | 171 return ScrollbarTheme::hitTest(scrollbar, position); |
170 } | 172 } |
171 | 173 |
172 ScrollbarThemeOverlay& ScrollbarThemeOverlay::mobileTheme() | 174 ScrollbarThemeOverlay& ScrollbarThemeOverlay::mobileTheme() |
173 { | 175 { |
174 DEFINE_STATIC_LOCAL(ScrollbarThemeOverlay, theme, (3, 3, ScrollbarThemeOverl
ay::DisallowHitTest, Color(128, 128, 128, 128))); | 176 DEFINE_STATIC_LOCAL(ScrollbarThemeOverlay, theme, (3, 3, ScrollbarThemeOverl
ay::DisallowHitTest, Color(128, 128, 128, 128))); |
175 return theme; | 177 return theme; |
176 } | 178 } |
177 | 179 |
178 } // namespace blink | 180 } // namespace blink |
OLD | NEW |