Index: third_party/WebKit/Source/platform/fonts/FontMetrics.h |
diff --git a/third_party/WebKit/Source/platform/fonts/FontMetrics.h b/third_party/WebKit/Source/platform/fonts/FontMetrics.h |
index ce51ee9aaa7a49f9a04ef249568865c9ce5ee38d..5d9e13a3b4acfcc971c2b09e04e68889083bf92d 100644 |
--- a/third_party/WebKit/Source/platform/fonts/FontMetrics.h |
+++ b/third_party/WebKit/Source/platform/fonts/FontMetrics.h |
@@ -46,7 +46,9 @@ class FontMetrics { |
m_ascentInt(0), |
m_descentInt(0), |
m_hasXHeight(false), |
- m_hasZeroWidth(false) {} |
+ m_hasZeroWidth(false), |
+ m_visualOverflowInflationForAscent(0), |
+ m_visualOverflowInflationForDescent(0) {} |
unsigned unitsPerEm() const { return m_unitsPerEm; } |
void setUnitsPerEm(unsigned unitsPerEm) { m_unitsPerEm = unitsPerEm; } |
@@ -60,6 +62,8 @@ class FontMetrics { |
void setAscent(float ascent) { |
m_ascent = ascent; |
m_ascentInt = lroundf(ascent); |
+ if (m_ascentInt < ascent) |
+ m_visualOverflowInflationForAscent++; |
eae
2017/04/07 17:41:57
FontMetrics already stores the rounded and unround
Xianzhu
2017/04/07 18:02:53
FontMetrics doesn't store the unrounded values in
|
} |
float floatDescent(FontBaseline baselineType = AlphabeticBaseline) const { |
@@ -71,6 +75,19 @@ class FontMetrics { |
void setDescent(float descent) { |
m_descent = descent; |
m_descentInt = lroundf(descent); |
+ if (m_descentInt < descent) |
+ m_visualOverflowInflationForDescent++; |
+ } |
+ |
+ void setVisualOverflowInflations(int forAscent, int forDescent) { |
+ m_visualOverflowInflationForAscent = forAscent; |
+ m_visualOverflowInflationForDescent = forDescent; |
+ } |
+ int visualOverflowInflationForAscent() const { |
+ return m_visualOverflowInflationForAscent; |
+ } |
+ int visualOverflowInflationForDescent() const { |
+ return m_visualOverflowInflationForDescent; |
} |
float floatHeight(FontBaseline baselineType = AlphabeticBaseline) const { |
@@ -167,6 +184,8 @@ class FontMetrics { |
m_hasXHeight = false; |
m_underlinethickness = 0; |
m_underlinePosition = 0; |
+ m_visualOverflowInflationForAscent = 0; |
+ m_visualOverflowInflationForDescent = 0; |
} |
unsigned m_unitsPerEm; |
@@ -182,6 +201,12 @@ class FontMetrics { |
int m_descentInt; |
bool m_hasXHeight; |
bool m_hasZeroWidth; |
+ |
+ // These are set to non-zero when ascent or descent is rounded or shifted |
+ // to be smaller than the actual ascent or descent. When calculating visual |
+ // overflows, we should add the inflations. |
+ int m_visualOverflowInflationForAscent; |
+ int m_visualOverflowInflationForDescent; |
}; |
} // namespace blink |