OLD | NEW |
| (Empty) |
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 "platform/graphics/paint/DisplayItemClient.h" | |
35 #include "public/platform/WebContentLayerClient.h" | |
36 #include "public/platform/WebPoint.h" | |
37 #include "public/platform/WebSize.h" | |
38 #include "public/web/WebPopupMenu.h" | |
39 #include "web/PopupContainerClient.h" | |
40 #include "wtf/OwnPtr.h" | |
41 #include "wtf/RefCounted.h" | |
42 | |
43 namespace blink { | |
44 | |
45 class DisplayItemList; | |
46 class WebContentLayer; | |
47 class WebGestureEvent; | |
48 class WebKeyboardEvent; | |
49 class WebLayerTreeView; | |
50 class WebMouseEvent; | |
51 class WebMouseWheelEvent; | |
52 class WebTouchEvent; | |
53 struct WebRect; | |
54 | |
55 class WebPopupMenuImpl : public WebPopupMenu, public PopupContainerClient, publi
c WebContentLayerClient, public RefCounted<WebPopupMenuImpl> { | |
56 WTF_MAKE_FAST_ALLOCATED(WebPopupMenuImpl); | |
57 public: | |
58 // WebWidget functions: | |
59 virtual void close() override final; | |
60 virtual WebSize size() override final { return m_size; } | |
61 virtual void willStartLiveResize() override final; | |
62 virtual void resize(const WebSize&) override final; | |
63 virtual void willEndLiveResize() override final; | |
64 virtual void beginFrame(const WebBeginFrameArgs&) override final; | |
65 virtual void layout() override final; | |
66 virtual void paint(WebCanvas*, const WebRect&) override final; | |
67 virtual void themeChanged() override final; | |
68 virtual bool handleInputEvent(const WebInputEvent&) override final; | |
69 virtual void mouseCaptureLost() override final; | |
70 virtual void setFocus(bool enable) override final; | |
71 virtual bool setComposition( | |
72 const WebString& text, | |
73 const WebVector<WebCompositionUnderline>& underlines, | |
74 int selectionStart, int selectionEnd) override final; | |
75 virtual bool confirmComposition() override final; | |
76 virtual bool confirmComposition(ConfirmCompositionBehavior selectionBehavior
) override final; | |
77 virtual bool confirmComposition(const WebString& text) override final; | |
78 virtual bool compositionRange(size_t* location, size_t* length) override fin
al; | |
79 virtual bool caretOrSelectionRange(size_t* location, size_t* length) overrid
e final; | |
80 virtual void setTextDirection(WebTextDirection) override final; | |
81 virtual bool isAcceleratedCompositingActive() const override final { return
false; } | |
82 virtual bool isPopupMenu() const override final { return true; } | |
83 virtual void willCloseLayerTreeView() override final; | |
84 | |
85 // WebContentLayerClient | |
86 virtual void paintContents(WebCanvas*, const WebRect& clip, WebContentLayerC
lient::PaintingControlSetting = PaintDefaultBehavior) override final; | |
87 virtual void paintContents(WebDisplayItemList*, const WebRect& clip, WebCont
entLayerClient::PaintingControlSetting = PaintDefaultBehavior) override final; | |
88 | |
89 // WebPopupMenuImpl | |
90 void initialize(PopupContainer* widget, const WebRect& bounds); | |
91 | |
92 WebWidgetClient* client() { return m_client; } | |
93 | |
94 void handleMouseMove(const WebMouseEvent&); | |
95 void handleMouseLeave(const WebMouseEvent&); | |
96 void handleMouseDown(const WebMouseEvent&); | |
97 void handleMouseUp(const WebMouseEvent&); | |
98 void handleMouseDoubleClick(const WebMouseEvent&); | |
99 void handleMouseWheel(const WebMouseWheelEvent&); | |
100 bool handleGestureEvent(const WebGestureEvent&); | |
101 bool handleTouchEvent(const WebTouchEvent&); | |
102 bool handleKeyEvent(const WebKeyboardEvent&); | |
103 | |
104 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi
s); } | |
105 String debugName() const { return "WebPopupMenuImpl"; } | |
106 | |
107 protected: | |
108 friend class WebPopupMenu; // For WebPopupMenu::create. | |
109 friend class WTF::RefCounted<WebPopupMenuImpl>; | |
110 | |
111 explicit WebPopupMenuImpl(WebWidgetClient*); | |
112 ~WebPopupMenuImpl(); | |
113 | |
114 // HostWindow methods: | |
115 virtual void invalidateRect(const IntRect&) override final; | |
116 virtual void scheduleAnimation() override final; | |
117 virtual IntRect viewportToScreen(const IntRect&) const override final; | |
118 | |
119 // PopupContainerClient methods: | |
120 virtual void popupClosed(PopupContainer*) override final; | |
121 void invalidateDisplayItemClient(DisplayItemClient) override final; | |
122 void invalidateAllDisplayItems() override final; | |
123 | |
124 WebWidgetClient* m_client; | |
125 WebSize m_size; | |
126 | |
127 WebLayerTreeView* m_layerTreeView; | |
128 OwnPtr<WebContentLayer> m_rootLayer; | |
129 | |
130 WebPoint m_lastMousePosition; | |
131 | |
132 // This is a non-owning ref. The popup will notify us via popupClosed() | |
133 // before it is destroyed. | |
134 PopupContainer* m_widget; | |
135 | |
136 OwnPtr<DisplayItemList> m_displayItemList; | |
137 }; | |
138 | |
139 DEFINE_TYPE_CASTS(WebPopupMenuImpl, WebWidget, widget, widget->isPopupMenu(), wi
dget.isPopupMenu()); | |
140 // WebPopupMenuImpl is the only implementation of PopupContainerClient, so | |
141 // no need for further checking. | |
142 DEFINE_TYPE_CASTS(WebPopupMenuImpl, PopupContainerClient, client, true, true); | |
143 | |
144 } // namespace blink | |
145 | |
146 #endif | |
OLD | NEW |