Commit 5c16995c authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

Bug 1805392 - Fix outline-style: inherit behavior if you don't specify outline-width. r=Oriol

The fix is calling set_outline_style so that we also reset the actual
outline width. Also clean-up surrounding code a little bit to be
marginally more efficient, and do the same change for border-*-style
(which was doing the right thing, but it's better to make sure both stay
in sync).

Differential Revision: https://phabricator.services.mozilla.com/D164554
parent f213a8e9
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -678,8 +678,7 @@ fn static_assert() {
    }

    pub fn copy_border_${side.ident}_style_from(&mut self, other: &Self) {
        self.gecko.mBorderStyle[${side.index}] = other.gecko.mBorderStyle[${side.index}];
        self.gecko.mComputedBorder.${side.ident} = self.gecko.mBorder.${side.ident};
        self.set_border_${side.ident}_style(other.gecko.mBorderStyle[${side.index}]);
    }

    pub fn reset_border_${side.ident}_style(&mut self, other: &Self) {
@@ -809,9 +808,7 @@ fn static_assert() {
    }

    pub fn copy_outline_style_from(&mut self, other: &Self) {
        // FIXME(emilio): Why doesn't this need to reset mActualOutlineWidth?
        // Looks fishy.
        self.gecko.mOutlineStyle = other.gecko.mOutlineStyle;
        self.set_outline_style(other.gecko.mOutlineStyle);
    }

    pub fn reset_outline_style(&mut self, other: &Self) {
+9 −11
Original line number Diff line number Diff line
@@ -434,19 +434,17 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
        properties::adjust_border_width(self.style);
    }

    /// The initial value of outline-width may be changed at computed value time.
    /// outline-style: none causes a computed outline-width of zero at computed
    /// value time.
    fn adjust_for_outline(&mut self) {
        if self
            .style
            .get_outline()
            .clone_outline_style()
            .none_or_hidden() &&
            self.style.get_outline().outline_has_nonzero_width()
        {
            self.style
                .mutate_outline()
                .set_outline_width(crate::Zero::zero());
        let outline = self.style.get_outline();
        if !outline.clone_outline_style().none_or_hidden() {
            return;
        }
        if !outline.outline_has_nonzero_width() {
            return;
        }
        self.style.mutate_outline().set_outline_width(crate::Zero::zero());
    }

    /// CSS overflow-x and overflow-y require some fixup as well in some cases.
+7 −0
Original line number Diff line number Diff line
<!doctype html>
<meta charset="utf-8">
<title>CSS Test Reference</title>
<style>
  div { width: 100px; height: 100px }
</style>
<div style="outline-style: solid; outline-color: green"></div>
+14 −0
Original line number Diff line number Diff line
<!doctype html>
<meta charset="utf-8">
<title>Inheriting outline-style should compute the right outline-width</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<link rel="author" title="Mozilla" href="https://mozilla.org">
<link rel="help" href="https://drafts.csswg.org/css-ui-4/#outline-width">
<link rel="help" href="https://drafts.csswg.org/css-ui-4/#outline-style">
<link rel="match" href="outline-style-inherit-ref.html">
<style>
  div { width: 100px; height: 100px }
</style>
<div style="outline-style: solid; outline-color: transparent">
  <div style="outline-style: inherit; outline-color: green"></div>
</div>