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;
51 class WebPagePopupImpl FINAL
53 , public PageWidgetEventHandler
55 , public RefCounted<WebPagePopupImpl> {
56 WTF_MAKE_NONCOPYABLE(WebPagePopupImpl);
57 WTF_MAKE_FAST_ALLOCATED;
60 virtual ~WebPagePopupImpl();
61 bool initialize(WebViewImpl*, PagePopupClient*, const IntRect& originBoundsInRootView);
62 bool handleKeyEvent(const PlatformKeyboardEvent&);
64 WebWidgetClient* widgetClient() const { return m_widgetClient; }
65 bool hasSamePopupClient(WebPagePopupImpl* other) { return other && m_popupClient == other->m_popupClient; }
68 // WebWidget functions
69 virtual WebSize size() OVERRIDE;
70 virtual void beginFrame(const WebBeginFrameArgs&) OVERRIDE;
71 virtual void layout() OVERRIDE;
72 virtual void willCloseLayerTreeView() OVERRIDE;
73 virtual void paint(WebCanvas*, const WebRect&) OVERRIDE;
74 virtual void resize(const WebSize&) OVERRIDE;
75 virtual void close() OVERRIDE;
76 virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE;
77 virtual void setFocus(bool) OVERRIDE;
78 virtual bool isPagePopup() const OVERRIDE { return true; }
79 virtual bool isAcceleratedCompositingActive() const OVERRIDE { return m_isAcceleratedCompositingActive; }
81 // PageWidgetEventHandler functions
82 virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE;
83 virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE;
84 virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE;
86 explicit WebPagePopupImpl(WebWidgetClient*);
87 bool initializePage();
89 void setRootGraphicsLayer(GraphicsLayer*);
90 void setIsAcceleratedCompositingActive(bool enter);
92 WebWidgetClient* m_widgetClient;
93 WebRect m_windowRectInScreen;
94 WebViewImpl* m_webView;
95 OwnPtrWillBePersistent<Page> m_page;
96 OwnPtr<PagePopupChromeClient> m_chromeClient;
97 PagePopupClient* m_popupClient;
100 WebLayerTreeView* m_layerTreeView;
101 WebLayer* m_rootLayer;
102 GraphicsLayer* m_rootGraphicsLayer;
103 bool m_isAcceleratedCompositingActive;
105 friend class WebPagePopup;
106 friend class PagePopupChromeClient;
109 DEFINE_TYPE_CASTS(WebPagePopupImpl, WebWidget, widget, widget->isPagePopup(), widget.isPagePopup());
110 // WebPagePopupImpl is the only implementation of PagePopup, so no
111 // further checking required.
112 DEFINE_TYPE_CASTS(WebPagePopupImpl, PagePopup, popup, true, true);
115 #endif // WebPagePopupImpl_h