Maybe<nsStyleLinkElement::SheetInfo> SVGStyleElement::GetStyleSheetInfo() { if (!IsCSSMimeTypeAttribute(*this)) { return Nothing(); } nsAutoString title; nsAutoString media; GetTitleAndMediaForElement(*this, title, media); return Some(SheetInfo{ *OwnerDoc(), this, nullptr, // FIXME(bug 1459822): Why doesn't this need a principal, but // HTMLStyleElement does? nullptr, net::ReferrerPolicy::RP_Unset, // FIXME(bug 1459822): Why does this need a crossorigin attribute, but // HTMLStyleElement doesn't? AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)), title, media, HasAlternateRel::No, IsInline::Yes, }); }
Maybe<nsStyleLinkElement::SheetInfo> HTMLLinkElement::GetStyleSheetInfo() { nsAutoString rel; GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel); uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel); if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) { return Nothing(); } if (!IsCSSMimeTypeAttribute(*this)) { return Nothing(); } nsAutoString title; nsAutoString media; GetTitleAndMediaForElement(*this, title, media); bool alternate = linkTypes & nsStyleLinkElement::eALTERNATE; if (alternate && title.IsEmpty()) { // alternates must have title. return Nothing(); } nsAutoString href; GetAttr(kNameSpaceID_None, nsGkAtoms::href, href); if (href.IsEmpty()) { return Nothing(); } nsCOMPtr<nsIURI> uri = Link::GetURI(); nsCOMPtr<nsIPrincipal> prin = mTriggeringPrincipal; return Some(SheetInfo{ *OwnerDoc(), this, uri.forget(), prin.forget(), GetReferrerPolicyAsEnum(), GetCORSMode(), title, media, alternate ? HasAlternateRel::Yes : HasAlternateRel::No, IsInline::No, }); }