Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / web / WebPagePopupImpl.h
1 /*
2  * Copyright (C) 2012 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 WebPagePopupImpl_h
32 #define WebPagePopupImpl_h
33
34 #include "core/page/PagePopup.h"
35 #include "public/web/WebPagePopup.h"
36 #include "web/PageWidgetDelegate.h"
37 #include "wtf/OwnPtr.h"
38 #include "wtf/RefCounted.h"
39
40 namespace blink {
41
42 class GraphicsLayer;
43 class Page;
44 class PagePopupChromeClient;
45 class PagePopupClient;
46 class PlatformKeyboardEvent;
47 class WebLayerTreeView;
48 class WebLayer;
49 class WebViewImpl;
50 class LocalDOMWindow;
51
52 class WebPagePopupImpl final
53     : public WebPagePopup
54     , public PageWidgetEventHandler
55     , public PagePopup
56     , public RefCounted<WebPagePopupImpl> {
57     WTF_MAKE_NONCOPYABLE(WebPagePopupImpl);
58     WTF_MAKE_FAST_ALLOCATED;
59
60 public:
61     virtual ~WebPagePopupImpl();
62     bool initialize(WebViewImpl*, PagePopupClient*, const IntRect& originBoundsInRootView);
63     bool handleKeyEvent(const PlatformKeyboardEvent&);
64     void closePopup();
65     WebWidgetClient* widgetClient() const { return m_widgetClient; }
66     bool hasSamePopupClient(WebPagePopupImpl* other) { return other && m_popupClient == other->m_popupClient; }
67     LocalDOMWindow* window();
68     virtual void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) override;
69     virtual WebPoint positionRelativeToOwner() override;
70
71 private:
72     // WebWidget functions
73     virtual WebSize size() override;
74     virtual void beginFrame(const WebBeginFrameArgs&) override;
75     virtual void layout() override;
76     virtual void willCloseLayerTreeView() override;
77     virtual void paint(WebCanvas*, const WebRect&) override;
78     virtual void resize(const WebSize&) override;
79     virtual void close() override;
80     virtual bool handleInputEvent(const WebInputEvent&) override;
81     virtual void setFocus(bool) override;
82     virtual bool isPagePopup() const override { return true; }
83     virtual bool isAcceleratedCompositingActive() const override { return m_isAcceleratedCompositingActive; }
84
85     // PageWidgetEventHandler functions
86     virtual bool handleKeyEvent(const WebKeyboardEvent&) override;
87     virtual bool handleCharEvent(const WebKeyboardEvent&) override;
88     virtual bool handleGestureEvent(const WebGestureEvent&) override;
89
90     // PagePopup function
91     virtual AXObject* rootAXObject() override;
92
93     explicit WebPagePopupImpl(WebWidgetClient*);
94     bool initializePage();
95     void destroyPage();
96     void setRootGraphicsLayer(GraphicsLayer*);
97     void setIsAcceleratedCompositingActive(bool enter);
98
99     WebWidgetClient* m_widgetClient;
100     WebRect m_windowRectInScreen;
101     WebViewImpl* m_webView;
102     OwnPtrWillBePersistent<Page> m_page;
103     OwnPtr<PagePopupChromeClient> m_chromeClient;
104     PagePopupClient* m_popupClient;
105     bool m_closing;
106
107     WebLayerTreeView* m_layerTreeView;
108     WebLayer* m_rootLayer;
109     GraphicsLayer* m_rootGraphicsLayer;
110     bool m_isAcceleratedCompositingActive;
111
112     friend class WebPagePopup;
113     friend class PagePopupChromeClient;
114 };
115
116 DEFINE_TYPE_CASTS(WebPagePopupImpl, WebWidget, widget, widget->isPagePopup(), widget.isPagePopup());
117 // WebPagePopupImpl is the only implementation of PagePopup, so no
118 // further checking required.
119 DEFINE_TYPE_CASTS(WebPagePopupImpl, PagePopup, popup, true, true);
120
121 } // namespace blink
122 #endif // WebPagePopupImpl_h