void HTMLAnchorElement::parseAttribute(Attribute* attr) { if (attr->name() == hrefAttr) { bool wasLink = isLink(); setIsLink(!attr->isNull()); if (wasLink != isLink()) setNeedsStyleRecalc(); if (isLink()) { String parsedURL = stripLeadingAndTrailingHTMLSpaces(attr->value()); if (document()->isDNSPrefetchEnabled()) { if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") || parsedURL.startsWith("//")) prefetchDNS(document()->completeURL(parsedURL).host()); } if (document()->page() && !document()->page()->javaScriptURLsAreAllowed() && protocolIsJavaScript(parsedURL)) { clearIsLink(); // FIXME: This is horribly factored. if (Attribute* hrefAttribute = getAttributeItem(hrefAttr)) hrefAttribute->setValue(nullAtom); } #ifdef ARTEMIS else if(protocolIsJavaScript(parsedURL) && !hasEventListeners(eventNames().clickEvent)) { // Don't set the onclick event handler if it already has one. setAttributeEventListener(eventNames().clickEvent, createAttributeEventListener(this, attr)); } #endif } invalidateCachedVisitedLinkHash(); } else if (attr->name() == nameAttr || attr->name() == titleAttr) { // Do nothing. } else if (attr->name() == relAttr) setRel(attr->value()); else HTMLElement::parseAttribute(attr); }
void HTMLAnchorElement::parseAttribute(const Attribute& attribute) { if (attribute.name() == hrefAttr) { bool wasLink = isLink(); setIsLink(!attribute.isNull()); if (wasLink != isLink()) setNeedsStyleRecalc(); if (isLink()) { String parsedURL = stripLeadingAndTrailingHTMLSpaces(attribute.value()); if (document()->isDNSPrefetchEnabled()) { if (protocolIs(parsedURL, "http") || protocolIs(parsedURL, "https") || parsedURL.startsWith("//")) prefetchDNS(document()->completeURL(parsedURL).host()); } if (document()->page() && !document()->page()->javaScriptURLsAreAllowed() && protocolIsJavaScript(parsedURL)) { clearIsLink(); // FIXME: This is horribly factored. if (Attribute* hrefAttribute = getAttributeItem(hrefAttr)) hrefAttribute->setValue(nullAtom); } } invalidateCachedVisitedLinkHash(); } else if (attribute.name() == nameAttr || attribute.name() == titleAttr) { // Do nothing. } else if (attribute.name() == relAttr) setRel(attribute.value()); else HTMLElement::parseAttribute(attribute); }
PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const QualifiedName& name, Element* element) const { ASSERT(element); Attribute* attribute = getAttributeItem(name); if (!attribute) return 0; return const_cast<ElementAttributeData*>(this)->ensureAttr(element, attribute->name()); }
PassRefPtr<Attr> ElementAttributeData::getAttributeNode(const String& name, bool shouldIgnoreAttributeCase, Element* element) const { ASSERT(element); Attribute* attribute = getAttributeItem(name, shouldIgnoreAttributeCase); if (!attribute) return 0; return const_cast<ElementAttributeData*>(this)->ensureAttr(element, attribute->name()); }
void ElementAttributeData::setAttributes(const ElementAttributeData& other, Element* element) { ASSERT(element); // If assigning the map changes the id attribute, we need to call // updateId. Attribute* oldId = getAttributeItem(element->document()->idAttributeName()); Attribute* newId = other.getAttributeItem(element->document()->idAttributeName()); if (oldId || newId) element->updateId(oldId ? oldId->value() : nullAtom, newId ? newId->value() : nullAtom); Attribute* oldName = getAttributeItem(HTMLNames::nameAttr); Attribute* newName = other.getAttributeItem(HTMLNames::nameAttr); if (oldName || newName) element->updateName(oldName ? oldName->value() : nullAtom, newName ? newName->value() : nullAtom); clearAttributes(element); m_attributes = other.m_attributes; for (unsigned i = 0; i < m_attributes.size(); ++i) element->attributeChanged(&m_attributes[i]); }
PassRefPtrWillBeRawPtr<CSSValue> SVGElement::getPresentationAttribute(const AtomicString& name) { if (!hasAttributesWithoutUpdate()) return nullptr; QualifiedName attributeName(nullAtom, name, nullAtom); const Attribute* attr = getAttributeItem(attributeName); if (!attr) return nullptr; RefPtr<MutableStylePropertySet> style = MutableStylePropertySet::create(SVGAttributeMode); CSSPropertyID propertyID = SVGElement::cssPropertyIdForSVGAttributeName(attr->name()); style->setProperty(propertyID, attr->value()); RefPtrWillBeRawPtr<CSSValue> cssValue = style->getPropertyCSSValue(propertyID); return cssValue ? cssValue->cloneForCSSOM() : nullptr; }