Commit d8e4a2c8 authored by Manuel Rego Casasnovas's avatar Manuel Rego Casasnovas Committed by Commit Bot

Check MayHaveMargin() in BlockAlignment()

This patch avoids to check for "auto" margins
if MayHaveMargin() is true in BlockAlignment().

The patch also modifies the calls to SetMayHaveMargin()
so they are also called for "auto" margins.

BUG=1098231

Change-Id: I400c0c0b92f52ffbd4c0333a27e17e7083c4bae2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2489301Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Reviewed-by: default avatarIan Kilpatrick <ikilpatrick@chromium.org>
Commit-Queue: Manuel Rego <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#819955}
parent 593a7819
...@@ -25,12 +25,14 @@ enum class EBlockAlignment { kStart, kCenter, kEnd }; ...@@ -25,12 +25,14 @@ enum class EBlockAlignment { kStart, kCenter, kEnd };
inline EBlockAlignment BlockAlignment(const ComputedStyle& style, inline EBlockAlignment BlockAlignment(const ComputedStyle& style,
const ComputedStyle& container_style) { const ComputedStyle& container_style) {
bool start_auto = style.MarginStartUsing(container_style).IsAuto(); if (style.MayHaveMargin()) {
bool end_auto = style.MarginEndUsing(container_style).IsAuto(); bool start_auto = style.MarginStartUsing(container_style).IsAuto();
if (start_auto || end_auto) { bool end_auto = style.MarginEndUsing(container_style).IsAuto();
if (start_auto) if (start_auto || end_auto) {
return end_auto ? EBlockAlignment::kCenter : EBlockAlignment::kEnd; if (start_auto)
return EBlockAlignment::kStart; return end_auto ? EBlockAlignment::kCenter : EBlockAlignment::kEnd;
return EBlockAlignment::kStart;
}
} }
// If none of the inline margins are auto, look for -webkit- text-align // If none of the inline margins are auto, look for -webkit- text-align
......
...@@ -1514,28 +1514,28 @@ class ComputedStyle : public ComputedStyleBase, ...@@ -1514,28 +1514,28 @@ class ComputedStyle : public ComputedStyleBase,
// Margin utility functions. // Margin utility functions.
void SetMarginTop(const Length& v) { void SetMarginTop(const Length& v) {
if (MarginTop() != v) { if (MarginTop() != v) {
if (!v.IsZero()) if (!v.IsZero() || v.IsAuto())
SetMayHaveMargin(); SetMayHaveMargin();
MutableMarginTopInternal() = v; MutableMarginTopInternal() = v;
} }
} }
void SetMarginRight(const Length& v) { void SetMarginRight(const Length& v) {
if (MarginRight() != v) { if (MarginRight() != v) {
if (!v.IsZero()) if (!v.IsZero() || v.IsAuto())
SetMayHaveMargin(); SetMayHaveMargin();
MutableMarginRightInternal() = v; MutableMarginRightInternal() = v;
} }
} }
void SetMarginBottom(const Length& v) { void SetMarginBottom(const Length& v) {
if (MarginBottom() != v) { if (MarginBottom() != v) {
if (!v.IsZero()) if (!v.IsZero() || v.IsAuto())
SetMayHaveMargin(); SetMayHaveMargin();
MutableMarginBottomInternal() = v; MutableMarginBottomInternal() = v;
} }
} }
void SetMarginLeft(const Length& v) { void SetMarginLeft(const Length& v) {
if (MarginLeft() != v) { if (MarginLeft() != v) {
if (!v.IsZero()) if (!v.IsZero() || v.IsAuto())
SetMayHaveMargin(); SetMayHaveMargin();
MutableMarginLeftInternal() = v; MutableMarginLeftInternal() = v;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment