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

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

Issue 2616093004: [ng_layout] Fix wrong percent_resolution_size (Closed)
Patch Set: Better fix Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // XXX for orthogonal writing mode this is not right 45 // XXX for orthogonal writing mode this is not right
46 LayoutUnit available_logical_width = 46 LayoutUnit available_logical_width =
47 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent()); 47 std::max(LayoutUnit(), box.containingBlockLogicalWidthForContent());
48 LayoutUnit available_logical_height; 48 LayoutUnit available_logical_height;
49 if (!box.parent()) { 49 if (!box.parent()) {
50 available_logical_height = box.view()->viewLogicalHeightForPercentages(); 50 available_logical_height = box.view()->viewLogicalHeightForPercentages();
51 } else if (box.containingBlock()) { 51 } else if (box.containingBlock()) {
52 available_logical_height = 52 available_logical_height =
53 box.containingBlock()->availableLogicalHeightForPercentageComputation(); 53 box.containingBlock()->availableLogicalHeightForPercentageComputation();
54 } 54 }
55 NGLogicalSize percentage_size = {available_logical_width,
56 available_logical_height};
cbiesinger 2017/01/10 19:45:03 While you're touching this, I'd also make this oth
atotic 2017/01/10 21:53:20 done
55 // When we have an override size, the available_logical_{width,height} will be 57 // When we have an override size, the available_logical_{width,height} will be
56 // used as the final size of the box, so it has to include border and 58 // used as the final size of the box, so it has to include border and
57 // padding. 59 // padding.
58 if (box.hasOverrideLogicalContentWidth()) { 60 if (box.hasOverrideLogicalContentWidth()) {
59 available_logical_width = 61 available_logical_width =
60 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth(); 62 box.borderAndPaddingLogicalWidth() + box.overrideLogicalContentWidth();
61 fixed_inline = true; 63 fixed_inline = true;
62 } 64 }
63 if (box.hasOverrideLogicalContentHeight()) { 65 if (box.hasOverrideLogicalContentHeight()) {
64 available_logical_height = box.borderAndPaddingLogicalHeight() + 66 available_logical_height = box.borderAndPaddingLogicalHeight() +
65 box.overrideLogicalContentHeight(); 67 box.overrideLogicalContentHeight();
66 fixed_block = true; 68 fixed_block = true;
67 } 69 }
68 70
69 bool is_new_fc = 71 bool is_new_fc =
70 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext(); 72 box.isLayoutBlock() && toLayoutBlock(box).createsNewFormattingContext();
71 73
72 NGLogicalSize size = {available_logical_width, available_logical_height}; 74 NGLogicalSize size = {available_logical_width, available_logical_height};
73 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode()); 75 auto writing_mode = FromPlatformWritingMode(box.styleRef().getWritingMode());
74 return NGConstraintSpaceBuilder(writing_mode) 76 return NGConstraintSpaceBuilder(writing_mode)
75 .SetAvailableSize(size) 77 .SetAvailableSize(size)
76 .SetPercentageResolutionSize(size) 78 .SetPercentageResolutionSize(percentage_size)
77 .SetIsInlineDirectionTriggersScrollbar( 79 .SetIsInlineDirectionTriggersScrollbar(
78 box.styleRef().overflowInlineDirection() == EOverflow::Auto) 80 box.styleRef().overflowInlineDirection() == EOverflow::Auto)
79 .SetIsBlockDirectionTriggersScrollbar( 81 .SetIsBlockDirectionTriggersScrollbar(
80 box.styleRef().overflowBlockDirection() == EOverflow::Auto) 82 box.styleRef().overflowBlockDirection() == EOverflow::Auto)
81 .SetIsFixedSizeInline(fixed_inline) 83 .SetIsFixedSizeInline(fixed_inline)
82 .SetIsFixedSizeBlock(fixed_block) 84 .SetIsFixedSizeBlock(fixed_block)
83 .SetIsShrinkToFit( 85 .SetIsShrinkToFit(
84 box.sizesLogicalWidthToFitContent(box.styleRef().logicalWidth())) 86 box.sizesLogicalWidthToFitContent(box.styleRef().logicalWidth()))
85 .SetIsNewFormattingContext(is_new_fc) 87 .SetIsNewFormattingContext(is_new_fc)
86 .SetTextDirection(box.styleRef().direction()) 88 .SetTextDirection(box.styleRef().direction())
(...skipping 21 matching lines...) Expand all
108 110
109 String NGConstraintSpace::ToString() const { 111 String NGConstraintSpace::ToString() const {
110 return String::format("%s,%s %sx%s", 112 return String::format("%s,%s %sx%s",
111 offset_.inline_offset.toString().ascii().data(), 113 offset_.inline_offset.toString().ascii().data(),
112 offset_.block_offset.toString().ascii().data(), 114 offset_.block_offset.toString().ascii().data(),
113 AvailableSize().inline_size.toString().ascii().data(), 115 AvailableSize().inline_size.toString().ascii().data(),
114 AvailableSize().block_size.toString().ascii().data()); 116 AvailableSize().block_size.toString().ascii().data());
115 } 117 }
116 118
117 } // namespace blink 119 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698