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

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

Issue 2706403008: [LayoutNG] Implement ComputeMinAndMaxContentSizes for inline (Closed)
Patch Set: cbiesinger review Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 NGInlineNode_h 5 #ifndef NGInlineNode_h
6 #define NGInlineNode_h 6 #define NGInlineNode_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/ng_layout_input_node.h" 9 #include "core/layout/ng/ng_layout_input_node.h"
10 #include "platform/fonts/FontFallbackPriority.h" 10 #include "platform/fonts/FontFallbackPriority.h"
11 #include "platform/fonts/shaping/ShapeResult.h" 11 #include "platform/fonts/shaping/ShapeResult.h"
12 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
13 #include "platform/text/TextDirection.h" 13 #include "platform/text/TextDirection.h"
14 #include "wtf/text/WTFString.h" 14 #include "wtf/text/WTFString.h"
15 15
16 #include <unicode/ubidi.h> 16 #include <unicode/ubidi.h>
17 #include <unicode/uscript.h> 17 #include <unicode/uscript.h>
18 18
19 namespace blink { 19 namespace blink {
20 20
21 class ComputedStyle; 21 class ComputedStyle;
22 class LayoutBlockFlow; 22 class LayoutBlockFlow;
23 class LayoutObject; 23 class LayoutObject;
24 class LayoutUnit; 24 class LayoutUnit;
25 struct MinAndMaxContentSizes;
25 class NGConstraintSpace; 26 class NGConstraintSpace;
26 class NGLayoutInlineItem; 27 class NGLayoutInlineItem;
27 class NGLayoutInlineItemRange; 28 class NGLayoutInlineItemRange;
28 class NGLayoutInlineItemsBuilder; 29 class NGLayoutInlineItemsBuilder;
29 class NGLayoutResult; 30 class NGLayoutResult;
30 class NGLineBuilder; 31 class NGLineBuilder;
31 32
32 // Represents an inline node to be laid out. 33 // Represents an anonymous block box to be laid out, that contains consecutive
34 // inline nodes and their descendants.
33 class CORE_EXPORT NGInlineNode : public NGLayoutInputNode { 35 class CORE_EXPORT NGInlineNode : public NGLayoutInputNode {
34 public: 36 public:
35 NGInlineNode(LayoutObject* start_inline, const ComputedStyle* block_style); 37 NGInlineNode(LayoutObject* start_inline, const ComputedStyle* block_style);
36 ~NGInlineNode() override; 38 ~NGInlineNode() override;
37 39
38 const ComputedStyle* BlockStyle() const { return block_style_.get(); } 40 const ComputedStyle* BlockStyle() const { return block_style_.get(); }
39 41
40 RefPtr<NGLayoutResult> Layout(NGConstraintSpace*) override; 42 RefPtr<NGLayoutResult> Layout(NGConstraintSpace*) override;
41 void LayoutInline(NGConstraintSpace*, NGLineBuilder*); 43 void LayoutInline(NGConstraintSpace*, NGLineBuilder*);
42 NGInlineNode* NextSibling() override; 44 NGInlineNode* NextSibling() override;
43 LayoutObject* GetLayoutObject() override; 45 LayoutObject* GetLayoutObject() override;
44 46
45 // Prepare inline and text content for layout. Must be called before 47 // Computes the value of min-content and max-content for this anonymous block
46 // calling the Layout method. 48 // box. min-content is the inline size when lines wrap at every break
47 void PrepareLayout(); 49 // opportunity, and max-content is when lines do not wrap at all.
50 MinAndMaxContentSizes ComputeMinAndMaxContentSizes();
51
52 // Instruct to re-compute |PrepareLayout| on the next layout.
53 void InvalidatePrepareLayout();
48 54
49 const String& Text() const { return text_content_; } 55 const String& Text() const { return text_content_; }
50 String Text(unsigned start_offset, unsigned end_offset) const { 56 String Text(unsigned start_offset, unsigned end_offset) const {
51 return text_content_.substring(start_offset, end_offset); 57 return text_content_.substring(start_offset, end_offset);
52 } 58 }
53 59
54 Vector<NGLayoutInlineItem>& Items() { return items_; } 60 Vector<NGLayoutInlineItem>& Items() { return items_; }
55 NGLayoutInlineItemRange Items(unsigned start_index, unsigned end_index); 61 NGLayoutInlineItemRange Items(unsigned start_index, unsigned end_index);
56 62
57 LayoutBlockFlow* GetLayoutBlockFlow() const; 63 LayoutBlockFlow* GetLayoutBlockFlow() const;
58 void GetLayoutTextOffsets(Vector<unsigned, 32>*); 64 void GetLayoutTextOffsets(Vector<unsigned, 32>*);
59 65
60 bool IsBidiEnabled() const { return is_bidi_enabled_; } 66 bool IsBidiEnabled() const { return is_bidi_enabled_; }
61 67
62 void AssertOffset(unsigned index, unsigned offset) const; 68 void AssertOffset(unsigned index, unsigned offset) const;
63 void AssertEndOffset(unsigned index, unsigned offset) const; 69 void AssertEndOffset(unsigned index, unsigned offset) const;
64 70
65 DECLARE_VIRTUAL_TRACE(); 71 DECLARE_VIRTUAL_TRACE();
66 72
67 protected: 73 protected:
68 NGInlineNode(); // This constructor is only for testing. 74 NGInlineNode(); // This constructor is only for testing.
75
76 // Prepare inline and text content for layout. Must be called before
77 // calling the Layout method.
78 void PrepareLayout();
79 bool IsPrepareLayoutFinished() const { return !items_.isEmpty(); }
80
69 void CollectInlines(LayoutObject* start, LayoutObject* last); 81 void CollectInlines(LayoutObject* start, LayoutObject* last);
70 void CollectInlines(LayoutObject* start, 82 void CollectInlines(LayoutObject* start,
71 LayoutObject* last, 83 LayoutObject* last,
72 NGLayoutInlineItemsBuilder*); 84 NGLayoutInlineItemsBuilder*);
73 void SegmentText(); 85 void SegmentText();
74 void ShapeText(); 86 void ShapeText();
75 87
76 LayoutObject* start_inline_; 88 LayoutObject* start_inline_;
77 LayoutObject* last_inline_; 89 LayoutObject* last_inline_;
78 RefPtr<const ComputedStyle> block_style_; 90 RefPtr<const ComputedStyle> block_style_;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 224
213 private: 225 private:
214 NGLayoutInlineItem* start_item_; 226 NGLayoutInlineItem* start_item_;
215 unsigned size_; 227 unsigned size_;
216 unsigned start_index_; 228 unsigned start_index_;
217 }; 229 };
218 230
219 } // namespace blink 231 } // namespace blink
220 232
221 #endif // NGInlineNode_h 233 #endif // NGInlineNode_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698