2 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
28 #include "platform/exported/WebScrollbarThemeClientImpl.h"
30 #include "platform/scroll/ScrollbarTheme.h"
32 using blink::WebScrollbar;
36 WebScrollbarThemeClientImpl::WebScrollbarThemeClientImpl(WebScrollbar* scrollbar)
37 : m_scrollbar(scrollbar)
39 ScrollbarTheme::theme()->registerScrollbar(this);
42 WebScrollbarThemeClientImpl::~WebScrollbarThemeClientImpl()
44 ScrollbarTheme::theme()->unregisterScrollbar(this);
47 int WebScrollbarThemeClientImpl::x() const
49 return location().x();
52 int WebScrollbarThemeClientImpl::y() const
54 return location().y();
57 int WebScrollbarThemeClientImpl::width() const
59 return size().width();
62 int WebScrollbarThemeClientImpl::height() const
64 return size().height();
67 IntSize WebScrollbarThemeClientImpl::size() const
69 return m_scrollbar->size();
72 IntPoint WebScrollbarThemeClientImpl::location() const
74 return m_scrollbar->location();
77 Widget* WebScrollbarThemeClientImpl::parent() const
79 // Unused by Chromium scrollbar themes.
84 Widget* WebScrollbarThemeClientImpl::root() const
86 // Unused by Chromium scrollbar themes.
91 void WebScrollbarThemeClientImpl::setFrameRect(const IntRect&)
93 // Unused by Chromium scrollbar themes.
97 IntRect WebScrollbarThemeClientImpl::frameRect() const
99 return IntRect(location(), size());
102 void WebScrollbarThemeClientImpl::invalidate()
104 // Unused by Chromium scrollbar themes.
105 ASSERT_NOT_REACHED();
108 void WebScrollbarThemeClientImpl::invalidateRect(const IntRect&)
110 // Unused by Chromium scrollbar themes.
111 ASSERT_NOT_REACHED();
114 WebCore::ScrollbarOverlayStyle WebScrollbarThemeClientImpl::scrollbarOverlayStyle() const
116 return static_cast<WebCore::ScrollbarOverlayStyle>(m_scrollbar->scrollbarOverlayStyle());
119 void WebScrollbarThemeClientImpl::getTickmarks(Vector<IntRect>& tickmarks) const
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];
128 bool WebScrollbarThemeClientImpl::isScrollableAreaActive() const
130 return m_scrollbar->isScrollableAreaActive();
133 bool WebScrollbarThemeClientImpl::isScrollViewScrollbar() const
135 // Unused by Chromium scrollbar themes.
136 ASSERT_NOT_REACHED();
140 IntPoint WebScrollbarThemeClientImpl::convertFromContainingWindow(const IntPoint& windowPoint)
142 // Unused by Chromium scrollbar themes.
143 ASSERT_NOT_REACHED();
147 bool WebScrollbarThemeClientImpl::isCustomScrollbar() const
149 return m_scrollbar->isCustomScrollbar();
152 WebCore::ScrollbarOrientation WebScrollbarThemeClientImpl::orientation() const
154 return static_cast<WebCore::ScrollbarOrientation>(m_scrollbar->orientation());
157 bool WebScrollbarThemeClientImpl::isLeftSideVerticalScrollbar() const
159 return m_scrollbar->isLeftSideVerticalScrollbar();
162 int WebScrollbarThemeClientImpl::value() const
164 return m_scrollbar->value();
167 float WebScrollbarThemeClientImpl::currentPos() const
172 int WebScrollbarThemeClientImpl::visibleSize() const
174 return totalSize() - maximum();
177 int WebScrollbarThemeClientImpl::totalSize() const
179 return m_scrollbar->totalSize();
182 int WebScrollbarThemeClientImpl::maximum() const
184 return m_scrollbar->maximum();
187 WebCore::ScrollbarControlSize WebScrollbarThemeClientImpl::controlSize() const
189 return static_cast<WebCore::ScrollbarControlSize>(m_scrollbar->controlSize());
192 WebCore::ScrollbarPart WebScrollbarThemeClientImpl::pressedPart() const
194 return static_cast<WebCore::ScrollbarPart>(m_scrollbar->pressedPart());
197 WebCore::ScrollbarPart WebScrollbarThemeClientImpl::hoveredPart() const
199 return static_cast<WebCore::ScrollbarPart>(m_scrollbar->hoveredPart());
202 void WebScrollbarThemeClientImpl::styleChanged()
204 ASSERT_NOT_REACHED();
207 bool WebScrollbarThemeClientImpl::enabled() const
209 return m_scrollbar->enabled();
212 void WebScrollbarThemeClientImpl::setEnabled(bool)
214 ASSERT_NOT_REACHED();
217 bool WebScrollbarThemeClientImpl::isOverlayScrollbar() const
219 return m_scrollbar->isOverlay();
222 bool WebScrollbarThemeClientImpl::isAlphaLocked() const
224 return m_scrollbar->isAlphaLocked();
227 void WebScrollbarThemeClientImpl::setIsAlphaLocked(bool flag)
229 m_scrollbar->setIsAlphaLocked(flag);