/* -*- 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/. */
// We allow looking outside an <svg:use> shadow tree for backwards compat. while (shadow && shadow->Host()->IsSVGElement(nsGkAtoms::use)) { // <svg:use> shadow trees are immutable, so we can just early-out if we find // our relevant element instead of having to support watching multiple // trees. if (LookupElement(*shadow, aID, aReferenceImage)) { return shadow;
}
shadow = shadow->Host()->GetContainingShadow();
}
nsAutoCString refPart;
aURI->GetRef(refPart); // Unescape %-escapes in the reference. The result will be in the // document charset, hopefully...
NS_UnescapeURL(refPart);
// Get the thing to observe changes to.
Document* doc = aFromContent->OwnerDoc(); auto encoding = doc->GetDocumentCharacterSet();
if (aFromContent->IsInNativeAnonymousSubtree()) { // This happens, for example, if aFromContent is part of the content // inserted by a call to Document::InsertAnonymousContent, which we // also want to handle. (It also happens for other native anonymous content // etc.)
Element* anonRoot =
doc->GetAnonRootIfInAnonymousContentContainer(aFromContent); if (anonRoot) {
mElement = nsContentUtils::MatchElementId(anonRoot, ref); // We don't have watching working yet for anonymous content, so bail out // here. return;
}
}
bool isEqualExceptRef;
rv = aURI->EqualsExceptRef(doc->GetDocumentURI(), &isEqualExceptRef);
DocumentOrShadowRoot* docOrShadow; if (NS_FAILED(rv) || !isEqualExceptRef) {
RefPtr<Document::ExternalResourceLoad> load;
doc = doc->RequestExternalResource(aURI, aReferrerInfo, aFromContent,
getter_AddRefs(load));
docOrShadow = doc; if (!doc) { if (!load) { // Nothing will ever happen here return;
}
DocumentLoadNotification* observer = new DocumentLoadNotification(this, ref);
mPendingNotification = observer;
load->AddObserver(observer); // Keep going so we set up our watching stuff a bit
}
} else {
docOrShadow = FindTreeToWatch(*aFromContent, ref, aReferenceImage);
}
auto ref = Substring(aLocalRef, 1); if (ref.IsEmpty()) {
Unlink(); return;
}
nsAutoCString utf8Ref; if (!AppendUTF16toUTF8(ref, utf8Ref, mozilla::fallible)) {
Unlink(); return;
}
// Only unescape ASCII characters; if we were to unescape arbitrary bytes, // we'd potentially end up with invalid UTF-8.
nsAutoCString unescaped; bool appended; if (NS_FAILED(NS_UnescapeURL(utf8Ref.BeginReading(), utf8Ref.Length(),
esc_OnlyASCII | esc_AlwaysCopy, unescaped,
appended, mozilla::fallible))) {
Unlink(); return;
}
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.