Skip to content

Commit

Permalink
Don't make the optimization of not calling the parent context's GetSt…
Browse files Browse the repository at this point in the history
…yleData when there are 'em' or similar units for the 'font-size' property, where those units imply inheritance. b=131454 r=bzbarsky sr=hyatt a=asa
  • Loading branch information
dbaron%fas.harvard.edu committed Mar 19, 2002
1 parent 21232a3 commit 822db53
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 11 additions & 3 deletions content/base/src/nsRuleNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ nscoord CalcLength(const nsCSSValue& aValue,
aPresContext->GetScaledPixelsToTwips(&p2t);
return NSFloatPixelsToTwips(aValue.GetFloatValue(), p2t);
default:
NS_NOTREACHED("unexpected unit");
break;
}
return 0;
Expand Down Expand Up @@ -794,6 +795,8 @@ CheckFontCallback(const nsCSSStruct& aData)
(family == NS_STYLE_FONT_LIST) ||
(family == NS_STYLE_FONT_FIELD) ||
(family == NS_STYLE_FONT_THEME))
// Mixed rather than Reset in case another sub-property has
// an explicit 'inherit'. XXXperf Could check them.
return nsRuleNode::eRuleFullMixed;
}
return nsRuleNode::eRuleUnknown;
Expand Down Expand Up @@ -1503,14 +1506,14 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
if (ruleNode->mNoneBits & bit)
break;

// If the inherit bit is set on a rule node for this struct, that
// If the dependent bit is set on a rule node for this struct, that
// means its rule won't have any information to add, so skip it.
// XXXldb I don't understand why we need to check |detail| here, but
// we do.
if (detail == eRuleNone)
while (ruleNode->mDependentBits & bit) {
NS_ASSERTION(ruleNode->mStyleData.GetStyleData(aSID) == nsnull,
"inherit bit with cached data makes no sense");
"dependent bit with cached data makes no sense");
// Climb up to the next rule in the tree (a less specific rule).
rootNode = ruleNode;
ruleNode = ruleNode->mParent;
Expand Down Expand Up @@ -2261,7 +2264,12 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
const nsStyleFont* parentFont = nsnull;
PRBool inherited = aInherited;

if (parentContext && aRuleDetail != eRuleFullReset)
// This optimization is a little weaker here since 'em', etc., for
// 'font-size' require inheritance.
if (parentContext &&
(aRuleDetail != eRuleFullReset ||
(fontData.mSize.IsRelativeLengthUnit() &&
fontData.mSize.GetUnit() != eCSSUnit_Pixel)))
parentFont = NS_STATIC_CAST(const nsStyleFont*,
parentContext->GetStyleData(eStyleStruct_Font));
if (aStartStruct)
Expand Down
14 changes: 11 additions & 3 deletions layout/style/nsRuleNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ nscoord CalcLength(const nsCSSValue& aValue,
aPresContext->GetScaledPixelsToTwips(&p2t);
return NSFloatPixelsToTwips(aValue.GetFloatValue(), p2t);
default:
NS_NOTREACHED("unexpected unit");
break;
}
return 0;
Expand Down Expand Up @@ -794,6 +795,8 @@ CheckFontCallback(const nsCSSStruct& aData)
(family == NS_STYLE_FONT_LIST) ||
(family == NS_STYLE_FONT_FIELD) ||
(family == NS_STYLE_FONT_THEME))
// Mixed rather than Reset in case another sub-property has
// an explicit 'inherit'. XXXperf Could check them.
return nsRuleNode::eRuleFullMixed;
}
return nsRuleNode::eRuleUnknown;
Expand Down Expand Up @@ -1503,14 +1506,14 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
if (ruleNode->mNoneBits & bit)
break;

// If the inherit bit is set on a rule node for this struct, that
// If the dependent bit is set on a rule node for this struct, that
// means its rule won't have any information to add, so skip it.
// XXXldb I don't understand why we need to check |detail| here, but
// we do.
if (detail == eRuleNone)
while (ruleNode->mDependentBits & bit) {
NS_ASSERTION(ruleNode->mStyleData.GetStyleData(aSID) == nsnull,
"inherit bit with cached data makes no sense");
"dependent bit with cached data makes no sense");
// Climb up to the next rule in the tree (a less specific rule).
rootNode = ruleNode;
ruleNode = ruleNode->mParent;
Expand Down Expand Up @@ -2261,7 +2264,12 @@ nsRuleNode::ComputeFontData(nsStyleStruct* aStartStruct, const nsCSSStruct& aDat
const nsStyleFont* parentFont = nsnull;
PRBool inherited = aInherited;

if (parentContext && aRuleDetail != eRuleFullReset)
// This optimization is a little weaker here since 'em', etc., for
// 'font-size' require inheritance.
if (parentContext &&
(aRuleDetail != eRuleFullReset ||
(fontData.mSize.IsRelativeLengthUnit() &&
fontData.mSize.GetUnit() != eCSSUnit_Pixel)))
parentFont = NS_STATIC_CAST(const nsStyleFont*,
parentContext->GetStyleData(eStyleStruct_Font));
if (aStartStruct)
Expand Down

0 comments on commit 822db53

Please sign in to comment.