Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, 2009, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, 2009, 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 state = blink::WebThemeEngine::StatePressed; | 138 state = blink::WebThemeEngine::StatePressed; |
| 139 else if (scrollbar->hoveredPart() == ThumbPart) | 139 else if (scrollbar->hoveredPart() == ThumbPart) |
| 140 state = blink::WebThemeEngine::StateHover; | 140 state = blink::WebThemeEngine::StateHover; |
| 141 else | 141 else |
| 142 state = blink::WebThemeEngine::StateNormal; | 142 state = blink::WebThemeEngine::StateNormal; |
| 143 blink::Platform::current()->themeEngine()->paint(canvas, scrollbar->orientat ion() == HorizontalScrollbar ? blink::WebThemeEngine::PartScrollbarHorizontalThu mb : blink::WebThemeEngine::PartScrollbarVerticalThumb, state, blink::WebRect(re ct), 0); | 143 blink::Platform::current()->themeEngine()->paint(canvas, scrollbar->orientat ion() == HorizontalScrollbar ? blink::WebThemeEngine::PartScrollbarHorizontalThu mb : blink::WebThemeEngine::PartScrollbarVerticalThumb, state, blink::WebRect(re ct), 0); |
| 144 } | 144 } |
| 145 | 145 |
| 146 bool ScrollbarThemeGtkOrAura::shouldCenterOnThumb(ScrollbarThemeClient*, const P latformMouseEvent& evt) | 146 bool ScrollbarThemeGtkOrAura::shouldCenterOnThumb(ScrollbarThemeClient*, const P latformMouseEvent& evt) |
| 147 { | 147 { |
| 148 return (evt.shiftKey() && evt.button() == LeftButton) || (evt.button() == Mi ddleButton); | 148 #if defined(TOOLKIT_GTK) |
|
Elliot Glaysher
2014/02/11 18:36:56
You probably want defined(TOOLKIT_GTK) || (defined
Peter Kasting
2014/02/12 03:17:58
Done.
| |
| 149 if (evt.button() == MiddleButton) | |
| 150 return true; | |
| 151 #endif | |
| 152 return (evt.shiftKey() && evt.button() == LeftButton); | |
| 153 } | |
| 154 | |
| 155 bool ScrollbarThemeGtkOrAura::shouldSnapBackToDragOrigin(ScrollbarThemeClient* s crollbar, const PlatformMouseEvent& evt) | |
| 156 { | |
| 157 #if defined(TOOLKIT_GTK) | |
|
sky
2014/02/10 15:14:30
Don't you want !win here? Otherwise won't chromeos
Peter Kasting
2014/02/10 23:09:16
To re-quote my initial comment on this CL:
"(I ch
| |
| 158 return false; | |
| 159 #endif | |
| 160 | |
| 161 // Constants used to figure the drag rect outside which we should snap the | |
| 162 // scrollbar thumb back to its origin. These calculations are based on | |
| 163 // observing the behavior of the MSVC8 main window scrollbar + some | |
| 164 // guessing/extrapolation. | |
| 165 static const int kOffEndMultiplier = 3; | |
| 166 static const int kOffSideMultiplier = 8; | |
| 167 | |
| 168 // Find the rect within which we shouldn't snap, by expanding the track rect | |
| 169 // in both dimensions. | |
| 170 IntRect rect = trackRect(scrollbar); | |
| 171 const bool horz = scrollbar->orientation() == HorizontalScrollbar; | |
| 172 const int thickness = scrollbarThickness(scrollbar->controlSize()); | |
| 173 rect.inflateX((horz ? kOffEndMultiplier : kOffSideMultiplier) * thickness); | |
| 174 rect.inflateY((horz ? kOffSideMultiplier : kOffEndMultiplier) * thickness); | |
| 175 | |
| 176 // Convert the event to local coordinates. | |
| 177 IntPoint mousePosition = scrollbar->convertFromContainingWindow(evt.position ()); | |
| 178 mousePosition.move(scrollbar->x(), scrollbar->y()); | |
| 179 | |
| 180 // We should snap iff the event is outside our calculated rect. | |
| 181 return !rect.contains(mousePosition); | |
| 149 } | 182 } |
| 150 | 183 |
| 151 IntSize ScrollbarThemeGtkOrAura::buttonSize(ScrollbarThemeClient* scrollbar) | 184 IntSize ScrollbarThemeGtkOrAura::buttonSize(ScrollbarThemeClient* scrollbar) |
| 152 { | 185 { |
| 153 if (scrollbar->orientation() == VerticalScrollbar) { | 186 if (scrollbar->orientation() == VerticalScrollbar) { |
| 154 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink: :WebThemeEngine::PartScrollbarUpArrow); | 187 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink: :WebThemeEngine::PartScrollbarUpArrow); |
| 155 return IntSize(size.width(), scrollbar->height() < 2 * size.height() ? s crollbar->height() / 2 : size.height()); | 188 return IntSize(size.width(), scrollbar->height() < 2 * size.height() ? s crollbar->height() / 2 : size.height()); |
| 156 } | 189 } |
| 157 | 190 |
| 158 // HorizontalScrollbar | 191 // HorizontalScrollbar |
| 159 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web ThemeEngine::PartScrollbarLeftArrow); | 192 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web ThemeEngine::PartScrollbarLeftArrow); |
| 160 return IntSize(scrollbar->width() < 2 * size.width() ? scrollbar->width() / 2 : size.width(), size.height()); | 193 return IntSize(scrollbar->width() < 2 * size.width() ? scrollbar->width() / 2 : size.width(), size.height()); |
| 161 } | 194 } |
| 162 | 195 |
| 163 int ScrollbarThemeGtkOrAura::minimumThumbLength(ScrollbarThemeClient* scrollbar) | 196 int ScrollbarThemeGtkOrAura::minimumThumbLength(ScrollbarThemeClient* scrollbar) |
| 164 { | 197 { |
| 165 if (scrollbar->orientation() == VerticalScrollbar) { | 198 if (scrollbar->orientation() == VerticalScrollbar) { |
| 166 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink: :WebThemeEngine::PartScrollbarVerticalThumb); | 199 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink: :WebThemeEngine::PartScrollbarVerticalThumb); |
| 167 return size.height(); | 200 return size.height(); |
| 168 } | 201 } |
| 169 | 202 |
| 170 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web ThemeEngine::PartScrollbarHorizontalThumb); | 203 IntSize size = blink::Platform::current()->themeEngine()->getSize(blink::Web ThemeEngine::PartScrollbarHorizontalThumb); |
| 171 return size.width(); | 204 return size.width(); |
| 172 } | 205 } |
| 173 | 206 |
| 174 } // namespace WebCore | 207 } // namespace WebCore |
| OLD | NEW |