|
|
Created:
3 years, 9 months ago by ikilpatrick Modified:
3 years, 9 months ago Reviewers:
Gleb Lanbin CC:
chromium-reviews, cbiesinger, ojan+watch_chromium.org, szager+layoutwatch_chromium.org, glebl+reviews_chromium.org, dgrogan+ng_chromium.org, atotic+reviews_chromium.org, blink-reviews-layout_chromium.org, pdr+renderingwatchlist_chromium.org, eae+blinkwatch, leviw+renderwatch, zoltan1, jchaffraix+rendering, blink-reviews Target Ref:
refs/heads/master Project:
chromium Visibility:
Public. |
Description[LayoutNG] Split apart CreateConstraintSpaceForChild.
Introduces PrepareChildLayout which takes now does all of the pre-layout
margin calculation, margin-collapsing, etc.
Going to try and follow up with a patch which bundles margin,
bfc_offset, etc, together instead of using the class curr_*_ variables.
BUG=635619
Review-Url: https://codereview.chromium.org/2754303003
Cr-Commit-Position: refs/heads/master@{#457953}
Committed: https://chromium.googlesource.com/chromium/src/+/fb239514f323bd9999a3e13fb5d8e3a27eddabd8
Patch Set 1 #
Total comments: 8
Patch Set 2 : address comments. #Patch Set 3 : rebase? #
Messages
Total messages: 27 (16 generated)
The CQ bit was checked by ikilpatrick@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
ikilpatrick@chromium.org changed reviewers: + glebl@chromium.org
I'm not hugely attached to this patch, so if you don't like it feel free to push back.
On 2017/03/17 18:58:49, ikilpatrick wrote: > I'm not hugely attached to this patch, so if you don't like it feel free to push > back. (was just a good initial first step in cleaning this up a little).
On 2017/03/17 18:58:49, ikilpatrick wrote: > I'm not hugely attached to this patch, so if you don't like it feel free to push > back. (was just a good initial first step in cleaning this up a little).
lgtm feel free to ignore comments and submit this patch. I can fix them later by myself. https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc (right): https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:524: void NGBlockLayoutAlgorithm::PrepareChildLayout(NGLayoutInputNode* child) { optional 1) change ComputeMinMaxContentSize to be a const method 2) pass a const pointer to this function. https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:556: curr_margin_strut_ = NGMarginStrut(); optional curr_margin_strut_ = {}; https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:750: space_builder_.SetClearanceOffset(clearance_offset); optional just space_builder_.SetClearanceOffset( GetClearanceOffset(constraint_space_->Exclusions(), child_style)); instead of if (child_style.clear() != EClear::kNone) { ... https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:752: // Floats margins are not included in child's space because: .nit Float's margins ?
https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... File third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc (right): https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:524: void NGBlockLayoutAlgorithm::PrepareChildLayout(NGLayoutInputNode* child) { On 2017/03/17 19:31:18, Gleb Lanbin wrote: > optional > 1) change ComputeMinMaxContentSize to be a const method > 2) pass a const pointer to this function. Ack. Yeah didn't to this - larger changes :(. https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:556: curr_margin_strut_ = NGMarginStrut(); On 2017/03/17 19:31:18, Gleb Lanbin wrote: > optional > curr_margin_strut_ = {}; Done. https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:750: space_builder_.SetClearanceOffset(clearance_offset); On 2017/03/17 19:31:18, Gleb Lanbin wrote: > optional > > just > > space_builder_.SetClearanceOffset( > GetClearanceOffset(constraint_space_->Exclusions(), child_style)); > > instead of > if (child_style.clear() != EClear::kNone) { > ... > Done. https://codereview.chromium.org/2754303003/diff/1/third_party/WebKit/Source/c... third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:752: // Floats margins are not included in child's space because: On 2017/03/17 19:31:18, Gleb Lanbin wrote: > .nit Float's margins ? Done.
The CQ bit was checked by ikilpatrick@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from glebl@chromium.org Link to the patchset: https://codereview.chromium.org/2754303003/#ps20001 (title: "address comments.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by ikilpatrick@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Failed to apply patch for third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc: While running git apply --index -p1; error: patch failed: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc:456 error: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc: patch does not apply Patch: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc Index: third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc index a7b476f4d0a6aefdc1590f2e55431bb444b59835..ac98df7c4584f9087295cafedb9f6db4efbe9ea9 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_layout_algorithm.cc @@ -456,6 +456,7 @@ RefPtr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() { } } + PrepareChildLayout(child); RefPtr<NGConstraintSpace> child_space = CreateConstraintSpaceForChild(child); @@ -520,6 +521,63 @@ RefPtr<NGLayoutResult> NGBlockLayoutAlgorithm::Layout() { return builder_.ToBoxFragment(); } +void NGBlockLayoutAlgorithm::PrepareChildLayout(NGLayoutInputNode* child) { + DCHECK(child); + + // Margins collapsing: + // - An inline node doesn't have any margins to collapse with, so always + // can determine its position in space. + if (child->Type() == NGLayoutInputNode::kLegacyInline) { + curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); + UpdateFragmentBfcOffset(curr_bfc_offset_); + PositionPendingFloats(curr_bfc_offset_.block_offset, + MutableConstraintSpace(), &builder_); + curr_margin_strut_ = {}; + curr_child_margins_ = {}; + return; + } + + NGBlockNode* block_child = toNGBlockNode(child); + const ComputedStyle& child_style = block_child->Style(); + + // Calculate margins in parent's writing mode. + curr_child_margins_ = CalculateMargins( + block_child, *space_builder_.ToConstraintSpace( + FromPlatformWritingMode(Style().getWritingMode()))); + + // Clearance: + // - *Always* collapse margins and update *container*'s BFC offset. + // - Position all pending floats since the fragment's BFC offset is known. + if (child_style.clear() != EClear::kNone) { + curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); + UpdateFragmentBfcOffset(curr_bfc_offset_); + // Only collapse margins if it's an adjoining block with clearance. + if (!content_size_) { + curr_margin_strut_ = {}; + curr_child_margins_.block_start = LayoutUnit(); + } + PositionPendingFloats(curr_bfc_offset_.block_offset, + MutableConstraintSpace(), &builder_); + } + + // Set estimated BFC offset to the next child's constraint space. + curr_bfc_offset_ = builder_.BfcOffset() ? builder_.BfcOffset().value() + : ConstraintSpace().BfcOffset(); + curr_bfc_offset_.block_offset += content_size_; + curr_bfc_offset_.inline_offset += border_and_padding_.inline_start; + + // Floats margins are not included in child's space because: + // 1) Floats do not participate in margins collapsing. + // 2) Floats margins are used separately to calculate floating exclusions. + if (!child_style.isFloating()) { + curr_bfc_offset_.inline_offset += curr_child_margins_.inline_start; + // Append the current margin strut with child's block start margin. + // Non empty border/padding use cases are handled inside of the child's + // layout. + curr_margin_strut_.Append(curr_child_margins_.block_start); + } +} + void NGBlockLayoutAlgorithm::FinishChildLayout( NGLayoutInputNode* child, NGConstraintSpace* child_space, @@ -670,71 +728,27 @@ RefPtr<NGConstraintSpace> NGBlockLayoutAlgorithm::CreateConstraintSpaceForChild( if (child->Type() == NGLayoutInputNode::kLegacyInline) { // TODO(kojii): Setup space_builder_ appropriately for inline child. - - // Margins collapsing: Inline block. - curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); - UpdateFragmentBfcOffset(curr_bfc_offset_); - PositionPendingFloats(curr_bfc_offset_.block_offset, - MutableConstraintSpace(), &builder_); - curr_margin_strut_ = {}; space_builder_.SetBfcOffset(curr_bfc_offset_); - return space_builder_.ToConstraintSpace( FromPlatformWritingMode(Style().getWritingMode())); } - NGBlockNode* block_child = toNGBlockNode(child); - const ComputedStyle& child_style = block_child->Style(); - - // Calculate margins in parent's writing mode. - curr_child_margins_ = CalculateMargins( - block_child, *space_builder_.ToConstraintSpace( - FromPlatformWritingMode(Style().getWritingMode()))); + const ComputedStyle& child_style = toNGBlockNode(child)->Style(); bool is_new_bfc = IsNewFormattingContextForInFlowBlockLevelChild( ConstraintSpace(), child_style); space_builder_.SetIsNewFormattingContext(is_new_bfc) + .SetBfcOffset(curr_bfc_offset_) + .SetClearanceOffset( + GetClearanceOffset(constraint_space_->Exclusions(), child_style)) .SetIsShrinkToFit(ShouldShrinkToFit(ConstraintSpace(), child_style)) .SetTextDirection(child_style.direction()); - // Clearance : - // - *Always* collapse margins and update *container*'s BFC offset. - // - Position all pending floats since the fragment's BFC offset is known. - // - Set the clearance offset on the constraint space's builder. - if (child_style.clear() != EClear::kNone) { - curr_bfc_offset_.block_offset += curr_margin_strut_.Sum(); - UpdateFragmentBfcOffset(curr_bfc_offset_); - // Only collapse margins if it's an adjoining block with clearance. - if (!content_size_) { - curr_margin_strut_ = NGMarginStrut(); - curr_child_margins_.block_start = LayoutUnit(); - } - PositionPendingFloats(curr_bfc_offset_.block_offset, - MutableConstraintSpace(), &builder_); - WTF::Optional<LayoutUnit> clearance_offset = - GetClearanceOffset(constraint_space_->Exclusions(), child_style); - space_builder_.SetClearanceOffset(clearance_offset); - } - - // Set estimated BFC offset to the next child's constraint space. - curr_bfc_offset_ = builder_.BfcOffset() ? builder_.BfcOffset().value() - : ConstraintSpace().BfcOffset(); - curr_bfc_offset_.block_offset += content_size_; - curr_bfc_offset_.inline_offset += border_and_padding_.inline_start; - - // Floats margins are not included in child's CS because - // 1) Floats do not participate in margins collapsing + // Float's margins are not included in child's space because: + // 1) Floats do not participate in margins collapsing. // 2) Floats margins are used separately to calculate floating exclusions. - if (!child_style.isFloating()) { - curr_bfc_offset_.inline_offset += curr_child_margins_.inline_start; - // Append the current margin strut with child's block start margin. - // Non empty border/padding use cases are handled inside of the child's - // layout. - curr_margin_strut_.Append(curr_child_margins_.block_start); - space_builder_.SetMarginStrut(curr_margin_strut_); - } - - space_builder_.SetBfcOffset(curr_bfc_offset_); + space_builder_.SetMarginStrut(child_style.isFloating() ? NGMarginStrut() + : curr_margin_strut_); LayoutUnit space_available; if (constraint_space_->HasBlockFragmentation()) {
The CQ bit was checked by ikilpatrick@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by ikilpatrick@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from glebl@chromium.org Link to the patchset: https://codereview.chromium.org/2754303003/#ps40001 (title: "rebase?")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
CQ is committing da patch. Bot data: {"patchset_id": 40001, "attempt_start_ts": 1489809200944600, "parent_rev": "6719c20584c6c916a4f5820a0f3b458ab612dfad", "commit_rev": "fb239514f323bd9999a3e13fb5d8e3a27eddabd8"}
Message was sent while issue was closed.
Description was changed from ========== [LayoutNG] Split apart CreateConstraintSpaceForChild. Introduces PrepareChildLayout which takes now does all of the pre-layout margin calculation, margin-collapsing, etc. Going to try and follow up with a patch which bundles margin, bfc_offset, etc, together instead of using the class curr_*_ variables. BUG=635619 ========== to ========== [LayoutNG] Split apart CreateConstraintSpaceForChild. Introduces PrepareChildLayout which takes now does all of the pre-layout margin calculation, margin-collapsing, etc. Going to try and follow up with a patch which bundles margin, bfc_offset, etc, together instead of using the class curr_*_ variables. BUG=635619 Review-Url: https://codereview.chromium.org/2754303003 Cr-Commit-Position: refs/heads/master@{#457953} Committed: https://chromium.googlesource.com/chromium/src/+/fb239514f323bd9999a3e13fb5d8... ==========
Message was sent while issue was closed.
Committed patchset #3 (id:40001) as https://chromium.googlesource.com/chromium/src/+/fb239514f323bd9999a3e13fb5d8... |