ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2009, 2011, 2012, 2014 Apple Inc. All rights reserved. |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Library General Public |
| 6 | * License as published by the Free Software Foundation; either |
| 7 | * version 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This library is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * Library General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Library General Public License |
| 15 | * along with this library; see the file COPYING.LIB. If not, write to |
| 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | #ifndef HTMLPlugInImageElement_h |
| 22 | #define HTMLPlugInImageElement_h |
| 23 | |
| 24 | #include "HTMLPlugInElement.h" |
beidson@apple.com | c1a24e1 | 2011-12-15 18:50:59 +0000 | [diff] [blame] | 25 | |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 26 | namespace WebCore { |
| 27 | |
| 28 | class HTMLImageLoader; |
eric@webkit.org | 918affb | 2010-09-03 04:04:29 +0000 | [diff] [blame] | 29 | class FrameLoader; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 30 | class Image; |
jonlee@apple.com | 64454f9 | 2012-11-26 22:36:03 +0000 | [diff] [blame] | 31 | class MouseEvent; |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 32 | class RenderStyle; |
jonlee@apple.com | f1a18ed | 2012-12-17 02:43:44 +0000 | [diff] [blame] | 33 | class Widget; |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 34 | |
abarth@webkit.org | 12c7af0 | 2011-02-02 08:00:19 +0000 | [diff] [blame] | 35 | enum PluginCreationOption { |
| 36 | CreateAnyWidgetType, |
| 37 | CreateOnlyNonNetscapePlugins, |
| 38 | }; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 39 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 40 | // Base class for HTMLAppletElement, HTMLEmbedElement, and HTMLObjectElement. |
| 41 | // FIXME: Should HTMLAppletElement inherit from HTMLPlugInElement directly instead? |
shinyak@chromium.org | 4221ffd | 2013-01-18 03:57:06 +0000 | [diff] [blame] | 42 | class HTMLPlugInImageElement : public HTMLPlugInElement { |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 43 | public: |
kbr@google.com | 61bbd85c | 2011-12-12 23:05:34 +0000 | [diff] [blame] | 44 | virtual ~HTMLPlugInImageElement(); |
beidson@apple.com | 343e49b | 2011-12-12 22:00:31 +0000 | [diff] [blame] | 45 | |
eric@webkit.org | 1402eb4 | 2010-09-02 09:10:21 +0000 | [diff] [blame] | 46 | RenderEmbeddedObject* renderEmbeddedObject() const; |
eric@webkit.org | e164bb6 | 2010-09-02 10:58:04 +0000 | [diff] [blame] | 47 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 48 | void setDisplayState(DisplayState) override; |
dino@apple.com | e5a9a9c | 2013-02-21 21:53:01 +0000 | [diff] [blame] | 49 | |
abarth@webkit.org | 12c7af0 | 2011-02-02 08:00:19 +0000 | [diff] [blame] | 50 | virtual void updateWidget(PluginCreationOption) = 0; |
eric@webkit.org | f8fade8 | 2010-09-03 04:49:14 +0000 | [diff] [blame] | 51 | |
andersca@apple.com | d86d842 | 2010-12-21 18:29:57 +0000 | [diff] [blame] | 52 | const String& serviceType() const { return m_serviceType; } |
| 53 | const String& url() const { return m_url; } |
darin@apple.com | 5ffbb5c | 2013-09-27 16:39:41 +0000 | [diff] [blame] | 54 | const URL& loadedUrl() const { return m_loadedUrl; } |
dino@apple.com | cf69686 | 2013-03-26 23:52:31 +0000 | [diff] [blame] | 55 | |
| 56 | const String loadedMimeType() const |
| 57 | { |
| 58 | String mimeType = serviceType(); |
| 59 | if (mimeType.isEmpty()) |
| 60 | mimeType = mimeTypeFromURL(m_loadedUrl); |
| 61 | return mimeType; |
| 62 | } |
| 63 | |
eric@webkit.org | a4c0208 | 2011-12-15 22:00:09 +0000 | [diff] [blame] | 64 | // Public for FrameView::addWidgetToUpdate() |
| 65 | bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } |
| 66 | void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; } |
dbates@webkit.org | 1edd81d | 2013-12-18 00:15:02 +0000 | [diff] [blame] | 67 | |
dino@apple.com | 435c2ed | 2013-04-05 01:25:05 +0000 | [diff] [blame] | 68 | void userDidClickSnapshot(PassRefPtr<MouseEvent>, bool forwardEvent); |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 69 | void checkSnapshotStatus(); |
dino@apple.com | f8474a7 | 2013-02-26 17:16:35 +0000 | [diff] [blame] | 70 | Image* snapshotImage() const { return m_snapshotImage.get(); } |
commit-queue@webkit.org | 8cc7564 | 2014-08-22 18:25:37 +0000 | [diff] [blame] | 71 | WEBCORE_EXPORT void restartSnapshottedPlugIn(); |
jonlee@apple.com | f494c4f | 2012-12-11 01:33:15 +0000 | [diff] [blame] | 72 | |
| 73 | // Plug-in URL might not be the same as url() with overriding parameters. |
darin@apple.com | 5ffbb5c | 2013-09-27 16:39:41 +0000 | [diff] [blame] | 74 | void subframeLoaderWillCreatePlugIn(const URL& plugInURL); |
cdumez@apple.com | 63c654d | 2014-10-09 16:45:32 +0000 | [diff] [blame] | 75 | void subframeLoaderDidCreatePlugIn(const Widget&); |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 76 | |
commit-queue@webkit.org | 8cc7564 | 2014-08-22 18:25:37 +0000 | [diff] [blame] | 77 | WEBCORE_EXPORT void setIsPrimarySnapshottedPlugIn(bool); |
mjs@apple.com | fb312bf | 2015-02-04 07:01:23 +0000 | [diff] [blame] | 78 | bool partOfSnapshotOverlay(const Node*) const; |
jonlee@apple.com | 64454f9 | 2012-11-26 22:36:03 +0000 | [diff] [blame] | 79 | |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 80 | bool needsCheckForSizeChange() const { return m_needsCheckForSizeChange; } |
| 81 | void setNeedsCheckForSizeChange() { m_needsCheckForSizeChange = true; } |
| 82 | void checkSizeChangeForSnapshotting(); |
| 83 | |
| 84 | enum SnapshotDecision { |
| 85 | SnapshotNotYetDecided, |
| 86 | NeverSnapshot, |
| 87 | Snapshotted, |
dino@apple.com | 40a941f | 2013-05-27 01:44:32 +0000 | [diff] [blame] | 88 | MaySnapshotWhenResized, |
| 89 | MaySnapshotWhenContentIsSet |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 90 | }; |
| 91 | SnapshotDecision snapshotDecision() const { return m_snapshotDecision; } |
| 92 | |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 93 | protected: |
andersca@apple.com | 589100e | 2015-10-12 17:25:37 +0000 | [diff] [blame] | 94 | HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool createdByParser); |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 95 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 96 | void didMoveToNewDocument(Document* oldDocument) override; |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame^] | 97 | bool requestObject(const String& url, const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) final; |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 98 | |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 99 | bool isImageType(); |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 100 | HTMLImageLoader* imageLoader() { return m_imageLoader.get(); } |
eric@webkit.org | e164bb6 | 2010-09-02 10:58:04 +0000 | [diff] [blame] | 101 | |
eric@webkit.org | 4ffb1fe | 2010-09-03 04:28:12 +0000 | [diff] [blame] | 102 | bool allowedToLoadFrameURL(const String& url); |
| 103 | bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType); |
| 104 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 105 | String m_serviceType; |
| 106 | String m_url; |
slewis@apple.com | 1365cdf | 2014-04-02 23:53:30 +0000 | [diff] [blame] | 107 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 108 | std::unique_ptr<HTMLImageLoader> m_imageLoader; |
dino@apple.com | 2e88ddc | 2013-03-19 20:23:43 +0000 | [diff] [blame] | 109 | |
darin@apple.com | 21e3cf9 | 2010-04-06 01:38:15 +0000 | [diff] [blame] | 110 | private: |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame^] | 111 | bool isPlugInImageElement() const final { return true; } |
| 112 | bool isRestartedPlugin() const final { return m_isRestartedPlugin; } |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 113 | |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame^] | 114 | void finishParsingChildren() final; |
| 115 | void didAddUserAgentShadowRoot(ShadowRoot*) final; |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 116 | |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 117 | RenderPtr<RenderElement> createElementRenderer(Ref<RenderStyle>&&, const RenderTreePosition&) override; |
| 118 | bool childShouldCreateRenderer(const Node&) const override; |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame^] | 119 | bool willRecalcStyle(Style::Change) final; |
| 120 | void didAttachRenderers() final; |
| 121 | void willDetachRenderers() final; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 122 | |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame^] | 123 | void prepareForDocumentSuspension() final; |
| 124 | void resumeFromDocumentSuspension() final; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 125 | |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame^] | 126 | void defaultEventHandler(Event*) final; |
| 127 | void dispatchPendingMouseClick() final; |
eric@webkit.org | 1402eb4 | 2010-09-02 09:10:21 +0000 | [diff] [blame] | 128 | |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame^] | 129 | void updateSnapshot(PassRefPtr<Image>) final; |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 130 | |
slewis@apple.com | 1365cdf | 2014-04-02 23:53:30 +0000 | [diff] [blame] | 131 | void startLoadingImage(); |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 132 | void updateWidgetIfNecessary(); |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 133 | |
andersca@apple.com | 8ef4e62 | 2014-06-02 23:44:48 +0000 | [diff] [blame] | 134 | void simulatedMouseClickTimerFired(); |
jonlee@apple.com | 9b6356d | 2012-10-08 21:27:29 +0000 | [diff] [blame] | 135 | |
dino@apple.com | cf69686 | 2013-03-26 23:52:31 +0000 | [diff] [blame] | 136 | void restartSimilarPlugIns(); |
andersca@apple.com | 574a745 | 2014-11-21 20:10:13 +0000 | [diff] [blame] | 137 | void removeSnapshotTimerFired(); |
roger_fong@apple.com | 558b198 | 2014-04-16 00:26:11 +0000 | [diff] [blame] | 138 | bool isTopLevelFullPagePlugin(const RenderEmbeddedObject&) const; |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 139 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 140 | URL m_loadedUrl; |
eric@webkit.org | 1402eb4 | 2010-09-02 09:10:21 +0000 | [diff] [blame] | 141 | bool m_needsWidgetUpdate; |
beidson@apple.com | 343e49b | 2011-12-12 22:00:31 +0000 | [diff] [blame] | 142 | bool m_needsDocumentActivationCallbacks; |
jonlee@apple.com | 64454f9 | 2012-11-26 22:36:03 +0000 | [diff] [blame] | 143 | RefPtr<MouseEvent> m_pendingClickEventFromSnapshot; |
andersca@apple.com | 8ef4e62 | 2014-06-02 23:44:48 +0000 | [diff] [blame] | 144 | DeferrableOneShotTimer m_simulatedMouseClickTimer; |
jer.noble@apple.com | 50862fe | 2014-11-06 23:06:03 +0000 | [diff] [blame] | 145 | Timer m_removeSnapshotTimer; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 146 | RefPtr<Image> m_snapshotImage; |
dino@apple.com | d51798b | 2013-03-11 22:51:43 +0000 | [diff] [blame] | 147 | bool m_createdDuringUserGesture; |
dino@apple.com | 5fdf3c8 | 2013-04-16 02:52:00 +0000 | [diff] [blame] | 148 | bool m_isRestartedPlugin; |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 149 | bool m_needsCheckForSizeChange; |
timothy_horton@apple.com | 3019d20 | 2013-04-16 22:58:03 +0000 | [diff] [blame] | 150 | bool m_plugInWasCreated; |
| 151 | bool m_deferredPromotionToPrimaryPlugIn; |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 152 | IntSize m_sizeWhenSnapshotted; |
| 153 | SnapshotDecision m_snapshotDecision; |
roger_fong@apple.com | 558b198 | 2014-04-16 00:26:11 +0000 | [diff] [blame] | 154 | bool m_plugInDimensionsSpecified; |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 155 | }; |
| 156 | |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 157 | } // namespace WebCore |
| 158 | |
cdumez@apple.com | 3e58f0f | 2014-09-30 21:32:55 +0000 | [diff] [blame] | 159 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLPlugInImageElement) |
| 160 | static bool isType(const WebCore::HTMLPlugInElement& element) { return element.isPlugInImageElement(); } |
| 161 | static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLPlugInElement>(node) && isType(downcast<WebCore::HTMLPlugInElement>(node)); } |
| 162 | SPECIALIZE_TYPE_TRAITS_END() |
| 163 | |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 164 | #endif // HTMLPlugInImageElement_h |