ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 1 | /* |
darin@apple.com | 9e71e5e | 2017-01-05 06:45:48 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008-2017 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 | |
commit-queue@webkit.org | d862d77 | 2016-10-31 22:07:53 +0000 | [diff] [blame] | 21 | #pragma once |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 22 | |
| 23 | #include "HTMLPlugInElement.h" |
beidson@apple.com | c1a24e1 | 2011-12-15 18:50:59 +0000 | [diff] [blame] | 24 | |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 25 | namespace WebCore { |
| 26 | |
| 27 | class HTMLImageLoader; |
jonlee@apple.com | 64454f9 | 2012-11-26 22:36:03 +0000 | [diff] [blame] | 28 | class MouseEvent; |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 29 | |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 30 | enum class CreatePlugins { No, Yes }; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 31 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 32 | // Base class for HTMLAppletElement, HTMLEmbedElement, and HTMLObjectElement. |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 33 | // FIXME: Perhaps HTMLAppletElement should inherit from HTMLPlugInElement directly instead. |
shinyak@chromium.org | 4221ffd | 2013-01-18 03:57:06 +0000 | [diff] [blame] | 34 | class HTMLPlugInImageElement : public HTMLPlugInElement { |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 35 | public: |
kbr@google.com | 61bbd85c | 2011-12-12 23:05:34 +0000 | [diff] [blame] | 36 | virtual ~HTMLPlugInImageElement(); |
beidson@apple.com | 343e49b | 2011-12-12 22:00:31 +0000 | [diff] [blame] | 37 | |
eric@webkit.org | 1402eb4 | 2010-09-02 09:10:21 +0000 | [diff] [blame] | 38 | RenderEmbeddedObject* renderEmbeddedObject() const; |
eric@webkit.org | e164bb6 | 2010-09-02 10:58:04 +0000 | [diff] [blame] | 39 | |
andersca@apple.com | 39049e2 | 2016-08-10 01:31:17 +0000 | [diff] [blame] | 40 | virtual void updateWidget(CreatePlugins) = 0; |
eric@webkit.org | f8fade8 | 2010-09-03 04:49:14 +0000 | [diff] [blame] | 41 | |
andersca@apple.com | d86d842 | 2010-12-21 18:29:57 +0000 | [diff] [blame] | 42 | const String& serviceType() const { return m_serviceType; } |
| 43 | const String& url() const { return m_url; } |
darin@apple.com | 5ffbb5c | 2013-09-27 16:39:41 +0000 | [diff] [blame] | 44 | const URL& loadedUrl() const { return m_loadedUrl; } |
dino@apple.com | cf69686 | 2013-03-26 23:52:31 +0000 | [diff] [blame] | 45 | |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 46 | String loadedMimeType() const |
dino@apple.com | cf69686 | 2013-03-26 23:52:31 +0000 | [diff] [blame] | 47 | { |
| 48 | String mimeType = serviceType(); |
| 49 | if (mimeType.isEmpty()) |
| 50 | mimeType = mimeTypeFromURL(m_loadedUrl); |
| 51 | return mimeType; |
| 52 | } |
| 53 | |
eric@webkit.org | a4c0208 | 2011-12-15 22:00:09 +0000 | [diff] [blame] | 54 | // Public for FrameView::addWidgetToUpdate() |
| 55 | bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } |
| 56 | void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; } |
dbates@webkit.org | 1edd81d | 2013-12-18 00:15:02 +0000 | [diff] [blame] | 57 | |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 58 | void userDidClickSnapshot(MouseEvent&, bool forwardEvent); |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 59 | void checkSnapshotStatus(); |
dino@apple.com | f8474a7 | 2013-02-26 17:16:35 +0000 | [diff] [blame] | 60 | Image* snapshotImage() const { return m_snapshotImage.get(); } |
commit-queue@webkit.org | 8cc7564 | 2014-08-22 18:25:37 +0000 | [diff] [blame] | 61 | WEBCORE_EXPORT void restartSnapshottedPlugIn(); |
jonlee@apple.com | f494c4f | 2012-12-11 01:33:15 +0000 | [diff] [blame] | 62 | |
| 63 | // 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] | 64 | void subframeLoaderWillCreatePlugIn(const URL& plugInURL); |
cdumez@apple.com | 63c654d | 2014-10-09 16:45:32 +0000 | [diff] [blame] | 65 | void subframeLoaderDidCreatePlugIn(const Widget&); |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 66 | |
commit-queue@webkit.org | 8cc7564 | 2014-08-22 18:25:37 +0000 | [diff] [blame] | 67 | WEBCORE_EXPORT void setIsPrimarySnapshottedPlugIn(bool); |
mjs@apple.com | fb312bf | 2015-02-04 07:01:23 +0000 | [diff] [blame] | 68 | bool partOfSnapshotOverlay(const Node*) const; |
jonlee@apple.com | 64454f9 | 2012-11-26 22:36:03 +0000 | [diff] [blame] | 69 | |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 70 | bool needsCheckForSizeChange() const { return m_needsCheckForSizeChange; } |
| 71 | void setNeedsCheckForSizeChange() { m_needsCheckForSizeChange = true; } |
| 72 | void checkSizeChangeForSnapshotting(); |
| 73 | |
| 74 | enum SnapshotDecision { |
| 75 | SnapshotNotYetDecided, |
| 76 | NeverSnapshot, |
| 77 | Snapshotted, |
dino@apple.com | 40a941f | 2013-05-27 01:44:32 +0000 | [diff] [blame] | 78 | MaySnapshotWhenResized, |
| 79 | MaySnapshotWhenContentIsSet |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 80 | }; |
| 81 | SnapshotDecision snapshotDecision() const { return m_snapshotDecision; } |
| 82 | |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 83 | protected: |
andersca@apple.com | 589100e | 2015-10-12 17:25:37 +0000 | [diff] [blame] | 84 | HTMLPlugInImageElement(const QualifiedName& tagName, Document&, bool createdByParser); |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 85 | |
cdumez@apple.com | 33db059 | 2016-11-17 00:39:55 +0000 | [diff] [blame] | 86 | void didMoveToNewDocument(Document& oldDocument) override; |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 87 | 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] | 88 | |
darin@apple.com | cf9dd0f | 2009-08-23 06:55:57 +0000 | [diff] [blame] | 89 | bool isImageType(); |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 90 | HTMLImageLoader* imageLoader() { return m_imageLoader.get(); } |
eric@webkit.org | e164bb6 | 2010-09-02 10:58:04 +0000 | [diff] [blame] | 91 | |
eric@webkit.org | 4ffb1fe | 2010-09-03 04:28:12 +0000 | [diff] [blame] | 92 | bool allowedToLoadFrameURL(const String& url); |
andersca@apple.com | 39049e2 | 2016-08-10 01:31:17 +0000 | [diff] [blame] | 93 | bool wouldLoadAsPlugIn(const String& url, const String& serviceType); |
eric@webkit.org | 4ffb1fe | 2010-09-03 04:28:12 +0000 | [diff] [blame] | 94 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 95 | String m_serviceType; |
| 96 | String m_url; |
slewis@apple.com | 1365cdf | 2014-04-02 23:53:30 +0000 | [diff] [blame] | 97 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 98 | std::unique_ptr<HTMLImageLoader> m_imageLoader; |
dino@apple.com | 2e88ddc | 2013-03-19 20:23:43 +0000 | [diff] [blame] | 99 | |
darin@apple.com | 21e3cf9 | 2010-04-06 01:38:15 +0000 | [diff] [blame] | 100 | private: |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 101 | bool isPlugInImageElement() const final { return true; } |
| 102 | bool isRestartedPlugin() const final { return m_isRestartedPlugin; } |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 103 | |
dbates@webkit.org | a321639 | 2016-07-22 20:33:11 +0000 | [diff] [blame] | 104 | bool allowedToLoadPluginContent(const String& url, const String& mimeType) const; |
| 105 | |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 106 | void finishParsingChildren() final; |
| 107 | void didAddUserAgentShadowRoot(ShadowRoot*) final; |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 108 | |
antti@apple.com | 454418f | 2016-04-25 19:49:23 +0000 | [diff] [blame] | 109 | RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; |
darin@apple.com | 11ff47c | 2016-03-04 16:47:55 +0000 | [diff] [blame] | 110 | bool childShouldCreateRenderer(const Node&) const override; |
antti@apple.com | 81bb8da | 2016-11-24 12:54:00 +0000 | [diff] [blame] | 111 | void willRecalcStyle(Style::Change) final; |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 112 | void didAttachRenderers() final; |
| 113 | void willDetachRenderers() final; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 114 | |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 115 | void prepareForDocumentSuspension() final; |
| 116 | void resumeFromDocumentSuspension() final; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 117 | |
akling@apple.com | e8090dd | 2016-08-31 16:32:44 +0000 | [diff] [blame] | 118 | void defaultEventHandler(Event&) final; |
darin@apple.com | 49cc03e | 2016-03-04 17:20:46 +0000 | [diff] [blame] | 119 | void dispatchPendingMouseClick() final; |
eric@webkit.org | 1402eb4 | 2010-09-02 09:10:21 +0000 | [diff] [blame] | 120 | |
darin@apple.com | 9e71e5e | 2017-01-05 06:45:48 +0000 | [diff] [blame] | 121 | void updateSnapshot(Image*) final; |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 122 | |
slewis@apple.com | 1365cdf | 2014-04-02 23:53:30 +0000 | [diff] [blame] | 123 | void startLoadingImage(); |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 124 | void updateWidgetIfNecessary(); |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 125 | |
andersca@apple.com | 8ef4e62 | 2014-06-02 23:44:48 +0000 | [diff] [blame] | 126 | void simulatedMouseClickTimerFired(); |
jonlee@apple.com | 9b6356d | 2012-10-08 21:27:29 +0000 | [diff] [blame] | 127 | |
dino@apple.com | cf69686 | 2013-03-26 23:52:31 +0000 | [diff] [blame] | 128 | void restartSimilarPlugIns(); |
andersca@apple.com | 574a745 | 2014-11-21 20:10:13 +0000 | [diff] [blame] | 129 | void removeSnapshotTimerFired(); |
roger_fong@apple.com | 558b198 | 2014-04-16 00:26:11 +0000 | [diff] [blame] | 130 | bool isTopLevelFullPagePlugin(const RenderEmbeddedObject&) const; |
dino@apple.com | 2e06ec8 | 2013-04-03 20:13:20 +0000 | [diff] [blame] | 131 | |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 132 | void setDisplayState(DisplayState) final; |
| 133 | |
darin@apple.com | cdcb72f | 2014-04-06 20:27:07 +0000 | [diff] [blame] | 134 | URL m_loadedUrl; |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 135 | bool m_needsWidgetUpdate { false }; |
| 136 | bool m_needsDocumentActivationCallbacks { false }; |
jonlee@apple.com | 64454f9 | 2012-11-26 22:36:03 +0000 | [diff] [blame] | 137 | RefPtr<MouseEvent> m_pendingClickEventFromSnapshot; |
andersca@apple.com | 8ef4e62 | 2014-06-02 23:44:48 +0000 | [diff] [blame] | 138 | DeferrableOneShotTimer m_simulatedMouseClickTimer; |
jer.noble@apple.com | 50862fe | 2014-11-06 23:06:03 +0000 | [diff] [blame] | 139 | Timer m_removeSnapshotTimer; |
dino@apple.com | 018d5e4 | 2013-02-11 21:34:50 +0000 | [diff] [blame] | 140 | RefPtr<Image> m_snapshotImage; |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 141 | bool m_createdDuringUserGesture { false }; |
| 142 | bool m_isRestartedPlugin { false }; |
| 143 | bool m_needsCheckForSizeChange { false }; |
| 144 | bool m_plugInWasCreated { false }; |
| 145 | bool m_deferredPromotionToPrimaryPlugIn { false }; |
dino@apple.com | 455c019 | 2013-04-16 01:05:39 +0000 | [diff] [blame] | 146 | IntSize m_sizeWhenSnapshotted; |
darin@apple.com | aeea79fb | 2016-12-12 00:56:25 +0000 | [diff] [blame] | 147 | SnapshotDecision m_snapshotDecision { SnapshotNotYetDecided }; |
| 148 | bool m_plugInDimensionsSpecified { false }; |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 149 | }; |
| 150 | |
ddkilzer@apple.com | d5bccb5 | 2008-08-06 17:23:22 +0000 | [diff] [blame] | 151 | } // namespace WebCore |
| 152 | |
cdumez@apple.com | 3e58f0f | 2014-09-30 21:32:55 +0000 | [diff] [blame] | 153 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::HTMLPlugInImageElement) |
| 154 | static bool isType(const WebCore::HTMLPlugInElement& element) { return element.isPlugInImageElement(); } |
| 155 | static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLPlugInElement>(node) && isType(downcast<WebCore::HTMLPlugInElement>(node)); } |
| 156 | SPECIALIZE_TYPE_TRAITS_END() |