2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
31 #ifndef WebPopupMenuImpl_h
32 #define WebPopupMenuImpl_h
34 #include "FramelessScrollViewClient.h"
36 #include "WebPopupMenu.h"
38 #include <wtf/OwnPtr.h>
39 #include <wtf/RefCounted.h>
43 class FramelessScrollView;
46 #if ENABLE(GESTURE_RECOGNIZER)
47 class PlatformGestureRecognizer;
49 class PlatformKeyboardEvent;
55 class WebGestureEvent;
56 class WebKeyboardEvent;
58 class WebMouseWheelEvent;
63 class WebPopupMenuImpl : public WebPopupMenu,
64 public WebCore::FramelessScrollViewClient,
65 public RefCounted<WebPopupMenuImpl> {
66 WTF_MAKE_FAST_ALLOCATED;
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; }
97 void Init(WebCore::FramelessScrollView* widget,
98 const WebRect& bounds);
100 WebWidgetClient* client() { return m_client; }
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&);
113 friend class WebPopupMenu; // For WebPopupMenu::create
114 friend class WTF::RefCounted<WebPopupMenuImpl>;
116 WebPopupMenuImpl(WebWidgetClient* client);
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();
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);
136 // WebCore::FramelessScrollViewClient methods:
137 virtual void popupClosed(WebCore::FramelessScrollView*);
139 WebWidgetClient* m_client;
142 WebPoint m_lastMousePosition;
144 // This is a non-owning ref. The popup will notify us via popupClosed()
145 // before it is destroyed.
146 WebCore::FramelessScrollView* m_widget;
148 #if ENABLE(GESTURE_RECOGNIZER)
149 OwnPtr<WebCore::PlatformGestureRecognizer> m_gestureRecognizer;
153 } // namespace WebKit