/*! Returns the namespace URI. Note that for efficiency, the namespace URI string is not stored in the QXmlName but in the \l {QXmlNamePool} that was passed to the constructor. Hence, that same \a namePool must be passed to this function, so it can be used for looking up the namespace URI. */ QString QXmlName::namespaceUri(const QXmlNamePool &namePool) const { if(isNull()) return QString(); else return namePool.d->stringForNamespace(namespaceURI()); }
static nsresult ExtractAttribute(nsIDOMNode* aNode, const char* aAttribute, const char* aNamespaceURI, nsCString& aValue) { nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode); MOZ_ASSERT(element); // Find the named URI attribute on the (element) node and store // a reference to the URI that maps onto a local file name nsCOMPtr<nsIDOMMozNamedAttrMap> attrMap; nsresult rv = element->GetAttributes(getter_AddRefs(attrMap)); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); NS_ConvertASCIItoUTF16 namespaceURI(aNamespaceURI); NS_ConvertASCIItoUTF16 attribute(aAttribute); nsCOMPtr<nsIDOMAttr> attr; rv = attrMap->GetNamedItemNS(namespaceURI, attribute, getter_AddRefs(attr)); NS_ENSURE_SUCCESS(rv, rv); if (attr) { nsAutoString value; rv = attr->GetValue(value); NS_ENSURE_SUCCESS(rv, rv); aValue = NS_ConvertUTF16toUTF8(value); } else { aValue.Truncate(); } return NS_OK; }
void StyledElement::makePresentationAttributeCacheKey(PresentationAttributeCacheKey& result) const { // FIXME: Enable for SVG. if (namespaceURI() != xhtmlNamespaceURI) return; // Interpretation of the size attributes on <input> depends on the type attribute. if (hasTagName(inputTag)) return; for (const Attribute& attribute : attributesIterator()) { if (!isPresentationAttribute(attribute.name())) continue; if (!attribute.namespaceURI().isNull()) return; // FIXME: Background URL may depend on the base URL and can't be shared. Disallow caching. if (attribute.name() == backgroundAttr) return; result.attributesAndValues.append(std::make_pair(attribute.localName().impl(), attribute.value())); } if (result.attributesAndValues.isEmpty()) return; // Attribute order doesn't matter. Sort for easy equality comparison. std::sort(result.attributesAndValues.begin(), result.attributesAndValues.end(), attributeNameSort); // The cache key is non-null when the tagName is set. result.tagName = localName().impl(); }
AtomicString XMLTreeBuilder::NodeStackItem::namespaceForPrefix(AtomicString prefix, AtomicString fallback) { AtomicString uri = fallback; if (!prefix.isNull() && hasNamespaceURI(prefix)) uri = namespaceURI(prefix); return uri; }
String CSSNamespaceRule::cssText() const { StringBuilder result; result.append("@namespace "); serializeIdentifier(prefix(), result); if (!prefix().isEmpty()) result.append(" "); result.append("url("); result.append(serializeString(namespaceURI())); result.append(");"); return result.toString(); }
PassRefPtr<Node> Element::cloneNode(bool deep) { ExceptionCode ec = 0; RefPtr<Element> clone = document()->createElementNS(namespaceURI(), nodeName(), ec); ASSERT(!ec); // clone attributes if (namedAttrMap) clone->attributes()->setAttributes(*namedAttrMap); clone->copyNonAttributeProperties(this); if (deep) cloneChildNodes(clone.get()); return clone.release(); }
static void ExtractAttribute(Element* aElement, const char* aAttribute, const char* aNamespaceURI, nsCString& aValue) { // Find the named URI attribute on the (element) node and store // a reference to the URI that maps onto a local file name RefPtr<nsDOMAttributeMap> attrMap = aElement->Attributes(); NS_ConvertASCIItoUTF16 namespaceURI(aNamespaceURI); NS_ConvertASCIItoUTF16 attribute(aAttribute); RefPtr<dom::Attr> attr = attrMap->GetNamedItemNS(namespaceURI, attribute); if (attr) { nsAutoString value; attr->GetValue(value); CopyUTF16toUTF8(value, aValue); } else { aValue.Truncate(); } }
void QualifiedName::setPrefix(const AtomicString& prefix) { QualifiedName other(prefix, localName(), namespaceURI()); *this = other; }