mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1414926 - Make -moz-font-smoothing-background-color changes only cause repaints, not reflows. r=emilio
This case is hit by hovering over menu items, so the optimization is somewhat worthwhile. As a side-effect, not causing reflows also avoids a XUL <select> popup positioning bug. MozReview-Commit-ID: AOrijytoHHL --HG-- extra : rebase_source : c2156eb24171f6d0b0e5476c4a7dbc641a0b5301
This commit is contained in:
parent
91932e97bd
commit
62e25a4903
@ -42,32 +42,42 @@ nsFont::~nsFont()
|
|||||||
|
|
||||||
bool nsFont::Equals(const nsFont& aOther) const
|
bool nsFont::Equals(const nsFont& aOther) const
|
||||||
{
|
{
|
||||||
if ((style == aOther.style) &&
|
return CalcDifference(aOther) == MaxDifference::eNone;
|
||||||
(systemFont == aOther.systemFont) &&
|
}
|
||||||
(weight == aOther.weight) &&
|
|
||||||
(stretch == aOther.stretch) &&
|
nsFont::MaxDifference
|
||||||
(size == aOther.size) &&
|
nsFont::CalcDifference(const nsFont& aOther) const
|
||||||
(sizeAdjust == aOther.sizeAdjust) &&
|
{
|
||||||
(fontlist == aOther.fontlist) &&
|
if ((style != aOther.style) ||
|
||||||
(kerning == aOther.kerning) &&
|
(systemFont != aOther.systemFont) ||
|
||||||
(synthesis == aOther.synthesis) &&
|
(weight != aOther.weight) ||
|
||||||
(fontFeatureSettings == aOther.fontFeatureSettings) &&
|
(stretch != aOther.stretch) ||
|
||||||
(fontVariationSettings == aOther.fontVariationSettings) &&
|
(size != aOther.size) ||
|
||||||
(languageOverride == aOther.languageOverride) &&
|
(sizeAdjust != aOther.sizeAdjust) ||
|
||||||
(variantAlternates == aOther.variantAlternates) &&
|
(fontlist != aOther.fontlist) ||
|
||||||
(variantCaps == aOther.variantCaps) &&
|
(kerning != aOther.kerning) ||
|
||||||
(variantEastAsian == aOther.variantEastAsian) &&
|
(synthesis != aOther.synthesis) ||
|
||||||
(variantLigatures == aOther.variantLigatures) &&
|
(fontFeatureSettings != aOther.fontFeatureSettings) ||
|
||||||
(variantNumeric == aOther.variantNumeric) &&
|
(fontVariationSettings != aOther.fontVariationSettings) ||
|
||||||
(variantPosition == aOther.variantPosition) &&
|
(languageOverride != aOther.languageOverride) ||
|
||||||
(variantWidth == aOther.variantWidth) &&
|
(variantAlternates != aOther.variantAlternates) ||
|
||||||
(alternateValues == aOther.alternateValues) &&
|
(variantCaps != aOther.variantCaps) ||
|
||||||
(featureValueLookup == aOther.featureValueLookup) &&
|
(variantEastAsian != aOther.variantEastAsian) ||
|
||||||
(smoothing == aOther.smoothing) &&
|
(variantLigatures != aOther.variantLigatures) ||
|
||||||
(fontSmoothingBackgroundColor == aOther.fontSmoothingBackgroundColor)) {
|
(variantNumeric != aOther.variantNumeric) ||
|
||||||
return true;
|
(variantPosition != aOther.variantPosition) ||
|
||||||
|
(variantWidth != aOther.variantWidth) ||
|
||||||
|
(alternateValues != aOther.alternateValues) ||
|
||||||
|
(featureValueLookup != aOther.featureValueLookup)) {
|
||||||
|
return MaxDifference::eLayoutAffecting;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
if ((smoothing != aOther.smoothing) ||
|
||||||
|
(fontSmoothingBackgroundColor != aOther.fontSmoothingBackgroundColor)) {
|
||||||
|
return MaxDifference::eVisual;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MaxDifference::eNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsFont& nsFont::operator=(const nsFont& aOther) = default;
|
nsFont& nsFont::operator=(const nsFont& aOther) = default;
|
||||||
|
@ -143,6 +143,14 @@ struct nsFont {
|
|||||||
|
|
||||||
nsFont& operator=(const nsFont& aOther);
|
nsFont& operator=(const nsFont& aOther);
|
||||||
|
|
||||||
|
enum class MaxDifference : uint8_t {
|
||||||
|
eNone,
|
||||||
|
eVisual,
|
||||||
|
eLayoutAffecting
|
||||||
|
};
|
||||||
|
|
||||||
|
MaxDifference CalcDifference(const nsFont& aOther) const;
|
||||||
|
|
||||||
void CopyAlternates(const nsFont& aOther);
|
void CopyAlternates(const nsFont& aOther);
|
||||||
|
|
||||||
// Add featureSettings into style
|
// Add featureSettings into style
|
||||||
|
@ -446,6 +446,11 @@ operator==(const FontFamilyList& a, const FontFamilyList& b) {
|
|||||||
return a.Equals(b);
|
return a.Equals(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool
|
||||||
|
operator!=(const FontFamilyList& a, const FontFamilyList& b) {
|
||||||
|
return !a.Equals(b);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
#endif /* GFX_FONT_FAMILY_LIST_H */
|
#endif /* GFX_FONT_FAMILY_LIST_H */
|
||||||
|
@ -199,18 +199,25 @@ nsStyleFont::CalcDifference(const nsStyleFont& aNewData) const
|
|||||||
MOZ_ASSERT(mAllowZoom == aNewData.mAllowZoom,
|
MOZ_ASSERT(mAllowZoom == aNewData.mAllowZoom,
|
||||||
"expected mAllowZoom to be the same on both nsStyleFonts");
|
"expected mAllowZoom to be the same on both nsStyleFonts");
|
||||||
if (mSize != aNewData.mSize ||
|
if (mSize != aNewData.mSize ||
|
||||||
mFont != aNewData.mFont ||
|
|
||||||
mLanguage != aNewData.mLanguage ||
|
mLanguage != aNewData.mLanguage ||
|
||||||
mExplicitLanguage != aNewData.mExplicitLanguage ||
|
mExplicitLanguage != aNewData.mExplicitLanguage ||
|
||||||
mMathVariant != aNewData.mMathVariant ||
|
mMathVariant != aNewData.mMathVariant ||
|
||||||
mMathDisplay != aNewData.mMathDisplay ||
|
mMathDisplay != aNewData.mMathDisplay ||
|
||||||
mMinFontSizeRatio != aNewData.mMinFontSizeRatio) {
|
mMinFontSizeRatio != aNewData.mMinFontSizeRatio) {
|
||||||
// If only mFont.fontSmoothingBackgroundColor changes, we really only need
|
|
||||||
// a repaint hint rather than a reflow+repaint hint, but it's not worth
|
|
||||||
// worth optimizing.
|
|
||||||
return NS_STYLE_HINT_REFLOW;
|
return NS_STYLE_HINT_REFLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (mFont.CalcDifference(aNewData.mFont)) {
|
||||||
|
case nsFont::MaxDifference::eLayoutAffecting:
|
||||||
|
return NS_STYLE_HINT_REFLOW;
|
||||||
|
|
||||||
|
case nsFont::MaxDifference::eVisual:
|
||||||
|
return NS_STYLE_HINT_VISUAL;
|
||||||
|
|
||||||
|
case nsFont::MaxDifference::eNone:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// XXX Should any of these cause a non-nsChangeHint_NeutralChange change?
|
// XXX Should any of these cause a non-nsChangeHint_NeutralChange change?
|
||||||
if (mGenericID != aNewData.mGenericID ||
|
if (mGenericID != aNewData.mGenericID ||
|
||||||
mScriptLevel != aNewData.mScriptLevel ||
|
mScriptLevel != aNewData.mScriptLevel ||
|
||||||
|
Loading…
Reference in New Issue
Block a user