Index: third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h |
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h |
index cb3de054fa9affe5b582e4d989c591241baa6819..402a8d1f09af68d2aace96461fcf9cb93e835270 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h |
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h |
@@ -45,13 +45,46 @@ class CORE_EXPORT NGLineBreaker { |
RefPtr<NGInlineBreakToken> CreateBreakToken() const; |
private: |
+ // This struct holds information for the current line. |
+ struct LineData { |
+ STACK_ALLOCATED(); |
+ |
+ // The current position from inline_start. Unlike NGInlineLayoutAlgorithm |
+ // that computes position in visual order, this position in logical order. |
+ LayoutUnit position; |
+ |
+ // The current opportunity. |
+ WTF::Optional<NGLayoutOpportunity> opportunity; |
+ |
+ // True if the current opportunity has floats or exclusions. |
+ bool has_floats_or_exclusions = false; |
+ |
+ // We don't create "certain zero-height line boxes". |
+ // https://drafts.csswg.org/css2/visuren.html#phantom-line-box |
+ // Such line boxes do not prevent two margins being "adjoining", and thus |
+ // collapsing. |
+ // https://drafts.csswg.org/css2/box.html#collapsing-margins |
+ bool should_create_line_box = false; |
+ |
+ // Set when the line ended with a forced break. Used to setup the states for |
+ // the next line. |
+ bool is_after_forced_break = false; |
+ |
+ bool HasAvailableWidth() const { return opportunity.has_value(); } |
+ LayoutUnit AvailableWidth() const { return opportunity->InlineSize(); } |
+ bool CanFit() const { return position <= AvailableWidth(); } |
+ bool CanFit(LayoutUnit extra) const { |
+ return position + extra <= AvailableWidth(); |
+ } |
+ }; |
+ |
void BreakLine(NGLineInfo*); |
- bool HasAvailableWidth() const { return opportunity_.has_value(); } |
- LayoutUnit AvailableWidth() const { |
- return opportunity_.value().InlineSize(); |
- } |
+ void PrepareNextLine(NGLineInfo*); |
+ |
void UpdateAvailableWidth(); |
+ void MoveDownBelowFloats(LayoutUnit min_inline_size); |
+ |
void ComputeLineLocation(NGLineInfo*) const; |
enum class LineBreakState { |
@@ -94,31 +127,26 @@ class CORE_EXPORT NGLineBreaker { |
bool IsFirstFormattedLine() const; |
+ LineData line_; |
NGInlineNode node_; |
NGConstraintSpace* constraint_space_; |
NGFragmentBuilder* container_builder_; |
Vector<RefPtr<NGUnpositionedFloat>>* unpositioned_floats_; |
- const AtomicString locale_; |
- unsigned item_index_; |
- unsigned offset_; |
- LayoutUnit position_; |
- WTF::Optional<NGLayoutOpportunity> opportunity_; |
+ unsigned item_index_ = 0; |
+ unsigned offset_ = 0; |
NGLogicalOffset content_offset_; |
LazyLineBreakIterator break_iterator_; |
HarfBuzzShaper shaper_; |
ShapeResultSpacing<String> spacing_; |
- bool auto_wrap_; |
- bool break_if_overflow_; |
+ // Keep track of handled float items. See HandleFloat(). |
+ unsigned handled_floats_end_item_index_ = 0; |
- // We don't create "certain zero-height line boxes". |
- // https://drafts.csswg.org/css2/visuren.html#phantom-line-box |
- // Such line boxes do not prevent two margins being "adjoining", and thus |
- // collapsing. |
- // https://drafts.csswg.org/css2/box.html#collapsing-margins |
- bool should_create_line_box_; |
+ // True when current box allows line wrapping. |
+ bool auto_wrap_ = false; |
- bool is_after_forced_break_; |
+ // True when current box has 'word-break/word-wrap: break-word'. |
+ bool break_if_overflow_ = false; |
}; |
} // namespace blink |