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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/inline/ng_line_height_metrics.h

Issue 2803433002: [LayoutNG] Initial support for the 'vertical-align' property (Closed)
Patch Set: Move all On*() to NGInlineLayoutStateStack Created 3 years, 8 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NGLineHeightMetrics_h 5 #ifndef NGLineHeightMetrics_h
6 #define NGLineHeightMetrics_h 6 #define NGLineHeightMetrics_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/ng_physical_fragment.h" 9 #include "core/layout/ng/ng_physical_fragment.h"
10 #include "platform/fonts/FontBaseline.h" 10 #include "platform/fonts/FontBaseline.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 class ComputedStyle; 14 class ComputedStyle;
15 class FontMetrics; 15 class FontMetrics;
16 16
17 // Represents line-progression metrics for line boxes and inline boxes. 17 // Represents line-progression metrics for line boxes and inline boxes.
18 // Computed for inline boxes, then the metrics of inline boxes are united to 18 // Computed for inline boxes, then the metrics of inline boxes are united to
19 // compute metrics for line boxes. 19 // compute metrics for line boxes.
20 // https://drafts.csswg.org/css2/visudet.html#line-height 20 // https://drafts.csswg.org/css2/visudet.html#line-height
21 struct NGLineHeightMetrics { 21 struct NGLineHeightMetrics {
22 NGLineHeightMetrics() {} 22 NGLineHeightMetrics()
23 : ascent(LayoutUnit::Min()), descent(LayoutUnit::Min()) {}
23 NGLineHeightMetrics(LayoutUnit initial_ascent, LayoutUnit initial_descent) 24 NGLineHeightMetrics(LayoutUnit initial_ascent, LayoutUnit initial_descent)
24 : ascent(initial_ascent), descent(initial_descent) {} 25 : ascent(initial_ascent), descent(initial_descent) {}
25 26
26 // Compute from ComputedStyle, using the font metrics of the prikmary font. 27 // Compute from ComputedStyle, using the font metrics of the prikmary font.
27 // The leading is not included. 28 // The leading is not included.
28 NGLineHeightMetrics(const ComputedStyle&, FontBaseline); 29 NGLineHeightMetrics(const ComputedStyle&, FontBaseline);
29 30
30 // Compute from FontMetrics. The leading is not included. 31 // Compute from FontMetrics. The leading is not included.
31 NGLineHeightMetrics(const FontMetrics&, FontBaseline); 32 NGLineHeightMetrics(const FontMetrics&, FontBaseline);
32 33
34 bool IsEmpty() const { return ascent == LayoutUnit::Min(); }
35
33 // Add the leading. Half the leading is added to ascent and descent each. 36 // Add the leading. Half the leading is added to ascent and descent each.
34 // https://drafts.csswg.org/css2/visudet.html#leading 37 // https://drafts.csswg.org/css2/visudet.html#leading
35 void AddLeading(LayoutUnit line_height); 38 void AddLeading(LayoutUnit line_height);
36 39
40 // Move the metrics by the specified amount, in line progression direction.
41 void Move(LayoutUnit);
42
37 // Unite a metrics for an inline box to a metrics for a line box. 43 // Unite a metrics for an inline box to a metrics for a line box.
38 void Unite(const NGLineHeightMetrics&); 44 void Unite(const NGLineHeightMetrics&);
39 45
40 // Ascent and descent of glyphs, or synthesized for replaced elements. 46 // Ascent and descent of glyphs, or synthesized for replaced elements.
41 // Then united to compute 'text-top' and 'text-bottom' of line boxes. 47 // Then united to compute 'text-top' and 'text-bottom' of line boxes.
42 LayoutUnit ascent; 48 LayoutUnit ascent;
43 LayoutUnit descent; 49 LayoutUnit descent;
44 50
45 LayoutUnit LineHeight() const { return ascent + descent; } 51 LayoutUnit LineHeight() const { return ascent + descent; }
46 52
47 private: 53 private:
48 void Initialize(const FontMetrics&, FontBaseline); 54 void Initialize(const FontMetrics&, FontBaseline);
49 }; 55 };
50 56
51 } // namespace blink 57 } // namespace blink
52 58
53 #endif // NGLineHeightMetrics_h 59 #endif // NGLineHeightMetrics_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698