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

Side by Side Diff: sky/engine/platform/scroll/Scrollbar.cpp

Issue 873963003: Remove more mouse-specific code (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Build fixes Created 5 years, 11 months 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
« no previous file with comments | « sky/engine/platform/scroll/Scrollbar.h ('k') | sky/engine/public/web/WebViewClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 splitTrack(trackRect(), startTrackRect, thumbRect, endTrackRect); 123 splitTrack(trackRect(), startTrackRect, thumbRect, endTrackRect);
124 if (damageRect.intersects(thumbRect)) 124 if (damageRect.intersects(thumbRect))
125 paintThumb(context, thumbRect); 125 paintThumb(context, thumbRect);
126 } 126 }
127 127
128 void Scrollbar::autoscrollTimerFired(Timer<Scrollbar>*) 128 void Scrollbar::autoscrollTimerFired(Timer<Scrollbar>*)
129 { 129 {
130 autoscrollPressedPart(autoscrollTimerDelay()); 130 autoscrollPressedPart(autoscrollTimerDelay());
131 } 131 }
132 132
133 static bool thumbUnderMouse(Scrollbar* scrollbar)
134 {
135 int thumbPos = scrollbar->trackPosition() + scrollbar->thumbPosition();
136 int thumbLength = scrollbar->thumbLength();
137 return scrollbar->pressedPos() >= thumbPos && scrollbar->pressedPos() < thum bPos + thumbLength;
138 }
139
140 void Scrollbar::autoscrollPressedPart(double delay) 133 void Scrollbar::autoscrollPressedPart(double delay)
141 { 134 {
142 // Don't do anything for the thumb or if nothing was pressed. 135 // Don't do anything for the thumb or if nothing was pressed.
143 if (m_pressedPart == ThumbPart || m_pressedPart == NoPart) 136 if (m_pressedPart == ThumbPart || m_pressedPart == NoPart)
144 return; 137 return;
145 138
146 // Handle the track.
147 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
148 setHoveredPart(ThumbPart);
149 return;
150 }
151
152 // Handle the arrows and track. 139 // Handle the arrows and track.
153 if (m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection( ), pressedPartScrollGranularity())) 140 if (m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection( ), pressedPartScrollGranularity()))
154 startTimerIfNeeded(delay); 141 startTimerIfNeeded(delay);
155 } 142 }
156 143
157 void Scrollbar::startTimerIfNeeded(double delay) 144 void Scrollbar::startTimerIfNeeded(double delay)
158 { 145 {
159 // Don't do anything for the thumb. 146 // Don't do anything for the thumb.
160 if (m_pressedPart == ThumbPart) 147 if (m_pressedPart == ThumbPart)
161 return; 148 return;
162 149
163 // Handle the track. We halt track scrolling once the thumb is level
164 // with us.
165 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
166 setHoveredPart(ThumbPart);
167 return;
168 }
169
170 // We can't scroll if we've hit the beginning or end. 150 // We can't scroll if we've hit the beginning or end.
171 ScrollDirection dir = pressedPartScrollDirection(); 151 ScrollDirection dir = pressedPartScrollDirection();
172 if (dir == ScrollUp || dir == ScrollLeft) { 152 if (dir == ScrollUp || dir == ScrollLeft) {
173 if (m_currentPos == 0) 153 if (m_currentPos == 0)
174 return; 154 return;
175 } else { 155 } else {
176 if (m_currentPos == maximum()) 156 if (m_currentPos == maximum())
177 return; 157 return;
178 } 158 }
179 159
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if (part == m_hoveredPart) 214 if (part == m_hoveredPart)
235 return; 215 return;
236 m_hoveredPart = part; 216 m_hoveredPart = part;
237 } 217 }
238 218
239 void Scrollbar::setPressedPart(ScrollbarPart part) 219 void Scrollbar::setPressedPart(ScrollbarPart part)
240 { 220 {
241 m_pressedPart = part; 221 m_pressedPart = part;
242 } 222 }
243 223
244 void Scrollbar::mouseEntered()
245 {
246 if (m_scrollableArea)
247 m_scrollableArea->mouseEnteredScrollbar(this);
248 }
249
250 void Scrollbar::mouseExited()
251 {
252 if (m_scrollableArea)
253 m_scrollableArea->mouseExitedScrollbar(this);
254 setHoveredPart(NoPart);
255 }
256
257 bool Scrollbar::isOverlayScrollbar() const 224 bool Scrollbar::isOverlayScrollbar() const
258 { 225 {
259 // FIXME(sky): Remove 226 // FIXME(sky): Remove
260 return true; 227 return true;
261 } 228 }
262 229
263 bool Scrollbar::shouldParticipateInHitTesting() 230 bool Scrollbar::shouldParticipateInHitTesting()
264 { 231 {
265 // Non-overlay scrollbars should always participate in hit testing. 232 // Non-overlay scrollbars should always participate in hit testing.
266 if (!isOverlayScrollbar()) 233 if (!isOverlayScrollbar())
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 thumbRect.setWidth(thumbRect.width() - kScrollbarMargin); 375 thumbRect.setWidth(thumbRect.width() - kScrollbarMargin);
409 if (isLeftSideVerticalScrollbar()) 376 if (isLeftSideVerticalScrollbar())
410 thumbRect.setX(thumbRect.x() + kScrollbarMargin); 377 thumbRect.setX(thumbRect.x() + kScrollbarMargin);
411 } 378 }
412 379
413 DEFINE_STATIC_LOCAL(Color, color, (128, 128, 128, 128)); 380 DEFINE_STATIC_LOCAL(Color, color, (128, 128, 128, 128));
414 context->fillRect(thumbRect, color); 381 context->fillRect(thumbRect, color);
415 } 382 }
416 383
417 } // namespace blink 384 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/scroll/Scrollbar.h ('k') | sky/engine/public/web/WebViewClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698