Index: third_party/WebKit/Source/core/layout/line/GlyphOverflow.h |
diff --git a/third_party/WebKit/Source/core/layout/line/GlyphOverflow.h b/third_party/WebKit/Source/core/layout/line/GlyphOverflow.h |
index f13382f1327e7e476c88e6c15ee4440be7134370..6b70e03daa67acd37cd24943b66f410e12fc5dc8 100644 |
--- a/third_party/WebKit/Source/core/layout/line/GlyphOverflow.h |
+++ b/third_party/WebKit/Source/core/layout/line/GlyphOverflow.h |
@@ -46,12 +46,31 @@ struct GlyphOverflow { |
return !left && !right && !top && !bottom; |
} |
+ // These helper functions are exposed to share logic with SVG which computes overflow |
+ // in floating point (see: SVGTextLayoutEngine). |
+ static float topOverflow(const FloatRect& bounds, float ascent) |
+ { |
+ return std::max(0.0f, -bounds.y() - ascent); |
+ } |
+ static float bottomOverflow(const FloatRect& bounds, float descent) |
+ { |
+ return std::max(0.0f, bounds.maxY() - descent); |
+ } |
+ static float leftOverflow(const FloatRect& bounds) |
+ { |
+ return std::max(0.0f, -bounds.x()); |
+ } |
+ static float rightOverflow(const FloatRect& bounds, float textWidth) |
+ { |
+ return std::max(0.0f, bounds.maxX() - textWidth); |
+ } |
+ |
void setFromBounds(const FloatRect& bounds, float ascent, float descent, float textWidth) |
{ |
- top = ceilf(std::max(0.0f, -bounds.y() - ascent)); |
- bottom = ceilf(std::max(0.0f, bounds.maxY() - descent)); |
- left = ceilf(std::max(0.0f, -bounds.x())); |
- right = ceilf(std::max(0.0f, bounds.maxX() - textWidth)); |
+ top = ceilf(topOverflow(bounds, ascent)); |
+ bottom = ceilf(bottomOverflow(bounds, descent)); |
+ left = ceilf(leftOverflow(bounds)); |
+ right = ceilf(rightOverflow(bounds, textWidth)); |
} |
// Top and bottom are the amounts of glyph overflows exceeding the font metrics' ascent and descent, respectively. |