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

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 // Convert the thickness in the screen (dip) to the viewport
84 // by applying the invert of the viewport to screen scale.
85 // TODO(oshima): Introduce the screenToViewport(float) to avoid the roun ding error.
86 IntRect inScreen(0, 0, 100, 0);
87 inScreen = hostWindow->viewportToScreen(inScreen);
88 thickness *= 100.f / inScreen.width();
89 }
90
81 Widget::setFrameRect(IntRect(0, 0, thickness, thickness)); 91 Widget::setFrameRect(IntRect(0, 0, thickness, thickness));
82 92
83 m_currentPos = scrollableAreaCurrentPos(); 93 m_currentPos = scrollableAreaCurrentPos();
84 } 94 }
85 95
86 Scrollbar::~Scrollbar() 96 Scrollbar::~Scrollbar()
87 { 97 {
88 m_theme.unregisterScrollbar(*this); 98 m_theme.unregisterScrollbar(*this);
89 } 99 }
90 100
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 invalidParts = AllParts; 563 invalidParts = AllParts;
554 if (invalidParts & ~ThumbPart) 564 if (invalidParts & ~ThumbPart)
555 m_trackNeedsRepaint = true; 565 m_trackNeedsRepaint = true;
556 if (invalidParts & ThumbPart) 566 if (invalidParts & ThumbPart)
557 m_thumbNeedsRepaint = true; 567 m_thumbNeedsRepaint = true;
558 if (m_scrollableArea) 568 if (m_scrollableArea)
559 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation()); 569 m_scrollableArea->setScrollbarNeedsPaintInvalidation(orientation());
560 } 570 }
561 571
562 } // namespace blink 572 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698