| OLD | NEW |
| 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 Loading... |
| 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 ceilf(std::max(0.0f, -bounds.y() - ascent)); |
| 54 } |
| 55 static float bottomOverflow(const FloatRect& bounds, float descent) |
| 56 { |
| 57 return ceilf(std::max(0.0f, bounds.maxY() - descent)); |
| 58 } |
| 59 static float leftOverflow(const FloatRect& bounds) |
| 60 { |
| 61 return ceilf(std::max(0.0f, -bounds.x())); |
| 62 } |
| 63 static float rightOverflow(const FloatRect& bounds, float textWidth) |
| 64 { |
| 65 return ceilf(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 = topOverflow(bounds, ascent); |
| 52 bottom = ceilf(std::max(0.0f, bounds.maxY() - descent)); | 71 bottom = bottomOverflow(bounds, descent); |
| 53 left = ceilf(std::max(0.0f, -bounds.x())); | 72 left = leftOverflow(bounds); |
| 54 right = ceilf(std::max(0.0f, bounds.maxX() - textWidth)); | 73 right = 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 |
| OLD | NEW |