OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "platform/PlatformMouseEvent.h" | 29 #include "platform/PlatformMouseEvent.h" |
30 #include "platform/graphics/GraphicsContext.h" | 30 #include "platform/graphics/GraphicsContext.h" |
31 #include "platform/scroll/ScrollbarThemeClient.h" | 31 #include "platform/scroll/ScrollbarThemeClient.h" |
32 #include "platform/transforms/TransformationMatrix.h" | 32 #include "platform/transforms/TransformationMatrix.h" |
33 #include "public/platform/Platform.h" | 33 #include "public/platform/Platform.h" |
34 #include "public/platform/WebRect.h" | 34 #include "public/platform/WebRect.h" |
35 #include "public/platform/WebThemeEngine.h" | 35 #include "public/platform/WebThemeEngine.h" |
36 | 36 |
37 #include <algorithm> | 37 #include <algorithm> |
38 | 38 |
| 39 namespace { |
| 40 |
| 41 const int kDefaultOverlayScrollbarMinThumbThickness = 9; |
| 42 |
| 43 } // namespace |
| 44 |
39 namespace blink { | 45 namespace blink { |
40 | 46 |
41 ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMa
rgin, HitTestBehavior allowHitTest, Color color) | 47 ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMa
rgin, HitTestBehavior allowHitTest, Color color) |
42 : ScrollbarTheme() | 48 : ScrollbarTheme() |
43 , m_thumbThickness(thumbThickness) | 49 , m_thumbThickness(thumbThickness) |
44 , m_scrollbarMargin(scrollbarMargin) | 50 , m_scrollbarMargin(scrollbarMargin) |
45 , m_allowHitTest(allowHitTest) | 51 , m_allowHitTest(allowHitTest) |
46 , m_color(color) | 52 , m_color(color) |
47 , m_useSolidColor(true) | 53 , m_useSolidColor(true) |
48 { | 54 { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 thumbRect.setWidth(thumbRect.width() - m_scrollbarMargin); | 135 thumbRect.setWidth(thumbRect.width() - m_scrollbarMargin); |
130 if (scrollbar->isLeftSideVerticalScrollbar()) | 136 if (scrollbar->isLeftSideVerticalScrollbar()) |
131 thumbRect.setX(thumbRect.x() + m_scrollbarMargin); | 137 thumbRect.setX(thumbRect.x() + m_scrollbarMargin); |
132 } | 138 } |
133 | 139 |
134 if (m_useSolidColor) { | 140 if (m_useSolidColor) { |
135 context->fillRect(thumbRect, m_color); | 141 context->fillRect(thumbRect, m_color); |
136 return; | 142 return; |
137 } | 143 } |
138 | 144 |
139 blink::WebThemeEngine::State state = blink::WebThemeEngine::StateNormal; | |
140 if (scrollbar->pressedPart() == ThumbPart) | |
141 state = blink::WebThemeEngine::StatePressed; | |
142 else if (scrollbar->hoveredPart() == ThumbPart) | |
143 state = blink::WebThemeEngine::StateHover; | |
144 | |
145 blink::WebCanvas* canvas = context->canvas(); | 145 blink::WebCanvas* canvas = context->canvas(); |
146 | 146 |
147 blink::WebThemeEngine::Part part = blink::WebThemeEngine::PartScrollbarHoriz
ontalThumb; | 147 blink::WebThemeEngine::Part part = blink::WebThemeEngine::PartScrollbarHoriz
ontalThumb; |
148 if (scrollbar->orientation() == VerticalScrollbar) | 148 if (scrollbar->orientation() == VerticalScrollbar) |
149 part = blink::WebThemeEngine::PartScrollbarVerticalThumb; | 149 part = blink::WebThemeEngine::PartScrollbarVerticalThumb; |
150 | 150 |
151 blink::Platform::current()->themeEngine()->paint(canvas, part, state, blink:
:WebRect(rect), 0); | 151 if (scrollbar->isDuringStateTransitionAnimation()) { |
| 152 // Paint in between of two states. First get information from ScrollAnim
ator |
| 153 double progress = scrollbar->stateTransitionProgress(); |
| 154 blink::WebThemeEngine::State startState = scrollbar->stateTransitionStar
tState(); |
| 155 blink::WebThemeEngine::State endState = scrollbar->stateTransitionEndSta
te(); |
| 156 double thumbThicknessChanged = progress * (m_thumbThickness - kDefaultOv
erlayScrollbarMinThumbThickness); |
| 157 double disThumbThickness = m_thumbThickness - thumbThicknessChanged; |
| 158 int displayedThumbThickness = static_cast<int>(disThumbThickness); |
| 159 if (startState == blink::WebThemeEngine::StateNormal) |
| 160 displayedThumbThickness = kDefaultOverlayScrollbarMinThumbThickness
+ thumbThicknessChanged; |
| 161 |
| 162 if (scrollbar->orientation() == HorizontalScrollbar) { |
| 163 thumbRect.setY(thumbRect.y() + (m_thumbThickness - displayedThumbThi
ckness)); |
| 164 thumbRect.setHeight(displayedThumbThickness); |
| 165 } else { |
| 166 thumbRect.setWidth(displayedThumbThickness); |
| 167 if (!scrollbar->isLeftSideVerticalScrollbar()) |
| 168 thumbRect.setX(thumbRect.x() + (m_thumbThickness - displayedThum
bThickness)); |
| 169 } |
| 170 |
| 171 // int testThumbThickness = static_cast<int>(displayedThumbThickn
ess); |
| 172 // thumbRect.setWidth(1); |
| 173 |
| 174 blink::Platform::current()->themeEngine()->paintStateTransition(canvas,
part, startState, endState, progress, blink::WebRect(thumbRect)); |
| 175 return; |
| 176 } |
| 177 |
| 178 blink::WebThemeEngine::State state = blink::WebThemeEngine::StateNormal; |
| 179 if (scrollbar->pressedPart() == ThumbPart) { |
| 180 state = blink::WebThemeEngine::StatePressed; |
| 181 } else if (scrollbar->hoveredPart() == ThumbPart) { |
| 182 state = blink::WebThemeEngine::StateHover; |
| 183 } else { |
| 184 if (scrollbar->orientation() == HorizontalScrollbar) { |
| 185 thumbRect.setY(thumbRect.y() + (m_thumbThickness - kDefaultOverlaySc
rollbarMinThumbThickness)); |
| 186 thumbRect.setHeight(kDefaultOverlayScrollbarMinThumbThickness); |
| 187 } else { |
| 188 thumbRect.setWidth(kDefaultOverlayScrollbarMinThumbThickness); |
| 189 if (!scrollbar->isLeftSideVerticalScrollbar()) |
| 190 thumbRect.setX(thumbRect.x() + (m_thumbThickness - kDefaultOverl
ayScrollbarMinThumbThickness)); |
| 191 } |
| 192 } |
| 193 |
| 194 blink::Platform::current()->themeEngine()->paint(canvas, part, state, blink:
:WebRect(thumbRect), 0); |
152 } | 195 } |
153 | 196 |
154 ScrollbarPart ScrollbarThemeOverlay::hitTest(ScrollbarThemeClient* scrollbar, co
nst IntPoint& position) | 197 ScrollbarPart ScrollbarThemeOverlay::hitTest(ScrollbarThemeClient* scrollbar, co
nst IntPoint& position) |
155 { | 198 { |
156 if (m_allowHitTest == DisallowHitTest) | 199 if (m_allowHitTest == DisallowHitTest) |
157 return NoPart; | 200 return NoPart; |
158 | 201 |
159 return ScrollbarTheme::hitTest(scrollbar, position); | 202 return ScrollbarTheme::hitTest(scrollbar, position); |
160 } | 203 } |
161 | 204 |
162 } // namespace blink | 205 } // namespace blink |
OLD | NEW |