OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2008, 2009 Google Inc. | 3 * Copyright (C) 2008, 2009 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
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 if (!thickness) { | 65 if (!thickness) { |
66 if (isRunningLayoutTest()) | 66 if (isRunningLayoutTest()) |
67 return kMacScrollbarSize[controlSize]; | 67 return kMacScrollbarSize[controlSize]; |
68 thickness = IntSize(WebKit::Platform::current()->themeEngine()->getSize(
SBP_ARROWBTN)).width(); | 68 thickness = IntSize(WebKit::Platform::current()->themeEngine()->getSize(
SBP_ARROWBTN)).width(); |
69 } | 69 } |
70 return thickness; | 70 return thickness; |
71 } | 71 } |
72 | 72 |
73 bool ScrollbarThemeWin::invalidateOnMouseEnterExit() | 73 bool ScrollbarThemeWin::invalidateOnMouseEnterExit() |
74 { | 74 { |
75 return windowsVersion() >= WindowsVista; | 75 return isWindowsVistaOrGreater(); |
76 } | 76 } |
77 | 77 |
78 bool ScrollbarThemeWin::shouldSnapBackToDragOrigin(ScrollbarThemeClient* scrollb
ar, const PlatformMouseEvent& evt) | 78 bool ScrollbarThemeWin::shouldSnapBackToDragOrigin(ScrollbarThemeClient* scrollb
ar, const PlatformMouseEvent& evt) |
79 { | 79 { |
80 // Find the rect within which we shouldn't snap, by expanding the track rect | 80 // Find the rect within which we shouldn't snap, by expanding the track rect |
81 // in both dimensions. | 81 // in both dimensions. |
82 IntRect rect = trackRect(scrollbar); | 82 IntRect rect = trackRect(scrollbar); |
83 const bool horz = scrollbar->orientation() == HorizontalScrollbar; | 83 const bool horz = scrollbar->orientation() == HorizontalScrollbar; |
84 const int thickness = scrollbarThickness(scrollbar->controlSize()); | 84 const int thickness = scrollbarThickness(scrollbar->controlSize()); |
85 rect.inflateX((horz ? kOffEndMultiplier : kOffSideMultiplier) * thickness); | 85 rect.inflateX((horz ? kOffEndMultiplier : kOffSideMultiplier) * thickness); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 int ScrollbarThemeWin::getThemeState(ScrollbarThemeClient* scrollbar, ScrollbarP
art part) const | 140 int ScrollbarThemeWin::getThemeState(ScrollbarThemeClient* scrollbar, ScrollbarP
art part) const |
141 { | 141 { |
142 // When dragging the thumb, draw thumb pressed and other segments normal | 142 // When dragging the thumb, draw thumb pressed and other segments normal |
143 // regardless of where the cursor actually is. See also four places in | 143 // regardless of where the cursor actually is. See also four places in |
144 // getThemeArrowState(). | 144 // getThemeArrowState(). |
145 if (scrollbar->pressedPart() == ThumbPart) { | 145 if (scrollbar->pressedPart() == ThumbPart) { |
146 if (part == ThumbPart) | 146 if (part == ThumbPart) |
147 return SCRBS_PRESSED; | 147 return SCRBS_PRESSED; |
148 return (windowsVersion() < WindowsVista) ? SCRBS_NORMAL : SCRBS_HOVER; | 148 return isWindowsVistaOrGreater() ? SCRBS_HOVER : SCRBS_NORMAL; |
149 } | 149 } |
150 if (!scrollbar->enabled()) | 150 if (!scrollbar->enabled()) |
151 return SCRBS_DISABLED; | 151 return SCRBS_DISABLED; |
152 if (scrollbar->hoveredPart() != part || part == BackTrackPart || part == For
wardTrackPart) | 152 if (scrollbar->hoveredPart() != part || part == BackTrackPart || part == For
wardTrackPart) |
153 return (scrollbar->hoveredPart() == NoPart || (windowsVersion() < Window
sVista)) ? SCRBS_NORMAL : SCRBS_HOVER; | 153 return (scrollbar->hoveredPart() == NoPart || !isWindowsVistaOrGreater()
) ? SCRBS_NORMAL : SCRBS_HOVER; |
154 if (scrollbar->pressedPart() == NoPart) | 154 if (scrollbar->pressedPart() == NoPart) |
155 return SCRBS_HOT; | 155 return SCRBS_HOT; |
156 return (scrollbar->pressedPart() == part) ? SCRBS_PRESSED : SCRBS_NORMAL; | 156 return (scrollbar->pressedPart() == part) ? SCRBS_PRESSED : SCRBS_NORMAL; |
157 } | 157 } |
158 | 158 |
159 int ScrollbarThemeWin::getThemeArrowState(ScrollbarThemeClient* scrollbar, Scrol
lbarPart part) const | 159 int ScrollbarThemeWin::getThemeArrowState(ScrollbarThemeClient* scrollbar, Scrol
lbarPart part) const |
160 { | 160 { |
161 // We could take advantage of knowing the values in the state enum to write | 161 // We could take advantage of knowing the values in the state enum to write |
162 // some simpler code, but treating the state enum as a black box seems | 162 // some simpler code, but treating the state enum as a black box seems |
163 // clearer and more future-proof. | 163 // clearer and more future-proof. |
164 if (part == BackButtonStartPart || part == ForwardButtonStartPart) { | 164 if (part == BackButtonStartPart || part == ForwardButtonStartPart) { |
165 if (scrollbar->orientation() == HorizontalScrollbar) { | 165 if (scrollbar->orientation() == HorizontalScrollbar) { |
166 if (scrollbar->pressedPart() == ThumbPart) | 166 if (scrollbar->pressedPart() == ThumbPart) |
167 return (windowsVersion() < WindowsVista) ? ABS_LEFTNORMAL : ABS_
LEFTHOVER; | 167 return isWindowsVistaOrGreater() ? ABS_LEFTHOVER : ABS_LEFTNORMA
L; |
168 if (!scrollbar->enabled()) | 168 if (!scrollbar->enabled()) |
169 return ABS_LEFTDISABLED; | 169 return ABS_LEFTDISABLED; |
170 if (scrollbar->hoveredPart() != part) | 170 if (scrollbar->hoveredPart() != part) |
171 return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion(
) < WindowsVista)) ? ABS_LEFTNORMAL : ABS_LEFTHOVER; | 171 return ((scrollbar->hoveredPart() == NoPart) || !isWindowsVistaO
rGreater()) ? ABS_LEFTNORMAL : ABS_LEFTHOVER; |
172 if (scrollbar->pressedPart() == NoPart) | 172 if (scrollbar->pressedPart() == NoPart) |
173 return ABS_LEFTHOT; | 173 return ABS_LEFTHOT; |
174 return (scrollbar->pressedPart() == part) ? | 174 return (scrollbar->pressedPart() == part) ? |
175 ABS_LEFTPRESSED : ABS_LEFTNORMAL; | 175 ABS_LEFTPRESSED : ABS_LEFTNORMAL; |
176 } | 176 } |
177 if (scrollbar->pressedPart() == ThumbPart) | 177 if (scrollbar->pressedPart() == ThumbPart) |
178 return (windowsVersion() < WindowsVista) ? ABS_UPNORMAL : ABS_UPHOVE
R; | 178 return isWindowsVistaOrGreater() ? ABS_UPHOVER : ABS_UPNORMAL; |
179 if (!scrollbar->enabled()) | 179 if (!scrollbar->enabled()) |
180 return ABS_UPDISABLED; | 180 return ABS_UPDISABLED; |
181 if (scrollbar->hoveredPart() != part) | 181 if (scrollbar->hoveredPart() != part) |
182 return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() <
WindowsVista)) ? ABS_UPNORMAL : ABS_UPHOVER; | 182 return ((scrollbar->hoveredPart() == NoPart) || !isWindowsVistaOrGre
ater()) ? ABS_UPNORMAL : ABS_UPHOVER; |
183 if (scrollbar->pressedPart() == NoPart) | 183 if (scrollbar->pressedPart() == NoPart) |
184 return ABS_UPHOT; | 184 return ABS_UPHOT; |
185 return (scrollbar->pressedPart() == part) ? ABS_UPPRESSED : ABS_UPNORMAL
; | 185 return (scrollbar->pressedPart() == part) ? ABS_UPPRESSED : ABS_UPNORMAL
; |
186 } | 186 } |
187 if (scrollbar->orientation() == HorizontalScrollbar) { | 187 if (scrollbar->orientation() == HorizontalScrollbar) { |
188 if (scrollbar->pressedPart() == ThumbPart) | 188 if (scrollbar->pressedPart() == ThumbPart) |
189 return (windowsVersion() < WindowsVista) ? ABS_RIGHTNORMAL : ABS_RIG
HTHOVER; | 189 return isWindowsVistaOrGreater() ? ABS_RIGHTHOVER : ABS_RIGHTNORMAL; |
190 if (!scrollbar->enabled()) | 190 if (!scrollbar->enabled()) |
191 return ABS_RIGHTDISABLED; | 191 return ABS_RIGHTDISABLED; |
192 if (scrollbar->hoveredPart() != part) | 192 if (scrollbar->hoveredPart() != part) |
193 return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() <
WindowsVista)) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; | 193 return ((scrollbar->hoveredPart() == NoPart) || !isWindowsVistaOrGre
ater()) ? ABS_RIGHTNORMAL : ABS_RIGHTHOVER; |
194 if (scrollbar->pressedPart() == NoPart) | 194 if (scrollbar->pressedPart() == NoPart) |
195 return ABS_RIGHTHOT; | 195 return ABS_RIGHTHOT; |
196 return (scrollbar->pressedPart() == part) ? ABS_RIGHTPRESSED : ABS_RIGHT
NORMAL; | 196 return (scrollbar->pressedPart() == part) ? ABS_RIGHTPRESSED : ABS_RIGHT
NORMAL; |
197 } | 197 } |
198 if (scrollbar->pressedPart() == ThumbPart) | 198 if (scrollbar->pressedPart() == ThumbPart) |
199 return (windowsVersion() < WindowsVista) ? ABS_DOWNNORMAL : ABS_DOWNHOVE
R; | 199 return isWindowsVistaOrGreater() ? ABS_DOWNHOVER : ABS_DOWNNORMAL; |
200 if (!scrollbar->enabled()) | 200 if (!scrollbar->enabled()) |
201 return ABS_DOWNDISABLED; | 201 return ABS_DOWNDISABLED; |
202 if (scrollbar->hoveredPart() != part) | 202 if (scrollbar->hoveredPart() != part) |
203 return ((scrollbar->hoveredPart() == NoPart) || (windowsVersion() < Wind
owsVista)) ? ABS_DOWNNORMAL : ABS_DOWNHOVER; | 203 return ((scrollbar->hoveredPart() == NoPart) || !isWindowsVistaOrGreater
()) ? ABS_DOWNNORMAL : ABS_DOWNHOVER; |
204 if (scrollbar->pressedPart() == NoPart) | 204 if (scrollbar->pressedPart() == NoPart) |
205 return ABS_DOWNHOT; | 205 return ABS_DOWNHOT; |
206 return (scrollbar->pressedPart() == part) ? ABS_DOWNPRESSED : ABS_DOWNNORMAL
; | 206 return (scrollbar->pressedPart() == part) ? ABS_DOWNPRESSED : ABS_DOWNNORMAL
; |
207 } | 207 } |
208 | 208 |
209 int ScrollbarThemeWin::getClassicThemeState(ScrollbarThemeClient* scrollbar, Scr
ollbarPart part) const | 209 int ScrollbarThemeWin::getClassicThemeState(ScrollbarThemeClient* scrollbar, Scr
ollbarPart part) const |
210 { | 210 { |
211 // When dragging the thumb, draw the buttons normal even when hovered. | 211 // When dragging the thumb, draw the buttons normal even when hovered. |
212 if (scrollbar->pressedPart() == ThumbPart) | 212 if (scrollbar->pressedPart() == ThumbPart) |
213 return 0; | 213 return 0; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 int width = scrollbar->width() < 2 * girth ? scrollbar->width() / 2 : gi
rth; | 247 int width = scrollbar->width() < 2 * girth ? scrollbar->width() / 2 : gi
rth; |
248 return IntSize(width, thickness); | 248 return IntSize(width, thickness); |
249 } | 249 } |
250 | 250 |
251 int height = scrollbar->height() < 2 * girth ? scrollbar->height() / 2 : gir
th; | 251 int height = scrollbar->height() < 2 * girth ? scrollbar->height() / 2 : gir
th; |
252 return IntSize(thickness, height); | 252 return IntSize(thickness, height); |
253 } | 253 } |
254 | 254 |
255 | 255 |
256 } // namespace WebCore | 256 } // namespace WebCore |
OLD | NEW |