Chromium Code Reviews| Index: third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp |
| diff --git a/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp b/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp |
| index 6579fe491766dc6ef2c702aedbb0000f56081906..4406a9b981422df0c4db26a2b989ed7a09c873af 100644 |
| --- a/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp |
| +++ b/third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp |
| @@ -29,6 +29,7 @@ |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/graphics/Color.h" |
| #include "platform/graphics/GraphicsContext.h" |
| +#include "platform/graphics/GraphicsContextStateSaver.h" |
| #include "platform/graphics/paint/CompositingRecorder.h" |
| #include "platform/graphics/paint/CullRect.h" |
| #include "platform/graphics/paint/DrawingDisplayItem.h" |
| @@ -223,6 +224,50 @@ bool ScrollbarTheme::shouldCenterOnThumb(const ScrollbarThemeClient& scrollbar, |
| evt.pointerProperties().button, evt.shiftKey(), evt.altKey()); |
| } |
| +// Only ScrollbarThemeAura and ScrollbarThemeOverlay are using this method. |
| +void ScrollbarTheme::paintTickmarks(GraphicsContext& context, |
| + const Scrollbar& scrollbar, |
| + const IntRect& rect) { |
| +#if OS(ANDROID) |
| + NOTREACHED(); |
|
bokan
2016/11/07 19:06:16
Just add a comment here that Android paints tickma
|
| +#endif |
| + if (scrollbar.orientation() != VerticalScrollbar) |
| + return; |
| + |
| + if (rect.height() <= 0 || rect.width() <= 0) |
| + return; |
| + |
| + // Get the tickmarks for the frameview. |
| + Vector<IntRect> tickmarks; |
| + scrollbar.getTickmarks(tickmarks); |
| + if (!tickmarks.size()) |
| + return; |
| + |
| + if (DrawingRecorder::useCachedDrawingIfPossible( |
| + context, scrollbar, DisplayItem::kScrollbarTickmarks)) |
| + return; |
| + |
| + DrawingRecorder recorder(context, scrollbar, DisplayItem::kScrollbarTickmarks, |
| + rect); |
| + GraphicsContextStateSaver stateSaver(context); |
| + context.setShouldAntialias(false); |
| + |
| + for (Vector<IntRect>::const_iterator i = tickmarks.begin(); |
| + i != tickmarks.end(); ++i) { |
| + // Calculate how far down (in %) the tick-mark should appear. |
| + const float percent = static_cast<float>(i->y()) / scrollbar.totalSize(); |
| + |
| + // Calculate how far down (in pixels) the tick-mark should appear. |
| + const int yPos = rect.y() + (rect.height() * percent); |
| + |
| + FloatRect tickRect(rect.x(), yPos, rect.width(), 3); |
| + context.fillRect(tickRect, Color(0xCC, 0xAA, 0x00, 0xFF)); |
| + |
| + FloatRect tickStroke(rect.x(), yPos + 1, rect.width(), 1); |
| + context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF)); |
| + } |
| +} |
| + |
| bool ScrollbarTheme::shouldSnapBackToDragOrigin( |
| const ScrollbarThemeClient& scrollbar, |
| const PlatformMouseEvent& evt) { |