• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 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 
28 #include "platform/exported/WebScrollbarThemeClientImpl.h"
29 
30 #include "platform/scroll/ScrollbarTheme.h"
31 
32 using blink::WebScrollbar;
33 
34 namespace WebCore {
35 
WebScrollbarThemeClientImpl(WebScrollbar * scrollbar)36 WebScrollbarThemeClientImpl::WebScrollbarThemeClientImpl(WebScrollbar* scrollbar)
37     : m_scrollbar(scrollbar)
38 {
39     ScrollbarTheme::theme()->registerScrollbar(this);
40 }
41 
~WebScrollbarThemeClientImpl()42 WebScrollbarThemeClientImpl::~WebScrollbarThemeClientImpl()
43 {
44     ScrollbarTheme::theme()->unregisterScrollbar(this);
45 }
46 
x() const47 int WebScrollbarThemeClientImpl::x() const
48 {
49     return location().x();
50 }
51 
y() const52 int WebScrollbarThemeClientImpl::y() const
53 {
54     return location().y();
55 }
56 
width() const57 int WebScrollbarThemeClientImpl::width() const
58 {
59     return size().width();
60 }
61 
height() const62 int WebScrollbarThemeClientImpl::height() const
63 {
64     return size().height();
65 }
66 
size() const67 IntSize WebScrollbarThemeClientImpl::size() const
68 {
69     return m_scrollbar->size();
70 }
71 
location() const72 IntPoint WebScrollbarThemeClientImpl::location() const
73 {
74     return m_scrollbar->location();
75 }
76 
parent() const77 Widget* WebScrollbarThemeClientImpl::parent() const
78 {
79     // Unused by Chromium scrollbar themes.
80     ASSERT_NOT_REACHED();
81     return 0;
82 }
83 
root() const84 Widget* WebScrollbarThemeClientImpl::root() const
85 {
86     // Unused by Chromium scrollbar themes.
87     ASSERT_NOT_REACHED();
88     return 0;
89 }
90 
setFrameRect(const IntRect &)91 void WebScrollbarThemeClientImpl::setFrameRect(const IntRect&)
92 {
93     // Unused by Chromium scrollbar themes.
94     ASSERT_NOT_REACHED();
95 }
96 
frameRect() const97 IntRect WebScrollbarThemeClientImpl::frameRect() const
98 {
99     return IntRect(location(), size());
100 }
101 
invalidate()102 void WebScrollbarThemeClientImpl::invalidate()
103 {
104     // Unused by Chromium scrollbar themes.
105     ASSERT_NOT_REACHED();
106 }
107 
invalidateRect(const IntRect &)108 void WebScrollbarThemeClientImpl::invalidateRect(const IntRect&)
109 {
110     // Unused by Chromium scrollbar themes.
111     ASSERT_NOT_REACHED();
112 }
113 
scrollbarOverlayStyle() const114 WebCore::ScrollbarOverlayStyle WebScrollbarThemeClientImpl::scrollbarOverlayStyle() const
115 {
116     return static_cast<WebCore::ScrollbarOverlayStyle>(m_scrollbar->scrollbarOverlayStyle());
117 }
118 
getTickmarks(Vector<IntRect> & tickmarks) const119 void WebScrollbarThemeClientImpl::getTickmarks(Vector<IntRect>& tickmarks) const
120 {
121     blink::WebVector<blink::WebRect> webTickmarks;
122     m_scrollbar->getTickmarks(webTickmarks);
123     tickmarks.resize(webTickmarks.size());
124     for (size_t i = 0; i < webTickmarks.size(); ++i)
125         tickmarks[i] = webTickmarks[i];
126 }
127 
isScrollableAreaActive() const128 bool WebScrollbarThemeClientImpl::isScrollableAreaActive() const
129 {
130     return m_scrollbar->isScrollableAreaActive();
131 }
132 
isScrollViewScrollbar() const133 bool WebScrollbarThemeClientImpl::isScrollViewScrollbar() const
134 {
135     // Unused by Chromium scrollbar themes.
136     ASSERT_NOT_REACHED();
137     return false;
138 }
139 
convertFromContainingWindow(const IntPoint & windowPoint)140 IntPoint WebScrollbarThemeClientImpl::convertFromContainingWindow(const IntPoint& windowPoint)
141 {
142     // Unused by Chromium scrollbar themes.
143     ASSERT_NOT_REACHED();
144     return windowPoint;
145 }
146 
isCustomScrollbar() const147 bool WebScrollbarThemeClientImpl::isCustomScrollbar() const
148 {
149     return m_scrollbar->isCustomScrollbar();
150 }
151 
orientation() const152 WebCore::ScrollbarOrientation WebScrollbarThemeClientImpl::orientation() const
153 {
154     return static_cast<WebCore::ScrollbarOrientation>(m_scrollbar->orientation());
155 }
156 
isLeftSideVerticalScrollbar() const157 bool WebScrollbarThemeClientImpl::isLeftSideVerticalScrollbar() const
158 {
159     return m_scrollbar->isLeftSideVerticalScrollbar();
160 }
161 
value() const162 int WebScrollbarThemeClientImpl::value() const
163 {
164     return m_scrollbar->value();
165 }
166 
currentPos() const167 float WebScrollbarThemeClientImpl::currentPos() const
168 {
169     return value();
170 }
171 
visibleSize() const172 int WebScrollbarThemeClientImpl::visibleSize() const
173 {
174     return totalSize() - maximum();
175 }
176 
totalSize() const177 int WebScrollbarThemeClientImpl::totalSize() const
178 {
179     return m_scrollbar->totalSize();
180 }
181 
maximum() const182 int WebScrollbarThemeClientImpl::maximum() const
183 {
184     return m_scrollbar->maximum();
185 }
186 
controlSize() const187 WebCore::ScrollbarControlSize WebScrollbarThemeClientImpl::controlSize() const
188 {
189     return static_cast<WebCore::ScrollbarControlSize>(m_scrollbar->controlSize());
190 }
191 
pressedPart() const192 WebCore::ScrollbarPart WebScrollbarThemeClientImpl::pressedPart() const
193 {
194     return static_cast<WebCore::ScrollbarPart>(m_scrollbar->pressedPart());
195 }
196 
hoveredPart() const197 WebCore::ScrollbarPart WebScrollbarThemeClientImpl::hoveredPart() const
198 {
199     return static_cast<WebCore::ScrollbarPart>(m_scrollbar->hoveredPart());
200 }
201 
styleChanged()202 void WebScrollbarThemeClientImpl::styleChanged()
203 {
204     ASSERT_NOT_REACHED();
205 }
206 
enabled() const207 bool WebScrollbarThemeClientImpl::enabled() const
208 {
209     return m_scrollbar->enabled();
210 }
211 
setEnabled(bool)212 void WebScrollbarThemeClientImpl::setEnabled(bool)
213 {
214     ASSERT_NOT_REACHED();
215 }
216 
isOverlayScrollbar() const217 bool WebScrollbarThemeClientImpl::isOverlayScrollbar() const
218 {
219     return m_scrollbar->isOverlay();
220 }
221 
isAlphaLocked() const222 bool WebScrollbarThemeClientImpl::isAlphaLocked() const
223 {
224     return m_scrollbar->isAlphaLocked();
225 }
226 
setIsAlphaLocked(bool flag)227 void WebScrollbarThemeClientImpl::setIsAlphaLocked(bool flag)
228 {
229     m_scrollbar->setIsAlphaLocked(flag);
230 }
231 
232 } // namespace blink
233