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

Side by Side Diff: Source/platform/scroll/Scrollbar.cpp

Issue 1147283002: Add ScrollDirectionPhysical enum in Scroll types. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed a conflict on EventHandler Created 5 years, 7 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 | « Source/platform/scroll/Scrollbar.h ('k') | Source/web/WebFrameWidgetImpl.cpp » ('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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return; 219 return;
220 220
221 // Handle the track. 221 // Handle the track.
222 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) { 222 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
223 theme()->invalidatePart(this, m_pressedPart); 223 theme()->invalidatePart(this, m_pressedPart);
224 setHoveredPart(ThumbPart); 224 setHoveredPart(ThumbPart);
225 return; 225 return;
226 } 226 }
227 227
228 // Handle the arrows and track. 228 // Handle the arrows and track.
229 if (m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirection( ), pressedPartScrollGranularity())) 229 if (m_scrollableArea && m_scrollableArea->scroll(pressedPartScrollDirectionP hysical(), pressedPartScrollGranularity()))
230 startTimerIfNeeded(delay); 230 startTimerIfNeeded(delay);
231 } 231 }
232 232
233 void Scrollbar::startTimerIfNeeded(double delay) 233 void Scrollbar::startTimerIfNeeded(double delay)
234 { 234 {
235 // Don't do anything for the thumb. 235 // Don't do anything for the thumb.
236 if (m_pressedPart == ThumbPart) 236 if (m_pressedPart == ThumbPart)
237 return; 237 return;
238 238
239 // Handle the track. We halt track scrolling once the thumb is level 239 // Handle the track. We halt track scrolling once the thumb is level
240 // with us. 240 // with us.
241 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) { 241 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && thumbUnderMouse(this)) {
242 theme()->invalidatePart(this, m_pressedPart); 242 theme()->invalidatePart(this, m_pressedPart);
243 setHoveredPart(ThumbPart); 243 setHoveredPart(ThumbPart);
244 return; 244 return;
245 } 245 }
246 246
247 // We can't scroll if we've hit the beginning or end. 247 // We can't scroll if we've hit the beginning or end.
248 ScrollDirection dir = pressedPartScrollDirection(); 248 ScrollDirectionPhysical dir = pressedPartScrollDirectionPhysical();
249 if (dir == ScrollUp || dir == ScrollLeft) { 249 if (dir == ScrollUp || dir == ScrollLeft) {
250 if (m_currentPos == 0) 250 if (m_currentPos == 0)
251 return; 251 return;
252 } else { 252 } else {
253 if (m_currentPos == maximum()) 253 if (m_currentPos == maximum())
254 return; 254 return;
255 } 255 }
256 256
257 m_scrollTimer.startOneShot(delay, FROM_HERE); 257 m_scrollTimer.startOneShot(delay, FROM_HERE);
258 } 258 }
259 259
260 void Scrollbar::stopTimerIfNeeded() 260 void Scrollbar::stopTimerIfNeeded()
261 { 261 {
262 if (m_scrollTimer.isActive()) 262 if (m_scrollTimer.isActive())
263 m_scrollTimer.stop(); 263 m_scrollTimer.stop();
264 } 264 }
265 265
266 ScrollDirection Scrollbar::pressedPartScrollDirection() 266 ScrollDirectionPhysical Scrollbar::pressedPartScrollDirectionPhysical()
267 { 267 {
268 if (m_orientation == HorizontalScrollbar) { 268 if (m_orientation == HorizontalScrollbar) {
269 if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonE ndPart || m_pressedPart == BackTrackPart) 269 if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonE ndPart || m_pressedPart == BackTrackPart)
270 return ScrollLeft; 270 return ScrollLeft;
271 return ScrollRight; 271 return ScrollRight;
272 } else { 272 } else {
273 if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonE ndPart || m_pressedPart == BackTrackPart) 273 if (m_pressedPart == BackButtonStartPart || m_pressedPart == BackButtonE ndPart || m_pressedPart == BackTrackPart)
274 return ScrollUp; 274 return ScrollUp;
275 return ScrollDown; 275 return ScrollDown;
276 } 276 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return true; 370 return true;
371 case PlatformEvent::GestureScrollEnd: 371 case PlatformEvent::GestureScrollEnd:
372 case PlatformEvent::GestureLongPress: 372 case PlatformEvent::GestureLongPress:
373 case PlatformEvent::GestureFlingStart: 373 case PlatformEvent::GestureFlingStart:
374 m_scrollPos = 0; 374 m_scrollPos = 0;
375 m_pressedPos = 0; 375 m_pressedPos = 0;
376 setPressedPart(NoPart); 376 setPressedPart(NoPart);
377 return false; 377 return false;
378 case PlatformEvent::GestureTap: { 378 case PlatformEvent::GestureTap: {
379 if (m_pressedPart != ThumbPart && m_pressedPart != NoPart && m_scrollabl eArea 379 if (m_pressedPart != ThumbPart && m_pressedPart != NoPart && m_scrollabl eArea
380 && m_scrollableArea->scroll(pressedPartScrollDirection(), pressedPar tScrollGranularity())) { 380 && m_scrollableArea->scroll(pressedPartScrollDirectionPhysical(), pr essedPartScrollGranularity())) {
381 return true; 381 return true;
382 } 382 }
383 m_scrollPos = 0; 383 m_scrollPos = 0;
384 m_pressedPos = 0; 384 m_pressedPos = 0;
385 setPressedPart(NoPart); 385 setPressedPart(NoPart);
386 return false; 386 return false;
387 } 387 }
388 default: 388 default:
389 // By default, we assume that gestures don't deselect the scrollbar. 389 // By default, we assume that gestures don't deselect the scrollbar.
390 return true; 390 return true;
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 if (!m_scrollableArea) 560 if (!m_scrollableArea)
561 return 0; 561 return 0;
562 562
563 if (m_orientation == HorizontalScrollbar) 563 if (m_orientation == HorizontalScrollbar)
564 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x(); 564 return m_scrollableArea->scrollPosition().x() - m_scrollableArea->minimu mScrollPosition().x();
565 565
566 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y(); 566 return m_scrollableArea->scrollPosition().y() - m_scrollableArea->minimumScr ollPosition().y();
567 } 567 }
568 568
569 } // namespace blink 569 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/scroll/Scrollbar.h ('k') | Source/web/WebFrameWidgetImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698