Bug 804975 - Part 4: Cache reset structs on rule nodes for different font-size or writing mode values. r=dbaron

This commit is contained in:
Cameron McCormack 2015-06-23 11:48:18 +10:00
parent aca4e30a8b
commit 4e991f4ee0
2 changed files with 7 additions and 3 deletions

View File

@ -254,7 +254,8 @@ nsCSSCompressedDataBlock::MapRuleInfoInto(nsRuleData *aRuleData) const
// We can't cache anything on the rule tree if we use any data from
// the style context, since data cached in the rule tree could be
// used with a style context with a different value.
aRuleData->mConditions.SetUncacheable();
uint8_t wm = WritingMode(aRuleData->mStyleContext).GetBits();
aRuleData->mConditions.SetWritingModeDependency(wm);
}
nsCSSValue* target = aRuleData->ValueFor(iProp);
if (target->GetUnit() == eCSSUnit_Null) {
@ -693,7 +694,8 @@ nsCSSExpandedDataBlock::MapRuleInfoInto(nsCSSProperty aPropID,
nsCSSProperty physicalProp = aPropID;
if (nsCSSProps::PropHasFlags(aPropID, CSS_PROPERTY_LOGICAL)) {
EnsurePhysicalProperty(physicalProp, aRuleData);
aRuleData->mConditions.SetUncacheable();
uint8_t wm = WritingMode(aRuleData->mStyleContext).GetBits();
aRuleData->mConditions.SetWritingModeDependency(wm);
}
nsCSSValue* dest = aRuleData->ValueFor(physicalProp);

View File

@ -495,7 +495,6 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
}
// Common code for units that depend on the element's font data and
// thus can't be stored in the rule tree:
aConditions.SetUncacheable();
const nsStyleFont *styleFont =
aStyleFont ? aStyleFont : aStyleContext->StyleFont();
if (aFontSize == -1) {
@ -507,6 +506,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
case eCSSUnit_EM: {
// CSS2.1 specifies that this unit scales to the computed font
// size, not the em-width in the font metrics, despite the name.
aConditions.SetFontSizeDependency(aFontSize);
return ScaleCoordRound(aValue, float(aFontSize));
}
case eCSSUnit_XHeight: {
@ -514,6 +514,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
nsRefPtr<nsFontMetrics> fm =
GetMetricsFor(aPresContext, aStyleContext, styleFont,
aFontSize, aUseUserFontSet);
aConditions.SetUncacheable();
return ScaleCoordRound(aValue, float(fm->XHeight()));
}
case eCSSUnit_Char: {
@ -525,6 +526,7 @@ static nscoord CalcLengthWith(const nsCSSValue& aValue,
fm->GetThebesFontGroup()->GetFirstValidFont()->
GetMetrics(fm->Orientation()).zeroOrAveCharWidth;
aConditions.SetUncacheable();
return ScaleCoordRound(aValue, ceil(aPresContext->AppUnitsPerDevPixel() *
zeroWidth));
}