From cd50d30c31f24452c7edcda53c0d906e910c0a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 13 Dec 2022 12:29:37 +0000 Subject: [PATCH] style: Fix outline-style: inherit behavior if you don't specify outline-width 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 --- components/style/properties/gecko.mako.rs | 7 ++----- components/style/style_adjuster.rs | 20 +++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index ac1a5dc581f..93efb36f1d6 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -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) { diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs index 9c5977dea1c..b4416abe179 100644 --- a/components/style/style_adjuster.rs +++ b/components/style/style_adjuster.rs @@ -435,19 +435,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.