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 // Only ScrollbarThemeAura and ScrollbarThemeOverlay are using this method. |
| 228 void ScrollbarTheme::paintTickmarks(GraphicsContext& context, |
| 229 const Scrollbar& scrollbar, |
| 230 const IntRect& rect) { |
| 231 if (scrollbar.orientation() != VerticalScrollbar) |
| 232 return; |
| 233 |
| 234 if (rect.height() <= 0 || rect.width() <= 0) |
| 235 return; |
| 236 |
| 237 // Get the tickmarks for the frameview. |
| 238 Vector<IntRect> tickmarks; |
| 239 scrollbar.getTickmarks(tickmarks); |
| 240 if (!tickmarks.size()) |
| 241 return; |
| 242 |
| 243 if (DrawingRecorder::useCachedDrawingIfPossible( |
| 244 context, scrollbar, DisplayItem::kScrollbarTickmarks)) |
| 245 return; |
| 246 |
| 247 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarTickmarks, |
| 248 rect); |
| 249 GraphicsContextStateSaver stateSaver(context); |
| 250 context.setShouldAntialias(false); |
| 251 |
| 252 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); |
| 253 i != tickmarks.end(); ++i) { |
| 254 // Calculate how far down (in %) the tick-mark should appear. |
| 255 const float percent = static_cast<float>(i->y()) / scrollbar.totalSize(); |
| 256 |
| 257 // Calculate how far down (in pixels) the tick-mark should appear. |
| 258 const int yPos = rect.y() + (rect.height() * percent); |
| 259 |
| 260 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); |
| 261 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); |
| 262 |
| 263 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); |
| 264 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); |
| 265 } |
| 266 } |
| 267 |
226 bool ScrollbarTheme::shouldSnapBackToDragOrigin( | 268 bool ScrollbarTheme::shouldSnapBackToDragOrigin( |
227 const ScrollbarThemeClient& scrollbar, | 269 const ScrollbarThemeClient& scrollbar, |
228 const PlatformMouseEvent& evt) { | 270 const PlatformMouseEvent& evt) { |
229 IntPoint mousePosition = scrollbar.convertFromRootFrame(evt.position()); | 271 IntPoint mousePosition = scrollbar.convertFromRootFrame(evt.position()); |
230 mousePosition.move(scrollbar.x(), scrollbar.y()); | 272 mousePosition.move(scrollbar.x(), scrollbar.y()); |
231 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin( | 273 return Platform::current()->scrollbarBehavior()->shouldSnapBackToDragOrigin( |
232 mousePosition, trackRect(scrollbar), | 274 mousePosition, trackRect(scrollbar), |
233 scrollbar.orientation() == HorizontalScrollbar); | 275 scrollbar.orientation() == HorizontalScrollbar); |
234 } | 276 } |
235 | 277 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 return DisplayItem::kScrollbarBackTrack; | 433 return DisplayItem::kScrollbarBackTrack; |
392 case ForwardTrackPart: | 434 case ForwardTrackPart: |
393 return DisplayItem::kScrollbarForwardTrack; | 435 return DisplayItem::kScrollbarForwardTrack; |
394 default: | 436 default: |
395 ASSERT_NOT_REACHED(); | 437 ASSERT_NOT_REACHED(); |
396 return DisplayItem::kScrollbarBackTrack; | 438 return DisplayItem::kScrollbarBackTrack; |
397 } | 439 } |
398 } | 440 } |
399 | 441 |
400 } // namespace blink | 442 } // namespace blink |
OLD | NEW |