Changeset 66710 in webkit
- Timestamp:
- Sep 2, 2010 9:28:12 PM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r66709 r66710 1 2010-09-02 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Move updateWidget implementations into the DOM 6 https://bugs.webkit.org/show_bug.cgi?id=45058 7 8 Unfortunately it's not yet possible to share an updateWidget 9 implementation between <embed> and <object>. That would amount to 10 (positive) functional changes for <embed> which I'd will separate 11 into a later patch. I will also have to untangle <object>'s <param> 12 walk from its url/serviceType calculations. 13 14 However after this patch it's slap-you-across-the-face obvious that 15 RenderEmbeddedObject::updateWidget was the wrong place for this code. 16 RenderEmbeddedObject::updateWidget still exists, but only as a 17 pseudo-virtual-method dispatcher. Unless we add updateWidget() to 18 HTMLElement, we won't be able to use real virtual dispatch. 19 20 I may need to consider making "having a widget" a has-a relationship 21 with some sort of WidgetContainer object which Media and Plugin can 22 share. Or its also possible that Media's use of the widget code here 23 is just wrong. Certainly now that updateWidget was moved into HTMLMediaElement 24 it becomes obvious that HTMLMediaElement has duplicate code for updating widgets. 25 26 No functional changes, thus no tests. 27 28 * html/HTMLEmbedElement.cpp: 29 (WebCore::HTMLEmbedElement::updateWidget): 30 * html/HTMLEmbedElement.h: 31 * html/HTMLMediaElement.cpp: 32 (WebCore::HTMLMediaElement::updateWidget): 33 * html/HTMLMediaElement.h: 34 * html/HTMLObjectElement.cpp: 35 (WebCore::HTMLObjectElement::updateWidget): 36 * html/HTMLObjectElement.h: 37 (WebCore::HTMLObjectElement::useFallbackContent): 38 * html/HTMLPlugInImageElement.h: 39 (WebCore::HTMLPlugInImageElement::needsWidgetUpdate): 40 (WebCore::HTMLPlugInImageElement::setNeedsWidgetUpdate): 41 * loader/FrameLoader.cpp: 42 * rendering/RenderEmbeddedObject.cpp: 43 (WebCore::RenderEmbeddedObject::updateWidget): 44 1 45 2010-09-02 Eric Seidel <eric@webkit.org> 2 46 -
trunk/WebCore/html/HTMLEmbedElement.cpp
r66709 r66710 134 134 } 135 135 136 // FIXME: This should be unified with HTMLObjectElement::updateWidget and 137 // moved down into HTMLPluginImageElement.cpp 138 void HTMLEmbedElement::updateWidget(bool onlyCreateNonNetscapePlugins) 139 { 140 // FIXME: We should ASSERT(needsWidgetUpdate()), but currently 141 // FrameView::updateWidget() calls updateWidget(false) without checking if 142 // the widget actually needs updating! 143 setNeedsWidgetUpdate(false); 144 145 if (m_url.isEmpty() && m_serviceType.isEmpty()) 146 return; 147 148 // Note these pass m_url and m_serviceType to allow better code sharing with 149 // <object> which modifies url and serviceType before calling these. 150 if (!allowedToLoadFrameURL(m_url)) 151 return; 152 if (onlyCreateNonNetscapePlugins && wouldLoadAsNetscapePlugin(m_url, m_serviceType)) 153 return; 154 155 // FIXME: These should be joined into a PluginParameters class. 156 Vector<String> paramNames; 157 Vector<String> paramValues; 158 parametersForPlugin(paramNames, paramValues); 159 160 if (!dispatchBeforeLoadEvent(m_url)) 161 return; 162 163 SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); 164 // FIXME: beforeLoad could have detached the renderer! Just like in the <object> case above. 165 loader->requestObject(this, m_url, getAttribute(nameAttr), m_serviceType, paramNames, paramValues); 166 } 167 136 168 bool HTMLEmbedElement::rendererIsNeeded(RenderStyle* style) 137 169 { -
trunk/WebCore/html/HTMLEmbedElement.h
r66709 r66710 32 32 static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*, bool createdByParser); 33 33 34 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues);34 void updateWidget(bool onlyCreateNonNetscapePlugins); 35 35 36 36 private: … … 51 51 52 52 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; 53 54 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues); 53 55 }; 54 56 -
trunk/WebCore/html/HTMLMediaElement.cpp
r66311 r66710 2011 2011 m_needWidgetUpdate = false; 2012 2012 } 2013 2014 void HTMLMediaElement::updateWidget(bool) 2015 { 2016 mediaElement->setNeedWidgetUpdate(false); 2017 2018 Vector<String> paramNames; 2019 Vector<String> paramValues; 2020 KURL kurl; 2021 2022 mediaElement->getPluginProxyParams(kurl, paramNames, paramValues); 2023 SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); 2024 loader->loadMediaPlayerProxyPlugin(mediaElement, kurl, paramNames, paramValues); 2025 } 2026 2013 2027 #endif // ENABLE(PLUGIN_PROXY_FOR_VIDEO) 2014 2028 -
trunk/WebCore/html/HTMLMediaElement.h
r66311 r66710 154 154 virtual void finishParsingChildren(); 155 155 void createMediaPlayerProxy(); 156 void updateWidget(bool onlyCreateNonNetscapePlugins); 156 157 #endif 157 158 -
trunk/WebCore/html/HTMLObjectElement.cpp
r66709 r66710 237 237 } 238 238 239 // FIXME: This should be unified with HTMLEmbedElement::updateWidget and 240 // moved down into HTMLPluginImageElement.cpp 241 void HTMLObjectElement::updateWidget(bool onlyCreateNonNetscapePlugins) 242 { 243 // FIXME: We should ASSERT(needsWidgetUpdate()), but currently 244 // FrameView::updateWidget() calls updateWidget(false) without checking if 245 // the widget actually needs updating! 246 setNeedsWidgetUpdate(false); 247 // FIXME: This should ASSERT isFinishedParsingChildren() instead. 248 if (!isFinishedParsingChildren()) 249 return; 250 251 String url = this->url(); 252 String serviceType = this->serviceType(); 253 254 // FIXME: These should be joined into a PluginParameters class. 255 Vector<String> paramNames; 256 Vector<String> paramValues; 257 parametersForPlugin(paramNames, paramValues, url, serviceType); 258 259 // Note: url is modified above by parametersForPlugin. 260 if (!allowedToLoadFrameURL(url)) 261 return; 262 263 bool fallbackContent = hasFallbackContent(); 264 renderEmbeddedObject()->setHasFallbackContent(fallbackContent); 265 266 if (onlyCreateNonNetscapePlugins && wouldLoadAsNetscapePlugin(url, serviceType)) 267 return; 268 269 bool beforeLoadAllowedLoad = dispatchBeforeLoadEvent(url); 270 271 // beforeload events can modify the DOM, potentially causing 272 // RenderWidget::destroy() to be called. Ensure we haven't been 273 // destroyed before continuing. 274 // FIXME: Should this render fallback content? 275 if (!renderer()) 276 return; 277 278 SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); 279 bool success = beforeLoadAllowedLoad && loader->requestObject(this, url, getAttribute(nameAttr), serviceType, paramNames, paramValues); 280 281 if (!success && fallbackContent) 282 renderFallbackContent(); 283 } 284 239 285 bool HTMLObjectElement::rendererIsNeeded(RenderStyle* style) 240 286 { -
trunk/WebCore/html/HTMLObjectElement.h
r66709 r66710 32 32 static PassRefPtr<HTMLObjectElement> create(const QualifiedName&, Document*, bool createdByParser); 33 33 34 void renderFallbackContent();35 36 34 bool isDocNamedItem() const { return m_docNamedItem; } 37 35 … … 40 38 bool containsJavaApplet() const; 41 39 42 bool hasFallbackContent() const; 40 void updateWidget(bool onlyCreateNonNetscapePlugins); 41 43 42 virtual bool useFallbackContent() const { return m_useFallbackContent; } 44 45 // FIXME: This function should not deal with url or serviceType 46 // so that we can better share code between <object> and <embed>. 47 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType); 43 void renderFallbackContent(); 48 44 49 45 private: … … 67 63 void updateDocNamedItem(); 68 64 65 bool hasFallbackContent() const; 66 67 // FIXME: This function should not deal with url or serviceType 68 // so that we can better share code between <object> and <embed>. 69 void parametersForPlugin(Vector<String>& paramNames, Vector<String>& paramValues, String& url, String& serviceType); 70 69 71 AtomicString m_id; 70 72 String m_classId; -
trunk/WebCore/html/HTMLPlugInImageElement.h
r66709 r66710 36 36 const String& url() const { return m_url; } 37 37 38 // These can all move to be protected once updateWidget is moved out of RenderEmbeddedObject.cpp39 bool needsWidgetUpdate() const { return m_needsWidgetUpdate; }40 void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; }41 bool allowedToLoadFrameURL(const String& url);42 bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType);43 44 38 RenderEmbeddedObject* renderEmbeddedObject() const; 45 39 … … 56 50 virtual void attach(); 57 51 virtual void detach(); 52 53 bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } 54 void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; } 55 56 bool allowedToLoadFrameURL(const String& url); 57 bool wouldLoadAsNetscapePlugin(const String& url, const String& serviceType); 58 58 59 59 private: -
trunk/WebCore/loader/FrameLoader.cpp
r66677 r66710 1043 1043 } 1044 1044 1045 // FIXME: This does not belong in FrameLoader! 1045 1046 void FrameLoader::handleFallbackContent() 1046 1047 { -
trunk/WebCore/rendering/RenderEmbeddedObject.cpp
r66709 r66710 102 102 } 103 103 #endif 104 105 // FIXME: This belongs on HTMLObjectElement, HTMLPluginElement or HTMLFrameOwnerElement. 106 static void updateWidgetForObjectElement(HTMLObjectElement* objectElement, bool onlyCreateNonNetscapePlugins) 107 { 108 // FIXME: We should ASSERT(objectElement->needsWidgetUpdate()), but currently 109 // FrameView::updateWidget() calls updateWidget(false) without checking if 110 // the widget actually needs updating! 111 objectElement->setNeedsWidgetUpdate(false); 112 // FIXME: This should ASSERT isFinishedParsingChildren() instead. 113 if (!objectElement->isFinishedParsingChildren()) 114 return; 115 116 String url = objectElement->url(); 117 String serviceType = objectElement->serviceType(); 118 119 Vector<String> paramNames; 120 Vector<String> paramValues; 121 objectElement->parametersForPlugin(paramNames, paramValues, url, serviceType); 122 123 // Note: url is modified above by parametersForPlugin. 124 if (!objectElement->allowedToLoadFrameURL(url)) 125 return; 126 127 bool fallbackContent = objectElement->hasFallbackContent(); 128 objectElement->renderEmbeddedObject()->setHasFallbackContent(fallbackContent); 129 130 if (onlyCreateNonNetscapePlugins && objectElement->wouldLoadAsNetscapePlugin(url, serviceType)) 131 return; 132 133 bool beforeLoadAllowedLoad = objectElement->dispatchBeforeLoadEvent(url); 134 135 // beforeload events can modify the DOM, potentially causing 136 // RenderWidget::destroy() to be called. Ensure we haven't been 137 // destroyed before continuing. 138 // FIXME: Should this render fallback content? 139 if (!objectElement->renderer()) 140 return; 141 142 SubframeLoader* loader = objectElement->document()->frame()->loader()->subframeLoader(); 143 bool success = beforeLoadAllowedLoad && loader->requestObject(objectElement, url, objectElement->getAttribute(nameAttr), serviceType, paramNames, paramValues); 144 145 if (!success && fallbackContent) 146 objectElement->renderFallbackContent(); 147 } 148 149 // FIXME: This belongs on HTMLEmbedElement, HTMLPluginElement or HTMLFrameOwnerElement. 150 static void updateWidgetForEmbedElement(HTMLEmbedElement* embedElement, bool onlyCreateNonNetscapePlugins) 151 { 152 // FIXME: We should ASSERT(embedElement->needsWidgetUpdate()), but currently 153 // FrameView::updateWidget() calls updateWidget(false) without checking if 154 // the widget actually needs updating! 155 embedElement->setNeedsWidgetUpdate(false); 156 157 String url = embedElement->url(); 158 String serviceType = embedElement->serviceType(); 159 if (url.isEmpty() && serviceType.isEmpty()) 160 return; 161 if (!embedElement->allowedToLoadFrameURL(url)) 162 return; 163 164 if (onlyCreateNonNetscapePlugins && embedElement->wouldLoadAsNetscapePlugin(url, serviceType)) 165 return; 166 167 Vector<String> paramNames; 168 Vector<String> paramValues; 169 embedElement->parametersForPlugin(paramNames, paramValues); 170 171 if (!embedElement->dispatchBeforeLoadEvent(url)) 172 return; 173 174 SubframeLoader* loader = embedElement->document()->frame()->loader()->subframeLoader(); 175 // FIXME: beforeLoad could have detached the renderer! Just like in the <object> case above. 176 loader->requestObject(embedElement, url, embedElement->getAttribute(nameAttr), serviceType, paramNames, paramValues); 177 } 178 179 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) 180 // FIXME: This belongs on HTMLMediaElement. 181 static void updateWidgetForMediaElement(HTMLMediaElement* mediaElement, bool ignored) 182 { 183 Vector<String> paramNames; 184 Vector<String> paramValues; 185 KURL kurl; 186 187 mediaElement->getPluginProxyParams(kurl, paramNames, paramValues); 188 mediaElement->setNeedWidgetUpdate(false); 189 frame->loader()->subframeLoader()->loadMediaPlayerProxyPlugin(mediaElement, kurl, paramNames, paramValues); 190 } 191 #endif 192 104 105 // FIXME: This should be moved into FrameView (the only caller) 193 106 void RenderEmbeddedObject::updateWidget(bool onlyCreateNonNetscapePlugins) 194 107 { … … 202 115 RenderWidgetProtector protector(this); 203 116 204 if (node()->hasTagName(objectTag)) { 205 HTMLObjectElement* objectElement = static_cast<HTMLObjectElement*>(node()); 206 updateWidgetForObjectElement(objectElement, onlyCreateNonNetscapePlugins); 207 } else if (node()->hasTagName(embedTag)) { 208 HTMLEmbedElement* embedElement = static_cast<HTMLEmbedElement*>(node()); 209 updateWidgetForEmbedElement(embedElement, onlyCreateNonNetscapePlugins); 210 } 117 if (node()->hasTagName(objectTag)) 118 static_cast<HTMLObjectElement*>(node())->updateWidget(onlyCreateNonNetscapePlugins); 119 else if (node()->hasTagName(embedTag)) 120 static_cast<HTMLEmbedElement*>(node())->updateWidget(onlyCreateNonNetscapePlugins); 211 121 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) 212 else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag)) { 213 HTMLMediaElement* mediaElement = static_cast<HTMLMediaElement*>(node()); 214 updateWidgetForMediaElement(mediaElement, onlyCreateNonNetscapePlugins); 215 } 122 else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag)) 123 static_cast<HTMLMediaElement*>(node())->updateWidget(onlyCreateNonNetscapePlugins); 216 124 #endif 217 125 else
Note: See TracChangeset
for help on using the changeset viewer.