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"
34 WebScrollbarThemeClientImpl::WebScrollbarThemeClientImpl(WebScrollbar* scrollbar)
35 : m_scrollbar(scrollbar)
37 ScrollbarTheme::theme()->registerScrollbar(this);
40 WebScrollbarThemeClientImpl::~WebScrollbarThemeClientImpl()
42 ScrollbarTheme::theme()->unregisterScrollbar(this);
45 int WebScrollbarThemeClientImpl::x() const
47 return location().x();
50 int WebScrollbarThemeClientImpl::y() const
52 return location().y();
55 int WebScrollbarThemeClientImpl::width() const
57 return size().width();
60 int WebScrollbarThemeClientImpl::height() const
62 return size().height();
65 IntSize WebScrollbarThemeClientImpl::size() const
67 return m_scrollbar->size();
70 IntPoint WebScrollbarThemeClientImpl::location() const
72 return m_scrollbar->location();
75 Widget* WebScrollbarThemeClientImpl::parent() const
77 // Unused by Chromium scrollbar themes.
82 Widget* WebScrollbarThemeClientImpl::root() const
84 // Unused by Chromium scrollbar themes.
89 void WebScrollbarThemeClientImpl::setFrameRect(const IntRect&)
91 // Unused by Chromium scrollbar themes.
95 IntRect WebScrollbarThemeClientImpl::frameRect() const
97 return IntRect(location(), size());
100 void WebScrollbarThemeClientImpl::invalidate()
102 // Unused by Chromium scrollbar themes.
103 ASSERT_NOT_REACHED();
106 void WebScrollbarThemeClientImpl::invalidateRect(const IntRect&)
108 // Unused by Chromium scrollbar themes.
109 ASSERT_NOT_REACHED();
112 ScrollbarOverlayStyle WebScrollbarThemeClientImpl::scrollbarOverlayStyle() const
114 return static_cast<ScrollbarOverlayStyle>(m_scrollbar->scrollbarOverlayStyle());
117 void WebScrollbarThemeClientImpl::getTickmarks(Vector<IntRect>& tickmarks) const
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];
126 bool WebScrollbarThemeClientImpl::isScrollableAreaActive() const
128 return m_scrollbar->isScrollableAreaActive();
131 IntPoint WebScrollbarThemeClientImpl::convertFromContainingWindow(const IntPoint& windowPoint)
133 // Unused by Chromium scrollbar themes.
134 ASSERT_NOT_REACHED();
138 bool WebScrollbarThemeClientImpl::isCustomScrollbar() const
140 return m_scrollbar->isCustomScrollbar();
143 ScrollbarOrientation WebScrollbarThemeClientImpl::orientation() const
145 return static_cast<ScrollbarOrientation>(m_scrollbar->orientation());
148 bool WebScrollbarThemeClientImpl::isLeftSideVerticalScrollbar() const
150 return m_scrollbar->isLeftSideVerticalScrollbar();
153 int WebScrollbarThemeClientImpl::value() const
155 return m_scrollbar->value();
158 float WebScrollbarThemeClientImpl::currentPos() const
163 int WebScrollbarThemeClientImpl::visibleSize() const
165 return totalSize() - maximum();
168 int WebScrollbarThemeClientImpl::totalSize() const
170 return m_scrollbar->totalSize();
173 int WebScrollbarThemeClientImpl::maximum() const
175 return m_scrollbar->maximum();
178 ScrollbarControlSize WebScrollbarThemeClientImpl::controlSize() const
180 return static_cast<ScrollbarControlSize>(m_scrollbar->controlSize());
183 ScrollbarPart WebScrollbarThemeClientImpl::pressedPart() const
185 return static_cast<ScrollbarPart>(m_scrollbar->pressedPart());
188 ScrollbarPart WebScrollbarThemeClientImpl::hoveredPart() const
190 return static_cast<ScrollbarPart>(m_scrollbar->hoveredPart());
193 void WebScrollbarThemeClientImpl::styleChanged()
195 ASSERT_NOT_REACHED();
198 bool WebScrollbarThemeClientImpl::enabled() const
200 return m_scrollbar->enabled();
203 void WebScrollbarThemeClientImpl::setEnabled(bool)
205 ASSERT_NOT_REACHED();
208 bool WebScrollbarThemeClientImpl::isOverlayScrollbar() const
210 return m_scrollbar->isOverlay();
213 bool WebScrollbarThemeClientImpl::isAlphaLocked() const
215 return m_scrollbar->isAlphaLocked();
218 void WebScrollbarThemeClientImpl::setIsAlphaLocked(bool flag)
220 m_scrollbar->setIsAlphaLocked(flag);