2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
23 #ifndef HTMLPlugInElement_h
24 #define HTMLPlugInElement_h
26 #include "bindings/v8/SharedPersistent.h"
27 #include "core/html/HTMLFrameOwnerElement.h"
33 class HTMLImageLoader;
34 class RenderEmbeddedObject;
38 enum PreferPlugInsForImagesOption {
39 ShouldPreferPlugInsForImages,
40 ShouldNotPreferPlugInsForImages
43 class HTMLPlugInElement : public HTMLFrameOwnerElement {
45 virtual ~HTMLPlugInElement();
48 SharedPersistent<v8::Object>* pluginWrapper();
49 Widget* pluginWidget() const;
50 NPObject* getNPObject();
51 bool canProcessDrag() const;
52 const String& url() const { return m_url; }
54 // Public for FrameView::addWidgetToUpdate()
55 bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }
56 void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }
60 HTMLPlugInElement(const QualifiedName& tagName, Document&, bool createdByParser, PreferPlugInsForImagesOption);
63 virtual void didMoveToNewDocument(Document& oldDocument) OVERRIDE;
64 virtual bool dispatchBeforeLoadEvent(const String& sourceURL) OVERRIDE FINAL;
67 virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
68 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) OVERRIDE;
70 virtual bool useFallbackContent() const;
71 // Create or update the RenderWidget and return it, triggering layout if
73 virtual RenderWidget* renderWidgetForJSBindings() const;
76 bool shouldPreferPlugInsForImages() const { return m_shouldPreferPlugInsForImages; }
77 RenderEmbeddedObject* renderEmbeddedObject() const;
78 bool allowedToLoadFrameURL(const String& url);
79 bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues);
80 bool shouldUsePlugin(const KURL&, const String& mimeType, bool hasFallback, bool& useFallback);
82 void dispatchErrorEvent();
87 OwnPtr<HTMLImageLoader> m_imageLoader;
88 bool m_isDelayingLoadEvent;
91 // EventTarget functions:
92 virtual void removeAllEventListeners() OVERRIDE FINAL;
95 virtual bool canContainRangeEndPoint() const OVERRIDE { return false; }
96 virtual bool willRespondToMouseClickEvents() OVERRIDE FINAL;
97 virtual void defaultEventHandler(Event*) OVERRIDE FINAL;
98 virtual void attach(const AttachContext& = AttachContext()) OVERRIDE FINAL;
99 virtual void detach(const AttachContext& = AttachContext()) OVERRIDE FINAL;
100 virtual void finishParsingChildren() OVERRIDE FINAL;
101 virtual bool isPluginElement() const OVERRIDE FINAL;
103 // Element functions:
104 virtual RenderObject* createRenderer(RenderStyle*) OVERRIDE;
105 virtual void willRecalcStyle(StyleRecalcChange) OVERRIDE FINAL;
106 virtual bool supportsFocus() const OVERRIDE FINAL { return true; }
107 virtual bool rendererIsFocusable() const OVERRIDE FINAL;
108 virtual bool isKeyboardFocusable() const OVERRIDE FINAL;
109 virtual void didAddUserAgentShadowRoot(ShadowRoot&) OVERRIDE FINAL;
110 virtual void didAddShadowRoot(ShadowRoot&) OVERRIDE FINAL;
112 // HTMLElement function:
113 virtual bool hasCustomFocusLogic() const OVERRIDE;
115 // Return any existing RenderWidget without triggering relayout, or 0 if it
116 // doesn't yet exist.
117 virtual RenderWidget* existingRenderWidget() const = 0;
118 virtual void updateWidgetInternal() = 0;
122 RestartingWithPendingMouseClick,
125 DisplayState displayState() const { return m_displayState; }
126 void setDisplayState(DisplayState state) { m_displayState = state; }
127 const String loadedMimeType() const;
128 bool loadPlugin(const KURL&, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback);
129 bool pluginIsLoadable(const KURL&, const String& mimeType);
130 bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);
132 mutable RefPtr<SharedPersistent<v8::Object> > m_pluginWrapper;
133 NPObject* m_NPObject;
134 bool m_isCapturingMouseEvents;
135 bool m_inBeforeLoadEventHandler;
136 bool m_needsWidgetUpdate;
137 bool m_shouldPreferPlugInsForImages;
138 DisplayState m_displayState;
141 DEFINE_NODE_TYPE_CASTS(HTMLPlugInElement, isPluginElement());
143 } // namespace WebCore
145 #endif // HTMLPlugInElement_h