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

Side by Side Diff: Source/core/platform/ScrollbarThemeOverlay.cpp

Issue 99103006: Moving GraphicsContext and dependencies from core to platform. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final patch - fixes Android Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/platform/ScrollbarThemeOverlay.h ('k') | Source/core/platform/ScrollbarThemeWin.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #include "config.h"
27 #include "core/platform/ScrollbarThemeOverlay.h"
28
29 #include "core/platform/graphics/GraphicsContext.h"
30 #include "platform/PlatformMouseEvent.h"
31 #include "platform/scroll/ScrollbarThemeClient.h"
32 #include "platform/transforms/TransformationMatrix.h"
33
34 #include <algorithm>
35
36 using namespace std;
37
38 namespace WebCore {
39
40 ScrollbarThemeOverlay::ScrollbarThemeOverlay(int thumbThickness, int scrollbarMa rgin, HitTestBehavior allowHitTest, Color color)
41 : ScrollbarTheme()
42 , m_thumbThickness(thumbThickness)
43 , m_scrollbarMargin(scrollbarMargin)
44 , m_allowHitTest(allowHitTest)
45 , m_color(color)
46 {
47 }
48
49 int ScrollbarThemeOverlay::scrollbarThickness(ScrollbarControlSize controlSize)
50 {
51 return m_thumbThickness + m_scrollbarMargin;
52 }
53
54 bool ScrollbarThemeOverlay::usesOverlayScrollbars() const
55 {
56 return true;
57 }
58
59 int ScrollbarThemeOverlay::thumbPosition(ScrollbarThemeClient* scrollbar)
60 {
61 if (!scrollbar->totalSize())
62 return 0;
63
64 int trackLen = trackLength(scrollbar);
65 float proportion = static_cast<float>(scrollbar->currentPos()) / scrollbar-> totalSize();
66 return round(proportion * trackLen);
67 }
68
69 int ScrollbarThemeOverlay::thumbLength(ScrollbarThemeClient* scrollbar)
70 {
71 int trackLen = trackLength(scrollbar);
72
73 if (!scrollbar->totalSize())
74 return trackLen;
75
76 float proportion = static_cast<float>(scrollbar->visibleSize()) / scrollbar- >totalSize();
77 int length = round(proportion * trackLen);
78 length = min(max(length, minimumThumbLength(scrollbar)), trackLen);
79 return length;
80 }
81
82 bool ScrollbarThemeOverlay::hasThumb(ScrollbarThemeClient* scrollbar)
83 {
84 return true;
85 }
86
87 IntRect ScrollbarThemeOverlay::backButtonRect(ScrollbarThemeClient*, ScrollbarPa rt, bool)
88 {
89 return IntRect();
90 }
91
92 IntRect ScrollbarThemeOverlay::forwardButtonRect(ScrollbarThemeClient*, Scrollba rPart, bool)
93 {
94 return IntRect();
95 }
96
97 IntRect ScrollbarThemeOverlay::trackRect(ScrollbarThemeClient* scrollbar, bool)
98 {
99 IntRect rect = scrollbar->frameRect();
100 if (scrollbar->orientation() == HorizontalScrollbar)
101 rect.inflateX(-m_scrollbarMargin);
102 else
103 rect.inflateY(-m_scrollbarMargin);
104 return rect;
105 }
106
107 int ScrollbarThemeOverlay::thumbThickness(ScrollbarThemeClient*)
108 {
109 return m_thumbThickness;
110 }
111
112 void ScrollbarThemeOverlay::paintThumb(GraphicsContext* context, ScrollbarThemeC lient* scrollbar, const IntRect& rect)
113 {
114 IntRect thumbRect = rect;
115 if (scrollbar->orientation() == HorizontalScrollbar) {
116 thumbRect.setHeight(thumbRect.height() - m_scrollbarMargin);
117 } else {
118 thumbRect.setWidth(thumbRect.width() - m_scrollbarMargin);
119 if (scrollbar->isLeftSideVerticalScrollbar())
120 thumbRect.setX(thumbRect.x() + m_scrollbarMargin);
121 }
122 context->fillRect(thumbRect, m_color);
123 }
124
125 ScrollbarPart ScrollbarThemeOverlay::hitTest(ScrollbarThemeClient* scrollbar, co nst IntPoint& position)
126 {
127 if (m_allowHitTest == DisallowHitTest)
128 return NoPart;
129
130 return ScrollbarTheme::hitTest(scrollbar, position);
131 }
132
133 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/platform/ScrollbarThemeOverlay.h ('k') | Source/core/platform/ScrollbarThemeWin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698