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