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

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

Issue 2691093004: Fix orthogonal mode legacy mismatch (Closed)
Patch Set: CR fixes, removed odd IsParallelWritingMode Created 3 years, 10 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_constraint_space.h" 5 #include "core/layout/ng/ng_constraint_space.h"
6 6
7 #include "core/layout/LayoutBlock.h" 7 #include "core/layout/LayoutBlock.h"
8 #include "core/layout/LayoutView.h" 8 #include "core/layout/LayoutView.h"
9 #include "core/layout/ng/ng_constraint_space_builder.h" 9 #include "core/layout/ng/ng_constraint_space_builder.h"
10 #include "core/layout/ng/ng_layout_opportunity_iterator.h" 10 #include "core/layout/ng/ng_layout_opportunity_iterator.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 block_direction_fragmentation_type_(block_direction_fragmentation_type), 42 block_direction_fragmentation_type_(block_direction_fragmentation_type),
43 is_new_fc_(is_new_fc), 43 is_new_fc_(is_new_fc),
44 writing_mode_(writing_mode), 44 writing_mode_(writing_mode),
45 direction_(static_cast<unsigned>(direction)), 45 direction_(static_cast<unsigned>(direction)),
46 margin_strut_(margin_strut), 46 margin_strut_(margin_strut),
47 bfc_offset_(bfc_offset), 47 bfc_offset_(bfc_offset),
48 exclusions_(exclusions) {} 48 exclusions_(exclusions) {}
49 49
50 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject( 50 NGConstraintSpace* NGConstraintSpace::CreateFromLayoutObject(
51 const LayoutBox& box) { 51 const LayoutBox& box) {
52 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode());
53 bool parallel_containing_block = IsParallelWritingMode(
54 FromPlatformWritingMode(
55 box.containingBlock()->styleRef().getWritingMode()),
56 writing_mode);
52 bool fixed_inline = false, fixed_block = false; 57 bool fixed_inline = false, fixed_block = false;
53 // XXX for orthogonal writing mode this is not right 58
54 LayoutUnit available_logical_width = 59 LayoutUnit available_logical_width;
55 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); 60 if (parallel_containing_block)
61 available_logical_width = box.containingBlockLogicalWidthForContent();
62 else
63 available_logical_width = box.perpendicularContainingBlockLogicalHeight();
64 available_logical_width = std::max(LayoutUnit(), available_logical_width);
65
56 LayoutUnit available_logical_height; 66 LayoutUnit available_logical_height;
57 if (!box.parent()) { 67 if (!box.parent()) {
58 available_logical_height = box.view()->viewLogicalHeightForPercentages(); 68 available_logical_height = box.view()->viewLogicalHeightForPercentages();
59 } else if (box.containingBlock()) { 69 } else if (box.containingBlock()) {
60 available_logical_height = 70 if (parallel_containing_block) {
61 box.containingBlock()->availableLogicalHeightForPercentageComputation(); 71 available_logical_height =
72 box.containingBlock()
73 ->availableLogicalHeightForPercentageComputation();
74 } else {
75 available_logical_height = box.containingBlockLogicalWidthForContent();
76 }
62 } 77 }
63 NGLogicalSize percentage_size = {available_logical_width, 78 NGLogicalSize percentage_size = {available_logical_width,
64 available_logical_height}; 79 available_logical_height};
65 NGLogicalSize available_size = percentage_size; 80 NGLogicalSize available_size = percentage_size;
66 // When we have an override size, the available_logical_{width,height} will be 81 // When we have an override size, the available_logical_{width,height} will be
67 // used as the final size of the box, so it has to include border and 82 // used as the final size of the box, so it has to include border and
68 // padding. 83 // padding.
69 if (box.hasOverrideLogicalContentWidth()) { 84 if (box.hasOverrideLogicalContentWidth()) {
70 available_size.inline_size = 85 available_size.inline_size =
71 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth(); 86 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth();
72 fixed_inline = true; 87 fixed_inline = true;
73 } 88 }
74 if (box.hasOverrideLogicalContentHeight()) { 89 if (box.hasOverrideLogicalContentHeight()) {
75 available_size.block_size = box.borderAndPaddingLogicalHeight() + 90 available_size.block_size = box.borderAndPaddingLogicalHeight() +
76 box.overrideLogicalContentHeight(); 91 box.overrideLogicalContentHeight();
77 fixed_block = true; 92 fixed_block = true;
78 } 93 }
79 94
80 bool is_new_fc = 95 bool is_new_fc =
81 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext(); 96 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext();
82 97
83 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode());
84
85 FloatSize icb_float_size = box.view()->viewportSizeForViewportUnits(); 98 FloatSize icb_float_size = box.view()->viewportSizeForViewportUnits();
86 NGPhysicalSize initial_containing_block_size{ 99 NGPhysicalSize initial_containing_block_size{
87 LayoutUnit(icb_float_size.width()), LayoutUnit(icb_float_size.height())}; 100 LayoutUnit(icb_float_size.width()), LayoutUnit(icb_float_size.height())};
88 101
89 return NGConstraintSpaceBuilder(writing_mode) 102 return NGConstraintSpaceBuilder(writing_mode)
90 .SetAvailableSize(available_size) 103 .SetAvailableSize(available_size)
91 .SetPercentageResolutionSize(percentage_size) 104 .SetPercentageResolutionSize(percentage_size)
92 .SetInitialContainingBlockSize(initial_containing_block_size) 105 .SetInitialContainingBlockSize(initial_containing_block_size)
93 .SetIsInlineDirectionTriggersScrollbar( 106 .SetIsInlineDirectionTriggersScrollbar(
94 box.styleRef().overflowInlineDirection() == EOverflow::kAuto) 107 box.styleRef().overflowInlineDirection() == EOverflow::kAuto)
(...skipping 23 matching lines...) Expand all
118 String NGConstraintSpace::ToString() const { 131 String NGConstraintSpace::ToString() const {
119 return String::format("Offset: %s,%s Size: %sx%s MarginStrut: %s", 132 return String::format("Offset: %s,%s Size: %sx%s MarginStrut: %s",
120 bfc_offset_.inline_offset.toString().ascii().data(), 133 bfc_offset_.inline_offset.toString().ascii().data(),
121 bfc_offset_.block_offset.toString().ascii().data(), 134 bfc_offset_.block_offset.toString().ascii().data(),
122 AvailableSize().inline_size.toString().ascii().data(), 135 AvailableSize().inline_size.toString().ascii().data(),
123 AvailableSize().block_size.toString().ascii().data(), 136 AvailableSize().block_size.toString().ascii().data(),
124 margin_strut_.ToString().ascii().data()); 137 margin_strut_.ToString().ascii().data());
125 } 138 }
126 139
127 } // namespace blink 140 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698