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