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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) 2008 Holger Hans Peter Freyther 6 * Copyright (C) 2008 Holger Hans Peter Freyther
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 28 matching lines...) Expand all
39 , top(0) 39 , top(0)
40 , bottom(0) 40 , bottom(0)
41 { 41 {
42 } 42 }
43 43
44 bool isZero() const 44 bool isZero() const
45 { 45 {
46 return !left && !right && !top && !bottom; 46 return !left && !right && !top && !bottom;
47 } 47 }
48 48
49 // These helper functions are exposed to share logic with SVG which computes overflow
50 // in floating point (see: SVGTextLayoutEngine).
51 static float topOverflow(const FloatRect& bounds, float ascent)
52 {
53 return std::max(0.0f, -bounds.y() - ascent);
54 }
55 static float bottomOverflow(const FloatRect& bounds, float descent)
56 {
57 return std::max(0.0f, bounds.maxY() - descent);
58 }
59 static float leftOverflow(const FloatRect& bounds)
60 {
61 return std::max(0.0f, -bounds.x());
62 }
63 static float rightOverflow(const FloatRect& bounds, float textWidth)
64 {
65 return std::max(0.0f, bounds.maxX() - textWidth);
66 }
67
49 void setFromBounds(const FloatRect& bounds, float ascent, float descent, flo at textWidth) 68 void setFromBounds(const FloatRect& bounds, float ascent, float descent, flo at textWidth)
50 { 69 {
51 top = ceilf(std::max(0.0f, -bounds.y() - ascent)); 70 top = ceilf(topOverflow(bounds, ascent));
52 bottom = ceilf(std::max(0.0f, bounds.maxY() - descent)); 71 bottom = ceilf(bottomOverflow(bounds, descent));
53 left = ceilf(std::max(0.0f, -bounds.x())); 72 left = ceilf(leftOverflow(bounds));
54 right = ceilf(std::max(0.0f, bounds.maxX() - textWidth)); 73 right = ceilf(rightOverflow(bounds, textWidth));
55 } 74 }
56 75
57 // Top and bottom are the amounts of glyph overflows exceeding the font metr ics' ascent and descent, respectively. 76 // Top and bottom are the amounts of glyph overflows exceeding the font metr ics' ascent and descent, respectively.
58 // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively. 77 // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively.
59 // All fields are in absolute number of pixels rounded up to the nearest int eger. 78 // All fields are in absolute number of pixels rounded up to the nearest int eger.
60 int left; 79 int left;
61 int right; 80 int right;
62 int top; 81 int top;
63 int bottom; 82 int bottom;
64 }; 83 };
65 84
66 } // namespace blink 85 } // namespace blink
67 86
68 #endif // GlyphOverflow_h 87 #endif // GlyphOverflow_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698