Changeset 66650 in webkit
- Timestamp:
- Sep 2, 2010 2:10:21 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r66649 r66650 1 2010-09-02 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Share more code between HTMLObjectElement and HTMLEmbedElement 6 https://bugs.webkit.org/show_bug.cgi?id=45054 7 8 This pushes more of HTMLObjectElement code down into 9 HTMLPlugInImageElement so that it can be shared with HTMLEmbedElement. 10 11 I also moved a little code from HTMLPluginElement to HTMLPlugInImageElement 12 since HTMLAppletElement does not need to share this same widget update logic. 13 This is a small correction from the previous change. 14 15 This patch was originally written in one piece and reviewed by Dimitri. 16 I'm landing it as two separate changes for easier readability and less 17 chance of regression. 18 19 No functional change, thus no tests. 20 21 * html/HTMLEmbedElement.cpp: 22 (WebCore::HTMLEmbedElement::HTMLEmbedElement): 23 (WebCore::HTMLEmbedElement::mapToEntry): 24 (WebCore::HTMLEmbedElement::parseMappedAttribute): 25 (WebCore::HTMLEmbedElement::rendererIsNeeded): 26 (WebCore::HTMLEmbedElement::attach): 27 (WebCore::HTMLEmbedElement::updateWidget): 28 (WebCore::HTMLEmbedElement::insertedIntoDocument): 29 (WebCore::HTMLEmbedElement::removedFromDocument): 30 (WebCore::HTMLEmbedElement::attributeChanged): 31 * html/HTMLEmbedElement.h: 32 * html/HTMLObjectElement.cpp: 33 (WebCore::HTMLObjectElement::HTMLObjectElement): 34 (WebCore::HTMLObjectElement::parseMappedAttribute): 35 (WebCore::HTMLObjectElement::rendererIsNeeded): 36 (WebCore::HTMLObjectElement::attach): 37 (WebCore::HTMLObjectElement::updateWidget): 38 (WebCore::HTMLObjectElement::finishParsingChildren): 39 (WebCore::HTMLObjectElement::detach): 40 (WebCore::HTMLObjectElement::insertedIntoDocument): 41 (WebCore::HTMLObjectElement::removedFromDocument): 42 (WebCore::HTMLObjectElement::recalcStyle): 43 (WebCore::HTMLObjectElement::childrenChanged): 44 (WebCore::HTMLObjectElement::renderFallbackContent): 45 * html/HTMLObjectElement.h: 46 * html/HTMLPlugInElement.cpp: 47 * html/HTMLPlugInElement.h: 48 * html/HTMLPlugInImageElement.cpp: 49 (WebCore::HTMLPlugInImageElement::HTMLPlugInImageElement): 50 (WebCore::HTMLPlugInImageElement::renderEmbeddedObject): 51 * html/HTMLPlugInImageElement.h: 52 (WebCore::HTMLPlugInImageElement::needsWidgetUpdate): 53 (WebCore::HTMLPlugInImageElement::setNeedsWidgetUpdate): 54 * loader/SubframeLoader.cpp: 55 (WebCore::SubframeLoader::requestObject): 56 (WebCore::SubframeLoader::loadPlugin): 57 * loader/SubframeLoader.h: 58 * rendering/RenderEmbeddedObject.cpp: 59 (WebCore::updateWidgetForObjectElement): 60 (WebCore::updateWidgetForEmbedElement): 61 1 62 2010-09-02 Tony Gentilcore <tonyg@chromium.org> 2 63 -
trunk/WebCore/html/HTMLEmbedElement.cpp
r66631 r66650 45 45 inline HTMLEmbedElement::HTMLEmbedElement(const QualifiedName& tagName, Document* document) 46 46 : HTMLPlugInImageElement(tagName, document) 47 , m_needWidgetUpdate(false)48 47 { 49 48 ASSERT(hasTagName(embedTag)); … … 81 80 } 82 81 83 return HTMLPlugIn Element::mapToEntry(attrName, result);82 return HTMLPlugInImageElement::mapToEntry(attrName, result); 84 83 } 85 84 … … 119 118 m_name = value; 120 119 } else 121 HTMLPlugIn Element::parseMappedAttribute(attr);120 HTMLPlugInImageElement::parseMappedAttribute(attr); 122 121 } 123 122 … … 125 124 { 126 125 if (isImageType()) 127 return HTMLPlugIn Element::rendererIsNeeded(style);126 return HTMLPlugInImageElement::rendererIsNeeded(style); 128 127 129 128 Frame* frame = document()->frame(); … … 150 149 #endif 151 150 152 return HTMLPlugIn Element::rendererIsNeeded(style);151 return HTMLPlugInImageElement::rendererIsNeeded(style); 153 152 } 154 153 … … 165 164 void HTMLEmbedElement::attach() 166 165 { 167 m_needWidgetUpdate = true;166 setNeedsWidgetUpdate(true); 168 167 169 168 bool isImage = isImageType(); 170 169 171 170 if (!isImage) 172 queuePostAttachCallback(&HTMLPlugIn Element::updateWidgetCallback, this);173 174 HTMLPlugIn Element::attach();171 queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, this); 172 173 HTMLPlugInImageElement::attach(); 175 174 176 175 if (isImage && renderer()) { … … 187 186 { 188 187 document()->updateStyleIfNeeded(); 189 if ( m_needWidgetUpdate&& renderEmbeddedObject() && !isImageType())188 if (needsWidgetUpdate() && renderEmbeddedObject() && !isImageType()) 190 189 renderEmbeddedObject()->updateWidget(true); 191 190 } … … 210 209 } 211 210 212 HTMLPlugIn Element::insertedIntoDocument();211 HTMLPlugInImageElement::insertedIntoDocument(); 213 212 } 214 213 … … 218 217 static_cast<HTMLDocument*>(document())->removeNamedItem(m_name); 219 218 220 HTMLPlugIn Element::removedFromDocument();219 HTMLPlugInImageElement::removedFromDocument(); 221 220 } 222 221 223 222 void HTMLEmbedElement::attributeChanged(Attribute* attr, bool preserveDecls) 224 223 { 225 HTMLPlugIn Element::attributeChanged(attr, preserveDecls);224 HTMLPlugInImageElement::attributeChanged(attr, preserveDecls); 226 225 227 226 if ((attr->name() == widthAttr || attr->name() == heightAttr) && !attr->isEmpty()) { -
trunk/WebCore/html/HTMLEmbedElement.h
r66057 r66650 32 32 static PassRefPtr<HTMLEmbedElement> create(const QualifiedName&, Document*); 33 33 34 void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; }35 36 34 private: 37 35 HTMLEmbedElement(const QualifiedName&, Document*); … … 56 54 57 55 virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; 58 59 bool m_needWidgetUpdate;60 56 }; 61 57 -
trunk/WebCore/html/HTMLObjectElement.cpp
r66631 r66650 49 49 : HTMLPlugInImageElement(tagName, document) 50 50 , m_docNamedItem(true) 51 , m_needWidgetUpdate(!createdByParser)52 51 , m_useFallbackContent(false) 53 52 { 53 // HTMLObjectElement tries to delay updating its widget while parsing until 54 // after all of its children are parsed. 55 setNeedsWidgetUpdate(!createdByParser); 54 56 ASSERT(hasTagName(objectTag)); 55 57 } … … 68 70 void HTMLObjectElement::parseMappedAttribute(Attribute* attr) 69 71 { 70 String val = attr->value();71 size_t pos;72 72 if (attr->name() == typeAttr) { 73 m_serviceType = val.lower();74 pos = m_serviceType.find(";");73 m_serviceType = attr->value().lower(); 74 size_t pos = m_serviceType.find(";"); 75 75 if (pos != notFound) 76 m_serviceType = m_serviceType.left(pos);76 m_serviceType = m_serviceType.left(pos); 77 77 if (renderer()) 78 m_needWidgetUpdate = true;78 setNeedsWidgetUpdate(true); 79 79 if (!isImageType() && m_imageLoader) 80 m_imageLoader.clear();80 m_imageLoader.clear(); 81 81 } else if (attr->name() == dataAttr) { 82 m_url = deprecatedParseURL(val); 82 m_url = deprecatedParseURL(attr->value()); 83 if (renderer()) { 84 setNeedsWidgetUpdate(true); 85 if (isImageType()) { 86 if (!m_imageLoader) 87 m_imageLoader = adoptPtr(new HTMLImageLoader(this)); 88 m_imageLoader->updateFromElementIgnoringPreviousError(); 89 } 90 } 91 } else if (attr->name() == classidAttr) { 92 m_classId = attr->value(); 83 93 if (renderer()) 84 m_needWidgetUpdate = true; 85 if (renderer() && isImageType()) { 86 if (!m_imageLoader) 87 m_imageLoader = adoptPtr(new HTMLImageLoader(this)); 88 m_imageLoader->updateFromElementIgnoringPreviousError(); 89 } 90 } else if (attr->name() == classidAttr) { 91 m_classId = val; 92 if (renderer()) 93 m_needWidgetUpdate = true; 94 setNeedsWidgetUpdate(true); 94 95 } else if (attr->name() == onloadAttr) 95 96 setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr)); … … 113 114 m_id = newId; 114 115 // also call superclass 115 HTMLPlugIn Element::parseMappedAttribute(attr);116 HTMLPlugInImageElement::parseMappedAttribute(attr); 116 117 } else 117 HTMLPlugIn Element::parseMappedAttribute(attr);118 HTMLPlugInImageElement::parseMappedAttribute(attr); 118 119 } 119 120 … … 128 129 // for the object element. 129 130 bool isGearsPlugin = equalIgnoringCase(getAttribute(typeAttr), "application/x-googlegears"); 130 return isGearsPlugin || HTMLPlugIn Element::rendererIsNeeded(style);131 return isGearsPlugin || HTMLPlugInImageElement::rendererIsNeeded(style); 131 132 } 132 133 … … 151 152 152 153 if (!isImage) 153 queuePostAttachCallback(&HTMLPlugIn Element::updateWidgetCallback, this);154 155 HTMLPlugIn Element::attach();154 queuePostAttachCallback(&HTMLPlugInImageElement::updateWidgetCallback, this); 155 156 HTMLPlugInImageElement::attach(); 156 157 157 158 if (isImage && renderer() && !m_useFallbackContent) { … … 165 166 { 166 167 document()->updateStyleIfNeeded(); 167 if ( m_needWidgetUpdate&& renderEmbeddedObject() && !m_useFallbackContent && !isImageType())168 if (needsWidgetUpdate() && renderEmbeddedObject() && !m_useFallbackContent && !isImageType()) 168 169 renderEmbeddedObject()->updateWidget(true); 169 170 } … … 171 172 void HTMLObjectElement::finishParsingChildren() 172 173 { 173 HTMLPlugIn Element::finishParsingChildren();174 HTMLPlugInImageElement::finishParsingChildren(); 174 175 if (!m_useFallbackContent) { 175 m_needWidgetUpdate = true;176 setNeedsWidgetUpdate(true); 176 177 if (inDocument()) 177 178 setNeedsStyleRecalc(); … … 183 184 if (attached() && renderer() && !m_useFallbackContent) 184 185 // Update the widget the next time we attach (detaching destroys the plugin). 185 m_needWidgetUpdate = true;186 HTMLPlugIn Element::detach();186 setNeedsWidgetUpdate(true); 187 HTMLPlugInImageElement::detach(); 187 188 } 188 189 … … 195 196 } 196 197 197 HTMLPlugIn Element::insertedIntoDocument();198 HTMLPlugInImageElement::insertedIntoDocument(); 198 199 } 199 200 … … 206 207 } 207 208 208 HTMLPlugIn Element::removedFromDocument();209 HTMLPlugInImageElement::removedFromDocument(); 209 210 } 210 211 211 212 void HTMLObjectElement::recalcStyle(StyleChange ch) 212 213 { 213 if (!m_useFallbackContent && m_needWidgetUpdate&& renderer() && !isImageType()) {214 if (!m_useFallbackContent && needsWidgetUpdate() && renderer() && !isImageType()) { 214 215 detach(); 215 216 attach(); 216 217 } 217 HTMLPlugIn Element::recalcStyle(ch);218 HTMLPlugInImageElement::recalcStyle(ch); 218 219 } 219 220 … … 222 223 updateDocNamedItem(); 223 224 if (inDocument() && !m_useFallbackContent) { 224 m_needWidgetUpdate = true;225 setNeedsWidgetUpdate(true); 225 226 setNeedsStyleRecalc(); 226 227 } 227 HTMLPlugIn Element::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);228 HTMLPlugInImageElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); 228 229 } 229 230 … … 258 259 } 259 260 260 // Mark ourselves as using the fallback content.261 261 m_useFallbackContent = true; 262 262 263 // Now do a detach and reattach.264 263 // FIXME: Style gets recalculated which is suboptimal. 265 264 detach(); -
trunk/WebCore/html/HTMLObjectElement.h
r66156 r66650 31 31 public: 32 32 static PassRefPtr<HTMLObjectElement> create(const QualifiedName&, Document*, bool createdByParser); 33 34 void setNeedWidgetUpdate(bool needWidgetUpdate) { m_needWidgetUpdate = needWidgetUpdate; }35 33 36 34 void renderFallbackContent(); … … 75 73 String m_classId; 76 74 bool m_docNamedItem : 1; 77 bool m_needWidgetUpdate : 1;78 75 bool m_useFallbackContent : 1; 79 76 }; -
trunk/WebCore/html/HTMLPlugInElement.cpp
r66631 r66650 80 80 81 81 HTMLFrameOwnerElement::detach(); 82 }83 84 RenderEmbeddedObject* HTMLPlugInElement::renderEmbeddedObject() const85 {86 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers87 // when using fallback content.88 if (!renderer() || !renderer()->isEmbeddedObject())89 return 0;90 return toRenderEmbeddedObject(renderer());91 82 } 92 83 -
trunk/WebCore/html/HTMLPlugInElement.h
r66631 r66650 52 52 void setIsCapturingMouseEvents(bool capturing) { m_isCapturingMouseEvents = capturing; } 53 53 54 RenderEmbeddedObject* renderEmbeddedObject() const;55 56 54 protected: 57 55 HTMLPlugInElement(const QualifiedName& tagName, Document*); -
trunk/WebCore/html/HTMLPlugInImageElement.cpp
r57109 r66650 27 27 #include "HTMLImageLoader.h" 28 28 #include "Image.h" 29 #include "RenderEmbeddedObject.h" 29 30 30 31 namespace WebCore { … … 32 33 HTMLPlugInImageElement::HTMLPlugInImageElement(const QualifiedName& tagName, Document* document) 33 34 : HTMLPlugInElement(tagName, document) 35 , m_needsWidgetUpdate(false) 34 36 { 37 } 38 39 RenderEmbeddedObject* HTMLPlugInImageElement::renderEmbeddedObject() const 40 { 41 // HTMLObjectElement and HTMLEmbedElement may return arbitrary renderers 42 // when using fallback content. 43 if (!renderer() || !renderer()->isEmbeddedObject()) 44 return 0; 45 return toRenderEmbeddedObject(renderer()); 35 46 } 36 47 -
trunk/WebCore/html/HTMLPlugInImageElement.h
r57109 r66650 29 29 class HTMLImageLoader; 30 30 31 // Base class for HTMLObjectElement and HTMLEmbedElement 31 32 class HTMLPlugInImageElement : public HTMLPlugInElement { 32 33 public: … … 34 35 const String& url() const { return m_url; } 35 36 37 bool needsWidgetUpdate() const { return m_needsWidgetUpdate; } 38 void setNeedsWidgetUpdate(bool needsWidgetUpdate) { m_needsWidgetUpdate = needsWidgetUpdate; } 39 40 RenderEmbeddedObject* renderEmbeddedObject() const; 41 36 42 protected: 37 43 HTMLPlugInImageElement(const QualifiedName& tagName, Document*); … … 45 51 private: 46 52 virtual void willMoveToNewOwnerDocument(); 53 54 bool m_needsWidgetUpdate; 47 55 }; 48 56 -
trunk/WebCore/loader/SubframeLoader.cpp
r66631 r66650 39 39 #include "HTMLFrameElementBase.h" 40 40 #include "HTMLNames.h" 41 #include "HTMLPlugIn Element.h"41 #include "HTMLPlugInImageElement.h" 42 42 #include "MIMETypeRegistry.h" 43 43 #include "Node.h" … … 90 90 } 91 91 92 bool SubframeLoader::requestObject(HTMLPlugIn Element* ownerElement, const String& url, const AtomicString& frameName,92 bool SubframeLoader::requestObject(HTMLPlugInImageElement* ownerElement, const String& url, const AtomicString& frameName, 93 93 const String& mimeType, const Vector<String>& paramNames, const Vector<String>& paramValues) 94 94 { … … 125 125 126 126 ASSERT(ownerElement->hasTagName(objectTag) || ownerElement->hasTagName(embedTag)); 127 HTMLPlugIn Element* pluginElement = static_cast<HTMLPlugInElement*>(ownerElement);127 HTMLPlugInImageElement* pluginElement = static_cast<HTMLPlugInImageElement*>(ownerElement); 128 128 129 129 return loadPlugin(pluginElement, completedURL, mimeType, paramNames, paramValues, useFallback); … … 329 329 } 330 330 331 bool SubframeLoader::loadPlugin(HTMLPlugIn Element* pluginElement, const KURL& url, const String& mimeType,331 bool SubframeLoader::loadPlugin(HTMLPlugInImageElement* pluginElement, const KURL& url, const String& mimeType, 332 332 const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback) 333 333 { -
trunk/WebCore/loader/SubframeLoader.h
r66631 r66650 46 46 class HTMLAppletElement; 47 47 class HTMLFrameOwnerElement; 48 class HTMLPlugIn Element;48 class HTMLPlugInImageElement; 49 49 class IntSize; 50 50 class KURL; … … 62 62 63 63 bool requestFrame(HTMLFrameOwnerElement*, const String& url, const AtomicString& frameName, bool lockHistory = true, bool lockBackForwardList = true); 64 bool requestObject(HTMLPlugIn Element*, const String& url, const AtomicString& frameName,64 bool requestObject(HTMLPlugInImageElement*, const String& url, const AtomicString& frameName, 65 65 const String& serviceType, const Vector<String>& paramNames, const Vector<String>& paramValues); 66 66 … … 80 80 Frame* loadOrRedirectSubframe(HTMLFrameOwnerElement*, const KURL&, const AtomicString& frameName, bool lockHistory, bool lockBackForwardList); 81 81 Frame* loadSubframe(HTMLFrameOwnerElement*, const KURL&, const String& name, const String& referrer); 82 bool loadPlugin(HTMLPlugIn Element*, const KURL&, const String& mimeType,82 bool loadPlugin(HTMLPlugInImageElement*, const KURL&, const String& mimeType, 83 83 const Vector<String>& paramNames, const Vector<String>& paramValues, bool useFallback); 84 84 -
trunk/WebCore/rendering/RenderEmbeddedObject.cpp
r66631 r66650 256 256 static void updateWidgetForObjectElement(HTMLObjectElement* objectElement, bool onlyCreateNonNetscapePlugins) 257 257 { 258 objectElement->setNeed WidgetUpdate(false);258 objectElement->setNeedsWidgetUpdate(false); 259 259 if (!objectElement->isFinishedParsingChildren()) 260 260 return; … … 312 312 String serviceType = embedElement->serviceType(); 313 313 314 embedElement->setNeed WidgetUpdate(false);314 embedElement->setNeedsWidgetUpdate(false); 315 315 316 316 if (url.isEmpty() && serviceType.isEmpty())
Note: See TracChangeset
for help on using the changeset viewer.