OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2011 Apple 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 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "platform/scroll/ScrollbarTheme.h" | 26 #include "platform/scroll/ScrollbarTheme.h" |
27 | 27 |
28 #include "platform/PlatformMouseEvent.h" | 28 #include "platform/PlatformMouseEvent.h" |
29 #include "platform/RuntimeEnabledFeatures.h" | 29 #include "platform/RuntimeEnabledFeatures.h" |
30 #include "platform/graphics/Color.h" | 30 #include "platform/graphics/Color.h" |
31 #include "platform/graphics/GraphicsContext.h" | 31 #include "platform/graphics/GraphicsContext.h" |
| 32 #include "platform/graphics/GraphicsContextStateSaver.h" |
32 #include "platform/graphics/paint/CompositingRecorder.h" | 33 #include "platform/graphics/paint/CompositingRecorder.h" |
33 #include "platform/graphics/paint/CullRect.h" | 34 #include "platform/graphics/paint/CullRect.h" |
34 #include "platform/graphics/paint/DrawingDisplayItem.h" | 35 #include "platform/graphics/paint/DrawingDisplayItem.h" |
35 #include "platform/graphics/paint/DrawingRecorder.h" | 36 #include "platform/graphics/paint/DrawingRecorder.h" |
36 #include "platform/graphics/paint/PaintController.h" | 37 #include "platform/graphics/paint/PaintController.h" |
37 #include "platform/scroll/Scrollbar.h" | 38 #include "platform/scroll/Scrollbar.h" |
38 #include "platform/scroll/ScrollbarThemeMock.h" | 39 #include "platform/scroll/ScrollbarThemeMock.h" |
39 #include "platform/scroll/ScrollbarThemeOverlayMock.h" | 40 #include "platform/scroll/ScrollbarThemeOverlayMock.h" |
40 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
41 #include "public/platform/WebPoint.h" | 42 #include "public/platform/WebPoint.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 WebThemeEngine::StateNormal, WebRect(cornerRect), 0); | 217 WebThemeEngine::StateNormal, WebRect(cornerRect), 0); |
217 #endif | 218 #endif |
218 } | 219 } |
219 | 220 |
220 bool ScrollbarTheme::shouldCenterOnThumb(const ScrollbarThemeClient& scrollbar, | 221 bool ScrollbarTheme::shouldCenterOnThumb(const ScrollbarThemeClient& scrollbar, |
221 const PlatformMouseEvent& evt) { | 222 const PlatformMouseEvent& evt) { |
222 return Platform::current()->scrollbarBehavior()->shouldCenterOnThumb( | 223 return Platform::current()->scrollbarBehavior()->shouldCenterOnThumb( |
223 evt.pointerProperties().button, evt.shiftKey(), evt.altKey()); | 224 evt.pointerProperties().button, evt.shiftKey(), evt.altKey()); |
224 } | 225 } |
225 | 226 |
| 227 void ScrollbarTheme::paintTickmarks(GraphicsContext& context, |
| 228 const Scrollbar& scrollbar, |
| 229 const IntRect& rect) { |
| 230 // Android paints tickmarks in the browser at FindResultBar.java. |
| 231 #if !OS(ANDROID) |
| 232 if (scrollbar.orientation() != VerticalScrollbar) |
| 233 return; |
| 234 |
| 235 if (rect.height() <= 0 || rect.width() <= 0) |
| 236 return; |
| 237 |
| 238 // Get the tickmarks for the frameview. |
| 239 Vector<IntRect> tickmarks; |
| 240 scrollbar.getTickmarks(tickmarks); |
| 241 if (!tickmarks.size()) |
| 242 return; |
| 243 |
| 244 if (DrawingRecorder::useCachedDrawingIfPossible( |
| 245 context, scrollbar, DisplayItem::kScrollbarTickmarks)) |
| 246 return; |
| 247 |
| 248 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarTickmarks, |
| 249 rect); |
| 250 GraphicsContextStateSaver stateSaver(context); |
| 251 context.setShouldAntialias(false); |
| 252 |
| 253 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); |
| 254 i != tickmarks.end(); ++i) { |
| 255 // Calculate how far down (in %) the tick-mark should appear. |
| 256 const float percent = static_cast<float>(i->y()) / scrollbar.totalSize(); |
| 257 |
| 258 // Calculate how far down (in pixels) the tick-mark should appear. |
| 259 const int yPos = rect.y() + (rect.height() * percent); |
| 260 |
| 261 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); |
| 262 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); |
| 263 |
| 264 FloatRect tickStroke(rect.x() + tickmarkBorderWidth(), yPos + 1, |
| 265 rect.width() - 2 * tickmarkBorderWidth(), 1); |
| 266 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); |
| 267 } |
| 268 #endif |
| 269 } |
| 270 |
226 bool ScrollbarTheme::shouldSnapBackToDragOrigin( | 271 bool ScrollbarTheme::shouldSnapBackToDragOrigin( |
227 const ScrollbarThemeClient& scrollbar, | 272 const ScrollbarThemeClient& scrollbar, |
228 const PlatformMouseEvent& evt) { | 273 const PlatformMouseEvent& evt) { |
229 IntPoint mousePosition = scrollbar.convertFromRootFrame(evt.position()); | 274 IntPoint mousePosition = scrollbar.convertFromRootFrame(evt.position()); |
230 mousePosition.move(scrollbar.x(), scrollbar.y()); | 275 mousePosition.move(scrollbar.x(), scrollbar.y()); |
231 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin( | 276 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin( |
232 mousePosition, trackRect(scrollbar), | 277 mousePosition, trackRect(scrollbar), |
233 scrollbar.orientation() == HorizontalScrollbar); | 278 scrollbar.orientation() == HorizontalScrollbar); |
234 } | 279 } |
235 | 280 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 return DisplayItem::kScrollbarBackTrack; | 436 return DisplayItem::kScrollbarBackTrack; |
392 case ForwardTrackPart: | 437 case ForwardTrackPart: |
393 return DisplayItem::kScrollbarForwardTrack; | 438 return DisplayItem::kScrollbarForwardTrack; |
394 default: | 439 default: |
395 ASSERT_NOT_REACHED(); | 440 ASSERT_NOT_REACHED(); |
396 return DisplayItem::kScrollbarBackTrack; | 441 return DisplayItem::kScrollbarBackTrack; |
397 } | 442 } |
398 } | 443 } |
399 | 444 |
400 } // namespace blink | 445 } // namespace blink |
OLD | NEW |