Bug 1422235 - Implement the 'overflow-inline' media query. r=emilio
authorquasicomputational <quasicomputational@gmail.com>
Sat, 22 Dec 2018 19:41:33 +0000
changeset 509132 9495b83aad6421af9b2f00cb248257d845344e04
parent 509131 75ddf9a6a2bb75a76e4fe1f683d52ca8987250bf
child 509133 435cf6bbfa9ea152e8bf79799e327d12edd947db
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1422235
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1422235 - Implement the 'overflow-inline' media query. r=emilio
layout/reftests/css-mediaqueries/mq_overflow-inline-ref.html
layout/reftests/css-mediaqueries/mq_overflow-inline.html
layout/reftests/css-mediaqueries/mq_print_overflow-inline-ref.html
layout/reftests/css-mediaqueries/mq_print_overflow-inline.html
layout/reftests/css-mediaqueries/reftest.list
servo/components/style/gecko/media_features.rs
testing/web-platform/tests/css/mediaqueries/test_media_queries.html
xpcom/ds/StaticAtoms.py
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-mediaqueries/mq_overflow-inline-ref.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html>
+<html>
+  <span>A</span>
+  <span>D</span>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-mediaqueries/mq_overflow-inline.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+  <style>
+    @media (overflow-inline: none) {
+      .a { display: none }
+    }
+    @media (overflow-inline: scroll) {
+      .b { display: none }
+    }
+    @media (overflow-inline) {
+      .c { display: none }
+    }
+    @media (overflow-inline: something-new-and-unknown) {
+      .d { display: none }
+    }
+  </style>
+  <span class=a>A</span>
+  <span class=b>B</span>
+  <span class=c>C</span>
+  <span class=d>D</span>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-mediaqueries/mq_print_overflow-inline-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<html class=reftest-paged>
+  <span>B</span>
+  <span>C</span>
+  <span>D</span>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-mediaqueries/mq_print_overflow-inline.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html class=reftest-paged>
+  <style>
+    @media (overflow-inline: none) {
+      .a { display: none }
+    }
+    @media (overflow-inline: scroll) {
+      .b { display: none }
+    }
+    @media (overflow-inline) {
+      .c { display: none }
+    }
+    @media (overflow-inline: something-new-and-unknown) {
+      .d { display: none }
+    }
+  </style>
+  <span class=a>A</span>
+  <span class=b>B</span>
+  <span class=c>C</span>
+  <span class=d>D</span>
--- a/layout/reftests/css-mediaqueries/reftest.list
+++ b/layout/reftests/css-mediaqueries/reftest.list
@@ -7,16 +7,18 @@ fuzzy-if(Android,0-8,0-454) == mq_print_
 == mq_print_deviceaspectratio.xhtml mq_print-ref.xhtml
 == mq_print_devicewidth.xhtml mq_print-ref.xhtml
 fuzzy-if(Android,0-8,0-454) == mq_print_orientation.xhtml mq_print_orientation-ref.xhtml
 fuzzy-if(Android,0-8,0-454) == mq_print_maxheight.xhtml mq_print-ref.xhtml
 == mq_print_maxwidth.xhtml mq_print-ref.xhtml
 == mq_overflow-block.html mq_overflow-block-ref.html
 == mq_print_overflow-block.html mq_print_overflow-block-ref.html
 == mq_overflow-block.svg mq_overflow-block-ref.svg
+== mq_overflow-inline.html mq_overflow-inline-ref.html
+== mq_print_overflow-inline.html mq_print_overflow-inline-ref.html
 
 == mq_print_maxwidth_updown.xhtml mq_print-ref.xhtml
 == mq_print_maxheight_updown.xhtml mq_print-ref.xhtml
 == mq_print_minheight_updown.xhtml mq_print-ref.xhtml
 == mq_print_minwidth_updown.xhtml mq_print-ref.xhtml
 test-pref(ui.prefersReducedMotion,0) == mq_prefers_reduced_motion.html about:blank
 test-pref(ui.prefersReducedMotion,1) == mq_prefers_reduced_motion.html greenbox.html
 test-pref(ui.prefersReducedMotion,0) == mq_prefers_reduced_motion_no_preference.html greenbox.html
--- a/servo/components/style/gecko/media_features.rs
+++ b/servo/components/style/gecko/media_features.rs
@@ -322,16 +322,38 @@ fn eval_overflow_block(device: &Device, 
     match query_value {
         OverflowBlock::None |
         OverflowBlock::OptionalPaged => false,
         OverflowBlock::Scroll => scrolling,
         OverflowBlock::Paged => !scrolling,
     }
 }
 
