OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NGInlineBoxState_h |
| 6 #define NGInlineBoxState_h |
| 7 |
| 8 #include "core/CoreExport.h" |
| 9 #include "core/layout/ng/inline/ng_line_height_metrics.h" |
| 10 #include "core/style/ComputedStyleConstants.h" |
| 11 #include "platform/LayoutUnit.h" |
| 12 #include "platform/fonts/FontBaseline.h" |
| 13 #include "platform/wtf/Vector.h" |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 class NGLayoutInlineItem; |
| 18 class NGLineBoxFragmentBuilder; |
| 19 class NGTextFragmentBuilder; |
| 20 |
| 21 // Fragments that require the layout position/size of ancestor are packed in |
| 22 // this struct. |
| 23 struct NGPendingPositions { |
| 24 unsigned fragment_start; |
| 25 unsigned fragment_end; |
| 26 NGLineHeightMetrics metrics; |
| 27 EVerticalAlign vertical_align; |
| 28 }; |
| 29 |
| 30 // Represents the current box while NGInlineLayoutAlgorithm performs layout. |
| 31 // Used 1) to cache common values for a box, and 2) to layout children that |
| 32 // require ancestor position or size. |
| 33 struct NGInlineBoxState { |
| 34 unsigned fragment_start; |
| 35 const ComputedStyle* style; |
| 36 NGLineHeightMetrics metrics; |
| 37 NGLineHeightMetrics text_metrics; |
| 38 LayoutUnit text_top; |
| 39 Vector<NGPendingPositions> pending_descendants; |
| 40 bool include_used_fonts = false; |
| 41 |
| 42 // Compute text metrics for a box. All text in a box share the same metrics. |
| 43 void ComputeTextMetrics(const NGLayoutInlineItem&, FontBaseline); |
| 44 }; |
| 45 |
| 46 // Represents the inline tree structure. This class provides: |
| 47 // 1) Allow access to fragments belonging to the current box. |
| 48 // 2) Performs layout when the positin/size of a box was computed. |
| 49 // 3) Cache common values for a box. |
| 50 class NGInlineLayoutStateStack { |
| 51 public: |
| 52 // Initialize the box state stack for a new line. |
| 53 // @return The initial box state for the line. |
| 54 NGInlineBoxState* OnBeginPlaceItems(const ComputedStyle*); |
| 55 |
| 56 // Push a box state stack. |
| 57 NGInlineBoxState* OnOpenTag(const NGLayoutInlineItem&, |
| 58 NGLineBoxFragmentBuilder*, |
| 59 NGTextFragmentBuilder*); |
| 60 |
| 61 // Pop a box state stack. |
| 62 NGInlineBoxState* OnCloseTag(const NGLayoutInlineItem&, |
| 63 NGLineBoxFragmentBuilder*, |
| 64 NGInlineBoxState*); |
| 65 |
| 66 // Compute all the pending positioning at the end of a line. |
| 67 void OnEndPlaceItems(NGLineBoxFragmentBuilder*); |
| 68 |
| 69 private: |
| 70 // End of a box state, either explicitly by close tag, or implicitly at the |
| 71 // end of a line. |
| 72 void EndBoxState(NGInlineBoxState*, NGLineBoxFragmentBuilder*); |
| 73 |
| 74 // Compute vertical position for the 'vertical-align' property. |
| 75 // The timing to apply varies by values; some values apply at the layout of |
| 76 // the box was computed. Other values apply when the layout of the parent or |
| 77 // the line box was computed. |
| 78 // https://www.w3.org/TR/CSS22/visudet.html#propdef-vertical-align |
| 79 // https://www.w3.org/TR/css-inline-3/#propdef-vertical-align |
| 80 void ApplyBaselineShift(NGInlineBoxState*, NGLineBoxFragmentBuilder*); |
| 81 |
| 82 Vector<NGInlineBoxState, 4> stack_; |
| 83 }; |
| 84 |
| 85 } // namespace blink |
| 86 |
| 87 #endif // NGInlineBoxState_h |
OLD | NEW |