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

Side by Side Diff: third_party/WebKit/Source/core/layout/ng/ng_fragment_builder.cc

Issue 2282213002: [LayoutNG] Introduce NGPhysicalFragment and make NGFragment a 'view' (Closed)
Patch Set: address comments. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/ng/ng_fragment_builder.h" 5 #include "core/layout/ng/ng_fragment_builder.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 NGFragmentBuilder::NGFragmentBuilder(NGFragmentBase::NGFragmentType type) 9 NGFragmentBuilder::NGFragmentBuilder(
10 NGPhysicalFragmentBase::NGFragmentType type)
10 : type_(type), 11 : type_(type),
11 writing_mode_(HorizontalTopBottom), 12 writing_mode_(HorizontalTopBottom),
12 direction_(LeftToRight) {} 13 direction_(LeftToRight) {}
13 14
14 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode( 15 NGFragmentBuilder& NGFragmentBuilder::SetWritingMode(
15 NGWritingMode writing_mode) { 16 NGWritingMode writing_mode) {
16 writing_mode_ = writing_mode; 17 writing_mode_ = writing_mode;
17 return *this; 18 return *this;
18 } 19 }
19 20
(...skipping 15 matching lines...) Expand all
35 NGFragmentBuilder& NGFragmentBuilder::SetInlineOverflow(LayoutUnit size) { 36 NGFragmentBuilder& NGFragmentBuilder::SetInlineOverflow(LayoutUnit size) {
36 overflow_.inline_size = size; 37 overflow_.inline_size = size;
37 return *this; 38 return *this;
38 } 39 }
39 40
40 NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) { 41 NGFragmentBuilder& NGFragmentBuilder::SetBlockOverflow(LayoutUnit size) {
41 overflow_.block_size = size; 42 overflow_.block_size = size;
42 return *this; 43 return *this;
43 } 44 }
44 45
45 NGFragmentBuilder& NGFragmentBuilder::AddChild(const NGFragment* child) { 46 NGFragmentBuilder& NGFragmentBuilder::AddChild(NGFragment* child,
46 DCHECK_EQ(type_, NGFragmentBase::FragmentBox) 47 NGLogicalOffset offset) {
48 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox)
47 << "Only box fragments can have children"; 49 << "Only box fragments can have children";
48 children_.append(child); 50 children_.append(child->PhysicalFragment());
51 offsets_.append(offset);
49 return *this; 52 return *this;
50 } 53 }
51 54
52 NGFragment* NGFragmentBuilder::ToFragment() { 55 NGPhysicalFragment* NGFragmentBuilder::ToFragment() {
53 // TODO(layout-ng): Support text fragments 56 // TODO(layout-ng): Support text fragments
54 DCHECK_EQ(type_, NGFragmentBase::FragmentBox); 57 DCHECK_EQ(type_, NGPhysicalFragmentBase::FragmentBox);
55 NGFragment* fragment = 58 DCHECK_EQ(offsets_.size(), children_.size());
56 new NGFragment(size_, overflow_, writing_mode_, direction_, children_); 59
57 return fragment; 60 NGPhysicalSize physical_size = size_.ConvertToPhysical(writing_mode_);
61 HeapVector<Member<const NGPhysicalFragmentBase>> children(children_.size());
62
63 for (size_t i = 0; i < children_.size(); ++i) {
64 NGPhysicalFragmentBase* child = children_[i].get();
65 child->SetOffset(offsets_[i].ConvertToPhysical(
66 writing_mode_, direction_, physical_size, child->Size()));
67 children.append(child);
68 }
69
70 return new NGPhysicalFragment(
71 physical_size, overflow_.ConvertToPhysical(writing_mode_), children);
58 } 72 }
59 73
60 } // namespace blink 74 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698