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

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

Issue 2745973002: [LayoutNG] Implement atomic inlines for LayoutNGInline (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_inline_node.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_inline_node.cc b/third_party/WebKit/Source/core/layout/ng/ng_inline_node.cc
index 6b896ddb19dd867b675242c3bcb8e8063a5bf2c1..03de34b2784c2a10d35f0202d695629ea1301ec8 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_inline_node.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_inline_node.cc
@@ -219,8 +219,11 @@ LayoutUnit NGLayoutInlineItem::InlineSize(unsigned start, unsigned end) const {
return LayoutUnit();
if (!style_ || !shape_result_) {
- // Bidi controls do not have widths.
- // TODO(kojii): Atomic inline not supported yet.
+ DCHECK(start == start_offset_ && end == end_offset_);
+ DCHECK(!IsAtomicInlineLevel()) << "Use NGLineBuilder::InlineSize";
+ DCHECK(!layout_object_ ||
+ layout_object_->isFloatingOrOutOfFlowPositioned());
+ // Bidi controls and out-of-flow objects do not have in-flow widths.
return LayoutUnit();
}
@@ -233,6 +236,22 @@ LayoutUnit NGLayoutInlineItem::InlineSize(unsigned start, unsigned end) const {
.width());
}
+RefPtr<NGLayoutResult> NGLayoutInlineItem::Layout(
+ const NGConstraintSpace& parent_space) const {
+ DCHECK(IsAtomicInlineLevel());
+
+ NGBlockNode* node = new NGBlockNode(layout_object_);
+ // TODO(kojii): Keep node in NGLayoutInlineItem.
+ const ComputedStyle& style = node->Style();
+ NGConstraintSpaceBuilder constraint_space_builder(&parent_space);
ikilpatrick 2017/03/16 16:15:40 we should do this in the parents call, ::Layout ta
kojii 2017/03/16 16:48:45 Moved this function to NGLineBuilder, please see t
+ RefPtr<NGConstraintSpace> constraint_space =
+ constraint_space_builder.SetIsNewFormattingContext(true)
+ .SetIsShrinkToFit(true)
+ .SetTextDirection(style.direction())
+ .ToConstraintSpace(FromPlatformWritingMode(style.getWritingMode()));
+ return node->Layout(constraint_space.get());
+}
+
void NGLayoutInlineItem::GetFallbackFonts(
HashSet<const SimpleFontData*>* fallback_fonts,
unsigned start,
@@ -250,7 +269,8 @@ void NGInlineNode::ShapeText() {
// Shape each item with the full context of the entire node.
HarfBuzzShaper shaper(text_content_.characters16(), text_content_.length());
for (auto& item : items_) {
- // Skip object replacement characters and bidi control characters.
+ // Skip non-text items; e.g., bidi controls, atomic inlines, out-of-flow
+ // objects.
if (!item.style_)
continue;
@@ -305,7 +325,7 @@ MinMaxContentSize NGInlineNode::ComputeMinMaxContentSize() {
// max-content is the width without any line wrapping.
// TODO(kojii): Implement hard breaks (<br> etc.) to break.
for (const auto& item : items_)
- sizes.max_content += item.InlineSize();
+ sizes.max_content += line_builder.InlineSize(item);
return sizes;
}

Powered by Google App Engine
This is Rietveld 408576698