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

Side by Side Diff: Source/core/layout/line/GlyphOverflow.h

Issue 1179723002: Store glyph bounds in WordMeasurement to avoid slow path width calc (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: For review Created 5 years, 6 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // 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.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GlyphOverflow_h
6 #define GlyphOverflow_h
7
8 #include "platform/geometry/FloatRect.h"
9 #include <math.h>
10
11 namespace blink {
12
13 struct GlyphOverflow {
14 GlyphOverflow()
15 : left(0)
16 , right(0)
17 , top(0)
18 , bottom(0)
19 , computeBounds(false)
20 {
21 }
22
23 bool isZero() const
24 {
25 return !left && !right && !top && !bottom;
26 }
27
28 void setFromBounds(const FloatRect& bounds, float ascent, float descent, flo at textWidth)
29 {
30 top = ceilf(computeBounds ? -bounds.y() : std::max(0.0f, -bounds.y() - a scent));
31 bottom = ceilf(computeBounds ? bounds.maxY() : std::max(0.0f, bounds.max Y() - descent));
32 left = ceilf(std::max(0.0f, -bounds.x()));
33 right = ceilf(std::max(0.0f, bounds.maxX() - textWidth));
34 }
35
36 // If computeBounds, top and bottom are the maximum heights of the glyphs ab ove and below the baseline, respectively.
37 // Otherwise they are the amounts of glyph overflows exceeding the font metr ics' ascent and descent, respectively.
38 // Left and right are the amounts of glyph overflows exceeding the left and right edge of normal layout boundary, respectively.
39 // All fields are in absolute number of pixels rounded up to the nearest int eger.
40 int left;
41 int right;
42 int top;
43 int bottom;
44 bool computeBounds;
45 };
46
47 } // namespace blink
48
49 #endif // GlyphOverflow_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698