Index: third_party/WebKit/Source/core/layout/ng/ng_absolute_utils.cc |
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_absolute_utils.cc b/third_party/WebKit/Source/core/layout/ng/ng_absolute_utils.cc |
index 3b5b8ab88fffe12ce4c175dc0a5c4e89b527026f..35bdbccda698338c5a759763de7fe8acbb66bd5e 100644 |
--- a/third_party/WebKit/Source/core/layout/ng/ng_absolute_utils.cc |
+++ b/third_party/WebKit/Source/core/layout/ng/ng_absolute_utils.cc |
@@ -117,12 +117,13 @@ void ComputeAbsoluteHorizontal( |
margin_right = margin_space - *margin_left; |
} else { |
// Are values overconstrained? |
- if (*margin_left + *margin_right != margin_space) { |
+ LayoutUnit margin_extra = margin_space - *margin_left - *margin_right; |
+ if (margin_extra) { |
// Relax the end. |
if (space.Direction() == TextDirection::kLtr) |
- right = *right - *margin_left + *margin_right - margin_space; |
+ right = *right + margin_extra; |
else |
- left = *left - *margin_left + *margin_right - margin_space; |
+ left = *left + margin_extra; |
} |
} |
} |
@@ -260,11 +261,9 @@ void ComputeAbsoluteVertical( |
} else if (!margin_bottom) { |
margin_bottom = margin_space - *margin_top; |
} else { |
- // Are values overconstrained? |
- if (*margin_top + *margin_bottom != margin_space) { |
- // Relax the end. |
- bottom = *bottom - *margin_top + *margin_bottom - margin_space; |
- } |
+ LayoutUnit margin_extra = margin_space - *margin_top - *margin_bottom; |
+ if (margin_extra) |
+ bottom = *bottom + margin_extra; |
} |
} |