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

Unified Diff: third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc

Issue 2954953002: [LayoutNG] Abort a layout once the BFC offset is resolved. (Closed)
Patch Set: rebase. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
index bcea6b98e0ee7bcc8ec904957b7be23045c477fd..855d747b3e31157f8e6551c24df71088c1eb60bf 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
@@ -56,13 +56,16 @@ std::pair<unsigned, LayoutUnit> ShapeLineMock(
} // namespace
-NGLineBreaker::NGLineBreaker(NGInlineNode node,
- NGConstraintSpace* space,
- NGFragmentBuilder* container_builder,
- const NGInlineBreakToken* break_token)
+NGLineBreaker::NGLineBreaker(
+ NGInlineNode node,
+ NGConstraintSpace* space,
+ NGFragmentBuilder* container_builder,
+ Vector<RefPtr<NGUnpositionedFloat>>* unpositioned_floats,
+ const NGInlineBreakToken* break_token)
: node_(node),
constraint_space_(space),
container_builder_(container_builder),
+ unpositioned_floats_(unpositioned_floats),
item_index_(0),
offset_(0),
break_iterator_(node.Text()),
@@ -436,17 +439,20 @@ void NGLineBreaker::HandleFloat(const NGInlineItem& item,
// I.e. we may not have come across any text yet, in order to be able to
// resolve the BFC position.
bool float_does_not_fit =
- !HasAvailableWidth() ||
- position_ + inline_size + margins.InlineSum() > AvailableWidth();
+ (!constraint_space_->FloatsBfcOffset() ||
+ container_builder_->BfcOffset()) &&
+ (!HasAvailableWidth() ||
+ position_ + inline_size + margins.InlineSum() > AvailableWidth());
// Check if we already have a pending float. That's because a float cannot be
// higher than any block or floated box generated before.
- if (!container_builder_->UnpositionedFloats().IsEmpty() ||
- float_does_not_fit) {
- container_builder_->AddUnpositionedFloat(unpositioned_float);
+ if (!unpositioned_floats_->IsEmpty() || float_does_not_fit) {
+ unpositioned_floats_->push_back(std::move(unpositioned_float));
} else {
NGLogicalOffset container_bfc_offset =
- container_builder_->BfcOffset().value();
+ container_builder_->BfcOffset()
+ ? container_builder_->BfcOffset().value()
+ : constraint_space_->FloatsBfcOffset().value();
LayoutUnit origin_block_offset =
container_bfc_offset.block_offset + content_offset_.block_offset;
@@ -456,7 +462,8 @@ void NGLineBreaker::HandleFloat(const NGInlineItem& item,
// We need to recalculate the available_width as the float probably
// consumed space on the line.
- UpdateAvailableWidth();
+ if (container_builder_->BfcOffset())
+ UpdateAvailableWidth();
}
// Floats are already positioned in the container_builder.

Powered by Google App Engine
This is Rietveld 408576698