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

Unified Diff: third_party/WebKit/Source/core/layout/line/GlyphOverflow.h

Issue 1505713002: Include glyph overflow in SVG text bounding boxes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More expectations Created 5 years 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/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.

Powered by Google App Engine
This is Rietveld 408576698