• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     WTF_MAKE_FAST_ALLOCATED;
60 public:
61     // WebWidget
62     virtual void close();
size()63     virtual WebSize size() { return m_size; }
64     virtual void resize(const WebSize&);
65     virtual void animate();
66     virtual void layout();
67     virtual void paint(WebCanvas* canvas, const WebRect& rect);
68     virtual void themeChanged();
69     virtual void composite(bool finish);
70     virtual bool handleInputEvent(const WebInputEvent&);
71     virtual void mouseCaptureLost();
72     virtual void setFocus(bool enable);
73     virtual bool setComposition(
74         const WebString& text,
75         const WebVector<WebCompositionUnderline>& underlines,
76         int selectionStart, int selectionEnd);
77     virtual bool confirmComposition();
78     virtual bool confirmComposition(const WebString& text);
79     virtual WebTextInputType textInputType();
80     virtual WebRect caretOrSelectionBounds();
selectionRange(WebPoint & start,WebPoint & end)81     virtual bool selectionRange(WebPoint& start, WebPoint& end) const { return false; }
82     virtual void setTextDirection(WebTextDirection direction);
isAcceleratedCompositingActive()83     virtual bool isAcceleratedCompositingActive() const { return false; }
84 
85     // WebPopupMenuImpl
86     void Init(WebCore::FramelessScrollView* widget,
87               const WebRect& bounds);
88 
client()89     WebWidgetClient* client() { return m_client; }
90 
91     void MouseMove(const WebMouseEvent&);
92     void MouseLeave(const WebMouseEvent&);
93     void MouseDown(const WebMouseEvent&);
94     void MouseUp(const WebMouseEvent&);
95     void MouseDoubleClick(const WebMouseEvent&);
96     void MouseWheel(const WebMouseWheelEvent&);
97     bool KeyEvent(const WebKeyboardEvent&);
98 
99    protected:
100     friend class WebPopupMenu;  // For WebPopupMenu::create
101     friend class WTF::RefCounted<WebPopupMenuImpl>;
102 
103     WebPopupMenuImpl(WebWidgetClient* client);
104     ~WebPopupMenuImpl();
105 
106     // WebCore::HostWindow methods:
107     virtual void invalidateContents(const WebCore::IntRect&, bool);
108     virtual void invalidateWindow(const WebCore::IntRect&, bool);
109     virtual void invalidateContentsAndWindow(const WebCore::IntRect&, bool);
110     virtual void invalidateContentsForSlowScroll(const WebCore::IntRect&, bool);
111     virtual void scheduleAnimation();
112     virtual void scroll(
113         const WebCore::IntSize& scrollDelta, const WebCore::IntRect& scrollRect,
114         const WebCore::IntRect& clipRect);
115     virtual WebCore::IntPoint screenToWindow(const WebCore::IntPoint&) const;
116     virtual WebCore::IntRect windowToScreen(const WebCore::IntRect&) const;
platformPageClient()117     virtual PlatformPageClient platformPageClient() const { return 0; }
118     virtual void scrollRectIntoView(const WebCore::IntRect&, const WebCore::ScrollView*) const;
119     virtual void scrollbarsModeDidChange() const;
120     virtual void setCursor(const WebCore::Cursor&);
121 
122     // WebCore::FramelessScrollViewClient methods:
123     virtual void popupClosed(WebCore::FramelessScrollView*);
124 
125     WebWidgetClient* m_client;
126     WebSize m_size;
127 
128     WebPoint m_lastMousePosition;
129 
130     // This is a non-owning ref.  The popup will notify us via popupClosed()
131     // before it is destroyed.
132     WebCore::FramelessScrollView* m_widget;
133 };
134 
135 } // namespace WebKit
136 
137 #endif
138