diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index 22fdac2d121d..73af62afc907 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -390,9 +390,6 @@ nsIContent::GetBaseURI(bool aTryUseXHRDocBaseURI) const if (!baseAttrs.IsEmpty()) { doc->WarnOnceAbout(nsIDocument::eXMLBaseAttribute); - if (IsHTMLElement() || IsSVGElement() || IsXULElement()) { - doc->WarnOnceAbout(nsIDocument::eXMLBaseAttributeWithStyledElement); - } // Now resolve against all xml:base attrs for (uint32_t i = baseAttrs.Length() - 1; i != uint32_t(-1); --i) { nsCOMPtr newBase; @@ -414,21 +411,38 @@ nsIContent::GetBaseURI(bool aTryUseXHRDocBaseURI) const return base.forget(); } -already_AddRefed -nsIContent::GetBaseURIForStyleAttr() const +nsIURI* +nsIContent::GetBaseURIWithoutXMLBase() const { - if (!nsLayoutUtils::StyleAttrWithXMLBaseDisabled()) { - return GetBaseURI(); - } if (IsInAnonymousSubtree() && IsAnonymousContentInSVGUseSubtree()) { nsIContent* bindingParent = GetBindingParent(); MOZ_ASSERT(bindingParent); SVGUseElement* useElement = static_cast(bindingParent); - return do_AddRef(useElement->GetContentBaseURI()); + return useElement->GetContentBaseURI(); } // This also ignores the case that SVG inside XBL binding. // But it is probably fine. - return do_AddRef(OwnerDoc()->GetDocBaseURI()); + return OwnerDoc()->GetDocBaseURI(); +} + +already_AddRefed +nsIContent::GetBaseURIForStyleAttr() const +{ + nsIDocument* doc = OwnerDoc(); + nsIURI* baseWithoutXMLBase = GetBaseURIWithoutXMLBase(); + nsCOMPtr base = GetBaseURI(); + // If eXMLBaseAttribute is not triggered in GetBaseURI() call above, + // we don't need to count eXMLBaseAttributeForStyleAttr either. + if (doc->HasWarnedAbout(nsIDocument::eXMLBaseAttribute) && + !doc->HasWarnedAbout(nsIDocument::eXMLBaseAttributeForStyleAttr)) { + bool isEqual = false; + base->Equals(baseWithoutXMLBase, &isEqual); + if (!isEqual) { + doc->WarnOnceAbout(nsIDocument::eXMLBaseAttributeForStyleAttr); + } + } + return nsLayoutUtils::StyleAttrWithXMLBaseDisabled() + ? do_AddRef(baseWithoutXMLBase) : base.forget(); } //---------------------------------------------------------------------- diff --git a/dom/base/nsDeprecatedOperationList.h b/dom/base/nsDeprecatedOperationList.h index b0b8f0c227cd..90a20c538e57 100644 --- a/dom/base/nsDeprecatedOperationList.h +++ b/dom/base/nsDeprecatedOperationList.h @@ -52,4 +52,4 @@ DEPRECATED_OPERATION(FileLastModifiedDate) DEPRECATED_OPERATION(ImageBitmapRenderingContext_TransferImageBitmap) DEPRECATED_OPERATION(URLCreateObjectURL_MediaStream) DEPRECATED_OPERATION(XMLBaseAttribute) -DEPRECATED_OPERATION(XMLBaseAttributeWithStyledElement) +DEPRECATED_OPERATION(XMLBaseAttributeForStyleAttr) diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index 1d42967c3dd0..f74f7974e287 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -975,6 +975,9 @@ protected: */ nsIAtom* DoGetID() const; + // Returns base URI without considering xml:base. + inline nsIURI* GetBaseURIWithoutXMLBase() const; + public: #ifdef DEBUG /**