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

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

Issue 2855523002: Deleted Widget/FrameViewBase (Closed)
Patch Set: Keep FrameViewBase.h file until dependent CL is landed. Created 3 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
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/FrameViewBase.h"
30 #include "platform/PlatformChromeClient.h" 29 #include "platform/PlatformChromeClient.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"
34 #include "platform/scroll/ScrollbarParent.h"
35 #include "platform/scroll/ScrollbarTheme.h" 35 #include "platform/scroll/ScrollbarTheme.h"
36 #include "public/platform/WebGestureEvent.h" 36 #include "public/platform/WebGestureEvent.h"
37 #include "public/platform/WebMouseEvent.h" 37 #include "public/platform/WebMouseEvent.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 Scrollbar::Scrollbar(ScrollableArea* scrollable_area, 41 Scrollbar::Scrollbar(ScrollableArea* scrollable_area,
42 ScrollbarOrientation orientation, 42 ScrollbarOrientation orientation,
43 ScrollbarControlSize control_size, 43 ScrollbarControlSize control_size,
44 PlatformChromeClient* chrome_client, 44 PlatformChromeClient* chrome_client,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 330 }
331 331
332 bool Scrollbar::GestureEvent(const WebGestureEvent& evt, 332 bool Scrollbar::GestureEvent(const WebGestureEvent& evt,
333 bool* should_update_capture) { 333 bool* should_update_capture) {
334 DCHECK(should_update_capture); 334 DCHECK(should_update_capture);
335 switch (evt.GetType()) { 335 switch (evt.GetType()) {
336 case WebInputEvent::kGestureTapDown: { 336 case WebInputEvent::kGestureTapDown: {
337 IntPoint position = FlooredIntPoint(evt.PositionInRootFrame()); 337 IntPoint position = FlooredIntPoint(evt.PositionInRootFrame());
338 SetPressedPart(GetTheme().HitTest(*this, position)); 338 SetPressedPart(GetTheme().HitTest(*this, position));
339 pressed_pos_ = Orientation() == kHorizontalScrollbar 339 pressed_pos_ = Orientation() == kHorizontalScrollbar
340 ? ConvertFromRootFrame(position).X() 340 ? ConvertPointFromRootFrame(position).X()
341 : ConvertFromRootFrame(position).Y(); 341 : ConvertPointFromRootFrame(position).Y();
342 *should_update_capture = true; 342 *should_update_capture = true;
343 return true; 343 return true;
344 } 344 }
345 case WebInputEvent::kGestureTapCancel: 345 case WebInputEvent::kGestureTapCancel:
346 if (pressed_part_ != kThumbPart) 346 if (pressed_part_ != kThumbPart)
347 return false; 347 return false;
348 scroll_pos_ = pressed_pos_; 348 scroll_pos_ = pressed_pos_;
349 return true; 349 return true;
350 case WebInputEvent::kGestureScrollBegin: 350 case WebInputEvent::kGestureScrollBegin:
351 switch (evt.source_device) { 351 switch (evt.source_device) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (pressed_part_ == kThumbPart) { 426 if (pressed_part_ == kThumbPart) {
427 if (GetTheme().ShouldSnapBackToDragOrigin(*this, evt)) { 427 if (GetTheme().ShouldSnapBackToDragOrigin(*this, evt)) {
428 if (scrollable_area_) { 428 if (scrollable_area_) {
429 scrollable_area_->SetScrollOffsetSingleAxis( 429 scrollable_area_->SetScrollOffsetSingleAxis(
430 orientation_, 430 orientation_,
431 drag_origin_ + scrollable_area_->MinimumScrollOffset(orientation_), 431 drag_origin_ + scrollable_area_->MinimumScrollOffset(orientation_),
432 kUserScroll); 432 kUserScroll);
433 } 433 }
434 } else { 434 } else {
435 MoveThumb(orientation_ == kHorizontalScrollbar 435 MoveThumb(orientation_ == kHorizontalScrollbar
436 ? ConvertFromRootFrame(position).X() 436 ? ConvertPointFromRootFrame(position).X()
437 : ConvertFromRootFrame(position).Y(), 437 : ConvertPointFromRootFrame(position).Y(),
438 GetTheme().ShouldDragDocumentInsteadOfThumb(*this, evt)); 438 GetTheme().ShouldDragDocumentInsteadOfThumb(*this, evt));
439 } 439 }
440 return; 440 return;
441 } 441 }
442 442
443 if (pressed_part_ != kNoPart) { 443 if (pressed_part_ != kNoPart) {
444 pressed_pos_ = Orientation() == kHorizontalScrollbar 444 pressed_pos_ = Orientation() == kHorizontalScrollbar
445 ? ConvertFromRootFrame(position).X() 445 ? ConvertPointFromRootFrame(position).X()
446 : ConvertFromRootFrame(position).Y(); 446 : ConvertPointFromRootFrame(position).Y();
447 } 447 }
448 448
449 ScrollbarPart part = GetTheme().HitTest(*this, position); 449 ScrollbarPart part = GetTheme().HitTest(*this, position);
450 if (part != hovered_part_) { 450 if (part != hovered_part_) {
451 if (pressed_part_ != kNoPart) { 451 if (pressed_part_ != kNoPart) {
452 if (part == pressed_part_) { 452 if (part == pressed_part_) {
453 // The mouse is moving back over the pressed part. We 453 // The mouse is moving back over the pressed part. We
454 // need to start up the timer action again. 454 // need to start up the timer action again.
455 StartTimerIfNeeded(GetTheme().AutoscrollTimerDelay()); 455 StartTimerIfNeeded(GetTheme().AutoscrollTimerDelay());
456 } else if (hovered_part_ == pressed_part_) { 456 } else if (hovered_part_ == pressed_part_) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 499
500 void Scrollbar::MouseDown(const WebMouseEvent& evt) { 500 void Scrollbar::MouseDown(const WebMouseEvent& evt) {
501 // Early exit for right click 501 // Early exit for right click
502 if (evt.button == WebPointerProperties::Button::kRight) 502 if (evt.button == WebPointerProperties::Button::kRight)
503 return; 503 return;
504 504
505 IntPoint position = FlooredIntPoint(evt.PositionInRootFrame()); 505 IntPoint position = FlooredIntPoint(evt.PositionInRootFrame());
506 SetPressedPart(GetTheme().HitTest(*this, position)); 506 SetPressedPart(GetTheme().HitTest(*this, position));
507 int pressed_pos = Orientation() == kHorizontalScrollbar 507 int pressed_pos = Orientation() == kHorizontalScrollbar
508 ? ConvertFromRootFrame(position).X() 508 ? ConvertPointFromRootFrame(position).X()
509 : ConvertFromRootFrame(position).Y(); 509 : ConvertPointFromRootFrame(position).Y();
510 510
511 if ((pressed_part_ == kBackTrackPart || pressed_part_ == kForwardTrackPart) && 511 if ((pressed_part_ == kBackTrackPart || pressed_part_ == kForwardTrackPart) &&
512 GetTheme().ShouldCenterOnThumb(*this, evt)) { 512 GetTheme().ShouldCenterOnThumb(*this, evt)) {
513 SetHoveredPart(kThumbPart); 513 SetHoveredPart(kThumbPart);
514 SetPressedPart(kThumbPart); 514 SetPressedPart(kThumbPart);
515 drag_origin_ = current_pos_; 515 drag_origin_ = current_pos_;
516 int thumb_len = GetTheme().ThumbLength(*this); 516 int thumb_len = GetTheme().ThumbLength(*this);
517 int desired_pos = pressed_pos; 517 int desired_pos = pressed_pos;
518 // Set the pressed position to the middle of the thumb so that when we do 518 // Set the pressed position to the middle of the thumb so that when we do
519 // the move, the delta will be from the current pixel position of the thumb 519 // the move, the delta will be from the current pixel position of the thumb
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 // Non-overlay scrollbars should always participate in hit testing. 567 // Non-overlay scrollbars should always participate in hit testing.
568 if (!IsOverlayScrollbar()) 568 if (!IsOverlayScrollbar())
569 return true; 569 return true;
570 return !scrollable_area_->ScrollbarsHidden(); 570 return !scrollable_area_->ScrollbarsHidden();
571 } 571 }
572 572
573 bool Scrollbar::IsWindowActive() const { 573 bool Scrollbar::IsWindowActive() const {
574 return scrollable_area_ && scrollable_area_->IsActive(); 574 return scrollable_area_ && scrollable_area_->IsActive();
575 } 575 }
576 576
577 IntPoint Scrollbar::ConvertFromRootFrame( 577 IntPoint Scrollbar::ConvertPointFromRootFrame(
578 const IntPoint& point_in_root_frame) const { 578 const IntPoint& point_in_root_frame) const {
579 if (const FrameViewBase* parent = Parent()) { 579 if (const ScrollbarParent* parent = Parent()) {
580 IntPoint parent_point = parent->ConvertFromRootFrame(point_in_root_frame); 580 IntPoint parent_point =
581 parent->ConvertPointFromRootFrame(point_in_root_frame);
581 if (scrollable_area_) { 582 if (scrollable_area_) {
582 return scrollable_area_->ConvertFromContainingFrameViewToScrollbar( 583 return scrollable_area_->ConvertFromContainingFrameViewToScrollbar(
583 *this, parent_point); 584 *this, parent_point);
584 } 585 }
585 } 586 }
586 587
587 return point_in_root_frame; 588 return point_in_root_frame;
588 } 589 }
589 590
590 IntRect Scrollbar::ConvertToContainingFrameView( 591 IntRect Scrollbar::ConvertToContainingFrameView(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 invalid_parts = kAllParts; 639 invalid_parts = kAllParts;
639 if (invalid_parts & ~kThumbPart) 640 if (invalid_parts & ~kThumbPart)
640 track_needs_repaint_ = true; 641 track_needs_repaint_ = true;
641 if (invalid_parts & kThumbPart) 642 if (invalid_parts & kThumbPart)
642 thumb_needs_repaint_ = true; 643 thumb_needs_repaint_ = true;
643 if (scrollable_area_) 644 if (scrollable_area_)
644 scrollable_area_->SetScrollbarNeedsPaintInvalidation(Orientation()); 645 scrollable_area_->SetScrollbarNeedsPaintInvalidation(Orientation());
645 } 646 }
646 647
647 } // namespace blink 648 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698