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

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

Issue 2887623002: [LayoutNG] Place InlineFlowBox from NGFragment tree (Closed)
Patch Set: Rebase Created 3 years, 7 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_inline_node.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
index f690f02b41d38792f9e11f5741cf8badb5c16430..5a220c2e9a7a94f5d356d5ff27137fa647beb3d9 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node.cc
@@ -30,6 +30,34 @@
namespace blink {
+namespace {
+
+// Set the geometry to InlineFlowBox by computing the union of children.
+void PlaceInlineFlowBoxes(InlineFlowBox* flow_box) {
+ LayoutUnit logical_left = LayoutUnit::Max();
+ LayoutUnit logical_right = LayoutUnit::Min();
+ LayoutUnit logical_top = LayoutUnit::Max();
+ for (InlineBox* curr = flow_box->FirstChild(); curr;
+ curr = curr->NextOnLine()) {
+ if (curr->GetLineLayoutItem().IsLayoutInline()) {
+ InlineFlowBox* flow = ToInlineFlowBox(curr);
+ PlaceInlineFlowBoxes(flow);
+ }
+ logical_left = std::min(curr->LogicalLeft(), logical_left);
+ logical_right = std::max(curr->LogicalRight(), logical_right);
+ logical_top = std::min(curr->LogicalTop(), logical_top);
+ }
+ if (logical_left == LayoutUnit::Max())
+ return;
+ logical_left -= flow_box->MarginBorderPaddingLogicalLeft();
+ logical_right += flow_box->MarginBorderPaddingLogicalRight();
+ flow_box->SetLogicalLeft(logical_left);
+ flow_box->SetLogicalWidth(logical_right - logical_left);
+ flow_box->SetLogicalTop(logical_top);
+}
+
+} // namespace
+
NGInlineNode::NGInlineNode(LayoutObject* start_inline, LayoutNGBlockFlow* block)
: NGLayoutInputNode(NGLayoutInputNodeType::kLegacyInline),
start_inline_(start_inline),
@@ -357,6 +385,10 @@ void NGInlineNode::CopyFragmentDataToLayoutBox(
}
DCHECK(!run);
+ // InlineTextBox and InlineBox are placed, but when ConstructLine() created
+ // InlineFlowBox, they needed to be placed as well.
+ PlaceInlineFlowBoxes(root_line_box);
+
// Copy to RootInlineBox.
NGLineBoxFragment line_box(constraint_space.WritingMode(),
physical_line_box);

Powered by Google App Engine
This is Rietveld 408576698