diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-10-13 16:44:51 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2017-10-14 11:31:01 +0200 |
commit | 6d694a4bcd97e8602e39c576452604796c17d269 (patch) | |
tree | b90eae4d931889a234c03e77d30089dc0c32129d | |
parent | 25c303ee627774ee8cb0b0acfe06f6802daf17c2 (diff) | |
download | servo-6d694a4bcd97e8602e39c576452604796c17d269.tar.gz servo-6d694a4bcd97e8602e39c576452604796c17d269.zip |
style: Dishonor display: -moz-box if -webkit-box was specified before.
Bug: 1407701
-rw-r--r-- | components/style/properties/declaration_block.rs | 19 | ||||
-rw-r--r-- | components/style/properties/longhand/box.mako.rs | 27 |
2 files changed, 46 insertions, 0 deletions
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index b02d98ff689..69a5fadd7ce 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -500,6 +500,25 @@ impl PropertyDeclarationBlock { return true; } DeclarationSource::Parsing => { + // As a compatibility hack, specially on Android, + // don't allow to override a prefixed webkit display + // value with an unprefixed version from parsing + // code. + // + // TODO(emilio): Unship. + if let PropertyDeclaration::Display(old_display) = *slot { + use properties::longhands::display::computed_value::T as display; + + let new_display = match declaration { + PropertyDeclaration::Display(new_display) => new_display, + _ => unreachable!("How could the declaration id be the same?"), + }; + + if display::should_ignore_parsed_value(old_display, new_display) { + return false; + } + } + // NOTE(emilio): We could avoid this and just override for // properties not affected by logical props, but it's not // clear it's worth it given the `definitely_new` check. diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 8299ceade3d..f7b34b78f54 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -68,6 +68,33 @@ ) } + /// Whether `new_display` should be ignored, given a previous + /// `old_display` value. + /// + /// This is used to ignore `display: -moz-box` declarations after an + /// equivalent `display: -webkit-box` declaration, since the former + /// has a vastly different meaning. See bug 1107378 and bug 1407701. + /// + /// FIXME(emilio): This is a pretty decent hack, we should try to + /// remove it. + pub fn should_ignore_parsed_value( + _old_display: Self, + _new_display: Self, + ) -> bool { + #[cfg(feature = "gecko")] + { + match (_old_display, _new_display) { + (T::_webkit_box, T::_moz_box) | + (T::_webkit_inline_box, T::_moz_inline_box) => { + return true; + } + _ => {}, + } + } + + return false; + } + /// Returns whether this "display" value is one of the types for /// ruby. #[cfg(feature = "gecko")] |