Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1419)

Unified Diff: third_party/WebKit/Source/platform/scroll/ScrollbarTheme.cpp

Issue 2478743003: add Tickmarks to aura overlay scrollbar (Closed)
Patch Set: typo Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..00b2e022398ea77ecf08ea9a5bc881fe503aeb5a 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());
}
+void ScrollbarTheme::paintTickmarks(GraphicsContext& context,
+ const Scrollbar& scrollbar,
+ const IntRect& rect) {
+// Android paints tickmarks in the browser at FindResultBar.java.
+#if !OS(ANDROID)
+ 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() + tickmarkBorderWidth(), yPos + 1,
+ rect.width() - 2 * tickmarkBorderWidth(), 1);
+ context.fillRect(tickStroke, Color(0xFF, 0xDD, 0x00, 0xFF));
+ }
+#endif
+}
+
bool ScrollbarTheme::shouldSnapBackToDragOrigin(
const ScrollbarThemeClient& scrollbar,
const PlatformMouseEvent& evt) {

Powered by Google App Engine
This is Rietveld 408576698