Chromium Code Reviews| Index: Source/core/layout/line/GlyphOverflow.h |
| diff --git a/Source/core/layout/line/GlyphOverflow.h b/Source/core/layout/line/GlyphOverflow.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0f95a3b92ce657adcd95de90862237ccff980bf4 |
| --- /dev/null |
| +++ b/Source/core/layout/line/GlyphOverflow.h |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
eae
2015/06/11 18:33:38
Retain copyright from Font.h where this came from.
Xianzhu
2015/06/11 20:40:09
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef GlyphOverflow_h |
| +#define GlyphOverflow_h |
| + |
| +#include "platform/geometry/FloatRect.h" |
| +#include <math.h> |
| + |
| +namespace blink { |
| + |
| +struct GlyphOverflow { |
| + GlyphOverflow() |
| + : left(0) |
| + , right(0) |
| + , top(0) |
| + , bottom(0) |
| + , computeBounds(false) |
| + { |
| + } |
| + |
| + bool isZero() const |
| + { |
| + return !left && !right && !top && !bottom; |
| + } |
| + |
| + void setFromBounds(const FloatRect& bounds, float ascent, float descent, float textWidth) |
| + { |
| + top = ceilf(computeBounds ? -bounds.y() : std::max(0.0f, -bounds.y() - ascent)); |
| + bottom = ceilf(computeBounds ? bounds.maxY() : std::max(0.0f, bounds.maxY() - descent)); |
| + left = ceilf(std::max(0.0f, -bounds.x())); |
| + right = ceilf(std::max(0.0f, bounds.maxX() - textWidth)); |
| + } |
| + |
| + // If computeBounds, top and bottom are the maximum heights of the glyphs above and below the baseline, respectively. |
| + // Otherwise they are the amounts of glyph overflows exceeding the font metrics' ascent and descent, respectively. |
| + // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively. |
| + // All fields are in absolute number of pixels rounded up to the nearest integer. |
| + int left; |
| + int right; |
| + int top; |
| + int bottom; |
| + bool computeBounds; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // GlyphOverflow_h |