зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1565767 part 5. Remove some unnecesary refcounting at nsIContent::GetBaseURI callsites. r=peterv
Differential Revision: https://phabricator.services.mozilla.com/D37973 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
75aa8f554d
Коммит
374137e8d8
|
@ -152,10 +152,10 @@ already_AddRefed<nsIURI> ImageAccessible::GetLongDescURI() const {
|
|||
longdesc.FindChar('\r') != -1 || longdesc.FindChar('\n') != -1) {
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri), longdesc,
|
||||
mContent->OwnerDoc(), baseURI);
|
||||
mContent->OwnerDoc(),
|
||||
mContent->GetBaseURI());
|
||||
return uri.forget();
|
||||
}
|
||||
|
||||
|
|
|
@ -205,12 +205,11 @@ already_AddRefed<nsIURI> XULLinkAccessible::AnchorURIAt(
|
|||
nsAutoString href;
|
||||
mContent->AsElement()->GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
dom::Document* document = mContent->OwnerDoc();
|
||||
|
||||
nsCOMPtr<nsIURI> anchorURI;
|
||||
NS_NewURI(getter_AddRefs(anchorURI), href,
|
||||
document->GetDocumentCharacterSet(), baseURI);
|
||||
document->GetDocumentCharacterSet(), mContent->GetBaseURI());
|
||||
|
||||
return anchorURI.forget();
|
||||
}
|
||||
|
|
|
@ -273,9 +273,9 @@ static void ForEachPing(nsIContent* aContent, ForEachPingCallback aCallback,
|
|||
nsWhitespaceTokenizer tokenizer(value);
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
nsCOMPtr<nsIURI> uri, baseURI = aContent->GetBaseURI();
|
||||
ios->NewURI(NS_ConvertUTF16toUTF8(tokenizer.nextToken()), charset.get(),
|
||||
baseURI, getter_AddRefs(uri));
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewURI(getter_AddRefs(uri), tokenizer.nextToken(), charset.get(),
|
||||
aContent->GetBaseURI());
|
||||
// if we can't generate a valid URI, then there is nothing to do
|
||||
if (!uri) {
|
||||
continue;
|
||||
|
|
|
@ -445,7 +445,7 @@ void nsFrameLoader::LoadFrame(bool aOriginalSrc) {
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> base_uri = mOwnerContent->GetBaseURI();
|
||||
nsIURI* base_uri = mOwnerContent->GetBaseURI();
|
||||
auto encoding = doc->GetDocumentCharacterSet();
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
|
@ -635,8 +635,7 @@ nsresult nsFrameLoader::ReallyStartLoadingInternal() {
|
|||
|
||||
if (isSrcdoc) {
|
||||
loadState->SetSrcdocData(srcdoc);
|
||||
nsCOMPtr<nsIURI> baseURI = mOwnerContent->GetBaseURI();
|
||||
loadState->SetBaseURI(baseURI);
|
||||
loadState->SetBaseURI(mOwnerContent->GetBaseURI());
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIReferrerInfo> referrerInfo = new ReferrerInfo();
|
||||
|
|
|
@ -104,7 +104,7 @@ bool nsHTMLContentSerializer::SerializeHTMLAttributes(
|
|||
// Would be nice to handle OBJECT tags, but that gets more complicated
|
||||
// since we have to search the tag list for CODEBASE as well. For now,
|
||||
// just leave them relative.
|
||||
nsCOMPtr<nsIURI> uri = aElement->GetBaseURI();
|
||||
nsIURI* uri = aElement->GetBaseURI();
|
||||
if (uri) {
|
||||
nsAutoString absURI;
|
||||
rv = NS_MakeAbsoluteURI(absURI, valueStr, uri);
|
||||
|
|
|
@ -1353,7 +1353,7 @@ nsresult nsImageLoadingContent::StringToURI(const nsAString& aSpec,
|
|||
|
||||
// (1) Get the base URI
|
||||
nsIContent* thisContent = AsContent();
|
||||
nsCOMPtr<nsIURI> baseURL = thisContent->GetBaseURI();
|
||||
nsIURI* baseURL = thisContent->GetBaseURI();
|
||||
|
||||
// (2) Get the charset
|
||||
auto encoding = aDocument->GetDocumentCharacterSet();
|
||||
|
|
|
@ -1492,7 +1492,7 @@ nsObjectLoadingContent::UpdateObjectParameters() {
|
|||
///
|
||||
|
||||
nsAutoString codebaseStr;
|
||||
nsCOMPtr<nsIURI> docBaseURI = thisElement->GetBaseURI();
|
||||
nsIURI* docBaseURI = thisElement->GetBaseURI();
|
||||
thisElement->GetAttr(kNameSpaceID_None, nsGkAtoms::codebase, codebaseStr);
|
||||
|
||||
if (!codebaseStr.IsEmpty()) {
|
||||
|
@ -1508,6 +1508,11 @@ nsObjectLoadingContent::UpdateObjectParameters() {
|
|||
}
|
||||
}
|
||||
|
||||
// If we failed to build a valid URI, use the document's base URI
|
||||
if (!newBaseURI) {
|
||||
newBaseURI = docBaseURI;
|
||||
}
|
||||
|
||||
nsAutoString rawTypeAttr;
|
||||
thisElement->GetAttr(kNameSpaceID_None, nsGkAtoms::type, rawTypeAttr);
|
||||
if (!rawTypeAttr.IsEmpty()) {
|
||||
|
@ -1518,11 +1523,6 @@ nsObjectLoadingContent::UpdateObjectParameters() {
|
|||
CopyUTF16toUTF8(mime, newMime);
|
||||
}
|
||||
|
||||
// If we failed to build a valid URI, use the document's base URI
|
||||
if (!newBaseURI) {
|
||||
newBaseURI = docBaseURI;
|
||||
}
|
||||
|
||||
///
|
||||
/// URI
|
||||
///
|
||||
|
|
|
@ -1286,9 +1286,9 @@ bool nsTreeSanitizer::SanitizeURL(mozilla::dom::Element* aElement,
|
|||
nsIScriptSecurityManager* secMan = nsContentUtils::GetSecurityManager();
|
||||
uint32_t flags = nsIScriptSecurityManager::DISALLOW_INHERIT_PRINCIPAL;
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = aElement->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> attrURI;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(attrURI), v, nullptr, baseURI);
|
||||
nsresult rv =
|
||||
NS_NewURI(getter_AddRefs(attrURI), v, nullptr, aElement->GetBaseURI());
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (mCidEmbedsOnly && kNameSpaceID_None == aNamespace) {
|
||||
if (nsGkAtoms::src == aLocalName || nsGkAtoms::background == aLocalName) {
|
||||
|
@ -1383,9 +1383,8 @@ void nsTreeSanitizer::SanitizeChildren(nsINode* aRoot) {
|
|||
nsContentUtils::GetNodeTextContent(node, false, styleText);
|
||||
|
||||
nsAutoString sanitizedStyle;
|
||||
nsCOMPtr<nsIURI> baseURI = node->GetBaseURI();
|
||||
if (SanitizeStyleSheet(styleText, sanitizedStyle, aRoot->OwnerDoc(),
|
||||
baseURI)) {
|
||||
node->GetBaseURI())) {
|
||||
nsContentUtils::SetNodeTextContent(node, sanitizedStyle, true);
|
||||
} else {
|
||||
// If the node had non-text child nodes, this operation zaps those.
|
||||
|
|
|
@ -277,7 +277,7 @@ bool nsXHTMLContentSerializer::SerializeAttributes(
|
|||
// but that gets more complicated since we have to
|
||||
// search the tag list for CODEBASE as well.
|
||||
// For now, just leave them relative.
|
||||
nsCOMPtr<nsIURI> uri = aElement->GetBaseURI();
|
||||
nsIURI* uri = aElement->GetBaseURI();
|
||||
if (uri) {
|
||||
nsAutoString absURI;
|
||||
rv = NS_MakeAbsoluteURI(absURI, valueStr, uri);
|
||||
|
|
|
@ -1485,7 +1485,7 @@ nsresult HTMLFormElement::GetActionURL(nsIURI** aActionURL,
|
|||
|
||||
actionURL = docURI;
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> baseURL = GetBaseURI();
|
||||
nsIURI* baseURL = GetBaseURI();
|
||||
NS_ASSERTION(baseURL, "No Base URL found in Form Submit!\n");
|
||||
if (!baseURL) {
|
||||
return NS_OK; // No base URL -> exit early, see Bug 30721
|
||||
|
|
|
@ -135,10 +135,9 @@ bool HTMLMenuElement::CanLoadIcon(nsIContent* aContent,
|
|||
|
||||
Document* doc = aContent->OwnerDoc();
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = aContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri), aIcon, doc,
|
||||
baseURI);
|
||||
aContent->GetBaseURI());
|
||||
|
||||
if (!uri) {
|
||||
return false;
|
||||
|
|
|
@ -186,9 +186,8 @@ void HTMLScriptElement::FreezeExecutionAttrs(Document* aOwnerDoc) {
|
|||
if (GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
// Empty src should be treated as invalid URL.
|
||||
if (!src.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(mUri), src,
|
||||
OwnerDoc(), baseURI);
|
||||
OwnerDoc(), GetBaseURI());
|
||||
|
||||
if (!mUri) {
|
||||
AutoTArray<nsString, 2> params = {NS_LITERAL_STRING("src"), src};
|
||||
|
|
|
@ -863,10 +863,9 @@ bool nsGenericHTMLElement::ParseBackgroundAttribute(int32_t aNamespaceID,
|
|||
aAttribute == nsGkAtoms::background && !aValue.IsEmpty()) {
|
||||
// Resolve url to an absolute url
|
||||
Document* doc = OwnerDoc();
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = nsContentUtils::NewURIWithDocumentCharset(
|
||||
getter_AddRefs(uri), aValue, doc, baseURI);
|
||||
getter_AddRefs(uri), aValue, doc, GetBaseURI());
|
||||
if (NS_FAILED(rv)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2685,9 +2684,9 @@ nsresult nsGenericHTMLElement::NewURIFromString(const nsAString& aURISpec,
|
|||
|
||||
nsCOMPtr<Document> doc = OwnerDoc();
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsresult rv =
|
||||
nsContentUtils::NewURIWithDocumentCharset(aURI, aURISpec, doc, baseURI);
|
||||
nsContentUtils::NewURIWithDocumentCharset(aURI, aURISpec, doc,
|
||||
GetBaseURI());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool equal;
|
||||
|
|
|
@ -930,12 +930,11 @@ bool nsMathMLElement::IsLink(nsIURI** aURI) const {
|
|||
}
|
||||
|
||||
if (hasHref) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
// Get absolute URI
|
||||
nsAutoString hrefStr;
|
||||
href->ToString(hrefStr);
|
||||
nsContentUtils::NewURIWithDocumentCharset(aURI, hrefStr, OwnerDoc(),
|
||||
baseURI);
|
||||
GetBaseURI());
|
||||
// must promise out param is non-null if we return true
|
||||
return !!*aURI;
|
||||
}
|
||||
|
|
|
@ -276,12 +276,12 @@ bool SVGAElement::IsLink(nsIURI** aURI) const {
|
|||
eCaseMatters) != Element::ATTR_VALUE_NO_MATCH &&
|
||||
FindAttrValueIn(kNameSpaceID_XLink, nsGkAtoms::actuate, sActuateVals,
|
||||
eCaseMatters) != Element::ATTR_VALUE_NO_MATCH) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
// Get absolute URI
|
||||
nsAutoString str;
|
||||
const uint8_t idx = useBareHref ? HREF : XLINK_HREF;
|
||||
mStringAttributes[idx].GetAnimValue(str, this);
|
||||
nsContentUtils::NewURIWithDocumentCharset(aURI, str, OwnerDoc(), baseURI);
|
||||
nsContentUtils::NewURIWithDocumentCharset(aURI, str, OwnerDoc(),
|
||||
GetBaseURI());
|
||||
// must promise out param is non-null if we return true
|
||||
return !!*aURI;
|
||||
}
|
||||
|
|
|
@ -356,9 +356,8 @@ bool SVGAnimationElement::IsEventAttributeNameInternal(nsAtom* aName) {
|
|||
|
||||
void SVGAnimationElement::UpdateHrefTarget(const nsAString& aHrefStr) {
|
||||
nsCOMPtr<nsIURI> targetURI;
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), aHrefStr,
|
||||
OwnerDoc(), baseURI);
|
||||
OwnerDoc(), GetBaseURI());
|
||||
// Bug 1415044 to investigate which referrer we should use
|
||||
mHrefTarget.ResetToURIFragmentID(this, targetURI,
|
||||
OwnerDoc()->GetDocumentURI(),
|
||||
|
|
|
@ -59,7 +59,7 @@ SVGFEImageElement::~SVGFEImageElement() { DestroyImageLoadingContent(); }
|
|||
|
||||
nsresult SVGFEImageElement::LoadSVGImage(bool aForce, bool aNotify) {
|
||||
// resolve href attribute
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsIURI* baseURI = GetBaseURI();
|
||||
|
||||
nsAutoString href;
|
||||
if (mStringAttributes[HREF].IsExplicitlySet()) {
|
||||
|
|
|
@ -128,7 +128,7 @@ already_AddRefed<Promise> SVGImageElement::Decode(ErrorResult& aRv) {
|
|||
|
||||
nsresult SVGImageElement::LoadSVGImage(bool aForce, bool aNotify) {
|
||||
// resolve href attribute
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsIURI* baseURI = GetBaseURI();
|
||||
|
||||
nsAutoString href;
|
||||
if (mStringAttributes[HREF].IsExplicitlySet()) {
|
||||
|
|
|
@ -191,9 +191,8 @@ SVGPathElement* SVGMPathElement::GetReferencedPath() {
|
|||
void SVGMPathElement::UpdateHrefTarget(nsIContent* aParent,
|
||||
const nsAString& aHrefStr) {
|
||||
nsCOMPtr<nsIURI> targetURI;
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), aHrefStr,
|
||||
OwnerDoc(), baseURI);
|
||||
OwnerDoc(), GetBaseURI());
|
||||
|
||||
// Stop observing old target (if any)
|
||||
if (mPathTracker.get()) {
|
||||
|
|
|
@ -129,8 +129,7 @@ void SVGScriptElement::FreezeExecutionAttrs(Document* aOwnerDoc) {
|
|||
|
||||
// Empty src should be treated as invalid URL.
|
||||
if (!src.IsEmpty()) {
|
||||
nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
||||
NS_NewURI(getter_AddRefs(mUri), src, nullptr, baseURI);
|
||||
NS_NewURI(getter_AddRefs(mUri), src, nullptr, GetBaseURI());
|
||||
|
||||
if (!mUri) {
|
||||
AutoTArray<nsString, 2> params = {isHref
|
||||
|
|
|
@ -2415,7 +2415,7 @@ void nsImageFrame::GetDocumentCharacterSet(nsACString& aCharset) const {
|
|||
}
|
||||
|
||||
void nsImageFrame::SpecToURI(const nsAString& aSpec, nsIURI** aURI) {
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsIURI* baseURI = nullptr;
|
||||
if (mContent) {
|
||||
baseURI = mContent->GetBaseURI();
|
||||
}
|
||||
|
|
|
@ -1007,7 +1007,7 @@ nsresult Loader::CreateSheet(nsIURI* aURI, nsIContent* aLinkingContent,
|
|||
if (!*aSheet) {
|
||||
aSheetState = eSheetNeedsParser;
|
||||
nsIURI* sheetURI;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsIURI* baseURI;
|
||||
nsIURI* originalURI;
|
||||
if (!aURI) {
|
||||
// Inline style. Use the document's base URL so that @import in
|
||||
|
|
|
@ -119,8 +119,7 @@ already_AddRefed<nsIURI> StyleComputedUrl::ResolveLocalRef(nsIURI* aURI) const {
|
|||
|
||||
already_AddRefed<nsIURI> StyleComputedUrl::ResolveLocalRef(
|
||||
const nsIContent* aContent) const {
|
||||
nsCOMPtr<nsIURI> url = aContent->GetBaseURI();
|
||||
return ResolveLocalRef(url);
|
||||
return ResolveLocalRef(aContent->GetBaseURI());
|
||||
}
|
||||
|
||||
imgRequestProxy* StyleComputedUrl::LoadImage(Document& aDocument) {
|
||||
|
|
|
@ -1372,9 +1372,9 @@ SVGGeometryElement* SVGObserverUtils::GetAndObserveTextPathsPath(
|
|||
}
|
||||
|
||||
nsCOMPtr<nsIURI> targetURI;
|
||||
nsCOMPtr<nsIURI> base = content->GetBaseURI();
|
||||
nsContentUtils::NewURIWithDocumentCharset(
|
||||
getter_AddRefs(targetURI), href, content->GetUncomposedDoc(), base);
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), href,
|
||||
content->GetUncomposedDoc(),
|
||||
content->GetBaseURI());
|
||||
|
||||
// There's no clear refererer policy spec about non-CSS SVG resource
|
||||
// references Bug 1415044 to investigate which referrer we should use
|
||||
|
@ -1422,9 +1422,9 @@ nsIFrame* SVGObserverUtils::GetAndObserveTemplate(
|
|||
// Convert href to an nsIURI
|
||||
nsIContent* content = aFrame->GetContent();
|
||||
nsCOMPtr<nsIURI> targetURI;
|
||||
nsCOMPtr<nsIURI> base = content->GetBaseURI();
|
||||
nsContentUtils::NewURIWithDocumentCharset(
|
||||
getter_AddRefs(targetURI), href, content->GetUncomposedDoc(), base);
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(targetURI), href,
|
||||
content->GetUncomposedDoc(),
|
||||
content->GetBaseURI());
|
||||
|
||||
// There's no clear refererer policy spec about non-CSS SVG resource
|
||||
// references. Bug 1415044 to investigate which referrer we should use.
|
||||
|
@ -1457,10 +1457,10 @@ Element* SVGObserverUtils::GetAndObserveBackgroundImage(nsIFrame* aFrame,
|
|||
nsAutoString elementId =
|
||||
NS_LITERAL_STRING("#") + nsDependentAtomString(aHref);
|
||||
nsCOMPtr<nsIURI> targetURI;
|
||||
nsCOMPtr<nsIURI> base = aFrame->GetContent()->GetBaseURI();
|
||||
nsContentUtils::NewURIWithDocumentCharset(
|
||||
getter_AddRefs(targetURI), elementId,
|
||||
aFrame->GetContent()->GetUncomposedDoc(), base);
|
||||
aFrame->GetContent()->GetUncomposedDoc(),
|
||||
aFrame->GetContent()->GetBaseURI());
|
||||
RefPtr<URLAndReferrerInfo> url = new URLAndReferrerInfo(
|
||||
targetURI, aFrame->GetContent()->OwnerDoc()->GetDocumentURI(),
|
||||
aFrame->GetContent()->OwnerDoc()->GetReferrerPolicy());
|
||||
|
|
|
@ -238,10 +238,9 @@ void nsImageBoxFrame::UpdateImage() {
|
|||
mContent, getter_AddRefs(triggeringPrincipal), contentPolicyType,
|
||||
&requestContextID);
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(uri), src, doc,
|
||||
baseURI);
|
||||
mContent->GetBaseURI());
|
||||
if (uri) {
|
||||
nsresult rv = nsContentUtils::LoadImage(
|
||||
uri, mContent, doc, triggeringPrincipal, requestContextID,
|
||||
|
|
|
@ -1913,11 +1913,9 @@ nsresult nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol,
|
|||
styleRequest->SyncClone(imgNotificationObserver, doc,
|
||||
getter_AddRefs(imageRequest));
|
||||
} else {
|
||||
nsCOMPtr<nsIURI> baseURI = mContent->GetBaseURI();
|
||||
|
||||
nsCOMPtr<nsIURI> srcURI;
|
||||
nsContentUtils::NewURIWithDocumentCharset(getter_AddRefs(srcURI),
|
||||
imageSrc, doc, baseURI);
|
||||
nsContentUtils::NewURIWithDocumentCharset(
|
||||
getter_AddRefs(srcURI), imageSrc, doc, mContent->GetBaseURI());
|
||||
if (!srcURI) return NS_ERROR_FAILURE;
|
||||
|
||||
// XXXbz what's the origin principal for this stuff that comes from our
|
||||
|
|
Загрузка…
Ссылка в новой задаче