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;
61 virtual ~WebPagePopupImpl();
62 bool initialize(WebViewImpl*, PagePopupClient*, const IntRect& originBoundsInRootView);
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 virtual void compositeAndReadbackAsync(WebCompositeAndReadbackAsyncCallback*) override;
69 virtual WebPoint positionRelativeToOwner() override;
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; }
85 // PageWidgetEventHandler functions
86 virtual bool handleKeyEvent(const WebKeyboardEvent&) override;
87 virtual bool handleCharEvent(const WebKeyboardEvent&) override;
88 virtual bool handleGestureEvent(const WebGestureEvent&) override;
91 virtual AXObject* rootAXObject() override;
93 explicit WebPagePopupImpl(WebWidgetClient*);
94 bool initializePage();
96 void setRootGraphicsLayer(GraphicsLayer*);
97 void setIsAcceleratedCompositingActive(bool enter);
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;
107 WebLayerTreeView* m_layerTreeView;
108 WebLayer* m_rootLayer;
109 GraphicsLayer* m_rootGraphicsLayer;
110 bool m_isAcceleratedCompositingActive;
112 friend class WebPagePopup;
113 friend class PagePopupChromeClient;
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);
122 #endif // WebPagePopupImpl_h