forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LayoutNG] Add the "simplified" layout pass.
This introduces the simplified layout algorithm. This is triggered when - An OOF descendant has its constraints changed. - The block-size of a fragment changes in size. There are several nuanced details with this algorithm. E.g. determining the correct static position for an OOF descendant. Bug: 635619 Change-Id: Iba4c4b82edf873fa4cad9ba28e9fa3849a4a8e8e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1590237 Commit-Queue: Ian Kilpatrick <ikilpatrick@chromium.org> Reviewed-by: Koji Ishii <kojii@chromium.org> Reviewed-by: Morten Stenshorne <mstensho@chromium.org> Cr-Commit-Position: refs/heads/master@{#659745}
- Loading branch information
Showing
38 changed files
with
1,239 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm_utils.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/renderer/core/layout/ng/ng_block_layout_algorithm_utils.h" | ||
|
||
#include "third_party/blink/renderer/core/layout/ng/exclusions/ng_exclusion_space.h" | ||
#include "third_party/blink/renderer/core/layout/ng/ng_length_utils.h" | ||
|
||
namespace blink { | ||
|
||
LayoutUnit CalculateOutOfFlowStaticInlineLevelOffset( | ||
const ComputedStyle& container_style, | ||
const NGBfcOffset& origin_bfc_offset, | ||
const NGExclusionSpace& exclusion_space, | ||
LayoutUnit child_available_inline_size) { | ||
const TextDirection direction = container_style.Direction(); | ||
|
||
// Find a layout opportunity, where we would have placed a zero-sized line. | ||
NGLayoutOpportunity opportunity = exclusion_space.FindLayoutOpportunity( | ||
origin_bfc_offset, child_available_inline_size, | ||
/* minimum_size */ LogicalSize()); | ||
|
||
LayoutUnit child_line_offset = IsLtr(direction) | ||
? opportunity.rect.LineStartOffset() | ||
: opportunity.rect.LineEndOffset(); | ||
|
||
LayoutUnit relative_line_offset = | ||
child_line_offset - origin_bfc_offset.line_offset; | ||
|
||
// Convert back to the logical coordinate system. As the conversion is on an | ||
// OOF-positioned node, we pretent it has zero inline-size. | ||
LayoutUnit inline_offset = | ||
IsLtr(direction) ? relative_line_offset | ||
: child_available_inline_size - relative_line_offset; | ||
|
||
// Adjust for text alignment, within the layout opportunity. | ||
LayoutUnit line_offset = LineOffsetForTextAlign( | ||
container_style.GetTextAlign(), direction, opportunity.rect.InlineSize()); | ||
|
||
if (IsLtr(direction)) | ||
inline_offset += line_offset; | ||
else | ||
inline_offset += opportunity.rect.InlineSize() - line_offset; | ||
|
||
return inline_offset; | ||
} | ||
|
||
} // namespace blink |
Oops, something went wrong.