void HTMLObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == formAttr) formAttributeChanged(); else if (name == typeAttr) { m_serviceType = value.lower(); size_t pos = m_serviceType.find(";"); if (pos != notFound) m_serviceType = m_serviceType.left(pos); if (renderer()) setNeedsWidgetUpdate(true); } else if (name == dataAttr) { m_url = stripLeadingAndTrailingHTMLSpaces(value); if (renderer()) { setNeedsWidgetUpdate(true); if (isImageType()) { if (!m_imageLoader) m_imageLoader = adoptPtr(new HTMLImageLoader(this)); m_imageLoader->updateFromElementIgnoringPreviousError(); } } } else if (name == classidAttr) { m_classId = value; if (renderer()) setNeedsWidgetUpdate(true); } else if (name == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, name, value); else HTMLPlugInImageElement::parseAttribute(name, value); }
void HTMLObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == formAttr) formAttributeChanged(); else if (name == typeAttr) { m_serviceType = value.string().left(value.find(';')).lower(); setNeedsWidgetUpdate(true); } else if (name == dataAttr) { m_url = stripLeadingAndTrailingHTMLSpaces(value); setNeedsWidgetUpdate(true); document().updateStyleIfNeeded(); if (renderer()) { if (isImageType()) { if (!m_imageLoader) m_imageLoader = std::make_unique<HTMLImageLoader>(*this); m_imageLoader->updateFromElementIgnoringPreviousError(); } } } else if (name == classidAttr) setNeedsWidgetUpdate(true); else if (name == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, name, value); else HTMLPlugInImageElement::parseAttribute(name, value); }
void HTMLObjectElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == typeAttr) { m_serviceType = attr->value().lower(); size_t pos = m_serviceType.find(";"); if (pos != notFound) m_serviceType = m_serviceType.left(pos); if (renderer()) setNeedsWidgetUpdate(true); if (!isImageType() && m_imageLoader) m_imageLoader.clear(); } else if (attr->name() == dataAttr) { m_url = stripLeadingAndTrailingHTMLSpaces(attr->value()); if (renderer()) { setNeedsWidgetUpdate(true); if (isImageType()) { if (!m_imageLoader) m_imageLoader = adoptPtr(new HTMLImageLoader(this)); m_imageLoader->updateFromElementIgnoringPreviousError(); } } } else if (attr->name() == classidAttr) { m_classId = attr->value(); if (renderer()) setNeedsWidgetUpdate(true); } else if (attr->name() == onloadAttr) setAttributeEventListener(eventNames().loadEvent, NULL_METHOD_RESULT(this, attr)); else if (attr->name() == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, NULL_METHOD_RESULT(this, attr)); else if (attr->name() == nameAttr) { const AtomicString& newName = attr->value(); if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeNamedItem(m_name); document->addNamedItem(newName); } m_name = newName; } else if (attr->name() == borderAttr) { addCSSLength(attr, CSSPropertyBorderWidth, attr->value().toInt() ? attr->value() : "0"); addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid); addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid); addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid); addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid); } else if (isIdAttributeName(attr->name())) { const AtomicString& newId = attr->value(); if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeExtraNamedItem(m_id); document->addExtraNamedItem(newId); } m_id = newId; // also call superclass HTMLPlugInImageElement::parseMappedAttribute(attr); } else HTMLPlugInImageElement::parseMappedAttribute(attr); }
void HTMLObjectElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == typeAttr) { m_serviceType = attr->value().lower(); size_t pos = m_serviceType.find(";"); if (pos != notFound) m_serviceType = m_serviceType.left(pos); if (renderer()) setNeedsWidgetUpdate(true); if (!isImageType() && m_imageLoader) m_imageLoader.clear(); } else if (attr->name() == dataAttr) { m_url = deprecatedParseURL(attr->value()); if (renderer()) { setNeedsWidgetUpdate(true); if (isImageType()) { if (!m_imageLoader) m_imageLoader = adoptPtr(new HTMLImageLoader(this)); m_imageLoader->updateFromElementIgnoringPreviousError(); } } } else if (attr->name() == classidAttr) { m_classId = attr->value(); if (renderer()) setNeedsWidgetUpdate(true); } else if (attr->name() == onloadAttr) setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr)); else if (attr->name() == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr)); else if (attr->name() == nameAttr) { const AtomicString& newName = attr->value(); if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeNamedItem(m_name); document->addNamedItem(newName); } m_name = newName; } else if (isIdAttributeName(attr->name())) { const AtomicString& newId = attr->value(); if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeExtraNamedItem(m_id); document->addExtraNamedItem(newId); } m_id = newId; // also call superclass HTMLPlugInImageElement::parseMappedAttribute(attr); } else HTMLPlugInImageElement::parseMappedAttribute(attr); }
// FIXME: This should be unified with HTMLEmbedElement::updateWidget and // moved down into HTMLPluginImageElement.cpp void HTMLObjectElement::updateWidget(PluginCreationOption pluginCreationOption) { ASSERT(!renderEmbeddedObject()->isPluginUnavailable()); ASSERT(needsWidgetUpdate()); setNeedsWidgetUpdate(false); // FIXME: This should ASSERT isFinishedParsingChildren() instead. if (!isFinishedParsingChildren()) return; // FIXME: I'm not sure it's ever possible to get into updateWidget during a // removal, but just in case we should avoid loading the frame to prevent // security bugs. if (!SubframeLoadingDisabler::canLoadFrame(*this)) return; String url = this->url(); String serviceType = this->serviceType(); // FIXME: These should be joined into a PluginParameters class. Vector<String> paramNames; Vector<String> paramValues; parametersForPlugin(paramNames, paramValues, url, serviceType); // Note: url is modified above by parametersForPlugin. if (!allowedToLoadFrameURL(url)) return; bool fallbackContent = hasFallbackContent(); renderEmbeddedObject()->setHasFallbackContent(fallbackContent); // FIXME: It's sadness that we have this special case here. // See http://trac.webkit.org/changeset/25128 and // plugins/netscape-plugin-setwindow-size.html if (pluginCreationOption == CreateOnlyNonNetscapePlugins && wouldLoadAsNetscapePlugin(url, serviceType)) { // Ensure updateWidget() is called again during layout to create the Netscape plug-in. setNeedsWidgetUpdate(true); return; } Ref<HTMLObjectElement> protect(*this); // beforeload and plugin loading can make arbitrary DOM mutations. bool beforeLoadAllowedLoad = guardedDispatchBeforeLoadEvent(url); if (!renderer()) // Do not load the plugin if beforeload removed this element or its renderer. return; SubframeLoader& loader = document().frame()->loader().subframeLoader(); bool success = beforeLoadAllowedLoad && hasValidClassId() && loader.requestObject(this, url, getNameAttribute(), serviceType, paramNames, paramValues); if (!success && fallbackContent) renderFallbackContent(); }
void HTMLPlugInElement::detach(const AttachContext& context) { // Update the widget the next time we attach (detaching destroys the plugin). // FIXME: None of this "needsWidgetUpdate" related code looks right. if (renderer() && !useFallbackContent()) setNeedsWidgetUpdate(true); if (m_isDelayingLoadEvent) { m_isDelayingLoadEvent = false; document().decrementLoadEventDelayCount(); } // Only try to persist a plugin widget we actually own. Widget* plugin = ownedWidget(); if (plugin && plugin->pluginShouldPersist()) m_persistedPluginWidget = plugin; resetInstance(); // FIXME - is this next line necessary? setWidget(nullptr); if (m_isCapturingMouseEvents) { if (LocalFrame* frame = document().frame()) frame->eventHandler().setCapturingMouseEventsNode(nullptr); m_isCapturingMouseEvents = false; } if (m_NPObject) { _NPN_ReleaseObject(m_NPObject); m_NPObject = 0; } HTMLFrameOwnerElement::detach(context); }
void HTMLObjectElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta) { updateDocNamedItem(); if (inDocument() && !useFallbackContent()) { setNeedsWidgetUpdate(true); setNeedsStyleRecalc(); } HTMLPlugInImageElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta); }
void HTMLObjectElement::childrenChanged(const ChildChange& change) { updateDocNamedItem(); if (inDocument() && !useFallbackContent()) { setNeedsWidgetUpdate(true); setNeedsStyleRecalc(); } HTMLPlugInImageElement::childrenChanged(change); }
void HTMLObjectElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == formAttr) formAttributeChanged(); else if (name == typeAttr) { m_serviceType = value.string().left(value.find(';')).lower(); setNeedsWidgetUpdate(true); } else if (name == dataAttr) { m_url = stripLeadingAndTrailingHTMLSpaces(value); setNeedsWidgetUpdate(true); updateImageLoaderWithNewURLSoon(); } else if (name == classidAttr) setNeedsWidgetUpdate(true); else if (name == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, name, value); else HTMLPlugInImageElement::parseAttribute(name, value); }
void HTMLPlugInImageElement::finishParsingChildren() { HTMLPlugInElement::finishParsingChildren(); if (useFallbackContent()) return; setNeedsWidgetUpdate(true); if (inDocument()) setNeedsStyleRecalc(); }
void HTMLPlugInImageElement::detach() { // FIXME: Because of the insanity that is HTMLPlugInImageElement::recalcStyle, // we can end up detaching during an attach() call, before we even have a // renderer. In that case, don't mark the widget for update. if (attached() && renderer() && !useFallbackContent()) // Update the widget the next time we attach (detaching destroys the plugin). setNeedsWidgetUpdate(true); HTMLPlugInElement::detach(); }
void HTMLPlugInElement::finishParsingChildren() { HTMLFrameOwnerElement::finishParsingChildren(); if (useFallbackContent()) return; setNeedsWidgetUpdate(true); if (inDocument()) setNeedsStyleRecalc(SubtreeStyleChange); }
// FIXME: This should be unified with HTMLEmbedElement::updateWidget and // moved down into HTMLPluginImageElement.cpp void HTMLObjectElement::updateWidget(bool onlyCreateNonNetscapePlugins) { ASSERT(!renderEmbeddedObject()->pluginCrashedOrWasMissing()); // FIXME: We should ASSERT(needsWidgetUpdate()), but currently // FrameView::updateWidget() calls updateWidget(false) without checking if // the widget actually needs updating! setNeedsWidgetUpdate(false); // FIXME: This should ASSERT isFinishedParsingChildren() instead. if (!isFinishedParsingChildren()) return; String url = this->url(); // If the object does not specify a MIME type via a type attribute, but does // contain a classid attribute, try to map the classid to a MIME type. String serviceType = this->serviceType(); if (serviceType.isEmpty()) serviceType = serviceTypeForClassId(classId()); // FIXME: These should be joined into a PluginParameters class. Vector<String> paramNames; Vector<String> paramValues; parametersForPlugin(paramNames, paramValues, url, serviceType); // Note: url is modified above by parametersForPlugin. if (!allowedToLoadFrameURL(url)) return; bool fallbackContent = hasFallbackContent(); renderEmbeddedObject()->setHasFallbackContent(fallbackContent); if (onlyCreateNonNetscapePlugins && wouldLoadAsNetscapePlugin(url, serviceType)) return; bool beforeLoadAllowedLoad = dispatchBeforeLoadEvent(url); // beforeload events can modify the DOM, potentially causing // RenderWidget::destroy() to be called. Ensure we haven't been // destroyed before continuing. // FIXME: Should this render fallback content? if (!renderer()) return; SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); bool success = beforeLoadAllowedLoad && loader->requestObject(this, url, getAttribute(nameAttr), serviceType, paramNames, paramValues); if (!success && fallbackContent) renderFallbackContent(); }
// FIXME: This should be unified with HTMLEmbedElement::updateWidget and // moved down into HTMLPluginImageElement.cpp void HTMLObjectElement::updateWidget(PluginCreationOption pluginCreationOption) { ASSERT(!renderEmbeddedObject()->pluginCrashedOrWasMissing()); // FIXME: We should ASSERT(needsWidgetUpdate()), but currently // FrameView::updateWidget() calls updateWidget(false) without checking if // the widget actually needs updating! setNeedsWidgetUpdate(false); // FIXME: This should ASSERT isFinishedParsingChildren() instead. if (!isFinishedParsingChildren()) return; String url = this->url(); String serviceType = this->serviceType(); // FIXME: These should be joined into a PluginParameters class. Vector<String> paramNames; Vector<String> paramValues; parametersForPlugin(paramNames, paramValues, url, serviceType); // Note: url is modified above by parametersForPlugin. if (!allowedToLoadFrameURL(url)) return; bool fallbackContent = hasFallbackContent(); renderEmbeddedObject()->setHasFallbackContent(fallbackContent); if (pluginCreationOption == CreateOnlyNonNetscapePlugins && wouldLoadAsNetscapePlugin(url, serviceType)) return; ASSERT(!m_inBeforeLoadEventHandler); m_inBeforeLoadEventHandler = true; bool beforeLoadAllowedLoad = dispatchBeforeLoadEvent(url); m_inBeforeLoadEventHandler = false; // beforeload events can modify the DOM, potentially causing // RenderWidget::destroy() to be called. Ensure we haven't been // destroyed before continuing. // FIXME: Should this render fallback content? if (!renderer()) return; RefPtr<HTMLObjectElement> protect(this); // Loading the plugin might remove us from the document. SubframeLoader* loader = document()->frame()->loader()->subframeLoader(); bool success = beforeLoadAllowedLoad && hasValidClassId() && loader->requestObject(this, url, getAttribute(nameAttr), serviceType, paramNames, paramValues); if (!success && fallbackContent) renderFallbackContent(); }