15267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)/*
25267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * Copyright (C) 2012 Google Inc. All rights reserved.
35267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) *
45267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without
55267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * modification, are permitted provided that the following conditions
65267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * are met:
75267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 1.  Redistributions of source code must retain the above copyright
85267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) *     notice, this list of conditions and the following disclaimer.
95267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * 2.  Redistributions in binary form must reproduce the above copyright
105267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) *     notice, this list of conditions and the following disclaimer in the
115267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) *     documentation and/or other materials provided with the distribution.
125267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) *
135267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
145267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
155267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
175267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
185267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
195267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
205267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
215267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
225267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
235267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) */
245267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
255267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#ifndef WebPluginScrollbar_h
265267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#define WebPluginScrollbar_h
275267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
285267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "../platform/WebCanvas.h"
295267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#include "../platform/WebScrollbar.h"
305267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
3151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)namespace blink {
325267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
335267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebInputEvent;
345267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebPluginContainer;
355267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebPluginScrollbarClient;
365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)struct WebRect;
375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
385267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)class WebPluginScrollbar : public WebScrollbar {
395267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)public:
405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Creates a WebPluginScrollbar for use by a plugin. The plugin container and
415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // client are guaranteed to outlive this object.
4206f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static WebPluginScrollbar* createForPlugin(WebScrollbar::Orientation,
435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)                                                             WebPluginContainer*,
445267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)                                                             WebPluginScrollbarClient*);
455267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
465267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual ~WebPluginScrollbar() { }
475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
485267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Gets the thickness of the scrollbar in pixels.
4906f816c7c76bc45a15e452ade8a34e8af077693eTorne (Richard Coles)    BLINK_EXPORT static int defaultThickness();
505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
515267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Sets the rectangle of the scrollbar.
525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void setLocation(const WebRect&) = 0;
535267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
545267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Sets the size of the scrollable region in pixels, i.e. if a document is
555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // 800x10000 pixels and the viewport is 1000x1000 pixels, then setLocation
565267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // for the vertical scrollbar would have passed in a rectangle like:
575267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    //            (800 - defaultThickness(), 0) (defaultThickness() x 10000)
585267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // and setDocumentSize(10000)
595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void setDocumentSize(int) = 0;
605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
615267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Sets the current value.
625267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void setValue(int position) = 0;
635267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
645267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Scroll back or forward with the given granularity.
655267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void scroll(ScrollDirection, ScrollGranularity, float multiplier) = 0;
665267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
675267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Paint the given rectangle.
685267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual void paint(WebCanvas*, const WebRect&) = 0;
695267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
705267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    // Returns true iff the given event was used.
715267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)    virtual bool handleInputEvent(const WebInputEvent&) = 0;
725267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)};
735267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
7451b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles)} // namespace blink
755267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)
765267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#endif
77