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

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

Issue 1560403002: Scale scrollbar in use-zoom-for-dsf mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/PlatformGestureEvent.h" 30 #include "platform/PlatformGestureEvent.h"
30 #include "platform/PlatformMouseEvent.h" 31 #include "platform/PlatformMouseEvent.h"
31 #include "platform/graphics/paint/CullRect.h" 32 #include "platform/graphics/paint/CullRect.h"
32 // See windowActiveChangedForSnowLeopardOnly() below. 33 // See windowActiveChangedForSnowLeopardOnly() below.
33 // TODO(ellyjones): remove this when Snow Leopard support is gone. 34 // TODO(ellyjones): remove this when Snow Leopard support is gone.
34 #if OS(MACOSX) 35 #if OS(MACOSX)
35 #include "platform/mac/VersionUtilMac.h" 36 #include "platform/mac/VersionUtilMac.h"
36 #endif 37 #endif
37 #include "platform/scroll/ScrollAnimatorBase.h" 38 #include "platform/scroll/ScrollAnimatorBase.h"
38 #include "platform/scroll/ScrollableArea.h" 39 #include "platform/scroll/ScrollableArea.h"
39 #include "platform/scroll/ScrollbarTheme.h" 40 #include "platform/scroll/ScrollbarTheme.h"
40 41
41 namespace blink { 42 namespace blink {
42 43
43 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr ea, ScrollbarOrientation orientation, ScrollbarControlSize size) 44 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::create(ScrollableArea* scrollableAr ea, ScrollbarOrientation orientation, ScrollbarControlSize size, HostWindow* hos tWindow)
44 { 45 {
45 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size)); 46 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, h ostWindow));
46 } 47 }
47 48
48 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::createForTesting(ScrollableArea* sc rollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size, Scrol lbarTheme* theme) 49 PassRefPtrWillBeRawPtr<Scrollbar> Scrollbar::createForTesting(ScrollableArea* sc rollableArea, ScrollbarOrientation orientation, ScrollbarControlSize size, Scrol lbarTheme* theme)
49 { 50 {
50 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, t heme)); 51 return adoptRefWillBeNoop(new Scrollbar(scrollableArea, orientation, size, n ullptr, theme));
51 } 52 }
52 53
53 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient ation, ScrollbarControlSize controlSize, ScrollbarTheme* theme) 54 Scrollbar::Scrollbar(ScrollableArea* scrollableArea, ScrollbarOrientation orient ation, ScrollbarControlSize controlSize, HostWindow* hostWindow, ScrollbarTheme* theme)
54 : m_scrollableArea(scrollableArea) 55 : m_scrollableArea(scrollableArea)
55 , m_orientation(orientation) 56 , m_orientation(orientation)
56 , m_controlSize(controlSize) 57 , m_controlSize(controlSize)
57 , m_theme(theme ? *theme : ScrollbarTheme::theme()) 58 , m_theme(theme ? *theme : ScrollbarTheme::theme())
58 , m_visibleSize(0) 59 , m_visibleSize(0)
59 , m_totalSize(0) 60 , m_totalSize(0)
60 , m_currentPos(0) 61 , m_currentPos(0)
61 , m_dragOrigin(0) 62 , m_dragOrigin(0)
62 , m_hoveredPart(NoPart) 63 , m_hoveredPart(NoPart)
63 , m_pressedPart(NoPart) 64 , m_pressedPart(NoPart)
64 , m_pressedPos(0) 65 , m_pressedPos(0)
65 , m_scrollPos(0) 66 , m_scrollPos(0)
66 , m_draggingDocument(false) 67 , m_draggingDocument(false)
67 , m_documentDragPos(0) 68 , m_documentDragPos(0)
68 , m_enabled(true) 69 , m_enabled(true)
69 , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired) 70 , m_scrollTimer(this, &Scrollbar::autoscrollTimerFired)
70 , m_overlapsResizer(false) 71 , m_overlapsResizer(false)
71 , m_elasticOverscroll(0) 72 , m_elasticOverscroll(0)
72 , m_trackNeedsRepaint(true) 73 , m_trackNeedsRepaint(true)
73 , m_thumbNeedsRepaint(true) 74 , m_thumbNeedsRepaint(true)
74 { 75 {
75 m_theme.registerScrollbar(*this); 76 m_theme.registerScrollbar(*this);
76 77
77 // FIXME: This is ugly and would not be necessary if we fix cross-platform c ode to actually query for 78 // FIXME: This is ugly and would not be necessary if we fix cross-platform c ode to actually query for
78 // scrollbar thickness and use it when sizing scrollbars (rather than leavin g one dimension of the scrollbar 79 // scrollbar thickness and use it when sizing scrollbars (rather than leavin g one dimension of the scrollbar
79 // alone when sizing). 80 // alone when sizing).
80 int thickness = m_theme.scrollbarThickness(controlSize); 81 int thickness = m_theme.scrollbarThickness(controlSize);
82 if (hostWindow) {
83 IntRect tmp(0, 0, 100, 0);
skobes 2016/01/07 21:49:10 Where does this "100" come from?
oshima 2016/01/09 00:58:39 It's picked as large enough number so that you can
skobes 2016/01/11 03:28:29 It would be much clearer to have an overload of vi
skobes 2016/01/11 03:30:52 Clarification: I meant something like HostWindow::
84 tmp = hostWindow->viewportToScreen(tmp);
85 thickness *= 100.f / tmp.width();
86 }
87
81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); 88 Widget::setFrameRect(IntRect(0, 0, thickness, thickness));
82 89
83 m_currentPos = scrollableAreaCurrentPos(); 90 m_currentPos = scrollableAreaCurrentPos();
84 } 91 }
85 92
86 Scrollbar::~Scrollbar() 93 Scrollbar::~Scrollbar()
87 { 94 {
88 m_theme.unregisterScrollbar(*this); 95 m_theme.unregisterScrollbar(*this);
89 } 96 }
90 97
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 { 573 {
567 if (m_theme.shouldRepaintAllPartsOnInvalidation()) { 574 if (m_theme.shouldRepaintAllPartsOnInvalidation()) {
568 m_trackNeedsRepaint = true; 575 m_trackNeedsRepaint = true;
569 m_thumbNeedsRepaint = true; 576 m_thumbNeedsRepaint = true;
570 } 577 }
571 if (m_scrollableArea) 578 if (m_scrollableArea)
572 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); 579 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation());
573 } 580 }
574 581
575 } // namespace blink 582 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698