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..c6c0a30e040788d6adc65ec608aa80609db29892 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_visualOverflowAdjustmentForAscent(0), |
+ m_visualOverflowAdjustmentForDescent(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_visualOverflowAdjustmentForAscent++; |
} |
float floatDescent(FontBaseline baselineType = AlphabeticBaseline) const { |
@@ -71,6 +75,20 @@ class FontMetrics { |
void setDescent(float descent) { |
m_descent = descent; |
m_descentInt = lroundf(descent); |
+ if (m_descentInt < descent) |
+ m_visualOverflowAdjustmentForDescent++; |
+ } |
+ |
+ void setVisualOverflowAdjustments(int ascentAdjustment, |
+ int descentAdjustment) { |
+ m_visualOverflowAdjustmentForAscent = ascentAdjustment; |
+ m_visualOverflowAdjustmentForDescent = descentAdjustment; |
+ } |
+ int visualOverflowAdjustmentForAscent() const { |
+ return m_visualOverflowAdjustmentForAscent; |
+ } |
+ int visualOverflowAdjustmentForDescent() const { |
+ return m_visualOverflowAdjustmentForDescent; |
} |
float floatHeight(FontBaseline baselineType = AlphabeticBaseline) const { |
@@ -167,6 +185,8 @@ class FontMetrics { |
m_hasXHeight = false; |
m_underlinethickness = 0; |
m_underlinePosition = 0; |
+ m_visualOverflowAdjustmentForAscent = 0; |
+ m_visualOverflowAdjustmentForDescent = 0; |
} |
unsigned m_unitsPerEm; |
@@ -182,6 +202,12 @@ class FontMetrics { |
int m_descentInt; |
bool m_hasXHeight; |
bool m_hasZeroWidth; |
+ |
+ // These are set to non-zero when ascent or descent is rounded to be smaller |
+ // than the actual ascent or descent. Should consider these adjustments when |
+ // calculating visual overflows. |
+ int m_visualOverflowAdjustmentForAscent; |
+ int m_visualOverflowAdjustmentForDescent; |
}; |
} // namespace blink |