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_absolute_utils.h" | 5 #include "core/layout/ng/ng_absolute_utils.h" |
6 | 6 |
7 #include "core/layout/ng/ng_constraint_space.h" | 7 #include "core/layout/ng/ng_constraint_space.h" |
8 #include "core/layout/ng/ng_length_utils.h" | 8 #include "core/layout/ng/ng_length_utils.h" |
9 #include "core/style/ComputedStyle.h" | 9 #include "core/style/ComputedStyle.h" |
10 #include "platform/LengthFunctions.h" | 10 #include "platform/LengthFunctions.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 margin_right = LayoutUnit(); | 110 margin_right = LayoutUnit(); |
111 margin_left = margin_space; | 111 margin_left = margin_space; |
112 } | 112 } |
113 } | 113 } |
114 } else if (!margin_left) { | 114 } else if (!margin_left) { |
115 margin_left = margin_space - *margin_right; | 115 margin_left = margin_space - *margin_right; |
116 } else if (!margin_right) { | 116 } else if (!margin_right) { |
117 margin_right = margin_space - *margin_left; | 117 margin_right = margin_space - *margin_left; |
118 } else { | 118 } else { |
119 // Are values overconstrained? | 119 // Are values overconstrained? |
120 if (*margin_left + *margin_right != margin_space) { | 120 LayoutUnit margin_extra = margin_space - *margin_left - *margin_right; |
| 121 if (margin_extra) { |
121 // Relax the end. | 122 // Relax the end. |
122 if (space.Direction() == TextDirection::kLtr) | 123 if (space.Direction() == TextDirection::kLtr) |
123 right = *right - *margin_left + *margin_right - margin_space; | 124 right = *right + margin_extra; |
124 else | 125 else |
125 left = *left - *margin_left + *margin_right - margin_space; | 126 left = *left + margin_extra; |
126 } | 127 } |
127 } | 128 } |
128 } | 129 } |
129 | 130 |
130 // Set unknown margins. | 131 // Set unknown margins. |
131 if (!margin_left) | 132 if (!margin_left) |
132 margin_left = LayoutUnit(); | 133 margin_left = LayoutUnit(); |
133 if (!margin_right) | 134 if (!margin_right) |
134 margin_right = LayoutUnit(); | 135 margin_right = LayoutUnit(); |
135 | 136 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } else { | 254 } else { |
254 // Margin space is over-constrained. | 255 // Margin space is over-constrained. |
255 margin_top = LayoutUnit(); | 256 margin_top = LayoutUnit(); |
256 margin_bottom = margin_space; | 257 margin_bottom = margin_space; |
257 } | 258 } |
258 } else if (!margin_top) { | 259 } else if (!margin_top) { |
259 margin_top = margin_space - *margin_bottom; | 260 margin_top = margin_space - *margin_bottom; |
260 } else if (!margin_bottom) { | 261 } else if (!margin_bottom) { |
261 margin_bottom = margin_space - *margin_top; | 262 margin_bottom = margin_space - *margin_top; |
262 } else { | 263 } else { |
263 // Are values overconstrained? | 264 LayoutUnit margin_extra = margin_space - *margin_top - *margin_bottom; |
264 if (*margin_top + *margin_bottom != margin_space) { | 265 if (margin_extra) |
265 // Relax the end. | 266 bottom = *bottom + margin_extra; |
266 bottom = *bottom - *margin_top + *margin_bottom - margin_space; | |
267 } | |
268 } | 267 } |
269 } | 268 } |
270 | 269 |
271 // Set unknown margins. | 270 // Set unknown margins. |
272 if (!margin_top) | 271 if (!margin_top) |
273 margin_top = LayoutUnit(); | 272 margin_top = LayoutUnit(); |
274 if (!margin_bottom) | 273 if (!margin_bottom) |
275 margin_bottom = LayoutUnit(); | 274 margin_bottom = LayoutUnit(); |
276 | 275 |
277 // Rules 1 through 3, 2 out of 3 are unknown, fix 1. | 276 // Rules 1 through 3, 2 out of 3 are unknown, fix 1. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 if (style.isHorizontalWritingMode()) | 368 if (style.isHorizontalWritingMode()) |
370 ComputeAbsoluteVertical(space, style, static_position, child_minmax, | 369 ComputeAbsoluteVertical(space, style, static_position, child_minmax, |
371 position); | 370 position); |
372 else { | 371 else { |
373 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax, | 372 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax, |
374 position); | 373 position); |
375 } | 374 } |
376 } | 375 } |
377 | 376 |
378 } // namespace blink | 377 } // namespace blink |
OLD | NEW |