2 * Copyright (C) 2012 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 WebPagePopupImpl_h
32 #define WebPagePopupImpl_h
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"
44 class PagePopupChromeClient
;
45 class PagePopupClient
;
46 class PlatformKeyboardEvent
;
47 class WebLayerTreeView
;
52 class WebPagePopupImpl final
54 , public PageWidgetEventHandler
56 , public RefCounted
<WebPagePopupImpl
> {
57 WTF_MAKE_NONCOPYABLE(WebPagePopupImpl
);
58 WTF_MAKE_FAST_ALLOCATED(WebPagePopupImpl
);
61 ~WebPagePopupImpl() override
;
62 bool initialize(WebViewImpl
*, PagePopupClient
*);
63 bool handleKeyEvent(const PlatformKeyboardEvent
&);
65 WebWidgetClient
* widgetClient() const { return m_widgetClient
; }
66 bool hasSamePopupClient(WebPagePopupImpl
* other
) { return other
&& m_popupClient
== other
->m_popupClient
; }
67 LocalDOMWindow
* window();
68 void layoutAndPaintAsync(WebLayoutAndPaintAsyncCallback
*) override
;
69 void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback
*) override
;
70 WebPoint
positionRelativeToOwner() override
;
71 void postMessage(const String
& message
) override
;
75 // WebWidget functions
76 WebSize
size() override
;
77 void beginFrame(const WebBeginFrameArgs
&) override
;
78 void layout() override
;
79 void willCloseLayerTreeView() override
;
80 void paint(WebCanvas
*, const WebRect
&) override
;
81 void resize(const WebSize
&) override
;
82 void close() override
;
83 bool handleInputEvent(const WebInputEvent
&) override
;
84 void setFocus(bool) override
;
85 bool isPagePopup() const override
{ return true; }
86 bool isAcceleratedCompositingActive() const override
{ return m_isAcceleratedCompositingActive
; }
88 // PageWidgetEventHandler functions
89 bool handleKeyEvent(const WebKeyboardEvent
&) override
;
90 bool handleCharEvent(const WebKeyboardEvent
&) override
;
91 bool handleGestureEvent(const WebGestureEvent
&) override
;
92 void handleMouseDown(LocalFrame
& mainFrame
, const WebMouseEvent
&) override
;
93 bool handleMouseWheel(LocalFrame
& mainFrame
, const WebMouseWheelEvent
&) override
;
95 bool isMouseEventInWindow(const WebMouseEvent
&);
96 bool isGestureEventInWindow(const WebGestureEvent
&);
99 AXObject
* rootAXObject() override
;
100 void setWindowRect(const IntRect
&) override
;
102 explicit WebPagePopupImpl(WebWidgetClient
*);
103 bool initializePage();
105 void setRootGraphicsLayer(GraphicsLayer
*);
106 void setIsAcceleratedCompositingActive(bool enter
);
108 WebWidgetClient
* m_widgetClient
;
109 WebRect m_windowRectInScreen
;
110 WebViewImpl
* m_webView
;
111 OwnPtrWillBePersistent
<Page
> m_page
;
112 OwnPtrWillBePersistent
<PagePopupChromeClient
> m_chromeClient
;
113 PagePopupClient
* m_popupClient
;
116 WebLayerTreeView
* m_layerTreeView
;
117 WebLayer
* m_rootLayer
;
118 GraphicsLayer
* m_rootGraphicsLayer
;
119 bool m_isAcceleratedCompositingActive
;
121 friend class WebPagePopup
;
122 friend class PagePopupChromeClient
;
125 DEFINE_TYPE_CASTS(WebPagePopupImpl
, WebWidget
, widget
, widget
->isPagePopup(), widget
.isPagePopup());
126 // WebPagePopupImpl is the only implementation of PagePopup, so no
127 // further checking required.
128 DEFINE_TYPE_CASTS(WebPagePopupImpl
, PagePopup
, popup
, true, true);
131 #endif // WebPagePopupImpl_h