void HTMLAppletElement::parseMappedAttribute(MappedAttribute* attr) { if (attr->name() == altAttr || attr->name() == archiveAttr || attr->name() == codeAttr || attr->name() == codebaseAttr || attr->name() == mayscriptAttr || attr->name() == objectAttr) { // Do nothing. } else if (attr->name() == nameAttr) { const AtomicString& newName = attr->value(); if (inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeNamedItem(m_name); document->addNamedItem(newName); } m_name = newName; } else if (attr->name() == idAttr) { const AtomicString& newId = attr->value(); if (inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeExtraNamedItem(m_id); document->addExtraNamedItem(newId); } m_id = newId; // also call superclass HTMLPlugInElement::parseMappedAttribute(attr); } else HTMLPlugInElement::parseMappedAttribute(attr); }
void HTMLObjectElement::updateDocNamedItem() { // The rule is "<object> elements with no children other than // <param> elements, unknown elements and whitespace can be // found by name in a document, and other <object> elements cannot." bool wasNamedItem = m_docNamedItem; bool isNamedItem = true; Node* child = firstChild(); while (child && isNamedItem) { if (child->isElementNode()) { Element* element = static_cast<Element*>(child); if (HTMLElement::isRecognizedTagName(element->tagQName()) && !element->hasTagName(paramTag)) isNamedItem = false; } else if (child->isTextNode()) { if (!static_cast<Text*>(child)->containsOnlyWhitespace()) isNamedItem = false; } else isNamedItem = false; child = child->nextSibling(); } if (isNamedItem != wasNamedItem && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); if (isNamedItem) { document->addNamedItem(m_name); document->addExtraNamedItem(m_id); } else { document->removeNamedItem(m_name); document->removeExtraNamedItem(m_id); } } m_docNamedItem = isNamedItem; }
void HTMLIFrameElement::parseMappedAttribute(Attribute* attr) { if (attr->name() == widthAttr) addCSSLength(attr, CSSPropertyWidth, attr->value()); else if (attr->name() == heightAttr) addCSSLength(attr, CSSPropertyHeight, attr->value()); else if (attr->name() == alignAttr) addHTMLAlignment(attr); else if (attr->name() == nameAttr) { const AtomicString& newName = attr->value(); if (inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeExtraNamedItem(m_name); document->addExtraNamedItem(newName); } m_name = newName; } else if (attr->name() == frameborderAttr) { // Frame border doesn't really match the HTML4 spec definition for iframes. It simply adds // a presentational hint that the border should be off if set to zero. if (!attr->isNull() && !attr->value().toInt()) // Add a rule that nulls out our border width. addCSSLength(attr, CSSPropertyBorderWidth, "0"); } else if (attr->name() == sandboxAttr) setSandboxFlags(parseSandboxAttribute(attr)); else HTMLFrameElementBase::parseMappedAttribute(attr); }
void HTMLImageElement::parseMappedAttribute(Attribute* attr) { const QualifiedName& attrName = attr->name(); if (attrName == altAttr) { if (renderer() && renderer()->isImage()) toRenderImage(renderer())->updateAltText(); } else if (attrName == srcAttr) m_imageLoader.updateFromElementIgnoringPreviousError(); else if (attrName == widthAttr) addCSSLength(attr, CSSPropertyWidth, attr->value()); else if (attrName == heightAttr) addCSSLength(attr, CSSPropertyHeight, attr->value()); else if (attrName == borderAttr) { // border="noborder" -> border="0" applyBorderAttribute(attr); } else if (attrName == vspaceAttr) { addCSSLength(attr, CSSPropertyMarginTop, attr->value()); addCSSLength(attr, CSSPropertyMarginBottom, attr->value()); } else if (attrName == hspaceAttr) { addCSSLength(attr, CSSPropertyMarginLeft, attr->value()); addCSSLength(attr, CSSPropertyMarginRight, attr->value()); } else if (attrName == alignAttr) addHTMLAlignment(attr); else if (attrName == valignAttr) addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value()); else if (attrName == usemapAttr) setIsLink(!attr->isNull()); else if (attrName == onabortAttr) setAttributeEventListener(eventNames().abortEvent, createAttributeEventListener(this, attr)); else if (attrName == onloadAttr) setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr)); else if (attrName == onbeforeloadAttr) setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr)); else if (attrName == compositeAttr) { if (!parseCompositeOperator(attr->value(), m_compositeOperator)) m_compositeOperator = CompositeSourceOver; } else if (attrName == nameAttr) { const AtomicString& newName = attr->value(); if (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 (inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeExtraNamedItem(m_id); document->addExtraNamedItem(newId); } m_id = newId; // also call superclass HTMLElement::parseMappedAttribute(attr); } else HTMLElement::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 = 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::insertedIntoDocument() { if (isDocNamedItem() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->addNamedItem(m_name); document->addExtraNamedItem(m_id); } HTMLPlugInElement::insertedIntoDocument(); }
void HTMLImageElement::insertedIntoDocument() { if (document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->addNamedItem(m_name); document->addExtraNamedItem(m_id); } HTMLElement::insertedIntoDocument(); }
void HTMLObjectElement::parseMappedAttribute(Attribute* attr) { String val = attr->value(); int pos; if (attr->name() == typeAttr) { m_serviceType = val.lower(); pos = m_serviceType.find(";"); if (pos != -1) m_serviceType = m_serviceType.left(pos); if (renderer()) m_needWidgetUpdate = true; if (!isImageType() && m_imageLoader) m_imageLoader.clear(); } else if (attr->name() == dataAttr) { m_url = deprecatedParseURL(val); if (renderer()) m_needWidgetUpdate = true; if (renderer() && isImageType()) { if (!m_imageLoader) m_imageLoader.set(new HTMLImageLoader(this)); m_imageLoader->updateFromElementIgnoringPreviousError(); } } else if (attr->name() == classidAttr) { m_classId = val; if (renderer()) m_needWidgetUpdate = 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 HTMLPlugInElement::parseMappedAttribute(attr); } else HTMLPlugInElement::parseMappedAttribute(attr); }
void HTMLObjectElement::insertedIntoDocument() { HTMLPlugInImageElement::insertedIntoDocument(); if (!inDocument()) return; if (isDocNamedItem() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->addNamedItem(m_name); document->addExtraNamedItem(m_id); } FormAssociatedElement::insertedIntoDocument(); }
void HTMLImageElement::insertedIntoDocument() { if (document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->addNamedItem(m_name); document->addExtraNamedItem(m_id); } // If we have been inserted from a renderer-less document, // our loader may have not fetched the image, so do it now. if (!m_imageLoader.image()) m_imageLoader.updateFromElement(); HTMLElement::insertedIntoDocument(); }
void HTMLIFrameElement::parseAttribute(const QualifiedName& name, const AtomicString& value) { if (name == nameAttr) { if (inDocument() && document()->isHTMLDocument() && !isInShadowTree()) { HTMLDocument* document = toHTMLDocument(this->document()); document->removeExtraNamedItem(m_name); document->addExtraNamedItem(value); } m_name = value; } else if (name == sandboxAttr) { String invalidTokens; setSandboxFlags(value.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(value, invalidTokens)); if (!invalidTokens.isNull()) document()->addConsoleMessage(OtherMessageSource, ErrorMessageLevel, "Error while parsing the 'sandbox' attribute: " + invalidTokens); } else if (name == seamlessAttr) { // If we're adding or removing the seamless attribute, we need to force the content document to recalculate its StyleResolver. if (contentDocument()) contentDocument()->styleResolverChanged(DeferRecalcStyle); } else HTMLFrameElementBase::parseAttribute(name, value); }
void HTMLImageElement::insertedIntoDocument() { if (document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->addNamedItem(m_name); document->addExtraNamedItem(m_id); } // If we have been inserted from a renderer-less document, // our loader may have not fetched the image, so do it now. if (!m_imageLoader.image()) m_imageLoader.updateFromElement(); HTMLElement::insertedIntoDocument(); Request* req = cache()->loader()->requestForUrl(src().string()); if (!req) return; req->setNode(PassRefPtr<Node>(this)); }
void HTMLImageElement::parseMappedAttribute(MappedAttribute* attr) { const QualifiedName& attrName = attr->name(); if (attrName == altAttr) { if (renderer() && renderer()->isImage()) static_cast<RenderImage*>(renderer())->updateAltText(); } else if (attrName == srcAttr) m_imageLoader.updateFromElement(); else if (attrName == widthAttr) addCSSLength(attr, CSSPropertyWidth, attr->value()); else if (attrName == heightAttr) addCSSLength(attr, CSSPropertyHeight, attr->value()); else if (attrName == borderAttr) { // border="noborder" -> border="0" 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 (attrName == vspaceAttr) { addCSSLength(attr, CSSPropertyMarginTop, attr->value()); addCSSLength(attr, CSSPropertyMarginBottom, attr->value()); } else if (attrName == hspaceAttr) { addCSSLength(attr, CSSPropertyMarginLeft, attr->value()); addCSSLength(attr, CSSPropertyMarginRight, attr->value()); } else if (attrName == alignAttr) addHTMLAlignment(attr); else if (attrName == valignAttr) addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value()); else if (attrName == usemapAttr) { if (attr->value().string()[0] == '#') usemap = attr->value(); else usemap = document()->completeURL(parseURL(attr->value())).string(); setIsLink(!attr->isNull()); } else if (attrName == ismapAttr) ismap = true; else if (attrName == onabortAttr) setInlineEventListenerForTypeAndAttribute(eventNames().abortEvent, attr); else if (attrName == onloadAttr) setInlineEventListenerForTypeAndAttribute(eventNames().loadEvent, attr); else if (attrName == compositeAttr) { if (!parseCompositeOperator(attr->value(), m_compositeOperator)) m_compositeOperator = CompositeSourceOver; } else if (attrName == nameAttr) { const AtomicString& newName = attr->value(); if (inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeNamedItem(m_name); document->addNamedItem(newName); } m_name = newName; } else if (attr->name() == idAttr) { const AtomicString& newId = attr->value(); if (inDocument() && document()->isHTMLDocument()) { HTMLDocument* document = static_cast<HTMLDocument*>(this->document()); document->removeExtraNamedItem(m_id); document->addExtraNamedItem(newId); } m_id = newId; // also call superclass HTMLElement::parseMappedAttribute(attr); } else HTMLElement::parseMappedAttribute(attr); }