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/NGBlockLayoutAlgorithm.h" | 5 #include "core/layout/ng/NGBlockLayoutAlgorithm.h" |
6 | 6 |
7 #include "core/layout/LayoutBox.h" | 7 #include "core/layout/LayoutBox.h" |
8 #include "core/layout/ng/NGConstraintSpace.h" | 8 #include "core/layout/ng/NGConstraintSpace.h" |
| 9 #include "core/layout/ng/NGFragment.h" |
9 #include "core/style/ComputedStyle.h" | 10 #include "core/style/ComputedStyle.h" |
| 11 #include "platform/LengthFunctions.h" |
10 | 12 |
11 namespace blink { | 13 namespace blink { |
12 | 14 |
13 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm() | 15 NGBlockLayoutAlgorithm::NGBlockLayoutAlgorithm(ComputedStyle* style) |
| 16 : m_style(style) |
14 { | 17 { |
15 } | 18 } |
16 | 19 |
| 20 NGFragment* NGBlockLayoutAlgorithm::layout( |
| 21 const NGConstraintSpace& constraintSpace) |
| 22 { |
| 23 LayoutUnit inlineSize = valueForLength(m_style->logicalWidth(), |
| 24 constraintSpace.inlineContainerSize()); |
| 25 LayoutUnit blockSize = valueForLength(m_style->logicalHeight(), |
| 26 constraintSpace.blockContainerSize()); |
| 27 return new NGFragment(inlineSize, blockSize); |
| 28 } |
| 29 |
17 NGConstraintSpace NGBlockLayoutAlgorithm::createConstraintSpaceFromLayoutObject(
const LayoutBox& child) | 30 NGConstraintSpace NGBlockLayoutAlgorithm::createConstraintSpaceFromLayoutObject(
const LayoutBox& child) |
18 { | 31 { |
19 bool fixedInline = false, fixedBlock = false; | 32 bool fixedInline = false, fixedBlock = false; |
20 // XXX for orthogonal writing mode this is not right | 33 // XXX for orthogonal writing mode this is not right |
21 LayoutUnit containerLogicalWidth = std::max(LayoutUnit(), child.containingBl
ockLogicalWidthForContent()); | 34 LayoutUnit containerLogicalWidth = std::max(LayoutUnit(), child.containingBl
ockLogicalWidthForContent()); |
22 // XXX Make sure this height is correct | 35 // XXX Make sure this height is correct |
23 LayoutUnit containerLogicalHeight = child.containingBlockLogicalHeightForCon
tent(ExcludeMarginBorderPadding); | 36 LayoutUnit containerLogicalHeight = child.containingBlockLogicalHeightForCon
tent(ExcludeMarginBorderPadding); |
24 if (child.hasOverrideLogicalContentWidth()) { | 37 if (child.hasOverrideLogicalContentWidth()) { |
25 containerLogicalWidth = child.overrideLogicalContentWidth(); | 38 containerLogicalWidth = child.overrideLogicalContentWidth(); |
26 fixedInline = true; | 39 fixedInline = true; |
27 } | 40 } |
28 if (child.hasOverrideLogicalContentHeight()) { | 41 if (child.hasOverrideLogicalContentHeight()) { |
29 containerLogicalWidth = child.overrideLogicalContentHeight(); | 42 containerLogicalWidth = child.overrideLogicalContentHeight(); |
30 fixedBlock = true; | 43 fixedBlock = true; |
31 } | 44 } |
32 NGConstraintSpace space(containerLogicalWidth, containerLogicalHeight); | 45 NGConstraintSpace space(containerLogicalWidth, containerLogicalHeight); |
33 // XXX vertical writing mode | 46 // XXX vertical writing mode |
34 space.setOverflowTriggersScrollbar(child.styleRef().overflowX() == OverflowA
uto, | 47 space.setOverflowTriggersScrollbar(child.styleRef().overflowX() == OverflowA
uto, |
35 child.styleRef().overflowY() == OverflowAuto); | 48 child.styleRef().overflowY() == OverflowAuto); |
36 space.setFixedSize(fixedInline, fixedBlock); | 49 space.setFixedSize(fixedInline, fixedBlock); |
37 return space; | 50 return space; |
38 } | 51 } |
39 | 52 |
40 } // namespace blink | 53 } // namespace blink |
OLD | NEW |