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 WebCore { 41 class GraphicsLayer; 42 class Page; 43 class PagePopupClient; 44 class PlatformKeyboardEvent; 45 } 46 47 namespace blink { 48 49 class PagePopupChromeClient; 50 class WebLayerTreeView; 51 class WebLayer; 52 class WebViewImpl; 53 54 class WebPagePopupImpl FINAL : 55 public WebPagePopup, 56 public PageWidgetEventHandler, 57 public WebCore::PagePopup, 58 public RefCounted<WebPagePopupImpl> { 59 WTF_MAKE_NONCOPYABLE(WebPagePopupImpl); 60 WTF_MAKE_FAST_ALLOCATED; 61 62 public: 63 virtual ~WebPagePopupImpl(); 64 bool initialize(WebViewImpl*, WebCore::PagePopupClient*, const WebCore::IntRect& originBoundsInRootView); 65 bool handleKeyEvent(const WebCore::PlatformKeyboardEvent&); 66 void closePopup(); widgetClient()67 WebWidgetClient* widgetClient() const { return m_widgetClient; } hasSamePopupClient(WebPagePopupImpl * other)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; 74 virtual void layout() OVERRIDE; 75 virtual void willCloseLayerTreeView() OVERRIDE; 76 virtual void paint(WebCanvas*, const WebRect&) OVERRIDE; 77 virtual void resize(const WebSize&) OVERRIDE; 78 virtual void close() OVERRIDE; 79 virtual bool handleInputEvent(const WebInputEvent&) OVERRIDE; 80 virtual void setFocus(bool) OVERRIDE; isPagePopup()81 virtual bool isPagePopup() const OVERRIDE { return true; } isAcceleratedCompositingActive()82 virtual bool isAcceleratedCompositingActive() const OVERRIDE { return m_isAcceleratedCompositingActive; } 83 84 // PageWidgetEventHandler functions 85 virtual bool handleKeyEvent(const WebKeyboardEvent&) OVERRIDE; 86 virtual bool handleCharEvent(const WebKeyboardEvent&) OVERRIDE; 87 virtual bool handleGestureEvent(const WebGestureEvent&) OVERRIDE; 88 89 explicit WebPagePopupImpl(WebWidgetClient*); 90 bool initializePage(); 91 void destroyPage(); 92 void setRootGraphicsLayer(WebCore::GraphicsLayer*); 93 void setIsAcceleratedCompositingActive(bool enter); 94 95 WebWidgetClient* m_widgetClient; 96 WebRect m_windowRectInScreen; 97 WebViewImpl* m_webView; 98 OwnPtrWillBePersistent<WebCore::Page> m_page; 99 OwnPtr<PagePopupChromeClient> m_chromeClient; 100 WebCore::PagePopupClient* m_popupClient; 101 bool m_closing; 102 103 WebLayerTreeView* m_layerTreeView; 104 WebLayer* m_rootLayer; 105 WebCore::GraphicsLayer* m_rootGraphicsLayer; 106 bool m_isAcceleratedCompositingActive; 107 108 friend class WebPagePopup; 109 friend class PagePopupChromeClient; 110 }; 111 112 DEFINE_TYPE_CASTS(WebPagePopupImpl, WebWidget, widget, widget->isPagePopup(), widget.isPagePopup()); 113 // WebPagePopupImpl is the only implementation of WebCore::PagePopup, so no 114 // further checking required. 115 DEFINE_TYPE_CASTS(WebPagePopupImpl, WebCore::PagePopup, popup, true, true); 116 117 } // namespace blink 118 #endif // WebPagePopupImpl_h 119