Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 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 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 34 | #include "PageWidgetDelegate.h" |
| 35 | #include "WebPagePopup.h" |
Torne (Richard Coles) | 53e740f | 2013-05-09 18:38:43 +0100 | [diff] [blame] | 36 | #include "core/page/PagePopup.h" |
Ben Murdoch | 591b958 | 2013-07-10 11:41:44 +0100 | [diff] [blame] | 37 | #include "wtf/OwnPtr.h" |
| 38 | #include "wtf/RefCounted.h" |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 39 | |
| 40 | namespace WebCore { |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 41 | class GraphicsLayer; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 42 | class Page; |
| 43 | class PagePopupClient; |
| 44 | class PlatformKeyboardEvent; |
| 45 | } |
| 46 | |
Torne (Richard Coles) | 51b2906 | 2013-11-28 11:56:03 +0000 | [diff] [blame] | 47 | namespace blink { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 48 | |
| 49 | class PagePopupChromeClient; |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 50 | class WebLayerTreeView; |
| 51 | class WebLayer; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 52 | class WebViewImpl; |
| 53 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 54 | class WebPagePopupImpl FINAL : |
| 55 | public WebPagePopup, |
| 56 | public PageWidgetEventHandler, |
| 57 | public WebCore::PagePopup, |
| 58 | public RefCounted<WebPagePopupImpl> { |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 59 | WTF_MAKE_NONCOPYABLE(WebPagePopupImpl); |
| 60 | WTF_MAKE_FAST_ALLOCATED; |
| 61 | |
| 62 | public: |
| 63 | virtual ~WebPagePopupImpl(); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 64 | bool initialize(WebViewImpl*, WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 65 | bool handleKeyEvent(const WebCore::PlatformKeyboardEvent&); |
| 66 | void closePopup(); |
| 67 | WebWidgetClient* widgetClient() const { return m_widgetClient; } |
| 68 | bool hasSamePopupClient(WebPagePopupImpl* other) { return other && m_popupClient == other->m_popupClient; } |
| 69 | |
| 70 | private: |
| 71 | // WebWidget functions |
| 72 | virtual WebSize size() OVERRIDE; |
| 73 | virtual void animate(double) OVERRIDE; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 74 | virtual void layout() OVERRIDE; |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 75 | virtual void enterForceCompositingMode(bool enter) OVERRIDE; |
| 76 | virtual void didExitCompositingMode() OVERRIDE; |
| 77 | virtual void willCloseLayerTreeView() OVERRIDE; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 78 | virtual void paint(WebCanvas*, const WebRect&, PaintOptions = ReadbackFromCompositorIfAvailable) OVERRIDE; |
| 79 | virtual void resize(const WebSize&) OVERRIDE; |
| 80 | virtual void close() OVERRIDE; |
| 81 | virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE; |
| 82 | virtual void setFocus(bool) OVERRIDE; |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 83 | virtual bool isPagePopup() const OVERRIDE { return true; } |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 84 | |
| 85 | // PageWidgetEventHandler functions |
| 86 | virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE; |
| 87 | virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 88 | virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE; |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 89 | |
| 90 | explicit WebPagePopupImpl(WebWidgetClient*); |
Torne (Richard Coles) | 926b001 | 2013-03-28 15:32:48 +0000 | [diff] [blame] | 91 | bool initializePage(); |
| 92 | void destroyPage(); |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 93 | void setRootGraphicsLayer(WebCore::GraphicsLayer*); |
| 94 | void setIsAcceleratedCompositingActive(bool enter); |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 95 | |
| 96 | WebWidgetClient* m_widgetClient; |
| 97 | WebRect m_windowRectInScreen; |
| 98 | WebViewImpl* m_webView; |
| 99 | OwnPtr<WebCore::Page> m_page; |
| 100 | OwnPtr<PagePopupChromeClient> m_chromeClient; |
| 101 | WebCore::PagePopupClient* m_popupClient; |
| 102 | bool m_closing; |
| 103 | |
Torne (Richard Coles) | d5428f3 | 2014-03-18 10:21:16 +0000 | [diff] [blame] | 104 | WebLayerTreeView* m_layerTreeView; |
| 105 | WebLayer* m_rootLayer; |
| 106 | WebCore::GraphicsLayer* m_rootGraphicsLayer; |
| 107 | bool m_isAcceleratedCompositingActive; |
| 108 | |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 109 | friend class WebPagePopup; |
| 110 | friend class PagePopupChromeClient; |
| 111 | }; |
| 112 | |
Torne (Richard Coles) | 0938029 | 2014-02-21 12:17:33 +0000 | [diff] [blame] | 113 | DEFINE_TYPE_CASTS(WebPagePopupImpl, WebWidget, widget, widget->isPagePopup(), widget.isPagePopup()); |
| 114 | // WebPagePopupImpl is the only implementation of WebCore::PagePopup, so no |
| 115 | // further checking required. |
| 116 | DEFINE_TYPE_CASTS(WebPagePopupImpl, WebCore::PagePopup, popup, true, true); |
Torne (Richard Coles) | 1e20218 | 2013-10-18 15:46:42 +0100 | [diff] [blame] | 117 | |
Torne (Richard Coles) | 51b2906 | 2013-11-28 11:56:03 +0000 | [diff] [blame] | 118 | } // namespace blink |
Torne (Richard Coles) | 5c87bf8 | 2012-11-14 11:46:17 +0000 | [diff] [blame] | 119 | #endif // WebPagePopupImpl_h |