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"
35 #include "WebPopupMenu.h"
36 #include <public/WebPoint.h>
37 #include <public/WebSize.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;
68 // WebWidget functions:
69 virtual void close() OVERRIDE;
70 virtual WebSize size() OVERRIDE { return m_size; }
71 virtual void willStartLiveResize() OVERRIDE;
72 virtual void resize(const WebSize&) OVERRIDE;
73 virtual void willEndLiveResize() OVERRIDE;
74 virtual void animate(double frameBeginTime) OVERRIDE;
75 virtual void layout() OVERRIDE;
76 virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE;
77 virtual void themeChanged() OVERRIDE;
78 virtual void setCompositorSurfaceReady() OVERRIDE;
79 virtual void composite(bool finish) OVERRIDE;
80 virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
81 virtual void mouseCaptureLost() OVERRIDE;
82 virtual void setFocus(bool enable) OVERRIDE;
83 virtual bool setComposition(
84 const WebString& text,
85 const WebVector<WebCompositionUnderline>& underlines,
86 int selectionStart, int selectionEnd) OVERRIDE;
87 virtual bool confirmComposition() OVERRIDE;
88 virtual bool confirmComposition(const WebString& text) OVERRIDE;
89 virtual bool compositionRange(size_t* location, size_t* length) OVERRIDE;
90 virtual WebTextInputType textInputType() OVERRIDE;
91 virtual bool caretOrSelectionRange(size_t* location, size_t* length) OVERRIDE;
92 virtual void setTextDirection(WebTextDirection) OVERRIDE;
93 virtual bool isAcceleratedCompositingActive() const OVERRIDE { return false; }
96 void initialize(WebCore::FramelessScrollView* widget, const WebRect& bounds);
98 WebWidgetClient* client() { return m_client; }
100 void handleMouseMove(const WebMouseEvent&);
101 void handleMouseLeave(const WebMouseEvent&);
102 void handleMouseDown(const WebMouseEvent&);
103 void handleMouseUp(const WebMouseEvent&);
104 void handleMouseDoubleClick(const WebMouseEvent&);
105 void handleMouseWheel(const WebMouseWheelEvent&);
106 bool handleGestureEvent(const WebGestureEvent&);
107 bool handleTouchEvent(const WebTouchEvent&);
108 bool handleKeyEvent(const WebKeyboardEvent&);
111 friend class WebPopupMenu; // For WebPopupMenu::create.
112 friend class WTF::RefCounted<WebPopupMenuImpl>;
114 WebPopupMenuImpl(WebWidgetClient*);
117 // WebCore::HostWindow methods:
118 virtual void invalidateRootView(const WebCore::IntRect&, bool) OVERRIDE;
119 virtual void invalidateContentsAndRootView(const WebCore::IntRect&, bool) OVERRIDE;
120 virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool) OVERRIDE;
121 virtual void scheduleAnimation() OVERRIDE;
123 const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
124 const WebCore::IntRect& clipRect) OVERRIDE;
125 virtual WebCore::IntPoint screenToRootView(const WebCore::IntPoint&) const OVERRIDE;
126 virtual WebCore::IntRect rootViewToScreen(const WebCore::IntRect&) const OVERRIDE;
127 virtual PlatformPageClient platformPageClient() const OVERRIDE { return 0; }
128 virtual void scrollbarsModeDidChange() const OVERRIDE;
129 virtual void setCursor(const WebCore::Cursor&) OVERRIDE;
130 virtual void setCursorHiddenUntilMouseMoves(bool) OVERRIDE;
132 // WebCore::FramelessScrollViewClient methods:
133 virtual void popupClosed(WebCore::FramelessScrollView*) OVERRIDE;
135 WebWidgetClient* m_client;
138 WebPoint m_lastMousePosition;
140 // This is a non-owning ref. The popup will notify us via popupClosed()
141 // before it is destroyed.
142 WebCore::FramelessScrollView* m_widget;
145 } // namespace WebKit