Commit a3c5b1f4 authored by Ian Kilpatrick's avatar Ian Kilpatrick Committed by Commit Bot

[css-layout-api] Fix data passing between parent<->child layouts.

This was broken in:
https://chromium-review.googlesource.com/c/chromium/src/+/1745396

This adds this functionality back in, and performs the data passing
via the constraint-space, and layout-result (as opposed to setting this
information explicitly on the layout-object classes.

Bug: 993306
Change-Id: I5083ad782227657a19301cf61b2867be603f521a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757739Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688167}
parent 12505057
...@@ -91,10 +91,9 @@ bool CSSLayoutDefinition::Instance::Layout( ...@@ -91,10 +91,9 @@ bool CSSLayoutDefinition::Instance::Layout(
// TODO(ikilpatrick): Fill in layout edges. // TODO(ikilpatrick): Fill in layout edges.
ScriptValue edges(script_state, v8::Undefined(isolate)); ScriptValue edges(script_state, v8::Undefined(isolate));
// TODO(crbug.com/992950): Pass constraint data through a constraint space.
CustomLayoutConstraints* constraints = CustomLayoutConstraints* constraints =
MakeGarbageCollected<CustomLayoutConstraints>( MakeGarbageCollected<CustomLayoutConstraints>(
border_box_size, nullptr /* constraint_data */, isolate); border_box_size, space.CustomLayoutData(), isolate);
// TODO(ikilpatrick): Instead of creating a new style_map each time here, // TODO(ikilpatrick): Instead of creating a new style_map each time here,
// store on LayoutCustom, and update when the style changes. // store on LayoutCustom, and update when the style changes.
...@@ -129,12 +128,12 @@ bool CSSLayoutDefinition::Instance::Layout( ...@@ -129,12 +128,12 @@ bool CSSLayoutDefinition::Instance::Layout(
// Run the work queue until exhaustion. // Run the work queue until exhaustion.
while (!custom_layout_scope->Queue()->IsEmpty()) { while (!custom_layout_scope->Queue()->IsEmpty()) {
for (auto& task : *custom_layout_scope->Queue())
task.Run(space, node.Style());
custom_layout_scope->Queue()->clear();
{ {
v8::MicrotasksScope microtasks_scope(isolate, microtask_queue, v8::MicrotasksScope microtasks_scope(isolate, microtask_queue,
v8::MicrotasksScope::kRunMicrotasks); v8::MicrotasksScope::kRunMicrotasks);
for (auto& task : *custom_layout_scope->Queue())
task.Run(space, node.Style());
custom_layout_scope->Queue()->clear();
} }
} }
......
...@@ -21,7 +21,10 @@ CustomLayoutFragment::CustomLayoutFragment( ...@@ -21,7 +21,10 @@ CustomLayoutFragment::CustomLayoutFragment(
layout_result_(std::move(layout_result)), layout_result_(std::move(layout_result)),
inline_size_(size.inline_size.ToDouble()), inline_size_(size.inline_size.ToDouble()),
block_size_(size.block_size.ToDouble()) { block_size_(size.block_size.ToDouble()) {
// TODO(crbug.com/992950): Pass constraint data through layout result. // Immediately store the result data, so that it remains immutable between
// layout calls to the child.
if (SerializedScriptValue* data = layout_result_->CustomLayoutData())
layout_worklet_world_v8_data_.Set(isolate, data->Deserialize(isolate));
} }
const NGLayoutResult& CustomLayoutFragment::GetLayoutResult() const { const NGLayoutResult& CustomLayoutFragment::GetLayoutResult() const {
......
...@@ -97,6 +97,8 @@ void CustomLayoutWorkTask::Run(const NGConstraintSpace& parent_space, ...@@ -97,6 +97,8 @@ void CustomLayoutWorkTask::Run(const NGConstraintSpace& parent_space,
builder.SetIsShrinkToFit(node.Style().LogicalWidth().IsAuto()); builder.SetIsShrinkToFit(node.Style().LogicalWidth().IsAuto());
builder.SetIsFixedInlineSize(is_fixed_inline_size); builder.SetIsFixedInlineSize(is_fixed_inline_size);
builder.SetIsFixedBlockSize(is_fixed_block_size); builder.SetIsFixedBlockSize(is_fixed_block_size);
if (node.IsLayoutNGCustom())
builder.SetCustomLayoutData(std::move(constraint_data_));
auto space = builder.ToConstraintSpace(); auto space = builder.ToConstraintSpace();
auto result = To<NGBlockNode>(node).Layout(space, nullptr /* break_token */); auto result = To<NGBlockNode>(node).Layout(space, nullptr /* break_token */);
......
...@@ -122,6 +122,7 @@ scoped_refptr<const NGLayoutResult> NGCustomLayoutAlgorithm::Layout() { ...@@ -122,6 +122,7 @@ scoped_refptr<const NGLayoutResult> NGCustomLayoutAlgorithm::Layout() {
LayoutUnit block_size = ComputeBlockSizeForFragment( LayoutUnit block_size = ComputeBlockSizeForFragment(
ConstraintSpace(), Style(), border_padding_, auto_block_size); ConstraintSpace(), Style(), border_padding_, auto_block_size);
container_builder_.SetCustomLayoutData(std::move(fragment_result_data));
container_builder_.SetIntrinsicBlockSize(auto_block_size); container_builder_.SetIntrinsicBlockSize(auto_block_size);
container_builder_.SetBlockSize(block_size); container_builder_.SetBlockSize(block_size);
......
...@@ -189,6 +189,11 @@ class CORE_EXPORT NGBoxFragmentBuilder final ...@@ -189,6 +189,11 @@ class CORE_EXPORT NGBoxFragmentBuilder final
// Either this function or SetBoxType must be called before ToBoxFragment(). // Either this function or SetBoxType must be called before ToBoxFragment().
void SetIsNewFormattingContext(bool is_new_fc) { is_new_fc_ = is_new_fc; } void SetIsNewFormattingContext(bool is_new_fc) { is_new_fc_ = is_new_fc; }
void SetCustomLayoutData(
scoped_refptr<SerializedScriptValue> custom_layout_data) {
custom_layout_data_ = std::move(custom_layout_data);
}
// Layout algorithms should call this function for each baseline request in // Layout algorithms should call this function for each baseline request in
// the constraint space. // the constraint space.
// //
...@@ -260,6 +265,8 @@ class CORE_EXPORT NGBoxFragmentBuilder final ...@@ -260,6 +265,8 @@ class CORE_EXPORT NGBoxFragmentBuilder final
NGBorderEdges border_edges_; NGBorderEdges border_edges_;
scoped_refptr<SerializedScriptValue> custom_layout_data_;
friend class NGPhysicalBoxFragment; friend class NGPhysicalBoxFragment;
friend class NGLayoutResult; friend class NGLayoutResult;
}; };
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define NGConstraintSpace_h #define NGConstraintSpace_h
#include "base/optional.h" #include "base/optional.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/geometry/logical_size.h" #include "third_party/blink/renderer/core/layout/geometry/logical_size.h"
#include "third_party/blink/renderer/core/layout/geometry/physical_size.h" #include "third_party/blink/renderer/core/layout/geometry/physical_size.h"
...@@ -421,6 +422,10 @@ class CORE_EXPORT NGConstraintSpace final { ...@@ -421,6 +422,10 @@ class CORE_EXPORT NGConstraintSpace final {
OptimisticBfcBlockOffset().value_or(BfcOffset().block_offset)); OptimisticBfcBlockOffset().value_or(BfcOffset().block_offset));
} }
SerializedScriptValue* CustomLayoutData() const {
return HasRareData() ? rare_data_->custom_layout_data.get() : nullptr;
}
// Returns the types of preceding adjoining objects. // Returns the types of preceding adjoining objects.
// See |NGAdjoiningObjectTypes|. // See |NGAdjoiningObjectTypes|.
// //
...@@ -564,6 +569,8 @@ class CORE_EXPORT NGConstraintSpace final { ...@@ -564,6 +569,8 @@ class CORE_EXPORT NGConstraintSpace final {
NGBoxStrut table_cell_borders; NGBoxStrut table_cell_borders;
NGBoxStrut table_cell_intrinsic_padding; NGBoxStrut table_cell_intrinsic_padding;
scoped_refptr<SerializedScriptValue> custom_layout_data;
LayoutUnit fragmentainer_block_size = kIndefiniteSize; LayoutUnit fragmentainer_block_size = kIndefiniteSize;
LayoutUnit fragmentainer_space_at_bfc_start = kIndefiniteSize; LayoutUnit fragmentainer_space_at_bfc_start = kIndefiniteSize;
......
...@@ -284,6 +284,18 @@ class CORE_EXPORT NGConstraintSpaceBuilder final { ...@@ -284,6 +284,18 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
space_.exclusion_space_ = exclusion_space; space_.exclusion_space_ = exclusion_space;
} }
void SetCustomLayoutData(
scoped_refptr<SerializedScriptValue> custom_layout_data) {
#if DCHECK_IS_ON()
DCHECK(!is_custom_layout_data_set_);
is_custom_layout_data_set_ = true;
#endif
if (custom_layout_data) {
space_.EnsureRareData()->custom_layout_data =
std::move(custom_layout_data);
}
}
void AddBaselineRequests(const NGBaselineRequestList requests) { void AddBaselineRequests(const NGBaselineRequestList requests) {
DCHECK(baseline_requests_.IsEmpty()); DCHECK(baseline_requests_.IsEmpty());
baseline_requests_.AppendVector(requests); baseline_requests_.AppendVector(requests);
...@@ -337,6 +349,7 @@ class CORE_EXPORT NGConstraintSpaceBuilder final { ...@@ -337,6 +349,7 @@ class CORE_EXPORT NGConstraintSpaceBuilder final {
bool is_clearance_offset_set_ = false; bool is_clearance_offset_set_ = false;
bool is_table_cell_borders_set_ = false; bool is_table_cell_borders_set_ = false;
bool is_table_cell_intrinsic_padding_set_ = false; bool is_table_cell_intrinsic_padding_set_ = false;
bool is_custom_layout_data_set_ = false;
bool to_constraint_space_called_ = false; bool to_constraint_space_called_ = false;
#endif #endif
......
...@@ -82,6 +82,9 @@ class CORE_EXPORT NGLayoutInputNode { ...@@ -82,6 +82,9 @@ class CORE_EXPORT NGLayoutInputNode {
bool IsBlock() const { return type_ == kBlock; } bool IsBlock() const { return type_ == kBlock; }
bool IsBlockFlow() const { return IsBlock() && box_->IsLayoutBlockFlow(); } bool IsBlockFlow() const { return IsBlock() && box_->IsLayoutBlockFlow(); }
bool IsLayoutNGCustom() const {
return IsBlock() && box_->IsLayoutNGCustom();
}
bool IsColumnSpanAll() const { return IsBlock() && box_->IsColumnSpanAll(); } bool IsColumnSpanAll() const { return IsBlock() && box_->IsColumnSpanAll(); }
bool IsFloating() const { return IsBlock() && box_->IsFloating(); } bool IsFloating() const { return IsBlock() && box_->IsFloating(); }
bool IsOutOfFlowPositioned() const { bool IsOutOfFlowPositioned() const {
......
...@@ -45,6 +45,10 @@ NGLayoutResult::NGLayoutResult( ...@@ -45,6 +45,10 @@ NGLayoutResult::NGLayoutResult(
intrinsic_block_size_ = builder->intrinsic_block_size_; intrinsic_block_size_ = builder->intrinsic_block_size_;
if (builder->minimal_space_shortage_ != LayoutUnit::Max()) if (builder->minimal_space_shortage_ != LayoutUnit::Max())
EnsureRareData()->minimal_space_shortage = builder->minimal_space_shortage_; EnsureRareData()->minimal_space_shortage = builder->minimal_space_shortage_;
if (builder->custom_layout_data_) {
EnsureRareData()->custom_layout_data =
std::move(builder->custom_layout_data_);
}
bitfields_.initial_break_before = bitfields_.initial_break_before =
static_cast<unsigned>(builder->initial_break_before_); static_cast<unsigned>(builder->initial_break_before_);
bitfields_.final_break_after = bitfields_.final_break_after =
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define NGLayoutResult_h #define NGLayoutResult_h
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/layout/ng/exclusions/ng_exclusion_space.h" #include "third_party/blink/renderer/core/layout/ng/exclusions/ng_exclusion_space.h"
#include "third_party/blink/renderer/core/layout/ng/geometry/ng_bfc_offset.h" #include "third_party/blink/renderer/core/layout/ng/geometry/ng_bfc_offset.h"
...@@ -122,6 +123,10 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> { ...@@ -122,6 +123,10 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> {
: LayoutUnit::Max(); : LayoutUnit::Max();
} }
SerializedScriptValue* CustomLayoutData() const {
return HasRareData() ? rare_data_->custom_layout_data.get() : nullptr;
}
// The break-before value on the first child needs to be propagated to the // The break-before value on the first child needs to be propagated to the
// container, in search of a valid class A break point. // container, in search of a valid class A break point.
EBreakBetween InitialBreakBefore() const { EBreakBetween InitialBreakBefore() const {
...@@ -280,6 +285,7 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> { ...@@ -280,6 +285,7 @@ class CORE_EXPORT NGLayoutResult : public RefCounted<NGLayoutResult> {
NGUnpositionedListMarker unpositioned_list_marker; NGUnpositionedListMarker unpositioned_list_marker;
LayoutUnit minimal_space_shortage = LayoutUnit::Max(); LayoutUnit minimal_space_shortage = LayoutUnit::Max();
NGExclusionSpace exclusion_space; NGExclusionSpace exclusion_space;
scoped_refptr<SerializedScriptValue> custom_layout_data;
}; };
bool HasRareData() const { return bitfields_.has_rare_data; } bool HasRareData() const { return bitfields_.has_rare_data; }
......
...@@ -336,10 +336,6 @@ crbug.com/922249 virtual/android/fullscreen/compositor-touch-hit-rects-fullscree ...@@ -336,10 +336,6 @@ crbug.com/922249 virtual/android/fullscreen/compositor-touch-hit-rects-fullscree
# ====== Layout team owned tests from here ====== # ====== Layout team owned tests from here ======
crbug.com/992950 external/wpt/css/css-layout-api/constraints-data.https.html [ Failure ]
crbug.com/992950 external/wpt/css/css-layout-api/fragment-data-immutable.https.html [ Failure ]
crbug.com/992950 external/wpt/css/css-layout-api/fragment-data.https.html [ Failure ]
crbug.com/711704 external/wpt/css/CSS2/floats/floats-rule3-outside-left-002.xht [ Failure ] crbug.com/711704 external/wpt/css/CSS2/floats/floats-rule3-outside-left-002.xht [ Failure ]
crbug.com/711704 external/wpt/css/CSS2/floats/floats-rule3-outside-right-002.xht [ Failure ] crbug.com/711704 external/wpt/css/CSS2/floats/floats-rule3-outside-right-002.xht [ Failure ]
crbug.com/711704 external/wpt/css/CSS2/floats/floats-rule7-outside-left-001.xht [ Failure ] crbug.com/711704 external/wpt/css/CSS2/floats/floats-rule7-outside-left-001.xht [ Failure ]
......
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