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

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

Issue 2650403006: Remove PlatformMouseEvent and use WebMouseEvent instead (Closed)
Patch Set: Fix nits Created 3 years, 10 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
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
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "platform/scroll/Scrollbar.h" 26 #include "platform/scroll/Scrollbar.h"
27 27
28 #include <algorithm> 28 #include <algorithm>
29 #include "platform/HostWindow.h" 29 #include "platform/HostWindow.h"
30 #include "platform/PlatformMouseEvent.h"
31 #include "platform/geometry/FloatRect.h" 30 #include "platform/geometry/FloatRect.h"
32 #include "platform/graphics/paint/CullRect.h" 31 #include "platform/graphics/paint/CullRect.h"
33 #include "platform/scroll/ScrollAnimatorBase.h" 32 #include "platform/scroll/ScrollAnimatorBase.h"
34 #include "platform/scroll/ScrollableArea.h" 33 #include "platform/scroll/ScrollableArea.h"
35 #include "platform/scroll/ScrollbarTheme.h" 34 #include "platform/scroll/ScrollbarTheme.h"
36 #include "public/platform/WebGestureEvent.h" 35 #include "public/platform/WebGestureEvent.h"
36 #include "public/platform/WebMouseEvent.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, 40 Scrollbar::Scrollbar(ScrollableArea* scrollableArea,
41 ScrollbarOrientation orientation, 41 ScrollbarOrientation orientation,
42 ScrollbarControlSize controlSize, 42 ScrollbarControlSize controlSize,
43 HostWindow* hostWindow, 43 HostWindow* hostWindow,
44 ScrollbarTheme* theme) 44 ScrollbarTheme* theme)
45 : m_scrollableArea(scrollableArea), 45 : m_scrollableArea(scrollableArea),
46 m_orientation(orientation), 46 m_orientation(orientation),
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 m_pressedPos = 0; 411 m_pressedPos = 0;
412 setPressedPart(NoPart); 412 setPressedPart(NoPart);
413 return false; 413 return false;
414 } 414 }
415 default: 415 default:
416 // By default, we assume that gestures don't deselect the scrollbar. 416 // By default, we assume that gestures don't deselect the scrollbar.
417 return true; 417 return true;
418 } 418 }
419 } 419 }
420 420
421 void Scrollbar::mouseMoved(const PlatformMouseEvent& evt) { 421 void Scrollbar::mouseMoved(const WebMouseEvent& evt) {
422 IntPoint position = flooredIntPoint(evt.positionInRootFrame());
422 if (m_pressedPart == ThumbPart) { 423 if (m_pressedPart == ThumbPart) {
423 if (theme().shouldSnapBackToDragOrigin(*this, evt)) { 424 if (theme().shouldSnapBackToDragOrigin(*this, evt)) {
424 if (m_scrollableArea) { 425 if (m_scrollableArea) {
425 m_scrollableArea->setScrollOffsetSingleAxis( 426 m_scrollableArea->setScrollOffsetSingleAxis(
426 m_orientation, 427 m_orientation,
427 m_dragOrigin + m_scrollableArea->minimumScrollOffset(m_orientation), 428 m_dragOrigin + m_scrollableArea->minimumScrollOffset(m_orientation),
428 UserScroll); 429 UserScroll);
429 } 430 }
430 } else { 431 } else {
431 moveThumb(m_orientation == HorizontalScrollbar 432 moveThumb(m_orientation == HorizontalScrollbar
432 ? convertFromRootFrame(evt.position()).x() 433 ? convertFromRootFrame(position).x()
433 : convertFromRootFrame(evt.position()).y(), 434 : convertFromRootFrame(position).y(),
434 theme().shouldDragDocumentInsteadOfThumb(*this, evt)); 435 theme().shouldDragDocumentInsteadOfThumb(*this, evt));
435 } 436 }
436 return; 437 return;
437 } 438 }
438 439
439 if (m_pressedPart != NoPart) 440 if (m_pressedPart != NoPart) {
440 m_pressedPos = orientation() == HorizontalScrollbar 441 m_pressedPos = orientation() == HorizontalScrollbar
441 ? convertFromRootFrame(evt.position()).x() 442 ? convertFromRootFrame(position).x()
442 : convertFromRootFrame(evt.position()).y(); 443 : convertFromRootFrame(position).y();
444 }
443 445
444 ScrollbarPart part = theme().hitTest(*this, evt.position()); 446 ScrollbarPart part = theme().hitTest(*this, position);
445 if (part != m_hoveredPart) { 447 if (part != m_hoveredPart) {
446 if (m_pressedPart != NoPart) { 448 if (m_pressedPart != NoPart) {
447 if (part == m_pressedPart) { 449 if (part == m_pressedPart) {
448 // The mouse is moving back over the pressed part. We 450 // The mouse is moving back over the pressed part. We
449 // need to start up the timer action again. 451 // need to start up the timer action again.
450 startTimerIfNeeded(theme().autoscrollTimerDelay()); 452 startTimerIfNeeded(theme().autoscrollTimerDelay());
451 } else if (m_hoveredPart == m_pressedPart) { 453 } else if (m_hoveredPart == m_pressedPart) {
452 // The mouse is leaving the pressed part. Kill our timer 454 // The mouse is leaving the pressed part. Kill our timer
453 // if needed. 455 // if needed.
454 stopTimerIfNeeded(); 456 stopTimerIfNeeded();
(...skipping 10 matching lines...) Expand all
465 if (m_scrollableArea) 467 if (m_scrollableArea)
466 m_scrollableArea->mouseEnteredScrollbar(*this); 468 m_scrollableArea->mouseEnteredScrollbar(*this);
467 } 469 }
468 470
469 void Scrollbar::mouseExited() { 471 void Scrollbar::mouseExited() {
470 if (m_scrollableArea) 472 if (m_scrollableArea)
471 m_scrollableArea->mouseExitedScrollbar(*this); 473 m_scrollableArea->mouseExitedScrollbar(*this);
472 setHoveredPart(NoPart); 474 setHoveredPart(NoPart);
473 } 475 }
474 476
475 void Scrollbar::mouseUp(const PlatformMouseEvent& mouseEvent) { 477 void Scrollbar::mouseUp(const WebMouseEvent& mouseEvent) {
476 bool isCaptured = m_pressedPart == ThumbPart; 478 bool isCaptured = m_pressedPart == ThumbPart;
477 setPressedPart(NoPart); 479 setPressedPart(NoPart);
478 m_pressedPos = 0; 480 m_pressedPos = 0;
479 m_draggingDocument = false; 481 m_draggingDocument = false;
480 stopTimerIfNeeded(); 482 stopTimerIfNeeded();
481 483
482 if (m_scrollableArea) { 484 if (m_scrollableArea) {
483 if (isCaptured) 485 if (isCaptured)
484 m_scrollableArea->mouseReleasedScrollbar(); 486 m_scrollableArea->mouseReleasedScrollbar();
485 487
486 ScrollbarPart part = theme().hitTest(*this, mouseEvent.position()); 488 ScrollbarPart part = theme().hitTest(
489 *this, flooredIntPoint(mouseEvent.positionInRootFrame()));
487 if (part == NoPart) { 490 if (part == NoPart) {
488 setHoveredPart(NoPart); 491 setHoveredPart(NoPart);
489 m_scrollableArea->mouseExitedScrollbar(*this); 492 m_scrollableArea->mouseExitedScrollbar(*this);
490 } 493 }
491 } 494 }
492 } 495 }
493 496
494 void Scrollbar::mouseDown(const PlatformMouseEvent& evt) { 497 void Scrollbar::mouseDown(const WebMouseEvent& evt) {
495 // Early exit for right click 498 // Early exit for right click
496 if (evt.pointerProperties().button == WebPointerProperties::Button::Right) 499 if (evt.button == WebPointerProperties::Button::Right)
497 return; 500 return;
498 501
499 setPressedPart(theme().hitTest(*this, evt.position())); 502 IntPoint position = flooredIntPoint(evt.positionInRootFrame());
503 setPressedPart(theme().hitTest(*this, position));
500 int pressedPos = orientation() == HorizontalScrollbar 504 int pressedPos = orientation() == HorizontalScrollbar
501 ? convertFromRootFrame(evt.position()).x() 505 ? convertFromRootFrame(position).x()
502 : convertFromRootFrame(evt.position()).y(); 506 : convertFromRootFrame(position).y();
503 507
504 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) && 508 if ((m_pressedPart == BackTrackPart || m_pressedPart == ForwardTrackPart) &&
505 theme().shouldCenterOnThumb(*this, evt)) { 509 theme().shouldCenterOnThumb(*this, evt)) {
506 setHoveredPart(ThumbPart); 510 setHoveredPart(ThumbPart);
507 setPressedPart(ThumbPart); 511 setPressedPart(ThumbPart);
508 m_dragOrigin = m_currentPos; 512 m_dragOrigin = m_currentPos;
509 int thumbLen = theme().thumbLength(*this); 513 int thumbLen = theme().thumbLength(*this);
510 int desiredPos = pressedPos; 514 int desiredPos = pressedPos;
511 // Set the pressed position to the middle of the thumb so that when we do 515 // Set the pressed position to the middle of the thumb so that when we do
512 // the move, the delta will be from the current pixel position of the thumb 516 // the move, the delta will be from the current pixel position of the thumb
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 invalidParts = AllParts; 639 invalidParts = AllParts;
636 if (invalidParts & ~ThumbPart) 640 if (invalidParts & ~ThumbPart)
637 m_trackNeedsRepaint = true; 641 m_trackNeedsRepaint = true;
638 if (invalidParts & ThumbPart) 642 if (invalidParts & ThumbPart)
639 m_thumbNeedsRepaint = true; 643 m_thumbNeedsRepaint = true;
640 if (m_scrollableArea) 644 if (m_scrollableArea)
641 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); 645 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation());
642 } 646 }
643 647
644 } // namespace blink 648 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/Scrollbar.h ('k') | third_party/WebKit/Source/platform/scroll/ScrollbarTheme.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698