Commit b04cbc16 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[NGFragmentItem] Support list markers

This patch supports adding list markers to |NGFragmentItems|.

List markers are not part of the line box it belongs to in
the |NGPhysicalFragment| tree.

In |NGFragmentItem| world, it is an |NGFragmentItem| in the
inline formatting context in most cases.

When a list marker is attached to a block boxes, there is no
change; i.e., it still appears in the |NGPhysicalFragment|
tree. e.g.,
  <li><div>text</div></li>
then the list marker is propagated to a block formatting
context.

Some tests should turn to pass, but since bots are not setup
yet, I'll update FlagExpectation later.

Bug: 982194
Change-Id: I6af233360d1872de3e9507d69ef3c50275689267
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1846627Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706385}
parent 9293d5c8
...@@ -118,6 +118,13 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) { ...@@ -118,6 +118,13 @@ void NGFragmentItemsBuilder::AddItems(Child* child_begin, Child* child_end) {
} }
} }
void NGFragmentItemsBuilder::AddListMarker(
const NGPhysicalBoxFragment& marker_fragment,
const LogicalOffset& offset) {
items_.push_back(std::make_unique<NGFragmentItem>(marker_fragment, 1));
offsets_.push_back(offset);
}
// Convert internal logical offsets to physical. Items are kept with logical // Convert internal logical offsets to physical. Items are kept with logical
// offset until outer box size is determined. // offset until outer box size is determined.
void NGFragmentItemsBuilder::ConvertToPhysical(WritingMode writing_mode, void NGFragmentItemsBuilder::ConvertToPhysical(WritingMode writing_mode,
......
...@@ -49,6 +49,10 @@ class CORE_EXPORT NGFragmentItemsBuilder { ...@@ -49,6 +49,10 @@ class CORE_EXPORT NGFragmentItemsBuilder {
void AddLine(const NGPhysicalLineBoxFragment& line, void AddLine(const NGPhysicalLineBoxFragment& line,
const LogicalOffset& offset); const LogicalOffset& offset);
// Add a list marker to the current line.
void AddListMarker(const NGPhysicalBoxFragment& marker_fragment,
const LogicalOffset& offset);
// Build a |NGFragmentItems|. The builder cannot build twice because data set // Build a |NGFragmentItems|. The builder cannot build twice because data set
// to this builder may be cleared. // to this builder may be cleared.
void ToFragmentItems(WritingMode writing_mode, void ToFragmentItems(WritingMode writing_mode,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/core/layout/ng/list/ng_unpositioned_list_marker.h" #include "third_party/blink/renderer/core/layout/ng/list/ng_unpositioned_list_marker.h"
#include "third_party/blink/renderer/core/layout/layout_list_marker.h" #include "third_party/blink/renderer/core/layout/layout_list_marker.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_fragment_items_builder.h"
#include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_physical_line_box_fragment.h"
#include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_marker.h" #include "third_party/blink/renderer/core/layout/ng/list/layout_ng_list_marker.h"
#include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h" #include "third_party/blink/renderer/core/layout/ng/ng_box_fragment.h"
...@@ -124,6 +125,11 @@ void NGUnpositionedListMarker::AddToBox( ...@@ -124,6 +125,11 @@ void NGUnpositionedListMarker::AddToBox(
marker_offset.block_offset); marker_offset.block_offset);
DCHECK(container_builder); DCHECK(container_builder);
if (NGFragmentItemsBuilder* items_builder =
container_builder->ItemsBuilder()) {
items_builder->AddListMarker(marker_physical_fragment, marker_offset);
return;
}
container_builder->AddChild(marker_physical_fragment, marker_offset); container_builder->AddChild(marker_physical_fragment, marker_offset);
} }
...@@ -142,6 +148,7 @@ LayoutUnit NGUnpositionedListMarker::AddToBoxWithoutLineBoxes( ...@@ -142,6 +148,7 @@ LayoutUnit NGUnpositionedListMarker::AddToBoxWithoutLineBoxes(
LogicalOffset offset(InlineOffset(marker_size.inline_size), LayoutUnit()); LogicalOffset offset(InlineOffset(marker_size.inline_size), LayoutUnit());
DCHECK(container_builder); DCHECK(container_builder);
DCHECK(!container_builder->ItemsBuilder());
container_builder->AddChild(marker_physical_fragment, offset); container_builder->AddChild(marker_physical_fragment, offset);
return marker_size.block_size; return marker_size.block_size;
......
...@@ -201,6 +201,18 @@ void NGBoxFragmentBuilder::PropagateBreak( ...@@ -201,6 +201,18 @@ void NGBoxFragmentBuilder::PropagateBreak(
scoped_refptr<const NGLayoutResult> NGBoxFragmentBuilder::ToBoxFragment( scoped_refptr<const NGLayoutResult> NGBoxFragmentBuilder::ToBoxFragment(
WritingMode block_or_line_writing_mode) { WritingMode block_or_line_writing_mode) {
#if DCHECK_IS_ON()
if (ItemsBuilder()) {
for (const ChildWithOffset& child : Children()) {
DCHECK(child.fragment);
const NGPhysicalFragment& fragment = *child.fragment;
DCHECK(fragment.IsLineBox() ||
// TODO(kojii): How to place floats and OOF is TBD.
fragment.IsFloatingOrOutOfFlowPositioned());
}
}
#endif
if (UNLIKELY(node_ && has_block_fragmentation_)) { if (UNLIKELY(node_ && has_block_fragmentation_)) {
if (!inline_break_tokens_.IsEmpty()) { if (!inline_break_tokens_.IsEmpty()) {
if (auto token = inline_break_tokens_.back()) { if (auto token = inline_break_tokens_.back()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment