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 THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_INLINE_NODE_DATA_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_INLINE_NODE_DATA_H_ 7 8 #include "third_party/blink/renderer/core/core_export.h" 9 #include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_item.h" 10 #include "third_party/blink/renderer/platform/wtf/vector.h" 11 12 namespace blink { 13 14 template <typename OffsetMappingBuilder> 15 class NGInlineItemsBuilderTemplate; 16 17 // Data which is required for inline nodes. 18 struct CORE_EXPORT NGInlineNodeData : NGInlineItemsData { 19 public: IsBidiEnabledNGInlineNodeData20 bool IsBidiEnabled() const { return is_bidi_enabled_; } BaseDirectionNGInlineNodeData21 TextDirection BaseDirection() const { 22 return static_cast<TextDirection>(base_direction_); 23 } 24 HasLineEvenIfEmptyNGInlineNodeData25 bool HasLineEvenIfEmpty() const { return has_line_even_if_empty_; } HasRubyNGInlineNodeData26 bool HasRuby() const { return has_ruby_; } IsEmptyInlineNGInlineNodeData27 bool IsEmptyInline() const { return is_empty_inline_; } 28 IsBlockLevelNGInlineNodeData29 bool IsBlockLevel() const { return is_block_level_; } 30 ItemsDataNGInlineNodeData31 const NGInlineItemsData& ItemsData(bool is_first_line) const { 32 return !is_first_line || !first_line_items_ 33 ? (const NGInlineItemsData&)*this 34 : *first_line_items_; 35 } 36 37 private: SetBaseDirectionNGInlineNodeData38 void SetBaseDirection(TextDirection direction) { 39 base_direction_ = static_cast<unsigned>(direction); 40 } 41 42 friend class NGInlineItemsBuilderTest; 43 friend class NGInlineNode; 44 friend class NGInlineNodeLegacy; 45 friend class NGInlineNodeForTest; 46 friend class NGOffsetMappingTest; 47 48 template <typename OffsetMappingBuilder> 49 friend class NGInlineItemsBuilderTemplate; 50 51 // Items to use for the first line, when the node has :first-line rules. 52 // 53 // Items have different ComputedStyle, and may also have different 54 // text_content and ShapeResult if 'text-transform' is applied or fonts are 55 // different. 56 std::unique_ptr<NGInlineItemsData> first_line_items_; 57 58 unsigned is_bidi_enabled_ : 1; 59 unsigned base_direction_ : 1; // TextDirection 60 61 // True if there are no inline item items and the associated block is root 62 // editable element or having "-internal-empty-line-height:fabricated", 63 // e.g. <div contenteditable></div>, <input type=button value=""> 64 unsigned has_line_even_if_empty_ : 1; 65 66 // The node contains <ruby>. 67 unsigned has_ruby_ : 1; 68 69 // We use this flag to determine if the inline node is empty, and will 70 // produce a single zero block-size line box. If the node has text, atomic 71 // inlines, open/close tags with margins/border/padding this will be false. 72 unsigned is_empty_inline_ : 1; 73 74 // We use this flag to determine if we have *only* floats, and OOF-positioned 75 // children. If so we consider them block-level, and run the 76 // |NGBlockLayoutAlgorithm| instead of the |NGInlineLayoutAlgorithm|. This is 77 // done to pick up block-level static-position behaviour. 78 unsigned is_block_level_ : 1; 79 80 // True if changes to an item may affect different layout of earlier lines. 81 // May not be able to use line caches even when the line or earlier lines are 82 // not dirty. 83 unsigned changes_may_affect_earlier_lines_ : 1; 84 }; 85 86 } // namespace blink 87 88 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_NG_INLINE_NG_INLINE_NODE_DATA_H_ 89