| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2008 Holger Hans Peter Freyther |
| 7 * |
| 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either |
| 11 * version 2 of the License, or (at your option) any later version. |
| 12 * |
| 13 * This library is distributed in the hope that it will be useful, |
| 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 * Library General Public License for more details. |
| 17 * |
| 18 * You should have received a copy of the GNU Library General Public License |
| 19 * along with this library; see the file COPYING.LIB. If not, write to |
| 20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 21 * Boston, MA 02110-1301, USA. |
| 22 * |
| 23 */ |
| 24 |
| 25 #ifndef GlyphOverflow_h |
| 26 #define GlyphOverflow_h |
| 27 |
| 28 #include "platform/geometry/FloatRect.h" |
| 29 #include <math.h> |
| 30 |
| 31 namespace blink { |
| 32 |
| 33 struct GlyphOverflow { |
| 34 GlyphOverflow() |
| 35 : left(0) |
| 36 , right(0) |
| 37 , top(0) |
| 38 , bottom(0) |
| 39 , computeBounds(false) |
| 40 { |
| 41 } |
| 42 |
| 43 bool isZero() const |
| 44 { |
| 45 return !left && !right && !top && !bottom; |
| 46 } |
| 47 |
| 48 void setFromBounds(const FloatRect& bounds, float ascent, float descent, flo
at textWidth) |
| 49 { |
| 50 top = ceilf(computeBounds ? -bounds.y() : std::max(0.0f, -bounds.y() - a
scent)); |
| 51 bottom = ceilf(computeBounds ? bounds.maxY() : std::max(0.0f, bounds.max
Y() - descent)); |
| 52 left = ceilf(std::max(0.0f, -bounds.x())); |
| 53 right = ceilf(std::max(0.0f, bounds.maxX() - textWidth)); |
| 54 } |
| 55 |
| 56 // If computeBounds, top and bottom are the maximum heights of the glyphs ab
ove and below the baseline, respectively. |
| 57 // Otherwise they 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. |
| 59 // All fields are in absolute number of pixels rounded up to the nearest int
eger. |
| 60 int left; |
| 61 int right; |
| 62 int top; |
| 63 int bottom; |
| 64 bool computeBounds; |
| 65 }; |
| 66 |
| 67 } // namespace blink |
| 68 |
| 69 #endif // GlyphOverflow_h |
| OLD | NEW |