diff options
Diffstat (limited to 'Source/WebCore/html/HTMLPlugInImageElement.h')
-rw-r--r-- | Source/WebCore/html/HTMLPlugInImageElement.h | 139 |
1 files changed, 58 insertions, 81 deletions
diff --git a/Source/WebCore/html/HTMLPlugInImageElement.h b/Source/WebCore/html/HTMLPlugInImageElement.h index 7e9e68677..b1c7626a3 100644 --- a/Source/WebCore/html/HTMLPlugInImageElement.h +++ b/Source/WebCore/html/HTMLPlugInImageElement.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009, 2011, 2012 Apple Inc. All rights reserved. + * Copyright (C) 2008-2017 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -18,49 +18,32 @@ * */ -#ifndef HTMLPlugInImageElement_h -#define HTMLPlugInImageElement_h +#pragma once #include "HTMLPlugInElement.h" -#include "RenderStyle.h" -#include <wtf/OwnPtr.h> - namespace WebCore { class HTMLImageLoader; -class HTMLVideoElement; -class FrameLoader; -class Image; class MouseEvent; -class Widget; - -enum PluginCreationOption { - CreateAnyWidgetType, - CreateOnlyNonNetscapePlugins, -}; -enum PreferPlugInsForImagesOption { - ShouldPreferPlugInsForImages, - ShouldNotPreferPlugInsForImages -}; +enum class CreatePlugins { No, Yes }; -// Base class for HTMLObjectElement and HTMLEmbedElement +// Base class for HTMLAppletElement, HTMLEmbedElement, and HTMLObjectElement. +// FIXME: Perhaps HTMLAppletElement should inherit from HTMLPlugInElement directly instead. class HTMLPlugInImageElement : public HTMLPlugInElement { public: virtual ~HTMLPlugInImageElement(); RenderEmbeddedObject* renderEmbeddedObject() const; - virtual void setDisplayState(DisplayState) override; - - virtual void updateWidget(PluginCreationOption) = 0; + virtual void updateWidget(CreatePlugins) = 0; const String& serviceType() const { return m_serviceType; } const String& url() const { return m_url; } const URL& loadedUrl() const { return m_loadedUrl; } - const String loadedMimeType() const + String loadedMimeType() const { String mimeType = serviceType(); if (mimeType.isEmpty()) @@ -68,27 +51,21 @@ public: return mimeType; } - bool shouldPreferPlugInsForImages() const { return m_shouldPreferPlugInsForImages; } - // Public for FrameView::addWidgetToUpdate() bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; } -#if PLATFORM(IOS) - void createShadowIFrameSubtree(const String& src); -#endif - - void userDidClickSnapshot(PassRefPtr<MouseEvent>, bool forwardEvent); + void userDidClickSnapshot(MouseEvent&, bool forwardEvent); void checkSnapshotStatus(); Image* snapshotImage() const { return m_snapshotImage.get(); } - void restartSnapshottedPlugIn(); + WEBCORE_EXPORT void restartSnapshottedPlugIn(); // Plug-in URL might not be the same as url() with overriding parameters. void subframeLoaderWillCreatePlugIn(const URL& plugInURL); - void subframeLoaderDidCreatePlugIn(const Widget*); + void subframeLoaderDidCreatePlugIn(const Widget&); - void setIsPrimarySnapshottedPlugIn(bool); - bool partOfSnapshotOverlay(Node*); + WEBCORE_EXPORT void setIsPrimarySnapshottedPlugIn(bool); + bool partOfSnapshotOverlay(const Node*) const; bool needsCheckForSizeChange() const { return m_needsCheckForSizeChange; } void setNeedsCheckForSizeChange() { m_needsCheckForSizeChange = true; } @@ -104,76 +81,76 @@ public: SnapshotDecision snapshotDecision() const { return m_snapshotDecision; } protected: - HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool createdByParser, PreferPlugInsForImagesOption); + HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool createdByParser); + + void didMoveToNewDocument(Document& oldDocument) override; + bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) final; bool isImageType(); + HTMLImageLoader* imageLoader() { return m_imageLoader.get(); } + + bool allowedToLoadFrameURL(const String& url); + bool wouldLoadAsPlugIn(const String& url, const String& serviceType); - OwnPtr<HTMLImageLoader> m_imageLoader; String m_serviceType; String m_url; - URL m_loadedUrl; - static void updateWidgetCallback(Node&, unsigned); - static void startLoadingImageCallback(Node&, unsigned); + std::unique_ptr<HTMLImageLoader> m_imageLoader; - virtual void didAttachRenderers() override; - virtual void willDetachRenderers() override; +private: + bool isPlugInImageElement() const final { return true; } + bool isRestartedPlugin() const final { return m_isRestartedPlugin; } - bool allowedToLoadFrameURL(const String& url); - bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType); + bool allowedToLoadPluginContent(const String& url, const String& mimeType) const; - virtual void didMoveToNewDocument(Document* oldDocument) override; + void finishParsingChildren() final; + void didAddUserAgentShadowRoot(ShadowRoot*) final; - virtual void documentWillSuspendForPageCache() override; - virtual void documentDidResumeFromPageCache() override; + RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; + bool childShouldCreateRenderer(const Node&) const override; + void willRecalcStyle(Style::Change) final; + void didAttachRenderers() final; + void willDetachRenderers() final; - virtual bool isRestartedPlugin() const override { return m_isRestartedPlugin; } - virtual bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) override; + void prepareForDocumentSuspension() final; + void resumeFromDocumentSuspension() final; -private: - virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; - virtual bool willRecalcStyle(Style::Change) override; + void defaultEventHandler(Event&) final; + void dispatchPendingMouseClick() final; - virtual void didAddUserAgentShadowRoot(ShadowRoot*) override; + void updateSnapshot(Image*) final; - virtual void finishParsingChildren() override; - - void updateWidgetIfNecessary(); void startLoadingImage(); + void updateWidgetIfNecessary(); - virtual void updateSnapshot(PassRefPtr<Image>) override; - virtual void dispatchPendingMouseClick() override; - void simulatedMouseClickTimerFired(DeferrableOneShotTimer<HTMLPlugInImageElement>&); + void simulatedMouseClickTimerFired(); void restartSimilarPlugIns(); + void removeSnapshotTimerFired(); + bool isTopLevelFullPagePlugin(const RenderEmbeddedObject&) const; - virtual bool isPlugInImageElement() const override { return true; } - - void removeSnapshotTimerFired(Timer<HTMLPlugInImageElement>&); - - virtual void defaultEventHandler(Event*) override; + void setDisplayState(DisplayState) final; - bool m_needsWidgetUpdate; - bool m_shouldPreferPlugInsForImages; - bool m_needsDocumentActivationCallbacks; + URL m_loadedUrl; + bool m_needsWidgetUpdate { false }; + bool m_needsDocumentActivationCallbacks { false }; RefPtr<MouseEvent> m_pendingClickEventFromSnapshot; - DeferrableOneShotTimer<HTMLPlugInImageElement> m_simulatedMouseClickTimer; - Timer<HTMLPlugInImageElement> m_removeSnapshotTimer; + DeferrableOneShotTimer m_simulatedMouseClickTimer; + Timer m_removeSnapshotTimer; RefPtr<Image> m_snapshotImage; - bool m_createdDuringUserGesture; - bool m_isRestartedPlugin; - bool m_needsCheckForSizeChange; - bool m_plugInWasCreated; - bool m_deferredPromotionToPrimaryPlugIn; + bool m_createdDuringUserGesture { false }; + bool m_isRestartedPlugin { false }; + bool m_needsCheckForSizeChange { false }; + bool m_plugInWasCreated { false }; + bool m_deferredPromotionToPrimaryPlugIn { false }; IntSize m_sizeWhenSnapshotted; - SnapshotDecision m_snapshotDecision; + SnapshotDecision m_snapshotDecision { SnapshotNotYetDecided }; + bool m_plugInDimensionsSpecified { false }; }; -void isHTMLPlugInImageElement(const HTMLPlugInImageElement&); // Catch unnecessary runtime check of type known at compile time. -inline bool isHTMLPlugInImageElement(const HTMLPlugInElement& element) { return element.isPlugInImageElement(); } -inline bool isHTMLPlugInImageElement(const Node& node) { return node.isPluginElement() && toHTMLPlugInElement(node).isPlugInImageElement(); } -NODE_TYPE_CASTS(HTMLPlugInImageElement) - } // namespace WebCore -#endif // HTMLPlugInImageElement_h +SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLPlugInImageElement) + static bool isType(const WebCore::HTMLPlugInElement& element) { return element.isPlugInImageElement(); } + static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLPlugInElement>(node) && isType(downcast<WebCore::HTMLPlugInElement>(node)); } +SPECIALIZE_TYPE_TRAITS_END() |