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