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

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

Issue 2746823003: Revert of Use Opportunity Iterator to position text fragments in NGLineBuilder (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/ng/ng_line_builder.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_line_builder.cc b/third_party/WebKit/Source/core/layout/ng/ng_line_builder.cc
index de7113fd50971d28ebed21987033cb45dae6a74a..40fcb427f5851961060478cd39480f445ed18596 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_line_builder.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_line_builder.cc
@@ -20,7 +20,7 @@
namespace blink {
NGLineBuilder::NGLineBuilder(NGInlineNode* inline_box,
- NGConstraintSpace* constraint_space)
+ const NGConstraintSpace* constraint_space)
: inline_box_(inline_box),
constraint_space_(constraint_space),
baseline_type_(constraint_space->WritingMode() ==
@@ -35,7 +35,7 @@
}
bool NGLineBuilder::CanFitOnLine() const {
- LayoutUnit available_size = current_opportunity_.InlineSize();
+ LayoutUnit available_size = constraint_space_->AvailableSize().inline_size;
if (available_size == NGSizeIndefinite)
return true;
return end_position_ <= available_size;
@@ -59,8 +59,6 @@
start_index_ = last_index_ = last_break_opportunity_index_ = index;
start_offset_ = end_offset_ = last_break_opportunity_offset_ = offset;
end_position_ = last_break_opportunity_position_ = LayoutUnit();
-
- FindNextLayoutOpportunity();
}
void NGLineBuilder::SetEnd(unsigned end_offset) {
@@ -148,8 +146,6 @@
#if DCHECK_IS_ON()
is_bidi_reordered_ = false;
#endif
-
- FindNextLayoutOpportunity();
}
void NGLineBuilder::BidiReorder(Vector<LineItemChunk, 32>* line_item_chunks) {
@@ -193,7 +189,7 @@
NGFragmentBuilder text_builder(NGPhysicalFragment::kFragmentText,
inline_box_);
- text_builder.SetWritingMode(ConstraintSpace().WritingMode());
+ text_builder.SetWritingMode(constraint_space_->WritingMode());
line_box_data_list_.grow(line_box_data_list_.size() + 1);
LineBoxData& line_box_data = line_box_data_list_.back();
@@ -242,12 +238,7 @@
line_item_chunk.index, line_item_chunk.start_offset,
line_item_chunk.end_offset);
fragments_.push_back(std::move(text_fragment));
-
- NGLogicalOffset logical_offset(
- line_box_data.inline_size + current_opportunity_.InlineStartOffset() -
- ConstraintSpace().BfcOffset().inline_offset,
- top);
- offsets_.push_back(logical_offset);
+ offsets_.push_back(NGLogicalOffset(line_box_data.inline_size, top));
line_box_data.inline_size += line_item_chunk.inline_size;
}
DCHECK_EQ(fragments_.size(), offsets_.size());
@@ -328,15 +319,6 @@
}
}
-void NGLineBuilder::FindNextLayoutOpportunity() {
- NGLogicalOffset iter_offset = constraint_space_->BfcOffset();
- iter_offset.block_offset += content_size_;
- auto* iter = constraint_space_->LayoutOpportunityIterator(iter_offset);
- NGLayoutOpportunity opportunity = iter->Next();
- if (!opportunity.IsEmpty())
- current_opportunity_ = opportunity;
-}
-
void NGLineBuilder::CreateFragments(NGFragmentBuilder* container_builder) {
DCHECK(!HasItems()) << "Must call CreateLine()";
DCHECK_EQ(fragments_.size(), offsets_.size());
@@ -348,6 +330,7 @@
}
// TODO(kojii): Check if the line box width should be content or available.
+ // TODO(kojii): Need to take constraint_space into account.
container_builder->SetInlineSize(max_inline_size_)
.SetInlineOverflow(max_inline_size_)
.SetBlockSize(content_size_)
@@ -404,7 +387,7 @@
BidiRun* run = bidi_runs.firstRun();
for (auto* physical_fragment : fragments_for_bidi_runs) {
DCHECK(run);
- NGTextFragment fragment(ConstraintSpace().WritingMode(),
+ NGTextFragment fragment(constraint_space_->WritingMode(),
toNGPhysicalTextFragment(physical_fragment));
InlineBox* inline_box = run->m_box;
inline_box->setLogicalWidth(fragment.InlineSize());
@@ -429,4 +412,5 @@
fragments_for_bidi_runs.clear();
}
}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698