|
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/RefCounted.h> |
|
39 |
|
40 namespace WebCore { |
|
41 class Frame; |
|
42 class FramelessScrollView; |
|
43 class KeyboardEvent; |
|
44 class Page; |
|
45 class PlatformKeyboardEvent; |
|
46 class Range; |
|
47 class Widget; |
|
48 } |
|
49 |
|
50 namespace WebKit { |
|
51 class WebKeyboardEvent; |
|
52 class WebMouseEvent; |
|
53 class WebMouseWheelEvent; |
|
54 struct WebRect; |
|
55 |
|
56 class WebPopupMenuImpl : public WebPopupMenu, |
|
57 public WebCore::FramelessScrollViewClient, |
|
58 public RefCounted<WebPopupMenuImpl> { |
|
59 public: |
|
60 // WebWidget |
|
61 virtual void close(); |
|
62 virtual WebSize size() { return m_size; } |
|
63 virtual void resize(const WebSize&); |
|
64 virtual void layout(); |
|
65 virtual void paint(WebCanvas* canvas, const WebRect& rect); |
|
66 virtual bool handleInputEvent(const WebInputEvent&); |
|
67 virtual void mouseCaptureLost(); |
|
68 virtual void setFocus(bool enable); |
|
69 virtual bool setComposition( |
|
70 const WebString& text, |
|
71 const WebVector<WebCompositionUnderline>& underlines, |
|
72 int selectionStart, int selectionEnd); |
|
73 virtual bool confirmComposition(); |
|
74 virtual WebTextInputType textInputType(); |
|
75 virtual WebRect caretOrSelectionBounds(); |
|
76 virtual void setTextDirection(WebTextDirection direction); |
|
77 virtual bool isAcceleratedCompositingActive() const { return false; } |
|
78 |
|
79 // WebPopupMenuImpl |
|
80 void Init(WebCore::FramelessScrollView* widget, |
|
81 const WebRect& bounds); |
|
82 |
|
83 WebWidgetClient* client() { return m_client; } |
|
84 |
|
85 void MouseMove(const WebMouseEvent&); |
|
86 void MouseLeave(const WebMouseEvent&); |
|
87 void MouseDown(const WebMouseEvent&); |
|
88 void MouseUp(const WebMouseEvent&); |
|
89 void MouseDoubleClick(const WebMouseEvent&); |
|
90 void MouseWheel(const WebMouseWheelEvent&); |
|
91 bool KeyEvent(const WebKeyboardEvent&); |
|
92 |
|
93 protected: |
|
94 friend class WebPopupMenu; // For WebPopupMenu::create |
|
95 friend class WTF::RefCounted<WebPopupMenuImpl>; |
|
96 |
|
97 WebPopupMenuImpl(WebWidgetClient* client); |
|
98 ~WebPopupMenuImpl(); |
|
99 |
|
100 // WebCore::HostWindow methods: |
|
101 virtual void invalidateContents(const WebCore::IntRect&, bool); |
|
102 virtual void invalidateWindow(const WebCore::IntRect&, bool); |
|
103 virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool); |
|
104 virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool); |
|
105 virtual void scroll( |
|
106 const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect, |
|
107 const WebCore::IntRect& clipRect); |
|
108 virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const; |
|
109 virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const; |
|
110 virtual PlatformPageClient platformPageClient() const { return 0; } |
|
111 virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const; |
|
112 virtual void scrollbarsModeDidChange() const; |
|
113 virtual void setCursor(const WebCore::Cursor&); |
|
114 |
|
115 // WebCore::FramelessScrollViewClient methods: |
|
116 virtual void popupClosed(WebCore::FramelessScrollView*); |
|
117 |
|
118 WebWidgetClient* m_client; |
|
119 WebSize m_size; |
|
120 |
|
121 WebPoint m_lastMousePosition; |
|
122 |
|
123 // This is a non-owning ref. The popup will notify us via popupClosed() |
|
124 // before it is destroyed. |
|
125 WebCore::FramelessScrollView* m_widget; |
|
126 }; |
|
127 |
|
128 } // namespace WebKit |
|
129 |
|
130 #endif |