Bug 1957689 - Fix detection of cross-doc references.

MANUAL PUSH: Orange fix CLOSED TREE
This commit is contained in:
Emilio Cobos Álvarez
2025-04-02 19:17:42 +02:00
parent 6f0584dfe3
commit 9512128f4f
4 changed files with 18 additions and 16 deletions

View File

@@ -140,7 +140,11 @@ static nsIURI* GetExternalResourceURIIfNeeded(nsIURI* aBaseURI,
if (!use) {
return nullptr;
}
nsIURI* originalURI = use->GetSourceDocURI();
Document* doc = use->GetSourceDocument();
if (!doc || doc == aFrom.OwnerDoc()) {
return nullptr;
}
nsIURI* originalURI = doc->GetDocumentURI();
if (!originalURI) {
return nullptr;
}

View File

@@ -51,7 +51,7 @@ class IDTracker {
/**
* Find which element, if any, is referenced.
*/
Element* get() { return mElement; }
Element* get() const { return mElement; }
/**
* Set up a reference to another element, identified by the fragment

View File

@@ -485,22 +485,19 @@ void SVGUseElement::UpdateShadowTree() {
targetElement->AddMutationObserver(this);
}
nsIURI* SVGUseElement::GetSourceDocURI() {
Document* SVGUseElement::GetSourceDocument() const {
nsIContent* targetElement = mReferencedElementTracker.get();
if (!targetElement) {
return nullptr;
}
return targetElement->OwnerDoc()->GetDocumentURI();
return targetElement ? targetElement->OwnerDoc() : nullptr;
}
const Encoding* SVGUseElement::GetSourceDocCharacterSet() {
nsIContent* targetElement = mReferencedElementTracker.get();
if (!targetElement) {
return nullptr;
}
nsIURI* SVGUseElement::GetSourceDocURI() const {
auto* doc = GetSourceDocument();
return doc ? doc->GetDocumentURI() : nullptr;
}
return targetElement->OwnerDoc()->GetDocumentCharacterSet();
const Encoding* SVGUseElement::GetSourceDocCharacterSet() const {
auto* doc = GetSourceDocument();
return doc ? doc->GetDocumentCharacterSet() : nullptr;
}
static nsINode* GetClonedChild(const SVGUseElement& aUseElement) {

View File

@@ -80,8 +80,9 @@ class SVGUseElement final : public SVGUseElementBase,
already_AddRefed<DOMSVGAnimatedLength> Width();
already_AddRefed<DOMSVGAnimatedLength> Height();
nsIURI* GetSourceDocURI();
const Encoding* GetSourceDocCharacterSet();
Document* GetSourceDocument() const;
nsIURI* GetSourceDocURI() const;
const Encoding* GetSourceDocCharacterSet() const;
URLExtraData* GetContentURLData() const { return mContentURLData; }
// Updates the internal shadow tree to be an up-to-date clone of the