Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(659)

Unified Diff: third_party/WebKit/Source/platform/fonts/FontMetrics.h

Issue 2803483002: Adjust visual overflow rect for rounded/shifted ascent/descent (Closed)
Patch Set: - Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698