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 "public/web/WebPluginScrollbar.h"
     29 
     30 #include "wtf/RefPtr.h"
     31 #include "wtf/Vector.h"
     32 
     33 namespace blink {
     34 
     35 class IntPoint;
     36 class IntRect;
     37 class Scrollbar;
     38 class ScrollbarGroup;
     39 
     40 class WebPluginScrollbarImpl FINAL : public WebPluginScrollbar {
     41 public:
     42     WebPluginScrollbarImpl(Orientation, ScrollbarGroup*, WebPluginScrollbarClient*);
     43     virtual ~WebPluginScrollbarImpl();
     44 
     45     void setScrollOffset(int);
     46     void invalidateScrollbarRect(const IntRect&);
     47     // FIXME: Combine this with the other getTickmarks method
     48     void getTickmarks(Vector<IntRect>&) const;
     49     IntPoint convertFromContainingViewToScrollbar(const IntPoint& parentPoint) const;
     50     void scrollbarStyleChanged();
     51 
     52     int scrollOffset() { return m_scrollOffset; }
     53     Scrollbar* scrollbar() { return m_scrollbar.get(); }
     54 
     55     // WebScrollbar methods
     56     virtual bool isOverlay() const OVERRIDE;
     57     virtual int value() const OVERRIDE;
     58     virtual WebPoint location() const OVERRIDE;
     59     virtual WebSize size() const OVERRIDE;
     60     virtual bool enabled() const OVERRIDE;
     61     virtual int maximum() const OVERRIDE;
     62     virtual int totalSize() const OVERRIDE;
     63     virtual bool isScrollViewScrollbar() const OVERRIDE;
     64     virtual bool isScrollableAreaActive() const OVERRIDE;
     65     virtual void getTickmarks(WebVector<WebRect>& tickmarks) const OVERRIDE;
     66     virtual WebScrollbar::ScrollbarControlSize controlSize() const OVERRIDE;
     67     virtual WebScrollbar::ScrollbarPart pressedPart() const OVERRIDE;
     68     virtual WebScrollbar::ScrollbarPart hoveredPart() const OVERRIDE;
     69     virtual WebScrollbar::ScrollbarOverlayStyle scrollbarOverlayStyle() const OVERRIDE;
     70     virtual WebScrollbar::Orientation orientation() const OVERRIDE;
     71     virtual bool isLeftSideVerticalScrollbar() const OVERRIDE;
     72     virtual bool isCustomScrollbar() const OVERRIDE;
     73 
     74     // WebPluginScrollbar methods
     75     virtual void setLocation(const WebRect&) OVERRIDE;
     76     virtual void setValue(int position) OVERRIDE;
     77     virtual void setDocumentSize(int) OVERRIDE;
     78     virtual void scroll(ScrollDirection, ScrollGranularity, float multiplier) OVERRIDE;
     79     virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
     80     virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
     81     virtual bool isAlphaLocked() const OVERRIDE;
     82     virtual void setIsAlphaLocked(bool) OVERRIDE;
     83 
     84 private:
     85     bool onMouseDown(const WebInputEvent&);
     86     bool onMouseUp(const WebInputEvent&);
     87     bool onMouseMove(const WebInputEvent&);
     88     bool onMouseLeave(const WebInputEvent&);
     89     bool onMouseWheel(const WebInputEvent&);
     90     bool onKeyDown(const WebInputEvent&);
     91 
     92     ScrollbarGroup* m_group;
     93     WebPluginScrollbarClient* m_client;
     94 
     95     int m_scrollOffset;
     96     RefPtr<Scrollbar> m_scrollbar;
     97 };
     98 
     99 } // namespace blink
    100 
    101 #endif
    102