15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (C) 1999 Antti Koivisto (koivisto@kde.org) 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is free software; you can redistribute it and/or 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modify it under the terms of the GNU Library General Public 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * License as published by the Free Software Foundation; either 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * version 2 of the License, or (at your option) any later version. 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * This library is distributed in the hope that it will be useful, 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * but WITHOUT ANY WARRANTY; without even the implied warranty of 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Library General Public License for more details. 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * You should have received a copy of the GNU Library General Public License 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * along with this library; see the file COPYING.LIB. If not, write to 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Boston, MA 02110-1301, USA. 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef HTMLPlugInElement_h 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define HTMLPlugInElement_h 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 261e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles)#include "bindings/v8/SharedPersistent.h" 2753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/html/HTMLFrameOwnerElement.h" 28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)struct NPObject; 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace WebCore { 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 33f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)class HTMLImageLoader; 345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class RenderEmbeddedObject; 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class RenderWidget; 365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class Widget; 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 38f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)enum PreferPlugInsForImagesOption { 39f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) ShouldPreferPlugInsForImages, 40f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) ShouldNotPreferPlugInsForImages 41f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles)}; 42f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class HTMLPlugInElement : public HTMLFrameOwnerElement { 445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual ~HTMLPlugInElement(); 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void resetInstance(); 481e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) SharedPersistent<v8::Object>* pluginWrapper(); 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Widget* pluginWidget() const; 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) NPObject* getNPObject(); 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool canProcessDrag() const; 52f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) const String& url() const { return m_url; } 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 54f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // Public for FrameView::addWidgetToUpdate() 55f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } 56f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; } 57a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) void updateWidget(); 58c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles) 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)protected: 60f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) HTMLPlugInElement(const QualifiedName& tagName, Document&, bool createdByParser, PreferPlugInsForImagesOption); 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 62f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // Node functions: 63f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE; 64f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual bool dispatchBeforeLoadEvent(const String& sourceURL) OVERRIDE; 65f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) 66f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // Element functions: 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE; 68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE; 695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 70a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) virtual bool useFallbackContent() const; 71f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // Create or update the RenderWidget and return it, triggering layout if 72f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // necessary. 73f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual RenderWidget* renderWidgetForJSBindings() const; 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 75f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool isImageType(); 76f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool shouldPreferPlugInsForImages() const { return m_shouldPreferPlugInsForImages; } 77f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) RenderEmbeddedObject* renderEmbeddedObject() const; 78f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool allowedToLoadFrameURL(const String& url); 79f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues); 80f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback); 81926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 82f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) String m_serviceType; 83f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) String m_url; 84f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) KURL m_loadedUrl; 85f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) OwnPtr<HTMLImageLoader> m_imageLoader; 86a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) bool m_isDelayingLoadEvent; 87c0e19a689c8ac22cdc96b291a8d33a5d3b0b34a4Torne (Richard Coles) 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 89f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // EventTarget functions: 90f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual void removeAllEventListeners() OVERRIDE FINAL; 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 92f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // Node functions: 93f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual bool canContainRangeEndPoint() const OVERRIDE { return false; } 94f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual bool willRespondToMouseClickEvents() OVERRIDE; 95f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual void defaultEventHandler(Event*) OVERRIDE; 96f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual void attach(const AttachContext& = AttachContext()) OVERRIDE; 97f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual void detach(const AttachContext& = AttachContext()) OVERRIDE; 98f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual void finishParsingChildren() OVERRIDE; 99f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual bool isPluginElement() const OVERRIDE; 1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 101f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // Element functions: 102f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE; 103f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual void willRecalcStyle(StyleRecalcChange) OVERRIDE FINAL; 104521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) virtual bool supportsFocus() const OVERRIDE { return true; }; 105521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) virtual bool rendererIsFocusable() const OVERRIDE; 106f5e4ad553afbc08dd2e729bb77e937a9a94d5827Torne (Richard Coles) virtual bool isKeyboardFocusable() const OVERRIDE; 107a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE; 108a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) virtual void didAddShadowRoot(ShadowRoot&) OVERRIDE; 109f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) 110f21500f839d2ad369a2bd176fb90f26895a9a097Ben Murdoch // HTMLElement function: 111f21500f839d2ad369a2bd176fb90f26895a9a097Ben Murdoch virtual bool hasCustomFocusLogic() const OVERRIDE; 112f21500f839d2ad369a2bd176fb90f26895a9a097Ben Murdoch 113f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // Return any existing RenderWidget without triggering relayout, or 0 if it 114f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) // doesn't yet exist. 115f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) virtual RenderWidget* existingRenderWidget() const = 0; 116a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) virtual void updateWidgetInternal() = 0; 117f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) 118f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) enum DisplayState { 119f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) Restarting, 120f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) RestartingWithPendingMouseClick, 121f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) Playing 122f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) }; 123f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) DisplayState displayState() const { return m_displayState; } 124f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) void setDisplayState(DisplayState state) { m_displayState = state; } 125f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) const String loadedMimeType() const; 126f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool loadPlugin(const KURL&, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback); 127f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool pluginIsLoadable(const KURL&, const String& mimeType); 128a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType); 1295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1301e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) mutable RefPtr<SharedPersistent<v8::Object> > m_pluginWrapper; 1315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) NPObject* m_NPObject; 1325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) bool m_isCapturingMouseEvents; 13353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) bool m_inBeforeLoadEventHandler; 134f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool m_needsWidgetUpdate; 135f79f16f17ddc4f842d7b7a38603e280e94be826aTorne (Richard Coles) bool m_shouldPreferPlugInsForImages; 1365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DisplayState m_displayState; 1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 139bfe3590b1806e3ff18f46ee3af5d4b83078f305aTorne (Richard Coles)DEFINE_NODE_TYPE_CASTS(HTMLPlugInElement, isPluginElement()); 140926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 1415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace WebCore 1425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // HTMLPlugInElement_h 144