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

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

Issue 2281153002: [layoutng] async layout part 1: Change the API to support async (Closed)
Patch Set: Created 4 years, 4 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
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 5e3fbe4ea3f4c0ceeab9f5c6990403c3fa625b02..05f612fe4ddd7d63d691f5fa132388e7ee929180 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
@@ -17,15 +17,15 @@ namespace blink {
NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(
PassRefPtr<const ComputedStyle> style,
NGBoxIterator box_iterator)
- : m_style(style), m_boxIterator(box_iterator) {}
+ : style_(style), box_iterator_(box_iterator) {}
-NGFragment* NGBlockLayoutAlgorithm::layout(
- const NGConstraintSpace* constraint_space) {
+bool NGBlockLayoutAlgorithm::Layout(const NGConstraintSpace* constraint_space,
+ NGFragment** out) {
LayoutUnit inline_size =
- computeInlineSizeForFragment(*constraint_space, *m_style);
+ computeInlineSizeForFragment(*constraint_space, *style_);
// TODO(layout-ng): For quirks mode, should we pass blockSize instead of -1?
LayoutUnit block_size =
- computeBlockSizeForFragment(*constraint_space, *m_style, LayoutUnit(-1));
+ computeBlockSizeForFragment(*constraint_space, *style_, LayoutUnit(-1));
NGConstraintSpace* constraint_space_for_children = new NGConstraintSpace(
*constraint_space, NGLogicalSize(inline_size, block_size));
@@ -33,10 +33,13 @@ NGFragment* NGBlockLayoutAlgorithm::layout(
builder.SetInlineSize(inline_size).SetBlockSize(block_size);
LayoutUnit content_size;
- for (NGBox box : m_boxIterator) {
+ for (NGBox box : box_iterator_) {
NGBoxStrut child_margins =
computeMargins(*constraint_space_for_children, *box.style());
- NGFragment* fragment = box.layout(constraint_space_for_children);
+ NGFragment* fragment;
+ // TODO(layout-ng): Actually make this async
+ while (!box.Layout(constraint_space_for_children, &fragment))
+ ;
// TODO(layout-ng): Support auto margins
fragment->SetOffset(child_margins.inline_start,
content_size + child_margins.block_start);
@@ -47,14 +50,15 @@ NGFragment* NGBlockLayoutAlgorithm::layout(
// Recompute the block-axis size now that we know our content size.
block_size =
- computeBlockSizeForFragment(*constraint_space, *m_style, content_size);
+ computeBlockSizeForFragment(*constraint_space, *style_, content_size);
// TODO(layout-ng): Compute correct inline overflow (block overflow should be
// correct)
builder.SetBlockSize(block_size)
.SetInlineOverflow(inline_size)
.SetBlockOverflow(content_size);
- return builder.ToFragment();
+ *out = builder.ToFragment();
+ return true;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698