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

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

Issue 2824753005: Rename HostWindow to PlatformChromeClient (Closed)
Patch Set: mac Created 3 years, 8 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/PlatformChromeClient.h"
30 #include "platform/geometry/FloatRect.h" 30 #include "platform/geometry/FloatRect.h"
31 #include "platform/graphics/paint/CullRect.h" 31 #include "platform/graphics/paint/CullRect.h"
32 #include "platform/scroll/ScrollAnimatorBase.h" 32 #include "platform/scroll/ScrollAnimatorBase.h"
33 #include "platform/scroll/ScrollableArea.h" 33 #include "platform/scroll/ScrollableArea.h"
34 #include "platform/scroll/ScrollbarTheme.h" 34 #include "platform/scroll/ScrollbarTheme.h"
35 #include "public/platform/WebGestureEvent.h" 35 #include "public/platform/WebGestureEvent.h"
36 #include "public/platform/WebMouseEvent.h" 36 #include "public/platform/WebMouseEvent.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 Scrollbar::Scrollbar(ScrollableArea* scrollable_area, 40 Scrollbar::Scrollbar(ScrollableArea* scrollable_area,
41 ScrollbarOrientation orientation, 41 ScrollbarOrientation orientation,
42 ScrollbarControlSize control_size, 42 ScrollbarControlSize control_size,
43 HostWindow* host_window, 43 PlatformChromeClient* chrome_client,
44 ScrollbarTheme* theme) 44 ScrollbarTheme* theme)
45 : scrollable_area_(scrollable_area), 45 : scrollable_area_(scrollable_area),
46 orientation_(orientation), 46 orientation_(orientation),
47 control_size_(control_size), 47 control_size_(control_size),
48 theme_(theme ? *theme : ScrollbarTheme::GetTheme()), 48 theme_(theme ? *theme : ScrollbarTheme::GetTheme()),
49 host_window_(host_window), 49 chrome_client_(chrome_client),
50 visible_size_(0), 50 visible_size_(0),
51 total_size_(0), 51 total_size_(0),
52 current_pos_(0), 52 current_pos_(0),
53 drag_origin_(0), 53 drag_origin_(0),
54 hovered_part_(kNoPart), 54 hovered_part_(kNoPart),
55 pressed_part_(kNoPart), 55 pressed_part_(kNoPart),
56 pressed_pos_(0), 56 pressed_pos_(0),
57 scroll_pos_(0), 57 scroll_pos_(0),
58 dragging_document_(false), 58 dragging_document_(false),
59 document_drag_pos_(0), 59 document_drag_pos_(0),
60 enabled_(true), 60 enabled_(true),
61 scroll_timer_(scrollable_area->GetTimerTaskRunner(), 61 scroll_timer_(scrollable_area->GetTimerTaskRunner(),
62 this, 62 this,
63 &Scrollbar::AutoscrollTimerFired), 63 &Scrollbar::AutoscrollTimerFired),
64 elastic_overscroll_(0), 64 elastic_overscroll_(0),
65 track_needs_repaint_(true), 65 track_needs_repaint_(true),
66 thumb_needs_repaint_(true) { 66 thumb_needs_repaint_(true) {
67 theme_.RegisterScrollbar(*this); 67 theme_.RegisterScrollbar(*this);
68 68
69 // 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
70 // 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
71 // scrollbars (rather than leaving one dimension of the scrollbar alone when 71 // scrollbars (rather than leaving one dimension of the scrollbar alone when
72 // sizing). 72 // sizing).
73 int thickness = theme_.ScrollbarThickness(control_size); 73 int thickness = theme_.ScrollbarThickness(control_size);
74 theme_scrollbar_thickness_ = thickness; 74 theme_scrollbar_thickness_ = thickness;
75 if (host_window_) 75 if (chrome_client_)
76 thickness = host_window_->WindowToViewportScalar(thickness); 76 thickness = chrome_client_->WindowToViewportScalar(thickness);
77 FrameViewBase::SetFrameRect(IntRect(0, 0, thickness, thickness)); 77 FrameViewBase::SetFrameRect(IntRect(0, 0, thickness, thickness));
78 78
79 current_pos_ = ScrollableAreaCurrentPos(); 79 current_pos_ = ScrollableAreaCurrentPos();
80 } 80 }
81 81
82 Scrollbar::~Scrollbar() { 82 Scrollbar::~Scrollbar() {
83 theme_.UnregisterScrollbar(*this); 83 theme_.UnregisterScrollbar(*this);
84 } 84 }
85 85
86 DEFINE_TRACE(Scrollbar) { 86 DEFINE_TRACE(Scrollbar) {
87 visitor->Trace(scrollable_area_); 87 visitor->Trace(scrollable_area_);
88 visitor->Trace(host_window_); 88 visitor->Trace(chrome_client_);
89 FrameViewBase::Trace(visitor); 89 FrameViewBase::Trace(visitor);
90 } 90 }
91 91
92 void Scrollbar::SetFrameRect(const IntRect& frame_rect) { 92 void Scrollbar::SetFrameRect(const IntRect& frame_rect) {
93 if (frame_rect == this->FrameRect()) 93 if (frame_rect == this->FrameRect())
94 return; 94 return;
95 95
96 FrameViewBase::SetFrameRect(frame_rect); 96 FrameViewBase::SetFrameRect(frame_rect);
97 SetNeedsPaintInvalidation(kAllParts); 97 SetNeedsPaintInvalidation(kAllParts);
98 if (scrollable_area_) 98 if (scrollable_area_)
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 return; 542 return;
543 enabled_ = e; 543 enabled_ = e;
544 GetTheme().UpdateEnabledState(*this); 544 GetTheme().UpdateEnabledState(*this);
545 545
546 ScrollbarPart invalid_parts = GetTheme().InvalidateOnEnabledChange(); 546 ScrollbarPart invalid_parts = GetTheme().InvalidateOnEnabledChange();
547 SetNeedsPaintInvalidation(invalid_parts); 547 SetNeedsPaintInvalidation(invalid_parts);
548 } 548 }
549 549
550 int Scrollbar::ScrollbarThickness() const { 550 int Scrollbar::ScrollbarThickness() const {
551 int thickness = Orientation() == kHorizontalScrollbar ? Height() : Width(); 551 int thickness = Orientation() == kHorizontalScrollbar ? Height() : Width();
552 if (!thickness || !host_window_) 552 if (!thickness || !chrome_client_)
553 return thickness; 553 return thickness;
554 return host_window_->WindowToViewportScalar(theme_scrollbar_thickness_); 554 return chrome_client_->WindowToViewportScalar(theme_scrollbar_thickness_);
555 } 555 }
556 556
557 bool Scrollbar::IsOverlayScrollbar() const { 557 bool Scrollbar::IsOverlayScrollbar() const {
558 return theme_.UsesOverlayScrollbars(); 558 return theme_.UsesOverlayScrollbars();
559 } 559 }
560 560
561 bool Scrollbar::ShouldParticipateInHitTesting() { 561 bool Scrollbar::ShouldParticipateInHitTesting() {
562 // Non-overlay scrollbars should always participate in hit testing. 562 // Non-overlay scrollbars should always participate in hit testing.
563 if (!IsOverlayScrollbar()) 563 if (!IsOverlayScrollbar())
564 return true; 564 return true;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 invalid_parts = kAllParts; 640 invalid_parts = kAllParts;
641 if (invalid_parts & ~kThumbPart) 641 if (invalid_parts & ~kThumbPart)
642 track_needs_repaint_ = true; 642 track_needs_repaint_ = true;
643 if (invalid_parts & kThumbPart) 643 if (invalid_parts & kThumbPart)
644 thumb_needs_repaint_ = true; 644 thumb_needs_repaint_ = true;
645 if (scrollable_area_) 645 if (scrollable_area_)
646 scrollable_area_->SetScrollbarNeedsPaintInvalidation(Orientation()); 646 scrollable_area_->SetScrollbarNeedsPaintInvalidation(Orientation());
647 } 647 }
648 648
649 } // namespace blink 649 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/scroll/Scrollbar.h ('k') | third_party/WebKit/Source/web/ValidationMessageClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698