| OLD | NEW |
| 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" |
| 35 #include "platform/scroll/ScrollbarTheme.h" | 34 #include "platform/scroll/ScrollbarTheme.h" |
| 36 #include "public/platform/WebGestureEvent.h" | 35 #include "public/platform/WebGestureEvent.h" |
| 37 #include "public/platform/WebMouseEvent.h" | 36 #include "public/platform/WebMouseEvent.h" |
| 38 | 37 |
| 39 namespace blink { | 38 namespace blink { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 57 pressed_pos_(0), | 56 pressed_pos_(0), |
| 58 scroll_pos_(0), | 57 scroll_pos_(0), |
| 59 dragging_document_(false), | 58 dragging_document_(false), |
| 60 document_drag_pos_(0), | 59 document_drag_pos_(0), |
| 61 enabled_(true), | 60 enabled_(true), |
| 62 scroll_timer_(scrollable_area->GetTimerTaskRunner(), | 61 scroll_timer_(scrollable_area->GetTimerTaskRunner(), |
| 63 this, | 62 this, |
| 64 &Scrollbar::AutoscrollTimerFired), | 63 &Scrollbar::AutoscrollTimerFired), |
| 65 elastic_overscroll_(0), | 64 elastic_overscroll_(0), |
| 66 track_needs_repaint_(true), | 65 track_needs_repaint_(true), |
| 67 thumb_needs_repaint_(true), | 66 thumb_needs_repaint_(true) { |
| 68 parent_(nullptr) { | |
| 69 theme_.RegisterScrollbar(*this); | 67 theme_.RegisterScrollbar(*this); |
| 70 | 68 |
| 71 // FIXME: This is ugly and would not be necessary if we fix cross-platform | 69 // FIXME: This is ugly and would not be necessary if we fix cross-platform |
| 72 // code to actually query for scrollbar thickness and use it when sizing | 70 // code to actually query for scrollbar thickness and use it when sizing |
| 73 // scrollbars (rather than leaving one dimension of the scrollbar alone when | 71 // scrollbars (rather than leaving one dimension of the scrollbar alone when |
| 74 // sizing). | 72 // sizing). |
| 75 int thickness = theme_.ScrollbarThickness(control_size); | 73 int thickness = theme_.ScrollbarThickness(control_size); |
| 76 theme_scrollbar_thickness_ = thickness; | 74 theme_scrollbar_thickness_ = thickness; |
| 77 if (chrome_client_) | 75 if (chrome_client_) |
| 78 thickness = chrome_client_->WindowToViewportScalar(thickness); | 76 thickness = chrome_client_->WindowToViewportScalar(thickness); |
| 79 frame_rect_ = IntRect(0, 0, thickness, thickness); | 77 frame_rect_ = IntRect(0, 0, thickness, thickness); |
| 80 | 78 |
| 81 current_pos_ = ScrollableAreaCurrentPos(); | 79 current_pos_ = ScrollableAreaCurrentPos(); |
| 82 } | 80 } |
| 83 | 81 |
| 84 Scrollbar::~Scrollbar() { | 82 Scrollbar::~Scrollbar() { |
| 85 theme_.UnregisterScrollbar(*this); | 83 theme_.UnregisterScrollbar(*this); |
| 86 } | 84 } |
| 87 | 85 |
| 88 DEFINE_TRACE(Scrollbar) { | 86 DEFINE_TRACE(Scrollbar) { |
| 89 visitor->Trace(scrollable_area_); | 87 visitor->Trace(scrollable_area_); |
| 90 visitor->Trace(chrome_client_); | 88 visitor->Trace(chrome_client_); |
| 91 visitor->Trace(parent_); | |
| 92 } | 89 } |
| 93 | 90 |
| 94 void Scrollbar::SetFrameRect(const IntRect& frame_rect) { | 91 void Scrollbar::SetFrameRect(const IntRect& frame_rect) { |
| 95 if (frame_rect == frame_rect_) | 92 if (frame_rect == frame_rect_) |
| 96 return; | 93 return; |
| 97 | 94 |
| 98 frame_rect_ = frame_rect; | 95 frame_rect_ = frame_rect; |
| 99 SetNeedsPaintInvalidation(kAllParts); | 96 SetNeedsPaintInvalidation(kAllParts); |
| 100 if (scrollable_area_) | 97 if (scrollable_area_) |
| 101 scrollable_area_->ScrollbarFrameRectChanged(); | 98 scrollable_area_->ScrollbarFrameRectChanged(); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 return true; | 566 return true; |
| 570 return !scrollable_area_->ScrollbarsHidden(); | 567 return !scrollable_area_->ScrollbarsHidden(); |
| 571 } | 568 } |
| 572 | 569 |
| 573 bool Scrollbar::IsWindowActive() const { | 570 bool Scrollbar::IsWindowActive() const { |
| 574 return scrollable_area_ && scrollable_area_->IsActive(); | 571 return scrollable_area_ && scrollable_area_->IsActive(); |
| 575 } | 572 } |
| 576 | 573 |
| 577 IntPoint Scrollbar::ConvertFromRootFrame( | 574 IntPoint Scrollbar::ConvertFromRootFrame( |
| 578 const IntPoint& point_in_root_frame) const { | 575 const IntPoint& point_in_root_frame) const { |
| 579 if (const FrameViewBase* parent = Parent()) { | 576 if (scrollable_area_) { |
| 580 IntPoint parent_point = parent->ConvertFromRootFrame(point_in_root_frame); | 577 IntPoint parent_point = |
| 581 if (scrollable_area_) { | 578 scrollable_area_->ConvertFromRootFrame(point_in_root_frame); |
| 582 return scrollable_area_->ConvertFromContainingFrameViewToScrollbar( | 579 return scrollable_area_->ConvertFromContainingFrameViewToScrollbar( |
| 583 *this, parent_point); | 580 *this, parent_point); |
| 584 } | |
| 585 } | 581 } |
| 586 | 582 |
| 587 return point_in_root_frame; | 583 return point_in_root_frame; |
| 588 } | 584 } |
| 589 | 585 |
| 590 IntRect Scrollbar::ConvertToContainingFrameView( | 586 IntRect Scrollbar::ConvertToContainingFrameView( |
| 591 const IntRect& local_rect) const { | 587 const IntRect& local_rect) const { |
| 592 if (scrollable_area_) { | 588 if (scrollable_area_) { |
| 593 return scrollable_area_->ConvertFromScrollbarToContainingFrameView( | 589 return scrollable_area_->ConvertFromScrollbarToContainingFrameView( |
| 594 *this, local_rect); | 590 *this, local_rect); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 invalid_parts = kAllParts; | 634 invalid_parts = kAllParts; |
| 639 if (invalid_parts & ~kThumbPart) | 635 if (invalid_parts & ~kThumbPart) |
| 640 track_needs_repaint_ = true; | 636 track_needs_repaint_ = true; |
| 641 if (invalid_parts & kThumbPart) | 637 if (invalid_parts & kThumbPart) |
| 642 thumb_needs_repaint_ = true; | 638 thumb_needs_repaint_ = true; |
| 643 if (scrollable_area_) | 639 if (scrollable_area_) |
| 644 scrollable_area_->SetScrollbarNeedsPaintInvalidation(Orientation()); | 640 scrollable_area_->SetScrollbarNeedsPaintInvalidation(Orientation()); |
| 645 } | 641 } |
| 646 | 642 |
| 647 } // namespace blink | 643 } // namespace blink |
| OLD | NEW |