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

Unified Diff: Source/platform/scroll/ScrollbarThemeOverlay.cpp

Issue 246293006: Blink Support for Overlay Scrollbar Animation Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix unittest and move unittest to blink_platform_unittests Created 6 years, 3 months 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
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeClient.h ('k') | public/platform/WebThemeEngine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scroll/ScrollbarThemeOverlay.cpp
diff --git a/Source/platform/scroll/ScrollbarThemeOverlay.cpp b/Source/platform/scroll/ScrollbarThemeOverlay.cpp
index a8a9556d992fea9853b8a3c861fbfe6e48233192..39ad2deedbb340ecb917d0233b9b5762e19bd6e3 100644
--- a/Source/platform/scroll/ScrollbarThemeOverlay.cpp
+++ b/Source/platform/scroll/ScrollbarThemeOverlay.cpp
@@ -36,6 +36,12 @@
#include <algorithm>
+namespace {
+
+const int kDefaultOverlayScrollbarMinThumbThickness = 9;
+
+} // namespace
+
namespace blink {
ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMargin, HitTestBehavior allowHitTest, Color color)
@@ -136,19 +142,56 @@ void ScrollbarThemeOverlay::paintThumb(GraphicsContext* context, ScrollbarThemeC
return;
}
- blink::WebThemeEngine::State state = blink::WebThemeEngine::StateNormal;
- if (scrollbar->pressedPart() == ThumbPart)
- state = blink::WebThemeEngine::StatePressed;
- else if (scrollbar->hoveredPart() == ThumbPart)
- state = blink::WebThemeEngine::StateHover;
-
blink::WebCanvas* canvas = context->canvas();
blink::WebThemeEngine::Part part = blink::WebThemeEngine::PartScrollbarHorizontalThumb;
if (scrollbar->orientation() == VerticalScrollbar)
part = blink::WebThemeEngine::PartScrollbarVerticalThumb;
- blink::Platform::current()->themeEngine()->paint(canvas, part, state, blink::WebRect(rect), 0);
+ if (scrollbar->isDuringStateTransitionAnimation()) {
+ // Paint in between of two states. First get information from ScrollAnimator
+ double progress = scrollbar->stateTransitionProgress();
+ blink::WebThemeEngine::State startState = scrollbar->stateTransitionStartState();
+ blink::WebThemeEngine::State endState = scrollbar->stateTransitionEndState();
+ double thumbThicknessChanged = progress * (m_thumbThickness - kDefaultOverlayScrollbarMinThumbThickness);
+ double disThumbThickness = m_thumbThickness - thumbThicknessChanged;
+ int displayedThumbThickness = static_cast<int>(disThumbThickness);
+ if (startState == blink::WebThemeEngine::StateNormal)
+ displayedThumbThickness = kDefaultOverlayScrollbarMinThumbThickness + thumbThicknessChanged;
+
+ if (scrollbar->orientation() == HorizontalScrollbar) {
+ thumbRect.setY(thumbRect.y() + (m_thumbThickness - displayedThumbThickness));
+ thumbRect.setHeight(displayedThumbThickness);
+ } else {
+ thumbRect.setWidth(displayedThumbThickness);
+ if (!scrollbar->isLeftSideVerticalScrollbar())
+ thumbRect.setX(thumbRect.x() + (m_thumbThickness - displayedThumbThickness));
+ }
+
+ // int testThumbThickness = static_cast<int>(displayedThumbThickness);
+ // thumbRect.setWidth(1);
+
+ blink::Platform::current()->themeEngine()->paintStateTransition(canvas, part, startState, endState, progress, blink::WebRect(thumbRect));
+ return;
+ }
+
+ blink::WebThemeEngine::State state = blink::WebThemeEngine::StateNormal;
+ if (scrollbar->pressedPart() == ThumbPart) {
+ state = blink::WebThemeEngine::StatePressed;
+ } else if (scrollbar->hoveredPart() == ThumbPart) {
+ state = blink::WebThemeEngine::StateHover;
+ } else {
+ if (scrollbar->orientation() == HorizontalScrollbar) {
+ thumbRect.setY(thumbRect.y() + (m_thumbThickness - kDefaultOverlayScrollbarMinThumbThickness));
+ thumbRect.setHeight(kDefaultOverlayScrollbarMinThumbThickness);
+ } else {
+ thumbRect.setWidth(kDefaultOverlayScrollbarMinThumbThickness);
+ if (!scrollbar->isLeftSideVerticalScrollbar())
+ thumbRect.setX(thumbRect.x() + (m_thumbThickness - kDefaultOverlayScrollbarMinThumbThickness));
+ }
+ }
+
+ blink::Platform::current()->themeEngine()->paint(canvas, part, state, blink::WebRect(thumbRect), 0);
}
ScrollbarPart ScrollbarThemeOverlay::hitTest(ScrollbarThemeClient* scrollbar, const IntPoint& position)
« no previous file with comments | « Source/platform/scroll/ScrollbarThemeClient.h ('k') | public/platform/WebThemeEngine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698