Chromium Code Reviews| 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 OS(ANDROID) | |
| 232 NOTREACHED(); | |
|
bokan
2016/11/07 19:06:16
Just add a comment here that Android paints tickma
| |
| 233 #endif | |
| 234 if (scrollbar.orientation() != VerticalScrollbar) | |
| 235 return; | |
| 236 | |
| 237 if (rect.height() <= 0 || rect.width() <= 0) | |
| 238 return; | |
| 239 | |
| 240 // Get the tickmarks for the frameview. | |
| 241 Vector<IntRect> tickmarks; | |
| 242 scrollbar.getTickmarks(tickmarks); | |
| 243 if (!tickmarks.size()) | |
| 244 return; | |
| 245 | |
| 246 if (DrawingRecorder::useCachedDrawingIfPossible( | |
| 247 context, scrollbar, DisplayItem::kScrollbarTickmarks)) | |
| 248 return; | |
| 249 | |
| 250 DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarTickmarks, | |
| 251 rect); | |
| 252 GraphicsContextStateSaver stateSaver(context); | |
| 253 context.setShouldAntialias(false); | |
| 254 | |
| 255 for (Vector<IntRect>::const_iterator i = tickmarks.begin(); | |
| 256 i != tickmarks.end(); ++i) { | |
| 257 // Calculate how far down (in %) the tick-mark should appear. | |
| 258 const float percent = static_cast<float>(i->y()) / scrollbar.totalSize(); | |
| 259 | |
| 260 // Calculate how far down (in pixels) the tick-mark should appear. | |
| 261 const int yPos = rect.y() + (rect.height() * percent); | |
| 262 | |
| 263 FloatRect tickRect(rect.x(), yPos, rect.width(), 3); | |
| 264 context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); | |
| 265 | |
| 266 FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); | |
| 267 context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); | |
| 268 } | |
| 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 |