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

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

Issue 2865903002: [LayoutNG] Inline margin/border/padding, inter-item breaking, and tests (Closed)
Patch Set: ikilpatrick review Created 3 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
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 NGLineBreaker_h 5 #ifndef NGLineBreaker_h
6 #define NGLineBreaker_h 6 #define NGLineBreaker_h
7 7
8 #include "core/CoreExport.h" 8 #include "core/CoreExport.h"
9 #include "core/layout/ng/inline/ng_inline_item_result.h" 9 #include "core/layout/ng/inline/ng_inline_item_result.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 #include "platform/text/TextBreakIterator.h"
12 #include "platform/wtf/Allocator.h"
11 #include "platform/wtf/text/AtomicString.h" 13 #include "platform/wtf/text/AtomicString.h"
12 14
13 namespace blink { 15 namespace blink {
14 16
15 class LazyLineBreakIterator;
16 class NGInlineBreakToken; 17 class NGInlineBreakToken;
17 class NGInlineItem; 18 class NGInlineItem;
18 class NGInlineNode; 19 class NGInlineNode;
19 class NGInlineLayoutAlgorithm; 20 class NGInlineLayoutAlgorithm;
20 21
21 // Represents a line breaker. 22 // Represents a line breaker.
22 // 23 //
23 // This class measures each NGInlineItem and determines items to form a line, 24 // This class measures each NGInlineItem and determines items to form a line,
24 // so that NGInlineLayoutAlgorithm can build a line box from the output. 25 // so that NGInlineLayoutAlgorithm can build a line box from the output.
25 class CORE_EXPORT NGLineBreaker { 26 class CORE_EXPORT NGLineBreaker {
(...skipping 10 matching lines...) Expand all
36 // not only constraint space but also container builder. Consider refactor 37 // not only constraint space but also container builder. Consider refactor
37 // not to require algorithm. 38 // not to require algorithm.
38 void NextLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*); 39 void NextLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*);
39 40
40 // Create an NGInlineBreakToken for the last line returned by NextLine(). 41 // Create an NGInlineBreakToken for the last line returned by NextLine().
41 RefPtr<NGInlineBreakToken> CreateBreakToken() const; 42 RefPtr<NGInlineBreakToken> CreateBreakToken() const;
42 43
43 private: 44 private:
44 void BreakLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*); 45 void BreakLine(NGInlineItemResults*, NGInlineLayoutAlgorithm*);
45 46
46 bool HandleControlItem(const NGInlineItem&, 47 enum class LineBreakState {
47 const String& text, 48 // The current position is not breakable.
48 NGInlineItemResult*, 49 kNotBreakable,
49 LayoutUnit position); 50 // The current position is breakable.
50 void LayoutAtomicInline(const NGInlineItem&, NGInlineItemResult*); 51 kIsBreakable,
52 // Break by including trailing items (CloseTag).
53 kBreakAfterTrailings,
54 // Break immediately.
55 kForcedBreak
56 };
51 57
52 void HandleOverflow(NGInlineItemResults*, const LazyLineBreakIterator&); 58 LineBreakState HandleText(const NGInlineItem&, NGInlineItemResult*);
59 void BreakText(NGInlineItemResult*,
60 const NGInlineItem&,
61 LayoutUnit available_width);
62
63 LineBreakState HandleControlItem(const NGInlineItem&, NGInlineItemResult*);
64 LineBreakState HandleAtomicInline(const NGInlineItem&, NGInlineItemResult*);
65 void HandleFloat(const NGInlineItem&,
66 NGInlineItemResults*,
67 NGInlineLayoutAlgorithm*);
68
69 void HandleOpenTag(const NGInlineItem&, NGInlineItemResult*);
70 void HandleCloseTag(const NGInlineItem&, NGInlineItemResult*);
71
72 void HandleOverflow(NGInlineItemResults*);
73 void Rewind(NGInlineItemResults*, unsigned new_end);
74
75 void UpdateBreakIterator(const ComputedStyle&);
53 76
54 void MoveToNextOf(const NGInlineItem&); 77 void MoveToNextOf(const NGInlineItem&);
78 void MoveToNextOf(const NGInlineItemResult&);
55 void SkipCollapsibleWhitespaces(); 79 void SkipCollapsibleWhitespaces();
56 80
57 void AppendCloseTags(NGInlineItemResults*);
58
59 Persistent<NGInlineNode> node_; 81 Persistent<NGInlineNode> node_;
60 const NGConstraintSpace* constraint_space_; 82 const NGConstraintSpace* constraint_space_;
61 const AtomicString locale_; 83 const AtomicString locale_;
62 unsigned item_index_; 84 unsigned item_index_;
63 unsigned offset_; 85 unsigned offset_;
86 LayoutUnit available_width_;
87 LayoutUnit position_;
88 LazyLineBreakIterator break_iterator_;
89
90 unsigned auto_wrap_ : 1;
64 }; 91 };
65 92
66 } // namespace blink 93 } // namespace blink
67 94
68 #endif // NGLineBreaker_h 95 #endif // NGLineBreaker_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698