+#[derive(Clone, Copy, Debug, FromPrimitive, Parse, ToCss)]
+#[repr(u8)]
+enum OverflowInline {
+    None,
+    Scroll,
+}
+
+/// https://drafts.csswg.org/mediaqueries-4/#mf-overflow-inline
+fn eval_overflow_inline(device: &Device, query_value: Option<OverflowInline>) -> bool {
+    // See the note in eval_overflow_block.
+    let scrolling = device.media_type() != MediaType::print();
+    let query_value = match query_value {
+        Some(v) => v,
+        None => return scrolling,
+    };
+
+    match query_value {
+        OverflowInline::None => !scrolling,
+        OverflowInline::Scroll => scrolling,
+    }
+}
+
 /// https://drafts.csswg.org/mediaqueries-4/#mf-interaction
 bitflags! {
     struct PointerCapabilities: u8 {
         const COARSE = structs::PointerCapabilities_Coarse;
         const FINE = structs::PointerCapabilities_Fine;
         const HOVER = structs::PointerCapabilities_Hover;
     }
 }
@@ -500,17 +522,17 @@ macro_rules! system_metric_feature {
 }
 
 lazy_static! {
     /// Adding new media features requires (1) adding the new feature to this
     /// array, with appropriate entries (and potentially any new code needed
     /// to support new types in these entries and (2) ensuring that either
     /// nsPresContext::MediaFeatureValuesChanged is called when the value that
     /// would be returned by the evaluator function could change.
-    pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 49] = [
+    pub static ref MEDIA_FEATURES: [MediaFeatureDescription; 50] = [
         feature!(
             atom!("width"),
             AllowsRanges::Yes,
             Evaluator::Length(eval_width),
             ParsingRequirements::empty(),
         ),
         feature!(
             atom!("height"),
@@ -626,16 +648,22 @@ lazy_static! {
         ),
         feature!(
             atom!("overflow-block"),
             AllowsRanges::No,
             keyword_evaluator!(eval_overflow_block, OverflowBlock),
             ParsingRequirements::empty(),
         ),
         feature!(
+            atom!("overflow-inline"),
+            AllowsRanges::No,
+            keyword_evaluator!(eval_overflow_inline, OverflowInline),
+            ParsingRequirements::empty(),
+        ),
+        feature!(
             atom!("pointer"),
             AllowsRanges::No,
             keyword_evaluator!(eval_pointer, Pointer),
             ParsingRequirements::empty(),
         ),
         feature!(
             atom!("any-pointer"),
             AllowsRanges::No,
--- a/testing/web-platform/tests/css/mediaqueries/test_media_queries.html
+++ b/testing/web-platform/tests/css/mediaqueries/test_media_queries.html
@@ -523,14 +523,25 @@ function run() {
     expression_should_be_parseable("overflow-block: optional-paged")
     expression_should_not_be_parseable("overflow-block: some-random-invalid-thing")
 
     // Sanity check for overflow-block
     var any_overflow_block = query_applies("(overflow-block)");
     var overflow_block_none = query_applies("(overflow-block: none)");
     assert_not_equals(any_overflow_block, overflow_block_none, "overflow-block should be equivalent to not (overflow-block: none)");
 
+    // Parsing tests for overflow-inline from mediaqueries-4
+    expression_should_be_parseable("overflow-inline")
+    expression_should_be_parseable("overflow-inline: none")
+    expression_should_be_parseable("overflow-inline: scroll")
+    expression_should_not_be_parseable("overflow-inline: some-random-invalid-thing")
+
+    // Sanity check for overflow-inline
+    var any_overflow_inline = query_applies("(overflow-inline)");
+    var overflow_inline_none = query_applies("(overflow-inline: none)");
+    assert_not_equals(any_overflow_inline, overflow_inline_none, "overflow-inline should be equivalent to not (overflow-inline: none)");
+
     done();
 }
 
 </script>
 </body>
 </html>
--- a/xpcom/ds/StaticAtoms.py
+++ b/xpcom/ds/StaticAtoms.py
@@ -922,16 +922,17 @@ STATIC_ATOMS = [
     Atom("order", "order"),
     Atom("ordinal", "ordinal"),
     Atom("orient", "orient"),
     Atom("orientation", "orientation"),
     Atom("otherwise", "otherwise"),
     Atom("output", "output"),
     Atom("overflow", "overflow"),
     Atom("overflowBlock", "overflow-block"),
+    Atom("overflowInline", "overflow-inline"),
     Atom("overlay", "overlay"),
     Atom("p", "p"),
     Atom("pack", "pack"),
     Atom("page", "page"),
     Atom("pageincrement", "pageincrement"),
     Atom("paint_order", "paint-order"),
     Atom("panel", "panel"),
     Atom("paragraph", "paragraph"),