/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
void HTMLSharedElement::GetHref(nsAString& aValue) {
MOZ_ASSERT(mNodeInfo->Equals(nsGkAtoms::base), "This should only get called for elements");
nsAutoString href;
GetAttr(nsGkAtoms::href, href);
void HTMLSharedElement::DoneAddingChildren(bool aHaveNotified) { if (mNodeInfo->Equals(nsGkAtoms::head)) { if (nsCOMPtr<Document> doc = GetUncomposedDoc()) {
doc->OnL10nResourceContainerParsed(); if (!doc->IsLoadedAsData()) {
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(this, u"DOMHeadElementParsed"_ns,
CanBubble::eYes, ChromeOnlyDispatch::eYes); // Always run async in order to avoid running script when the content // sink isn't expecting it.
asyncDispatcher->PostDOMEvent();
}
}
}
}
staticvoid SetBaseURIUsingFirstBaseWithHref(Document* aDocument,
nsIContent* aMustMatch) {
MOZ_ASSERT(aDocument, "Need a document!");
for (nsIContent* child = aDocument->GetFirstChild(); child;
child = child->GetNextNode()) { if (child->IsHTMLElement(nsGkAtoms::base) &&
child->AsElement()->HasAttr(nsGkAtoms::href)) { if (aMustMatch && child != aMustMatch) { return;
}
// Resolve the <base> element's href relative to our document's // fallback base URI.
nsAutoString href;
child->AsElement()->GetAttr(nsGkAtoms::href, href);
void HTMLSharedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal, bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::href) { // If the href attribute of a <base> tag is changing, we may need to // update the document's base URI, which will cause all the links on the // page to be re-resolved given the new base. // If the href is being unset (aValue is null), we will need to find a new // <base>. if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
SetBaseURIUsingFirstBaseWithHref(GetUncomposedDoc(),
aValue ? this : nullptr);
}
} elseif (aName == nsGkAtoms::target) { // The target attribute is in pretty much the same situation as the href // attribute, above. if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) {
SetBaseTargetUsingFirstBaseWithTarget(GetUncomposedDoc(),
aValue ? this : nullptr);
}
}
}
// The document stores a pointer to its base URI and base target, which we may // need to update here. if (mNodeInfo->Equals(nsGkAtoms::base) && IsInUncomposedDoc()) { if (HasAttr(nsGkAtoms::href)) {
SetBaseURIUsingFirstBaseWithHref(&aContext.OwnerDoc(), this);
} if (HasAttr(nsGkAtoms::target)) {
SetBaseTargetUsingFirstBaseWithTarget(&aContext.OwnerDoc(), this);
}
}
// If we're removing a <base> from a document, we may need to update the // document's base URI and base target if (doc && mNodeInfo->Equals(nsGkAtoms::base)) { if (HasAttr(nsGkAtoms::href)) {
SetBaseURIUsingFirstBaseWithHref(doc, nullptr);
} if (HasAttr(nsGkAtoms::target)) {
SetBaseTargetUsingFirstBaseWithTarget(doc, nullptr);
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.