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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 int ScrollbarThemeOverlay::scrollbarMargin() const { | 67 int ScrollbarThemeOverlay::scrollbarMargin() const { |
68 return m_scrollbarMargin; | 68 return m_scrollbarMargin; |
69 } | 69 } |
70 | 70 |
71 bool ScrollbarThemeOverlay::usesOverlayScrollbars() const { | 71 bool ScrollbarThemeOverlay::usesOverlayScrollbars() const { |
72 return true; | 72 return true; |
73 } | 73 } |
74 | 74 |
| 75 double ScrollbarThemeOverlay::overlayScrollbarFadeOutDelaySeconds() const { |
| 76 WebThemeEngine::ScrollbarStyle style; |
| 77 Platform::current()->themeEngine()->getOverlayScrollbarStyle(&style); |
| 78 return style.fadeOutDelaySeconds; |
| 79 } |
| 80 |
| 81 double ScrollbarThemeOverlay::overlayScrollbarFadeOutDurationSeconds() const { |
| 82 WebThemeEngine::ScrollbarStyle style; |
| 83 Platform::current()->themeEngine()->getOverlayScrollbarStyle(&style); |
| 84 return style.fadeOutDurationSeconds; |
| 85 } |
| 86 |
75 int ScrollbarThemeOverlay::thumbPosition(const ScrollbarThemeClient& scrollbar, | 87 int ScrollbarThemeOverlay::thumbPosition(const ScrollbarThemeClient& scrollbar, |
76 float scrollPosition) { | 88 float scrollPosition) { |
77 if (!scrollbar.totalSize()) | 89 if (!scrollbar.totalSize()) |
78 return 0; | 90 return 0; |
79 | 91 |
80 int trackLen = trackLength(scrollbar); | 92 int trackLen = trackLength(scrollbar); |
81 float proportion = static_cast<float>(scrollPosition) / scrollbar.totalSize(); | 93 float proportion = static_cast<float>(scrollPosition) / scrollbar.totalSize(); |
82 return round(proportion * trackLen); | 94 return round(proportion * trackLen); |
83 } | 95 } |
84 | 96 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 if (scrollbar.isLeftSideVerticalScrollbar()) | 156 if (scrollbar.isLeftSideVerticalScrollbar()) |
145 thumbRect.setX(thumbRect.x() + m_scrollbarMargin); | 157 thumbRect.setX(thumbRect.x() + m_scrollbarMargin); |
146 } | 158 } |
147 | 159 |
148 if (m_useSolidColor) { | 160 if (m_useSolidColor) { |
149 context.fillRect(thumbRect, m_color); | 161 context.fillRect(thumbRect, m_color); |
150 return; | 162 return; |
151 } | 163 } |
152 | 164 |
153 WebThemeEngine::State state = WebThemeEngine::StateNormal; | 165 WebThemeEngine::State state = WebThemeEngine::StateNormal; |
154 if (scrollbar.pressedPart() == ThumbPart) | 166 |
| 167 if (!scrollbar.enabled()) |
| 168 state = WebThemeEngine::StateDisabled; |
| 169 else if (scrollbar.pressedPart() == ThumbPart) |
155 state = WebThemeEngine::StatePressed; | 170 state = WebThemeEngine::StatePressed; |
156 else if (scrollbar.hoveredPart() == ThumbPart) | 171 else if (scrollbar.hoveredPart() == ThumbPart) |
157 state = WebThemeEngine::StateHover; | 172 state = WebThemeEngine::StateHover; |
158 | 173 |
159 WebCanvas* canvas = context.canvas(); | 174 WebCanvas* canvas = context.canvas(); |
160 | 175 |
161 WebThemeEngine::Part part = WebThemeEngine::PartScrollbarHorizontalThumb; | 176 WebThemeEngine::Part part = WebThemeEngine::PartScrollbarHorizontalThumb; |
162 if (scrollbar.orientation() == VerticalScrollbar) | 177 if (scrollbar.orientation() == VerticalScrollbar) |
163 part = WebThemeEngine::PartScrollbarVerticalThumb; | 178 part = WebThemeEngine::PartScrollbarVerticalThumb; |
164 | 179 |
165 blink::WebThemeEngine::ExtraParams params; | 180 blink::WebThemeEngine::ExtraParams params; |
166 params.scrollbarThumb.scrollbarTheme = | 181 params.scrollbarThumb.scrollbarTheme = |
167 static_cast<WebScrollbarOverlayColorTheme>( | 182 static_cast<WebScrollbarOverlayColorTheme>( |
168 scrollbar.getScrollbarOverlayColorTheme()); | 183 scrollbar.getScrollbarOverlayColorTheme()); |
169 | 184 |
170 Platform::current()->themeEngine()->paint(canvas, part, state, WebRect(rect), | 185 Platform::current()->themeEngine()->paint(canvas, part, state, WebRect(rect), |
171 ¶ms); | 186 ¶ms); |
172 } | 187 } |
173 | 188 |
174 ScrollbarPart ScrollbarThemeOverlay::hitTest( | 189 ScrollbarPart ScrollbarThemeOverlay::hitTest( |
175 const ScrollbarThemeClient& scrollbar, | 190 const ScrollbarThemeClient& scrollbar, |
176 const IntPoint& position) { | 191 const IntPoint& position) { |
177 if (m_allowHitTest == DisallowHitTest) | 192 if (m_allowHitTest == DisallowHitTest) |
178 return NoPart; | 193 return NoPart; |
179 | 194 |
180 return ScrollbarTheme::hitTest(scrollbar, position); | 195 ScrollbarPart part = ScrollbarTheme::hitTest(scrollbar, position); |
| 196 if (part != ThumbPart) |
| 197 return NoPart; |
| 198 |
| 199 return ThumbPart; |
181 } | 200 } |
182 | 201 |
183 ScrollbarThemeOverlay& ScrollbarThemeOverlay::mobileTheme() { | 202 ScrollbarThemeOverlay& ScrollbarThemeOverlay::mobileTheme() { |
184 static ScrollbarThemeOverlay* theme; | 203 static ScrollbarThemeOverlay* theme; |
185 if (!theme) { | 204 if (!theme) { |
186 WebThemeEngine::ScrollbarStyle style = {3, 3, 0x80808080}; // default style | 205 WebThemeEngine::ScrollbarStyle style = {3, 3, 0x80808080}; // default style |
187 if (Platform::current()->themeEngine()) { | 206 if (Platform::current()->themeEngine()) { |
188 Platform::current()->themeEngine()->getOverlayScrollbarStyle(&style); | 207 Platform::current()->themeEngine()->getOverlayScrollbarStyle(&style); |
189 } | 208 } |
190 theme = new ScrollbarThemeOverlay( | 209 theme = new ScrollbarThemeOverlay( |
191 style.thumbThickness, style.scrollbarMargin, | 210 style.thumbThickness, style.scrollbarMargin, |
192 ScrollbarThemeOverlay::DisallowHitTest, Color(style.color)); | 211 ScrollbarThemeOverlay::DisallowHitTest, Color(style.color)); |
193 } | 212 } |
194 return *theme; | 213 return *theme; |
195 } | 214 } |
196 | 215 |
197 } // namespace blink | 216 } // namespace blink |
OLD | NEW |