From: L. David Baron Track whether nsStyleVisibility::mLanguage came from explicit information in the document. (Bug 702121) UNTESTED diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4690,16 +4690,17 @@ nsRuleNode::ComputeVisibilityData(void* // this is not a real CSS property, it is a html attribute mapped to CSS struture const nsCSSValue* langValue = aRuleData->ValueForLang(); if (eCSSUnit_Ident == langValue->GetUnit()) { nsAutoString lang; langValue->GetStringValue(lang); nsContentUtils::ASCIIToLower(lang); visibility->mLanguage = do_GetAtom(lang); + visibility->mExplicitLanguage = true; } COMPUTE_END_INHERITED(Visibility, visibility) } const void* nsRuleNode::ComputeColorData(void* aStartStruct, const nsRuleData* aRuleData, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2299,42 +2299,48 @@ nsStyleVisibility::nsStyleVisibility(nsP aPresContext->Document()->GetContentLanguage(language); language.StripWhitespace(); // Content-Language may be a comma-separated list of language codes, // in which case the HTML5 spec says to treat it as unknown if (!language.IsEmpty() && language.FindChar(PRUnichar(',')) == kNotFound) { mLanguage = do_GetAtom(language); + // REVIEW: Should this count as explicit, or should only the lang + // attribute count as explicit? + mExplicitLanguage = true; } else { // we didn't find a (usable) Content-Language, so we fall back // to whatever the presContext guessed from the charset mLanguage = aPresContext->GetLanguageFromCharset(); + mExplicitLanguage = false; } mVisible = NS_STYLE_VISIBILITY_VISIBLE; mPointerEvents = NS_STYLE_POINTER_EVENTS_AUTO; } nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource) { MOZ_COUNT_CTOR(nsStyleVisibility); mDirection = aSource.mDirection; mVisible = aSource.mVisible; mLanguage = aSource.mLanguage; + mExplicitLanguage = aSource.mExplicitLanguage; mPointerEvents = aSource.mPointerEvents; } nsChangeHint nsStyleVisibility::CalcDifference(const nsStyleVisibility& aOther) const { nsChangeHint hint = nsChangeHint(0); if (mDirection != aOther.mDirection) { NS_UpdateHint(hint, nsChangeHint_ReconstructFrame); - } else if (mLanguage == aOther.mLanguage) { + } else if (mLanguage == aOther.mLanguage && + mExplicitLanguage == aOther.mExplicitLanguage) { if (mVisible != aOther.mVisible) { if ((NS_STYLE_VISIBILITY_COLLAPSE == mVisible) || (NS_STYLE_VISIBILITY_COLLAPSE == aOther.mVisible)) { NS_UpdateHint(hint, NS_STYLE_HINT_REFLOW); } else { NS_UpdateHint(hint, NS_STYLE_HINT_VISUAL); } } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1329,18 +1329,21 @@ struct nsStyleVisibility { nsChangeHint CalcDifference(const nsStyleVisibility& aOther) const; #ifdef DEBUG static nsChangeHint MaxDifference(); #endif static bool ForceCompare() { return false; } PRUint8 mDirection; // [inherited] see nsStyleConsts.h NS_STYLE_DIRECTION_* PRUint8 mVisible; // [inherited] + PRUint8 mPointerEvents; // [inherited] see nsStyleConsts.h + + // was mLanguage set based on something in the document? + PRPackedBool mExplicitLanguage; // [inherited] nsCOMPtr mLanguage; // [inherited] - PRUint8 mPointerEvents; // [inherited] see nsStyleConsts.h bool IsVisible() const { return (mVisible == NS_STYLE_VISIBILITY_VISIBLE); } bool IsVisibleOrCollapsed() const { return ((mVisible == NS_STYLE_VISIBILITY_VISIBLE) || (mVisible == NS_STYLE_VISIBILITY_COLLAPSE));