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

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

Issue 2727263003: [LayoutNG] Fix orthogonal writing mode with abs/fixed descendants. (Closed)
Patch Set: fix comment. Created 3 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part.cc
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part.cc b/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part.cc
index e06e06de9819859f13a6f4859113e23dc659efa4..1aebb7508fa89294c21ef43d9f181cbe20e3aac9 100644
--- a/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part.cc
+++ b/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part.cc
@@ -105,10 +105,14 @@ RefPtr<NGLayoutResult> NGOutOfFlowLayoutPart::LayoutDescendant(
// relative to the container's padding box.
static_position.offset -= container_border_physical_offset_;
- RefPtr<NGLayoutResult> layout_result = nullptr;
+ // The inline and block estimates are in the descendant's writing mode.
Optional<MinAndMaxContentSizes> inline_estimate;
Optional<LayoutUnit> block_estimate;
+ RefPtr<NGLayoutResult> layout_result = nullptr;
+ NGWritingMode descendant_writing_mode(
+ FromPlatformWritingMode(descendant.Style().getWritingMode()));
+
if (AbsoluteNeedsChildInlineSize(descendant.Style())) {
inline_estimate = descendant.ComputeMinAndMaxContentSizes();
}
@@ -121,9 +125,8 @@ RefPtr<NGLayoutResult> NGOutOfFlowLayoutPart::LayoutDescendant(
if (AbsoluteNeedsChildBlockSize(descendant.Style())) {
layout_result = GenerateFragment(descendant, block_estimate, node_position);
- // TODO(ikilpatrick): the writing mode switching here looks wrong.
NGBoxFragment fragment(
- container_space_->WritingMode(),
+ descendant_writing_mode,
toNGPhysicalBoxFragment(layout_result->PhysicalFragment().get()));
block_estimate = fragment.BlockSize();
@@ -136,8 +139,7 @@ RefPtr<NGLayoutResult> NGOutOfFlowLayoutPart::LayoutDescendant(
// Skip this step if we produced a fragment when estimating the block size.
if (!layout_result) {
block_estimate =
- node_position.size.ConvertToLogical(container_space_->WritingMode())
- .block_size;
+ node_position.size.ConvertToLogical(descendant_writing_mode).block_size;
layout_result = GenerateFragment(descendant, block_estimate, node_position);
}
@@ -153,33 +155,39 @@ RefPtr<NGLayoutResult> NGOutOfFlowLayoutPart::LayoutDescendant(
return layout_result;
}
+// The fragment is generated in one of these two scenarios:
+// 1. To estimate descendant's block size, in this case block_size is
+// container's available size.
+// 2. To compute final fragment, when block size is known from the absolute
+// position calculation.
RefPtr<NGLayoutResult> NGOutOfFlowLayoutPart::GenerateFragment(
NGBlockNode& descendant,
const Optional<LayoutUnit>& block_estimate,
const NGAbsolutePhysicalPosition node_position) {
- // The fragment is generated in one of these two scenarios:
- // 1. To estimate descendant's block size, in this case block_size is
- // container's available size.
- // 2. To compute final fragment, when block size is known from the absolute
- // position calculation.
+ // As the block_estimate is always in the descendant's writing mode, we build
+ // the constraint space in the descendant's writing mode.
+ NGWritingMode writing_mode(
+ FromPlatformWritingMode(descendant.Style().getWritingMode()));
+ NGLogicalSize logical_available_size(
+ container_space_->AvailableSize()
+ .ConvertToPhysical(container_space_->WritingMode())
+ .ConvertToLogical(writing_mode));
+
LayoutUnit inline_size =
- node_position.size.ConvertToLogical(container_space_->WritingMode())
- .inline_size;
- LayoutUnit block_size = block_estimate
- ? *block_estimate
- : container_space_->AvailableSize().block_size;
+ node_position.size.ConvertToLogical(writing_mode).inline_size;
+ LayoutUnit block_size =
+ block_estimate ? *block_estimate : logical_available_size.block_size;
NGLogicalSize available_size{inline_size, block_size};
cbiesinger 2017/03/03 12:58:49 You have a variable logical_available_size and an
ikilpatrick 2017/03/03 17:27:06 Sent, thanks for picking up on this. :)
- NGConstraintSpaceBuilder builder(container_space_->WritingMode());
+ NGConstraintSpaceBuilder builder(writing_mode);
builder.SetAvailableSize(available_size);
- builder.SetPercentageResolutionSize(container_space_->AvailableSize());
+ builder.SetPercentageResolutionSize(logical_available_size);
if (block_estimate)
builder.SetIsFixedSizeBlock(true);
builder.SetIsFixedSizeInline(true);
builder.SetIsNewFormattingContext(true);
- RefPtr<NGConstraintSpace> space =
- builder.ToConstraintSpace(container_space_->WritingMode());
+ RefPtr<NGConstraintSpace> space = builder.ToConstraintSpace(writing_mode);
return descendant.Layout(space.get());
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698