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

Side by Side Diff: third_party/WebKit/Source/platform/scroll/ScrollbarThemeOverlay.cpp

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

Powered by Google App Engine
This is Rietveld 408576698