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

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

Issue 684353002: Remove more stuff from Widget. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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) 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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part. 277 else if (m_hoveredPart != NoPart) // When we no longer have a pressed part, we can start drawing a hovered state on the hovered part.
278 invalidatePart(m_hoveredPart); 278 invalidatePart(m_hoveredPart);
279 } 279 }
280 280
281 bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt) 281 bool Scrollbar::gestureEvent(const PlatformGestureEvent& evt)
282 { 282 {
283 switch (evt.type()) { 283 switch (evt.type()) {
284 case PlatformEvent::GestureTapDown: 284 case PlatformEvent::GestureTapDown:
285 // FIXME(sky): Is setting the pressed part needed since we only have ove rlay scrollbars? 285 // FIXME(sky): Is setting the pressed part needed since we only have ove rlay scrollbars?
286 setPressedPart(NoPart); 286 setPressedPart(NoPart);
287 m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContain ingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y(); 287 m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContain ingView(evt.position()).x() : convertFromContainingView(evt.position()).y();
288 return true; 288 return true;
289 case PlatformEvent::GestureTapDownCancel: 289 case PlatformEvent::GestureTapDownCancel:
290 case PlatformEvent::GestureScrollBegin: 290 case PlatformEvent::GestureScrollBegin:
291 if (m_pressedPart != ThumbPart) 291 if (m_pressedPart != ThumbPart)
292 return false; 292 return false;
293 m_scrollPos = m_pressedPos; 293 m_scrollPos = m_pressedPos;
294 return true; 294 return true;
295 case PlatformEvent::GestureScrollUpdate: 295 case PlatformEvent::GestureScrollUpdate:
296 case PlatformEvent::GestureScrollUpdateWithoutPropagation: 296 case PlatformEvent::GestureScrollUpdateWithoutPropagation:
297 if (m_pressedPart != ThumbPart) 297 if (m_pressedPart != ThumbPart)
(...skipping 25 matching lines...) Expand all
323 } 323 }
324 324
325 void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) 325 void Scrollbar::mouseMoved(const PlatformMouseEvent& evt)
326 { 326 {
327 if (m_pressedPart == ThumbPart) { 327 if (m_pressedPart == ThumbPart) {
328 if (shouldSnapBackToDragOrigin(evt)) { 328 if (shouldSnapBackToDragOrigin(evt)) {
329 if (m_scrollableArea) 329 if (m_scrollableArea)
330 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, m_dragOrigin + m_scrollableArea->minimumScrollPosition(m_orientation)); 330 m_scrollableArea->scrollToOffsetWithoutAnimation(m_orientation, m_dragOrigin + m_scrollableArea->minimumScrollPosition(m_orientation));
331 } else { 331 } else {
332 moveThumb(m_orientation == HorizontalScrollbar ? 332 moveThumb(m_orientation == HorizontalScrollbar ?
333 convertFromContainingWindow(evt.position()).x() : 333 convertFromContainingView(evt.position()).x() :
334 convertFromContainingWindow(evt.position()).y()); 334 convertFromContainingView(evt.position()).y());
335 } 335 }
336 return; 336 return;
337 } 337 }
338 338
339 if (m_pressedPart != NoPart) 339 if (m_pressedPart != NoPart)
340 m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContain ingWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y(); 340 m_pressedPos = orientation() == HorizontalScrollbar ? convertFromContain ingView(evt.position()).x() : convertFromContainingView(evt.position()).y();
341 341
342 // FIXME(sky): Cleanup this code now that part is always NoPart. 342 // FIXME(sky): Cleanup this code now that part is always NoPart.
343 ScrollbarPart part = NoPart; 343 ScrollbarPart part = NoPart;
344 if (part != m_hoveredPart) { 344 if (part != m_hoveredPart) {
345 if (m_pressedPart != NoPart) { 345 if (m_pressedPart != NoPart) {
346 if (part == m_pressedPart) { 346 if (part == m_pressedPart) {
347 // The mouse is moving back over the pressed part. We 347 // The mouse is moving back over the pressed part. We
348 // need to start up the timer action again. 348 // need to start up the timer action again.
349 startTimerIfNeeded(autoscrollTimerDelay()); 349 startTimerIfNeeded(autoscrollTimerDelay());
350 invalidatePart(m_pressedPart); 350 invalidatePart(m_pressedPart);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 390
391 void Scrollbar::mouseDown(const PlatformMouseEvent& evt) 391 void Scrollbar::mouseDown(const PlatformMouseEvent& evt)
392 { 392 {
393 // Early exit for right click 393 // Early exit for right click
394 if (evt.button() == RightButton) 394 if (evt.button() == RightButton)
395 return; 395 return;
396 396
397 // FIXME(sky): Do we still need setPressedPart now that we only set it to No Part? 397 // FIXME(sky): Do we still need setPressedPart now that we only set it to No Part?
398 setPressedPart(NoPart); 398 setPressedPart(NoPart);
399 int pressedPos = orientation() == HorizontalScrollbar ? convertFromContainin gWindow(evt.position()).x() : convertFromContainingWindow(evt.position()).y(); 399 int pressedPos = orientation() == HorizontalScrollbar ? convertFromContainin gView(evt.position()).x() : convertFromContainingView(evt.position()).y();
400 400
401 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && shouldCenterOnThumb(evt)) { 401 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && shouldCenterOnThumb(evt)) {
402 setHoveredPart(ThumbPart); 402 setHoveredPart(ThumbPart);
403 setPressedPart(ThumbPart); 403 setPressedPart(ThumbPart);
404 m_dragOrigin = m_currentPos; 404 m_dragOrigin = m_currentPos;
405 int thumbLen = thumbLength(); 405 int thumbLen = thumbLength();
406 int desiredPos = pressedPos; 406 int desiredPos = pressedPos;
407 // Set the pressed position to the middle of the thumb so that when we d o the move, the delta 407 // Set the pressed position to the middle of the thumb so that when we d o the move, the delta
408 // will be from the current pixel position of the thumb to the new desir ed position for the thumb. 408 // will be from the current pixel position of the thumb to the new desir ed position for the thumb.
409 m_pressedPos = trackPosition() + thumbPosition() + thumbLen / 2; 409 m_pressedPos = trackPosition() + thumbPosition() + thumbLen / 2;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 blink::Platform::current()->themeEngine()->paint(context->canvas(), blink::W ebThemeEngine::PartScrollbarCorner, blink::WebThemeEngine::StateNormal, blink::W ebRect(cornerRect), 0); 520 blink::Platform::current()->themeEngine()->paint(context->canvas(), blink::W ebThemeEngine::PartScrollbarCorner, blink::WebThemeEngine::StateNormal, blink::W ebRect(cornerRect), 0);
521 } 521 }
522 522
523 bool Scrollbar::shouldCenterOnThumb(const PlatformMouseEvent& evt) 523 bool Scrollbar::shouldCenterOnThumb(const PlatformMouseEvent& evt)
524 { 524 {
525 return blink::Platform::current()->scrollbarBehavior()->shouldCenterOnThumb( static_cast<blink::WebScrollbarBehavior::Button>(evt.button()), evt.shiftKey(), evt.altKey()); 525 return blink::Platform::current()->scrollbarBehavior()->shouldCenterOnThumb( static_cast<blink::WebScrollbarBehavior::Button>(evt.button()), evt.shiftKey(), evt.altKey());
526 } 526 }
527 527
528 bool Scrollbar::shouldSnapBackToDragOrigin(const PlatformMouseEvent& evt) 528 bool Scrollbar::shouldSnapBackToDragOrigin(const PlatformMouseEvent& evt)
529 { 529 {
530 IntPoint mousePosition = convertFromContainingWindow(evt.position()); 530 IntPoint mousePosition = convertFromContainingView(evt.position());
531 mousePosition.move(x(), y()); 531 mousePosition.move(x(), y());
532 return blink::Platform::current()->scrollbarBehavior()->shouldSnapBackToDrag Origin(mousePosition, trackRect(), orientation() == HorizontalScrollbar); 532 return blink::Platform::current()->scrollbarBehavior()->shouldSnapBackToDrag Origin(mousePosition, trackRect(), orientation() == HorizontalScrollbar);
533 } 533 }
534 534
535 int Scrollbar::thumbPosition() 535 int Scrollbar::thumbPosition()
536 { 536 {
537 if (!totalSize()) 537 if (!totalSize())
538 return 0; 538 return 0;
539 539
540 int trackLen = trackLength(); 540 int trackLen = trackLength();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 thumbRect.setWidth(thumbRect.width() - kScrollbarMargin); 624 thumbRect.setWidth(thumbRect.width() - kScrollbarMargin);
625 if (isLeftSideVerticalScrollbar()) 625 if (isLeftSideVerticalScrollbar())
626 thumbRect.setX(thumbRect.x() + kScrollbarMargin); 626 thumbRect.setX(thumbRect.x() + kScrollbarMargin);
627 } 627 }
628 628
629 DEFINE_STATIC_LOCAL(Color, color, (128, 128, 128, 128)); 629 DEFINE_STATIC_LOCAL(Color, color, (128, 128, 128, 128));
630 context->fillRect(thumbRect, color); 630 context->fillRect(thumbRect, color);
631 } 631 }
632 632
633 } // namespace blink 633 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698