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/WebScrollbarThemeGeometryNative.h" 29 30#include "platform/exported/WebScrollbarThemeClientImpl.h" 31#include "platform/scroll/ScrollbarTheme.h" 32#include "public/platform/WebScrollbar.h" 33 34using namespace WebCore; 35 36namespace blink { 37 38PassOwnPtr<blink::WebScrollbarThemeGeometryNative> WebScrollbarThemeGeometryNative::create(WebCore::ScrollbarTheme* theme) 39{ 40 return adoptPtr(new WebScrollbarThemeGeometryNative(theme)); 41} 42 43WebScrollbarThemeGeometryNative::WebScrollbarThemeGeometryNative(WebCore::ScrollbarTheme* theme) 44 : m_theme(theme) 45{ 46} 47 48WebScrollbarThemeGeometryNative* WebScrollbarThemeGeometryNative::clone() const 49{ 50 return new WebScrollbarThemeGeometryNative(m_theme); 51} 52 53int WebScrollbarThemeGeometryNative::thumbPosition(WebScrollbar* scrollbar) 54{ 55 WebScrollbarThemeClientImpl client(scrollbar); 56 return m_theme->thumbPosition(&client); 57} 58 59int WebScrollbarThemeGeometryNative::thumbLength(WebScrollbar* scrollbar) 60{ 61 WebScrollbarThemeClientImpl client(scrollbar); 62 return m_theme->thumbLength(&client); 63} 64 65int WebScrollbarThemeGeometryNative::trackPosition(WebScrollbar* scrollbar) 66{ 67 WebScrollbarThemeClientImpl client(scrollbar); 68 return m_theme->trackPosition(&client); 69} 70 71int WebScrollbarThemeGeometryNative::trackLength(WebScrollbar* scrollbar) 72{ 73 WebScrollbarThemeClientImpl client(scrollbar); 74 return m_theme->trackLength(&client); 75} 76 77bool WebScrollbarThemeGeometryNative::hasButtons(WebScrollbar* scrollbar) 78{ 79 WebScrollbarThemeClientImpl client(scrollbar); 80 return m_theme->hasButtons(&client); 81} 82 83bool WebScrollbarThemeGeometryNative::hasThumb(WebScrollbar* scrollbar) 84{ 85 WebScrollbarThemeClientImpl client(scrollbar); 86 return m_theme->hasThumb(&client); 87} 88 89WebRect WebScrollbarThemeGeometryNative::trackRect(WebScrollbar* scrollbar) 90{ 91 WebScrollbarThemeClientImpl client(scrollbar); 92 return m_theme->trackRect(&client); 93} 94 95WebRect WebScrollbarThemeGeometryNative::thumbRect(WebScrollbar* scrollbar) 96{ 97 WebScrollbarThemeClientImpl client(scrollbar); 98 return m_theme->thumbRect(&client); 99} 100 101int WebScrollbarThemeGeometryNative::minimumThumbLength(WebScrollbar* scrollbar) 102{ 103 WebScrollbarThemeClientImpl client(scrollbar); 104 return m_theme->minimumThumbLength(&client); 105} 106 107int WebScrollbarThemeGeometryNative::scrollbarThickness(WebScrollbar* scrollbar) 108{ 109 WebScrollbarThemeClientImpl client(scrollbar); 110 return m_theme->scrollbarThickness(client.controlSize()); 111} 112 113WebRect WebScrollbarThemeGeometryNative::backButtonStartRect(WebScrollbar* scrollbar) 114{ 115 WebScrollbarThemeClientImpl client(scrollbar); 116 return m_theme->backButtonRect(&client, BackButtonStartPart, false); 117} 118 119WebRect WebScrollbarThemeGeometryNative::backButtonEndRect(WebScrollbar* scrollbar) 120{ 121 WebScrollbarThemeClientImpl client(scrollbar); 122 return m_theme->backButtonRect(&client, BackButtonEndPart, false); 123} 124 125WebRect WebScrollbarThemeGeometryNative::forwardButtonStartRect(WebScrollbar* scrollbar) 126{ 127 WebScrollbarThemeClientImpl client(scrollbar); 128 return m_theme->forwardButtonRect(&client, ForwardButtonStartPart, false); 129} 130 131WebRect WebScrollbarThemeGeometryNative::forwardButtonEndRect(WebScrollbar* scrollbar) 132{ 133 WebScrollbarThemeClientImpl client(scrollbar); 134 return m_theme->forwardButtonRect(&client, ForwardButtonEndPart, false); 135} 136 137WebRect WebScrollbarThemeGeometryNative::constrainTrackRectToTrackPieces(WebScrollbar* scrollbar, const WebRect& rect) 138{ 139 WebScrollbarThemeClientImpl client(scrollbar); 140 return m_theme->constrainTrackRectToTrackPieces(&client, IntRect(rect)); 141} 142 143void WebScrollbarThemeGeometryNative::splitTrack(WebScrollbar* scrollbar, const WebRect& webTrack, WebRect& webStartTrack, WebRect& webThumb, WebRect& webEndTrack) 144{ 145 WebScrollbarThemeClientImpl client(scrollbar); 146 IntRect track(webTrack); 147 IntRect startTrack; 148 IntRect thumb; 149 IntRect endTrack; 150 m_theme->splitTrack(&client, track, startTrack, thumb, endTrack); 151 152 webStartTrack = startTrack; 153 webThumb = thumb; 154 webEndTrack = endTrack; 155} 156 157} // namespace blink 158