Bug 1459844: Share more code and fix some inconsistencies between html / svg style elements. r=heycam

MozReview-Commit-ID: IkTrIfJI1iK
This commit is contained in:
Emilio Cobos Álvarez
2018-05-08 06:51:34 +02:00
parent b5b468f1e1
commit d16c4825a1
5 changed files with 60 additions and 52 deletions

View File

@@ -197,27 +197,14 @@ HTMLStyleElement::SetTextContentInternal(const nsAString& aTextContent,
Maybe<nsStyleLinkElement::SheetInfo>
HTMLStyleElement::GetStyleSheetInfo()
{
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
nsAutoString media;
GetAttr(kNameSpaceID_None, nsGkAtoms::media, media);
// The HTML5 spec is formulated in terms of the CSSOM spec, which specifies
// that media queries should be ASCII lowercased during serialization.
//
// FIXME(emilio): Doesn't matter I'd think, style should take care of that.
nsContentUtils::ASCIIToLower(media);
nsAutoString type;
nsAutoString mimeType;
nsAutoString notUsed;
GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
nsContentUtils::SplitMimeType(type, mimeType, notUsed);
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
if (!IsCSSMimeTypeAttribute(*this)) {
return Nothing();
}
nsAutoString title;
nsAutoString media;
GetTitleAndMediaForElement(*this, title, media);
nsCOMPtr<nsIPrincipal> prin = mTriggeringPrincipal;
return Some(SheetInfo {
*OwnerDoc(),