Bug 1370802: There's actually no need for lang to be lowercased. r?heycam
MozReview-Commit-ID: KwtbLqR9Y81
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -1219,29 +1219,18 @@ MapLangAttributeInto(const nsMappedAttri
}
const nsAttrValue* langValue = aAttributes->GetAttr(nsGkAtoms::lang);
if (!langValue) {
return;
}
MOZ_ASSERT(langValue->Type() == nsAttrValue::eAtom);
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Font))) {
- nsIAtom* atom = langValue->GetAtomValue();
-
- const nsDependentAtomString atomString(atom);
- Maybe<nsCOMPtr<nsIAtom>> lowerAtom;
- if (nsContentUtils::StringContainsASCIIUpper(atomString)) {
- nsAutoString dest;
- dest.SetCapacity(atomString.Length());
- nsContentUtils::ASCIIToLower(atomString, dest);
- lowerAtom.emplace(NS_AtomizeMainThread(dest));
- }
-
- aData->SetIdentAtomValueIfUnset(
- eCSSProperty__x_lang, lowerAtom ? lowerAtom->get() : atom);
+ aData->SetIdentAtomValueIfUnset(eCSSProperty__x_lang,
+ langValue->GetAtomValue());
}
if (aData->ShouldComputeStyleStruct(NS_STYLE_INHERIT_BIT(Text))) {
if (!aData->PropertyIsSet(eCSSProperty_text_emphasis_position)) {
const nsIAtom* lang = langValue->GetAtomValue();
if (nsStyleUtil::MatchesLanguagePrefix(lang, u"zh")) {
aData->SetKeywordValue(eCSSProperty_text_emphasis_position,
NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT_ZH);
} else if (nsStyleUtil::MatchesLanguagePrefix(lang, u"ja") ||
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -588,27 +588,18 @@ nsHTMLStyleSheet::CalculateMappedServoDe
}
attr->mAttributes->LazilyResolveServoDeclaration(aPresContext);
}
}
nsIStyleRule*
nsHTMLStyleSheet::LangRuleFor(const nsIAtom* aLanguage)
{
- Maybe<nsCOMPtr<nsIAtom>> lowerAtom;
- nsDependentAtomString langString(aLanguage);
- if (nsContentUtils::StringContainsASCIIUpper(langString)) {
- nsString dest;
- nsContentUtils::ASCIIToLower(langString, dest);
- lowerAtom.emplace(NS_AtomizeMainThread(dest));
- }
-
- const nsIAtom* key = lowerAtom ? *lowerAtom : aLanguage;
auto entry =
- static_cast<LangRuleTableEntry*>(mLangRuleTable.Add(key, fallible));
+ static_cast<LangRuleTableEntry*>(mLangRuleTable.Add(aLanguage, fallible));
if (!entry) {
NS_ASSERTION(false, "out of memory");
return nullptr;
}
return entry->mRule;
}
size_t
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3561,19 +3561,16 @@ nsRuleNode::SetFont(nsPresContext* aPres
// mLanguage must be set before before any of the CalcLengthWith calls
// (direct calls or calls via SetFontSize) for the cases where |aParentFont|
// is the same as |aFont|.
//
// -x-lang: string, inherit
// This is not a real CSS property, it is an HTML attribute mapped to CSS.
const nsCSSValue* langValue = aRuleData->ValueForLang();
if (eCSSUnit_AtomIdent == langValue->GetUnit()) {
- MOZ_ASSERT(!nsContentUtils::StringContainsASCIIUpper(
- nsDependentAtomString(langValue->GetAtomValue())));
-
aFont->mLanguage = langValue->GetAtomValue();
aFont->mExplicitLanguage = true;
}
const nsFont* defaultVariableFont =
aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID,
aFont->mLanguage);