Home | History | Annotate | Download | only in web
      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  * 1.  Redistributions of source code must retain the above copyright
      8  *     notice, this list of conditions and the following disclaimer.
      9  * 2.  Redistributions in binary form must reproduce the above copyright
     10  *     notice, this list of conditions and the following disclaimer in the
     11  *     documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     16  * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     18  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     19  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
     20  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     22  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     23  */
     24 
     25 #ifndef WebPluginScrollbarImpl_h
     26 #define WebPluginScrollbarImpl_h
     27 
     28 #include "WebPluginScrollbar.h"
     29 
     30 #include "wtf/RefPtr.h"
     31 #include "wtf/Vector.h"
     32 
     33 namespace WebCore {
     34 class IntPoint;
     35 class IntRect;
     36 class Scrollbar;
     37 }
     38 
     39 namespace blink {
     40 
     41 class ScrollbarGroup;
     42 
     43 class WebPluginScrollbarImpl : public WebPluginScrollbar {
     44 public:
     45     WebPluginScrollbarImpl(Orientation, ScrollbarGroup*, WebPluginScrollbarClient*);
     46     ~WebPluginScrollbarImpl();
     47 
     48     void setScrollOffset(int);
     49     void invalidateScrollbarRect(const WebCore::IntRect&);
     50     // FIXME: Combine this with the other getTickmarks method
     51     void getTickmarks(Vector<WebCore::IntRect>&) const;
     52     WebCore::IntPoint convertFromContainingViewToScrollbar(const WebCore::IntPoint& parentPoint) const;
     53     void scrollbarStyleChanged();
     54 
     55     int scrollOffset() { return m_scrollOffset; }
     56     WebCore::Scrollbar* scrollbar() { return m_scrollbar.get(); }
     57 
     58     // blink::WebScrollbar methods
     59     virtual bool isOverlay() const OVERRIDE;
     60     virtual int value() const OVERRIDE;
     61     virtual WebPoint location() const OVERRIDE;
     62     virtual WebSize size() const OVERRIDE;
     63     virtual bool enabled() const OVERRIDE;
     64     virtual int maximum() const OVERRIDE;
     65     virtual int totalSize() const OVERRIDE;
     66     virtual bool isScrollViewScrollbar() const OVERRIDE;
     67     virtual bool isScrollableAreaActive() const OVERRIDE;
     68     virtual void getTickmarks(WebVector<WebRect>& tickmarks) const OVERRIDE;
     69     virtual WebScrollbar::ScrollbarControlSize controlSize() const OVERRIDE;
     70     virtual WebScrollbar::ScrollbarPart pressedPart() const OVERRIDE;
     71     virtual WebScrollbar::ScrollbarPart hoveredPart() const OVERRIDE;
     72     virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() const OVERRIDE;
     73     virtual WebScrollbar::Orientation orientation() const OVERRIDE;
     74     virtual bool isLeftSideVerticalScrollbar() const OVERRIDE;
     75     virtual bool isCustomScrollbar() const OVERRIDE;
     76 
     77     // blink::WebPluginScrollbar methods
     78     virtual void setLocation(const WebRect&) OVERRIDE;
     79     virtual void setValue(int position) OVERRIDE;
     80     virtual void setDocumentSize(int) OVERRIDE;
     81     virtual void scroll(ScrollDirection, ScrollGranularity, float multiplier) OVERRIDE;
     82     virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
     83     virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
     84     virtual bool isAlphaLocked() const OVERRIDE;
     85     virtual void setIsAlphaLocked(bool) OVERRIDE;
     86 
     87 private:
     88     bool onMouseDown(const WebInputEvent&);
     89     bool onMouseUp(const WebInputEvent&);
     90     bool onMouseMove(const WebInputEvent&);
     91     bool onMouseLeave(const WebInputEvent&);
     92     bool onMouseWheel(const WebInputEvent&);
     93     bool onKeyDown(const WebInputEvent&);
     94 
     95     ScrollbarGroup* m_group;
     96     WebPluginScrollbarClient* m_client;
     97 
     98     int m_scrollOffset;
     99     RefPtr<WebCore::Scrollbar> m_scrollbar;
    100 };
    101 
    102 } // namespace blink
    103 
    104 #endif
    105