OLD | NEW |
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_block_node.h" | 5 #include "core/layout/ng/ng_block_node.h" |
6 | 6 |
7 #include "core/layout/LayoutBlockFlow.h" | 7 #include "core/layout/LayoutBlockFlow.h" |
| 8 #include "core/layout/LayoutMultiColumnFlowThread.h" |
| 9 #include "core/layout/LayoutMultiColumnSet.h" |
8 #include "core/layout/api/LineLayoutAPIShim.h" | 10 #include "core/layout/api/LineLayoutAPIShim.h" |
9 #include "core/layout/line/InlineIterator.h" | 11 #include "core/layout/line/InlineIterator.h" |
10 #include "core/layout/ng/layout_ng_block_flow.h" | 12 #include "core/layout/ng/layout_ng_block_flow.h" |
11 #include "core/layout/ng/ng_block_break_token.h" | 13 #include "core/layout/ng/ng_block_break_token.h" |
12 #include "core/layout/ng/ng_block_layout_algorithm.h" | 14 #include "core/layout/ng/ng_block_layout_algorithm.h" |
13 #include "core/layout/ng/ng_box_fragment.h" | 15 #include "core/layout/ng/ng_box_fragment.h" |
14 #include "core/layout/ng/ng_column_layout_algorithm.h" | 16 #include "core/layout/ng/ng_column_layout_algorithm.h" |
15 #include "core/layout/ng/ng_constraint_space.h" | 17 #include "core/layout/ng/ng_constraint_space.h" |
16 #include "core/layout/ng/ng_constraint_space_builder.h" | 18 #include "core/layout/ng/ng_constraint_space_builder.h" |
17 #include "core/layout/ng/ng_fragment_builder.h" | 19 #include "core/layout/ng/ng_fragment_builder.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 FloatingObject* floating_object = | 78 FloatingObject* floating_object = |
77 toLayoutBlockFlow(parent)->insertFloatingObject(*layout_box); | 79 toLayoutBlockFlow(parent)->insertFloatingObject(*layout_box); |
78 floating_object->setIsInPlacedTree(false); | 80 floating_object->setIsInPlacedTree(false); |
79 floating_object->setX(ng_floating_object->left_offset); | 81 floating_object->setX(ng_floating_object->left_offset); |
80 floating_object->setY(box_fragment->TopOffset()); | 82 floating_object->setY(box_fragment->TopOffset()); |
81 floating_object->setIsPlaced(true); | 83 floating_object->setIsPlaced(true); |
82 floating_object->setIsInPlacedTree(true); | 84 floating_object->setIsInPlacedTree(true); |
83 } | 85 } |
84 } | 86 } |
85 | 87 |
| 88 void UpdateLegacyMultiColumnFlowThread(LayoutBox* layout_box, |
| 89 const NGPhysicalBoxFragment* fragment) { |
| 90 LayoutBlockFlow* multicol = toLayoutBlockFlow(layout_box); |
| 91 LayoutMultiColumnFlowThread* flow_thread = multicol->multiColumnFlowThread(); |
| 92 if (!flow_thread) |
| 93 return; |
| 94 if (LayoutMultiColumnSet* column_set = flow_thread->firstMultiColumnSet()) { |
| 95 column_set->setWidth(fragment->Width()); |
| 96 column_set->setHeight(fragment->Height()); |
| 97 |
| 98 // TODO(mstensho): This value has next to nothing to do with the flow thread |
| 99 // portion size, but at least it's usually better than zero. |
| 100 column_set->endFlow(fragment->Height()); |
| 101 |
| 102 column_set->clearNeedsLayout(); |
| 103 } |
| 104 // TODO(mstensho): Fix the relatively nonsensical values here (the content box |
| 105 // size of the multicol container has very little to do with the price of |
| 106 // eggs). |
| 107 flow_thread->setWidth(fragment->Width()); |
| 108 flow_thread->setHeight(fragment->Height()); |
| 109 |
| 110 flow_thread->validateColumnSets(); |
| 111 flow_thread->clearNeedsLayout(); |
| 112 } |
| 113 |
86 } // namespace | 114 } // namespace |
87 | 115 |
88 NGBlockNode::NGBlockNode(LayoutObject* layout_object) | 116 NGBlockNode::NGBlockNode(LayoutObject* layout_object) |
89 : NGLayoutInputNode(NGLayoutInputNodeType::kLegacyBlock), | 117 : NGLayoutInputNode(NGLayoutInputNodeType::kLegacyBlock), |
90 layout_box_(toLayoutBox(layout_object)) { | 118 layout_box_(toLayoutBox(layout_object)) { |
91 DCHECK(layout_box_); | 119 DCHECK(layout_box_); |
92 } | 120 } |
93 | 121 |
94 // Need an explicit destructor in the .cc file, or the MSWIN compiler will | 122 // Need an explicit destructor in the .cc file, or the MSWIN compiler will |
95 // produce an error when attempting to generate a default one, if the .h file is | 123 // produce an error when attempting to generate a default one, if the .h file is |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 | 259 |
232 return false; | 260 return false; |
233 } | 261 } |
234 | 262 |
235 void NGBlockNode::CopyFragmentDataToLayoutBox( | 263 void NGBlockNode::CopyFragmentDataToLayoutBox( |
236 const NGConstraintSpace& constraint_space, | 264 const NGConstraintSpace& constraint_space, |
237 NGLayoutResult* layout_result) { | 265 NGLayoutResult* layout_result) { |
238 NGPhysicalBoxFragment* fragment = | 266 NGPhysicalBoxFragment* fragment = |
239 toNGPhysicalBoxFragment(layout_result->PhysicalFragment().get()); | 267 toNGPhysicalBoxFragment(layout_result->PhysicalFragment().get()); |
240 | 268 |
| 269 if (layout_box_->style()->specifiesColumns()) |
| 270 UpdateLegacyMultiColumnFlowThread(layout_box_, fragment); |
241 layout_box_->setWidth(fragment->Width()); | 271 layout_box_->setWidth(fragment->Width()); |
242 layout_box_->setHeight(fragment->Height()); | 272 layout_box_->setHeight(fragment->Height()); |
243 NGBoxStrut border_and_padding = ComputeBorders(constraint_space, Style()) + | 273 NGBoxStrut border_and_padding = ComputeBorders(constraint_space, Style()) + |
244 ComputePadding(constraint_space, Style()); | 274 ComputePadding(constraint_space, Style()); |
245 LayoutUnit intrinsic_logical_height = | 275 LayoutUnit intrinsic_logical_height = |
246 layout_box_->style()->isHorizontalWritingMode() | 276 layout_box_->style()->isHorizontalWritingMode() |
247 ? fragment->HeightOverflow() | 277 ? fragment->HeightOverflow() |
248 : fragment->WidthOverflow(); | 278 : fragment->WidthOverflow(); |
249 intrinsic_logical_height -= border_and_padding.BlockSum(); | 279 intrinsic_logical_height -= border_and_padding.BlockSum(); |
250 layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height); | 280 layout_box_->setIntrinsicContentLogicalHeight(intrinsic_logical_height); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 369 |
340 // Save static position for legacy AbsPos layout. | 370 // Save static position for legacy AbsPos layout. |
341 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { | 371 void NGBlockNode::SaveStaticOffsetForLegacy(const NGLogicalOffset& offset) { |
342 DCHECK(layout_box_->isOutOfFlowPositioned()); | 372 DCHECK(layout_box_->isOutOfFlowPositioned()); |
343 DCHECK(layout_box_->layer()); | 373 DCHECK(layout_box_->layer()); |
344 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); | 374 layout_box_->layer()->setStaticBlockPosition(offset.block_offset); |
345 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); | 375 layout_box_->layer()->setStaticInlinePosition(offset.inline_offset); |
346 } | 376 } |
347 | 377 |
348 } // namespace blink | 378 } // namespace blink |
OLD | NEW |