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

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

Issue 2628583003: [ng_layout] Fix incorrect margin computation (Closed)
Patch Set: 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_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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Margins are negative. 105 // Margins are negative.
106 if (space.Direction() == TextDirection::kLtr) { 106 if (space.Direction() == TextDirection::kLtr) {
107 margin_left = LayoutUnit(); 107 margin_left = LayoutUnit();
108 margin_right = margin_space; 108 margin_right = margin_space;
109 } else { 109 } else {
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; 115 margin_left = margin_space - *margin_right;
116 } else if (!margin_right) { 116 } else if (!margin_right) {
117 margin_right = margin_space; 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 if (*margin_left + *margin_right != margin_space) {
121 // Relax the end. 121 // Relax the end.
122 if (space.Direction() == TextDirection::kLtr) 122 if (space.Direction() == TextDirection::kLtr)
123 right = *right - *margin_left + *margin_right - margin_space; 123 right = *right - *margin_left + *margin_right - margin_space;
124 else 124 else
125 left = *left - *margin_left + *margin_right - margin_space; 125 left = *left - *margin_left + *margin_right - margin_space;
126 } 126 }
127 } 127 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 if (!margin_top && !margin_bottom) { 249 if (!margin_top && !margin_bottom) {
250 if (margin_space > 0) { 250 if (margin_space > 0) {
251 margin_top = margin_space / 2; 251 margin_top = margin_space / 2;
252 margin_bottom = margin_space / 2; 252 margin_bottom = margin_space / 2;
253 } else { 253 } else {
254 // Margin space is over-constrained. 254 // Margin space is over-constrained.
255 margin_top = LayoutUnit(); 255 margin_top = LayoutUnit();
256 margin_bottom = margin_space; 256 margin_bottom = margin_space;
257 } 257 }
258 } else if (!margin_top) { 258 } else if (!margin_top) {
259 margin_top = margin_space; 259 margin_top = margin_space - *margin_bottom;
260 } else if (!margin_bottom) { 260 } else if (!margin_bottom) {
261 margin_bottom = margin_space; 261 margin_bottom = margin_space - *margin_top;
262 } else { 262 } else {
263 // Are values overconstrained? 263 // Are values overconstrained?
264 if (*margin_top + *margin_bottom != margin_space) { 264 if (*margin_top + *margin_bottom != margin_space) {
265 // Relax the end. 265 // Relax the end.
266 bottom = *bottom - *margin_top + *margin_bottom - margin_space; 266 bottom = *bottom - *margin_top + *margin_bottom - margin_space;
267 } 267 }
268 } 268 }
269 } 269 }
270 270
271 // Set unknown margins. 271 // Set unknown margins.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 if (style.isHorizontalWritingMode()) 369 if (style.isHorizontalWritingMode())
370 ComputeAbsoluteVertical(space, style, static_position, child_minmax, 370 ComputeAbsoluteVertical(space, style, static_position, child_minmax,
371 position); 371 position);
372 else { 372 else {
373 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax, 373 ComputeAbsoluteHorizontal(space, style, static_position, child_minmax,
374 position); 374 position);
375 } 375 }
376 } 376 }
377 377
378 } // namespace blink 378 } // 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