mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1426234 part 3. Simplify ProcessStyleLink now that it's only called for Link headers. r=mystor
MozReview-Commit-ID: 2Gn3AsYwVmI
This commit is contained in:
parent
13bf7b431d
commit
bc51214e31
@ -669,10 +669,10 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
|
||||
|
||||
href.Trim(" \t\n\r\f"); // trim HTML5 whitespace
|
||||
if (!href.IsEmpty() && !rel.IsEmpty()) {
|
||||
rv = ProcessLink(anchor, href, rel,
|
||||
// prefer RFC 5987 variant over non-I18zed version
|
||||
titleStar.IsEmpty() ? title : titleStar,
|
||||
type, media, crossOrigin, referrerPolicy, as);
|
||||
rv = ProcessLinkFromHeader(anchor, href, rel,
|
||||
// prefer RFC 5987 variant over non-I18zed version
|
||||
titleStar.IsEmpty() ? title : titleStar,
|
||||
type, media, crossOrigin, referrerPolicy, as);
|
||||
}
|
||||
|
||||
href.Truncate();
|
||||
@ -693,10 +693,10 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
|
||||
|
||||
href.Trim(" \t\n\r\f"); // trim HTML5 whitespace
|
||||
if (!href.IsEmpty() && !rel.IsEmpty()) {
|
||||
rv = ProcessLink(anchor, href, rel,
|
||||
// prefer RFC 5987 variant over non-I18zed version
|
||||
titleStar.IsEmpty() ? title : titleStar,
|
||||
type, media, crossOrigin, referrerPolicy, as);
|
||||
rv = ProcessLinkFromHeader(anchor, href, rel,
|
||||
// prefer RFC 5987 variant over non-I18zed version
|
||||
titleStar.IsEmpty() ? title : titleStar,
|
||||
type, media, crossOrigin, referrerPolicy, as);
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -704,12 +704,12 @@ nsContentSink::ProcessLinkHeader(const nsAString& aLinkData)
|
||||
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessLink(const nsAString& aAnchor, const nsAString& aHref,
|
||||
const nsAString& aRel, const nsAString& aTitle,
|
||||
const nsAString& aType, const nsAString& aMedia,
|
||||
const nsAString& aCrossOrigin,
|
||||
const nsAString& aReferrerPolicy,
|
||||
const nsAString& aAs)
|
||||
nsContentSink::ProcessLinkFromHeader(const nsAString& aAnchor, const nsAString& aHref,
|
||||
const nsAString& aRel, const nsAString& aTitle,
|
||||
const nsAString& aType, const nsAString& aMedia,
|
||||
const nsAString& aCrossOrigin,
|
||||
const nsAString& aReferrerPolicy,
|
||||
const nsAString& aAs)
|
||||
{
|
||||
uint32_t linkTypes =
|
||||
nsStyleLinkElement::ParseLinkTypes(aRel);
|
||||
@ -753,18 +753,17 @@ nsContentSink::ProcessLink(const nsAString& aAnchor, const nsAString& aHref,
|
||||
}
|
||||
|
||||
bool isAlternate = linkTypes & nsStyleLinkElement::eALTERNATE;
|
||||
return ProcessStyleLink(nullptr, aHref, isAlternate, aTitle, aType,
|
||||
aMedia, aReferrerPolicy);
|
||||
return ProcessStyleLinkFromHeader(aHref, isAlternate, aTitle, aType,
|
||||
aMedia, aReferrerPolicy);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy)
|
||||
nsContentSink::ProcessStyleLinkFromHeader(const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy)
|
||||
{
|
||||
if (aAlternate && aTitle.IsEmpty()) {
|
||||
// alternates must have title return without error, for now
|
||||
@ -790,20 +789,6 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_ASSERTION(!aElement ||
|
||||
aElement->NodeType() == nsIDOMNode::PROCESSING_INSTRUCTION_NODE,
|
||||
"We only expect processing instructions here");
|
||||
|
||||
nsAutoString integrity;
|
||||
if (aElement) {
|
||||
aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::integrity, integrity);
|
||||
}
|
||||
if (!integrity.IsEmpty()) {
|
||||
MOZ_LOG(dom::SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug,
|
||||
("nsContentSink::ProcessStyleLink, integrity=%s",
|
||||
NS_ConvertUTF16toUTF8(integrity).get()));
|
||||
}
|
||||
|
||||
mozilla::net::ReferrerPolicy referrerPolicy =
|
||||
mozilla::net::AttributeReferrerPolicyFromString(aReferrerPolicy);
|
||||
if (referrerPolicy == net::RP_Unset) {
|
||||
@ -812,9 +797,10 @@ nsContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
// If this is a fragment parser, we don't want to observe.
|
||||
// We don't support CORS for processing instructions
|
||||
bool isAlternate;
|
||||
rv = mCSSLoader->LoadStyleLink(aElement, url, nullptr, aTitle, aMedia, aAlternate,
|
||||
rv = mCSSLoader->LoadStyleLink(nullptr, url, nullptr, aTitle, aMedia, aAlternate,
|
||||
CORS_NONE, referrerPolicy,
|
||||
integrity, mRunsToCompletion ? nullptr : this,
|
||||
/* integrity = */ EmptyString(),
|
||||
mRunsToCompletion ? nullptr : this,
|
||||
&isAlternate);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -151,20 +151,20 @@ protected:
|
||||
nsresult ProcessHeaderData(nsAtom* aHeader, const nsAString& aValue,
|
||||
nsIContent* aContent = nullptr);
|
||||
nsresult ProcessLinkHeader(const nsAString& aLinkData);
|
||||
nsresult ProcessLink(const nsAString& aAnchor,
|
||||
const nsAString& aHref, const nsAString& aRel,
|
||||
const nsAString& aTitle, const nsAString& aType,
|
||||
const nsAString& aMedia, const nsAString& aCrossOrigin,
|
||||
const nsAString& aReferrerPolicy,
|
||||
const nsAString& aAs);
|
||||
nsresult ProcessLinkFromHeader(const nsAString& aAnchor,
|
||||
const nsAString& aHref, const nsAString& aRel,
|
||||
const nsAString& aTitle, const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aCrossOrigin,
|
||||
const nsAString& aReferrerPolicy,
|
||||
const nsAString& aAs);
|
||||
|
||||
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy);
|
||||
virtual nsresult ProcessStyleLinkFromHeader(const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy);
|
||||
|
||||
void PrefetchPreloadHref(const nsAString &aHref, nsINode *aSource,
|
||||
uint32_t aLinkTypes, const nsAString& aAs,
|
||||
|
@ -651,13 +651,12 @@ nsXMLContentSink::LoadXSLStyleSheet(nsIURI* aUrl)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy)
|
||||
nsXMLContentSink::ProcessStyleLinkFromHeader(const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy)
|
||||
{
|
||||
mPrettyPrintXML = false;
|
||||
|
||||
@ -668,7 +667,7 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
return NS_OK; // Do not load stylesheets when loading as data
|
||||
|
||||
bool wasXSLT;
|
||||
nsresult rv = MaybeProcessXSLTLink(aElement, aHref, aAlternate, aType, aType,
|
||||
nsresult rv = MaybeProcessXSLTLink(nullptr, aHref, aAlternate, aType, aType,
|
||||
aMedia, aReferrerPolicy, &wasXSLT);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (wasXSLT) {
|
||||
@ -677,19 +676,21 @@ nsXMLContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
}
|
||||
|
||||
// Otherwise fall through to nsContentSink to handle CSS Link headers.
|
||||
return nsContentSink::ProcessStyleLink(aElement, aHref, aAlternate,
|
||||
aTitle, aType, aMedia, aReferrerPolicy);
|
||||
return nsContentSink::ProcessStyleLinkFromHeader(aHref, aAlternate,
|
||||
aTitle, aType, aMedia,
|
||||
aReferrerPolicy);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLContentSink::MaybeProcessXSLTLink(nsIContent* aProcessingInstruction,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy,
|
||||
bool* aWasXSLT)
|
||||
nsXMLContentSink::MaybeProcessXSLTLink(
|
||||
ProcessingInstruction* aProcessingInstruction,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy,
|
||||
bool* aWasXSLT)
|
||||
{
|
||||
bool wasXSLT =
|
||||
aType.LowerCaseEqualsLiteral(TEXT_XSL) ||
|
||||
@ -732,7 +733,7 @@ nsXMLContentSink::MaybeProcessXSLTLink(nsIContent* aProcessingInstruction,
|
||||
url,
|
||||
mDocument->NodePrincipal(), // loading principal
|
||||
mDocument->NodePrincipal(), // triggering principal
|
||||
aProcessingInstruction,
|
||||
ToSupports(aProcessingInstruction),
|
||||
NS_ConvertUTF16toUTF8(aType),
|
||||
nullptr,
|
||||
&decision,
|
||||
|
@ -27,6 +27,7 @@ class nsIParser;
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class NodeInfo;
|
||||
class ProcessingInstruction;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
@ -145,13 +146,13 @@ protected:
|
||||
}
|
||||
|
||||
// nsContentSink override
|
||||
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy) override;
|
||||
virtual nsresult ProcessStyleLinkFromHeader(
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy) override;
|
||||
|
||||
// Try to handle an XSLT style link. If NS_OK is returned and aWasXSLT is not
|
||||
// null, *aWasXSLT will be set to whether we processed this link as XSLT.
|
||||
@ -160,7 +161,7 @@ protected:
|
||||
// header; otherwise it will be the xml-styleshset XML PI that the loading
|
||||
// information comes from.
|
||||
virtual nsresult MaybeProcessXSLTLink(
|
||||
nsIContent* aProcessingInstruction,
|
||||
mozilla::dom::ProcessingInstruction* aProcessingInstruction,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
|
@ -91,17 +91,17 @@ protected:
|
||||
virtual void MaybeStartLayout(bool aIgnorePendingSheets) override;
|
||||
|
||||
// nsContentSink overrides
|
||||
virtual nsresult ProcessStyleLink(nsIContent* aElement,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy) override;
|
||||
virtual nsresult ProcessStyleLinkFromHeader(
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy) override;
|
||||
|
||||
// nsXMLContentSink overrides
|
||||
virtual nsresult MaybeProcessXSLTLink(
|
||||
nsIContent* aProcessingInstruction,
|
||||
ProcessingInstruction* aProcessingInstruction,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
@ -336,28 +336,29 @@ nsXMLFragmentContentSink::ReportError(const char16_t* aErrorText,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLFragmentContentSink::ProcessStyleLink(nsIContent* aElement,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy)
|
||||
nsXMLFragmentContentSink::ProcessStyleLinkFromHeader(
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy)
|
||||
|
||||
{
|
||||
// don't process until moved to document
|
||||
NS_NOTREACHED("Shouldn't have headers for a fragment sink");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsXMLFragmentContentSink::MaybeProcessXSLTLink(nsIContent* aProcessingInstruction,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy,
|
||||
bool* aWasXSLT)
|
||||
nsXMLFragmentContentSink::MaybeProcessXSLTLink(
|
||||
ProcessingInstruction* aProcessingInstruction,
|
||||
const nsAString& aHref,
|
||||
bool aAlternate,
|
||||
const nsAString& aTitle,
|
||||
const nsAString& aType,
|
||||
const nsAString& aMedia,
|
||||
const nsAString& aReferrerPolicy,
|
||||
bool* aWasXSLT)
|
||||
{
|
||||
MOZ_ASSERT(!aWasXSLT, "Our one caller doesn't care about whether we're XSLT");
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user