Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / platform / exported / WebScrollbarThemeClientImpl.cpp
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 namespace blink {
33
34 WebScrollbarThemeClientImpl::WebScrollbarThemeClientImpl(WebScrollbar* scrollbar)
35     : m_scrollbar(scrollbar)
36 {
37     ScrollbarTheme::theme()->registerScrollbar(this);
38 }
39
40 WebScrollbarThemeClientImpl::~WebScrollbarThemeClientImpl()
41 {
42     ScrollbarTheme::theme()->unregisterScrollbar(this);
43 }
44
45 int WebScrollbarThemeClientImpl::x() const
46 {
47     return location().x();
48 }
49
50 int WebScrollbarThemeClientImpl::y() const
51 {
52     return location().y();
53 }
54
55 int WebScrollbarThemeClientImpl::width() const
56 {
57     return size().width();
58 }
59
60 int WebScrollbarThemeClientImpl::height() const
61 {
62     return size().height();
63 }
64
65 IntSize WebScrollbarThemeClientImpl::size() const
66 {
67     return m_scrollbar->size();
68 }
69
70 IntPoint WebScrollbarThemeClientImpl::location() const
71 {
72     return m_scrollbar->location();
73 }
74
75 Widget* WebScrollbarThemeClientImpl::parent() const
76 {
77     // Unused by Chromium scrollbar themes.
78     ASSERT_NOT_REACHED();
79     return 0;
80 }
81
82 Widget* WebScrollbarThemeClientImpl::root() const
83 {
84     // Unused by Chromium scrollbar themes.
85     ASSERT_NOT_REACHED();
86     return 0;
87 }
88
89 void WebScrollbarThemeClientImpl::setFrameRect(const IntRect&)
90 {
91     // Unused by Chromium scrollbar themes.
92     ASSERT_NOT_REACHED();
93 }
94
95 IntRect WebScrollbarThemeClientImpl::frameRect() const
96 {
97     return IntRect(location(), size());
98 }
99
100 void WebScrollbarThemeClientImpl::invalidate()
101 {
102     // Unused by Chromium scrollbar themes.
103     ASSERT_NOT_REACHED();
104 }
105
106 void WebScrollbarThemeClientImpl::invalidateRect(const IntRect&)
107 {
108     // Unused by Chromium scrollbar themes.
109     ASSERT_NOT_REACHED();
110 }
111
112 ScrollbarOverlayStyle WebScrollbarThemeClientImpl::scrollbarOverlayStyle() const
113 {
114     return static_cast<ScrollbarOverlayStyle>(m_scrollbar->scrollbarOverlayStyle());
115 }
116
117 void WebScrollbarThemeClientImpl::getTickmarks(Vector<IntRect>& tickmarks) const
118 {
119     WebVector<WebRect> webTickmarks;
120     m_scrollbar->getTickmarks(webTickmarks);
121     tickmarks.resize(webTickmarks.size());
122     for (size_t i = 0; i < webTickmarks.size(); ++i)
123         tickmarks[i] = webTickmarks[i];
124 }
125
126 bool WebScrollbarThemeClientImpl::isScrollableAreaActive() const
127 {
128     return m_scrollbar->isScrollableAreaActive();
129 }
130
131 IntPoint WebScrollbarThemeClientImpl::convertFromContainingWindow(const IntPoint& windowPoint)
132 {
133     // Unused by Chromium scrollbar themes.
134     ASSERT_NOT_REACHED();
135     return windowPoint;
136 }
137
138 bool WebScrollbarThemeClientImpl::isCustomScrollbar() const
139 {
140     return m_scrollbar->isCustomScrollbar();
141 }
142
143 ScrollbarOrientation WebScrollbarThemeClientImpl::orientation() const
144 {
145     return static_cast<ScrollbarOrientation>(m_scrollbar->orientation());
146 }
147
148 bool WebScrollbarThemeClientImpl::isLeftSideVerticalScrollbar() const
149 {
150     return m_scrollbar->isLeftSideVerticalScrollbar();
151 }
152
153 int WebScrollbarThemeClientImpl::value() const
154 {
155     return m_scrollbar->value();
156 }
157
158 float WebScrollbarThemeClientImpl::currentPos() const
159 {
160     return value();
161 }
162
163 int WebScrollbarThemeClientImpl::visibleSize() const
164 {
165     return totalSize() - maximum();
166 }
167
168 int WebScrollbarThemeClientImpl::totalSize() const
169 {
170     return m_scrollbar->totalSize();
171 }
172
173 int WebScrollbarThemeClientImpl::maximum() const
174 {
175     return m_scrollbar->maximum();
176 }
177
178 ScrollbarControlSize WebScrollbarThemeClientImpl::controlSize() const
179 {
180     return static_cast<ScrollbarControlSize>(m_scrollbar->controlSize());
181 }
182
183 ScrollbarPart WebScrollbarThemeClientImpl::pressedPart() const
184 {
185     return static_cast<ScrollbarPart>(m_scrollbar->pressedPart());
186 }
187
188 ScrollbarPart WebScrollbarThemeClientImpl::hoveredPart() const
189 {
190     return static_cast<ScrollbarPart>(m_scrollbar->hoveredPart());
191 }
192
193 void WebScrollbarThemeClientImpl::styleChanged()
194 {
195     ASSERT_NOT_REACHED();
196 }
197
198 bool WebScrollbarThemeClientImpl::enabled() const
199 {
200     return m_scrollbar->enabled();
201 }
202
203 void WebScrollbarThemeClientImpl::setEnabled(bool)
204 {
205     ASSERT_NOT_REACHED();
206 }
207
208 bool WebScrollbarThemeClientImpl::isOverlayScrollbar() const
209 {
210     return m_scrollbar->isOverlay();
211 }
212
213 bool WebScrollbarThemeClientImpl::isAlphaLocked() const
214 {
215     return m_scrollbar->isAlphaLocked();
216 }
217
218 void WebScrollbarThemeClientImpl::setIsAlphaLocked(bool flag)
219 {
220     m_scrollbar->setIsAlphaLocked(flag);
221 }
222
223 } // namespace blink