initial import
[vuplus_webkit] / Source / WebKit / chromium / src / WebPopupMenuImpl.h
1 /*
2  * Copyright (C) 2009 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 are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #ifndef WebPopupMenuImpl_h
32 #define WebPopupMenuImpl_h
33
34 #include "FramelessScrollViewClient.h"
35 #include "WebPoint.h"
36 #include "WebPopupMenu.h"
37 #include "WebSize.h"
38 #include <wtf/OwnPtr.h>
39 #include <wtf/RefCounted.h>
40
41 namespace WebCore {
42 class Frame;
43 class FramelessScrollView;
44 class KeyboardEvent;
45 class Page;
46 #if ENABLE(GESTURE_RECOGNIZER)
47 class PlatformGestureRecognizer;
48 #endif
49 class PlatformKeyboardEvent;
50 class Range;
51 class Widget;
52 }
53
54 namespace WebKit {
55 class WebGestureEvent;
56 class WebKeyboardEvent;
57 class WebMouseEvent;
58 class WebMouseWheelEvent;
59 class WebRange;
60 struct WebRect;
61 class WebTouchEvent;
62
63 class WebPopupMenuImpl : public WebPopupMenu,
64                          public WebCore::FramelessScrollViewClient,
65                          public RefCounted<WebPopupMenuImpl> {
66     WTF_MAKE_FAST_ALLOCATED;
67 public:
68     // WebWidget
69     virtual void close();
70     virtual WebSize size() { return m_size; }
71     virtual void willStartLiveResize();
72     virtual void resize(const WebSize&);
73     virtual void willEndLiveResize();
74     virtual void animate(double frameBeginTime);
75     virtual void layout();
76     virtual void paint(WebCanvas* canvas, const WebRect& rect);
77     virtual void themeChanged();
78     virtual void composite(bool finish);
79     virtual bool handleInputEvent(const WebInputEvent&);
80     virtual void mouseCaptureLost();
81     virtual void setFocus(bool enable);
82     virtual bool setComposition(
83         const WebString& text,
84         const WebVector<WebCompositionUnderline>& underlines,
85         int selectionStart, int selectionEnd);
86     virtual bool confirmComposition();
87     virtual bool confirmComposition(const WebString& text);
88     virtual bool compositionRange(size_t* location, size_t* length);
89     virtual WebTextInputType textInputType();
90     virtual WebRect caretOrSelectionBounds();
91     virtual bool selectionRange(WebPoint& start, WebPoint& end) const { return false; }
92     virtual bool caretOrSelectionRange(size_t* location, size_t* length);
93     virtual void setTextDirection(WebTextDirection direction);
94     virtual bool isAcceleratedCompositingActive() const { return false; }
95
96     // WebPopupMenuImpl
97     void Init(WebCore::FramelessScrollView* widget,
98               const WebRect& bounds);
99
100     WebWidgetClient* client() { return m_client; }
101
102     void MouseMove(const WebMouseEvent&);
103     void MouseLeave(const WebMouseEvent&);
104     void MouseDown(const WebMouseEvent&);
105     void MouseUp(const WebMouseEvent&);
106     void MouseDoubleClick(const WebMouseEvent&);
107     void MouseWheel(const WebMouseWheelEvent&);
108     bool GestureEvent(const WebGestureEvent&);
109     bool TouchEvent(const WebTouchEvent&);
110     bool KeyEvent(const WebKeyboardEvent&);
111
112    protected:
113     friend class WebPopupMenu;  // For WebPopupMenu::create
114     friend class WTF::RefCounted<WebPopupMenuImpl>;
115
116     WebPopupMenuImpl(WebWidgetClient* client);
117     ~WebPopupMenuImpl();
118
119     // WebCore::HostWindow methods:
120     virtual void invalidateContents(const WebCore::IntRect&, bool);
121     virtual void invalidateWindow(const WebCore::IntRect&, bool);
122     virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
123     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
124     virtual void scheduleAnimation();
125     virtual void scroll(
126         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
127         const WebCore::IntRect& clipRect);
128     virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
129     virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
130     virtual PlatformPageClient platformPageClient() const { return 0; }
131     virtual void scrollRectIntoView(const WebCore::IntRect&) const;
132     virtual void scrollbarsModeDidChange() const;
133     virtual void setCursor(const WebCore::Cursor&);
134     virtual void setCursorHiddenUntilMouseMoves(bool);
135
136     // WebCore::FramelessScrollViewClient methods:
137     virtual void popupClosed(WebCore::FramelessScrollView*);
138
139     WebWidgetClient* m_client;
140     WebSize m_size;
141
142     WebPoint m_lastMousePosition;
143
144     // This is a non-owning ref.  The popup will notify us via popupClosed()
145     // before it is destroyed.
146     WebCore::FramelessScrollView* m_widget;
147
148 #if ENABLE(GESTURE_RECOGNIZER)
149     OwnPtr<WebCore::PlatformGestureRecognizer> m_gestureRecognizer;
150 #endif
151 };
152
153 } // namespace WebKit
154
155 #endif