From f872fdac9a49ef1bc551e507439fa322e4d31528 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 23 Apr 2017 10:32:16 +0200 Subject: [PATCH 01/22] Make Stylist::quirks_mode hold a QuirksMode --- components/layout_thread/lib.rs | 8 +++++--- components/script/dom/document.rs | 2 +- components/script_layout_interface/message.rs | 6 +++--- components/style/stylist.rs | 11 ++++++----- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index c17d3bd9b48..e69e55512d4 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -601,7 +601,7 @@ impl LayoutThread { Msg::AddStylesheet(style_info) => { self.handle_add_stylesheet(style_info, possibly_locked_rw_data) } - Msg::SetQuirksMode => self.handle_set_quirks_mode(possibly_locked_rw_data), + Msg::SetQuirksMode(mode) => self.handle_set_quirks_mode(possibly_locked_rw_data, mode), Msg::GetRPC(response_chan) => { response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as Box).unwrap(); @@ -772,9 +772,11 @@ impl LayoutThread { } /// Sets quirks mode for the document, causing the quirks mode stylesheet to be used. - fn handle_set_quirks_mode<'a, 'b>(&self, possibly_locked_rw_data: &mut RwData<'a, 'b>) { + fn handle_set_quirks_mode<'a, 'b>(&self, + possibly_locked_rw_data: &mut RwData<'a, 'b>, + quirks_mode: QuirksMode) { let mut rw_data = possibly_locked_rw_data.lock(); - Arc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(true); + Arc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(quirks_mode); possibly_locked_rw_data.block(rw_data); } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index ab124ba1734..06b8f7596cf 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -542,7 +542,7 @@ impl Document { self.quirks_mode.set(mode); if mode == QuirksMode::Quirks { - self.window.layout_chan().send(Msg::SetQuirksMode).unwrap(); + self.window.layout_chan().send(Msg::SetQuirksMode(mode)).unwrap(); } } diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 69dfd125e12..b94b6cd8d14 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -17,7 +17,7 @@ use script_traits::{LayoutMsg as ConstellationMsg, StackingContextScrollState, W use servo_url::ServoUrl; use std::sync::Arc; use std::sync::mpsc::{Receiver, Sender}; -use style::context::ReflowGoal; +use style::context::{QuirksMode, ReflowGoal}; use style::properties::PropertyId; use style::selector_parser::PseudoElement; use style::stylesheets::Stylesheet; @@ -27,8 +27,8 @@ pub enum Msg { /// Adds the given stylesheet to the document. AddStylesheet(Arc), - /// Puts a document into quirks mode, causing the quirks mode stylesheet to be loaded. - SetQuirksMode, + /// Change the quirks mode. + SetQuirksMode(QuirksMode), /// Requests a reflow. Reflow(ScriptReflow), diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 8ae9998c4cb..190226bb0cc 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -8,6 +8,7 @@ use {Atom, LocalName}; use bit_vec::BitVec; +use context::QuirksMode; use data::ComputedStyle; use dom::{AnimationRules, PresentationalHintsSynthetizer, TElement}; use error_reporting::RustLogReporter; @@ -75,7 +76,7 @@ pub struct Stylist { viewport_constraints: Option, /// If true, the quirks-mode stylesheet is applied. - quirks_mode: bool, + quirks_mode: QuirksMode, /// If true, the device has changed, and the stylist needs to be updated. is_device_dirty: bool, @@ -165,7 +166,7 @@ impl Stylist { viewport_constraints: None, device: Arc::new(device), is_device_dirty: true, - quirks_mode: false, + quirks_mode: QuirksMode::NoQuirks, element_map: PerPseudoElementSelectorMap::new(), pseudos_map: Default::default(), @@ -268,7 +269,7 @@ impl Stylist { self.add_stylesheet(&stylesheet, guards.ua_or_user, extra_data); } - if self.quirks_mode { + if self.quirks_mode != QuirksMode::NoQuirks { self.add_stylesheet(&ua_stylesheets.quirks_mode_stylesheet, guards.ua_or_user, extra_data); } @@ -610,14 +611,14 @@ impl Stylist { } /// Sets the quirks mode of the document. - pub fn set_quirks_mode(&mut self, enabled: bool) { + pub fn set_quirks_mode(&mut self, quirks_mode: QuirksMode) { // FIXME(emilio): We don't seem to change the quirks mode dynamically // during multiple layout passes, but this is totally bogus, in the // sense that it's updated asynchronously. // // This should probably be an argument to `update`, and use the quirks // mode info in the `SharedLayoutContext`. - self.quirks_mode = enabled; + self.quirks_mode = quirks_mode; } /// Returns the applicable CSS declarations for the given element. From 4df7af564a9250ca52da4353b66fff5e841f3634 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 09:55:55 +0200 Subject: [PATCH 02/22] Run a test per property and value in unitless-length.html --- tests/wpt/metadata/MANIFEST.json | 2 +- .../quirks-mode/unitless-length.html | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/tests/wpt/metadata/MANIFEST.json b/tests/wpt/metadata/MANIFEST.json index fc43eb22216..90d74745236 100644 --- a/tests/wpt/metadata/MANIFEST.json +++ b/tests/wpt/metadata/MANIFEST.json @@ -586960,7 +586960,7 @@ "testharness" ], "quirks-mode/unitless-length.html": [ - "1e896cad5c89bfe1756af5db60b61bc9fa93f61b", + "578d2aed4afa7cd6739610d353aebc591d832418", "testharness" ], "referrer-policy/OWNERS": [ diff --git a/tests/wpt/web-platform-tests/quirks-mode/unitless-length.html b/tests/wpt/web-platform-tests/quirks-mode/unitless-length.html index b2f05c01049..944c91fe395 100644 --- a/tests/wpt/web-platform-tests/quirks-mode/unitless-length.html +++ b/tests/wpt/web-platform-tests/quirks-mode/unitless-length.html @@ -130,14 +130,11 @@ '#ref{border-style:solid;position:relative;{prop}:{ref};}'; tests.forEach(function(t) { - var test_q = async_test(t.input + ' (quirks)'); - var test_a = async_test(t.input + ' (almost standards)'); - var test_s = async_test(t.input + ' (standards)'); for (var i in props) { if (t.shorthand && !(props[i].check_also)) { continue; } - test_q.step(function() { + test(function() { q.style.textContent = style_template.replace('{test}', t.input) .replace('{ref}', t.q).replace(/\{prop\}/g, props[i].prop) .replace(/clip:[^;]+/g, function(match) { @@ -153,8 +150,8 @@ props[i].prop + ', checking ' + props[i].check_also[j]); } } - }); - test_a.step(function() { + }, props[i].prop + ": " + t.input + ' (quirks)'); + test(function() { a.style.textContent = style_template.replace('{test}', t.input) .replace('{ref}', t.s).replace(/\{prop\}/g, props[i].prop) .replace(/clip:[^;]+/g, function(match) { @@ -170,8 +167,8 @@ props[i].prop + ', checking ' + props[i].check_also[j]); } } - }); - test_s.step(function() { + }, props[i].prop + ": " + t.input + ' (almost standards)'); + test(function() { s.style.textContent = style_template.replace('{test}', t.input) .replace('{ref}', t.s).replace(/\{prop\}/g, props[i].prop) .replace(/clip:[^;]+/g, function(match) { @@ -187,12 +184,8 @@ props[i].prop + ', checking ' + props[i].check_also[j]); } } - }); + }, props[i].prop + ": " + t.input + ' (standards)'); } - test_q.done(); - test_a.done(); - test_s.done(); - }); var other_tests = [ From 10fb8e61c77fcb2ad1adfe517aa08ecbe64d4db6 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 12:21:04 +0200 Subject: [PATCH 03/22] Enable /quirks-mode/ tests --- tests/wpt/include.ini | 2 + .../blocks-ignore-line-height.html.ini | 11 + .../quirks-mode/hashless-hex-color.html.ini | 233 +++ .../line-height-calculation.html.ini | 50 + .../percentage-height-calculation.html.ini | 122 ++ .../metadata/quirks-mode/supports.html.ini | 8 + ...-nowrap-minimum-width-calculation.html.ini | 5 + .../table-cell-width-calculation.html.ini | 26 + .../quirks-mode/unitless-length.html.ini | 1292 +++++++++++++++++ 9 files changed, 1749 insertions(+) create mode 100644 tests/wpt/metadata/quirks-mode/blocks-ignore-line-height.html.ini create mode 100644 tests/wpt/metadata/quirks-mode/hashless-hex-color.html.ini create mode 100644 tests/wpt/metadata/quirks-mode/line-height-calculation.html.ini create mode 100644 tests/wpt/metadata/quirks-mode/percentage-height-calculation.html.ini create mode 100644 tests/wpt/metadata/quirks-mode/supports.html.ini create mode 100644 tests/wpt/metadata/quirks-mode/table-cell-nowrap-minimum-width-calculation.html.ini create mode 100644 tests/wpt/metadata/quirks-mode/table-cell-width-calculation.html.ini create mode 100644 tests/wpt/metadata/quirks-mode/unitless-length.html.ini diff --git a/tests/wpt/include.ini b/tests/wpt/include.ini index 201a69c5b98..795d3bbe2f5 100644 --- a/tests/wpt/include.ini +++ b/tests/wpt/include.ini @@ -43,6 +43,8 @@ skip: true skip: true [script_scheduling] skip: false +[quirks-mode] + skip: false [referrer-policy] skip: false [subresource-integrity] diff --git a/tests/wpt/metadata/quirks-mode/blocks-ignore-line-height.html.ini b/tests/wpt/metadata/quirks-mode/blocks-ignore-line-height.html.ini new file mode 100644 index 00000000000..3979d3098e2 --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/blocks-ignore-line-height.html.ini @@ -0,0 +1,11 @@ +[blocks-ignore-line-height.html] + type: testharness + [The blocks ignore line-height quirk, #ref { display:block }
x
x
x
] + expected: FAIL + + [The blocks ignore line-height quirk, #ref { display:block }
x
x
x
x
x
x
] + expected: FAIL + + [The blocks ignore line-height quirk, #ref { display:block } div, #ref { line-height:2 } span { font-size:50% }
x
x
x
] + expected: FAIL + diff --git a/tests/wpt/metadata/quirks-mode/hashless-hex-color.html.ini b/tests/wpt/metadata/quirks-mode/hashless-hex-color.html.ini new file mode 100644 index 00000000000..0834442c891 --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/hashless-hex-color.html.ini @@ -0,0 +1,233 @@ +[hashless-hex-color.html] + type: testharness + [123 (quirks)] + expected: FAIL + + [023 (quirks)] + expected: FAIL + + [003 (quirks)] + expected: FAIL + + [000 (quirks)] + expected: FAIL + + [abc (quirks)] + expected: FAIL + + [ABC (quirks)] + expected: FAIL + + [1ab (quirks)] + expected: FAIL + + [1AB (quirks)] + expected: FAIL + + [112233 (quirks)] + expected: FAIL + + [012233 (quirks)] + expected: FAIL + + [002233 (quirks)] + expected: FAIL + + [000233 (quirks)] + expected: FAIL + + [000033 (quirks)] + expected: FAIL + + [000003 (quirks)] + expected: FAIL + + [000000 (quirks)] + expected: FAIL + + [aabbcc (quirks)] + expected: FAIL + + [AABBCC (quirks)] + expected: FAIL + + [11aabb (quirks)] + expected: FAIL + + [11AABB (quirks)] + expected: FAIL + + [\\31 23 (quirks)] + expected: FAIL + + [\\61 bc (quirks)] + expected: FAIL + + [\\41 BC (quirks)] + expected: FAIL + + [\\31 ab (quirks)] + expected: FAIL + + [\\31 AB (quirks)] + expected: FAIL + + [\\31 12233 (quirks)] + expected: FAIL + + [\\61 abbcc (quirks)] + expected: FAIL + + [\\41 ABBCC (quirks)] + expected: FAIL + + [\\31 1aabb (quirks)] + expected: FAIL + + [\\31 1AABB (quirks)] + expected: FAIL + + [12\\33 (quirks)] + expected: FAIL + + [1 (quirks)] + expected: FAIL + + [12 (quirks)] + expected: FAIL + + [1234 (quirks)] + expected: FAIL + + [12345 (quirks)] + expected: FAIL + + [1a (quirks)] + expected: FAIL + + [1abc (quirks)] + expected: FAIL + + [1abcd (quirks)] + expected: FAIL + + [+1 (quirks)] + expected: FAIL + + [+12 (quirks)] + expected: FAIL + + [+123 (quirks)] + expected: FAIL + + [+1234 (quirks)] + expected: FAIL + + [+12345 (quirks)] + expected: FAIL + + [+123456 (quirks)] + expected: FAIL + + [+1a (quirks)] + expected: FAIL + + [+12a (quirks)] + expected: FAIL + + [+123a (quirks)] + expected: FAIL + + [+1234a (quirks)] + expected: FAIL + + [+12345a (quirks)] + expected: FAIL + + [+1A (quirks)] + expected: FAIL + + [+12A (quirks)] + expected: FAIL + + [+123A (quirks)] + expected: FAIL + + [+1234A (quirks)] + expected: FAIL + + [+12345A (quirks)] + expected: FAIL + + [rgb(calc(100 + 155), 255, 255) (quirks)] + expected: FAIL + + [rgb(calc(100 + 155), 255, 255) (almost standards)] + expected: FAIL + + [rgb(calc(100 + 155), 255, 255) (standards)] + expected: FAIL + + [rgba(calc(100 + 155), 255, 255, 001) (quirks)] + expected: FAIL + + [rgba(calc(100 + 155), 255, 255, 001) (almost standards)] + expected: FAIL + + [rgba(calc(100 + 155), 255, 255, 001) (standards)] + expected: FAIL + + [hsl(calc(050 + 050), 100%, 100%) (quirks)] + expected: FAIL + + [hsl(calc(050 + 050), 100%, 100%) (almost standards)] + expected: FAIL + + [hsl(calc(050 + 050), 100%, 100%) (standards)] + expected: FAIL + + [hsla(calc(050 + 050), 100%, 100%, 001) (quirks)] + expected: FAIL + + [hsla(calc(050 + 050), 100%, 100%, 001) (almost standards)] + expected: FAIL + + [hsla(calc(050 + 050), 100%, 100%, 001) (standards)] + expected: FAIL + + [rgb(calc(/**/100/**/ + /**/155/**/), 255, 255) (quirks)] + expected: FAIL + + [rgb(calc(/**/100/**/ + /**/155/**/), 255, 255) (almost standards)] + expected: FAIL + + [rgb(calc(/**/100/**/ + /**/155/**/), 255, 255) (standards)] + expected: FAIL + + [#123 123 abc 12a (quirks)] + expected: FAIL + + [#123 123 abc 12a (almost standards)] + expected: FAIL + + [#123 123 abc 12a (standards)] + expected: FAIL + + [rgb(119, 255, 255) 123 (quirks)] + expected: FAIL + + [rgb(119, 255, 255) 123 (almost standards)] + expected: FAIL + + [rgb(119, 255, 255) 123 (standards)] + expected: FAIL + + [123 rgb(119, 255, 255) (quirks)] + expected: FAIL + + [123 rgb(119, 255, 255) (almost standards)] + expected: FAIL + + [123 rgb(119, 255, 255) (standards)] + expected: FAIL + diff --git a/tests/wpt/metadata/quirks-mode/line-height-calculation.html.ini b/tests/wpt/metadata/quirks-mode/line-height-calculation.html.ini new file mode 100644 index 00000000000..59aa0a298ce --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/line-height-calculation.html.ini @@ -0,0 +1,50 @@ +[line-height-calculation.html] + type: testharness + [The line height calculation quirk,
x
] + expected: FAIL + + [The line height calculation quirk,
x
] + expected: FAIL + + [The line height calculation quirk,
x
] + expected: FAIL + + [The line height calculation quirk, span { margin:1px }
x
] + expected: FAIL + + [The line height calculation quirk, span { margin:0 1px }
x
] + expected: FAIL + + [The line height calculation quirk, span { margin:0 1px; padding:1px 0 }
x
] + expected: FAIL + + [The line height calculation quirk, span { border-right:1px solid }
x
x
] + expected: FAIL + + [The line height calculation quirk, span { border-left:1px solid }
x
x
] + expected: FAIL + + [The line height calculation quirk, span { padding-right:1px }
x
x
] + expected: FAIL + + [The line height calculation quirk, span { padding-left:1px }
x
x
] + expected: FAIL + + [The line height calculation quirk, span { display:inline-block; height:1px }
x
] + expected: FAIL + + [The line height calculation quirk,
x
] + expected: FAIL + + [The line height calculation quirk, #test img { padding:1px }
x
] + expected: FAIL + + [The line height calculation quirk, iframe { height:1px }
x
] + expected: FAIL + + [The line height calculation quirk, #test::before { content:"" } #test::before, span { border:solid }
x
x
] + expected: FAIL + + [The line height calculation quirk, div { line-height: 0;} span { margin:0 1px; line-height: normal; }
x
x
xx
] + expected: FAIL + diff --git a/tests/wpt/metadata/quirks-mode/percentage-height-calculation.html.ini b/tests/wpt/metadata/quirks-mode/percentage-height-calculation.html.ini new file mode 100644 index 00000000000..5837be3bd93 --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/percentage-height-calculation.html.ini @@ -0,0 +1,122 @@ +[percentage-height-calculation.html] + type: testharness + [The percentage height calculation quirk, #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, #test { height:50% }
] + expected: FAIL + + [The percentage height calculation quirk, #test { height:25% }
] + expected: FAIL + + [The percentage height calculation quirk, #test { height:12.5% }
] + expected: FAIL + + [The percentage height calculation quirk, #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, ] + expected: FAIL + + [The percentage height calculation quirk, ] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk, #foo { height:100px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, #foo { position:relative } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, #foo { height:100px } #test { height:100%; position:relative }
] + expected: FAIL + + [The percentage height calculation quirk, html { display:inline } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { margin:10px } body { display:inline } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, body { margin:0 } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, body { margin:0; padding:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, body { margin:0; border:10px solid } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { margin:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { padding:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { border:10px solid } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { height:100%; margin:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { height:100%; padding:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { height:100%; border:10px solid } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, body { height:100%; margin:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, body { height:100%; padding:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, body { height:100%; border:10px solid } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { position:absolute; height:100%; margin:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { position:absolute; height:100%; padding:10px } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html { position:absolute; height:100%; border:10px solid } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, body { margin:99px 0 } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html, body { border:10px none } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk, html, body { border:10px hidden } #test { height:100% }
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + + [The percentage height calculation quirk,
] + expected: FAIL + diff --git a/tests/wpt/metadata/quirks-mode/supports.html.ini b/tests/wpt/metadata/quirks-mode/supports.html.ini new file mode 100644 index 00000000000..d3fb177270f --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/supports.html.ini @@ -0,0 +1,8 @@ +[supports.html] + type: testharness + [@supports quirky color] + expected: FAIL + + [Sanity check @supports length] + expected: FAIL + diff --git a/tests/wpt/metadata/quirks-mode/table-cell-nowrap-minimum-width-calculation.html.ini b/tests/wpt/metadata/quirks-mode/table-cell-nowrap-minimum-width-calculation.html.ini new file mode 100644 index 00000000000..8ef6f809d1a --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/table-cell-nowrap-minimum-width-calculation.html.ini @@ -0,0 +1,5 @@ +[table-cell-nowrap-minimum-width-calculation.html] + type: testharness + [The table cell nowrap minimum width calculation quirk, basic] + expected: FAIL + diff --git a/tests/wpt/metadata/quirks-mode/table-cell-width-calculation.html.ini b/tests/wpt/metadata/quirks-mode/table-cell-width-calculation.html.ini new file mode 100644 index 00000000000..2ad0708c604 --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/table-cell-width-calculation.html.ini @@ -0,0 +1,26 @@ +[table-cell-width-calculation.html] + type: testharness + [The table cell width calculation quirk, basic] + expected: FAIL + + [The table cell width calculation quirk, inline-block] + expected: FAIL + + [The table cell width calculation quirk, img in span] + expected: FAIL + + [The table cell width calculation quirk, the don't-wrap rule is only for the purpose of calculating the width of the cell] + expected: FAIL + + [The table cell width calculation quirk, the quirk shouldn't apply for ] + expected: FAIL + + [The table cell width calculation quirk, non-auto width on cell] + expected: FAIL + + [The table cell width calculation quirk, display:table-cell on span] + expected: FAIL + + [The table cell width calculation quirk, display:table-cell on span, wbr] + expected: FAIL + diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini new file mode 100644 index 00000000000..9b8f785c3ce --- /dev/null +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -0,0 +1,1292 @@ +[unitless-length.html] + type: testharness + [border-spacing: 1 (quirks)] + expected: FAIL + + [border-top-width: 1 (quirks)] + expected: FAIL + + [border-right-width: 1 (quirks)] + expected: FAIL + + [border-bottom-width: 1 (quirks)] + expected: FAIL + + [border-left-width: 1 (quirks)] + expected: FAIL + + [border-width: 1 (quirks)] + expected: FAIL + + [bottom: 1 (quirks)] + expected: FAIL + + [bottom: 1 (almost standards)] + expected: FAIL + + [bottom: 1 (standards)] + expected: FAIL + + [clip: 1 (quirks)] + expected: FAIL + + [font-size: 1 (quirks)] + expected: FAIL + + [height: 1 (quirks)] + expected: FAIL + + [letter-spacing: 1 (quirks)] + expected: FAIL + + [margin-left: 1 (quirks)] + expected: FAIL + + [margin-top: 1 (quirks)] + expected: FAIL + + [margin-bottom: 1 (quirks)] + expected: FAIL + + [margin: 1 (quirks)] + expected: FAIL + + [max-height: 1 (quirks)] + expected: FAIL + + [max-width: 1 (quirks)] + expected: FAIL + + [min-height: 1 (quirks)] + expected: FAIL + + [min-width: 1 (quirks)] + expected: FAIL + + [padding-top: 1 (quirks)] + expected: FAIL + + [padding-right: 1 (quirks)] + expected: FAIL + + [padding-bottom: 1 (quirks)] + expected: FAIL + + [padding-left: 1 (quirks)] + expected: FAIL + + [padding: 1 (quirks)] + expected: FAIL + + [right: 1 (quirks)] + expected: FAIL + + [text-indent: 1 (quirks)] + expected: FAIL + + [top: 1 (quirks)] + expected: FAIL + + [top: 1 (almost standards)] + expected: FAIL + + [top: 1 (standards)] + expected: FAIL + + [vertical-align: 1 (quirks)] + expected: FAIL + + [width: 1 (quirks)] + expected: FAIL + + [word-spacing: 1 (quirks)] + expected: FAIL + + [border-spacing: +1 (quirks)] + expected: FAIL + + [border-top-width: +1 (quirks)] + expected: FAIL + + [border-right-width: +1 (quirks)] + expected: FAIL + + [border-bottom-width: +1 (quirks)] + expected: FAIL + + [border-left-width: +1 (quirks)] + expected: FAIL + + [border-width: +1 (quirks)] + expected: FAIL + + [bottom: +1 (quirks)] + expected: FAIL + + [bottom: +1 (almost standards)] + expected: FAIL + + [bottom: +1 (standards)] + expected: FAIL + + [clip: +1 (quirks)] + expected: FAIL + + [font-size: +1 (quirks)] + expected: FAIL + + [height: +1 (quirks)] + expected: FAIL + + [letter-spacing: +1 (quirks)] + expected: FAIL + + [margin-left: +1 (quirks)] + expected: FAIL + + [margin-top: +1 (quirks)] + expected: FAIL + + [margin-bottom: +1 (quirks)] + expected: FAIL + + [margin: +1 (quirks)] + expected: FAIL + + [max-height: +1 (quirks)] + expected: FAIL + + [max-width: +1 (quirks)] + expected: FAIL + + [min-height: +1 (quirks)] + expected: FAIL + + [min-width: +1 (quirks)] + expected: FAIL + + [padding-top: +1 (quirks)] + expected: FAIL + + [padding-right: +1 (quirks)] + expected: FAIL + + [padding-bottom: +1 (quirks)] + expected: FAIL + + [padding-left: +1 (quirks)] + expected: FAIL + + [padding: +1 (quirks)] + expected: FAIL + + [right: +1 (quirks)] + expected: FAIL + + [text-indent: +1 (quirks)] + expected: FAIL + + [top: +1 (quirks)] + expected: FAIL + + [top: +1 (almost standards)] + expected: FAIL + + [top: +1 (standards)] + expected: FAIL + + [vertical-align: +1 (quirks)] + expected: FAIL + + [width: +1 (quirks)] + expected: FAIL + + [word-spacing: +1 (quirks)] + expected: FAIL + + [bottom: -1 (quirks)] + expected: FAIL + + [bottom: -1 (almost standards)] + expected: FAIL + + [bottom: -1 (standards)] + expected: FAIL + + [clip: -1 (quirks)] + expected: FAIL + + [letter-spacing: -1 (quirks)] + expected: FAIL + + [margin-left: -1 (quirks)] + expected: FAIL + + [margin-top: -1 (quirks)] + expected: FAIL + + [margin-bottom: -1 (quirks)] + expected: FAIL + + [margin: -1 (quirks)] + expected: FAIL + + [padding: -1 (quirks)] + expected: FAIL + + [right: -1 (quirks)] + expected: FAIL + + [text-indent: -1 (quirks)] + expected: FAIL + + [top: -1 (quirks)] + expected: FAIL + + [top: -1 (almost standards)] + expected: FAIL + + [top: -1 (standards)] + expected: FAIL + + [vertical-align: -1 (quirks)] + expected: FAIL + + [word-spacing: -1 (quirks)] + expected: FAIL + + [border-spacing: 1.5 (quirks)] + expected: FAIL + + [border-top-width: 1.5 (quirks)] + expected: FAIL + + [border-right-width: 1.5 (quirks)] + expected: FAIL + + [border-bottom-width: 1.5 (quirks)] + expected: FAIL + + [border-left-width: 1.5 (quirks)] + expected: FAIL + + [border-width: 1.5 (quirks)] + expected: FAIL + + [bottom: 1.5 (quirks)] + expected: FAIL + + [bottom: 1.5 (almost standards)] + expected: FAIL + + [bottom: 1.5 (standards)] + expected: FAIL + + [clip: 1.5 (quirks)] + expected: FAIL + + [font-size: 1.5 (quirks)] + expected: FAIL + + [height: 1.5 (quirks)] + expected: FAIL + + [letter-spacing: 1.5 (quirks)] + expected: FAIL + + [margin-left: 1.5 (quirks)] + expected: FAIL + + [margin-top: 1.5 (quirks)] + expected: FAIL + + [margin-bottom: 1.5 (quirks)] + expected: FAIL + + [margin: 1.5 (quirks)] + expected: FAIL + + [max-height: 1.5 (quirks)] + expected: FAIL + + [max-width: 1.5 (quirks)] + expected: FAIL + + [min-height: 1.5 (quirks)] + expected: FAIL + + [min-width: 1.5 (quirks)] + expected: FAIL + + [padding-top: 1.5 (quirks)] + expected: FAIL + + [padding-right: 1.5 (quirks)] + expected: FAIL + + [padding-bottom: 1.5 (quirks)] + expected: FAIL + + [padding-left: 1.5 (quirks)] + expected: FAIL + + [padding: 1.5 (quirks)] + expected: FAIL + + [right: 1.5 (quirks)] + expected: FAIL + + [text-indent: 1.5 (quirks)] + expected: FAIL + + [top: 1.5 (quirks)] + expected: FAIL + + [top: 1.5 (almost standards)] + expected: FAIL + + [top: 1.5 (standards)] + expected: FAIL + + [vertical-align: 1.5 (quirks)] + expected: FAIL + + [width: 1.5 (quirks)] + expected: FAIL + + [word-spacing: 1.5 (quirks)] + expected: FAIL + + [border-spacing: +1.5 (quirks)] + expected: FAIL + + [border-top-width: +1.5 (quirks)] + expected: FAIL + + [border-right-width: +1.5 (quirks)] + expected: FAIL + + [border-bottom-width: +1.5 (quirks)] + expected: FAIL + + [border-left-width: +1.5 (quirks)] + expected: FAIL + + [border-width: +1.5 (quirks)] + expected: FAIL + + [bottom: +1.5 (quirks)] + expected: FAIL + + [bottom: +1.5 (almost standards)] + expected: FAIL + + [bottom: +1.5 (standards)] + expected: FAIL + + [clip: +1.5 (quirks)] + expected: FAIL + + [font-size: +1.5 (quirks)] + expected: FAIL + + [height: +1.5 (quirks)] + expected: FAIL + + [letter-spacing: +1.5 (quirks)] + expected: FAIL + + [margin-left: +1.5 (quirks)] + expected: FAIL + + [margin-top: +1.5 (quirks)] + expected: FAIL + + [margin-bottom: +1.5 (quirks)] + expected: FAIL + + [margin: +1.5 (quirks)] + expected: FAIL + + [max-height: +1.5 (quirks)] + expected: FAIL + + [max-width: +1.5 (quirks)] + expected: FAIL + + [min-height: +1.5 (quirks)] + expected: FAIL + + [min-width: +1.5 (quirks)] + expected: FAIL + + [padding-top: +1.5 (quirks)] + expected: FAIL + + [padding-right: +1.5 (quirks)] + expected: FAIL + + [padding-bottom: +1.5 (quirks)] + expected: FAIL + + [padding-left: +1.5 (quirks)] + expected: FAIL + + [padding: +1.5 (quirks)] + expected: FAIL + + [right: +1.5 (quirks)] + expected: FAIL + + [text-indent: +1.5 (quirks)] + expected: FAIL + + [top: +1.5 (quirks)] + expected: FAIL + + [top: +1.5 (almost standards)] + expected: FAIL + + [top: +1.5 (standards)] + expected: FAIL + + [vertical-align: +1.5 (quirks)] + expected: FAIL + + [width: +1.5 (quirks)] + expected: FAIL + + [word-spacing: +1.5 (quirks)] + expected: FAIL + + [bottom: -1.5 (quirks)] + expected: FAIL + + [bottom: -1.5 (almost standards)] + expected: FAIL + + [bottom: -1.5 (standards)] + expected: FAIL + + [clip: -1.5 (quirks)] + expected: FAIL + + [letter-spacing: -1.5 (quirks)] + expected: FAIL + + [margin-left: -1.5 (quirks)] + expected: FAIL + + [margin-top: -1.5 (quirks)] + expected: FAIL + + [margin-bottom: -1.5 (quirks)] + expected: FAIL + + [margin: -1.5 (quirks)] + expected: FAIL + + [padding: -1.5 (quirks)] + expected: FAIL + + [right: -1.5 (quirks)] + expected: FAIL + + [text-indent: -1.5 (quirks)] + expected: FAIL + + [top: -1.5 (quirks)] + expected: FAIL + + [top: -1.5 (almost standards)] + expected: FAIL + + [top: -1.5 (standards)] + expected: FAIL + + [vertical-align: -1.5 (quirks)] + expected: FAIL + + [word-spacing: -1.5 (quirks)] + expected: FAIL + + [bottom: \\31 (quirks)] + expected: FAIL + + [bottom: \\31 (almost standards)] + expected: FAIL + + [bottom: \\31 (standards)] + expected: FAIL + + [top: \\31 (quirks)] + expected: FAIL + + [top: \\31 (almost standards)] + expected: FAIL + + [top: \\31 (standards)] + expected: FAIL + + [bottom: +\\31 (quirks)] + expected: FAIL + + [bottom: +\\31 (almost standards)] + expected: FAIL + + [bottom: +\\31 (standards)] + expected: FAIL + + [top: +\\31 (quirks)] + expected: FAIL + + [top: +\\31 (almost standards)] + expected: FAIL + + [top: +\\31 (standards)] + expected: FAIL + + [bottom: -\\31 (quirks)] + expected: FAIL + + [bottom: -\\31 (almost standards)] + expected: FAIL + + [bottom: -\\31 (standards)] + expected: FAIL + + [top: -\\31 (quirks)] + expected: FAIL + + [top: -\\31 (almost standards)] + expected: FAIL + + [top: -\\31 (standards)] + expected: FAIL + + [bottom: \\31 .5 (quirks)] + expected: FAIL + + [bottom: \\31 .5 (almost standards)] + expected: FAIL + + [bottom: \\31 .5 (standards)] + expected: FAIL + + [top: \\31 .5 (quirks)] + expected: FAIL + + [top: \\31 .5 (almost standards)] + expected: FAIL + + [top: \\31 .5 (standards)] + expected: FAIL + + [bottom: +\\31 .5 (quirks)] + expected: FAIL + + [bottom: +\\31 .5 (almost standards)] + expected: FAIL + + [bottom: +\\31 .5 (standards)] + expected: FAIL + + [top: +\\31 .5 (quirks)] + expected: FAIL + + [top: +\\31 .5 (almost standards)] + expected: FAIL + + [top: +\\31 .5 (standards)] + expected: FAIL + + [bottom: -\\31 .5 (quirks)] + expected: FAIL + + [bottom: -\\31 .5 (almost standards)] + expected: FAIL + + [bottom: -\\31 .5 (standards)] + expected: FAIL + + [top: -\\31 .5 (quirks)] + expected: FAIL + + [top: -\\31 .5 (almost standards)] + expected: FAIL + + [top: -\\31 .5 (standards)] + expected: FAIL + + [bottom: 1\\31 (quirks)] + expected: FAIL + + [bottom: 1\\31 (almost standards)] + expected: FAIL + + [bottom: 1\\31 (standards)] + expected: FAIL + + [top: 1\\31 (quirks)] + expected: FAIL + + [top: 1\\31 (almost standards)] + expected: FAIL + + [top: 1\\31 (standards)] + expected: FAIL + + [bottom: +1\\31 (quirks)] + expected: FAIL + + [bottom: +1\\31 (almost standards)] + expected: FAIL + + [bottom: +1\\31 (standards)] + expected: FAIL + + [top: +1\\31 (quirks)] + expected: FAIL + + [top: +1\\31 (almost standards)] + expected: FAIL + + [top: +1\\31 (standards)] + expected: FAIL + + [bottom: -1\\31 (quirks)] + expected: FAIL + + [bottom: -1\\31 (almost standards)] + expected: FAIL + + [bottom: -1\\31 (standards)] + expected: FAIL + + [top: -1\\31 (quirks)] + expected: FAIL + + [top: -1\\31 (almost standards)] + expected: FAIL + + [top: -1\\31 (standards)] + expected: FAIL + + [bottom: 1\\31 .5 (quirks)] + expected: FAIL + + [bottom: 1\\31 .5 (almost standards)] + expected: FAIL + + [bottom: 1\\31 .5 (standards)] + expected: FAIL + + [top: 1\\31 .5 (quirks)] + expected: FAIL + + [top: 1\\31 .5 (almost standards)] + expected: FAIL + + [top: 1\\31 .5 (standards)] + expected: FAIL + + [bottom: +1\\31 .5 (quirks)] + expected: FAIL + + [bottom: +1\\31 .5 (almost standards)] + expected: FAIL + + [bottom: +1\\31 .5 (standards)] + expected: FAIL + + [top: +1\\31 .5 (quirks)] + expected: FAIL + + [top: +1\\31 .5 (almost standards)] + expected: FAIL + + [top: +1\\31 .5 (standards)] + expected: FAIL + + [bottom: -1\\31 .5 (quirks)] + expected: FAIL + + [bottom: -1\\31 .5 (almost standards)] + expected: FAIL + + [bottom: -1\\31 .5 (standards)] + expected: FAIL + + [top: -1\\31 .5 (quirks)] + expected: FAIL + + [top: -1\\31 .5 (almost standards)] + expected: FAIL + + [top: -1\\31 .5 (standards)] + expected: FAIL + + [bottom: a (quirks)] + expected: FAIL + + [bottom: a (almost standards)] + expected: FAIL + + [bottom: a (standards)] + expected: FAIL + + [top: a (quirks)] + expected: FAIL + + [top: a (almost standards)] + expected: FAIL + + [top: a (standards)] + expected: FAIL + + [bottom: A (quirks)] + expected: FAIL + + [bottom: A (almost standards)] + expected: FAIL + + [bottom: A (standards)] + expected: FAIL + + [top: A (quirks)] + expected: FAIL + + [top: A (almost standards)] + expected: FAIL + + [top: A (standards)] + expected: FAIL + + [bottom: 1a (quirks)] + expected: FAIL + + [bottom: 1a (almost standards)] + expected: FAIL + + [bottom: 1a (standards)] + expected: FAIL + + [top: 1a (quirks)] + expected: FAIL + + [top: 1a (almost standards)] + expected: FAIL + + [top: 1a (standards)] + expected: FAIL + + [bottom: +1a (quirks)] + expected: FAIL + + [bottom: +1a (almost standards)] + expected: FAIL + + [bottom: +1a (standards)] + expected: FAIL + + [top: +1a (quirks)] + expected: FAIL + + [top: +1a (almost standards)] + expected: FAIL + + [top: +1a (standards)] + expected: FAIL + + [bottom: -1a (quirks)] + expected: FAIL + + [bottom: -1a (almost standards)] + expected: FAIL + + [bottom: -1a (standards)] + expected: FAIL + + [top: -1a (quirks)] + expected: FAIL + + [top: -1a (almost standards)] + expected: FAIL + + [top: -1a (standards)] + expected: FAIL + + [bottom: +1A (quirks)] + expected: FAIL + + [bottom: +1A (almost standards)] + expected: FAIL + + [bottom: +1A (standards)] + expected: FAIL + + [top: +1A (quirks)] + expected: FAIL + + [top: +1A (almost standards)] + expected: FAIL + + [top: +1A (standards)] + expected: FAIL + + [bottom: -1A (quirks)] + expected: FAIL + + [bottom: -1A (almost standards)] + expected: FAIL + + [bottom: -1A (standards)] + expected: FAIL + + [top: -1A (quirks)] + expected: FAIL + + [top: -1A (almost standards)] + expected: FAIL + + [top: -1A (standards)] + expected: FAIL + + [bottom: +a (quirks)] + expected: FAIL + + [bottom: +a (almost standards)] + expected: FAIL + + [bottom: +a (standards)] + expected: FAIL + + [top: +a (quirks)] + expected: FAIL + + [top: +a (almost standards)] + expected: FAIL + + [top: +a (standards)] + expected: FAIL + + [bottom: -a (quirks)] + expected: FAIL + + [bottom: -a (almost standards)] + expected: FAIL + + [bottom: -a (standards)] + expected: FAIL + + [top: -a (quirks)] + expected: FAIL + + [top: -a (almost standards)] + expected: FAIL + + [top: -a (standards)] + expected: FAIL + + [bottom: +A (quirks)] + expected: FAIL + + [bottom: +A (almost standards)] + expected: FAIL + + [bottom: +A (standards)] + expected: FAIL + + [top: +A (quirks)] + expected: FAIL + + [top: +A (almost standards)] + expected: FAIL + + [top: +A (standards)] + expected: FAIL + + [bottom: -A (quirks)] + expected: FAIL + + [bottom: -A (almost standards)] + expected: FAIL + + [bottom: -A (standards)] + expected: FAIL + + [top: -A (quirks)] + expected: FAIL + + [top: -A (almost standards)] + expected: FAIL + + [top: -A (standards)] + expected: FAIL + + [bottom: @a (quirks)] + expected: FAIL + + [bottom: @a (almost standards)] + expected: FAIL + + [bottom: @a (standards)] + expected: FAIL + + [top: @a (quirks)] + expected: FAIL + + [top: @a (almost standards)] + expected: FAIL + + [top: @a (standards)] + expected: FAIL + + [bottom: @1 (quirks)] + expected: FAIL + + [bottom: @1 (almost standards)] + expected: FAIL + + [bottom: @1 (standards)] + expected: FAIL + + [top: @1 (quirks)] + expected: FAIL + + [top: @1 (almost standards)] + expected: FAIL + + [top: @1 (standards)] + expected: FAIL + + [bottom: @1a (quirks)] + expected: FAIL + + [bottom: @1a (almost standards)] + expected: FAIL + + [bottom: @1a (standards)] + expected: FAIL + + [top: @1a (quirks)] + expected: FAIL + + [top: @1a (almost standards)] + expected: FAIL + + [top: @1a (standards)] + expected: FAIL + + [bottom: "a" (quirks)] + expected: FAIL + + [bottom: "a" (almost standards)] + expected: FAIL + + [bottom: "a" (standards)] + expected: FAIL + + [top: "a" (quirks)] + expected: FAIL + + [top: "a" (almost standards)] + expected: FAIL + + [top: "a" (standards)] + expected: FAIL + + [bottom: "1" (quirks)] + expected: FAIL + + [bottom: "1" (almost standards)] + expected: FAIL + + [bottom: "1" (standards)] + expected: FAIL + + [top: "1" (quirks)] + expected: FAIL + + [top: "1" (almost standards)] + expected: FAIL + + [top: "1" (standards)] + expected: FAIL + + [bottom: "1a" (quirks)] + expected: FAIL + + [bottom: "1a" (almost standards)] + expected: FAIL + + [bottom: "1a" (standards)] + expected: FAIL + + [top: "1a" (quirks)] + expected: FAIL + + [top: "1a" (almost standards)] + expected: FAIL + + [top: "1a" (standards)] + expected: FAIL + + [bottom: url(1) (quirks)] + expected: FAIL + + [bottom: url(1) (almost standards)] + expected: FAIL + + [bottom: url(1) (standards)] + expected: FAIL + + [top: url(1) (quirks)] + expected: FAIL + + [top: url(1) (almost standards)] + expected: FAIL + + [top: url(1) (standards)] + expected: FAIL + + [bottom: url('1') (quirks)] + expected: FAIL + + [bottom: url('1') (almost standards)] + expected: FAIL + + [bottom: url('1') (standards)] + expected: FAIL + + [top: url('1') (quirks)] + expected: FAIL + + [top: url('1') (almost standards)] + expected: FAIL + + [top: url('1') (standards)] + expected: FAIL + + [bottom: #1 (quirks)] + expected: FAIL + + [bottom: #1 (almost standards)] + expected: FAIL + + [bottom: #1 (standards)] + expected: FAIL + + [top: #1 (quirks)] + expected: FAIL + + [top: #1 (almost standards)] + expected: FAIL + + [top: #1 (standards)] + expected: FAIL + + [bottom: #01 (quirks)] + expected: FAIL + + [bottom: #01 (almost standards)] + expected: FAIL + + [bottom: #01 (standards)] + expected: FAIL + + [top: #01 (quirks)] + expected: FAIL + + [top: #01 (almost standards)] + expected: FAIL + + [top: #01 (standards)] + expected: FAIL + + [bottom: #001 (quirks)] + expected: FAIL + + [bottom: #001 (almost standards)] + expected: FAIL + + [bottom: #001 (standards)] + expected: FAIL + + [top: #001 (quirks)] + expected: FAIL + + [top: #001 (almost standards)] + expected: FAIL + + [top: #001 (standards)] + expected: FAIL + + [bottom: #0001 (quirks)] + expected: FAIL + + [bottom: #0001 (almost standards)] + expected: FAIL + + [bottom: #0001 (standards)] + expected: FAIL + + [top: #0001 (quirks)] + expected: FAIL + + [top: #0001 (almost standards)] + expected: FAIL + + [top: #0001 (standards)] + expected: FAIL + + [bottom: #00001 (quirks)] + expected: FAIL + + [bottom: #00001 (almost standards)] + expected: FAIL + + [bottom: #00001 (standards)] + expected: FAIL + + [top: #00001 (quirks)] + expected: FAIL + + [top: #00001 (almost standards)] + expected: FAIL + + [top: #00001 (standards)] + expected: FAIL + + [bottom: #000001 (quirks)] + expected: FAIL + + [bottom: #000001 (almost standards)] + expected: FAIL + + [bottom: #000001 (standards)] + expected: FAIL + + [top: #000001 (quirks)] + expected: FAIL + + [top: #000001 (almost standards)] + expected: FAIL + + [top: #000001 (standards)] + expected: FAIL + + [bottom: +/**/1 (quirks)] + expected: FAIL + + [bottom: +/**/1 (almost standards)] + expected: FAIL + + [bottom: +/**/1 (standards)] + expected: FAIL + + [top: +/**/1 (quirks)] + expected: FAIL + + [top: +/**/1 (almost standards)] + expected: FAIL + + [top: +/**/1 (standards)] + expected: FAIL + + [bottom: -/**/1 (quirks)] + expected: FAIL + + [bottom: -/**/1 (almost standards)] + expected: FAIL + + [bottom: -/**/1 (standards)] + expected: FAIL + + [top: -/**/1 (quirks)] + expected: FAIL + + [top: -/**/1 (almost standards)] + expected: FAIL + + [top: -/**/1 (standards)] + expected: FAIL + + [bottom: calc(1) (quirks)] + expected: FAIL + + [bottom: calc(1) (almost standards)] + expected: FAIL + + [bottom: calc(1) (standards)] + expected: FAIL + + [top: calc(1) (quirks)] + expected: FAIL + + [top: calc(1) (almost standards)] + expected: FAIL + + [top: calc(1) (standards)] + expected: FAIL + + [bottom: calc(2 * 2px) (quirks)] + expected: FAIL + + [bottom: calc(2 * 2px) (almost standards)] + expected: FAIL + + [bottom: calc(2 * 2px) (standards)] + expected: FAIL + + [top: calc(2 * 2px) (quirks)] + expected: FAIL + + [top: calc(2 * 2px) (almost standards)] + expected: FAIL + + [top: calc(2 * 2px) (standards)] + expected: FAIL + + [border-spacing: 1px 2 (quirks)] + expected: FAIL + + [border-width: 1px 2 (quirks)] + expected: FAIL + + [margin: 1px 2 (quirks)] + expected: FAIL + + [padding: 1px 2 (quirks)] + expected: FAIL + + [border-spacing: 1 2px (quirks)] + expected: FAIL + + [border-width: 1 2px (quirks)] + expected: FAIL + + [margin: 1 2px (quirks)] + expected: FAIL + + [padding: 1 2px (quirks)] + expected: FAIL + + [border-spacing: 1 +2 (quirks)] + expected: FAIL + + [border-width: 1 +2 (quirks)] + expected: FAIL + + [margin: 1 +2 (quirks)] + expected: FAIL + + [padding: 1 +2 (quirks)] + expected: FAIL + + [margin: 1 -2 (quirks)] + expected: FAIL + + [padding: 1 -2 (quirks)] + expected: FAIL + From f68e2fded92e769a1fc0d5bdc963f47da366d651 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 23 Apr 2017 11:07:48 +0200 Subject: [PATCH 04/22] Propagate quirks mode all the way to ParserContext The quirks mode is still not properly propagated in geckolib. --- components/layout_thread/lib.rs | 5 ++- components/script/dom/css.rs | 7 +++- components/script/dom/cssmediarule.rs | 5 ++- components/script/dom/cssstyledeclaration.rs | 9 ++++- components/script/dom/csssupportsrule.rs | 4 +- components/script/dom/element.rs | 3 +- components/script/dom/htmllinkelement.rs | 3 +- components/script/dom/htmlmetaelement.rs | 1 + components/script/dom/htmlstyleelement.rs | 6 ++- components/script/dom/medialist.rs | 13 +++++-- components/script/dom/mediaquerylist.rs | 2 +- components/script/dom/window.rs | 4 +- components/script/stylesheet_loader.rs | 3 +- components/style/animation.rs | 3 +- components/style/encoding_support.rs | 5 ++- components/style/gecko/media_queries.rs | 10 +++-- components/style/gecko/wrapper.rs | 4 +- components/style/keyframes.rs | 3 +- components/style/matching.rs | 3 +- components/style/media_queries.rs | 5 ++- components/style/parser.rs | 17 +++++++-- .../style/properties/declaration_block.rs | 13 +++++-- components/style/properties/helpers.mako.rs | 3 +- .../helpers/animated_properties.mako.rs | 4 +- .../style/properties/properties.mako.rs | 23 ++++++++---- components/style/servo/media_queries.rs | 8 ++-- components/style/stylesheets.rs | 37 +++++++++++++------ components/style/stylist.rs | 23 +++++++----- components/style/values/computed/mod.rs | 4 ++ components/style/viewport.rs | 8 +++- ports/geckolib/glue.rs | 37 +++++++++++++------ tests/unit/style/media_queries.rs | 5 ++- tests/unit/style/parsing/image.rs | 2 + tests/unit/style/parsing/length.rs | 4 +- tests/unit/style/parsing/mod.rs | 4 +- tests/unit/style/properties/mod.rs | 4 +- tests/unit/style/rule_tree/bench.rs | 2 + tests/unit/style/stylesheets.rs | 6 ++- tests/unit/style/viewport.rs | 23 +++++++----- 39 files changed, 225 insertions(+), 100 deletions(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index e69e55512d4..30d59180a3c 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -1589,7 +1589,8 @@ fn get_ua_stylesheets() -> Result { MediaList::empty(), shared_lock.clone(), None, - &NullReporter)) + &NullReporter, + QuirksMode::NoQuirks)) } let shared_lock = SharedRwLock::new(); @@ -1602,7 +1603,7 @@ fn get_ua_stylesheets() -> Result { for &(ref contents, ref url) in &opts::get().user_stylesheets { user_or_user_agent_stylesheets.push(Stylesheet::from_bytes( &contents, url.clone(), None, None, Origin::User, MediaList::empty(), - shared_lock.clone(), None, &RustLogReporter)); + shared_lock.clone(), None, &RustLogReporter, QuirksMode::NoQuirks)); } let quirks_mode_stylesheet = try!(parse_ua_stylesheet(&shared_lock, "quirks-mode.css")); diff --git a/components/script/dom/css.rs b/components/script/dom/css.rs index 0e4a7f85065..72cdbfa5be6 100644 --- a/components/script/dom/css.rs +++ b/components/script/dom/css.rs @@ -9,6 +9,7 @@ use dom::bindings::reflector::Reflector; use dom::bindings::str::DOMString; use dom::window::Window; use dom_struct::dom_struct; +use style::context::QuirksMode; use style::parser::{LengthParsingMode, ParserContext}; use style::stylesheets::CssRuleType; use style::supports::{Declaration, parse_condition_or_declaration}; @@ -31,7 +32,8 @@ impl CSS { let decl = Declaration { prop: property.into(), val: value.into() }; let url = win.Document().url(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); decl.eval(&context) } @@ -42,7 +44,8 @@ impl CSS { if let Ok(cond) = cond { let url = win.Document().url(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); cond.eval(&context) } else { false diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index aff12e2e2ad..45bf65b1adf 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -5,6 +5,7 @@ use cssparser::Parser; use dom::bindings::codegen::Bindings::CSSMediaRuleBinding; use dom::bindings::codegen::Bindings::CSSMediaRuleBinding::CSSMediaRuleMethods; +use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::js::{MutNullableJS, Root}; use dom::bindings::reflector::{DomObject, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -72,8 +73,10 @@ impl CSSMediaRule { let global = self.global(); let win = global.as_window(); let url = win.get_url(); + let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); let new_medialist = parse_media_query_list(&context, &mut input); let mut guard = self.cssconditionrule.shared_lock().write(); diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 22fd1194034..d0996f04567 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -256,9 +256,12 @@ impl CSSStyleDeclaration { // Step 6 let window = self.owner.window(); + let quirks_mode = window.Document().quirks_mode(); let result = parse_one_declaration(id, &value, &self.owner.base_url(), - window.css_error_reporter(), LengthParsingMode::Default); + window.css_error_reporter(), + LengthParsingMode::Default, + quirks_mode); // Step 7 let parsed = match result { @@ -434,11 +437,13 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { return Err(Error::NoModificationAllowed); } + let quirks_mode = window.Document().quirks_mode(); self.owner.mutate_associated_block(|mut pdb, mut _changed| { // Step 3 *pdb = parse_style_attribute(&value, &self.owner.base_url(), - window.css_error_reporter()); + window.css_error_reporter(), + quirks_mode); }); Ok(()) diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 3ac60a00e06..86aedf10864 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -61,8 +61,10 @@ impl CSSSupportsRule { let global = self.global(); let win = global.as_window(); let url = win.Document().url(); + let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Supports), - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); let enabled = cond.eval(&context); let mut guard = self.cssconditionrule.shared_lock().write(); let rule = self.supportsrule.write_with(&mut guard); diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 7b56b6c6e81..d6974fb9075 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -2196,7 +2196,8 @@ impl VirtualMethods for Element { Arc::new(doc.style_shared_lock().wrap(parse_style_attribute( &attr.value(), &doc.base_url(), - win.css_error_reporter()))) + win.css_error_reporter(), + doc.quirks_mode()))) }; Some(block) diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index c0d0d12a775..bf36d28b29d 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -282,7 +282,8 @@ impl HTMLLinkElement { let win = document.window(); let doc_url = document.url(); let context = CssParserContext::new_for_cssom(&doc_url, win.css_error_reporter(), Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + document.quirks_mode()); let media = parse_media_query_list(&context, &mut css_parser); let im_attribute = element.get_attribute(&ns!(), &local_name!("integrity")); diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 3c4e817a132..62d7215e3df 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -113,6 +113,7 @@ impl HTMLMetaElement { // force all styles to be recomputed. dirty_on_viewport_size_change: AtomicBool::new(false), disabled: AtomicBool::new(false), + quirks_mode: document.quirks_mode(), })); let doc = document_from_node(self); doc.invalidate_stylesheets(); diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 0c026fcfe9a..8905c3baa65 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -76,6 +76,7 @@ impl HTMLStyleElement { assert!(node.is_in_doc()); let win = window_from_node(node); + let doc = document_from_node(self); let mq_attribute = element.get_attribute(&ns!(), &local_name!("media")); let mq_str = match mq_attribute { @@ -88,7 +89,8 @@ impl HTMLStyleElement { let context = CssParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + doc.quirks_mode()); let shared_lock = node.owner_doc().style_shared_lock().clone(); let mq = Arc::new(shared_lock.wrap( parse_media_query_list(&context, &mut CssParser::new(&mq_str)))); @@ -96,6 +98,7 @@ impl HTMLStyleElement { let sheet = Stylesheet::from_str(&data, win.get_url(), Origin::Author, mq, shared_lock, Some(&loader), win.css_error_reporter(), + doc.quirks_mode(), self.line_number); let sheet = Arc::new(sheet); @@ -107,7 +110,6 @@ impl HTMLStyleElement { win.layout_chan().send(Msg::AddStylesheet(sheet.clone())).unwrap(); *self.stylesheet.borrow_mut() = Some(sheet); - let doc = document_from_node(self); doc.invalidate_stylesheets(); } diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index 881c17966da..f2a2299d169 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -5,6 +5,7 @@ use cssparser::Parser; use dom::bindings::codegen::Bindings::MediaListBinding; use dom::bindings::codegen::Bindings::MediaListBinding::MediaListMethods; +use dom::bindings::codegen::Bindings::WindowBinding::WindowBinding::WindowMethods; use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; @@ -74,8 +75,10 @@ impl MediaListMethods for MediaList { let global = self.global(); let win = global.as_window(); let url = win.get_url(); + let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); *media_queries = parse_media_query_list(&context, &mut parser); } @@ -108,8 +111,10 @@ impl MediaListMethods for MediaList { let global = self.global(); let win = global.as_window(); let url = win.get_url(); + let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); let m = MediaQuery::parse(&context, &mut parser); // Step 2 if let Err(_) = m { @@ -134,8 +139,10 @@ impl MediaListMethods for MediaList { let global = self.global(); let win = global.as_window(); let url = win.get_url(); + let quirks_mode = win.Document().quirks_mode(); let context = ParserContext::new_for_cssom(&url, win.css_error_reporter(), Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); let m = MediaQuery::parse(&context, &mut parser); // Step 2 if let Err(_) = m { diff --git a/components/script/dom/mediaquerylist.rs b/components/script/dom/mediaquerylist.rs index dafc7602794..b25e041f4ef 100644 --- a/components/script/dom/mediaquerylist.rs +++ b/components/script/dom/mediaquerylist.rs @@ -77,7 +77,7 @@ impl MediaQueryList { if let Some(window_size) = self.document.window().window_size() { let viewport_size = window_size.initial_viewport; let device = Device::new(MediaType::Screen, viewport_size); - self.media_query_list.evaluate(&device) + self.media_query_list.evaluate(&device, self.document.quirks_mode()) } else { false } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index eaba1ded928..6b8857b81b1 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -976,8 +976,10 @@ impl WindowMethods for Window { fn MatchMedia(&self, query: DOMString) -> Root { let mut parser = Parser::new(&query); let url = self.get_url(); + let quirks_mode = self.Document().quirks_mode(); let context = CssParserContext::new_for_cssom(&url, self.css_error_reporter(), Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); let media_query_list = media_queries::parse_media_query_list(&context, &mut parser); let document = self.Document(); let mql = MediaQueryList::new(&document, media_query_list); diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index a859e798818..14b8c385e39 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -144,7 +144,8 @@ impl FetchResponseListener for StylesheetContext { media.take().unwrap(), shared_lock, Some(&loader), - win.css_error_reporter())); + win.css_error_reporter(), + document.quirks_mode())); if link.is_alternate() { sheet.set_disabled(true); diff --git a/components/style/animation.rs b/components/style/animation.rs index 16c7dab364d..01dcc850fc7 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -451,7 +451,8 @@ fn compute_style_for_animation_step(context: &SharedStyleContext, /* cascade_info = */ None, &*context.error_reporter, font_metrics_provider, - CascadeFlags::empty()); + CascadeFlags::empty(), + context.quirks_mode); computed } } diff --git a/components/style/encoding_support.rs b/components/style/encoding_support.rs index b61c743051f..2775de54893 100644 --- a/components/style/encoding_support.rs +++ b/components/style/encoding_support.rs @@ -6,6 +6,7 @@ extern crate encoding; +use context::QuirksMode; use cssparser::{stylesheet_encoding, EncodingSupport}; use error_reporting::ParseErrorReporter; use media_queries::MediaList; @@ -56,7 +57,8 @@ impl Stylesheet { media: MediaList, shared_lock: SharedRwLock, stylesheet_loader: Option<&StylesheetLoader>, - error_reporter: &ParseErrorReporter) + error_reporter: &ParseErrorReporter, + quirks_mode: QuirksMode) -> Stylesheet { let (string, _) = decode_stylesheet_bytes( bytes, protocol_encoding_label, environment_encoding); @@ -67,6 +69,7 @@ impl Stylesheet { shared_lock, stylesheet_loader, error_reporter, + quirks_mode, 0u64) } diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index 4aff56ee8d5..8aa3b2da396 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -5,6 +5,7 @@ //! Gecko's media-query device and expression representation. use app_units::Au; +use context::QuirksMode; use cssparser::{CssStringWriter, Parser, Token}; use euclid::Size2D; use font_metrics::get_metrics_provider_for_product; @@ -521,7 +522,7 @@ impl Expression { } /// Returns whether this media query evaluates to true for the given device. - pub fn matches(&self, device: &Device) -> bool { + pub fn matches(&self, device: &Device, quirks_mode: QuirksMode) -> bool { let mut css_value = nsCSSValue::null(); unsafe { (self.feature.mGetter.unwrap())(device.pres_context, @@ -534,12 +535,13 @@ impl Expression { None => return false, }; - self.evaluate_against(device, &value) + self.evaluate_against(device, &value, quirks_mode) } fn evaluate_against(&self, device: &Device, - actual_value: &MediaExpressionValue) + actual_value: &MediaExpressionValue, + quirks_mode: QuirksMode) -> bool { use self::MediaExpressionValue::*; use std::cmp::Ordering; @@ -564,6 +566,8 @@ impl Expression { style: default_values.clone(), font_metrics_provider: &provider, in_media_query: true, + // TODO: pass the correct value here. + quirks_mode: quirks_mode, }; let required_value = match self.value { diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 948a87d4cf6..7ec5a4cce72 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -16,7 +16,7 @@ use app_units::Au; use atomic_refcell::AtomicRefCell; -use context::{SharedStyleContext, UpdateAnimationsTasks}; +use context::{QuirksMode, SharedStyleContext, UpdateAnimationsTasks}; use data::ElementData; use dom::{self, AnimationRules, DescendantsBit, LayoutIterator, NodeInfo, TElement, TNode, UnsafeNode}; use dom::{OpaqueNode, PresentationalHintsSynthetizer}; @@ -324,7 +324,7 @@ impl<'le> GeckoElement<'le> { /// Parse the style attribute of an element. pub fn parse_style_attribute(value: &str, url_data: &UrlExtraData) -> PropertyDeclarationBlock { - parse_style_attribute(value, url_data, &RustLogReporter) + parse_style_attribute(value, url_data, &RustLogReporter, QuirksMode::NoQuirks) } fn flags(&self) -> u32 { diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index fb8290fedf4..8113c06bb6c 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -131,7 +131,8 @@ impl Keyframe { &parent_stylesheet.url_data, &error_reporter, Some(CssRuleType::Keyframe), - LengthParsingMode::Default); + LengthParsingMode::Default, + parent_stylesheet.quirks_mode); let mut input = Parser::new(css); let mut rule_parser = KeyframeListParser { diff --git a/components/style/matching.rs b/components/style/matching.rs index 201f6c50878..01b25bcccf9 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -453,7 +453,8 @@ trait PrivateMatchMethods: TElement { Some(&mut cascade_info), &*shared_context.error_reporter, font_metrics_provider, - cascade_flags)); + cascade_flags, + shared_context.quirks_mode)); cascade_info.finish(&self.as_node()); values diff --git a/components/style/media_queries.rs b/components/style/media_queries.rs index 10a29509bd1..4f1b3d68a12 100644 --- a/components/style/media_queries.rs +++ b/components/style/media_queries.rs @@ -7,6 +7,7 @@ //! [mq]: https://drafts.csswg.org/mediaqueries/ use Atom; +use context::QuirksMode; use cssparser::{Delimiter, Parser, Token}; use parser::ParserContext; use serialize_comma_separated_list; @@ -280,7 +281,7 @@ pub fn parse_media_query_list(context: &ParserContext, input: &mut Parser) -> Me impl MediaList { /// Evaluate a whole `MediaList` against `Device`. - pub fn evaluate(&self, device: &Device) -> bool { + pub fn evaluate(&self, device: &Device, quirks_mode: QuirksMode) -> bool { // Check if it is an empty media query list or any queries match (OR condition) // https://drafts.csswg.org/mediaqueries-4/#mq-list self.media_queries.is_empty() || self.media_queries.iter().any(|mq| { @@ -290,7 +291,7 @@ impl MediaList { let query_match = media_match && mq.expressions.iter() - .all(|expression| expression.matches(&device)); + .all(|expression| expression.matches(&device, quirks_mode)); // Apply the logical NOT qualifier to the result match mq.qualifier { diff --git a/components/style/parser.rs b/components/style/parser.rs index b82d21ace4f..bac1252228a 100644 --- a/components/style/parser.rs +++ b/components/style/parser.rs @@ -6,6 +6,7 @@ #![deny(missing_docs)] +use context::QuirksMode; use cssparser::{Parser, SourcePosition, UnicodeRange}; use error_reporting::ParseErrorReporter; use style_traits::OneOrMoreCommaSeparated; @@ -44,6 +45,8 @@ pub struct ParserContext<'a> { pub line_number_offset: u64, /// The mode to use when parsing lengths. pub length_parsing_mode: LengthParsingMode, + /// The quirks mode of this stylesheet. + pub quirks_mode: QuirksMode, } impl<'a> ParserContext<'a> { @@ -52,7 +55,8 @@ impl<'a> ParserContext<'a> { url_data: &'a UrlExtraData, error_reporter: &'a ParseErrorReporter, rule_type: Option, - length_parsing_mode: LengthParsingMode) + length_parsing_mode: LengthParsingMode, + quirks_mode: QuirksMode) -> ParserContext<'a> { ParserContext { stylesheet_origin: stylesheet_origin, @@ -61,6 +65,7 @@ impl<'a> ParserContext<'a> { rule_type: rule_type, line_number_offset: 0u64, length_parsing_mode: length_parsing_mode, + quirks_mode: quirks_mode, } } @@ -68,9 +73,10 @@ impl<'a> ParserContext<'a> { pub fn new_for_cssom(url_data: &'a UrlExtraData, error_reporter: &'a ParseErrorReporter, rule_type: Option, - length_parsing_mode: LengthParsingMode) + length_parsing_mode: LengthParsingMode, + quirks_mode: QuirksMode) -> ParserContext<'a> { - Self::new(Origin::Author, url_data, error_reporter, rule_type, length_parsing_mode) + Self::new(Origin::Author, url_data, error_reporter, rule_type, length_parsing_mode, quirks_mode) } /// Create a parser context based on a previous context, but with a modified rule type. @@ -84,6 +90,7 @@ impl<'a> ParserContext<'a> { rule_type: rule_type, line_number_offset: context.line_number_offset, length_parsing_mode: context.length_parsing_mode, + quirks_mode: context.quirks_mode, } } @@ -92,7 +99,8 @@ impl<'a> ParserContext<'a> { url_data: &'a UrlExtraData, error_reporter: &'a ParseErrorReporter, line_number_offset: u64, - length_parsing_mode: LengthParsingMode) + length_parsing_mode: LengthParsingMode, + quirks_mode: QuirksMode) -> ParserContext<'a> { ParserContext { stylesheet_origin: stylesheet_origin, @@ -101,6 +109,7 @@ impl<'a> ParserContext<'a> { rule_type: None, line_number_offset: line_number_offset, length_parsing_mode: length_parsing_mode, + quirks_mode: quirks_mode, } } diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index d652ab21c96..7b53a49626a 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -6,6 +6,7 @@ #![deny(missing_docs)] +use context::QuirksMode; use cssparser::{DeclarationListParser, parse_important}; use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter}; use error_reporting::ParseErrorReporter; @@ -641,13 +642,15 @@ pub fn append_serialization<'a, W, I, N>(dest: &mut W, /// shared between Servo and Gecko. pub fn parse_style_attribute(input: &str, url_data: &UrlExtraData, - error_reporter: &ParseErrorReporter) + error_reporter: &ParseErrorReporter, + quirks_mode: QuirksMode) -> PropertyDeclarationBlock { let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style), - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); parse_property_declaration_list(&context, &mut Parser::new(input)) } @@ -660,13 +663,15 @@ pub fn parse_one_declaration(id: PropertyId, input: &str, url_data: &UrlExtraData, error_reporter: &ParseErrorReporter, - length_parsing_mode: LengthParsingMode) + length_parsing_mode: LengthParsingMode, + quirks_mode: QuirksMode) -> Result { let context = ParserContext::new(Origin::Author, url_data, error_reporter, Some(CssRuleType::Style), - length_parsing_mode); + length_parsing_mode, + quirks_mode); Parser::new(input).parse_entirely(|parser| { ParsedDeclaration::parse(id, &context, parser) .map_err(|_| ()) diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 5d13f91e282..2505d1f82d5 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -277,6 +277,7 @@ % if not property.derived_from: { let custom_props = context.style().custom_properties(); + let quirks_mode = context.quirks_mode; ::properties::substitute_variables_${property.ident}( &declared_value, &custom_props, |value| { @@ -349,7 +350,7 @@ } } } - }, error_reporter); + }, error_reporter, quirks_mode); } % if property.custom_cascade: diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index cd384da294a..6e8cefc74c5 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -515,6 +515,7 @@ impl AnimationValue { % if prop.animatable: LonghandId::${prop.camel_case} => { let mut result = None; + let quirks_mode = context.quirks_mode; ::properties::substitute_variables_${prop.ident}_slow( &variables.css, variables.first_token_type, @@ -533,7 +534,8 @@ impl AnimationValue { }; result = AnimationValue::from_declaration(&declaration, context, initial); }, - &reporter); + &reporter, + quirks_mode); result }, % else: diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index fa6ed21a33b..366ae8af469 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -21,6 +21,7 @@ use cssparser::{Parser, TokenSerializationType}; use error_reporting::ParseErrorReporter; #[cfg(feature = "servo")] use euclid::side_offsets::SideOffsets2D; use computed_values; +use context::QuirksMode; use font_metrics::FontMetricsProvider; #[cfg(feature = "gecko")] use gecko_bindings::bindings; #[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID}; @@ -327,7 +328,8 @@ impl PropertyDeclarationIdSet { % endif custom_properties: &Option>, f: F, - error_reporter: &ParseErrorReporter) + error_reporter: &ParseErrorReporter, + quirks_mode: QuirksMode) % if property.boxed: where F: FnOnce(&DeclaredValue>) % else: @@ -341,7 +343,8 @@ impl PropertyDeclarationIdSet { with_variables.from_shorthand, custom_properties, f, - error_reporter); + error_reporter, + quirks_mode); } else { f(value); } @@ -356,7 +359,8 @@ impl PropertyDeclarationIdSet { from_shorthand: Option, custom_properties: &Option>, f: F, - error_reporter: &ParseErrorReporter) + error_reporter: &ParseErrorReporter, + quirks_mode: QuirksMode) % if property.boxed: where F: FnOnce(&DeclaredValue>) % else: @@ -374,7 +378,8 @@ impl PropertyDeclarationIdSet { url_data, error_reporter, None, - LengthParsingMode::Default); + LengthParsingMode::Default, + quirks_mode); Parser::new(&css).parse_entirely(|input| { match from_shorthand { None => { @@ -2114,7 +2119,8 @@ pub fn cascade(device: &Device, cascade_info: Option<<&mut CascadeInfo>, error_reporter: &ParseErrorReporter, font_metrics_provider: &FontMetricsProvider, - flags: CascadeFlags) + flags: CascadeFlags, + quirks_mode: QuirksMode) -> ComputedValues { debug_assert_eq!(parent_style.is_some(), layout_parent_style.is_some()); let (is_root_element, inherited_style, layout_parent_style) = match parent_style { @@ -2159,7 +2165,8 @@ pub fn cascade(device: &Device, cascade_info, error_reporter, font_metrics_provider, - flags) + flags, + quirks_mode) } /// NOTE: This function expects the declaration with more priority to appear @@ -2173,7 +2180,8 @@ pub fn apply_declarations<'a, F, I>(device: &Device, mut cascade_info: Option<<&mut CascadeInfo>, error_reporter: &ParseErrorReporter, font_metrics_provider: &FontMetricsProvider, - flags: CascadeFlags) + flags: CascadeFlags, + quirks_mode: QuirksMode) -> ComputedValues where F: Fn() -> I, I: Iterator, @@ -2226,6 +2234,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device, style: starting_style, font_metrics_provider: font_metrics_provider, in_media_query: false, + quirks_mode: quirks_mode, }; // Set computed values, overwriting earlier declarations for the same diff --git a/components/style/servo/media_queries.rs b/components/style/servo/media_queries.rs index c2ff1cb828d..4756d5bb705 100644 --- a/components/style/servo/media_queries.rs +++ b/components/style/servo/media_queries.rs @@ -5,6 +5,7 @@ //! Servo's media-query device and expression representation. use app_units::Au; +use context::QuirksMode; use cssparser::Parser; use euclid::{Size2D, TypedSize2D}; use font_metrics::ServoMetricsProvider; @@ -128,12 +129,12 @@ impl Expression { /// Evaluate this expression and return whether it matches the current /// device. - pub fn matches(&self, device: &Device) -> bool { + pub fn matches(&self, device: &Device, quirks_mode: QuirksMode) -> bool { let viewport_size = device.au_viewport_size(); let value = viewport_size.width; match self.0 { ExpressionKind::Width(ref range) => { - match range.to_computed_range(device) { + match range.to_computed_range(device, quirks_mode) { Range::Min(ref width) => { value >= *width }, Range::Max(ref width) => { value <= *width }, Range::Eq(ref width) => { value == *width }, @@ -175,7 +176,7 @@ pub enum Range { } impl Range { - fn to_computed_range(&self, device: &Device) -> Range { + fn to_computed_range(&self, device: &Device, quirks_mode: QuirksMode) -> Range { let default_values = device.default_computed_values(); // http://dev.w3.org/csswg/mediaqueries3/#units // em units are relative to the initial font-size. @@ -192,6 +193,7 @@ impl Range { // ch units can exist in media queries. font_metrics_provider: &ServoMetricsProvider, in_media_query: true, + quirks_mode: quirks_mode, }; match *self { diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 9986328cb00..97dfce4c51f 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -7,6 +7,7 @@ #![deny(missing_docs)] use {Atom, Prefix, Namespace}; +use context::QuirksMode; use counter_style::{CounterStyleRule, parse_counter_style_name, parse_counter_style_body}; use cssparser::{AtRuleParser, Parser, QualifiedRuleParser}; use cssparser::{AtRuleType, RuleListParser, parse_one_rule}; @@ -263,6 +264,8 @@ pub struct Stylesheet { pub dirty_on_viewport_size_change: AtomicBool, /// Whether this stylesheet should be disabled. pub disabled: AtomicBool, + /// The quirks mode of this stylesheet. + pub quirks_mode: QuirksMode, } @@ -415,7 +418,8 @@ impl CssRule { &parent_stylesheet.url_data, &error_reporter, None, - LengthParsingMode::Default); + LengthParsingMode::Default, + parent_stylesheet.quirks_mode); let mut input = Parser::new(css); // nested rules are in the body state @@ -663,7 +667,7 @@ impl Stylesheet { let (rules, dirty_on_viewport_size_change) = Stylesheet::parse_rules( css, url_data, existing.origin, &mut namespaces, &existing.shared_lock, stylesheet_loader, error_reporter, - 0u64); + existing.quirks_mode, 0u64); *existing.namespaces.write() = namespaces; existing.dirty_on_viewport_size_change @@ -681,6 +685,7 @@ impl Stylesheet { shared_lock: &SharedRwLock, stylesheet_loader: Option<&StylesheetLoader>, error_reporter: &ParseErrorReporter, + quirks_mode: QuirksMode, line_number_offset: u64) -> (Vec, bool) { let mut rules = Vec::new(); @@ -691,7 +696,8 @@ impl Stylesheet { shared_lock: shared_lock, loader: stylesheet_loader, context: ParserContext::new_with_line_number_offset(origin, url_data, error_reporter, - line_number_offset, LengthParsingMode::Default), + line_number_offset, LengthParsingMode::Default, + quirks_mode), state: Cell::new(State::Start), }; @@ -726,11 +732,13 @@ impl Stylesheet { shared_lock: SharedRwLock, stylesheet_loader: Option<&StylesheetLoader>, error_reporter: &ParseErrorReporter, - line_number_offset: u64) -> Stylesheet { + quirks_mode: QuirksMode, + line_number_offset: u64) + -> Stylesheet { let mut namespaces = Namespaces::default(); let (rules, dirty_on_viewport_size_change) = Stylesheet::parse_rules( css, &url_data, origin, &mut namespaces, - &shared_lock, stylesheet_loader, error_reporter, line_number_offset + &shared_lock, stylesheet_loader, error_reporter, quirks_mode, line_number_offset, ); Stylesheet { origin: origin, @@ -741,6 +749,7 @@ impl Stylesheet { shared_lock: shared_lock, dirty_on_viewport_size_change: AtomicBool::new(dirty_on_viewport_size_change), disabled: AtomicBool::new(false), + quirks_mode: quirks_mode, } } @@ -769,7 +778,7 @@ impl Stylesheet { /// /// Always true if no associated MediaList exists. pub fn is_effective_for_device(&self, device: &Device, guard: &SharedRwLockReadGuard) -> bool { - self.media.read_with(guard).evaluate(device) + self.media.read_with(guard).evaluate(device, self.quirks_mode) } /// Return an iterator over the effective rules within the style-sheet, as @@ -781,7 +790,7 @@ impl Stylesheet { #[inline] pub fn effective_rules(&self, device: &Device, guard: &SharedRwLockReadGuard, mut f: F) where F: FnMut(&CssRule) { - effective_rules(&self.rules.read_with(guard).0, device, guard, &mut f); + effective_rules(&self.rules.read_with(guard).0, device, self.quirks_mode, guard, &mut f); } /// Returns whether the stylesheet has been explicitly disabled through the @@ -802,17 +811,22 @@ impl Stylesheet { } } -fn effective_rules(rules: &[CssRule], device: &Device, guard: &SharedRwLockReadGuard, f: &mut F) -where F: FnMut(&CssRule) { +fn effective_rules(rules: &[CssRule], + device: &Device, + quirks_mode: QuirksMode, + guard: &SharedRwLockReadGuard, + f: &mut F) + where F: FnMut(&CssRule) +{ for rule in rules { f(rule); rule.with_nested_rules_and_mq(guard, |rules, mq| { if let Some(media_queries) = mq { - if !media_queries.evaluate(device) { + if !media_queries.evaluate(device, quirks_mode) { return } } - effective_rules(rules, device, guard, f) + effective_rules(rules, device, quirks_mode, guard, f) }) } } @@ -973,6 +987,7 @@ impl<'a> AtRuleParser for TopLevelRuleParser<'a> { namespaces: RwLock::new(Namespaces::default()), dirty_on_viewport_size_change: AtomicBool::new(false), disabled: AtomicBool::new(false), + quirks_mode: self.context.quirks_mode, }) } }, &mut |import_rule| { diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 190226bb0cc..630fbd6d995 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -240,7 +240,7 @@ impl Stylist { }; self.viewport_constraints = - ViewportConstraints::maybe_new(&self.device, &cascaded_rule); + ViewportConstraints::maybe_new(&self.device, &cascaded_rule, self.quirks_mode); if let Some(ref constraints) = self.viewport_constraints { Arc::get_mut(&mut self.device).unwrap() @@ -418,7 +418,8 @@ impl Stylist { None, &RustLogReporter, font_metrics, - cascade_flags); + cascade_flags, + self.quirks_mode); ComputedStyle::new(rule_node, Arc::new(computed)) } @@ -536,7 +537,8 @@ impl Stylist { None, &RustLogReporter, font_metrics, - CascadeFlags::empty()); + CascadeFlags::empty(), + self.quirks_mode); Some(ComputedStyle::new(rule_node, Arc::new(computed))) } @@ -569,22 +571,22 @@ impl Stylist { }; self.viewport_constraints = - ViewportConstraints::maybe_new(&device, &cascaded_rule); + ViewportConstraints::maybe_new(&device, &cascaded_rule, self.quirks_mode); if let Some(ref constraints) = self.viewport_constraints { device.account_for_viewport_rule(constraints); } fn mq_eval_changed(guard: &SharedRwLockReadGuard, rules: &[CssRule], - before: &Device, after: &Device) -> bool { + before: &Device, after: &Device, quirks_mode: QuirksMode) -> bool { for rule in rules { let changed = rule.with_nested_rules_and_mq(guard, |rules, mq| { if let Some(mq) = mq { - if mq.evaluate(before) != mq.evaluate(after) { + if mq.evaluate(before, quirks_mode) != mq.evaluate(after, quirks_mode) { return true } } - mq_eval_changed(guard, rules, before, after) + mq_eval_changed(guard, rules, before, after, quirks_mode) }); if changed { return true @@ -594,11 +596,11 @@ impl Stylist { } self.is_device_dirty |= stylesheets.iter().any(|stylesheet| { let mq = stylesheet.media.read_with(guard); - if mq.evaluate(&self.device) != mq.evaluate(&device) { + if mq.evaluate(&self.device, self.quirks_mode) != mq.evaluate(&device, self.quirks_mode) { return true } - mq_eval_changed(guard, &stylesheet.rules.read_with(guard).0, &self.device, &device) + mq_eval_changed(guard, &stylesheet.rules.read_with(guard).0, &self.device, &device, self.quirks_mode) }); self.device = Arc::new(device); @@ -866,7 +868,8 @@ impl Stylist { None, &RustLogReporter, &metrics, - CascadeFlags::empty())) + CascadeFlags::empty(), + self.quirks_mode)) } } diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 85a8ba19368..3e2ff2ceb89 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -4,6 +4,7 @@ //! Computed values. +use context::QuirksMode; use euclid::size::Size2D; use font_metrics::FontMetricsProvider; use media_queries::Device; @@ -63,6 +64,9 @@ pub struct Context<'a> { /// Whether or not we are computing the media list in a media query pub in_media_query: bool, + + /// The quirks mode of this context. + pub quirks_mode: QuirksMode, } impl<'a> Context<'a> { diff --git a/components/style/viewport.rs b/components/style/viewport.rs index 4c05ff52107..90811fa8549 100644 --- a/components/style/viewport.rs +++ b/components/style/viewport.rs @@ -10,6 +10,7 @@ #![deny(missing_docs)] use app_units::Au; +use context::QuirksMode; use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important}; use cssparser::ToCss as ParserToCss; use euclid::size::TypedSize2D; @@ -588,13 +589,15 @@ pub trait MaybeNew { /// Create a ViewportConstraints from a viewport size and a `@viewport` /// rule. fn maybe_new(device: &Device, - rule: &ViewportRule) + rule: &ViewportRule, + quirks_mode: QuirksMode) -> Option; } impl MaybeNew for ViewportConstraints { fn maybe_new(device: &Device, - rule: &ViewportRule) + rule: &ViewportRule, + quirks_mode: QuirksMode) -> Option { use std::cmp; @@ -684,6 +687,7 @@ impl MaybeNew for ViewportConstraints { style: device.default_computed_values().clone(), font_metrics_provider: &provider, in_media_query: false, + quirks_mode: quirks_mode, }; // DEVICE-ADAPT § 9.3 Resolving 'extend-to-zoom' diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 7e463db9d13..f9dadbfb7f1 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -511,7 +511,7 @@ pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyl Arc::new(Stylesheet::from_str( "", unsafe { dummy_url_data() }.clone(), origin, Arc::new(shared_lock.wrap(MediaList::empty())), - shared_lock, None, &RustLogReporter, 0u64) + shared_lock, None, &RustLogReporter, QuirksMode::NoQuirks, Wh0u64) ).into_strong() } @@ -554,7 +554,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader, Arc::new(Stylesheet::from_str( input, url_data.clone(), origin, media, - shared_lock, loader, &RustLogReporter, 0u64) + shared_lock, loader, &RustLogReporter, QuirksMode::NoQuirks, 0u64) ).into_strong() } @@ -1007,7 +1007,8 @@ pub extern "C" fn Servo_ParseProperty(property: nsCSSPropertyID, value: *const n let url_data = unsafe { RefPtr::from_ptr_ref(&data) }; let reporter = RustLogReporter; let context = ParserContext::new(Origin::Author, url_data, &reporter, - Some(CssRuleType::Style), LengthParsingMode::Default); + Some(CssRuleType::Style), LengthParsingMode::Default, + QuirksMode::NoQuirks); match ParsedDeclaration::parse(id, &context, &mut Parser::new(value)) { Ok(parsed) => { @@ -1030,7 +1031,8 @@ pub extern "C" fn Servo_ParseEasing(easing: *const nsAString, let url_data = unsafe { RefPtr::from_ptr_ref(&data) }; let reporter = RustLogReporter; let context = ParserContext::new(Origin::Author, url_data, &reporter, - Some(CssRuleType::Style), LengthParsingMode::Default); + Some(CssRuleType::Style), LengthParsingMode::Default, + QuirksMode::NoQuirks); let easing = unsafe { (*easing).to_string() }; match transition_timing_function::single_value::parse(&context, &mut Parser::new(&easing)) { Ok(parsed_easing) => { @@ -1171,7 +1173,7 @@ fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: Pro structs::LengthParsingMode::SVG => LengthParsingMode::SVG, }; if let Ok(parsed) = parse_one_declaration(property_id, value, url_data, &RustLogReporter, - length_parsing_mode) { + length_parsing_mode, QuirksMode::NoQuirks) { let importance = if is_important { Importance::Important } else { Importance::Normal }; write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| { parsed.expand_set_into(decls, importance) @@ -1238,7 +1240,7 @@ pub extern "C" fn Servo_MediaList_Matches(list: RawServoMediaListBorrowed, -> bool { let per_doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow(); read_locked_arc(list, |list: &MediaList| { - list.evaluate(&per_doc_data.stylist.device) + list.evaluate(&per_doc_data.stylist.device, QuirksMode::NoQuirks) }) } @@ -1265,7 +1267,8 @@ pub extern "C" fn Servo_MediaList_SetText(list: RawServoMediaListBorrowed, text: let url_data = unsafe { dummy_url_data() }; let reporter = RustLogReporter; let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); write_locked_arc(list, |list: &mut MediaList| { *list = parse_media_query_list(&context, &mut parser); }) @@ -1296,7 +1299,8 @@ pub extern "C" fn Servo_MediaList_AppendMedium(list: RawServoMediaListBorrowed, let url_data = unsafe { dummy_url_data() }; let reporter = RustLogReporter; let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); write_locked_arc(list, |list: &mut MediaList| { list.append_medium(&context, new_medium); }) @@ -1309,7 +1313,8 @@ pub extern "C" fn Servo_MediaList_DeleteMedium(list: RawServoMediaListBorrowed, let url_data = unsafe { dummy_url_data() }; let reporter = RustLogReporter; let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); write_locked_arc(list, |list: &mut MediaList| list.delete_medium(&context, old_medium)) } @@ -1662,7 +1667,8 @@ pub extern "C" fn Servo_DeclarationBlock_SetBackgroundImage(declarations: let string = unsafe { (*value).to_string() }; let error_reporter = RustLogReporter; let context = ParserContext::new(Origin::Author, url_data, &error_reporter, - Some(CssRuleType::Style), LengthParsingMode::Default); + Some(CssRuleType::Style), LengthParsingMode::Default, + QuirksMode::NoQuirks); if let Ok(url) = SpecifiedUrl::parse_from_string(string.into(), &context) { let decl = PropertyDeclaration::BackgroundImage(BackgroundImage( vec![SingleBackgroundImage( @@ -1700,7 +1706,12 @@ pub extern "C" fn Servo_CSSSupports2(property: *const nsACString, value: *const let value = unsafe { value.as_ref().unwrap().as_str_unchecked() }; let url_data = unsafe { dummy_url_data() }; - parse_one_declaration(id, &value, url_data, &RustLogReporter, LengthParsingMode::Default).is_ok() + parse_one_declaration(id, + &value, + url_data, + &RustLogReporter, + LengthParsingMode::Default, + QuirksMode::NoQuirks).is_ok() } #[no_mangle] @@ -1712,7 +1723,8 @@ pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool { let url_data = unsafe { dummy_url_data() }; let reporter = RustLogReporter; let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Style), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); cond.eval(&context) } else { false @@ -1944,6 +1956,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis style: (**style).clone(), font_metrics_provider: &metrics, in_media_query: false, + quirks_mode: QuirksMode::NoQuirks, }; for (index, keyframe) in keyframes.iter().enumerate() { diff --git a/tests/unit/style/media_queries.rs b/tests/unit/style/media_queries.rs index f256d296c9f..10634a6f134 100644 --- a/tests/unit/style/media_queries.rs +++ b/tests/unit/style/media_queries.rs @@ -8,6 +8,7 @@ use servo_url::ServoUrl; use std::borrow::ToOwned; use std::sync::Arc; use style::Atom; +use style::context::QuirksMode; use style::error_reporting::ParseErrorReporter; use style::media_queries::*; use style::servo::media_queries::*; @@ -37,7 +38,7 @@ fn test_media_rule(css: &str, callback: F) let media_list = Arc::new(lock.wrap(MediaList::empty())); let stylesheet = Stylesheet::from_str( css, url, Origin::Author, media_list, lock, - None, &CSSErrorReporterTest, 0u64); + None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0u64); let mut rule_count = 0; let guard = stylesheet.shared_lock.read(); media_queries(&guard, &stylesheet.rules.read_with(&guard).0, &mut |mq| { @@ -66,7 +67,7 @@ fn media_query_test(device: &Device, css: &str, expected_rule_count: usize) { let media_list = Arc::new(lock.wrap(MediaList::empty())); let ss = Stylesheet::from_str( css, url, Origin::Author, media_list, lock, - None, &CSSErrorReporterTest, 0u64); + None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0u64); let mut rule_count = 0; ss.effective_style_rules(device, &ss.shared_lock.read(), |_| rule_count += 1); assert!(rule_count == expected_rule_count, css.to_owned()); diff --git a/tests/unit/style/parsing/image.rs b/tests/unit/style/parsing/image.rs index 78a6b04eed9..158f99aaa4e 100644 --- a/tests/unit/style/parsing/image.rs +++ b/tests/unit/style/parsing/image.rs @@ -5,6 +5,7 @@ use euclid::size::TypedSize2D; use parsing::parse; use std::f32::consts::PI; +use style::context::QuirksMode; use style::font_metrics::ServoMetricsProvider; use style::media_queries::{Device, MediaType}; use style::properties::ComputedValues; @@ -51,6 +52,7 @@ fn test_linear_gradient() { style: initial_style.clone(), font_metrics_provider: &ServoMetricsProvider, in_media_query: false, + quirks_mode: QuirksMode::NoQuirks, }; assert_eq!(specified::AngleOrCorner::None.to_computed_value(&specified_context), computed::AngleOrCorner::Angle(Angle::from_radians(PI))); diff --git a/tests/unit/style/parsing/length.rs b/tests/unit/style/parsing/length.rs index ad0b77d2e01..b6d9a30b42c 100644 --- a/tests/unit/style/parsing/length.rs +++ b/tests/unit/style/parsing/length.rs @@ -5,6 +5,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; use parsing::parse; +use style::context::QuirksMode; use style::parser::{LengthParsingMode, Parse, ParserContext}; use style::stylesheets::{CssRuleType, Origin}; use style::values::specified::length::{AbsoluteLength, Length, NoCalcLength}; @@ -38,7 +39,8 @@ fn test_length_parsing_modes() { let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; let context = ParserContext::new(Origin::Author, &url, &reporter, - Some(CssRuleType::Style), LengthParsingMode::SVG); + Some(CssRuleType::Style), LengthParsingMode::SVG, + QuirksMode::NoQuirks); let mut parser = Parser::new("1"); let result = Length::parse(&context, &mut parser); assert!(result.is_ok()); diff --git a/tests/unit/style/parsing/mod.rs b/tests/unit/style/parsing/mod.rs index 79efb4a3484..6ba2043bd95 100644 --- a/tests/unit/style/parsing/mod.rs +++ b/tests/unit/style/parsing/mod.rs @@ -6,6 +6,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; +use style::context::QuirksMode; use style::parser::{LengthParsingMode, ParserContext}; use style::stylesheets::{CssRuleType, Origin}; @@ -13,7 +14,8 @@ fn parse Result>(f: F, s: &str) let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); let mut parser = Parser::new(s); f(&context, &mut parser) } diff --git a/tests/unit/style/properties/mod.rs b/tests/unit/style/properties/mod.rs index 68aae4dacca..747b0bd6571 100644 --- a/tests/unit/style/properties/mod.rs +++ b/tests/unit/style/properties/mod.rs @@ -4,6 +4,7 @@ use cssparser::Parser; use media_queries::CSSErrorReporterTest; +use style::context::QuirksMode; use style::parser::{LengthParsingMode, ParserContext}; use style::stylesheets::{CssRuleType, Origin}; @@ -11,7 +12,8 @@ fn parse Result>(f: F, s: &str) let url = ::servo_url::ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Style), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); let mut parser = Parser::new(s); f(&context, &mut parser) } diff --git a/tests/unit/style/rule_tree/bench.rs b/tests/unit/style/rule_tree/bench.rs index 96b63cfe2fb..ed73bd11d6f 100644 --- a/tests/unit/style/rule_tree/bench.rs +++ b/tests/unit/style/rule_tree/bench.rs @@ -6,6 +6,7 @@ use cssparser::{Parser, SourcePosition}; use rayon; use servo_url::ServoUrl; use std::sync::Arc; +use style::context::QuirksMode; use style::error_reporting::ParseErrorReporter; use style::media_queries::MediaList; use style::properties::{longhands, Importance, PropertyDeclaration, PropertyDeclarationBlock}; @@ -58,6 +59,7 @@ fn parse_rules(css: &str) -> Vec<(StyleSource, CascadeLevel)> { lock, None, &ErrorringErrorReporter, + QuirksMode::NoQuirks, 0u64); let guard = s.shared_lock.read(); let rules = s.rules.read_with(&guard); diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index dd1762ee686..47aa1ea9730 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -13,6 +13,7 @@ use std::borrow::ToOwned; use std::sync::Arc; use std::sync::Mutex; use std::sync::atomic::AtomicBool; +use style::context::QuirksMode; use style::error_reporting::ParseErrorReporter; use style::keyframes::{Keyframe, KeyframeSelector, KeyframePercentage}; use style::media_queries::MediaList; @@ -66,7 +67,7 @@ fn test_parse_stylesheet() { let lock = SharedRwLock::new(); let media = Arc::new(lock.wrap(MediaList::empty())); let stylesheet = Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock, - None, &CSSErrorReporterTest, 0u64); + None, &CSSErrorReporterTest, QuirksMode::NoQuirks, 0u64); let mut namespaces = Namespaces::default(); namespaces.default = Some(ns!(html)); let expected = Stylesheet { @@ -77,6 +78,7 @@ fn test_parse_stylesheet() { url_data: url, dirty_on_viewport_size_change: AtomicBool::new(false), disabled: AtomicBool::new(false), + quirks_mode: QuirksMode::NoQuirks, rules: CssRules::new(vec![ CssRule::Namespace(Arc::new(stylesheet.shared_lock.wrap(NamespaceRule { prefix: None, @@ -316,7 +318,7 @@ fn test_report_error_stylesheet() { let lock = SharedRwLock::new(); let media = Arc::new(lock.wrap(MediaList::empty())); Stylesheet::from_str(css, url.clone(), Origin::UserAgent, media, lock, - None, &error_reporter, 5u64); + None, &error_reporter, QuirksMode::NoQuirks, 5u64); let mut errors = errors.lock().unwrap(); diff --git a/tests/unit/style/viewport.rs b/tests/unit/style/viewport.rs index 150546ee588..fb29e87debf 100644 --- a/tests/unit/style/viewport.rs +++ b/tests/unit/style/viewport.rs @@ -8,6 +8,7 @@ use media_queries::CSSErrorReporterTest; use servo_config::prefs::{PREFS, PrefValue}; use servo_url::ServoUrl; use std::sync::Arc; +use style::context::QuirksMode; use style::media_queries::{Device, MediaList, MediaType}; use style::parser::{LengthParsingMode, Parse, ParserContext}; use style::shared_lock::SharedRwLock; @@ -32,6 +33,7 @@ macro_rules! stylesheet { $shared_lock, None, &$error_reporter, + QuirksMode::NoQuirks, 0u64 )) } @@ -293,7 +295,8 @@ fn constrain_viewport() { let url = ServoUrl::parse("http://localhost").unwrap(); let reporter = CSSErrorReporterTest; let context = ParserContext::new(Origin::Author, &url, &reporter, Some(CssRuleType::Viewport), - LengthParsingMode::Default); + LengthParsingMode::Default, + QuirksMode::NoQuirks); macro_rules! from_css { ($css:expr) => { @@ -303,9 +306,9 @@ fn constrain_viewport() { let initial_viewport = TypedSize2D::new(800., 600.); let device = Device::new(MediaType::Screen, initial_viewport); - assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("")), None); + assert_eq!(ViewportConstraints::maybe_new(&device, from_css!(""), QuirksMode::NoQuirks), None); - assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto")), + assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto"), QuirksMode::NoQuirks), Some(ViewportConstraints { size: initial_viewport, @@ -317,7 +320,7 @@ fn constrain_viewport() { orientation: Orientation::Auto })); - assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto")), + assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto"), QuirksMode::NoQuirks), Some(ViewportConstraints { size: initial_viewport, @@ -329,10 +332,12 @@ fn constrain_viewport() { orientation: Orientation::Auto })); - assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 800px; height: 600px;\ - zoom: 1;\ - user-zoom: zoom;\ - orientation: auto;")), + assert_eq!(ViewportConstraints::maybe_new(&device, + from_css!("width: 800px; height: 600px;\ + zoom: 1;\ + user-zoom: zoom;\ + orientation: auto;"), + QuirksMode::NoQuirks), Some(ViewportConstraints { size: initial_viewport, @@ -346,7 +351,7 @@ fn constrain_viewport() { let initial_viewport = TypedSize2D::new(200., 150.); let device = Device::new(MediaType::Screen, initial_viewport); - assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto")), + assert_eq!(ViewportConstraints::maybe_new(&device, from_css!("width: 320px auto"), QuirksMode::NoQuirks), Some(ViewportConstraints { size: TypedSize2D::new(320., 240.), From 080f74ca637047e273f6fdc95e269c897b46915c Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 11:24:43 +0200 Subject: [PATCH 05/22] Implement the unitless length quirk for background-position --- .../properties/shorthand/background.mako.rs | 4 +-- components/style/values/specified/length.rs | 35 ++++++++++++------- components/style/values/specified/mod.rs | 17 +++++++++ components/style/values/specified/position.rs | 31 +++++++++++++--- 4 files changed, 68 insertions(+), 19 deletions(-) diff --git a/components/style/properties/shorthand/background.mako.rs b/components/style/properties/shorthand/background.mako.rs index 8eaa94772f1..ab19507702f 100644 --- a/components/style/properties/shorthand/background.mako.rs +++ b/components/style/properties/shorthand/background.mako.rs @@ -194,8 +194,8 @@ sub_properties="background-position-x background-position-y" spec="https://drafts.csswg.org/css-backgrounds-4/#the-background-position"> use properties::longhands::{background_position_x,background_position_y}; + use values::specified::AllowQuirks; use values::specified::position::Position; - use parser::Parse; pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { let mut position_x = background_position_x::SpecifiedValue(Vec::new()); @@ -204,7 +204,7 @@ try!(input.parse_comma_separated(|input| { loop { - if let Ok(value) = input.try(|input| Position::parse(context, input)) { + if let Ok(value) = input.try(|input| Position::parse_quirky(context, input, AllowQuirks::Yes)) { position_x.0.push(value.horizontal); position_y.0.push(value.vertical); any = true; diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index ff8bdaa548e..e161b5fc589 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -17,7 +17,7 @@ use std::ops::Mul; use style_traits::ToCss; use style_traits::values::specified::AllowedLengthType; use stylesheets::CssRuleType; -use super::{Angle, Number, SimplifiedValueNode, SimplifiedSumNode, Time, ToComputedValue}; +use super::{AllowQuirks, Angle, Number, SimplifiedValueNode, SimplifiedSumNode, Time, ToComputedValue}; use values::{Auto, CSSFloat, Either, FONT_MEDIUM_PX, HasViewportPercentage, None_, Normal}; use values::ExtremumLength; use values::computed::{ComputedValueAsSpecified, Context}; @@ -1154,7 +1154,10 @@ impl LengthOrPercentage { LengthOrPercentage::Length(NoCalcLength::zero()) } - fn parse_internal(context: &ParserContext, input: &mut Parser, num_context: AllowedLengthType) + fn parse_internal(context: &ParserContext, + input: &mut Parser, + num_context: AllowedLengthType, + allow_quirks: AllowQuirks) -> Result { match try!(input.next()) { @@ -1162,12 +1165,9 @@ impl LengthOrPercentage { NoCalcLength::parse_dimension(context, value.value, unit).map(LengthOrPercentage::Length), Token::Percentage(ref value) if num_context.is_ok(value.unit_value) => Ok(LengthOrPercentage::Percentage(Percentage(value.unit_value))), - Token::Number(ref value) => { - if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() { - return Err(()) - } - Ok(LengthOrPercentage::Length(NoCalcLength::Absolute(AbsoluteLength::Px(value.value)))) - } + Token::Number(value) if value.value == 0. || + (num_context.is_ok(value.value) && allow_quirks.allowed(context.quirks_mode)) => + Ok(LengthOrPercentage::Length(NoCalcLength::from_px(value.value))), Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => { let calc = try!(input.parse_nested_block(|i| { CalcLengthOrPercentage::parse_length_or_percentage(context, i) @@ -1181,14 +1181,14 @@ impl LengthOrPercentage { /// Parse a non-negative length. #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative) + Self::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No) } /// Parse a length, treating dimensionless numbers as pixels /// /// https://www.w3.org/TR/SVG2/types.html#presentation-attribute-css-value pub fn parse_numbers_are_pixels(context: &ParserContext, input: &mut Parser) -> Result { - if let Ok(lop) = input.try(|i| Self::parse_internal(context, i, AllowedLengthType::All)) { + if let Ok(lop) = input.try(|i| Self::parse(context, i)) { return Ok(lop) } @@ -1204,7 +1204,7 @@ impl LengthOrPercentage { pub fn parse_numbers_are_pixels_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - if let Ok(lop) = input.try(|i| Self::parse_internal(context, i, AllowedLengthType::NonNegative)) { + if let Ok(lop) = input.try(|i| Self::parse_non_negative(context, i)) { return Ok(lop) } @@ -1230,7 +1230,18 @@ impl LengthOrPercentage { impl Parse for LengthOrPercentage { #[inline] fn parse(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::All) + Self::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl LengthOrPercentage { + /// Parses a length or a percentage, allowing the unitless length quirk. + /// https://quirks.spec.whatwg.org/#the-unitless-length-quirk + #[inline] + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { + Self::parse_internal(context, input, AllowedLengthType::All, allow_quirks) } } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index b610401ac32..6519613bf6b 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -7,6 +7,7 @@ //! TODO(emilio): Enhance docs. use app_units::Au; +use context::QuirksMode; use cssparser::{self, Parser, Token}; use euclid::size::Size2D; use parser::{ParserContext, Parse}; @@ -1326,3 +1327,19 @@ pub type ClipRectOrAuto = Either; /// | auto pub type ColorOrAuto = Either; + +/// Whether quirks are allowed in this context. +#[derive(Clone, Copy, PartialEq)] +pub enum AllowQuirks { + /// Quirks are allowed. + Yes, + /// Quirks are not allowed. + No, +} + +impl AllowQuirks { + /// Returns `true` if quirks are allowed in this context. + pub fn allowed(self, quirks_mode: QuirksMode) -> bool { + self == AllowQuirks::Yes && quirks_mode == QuirksMode::Quirks + } +} diff --git a/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index f8501e870c2..dfa05b36609 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -19,7 +19,7 @@ use values::computed::position as computed_position; use values::generics::position::{Position as GenericPosition, PositionValue, PositionWithKeyword}; use values::generics::position::HorizontalPosition as GenericHorizontalPosition; use values::generics::position::VerticalPosition as GenericVerticalPosition; -use values::specified::{LengthOrPercentage, Percentage}; +use values::specified::{AllowQuirks, LengthOrPercentage, Percentage}; pub use values::generics::position::Keyword; @@ -132,13 +132,23 @@ impl Position { impl Parse for Position { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - let first = input.try(|i| PositionComponent::parse(context, i))?; - let second = input.try(|i| PositionComponent::parse(context, i)) + Position::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl Position { + /// Parses, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + let first = input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks))?; + let second = input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) .unwrap_or(Either::Second(Keyword::Center)); - if let Ok(third) = input.try(|i| PositionComponent::parse(context, i)) { + if let Ok(third) = input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) { // There's a 3rd value. - if let Ok(fourth) = input.try(|i| PositionComponent::parse(context, i)) { + if let Ok(fourth) = input.try(|i| PositionComponent::parse_quirky(context, i, allow_quirks)) { // There's a 4th value. Position::from_components(Some(second), Some(fourth), Some(first), Some(third)) } else { @@ -173,6 +183,17 @@ impl Parse for Position { } } +impl PositionComponent { + /// Parses, with quirks. + fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { + input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) + .map(Either::First) + .or_else(|()| input.try(Keyword::parse).map(Either::Second)) + } +} + impl PositionValue { /// Generic function for the computed value of a position. fn computed_value(&self, context: &Context) -> ComputedLengthOrPercentage { From 03d24e8361a94d6a6ce03e599a41f4f9f5fc04a4 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 11:48:00 +0200 Subject: [PATCH 06/22] Implement the unitless length quirk for border-spacing --- .../longhand/inherited_table.mako.rs | 9 ++++--- components/style/values/specified/length.rs | 25 ++++++++++++++----- .../quirks-mode/unitless-length.html.ini | 21 ---------------- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhand/inherited_table.mako.rs index 3069482976e..e464d9433f6 100644 --- a/components/style/properties/longhand/inherited_table.mako.rs +++ b/components/style/properties/longhand/inherited_table.mako.rs @@ -26,6 +26,7 @@ ${helpers.single_keyword("caption-side", "top bottom", use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; + use values::specified::{AllowQuirks, Length}; pub mod computed_value { use app_units::Au; @@ -60,8 +61,8 @@ ${helpers.single_keyword("caption-side", "top bottom", #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue { - pub horizontal: specified::Length, - pub vertical: Option, + pub horizontal: Length, + pub vertical: Option, } #[inline] @@ -117,11 +118,11 @@ ${helpers.single_keyword("caption-side", "top bottom", pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { let mut first = None; let mut second = None; - match specified::Length::parse_non_negative(context, input) { + match Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes) { Err(()) => (), Ok(length) => { first = Some(length); - if let Ok(len) = input.try(|input| specified::Length::parse_non_negative(context, input)) { + if let Ok(len) = input.try(|i| Length::parse_non_negative_quirky(context, i, AllowQuirks::Yes)) { second = Some(len); } } diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index e161b5fc589..424e6553279 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -563,13 +563,17 @@ impl Length { } #[inline] - fn parse_internal(context: &ParserContext, input: &mut Parser, num_context: AllowedLengthType) + fn parse_internal(context: &ParserContext, + input: &mut Parser, + num_context: AllowedLengthType, + allow_quirks: AllowQuirks) -> Result { match try!(input.next()) { Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) => Length::parse_dimension(context, value.value, unit), - Token::Number(ref value) => { - if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() { + Token::Number(ref value) if num_context.is_ok(value.value) => { + if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() && + !allow_quirks.allowed(context.quirks_mode) { return Err(()) } Ok(Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(value.value)))) @@ -585,7 +589,16 @@ impl Length { /// Parse a non-negative length #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative) + Self::parse_non_negative_quirky(context, input, AllowQuirks::No) + } + + /// Parse a non-negative length, allowing quirks. + #[inline] + pub fn parse_non_negative_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + Self::parse_internal(context, input, AllowedLengthType::NonNegative, allow_quirks) } /// Get an absolute length from a px value. @@ -605,7 +618,7 @@ impl Length { impl Parse for Length { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::All) + Self::parse_internal(context, input, AllowedLengthType::All, AllowQuirks::No) } } @@ -616,7 +629,7 @@ impl Either { if let Ok(v) = input.try(|input| T::parse(context, input)) { return Ok(Either::Second(v)); } - Length::parse_internal(context, input, AllowedLengthType::NonNegative).map(Either::First) + Length::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No).map(Either::First) } } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 9b8f785c3ce..2be0a018e45 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -1,8 +1,5 @@ [unitless-length.html] type: testharness - [border-spacing: 1 (quirks)] - expected: FAIL - [border-top-width: 1 (quirks)] expected: FAIL @@ -102,9 +99,6 @@ [word-spacing: 1 (quirks)] expected: FAIL - [border-spacing: +1 (quirks)] - expected: FAIL - [border-top-width: +1 (quirks)] expected: FAIL @@ -255,9 +249,6 @@ [word-spacing: -1 (quirks)] expected: FAIL - [border-spacing: 1.5 (quirks)] - expected: FAIL - [border-top-width: 1.5 (quirks)] expected: FAIL @@ -357,9 +348,6 @@ [word-spacing: 1.5 (quirks)] expected: FAIL - [border-spacing: +1.5 (quirks)] - expected: FAIL - [border-top-width: +1.5 (quirks)] expected: FAIL @@ -1248,9 +1236,6 @@ [top: calc(2 * 2px) (standards)] expected: FAIL - [border-spacing: 1px 2 (quirks)] - expected: FAIL - [border-width: 1px 2 (quirks)] expected: FAIL @@ -1260,9 +1245,6 @@ [padding: 1px 2 (quirks)] expected: FAIL - [border-spacing: 1 2px (quirks)] - expected: FAIL - [border-width: 1 2px (quirks)] expected: FAIL @@ -1272,9 +1254,6 @@ [padding: 1 2px (quirks)] expected: FAIL - [border-spacing: 1 +2 (quirks)] - expected: FAIL - [border-width: 1 +2 (quirks)] expected: FAIL From b5a558e592fb1dec977a868ed1b7adaf3fa490d9 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 12:54:34 +0200 Subject: [PATCH 07/22] Implement the unitless length quirk for border-*-width --- components/style/properties/helpers.mako.rs | 8 +++- .../style/properties/longhand/border.mako.rs | 4 +- components/style/values/specified/mod.rs | 12 ++++- .../quirks-mode/unitless-length.html.ini | 48 ------------------- 4 files changed, 20 insertions(+), 52 deletions(-) diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 2505d1f82d5..5cfe95eec4d 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -8,11 +8,13 @@ %> <%def name="predefined_type(name, type, initial_value, parse_method='parse', - needs_context=True, vector=False, computed_type=None, initial_specified_value=None, **kwargs)"> + needs_context=True, vector=False, computed_type=None, initial_specified_value=None, + allow_quirks=False, **kwargs)"> <%def name="predefined_type_inner(name, type, initial_value, parse_method)"> #[allow(unused_imports)] use app_units::Au; use cssparser::{Color as CSSParserColor, RGBA}; + use values::specified::AllowQuirks; pub use values::specified::${type} as SpecifiedValue; pub mod computed_value { % if computed_type: @@ -30,7 +32,9 @@ pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - % if needs_context: + % if allow_quirks: + specified::${type}::${parse_method}_quirky(context, input, AllowQuirks::Yes) + % elif needs_context: specified::${type}::${parse_method}(context, input) % else: specified::${type}::${parse_method}(input) diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index df5cb06f1cc..a540b515a82 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -33,7 +33,9 @@ computed_type="::app_units::Au", alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"), spec=maybe_logical_spec(side, "width"), - animation_value_type="ComputedValue", logical=side[1])} + animation_value_type="ComputedValue", + logical=side[1], + allow_quirks=not side[1])} % endfor ${helpers.gecko_keyword_conversion(Keyword('border-style', diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 6519613bf6b..6c7a74627c0 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -491,7 +491,17 @@ pub enum BorderWidth { impl Parse for BorderWidth { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - match input.try(|i| Length::parse_non_negative(context, i)) { + Self::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl BorderWidth { + /// Parses a border width, allowing quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + match input.try(|i| Length::parse_non_negative_quirky(context, i, allow_quirks)) { Ok(length) => Ok(BorderWidth::Width(length)), Err(_) => match_ignore_ascii_case! { &try!(input.expect_ident()), "thin" => Ok(BorderWidth::Thin), diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 2be0a018e45..84929e65d87 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -1,17 +1,5 @@ [unitless-length.html] type: testharness - [border-top-width: 1 (quirks)] - expected: FAIL - - [border-right-width: 1 (quirks)] - expected: FAIL - - [border-bottom-width: 1 (quirks)] - expected: FAIL - - [border-left-width: 1 (quirks)] - expected: FAIL - [border-width: 1 (quirks)] expected: FAIL @@ -99,18 +87,6 @@ [word-spacing: 1 (quirks)] expected: FAIL - [border-top-width: +1 (quirks)] - expected: FAIL - - [border-right-width: +1 (quirks)] - expected: FAIL - - [border-bottom-width: +1 (quirks)] - expected: FAIL - - [border-left-width: +1 (quirks)] - expected: FAIL - [border-width: +1 (quirks)] expected: FAIL @@ -249,18 +225,6 @@ [word-spacing: -1 (quirks)] expected: FAIL - [border-top-width: 1.5 (quirks)] - expected: FAIL - - [border-right-width: 1.5 (quirks)] - expected: FAIL - - [border-bottom-width: 1.5 (quirks)] - expected: FAIL - - [border-left-width: 1.5 (quirks)] - expected: FAIL - [border-width: 1.5 (quirks)] expected: FAIL @@ -348,18 +312,6 @@ [word-spacing: 1.5 (quirks)] expected: FAIL - [border-top-width: +1.5 (quirks)] - expected: FAIL - - [border-right-width: +1.5 (quirks)] - expected: FAIL - - [border-bottom-width: +1.5 (quirks)] - expected: FAIL - - [border-left-width: +1.5 (quirks)] - expected: FAIL - [border-width: +1.5 (quirks)] expected: FAIL From 91cc30046b015888080d7f1fdfc09a2824977324 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 12:57:12 +0200 Subject: [PATCH 08/22] Implement the unitless length quirk for border-width --- .../style/properties/shorthand/border.mako.rs | 7 ++++--- .../quirks-mode/unitless-length.html.ini | 21 ------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/components/style/properties/shorthand/border.mako.rs b/components/style/properties/shorthand/border.mako.rs index 00fc89b0cec..223e5069d59 100644 --- a/components/style/properties/shorthand/border.mako.rs +++ b/components/style/properties/shorthand/border.mako.rs @@ -17,11 +17,12 @@ ${helpers.four_sides_shorthand("border-style", "border-%s-style", for side in PHYSICAL_SIDES)}" spec="https://drafts.csswg.org/css-backgrounds/#border-width"> use super::parse_four_sides; - use parser::Parse; - use values::specified; + use values::specified::{AllowQuirks, BorderWidth}; pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { - let (top, right, bottom, left) = try!(parse_four_sides(input, |i| specified::BorderWidth::parse(context, i))); + let (top, right, bottom, left) = try!(parse_four_sides(input, |i| { + BorderWidth::parse_quirky(context, i, AllowQuirks::Yes) + })); Ok(Longhands { % for side in PHYSICAL_SIDES: ${to_rust_ident('border-%s-width' % side)}: ${side}, diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 84929e65d87..aec7eace770 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -1,8 +1,5 @@ [unitless-length.html] type: testharness - [border-width: 1 (quirks)] - expected: FAIL - [bottom: 1 (quirks)] expected: FAIL @@ -87,9 +84,6 @@ [word-spacing: 1 (quirks)] expected: FAIL - [border-width: +1 (quirks)] - expected: FAIL - [bottom: +1 (quirks)] expected: FAIL @@ -225,9 +219,6 @@ [word-spacing: -1 (quirks)] expected: FAIL - [border-width: 1.5 (quirks)] - expected: FAIL - [bottom: 1.5 (quirks)] expected: FAIL @@ -312,9 +303,6 @@ [word-spacing: 1.5 (quirks)] expected: FAIL - [border-width: +1.5 (quirks)] - expected: FAIL - [bottom: +1.5 (quirks)] expected: FAIL @@ -1188,27 +1176,18 @@ [top: calc(2 * 2px) (standards)] expected: FAIL - [border-width: 1px 2 (quirks)] - expected: FAIL - [margin: 1px 2 (quirks)] expected: FAIL [padding: 1px 2 (quirks)] expected: FAIL - [border-width: 1 2px (quirks)] - expected: FAIL - [margin: 1 2px (quirks)] expected: FAIL [padding: 1 2px (quirks)] expected: FAIL - [border-width: 1 +2 (quirks)] - expected: FAIL - [margin: 1 +2 (quirks)] expected: FAIL From 46913ffe1d3c9c352df70c40b800305043223686 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 13:27:10 +0200 Subject: [PATCH 09/22] Implement the unitless length quirk for position properties --- .../properties/longhand/position.mako.rs | 3 +- components/style/values/specified/length.rs | 25 +- .../quirks-mode/unitless-length.html.ini | 864 ++++++++++++------ 3 files changed, 586 insertions(+), 306 deletions(-) diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 3f995b10873..263e45579f3 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -13,7 +13,8 @@ ${helpers.predefined_type(side, "LengthOrPercentageOrAuto", "computed::LengthOrPercentageOrAuto::Auto", spec="https://www.w3.org/TR/CSS2/visuren.html#propdef-%s" % side, - animation_value_type="ComputedValue")} + animation_value_type="ComputedValue", + allow_quirks=True)} % endfor // offset-* logical properties, map to "top" / "left" / "bottom" / "right" % for side in LOGICAL_SIDES: diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 424e6553279..830a6bb4554 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1307,15 +1307,19 @@ impl ToCss for LengthOrPercentageOrAuto { } impl LengthOrPercentageOrAuto { - fn parse_internal(context: &ParserContext, input: &mut Parser, num_context: AllowedLengthType) + fn parse_internal(context: &ParserContext, + input: &mut Parser, + num_context: AllowedLengthType, + allow_quirks: AllowQuirks) -> Result { match try!(input.next()) { Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) => NoCalcLength::parse_dimension(context, value.value, unit).map(LengthOrPercentageOrAuto::Length), Token::Percentage(ref value) if num_context.is_ok(value.unit_value) => Ok(LengthOrPercentageOrAuto::Percentage(Percentage(value.unit_value))), - Token::Number(ref value) if value.value == 0. => { - if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() { + Token::Number(ref value) if num_context.is_ok(value.value) => { + if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() && + !allow_quirks.allowed(context.quirks_mode) { return Err(()) } Ok(LengthOrPercentageOrAuto::Length( @@ -1337,7 +1341,7 @@ impl LengthOrPercentageOrAuto { /// Parse a non-negative length, percentage, or auto. #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative) + Self::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No) } /// Returns the `auto` value. @@ -1354,7 +1358,18 @@ impl LengthOrPercentageOrAuto { impl Parse for LengthOrPercentageOrAuto { #[inline] fn parse(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::All) + Self::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl LengthOrPercentageOrAuto { + /// Parses, with quirks. + #[inline] + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + Self::parse_internal(context, input, AllowedLengthType::All, allow_quirks) } } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index aec7eace770..870dcb0d8e8 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -1,13 +1,16 @@ [unitless-length.html] type: testharness [bottom: 1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [clip: 1 (quirks)] expected: FAIL @@ -60,20 +63,20 @@ [padding: 1 (quirks)] expected: FAIL - [right: 1 (quirks)] - expected: FAIL - [text-indent: 1 (quirks)] expected: FAIL [top: 1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [vertical-align: 1 (quirks)] expected: FAIL @@ -85,13 +88,16 @@ expected: FAIL [bottom: +1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [clip: +1 (quirks)] expected: FAIL @@ -144,20 +150,20 @@ [padding: +1 (quirks)] expected: FAIL - [right: +1 (quirks)] - expected: FAIL - [text-indent: +1 (quirks)] expected: FAIL [top: +1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [vertical-align: +1 (quirks)] expected: FAIL @@ -169,13 +175,16 @@ expected: FAIL [bottom: -1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [clip: -1 (quirks)] expected: FAIL @@ -198,20 +207,20 @@ [padding: -1 (quirks)] expected: FAIL - [right: -1 (quirks)] - expected: FAIL - [text-indent: -1 (quirks)] expected: FAIL [top: -1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [vertical-align: -1 (quirks)] expected: FAIL @@ -220,13 +229,16 @@ expected: FAIL [bottom: 1.5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1.5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1.5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [clip: 1.5 (quirks)] expected: FAIL @@ -279,20 +291,20 @@ [padding: 1.5 (quirks)] expected: FAIL - [right: 1.5 (quirks)] - expected: FAIL - [text-indent: 1.5 (quirks)] expected: FAIL [top: 1.5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1.5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1.5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [vertical-align: 1.5 (quirks)] expected: FAIL @@ -304,13 +316,16 @@ expected: FAIL [bottom: +1.5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1.5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1.5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [clip: +1.5 (quirks)] expected: FAIL @@ -363,20 +378,20 @@ [padding: +1.5 (quirks)] expected: FAIL - [right: +1.5 (quirks)] - expected: FAIL - [text-indent: +1.5 (quirks)] expected: FAIL [top: +1.5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1.5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1.5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [vertical-align: +1.5 (quirks)] expected: FAIL @@ -388,13 +403,16 @@ expected: FAIL [bottom: -1.5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1.5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1.5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [clip: -1.5 (quirks)] expected: FAIL @@ -417,20 +435,20 @@ [padding: -1.5 (quirks)] expected: FAIL - [right: -1.5 (quirks)] - expected: FAIL - [text-indent: -1.5 (quirks)] expected: FAIL [top: -1.5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1.5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1.5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [vertical-align: -1.5 (quirks)] expected: FAIL @@ -439,742 +457,988 @@ expected: FAIL [bottom: \\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: \\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: \\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: \\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: \\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: \\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: \\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: \\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: \\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: \\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: \\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: \\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1\\31 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1\\31 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1\\31 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1\\31 .5 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1\\31 .5 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1\\31 .5 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: 1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: 1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +1A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +1A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -1A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -1A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -A (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -A (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -A (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: @1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @1a (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @1a (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: @1a (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "a" (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "a" (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "a" (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "a" (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "a" (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "a" (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "1" (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "1" (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "1" (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "1" (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "1" (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "1" (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "1a" (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "1a" (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: "1a" (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "1a" (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "1a" (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: "1a" (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: url(1) (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: url(1) (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: url(1) (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: url(1) (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: url(1) (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: url(1) (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: url('1') (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: url('1') (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: url('1') (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: url('1') (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: url('1') (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: url('1') (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #01 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #01 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #01 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #01 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #01 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #01 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #0001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #0001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #0001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #0001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #0001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #0001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #00001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #00001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #00001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #00001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #00001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #00001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #000001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #000001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: #000001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #000001 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #000001 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: #000001 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +/**/1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +/**/1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: +/**/1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +/**/1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +/**/1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: +/**/1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -/**/1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -/**/1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: -/**/1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -/**/1 (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -/**/1 (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: -/**/1 (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: calc(1) (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: calc(1) (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: calc(1) (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: calc(1) (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: calc(1) (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: calc(1) (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: calc(2 * 2px) (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: calc(2 * 2px) (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [bottom: calc(2 * 2px) (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: calc(2 * 2px) (quirks)] - expected: FAIL + expected: + if os == "mac": FAIL [top: calc(2 * 2px) (almost standards)] - expected: FAIL + expected: + if os == "mac": FAIL [top: calc(2 * 2px) (standards)] - expected: FAIL + expected: + if os == "mac": FAIL [margin: 1px 2 (quirks)] expected: FAIL From ba59fafb44a62ee54cd2f701a2e99fe7327b7834 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 14:41:51 +0200 Subject: [PATCH 10/22] Implement the unitless length quirk for clip --- components/style/values/specified/length.rs | 12 +++++++++++- components/style/values/specified/mod.rs | 4 ++-- .../quirks-mode/unitless-length.html.ini | 18 ------------------ 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 830a6bb4554..142b44e1861 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -618,7 +618,17 @@ impl Length { impl Parse for Length { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::All, AllowQuirks::No) + Self::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl Length { + /// Parses a length, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + Self::parse_internal(context, input, AllowedLengthType::All, allow_quirks) } } diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 6c7a74627c0..eb7c71eabe8 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -1291,13 +1291,13 @@ impl ToComputedValue for ClipRect { impl Parse for ClipRect { fn parse(context: &ParserContext, input: &mut Parser) -> Result { - use values::specified::Length; + use values::specified::{AllowQuirks, Length}; fn parse_argument(context: &ParserContext, input: &mut Parser) -> Result, ()> { if input.try(|input| input.expect_ident_matching("auto")).is_ok() { Ok(None) } else { - Length::parse(context, input).map(Some) + Length::parse_quirky(context, input, AllowQuirks::Yes).map(Some) } } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 870dcb0d8e8..6b916d49a89 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [clip: 1 (quirks)] - expected: FAIL - [font-size: 1 (quirks)] expected: FAIL @@ -99,9 +96,6 @@ expected: if os == "mac": FAIL - [clip: +1 (quirks)] - expected: FAIL - [font-size: +1 (quirks)] expected: FAIL @@ -186,9 +180,6 @@ expected: if os == "mac": FAIL - [clip: -1 (quirks)] - expected: FAIL - [letter-spacing: -1 (quirks)] expected: FAIL @@ -240,9 +231,6 @@ expected: if os == "mac": FAIL - [clip: 1.5 (quirks)] - expected: FAIL - [font-size: 1.5 (quirks)] expected: FAIL @@ -327,9 +315,6 @@ expected: if os == "mac": FAIL - [clip: +1.5 (quirks)] - expected: FAIL - [font-size: +1.5 (quirks)] expected: FAIL @@ -414,9 +399,6 @@ expected: if os == "mac": FAIL - [clip: -1.5 (quirks)] - expected: FAIL - [letter-spacing: -1.5 (quirks)] expected: FAIL From 0e7308e6dc3c71c637e73c5a6eaa723f25fe8f3a Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 16:12:36 +0200 Subject: [PATCH 11/22] Implement the unitless length quirk for font-size --- components/style/properties/data.py | 3 ++- components/style/properties/helpers.mako.rs | 6 +++++- .../style/properties/longhand/font.mako.rs | 16 +++++++++++++--- components/style/values/specified/length.rs | 11 ++++++++++- .../quirks-mode/unitless-length.html.ini | 12 ------------ 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/components/style/properties/data.py b/components/style/properties/data.py index c935e00a79f..8db09e6fe81 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -140,7 +140,7 @@ class Longhand(object): need_clone=False, need_index=False, gecko_ffi_name=None, depend_on_viewport_size=False, allowed_in_keyframe_block=True, complex_color=False, cast_type='u8', has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None, boxed=False, - flags=None, allowed_in_page_rule=False): + flags=None, allowed_in_page_rule=False, allow_quirks=False): self.name = name if not spec: raise TypeError("Spec should be specified for %s" % name) @@ -166,6 +166,7 @@ class Longhand(object): self.boxed = arg_to_bool(boxed) self.flags = flags.split() if flags else [] self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule) + self.allow_quirks = allow_quirks # https://drafts.csswg.org/css-animations/#keyframes # > The inside of accepts any CSS property diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 5cfe95eec4d..6563b97df15 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -375,7 +375,11 @@ parse(context, input).map(|result| Box::new(result)) % else: -> Result { - parse(context, input) + % if property.allow_quirks: + parse_quirky(context, input, specified::AllowQuirks::Yes) + % else: + parse(context, input) + % endif % endif } pub fn parse_declared(context: &ParserContext, input: &mut Parser) diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 6bdc67037d3..02df590ee9d 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -550,14 +550,14 @@ ${helpers.single_keyword_system("font-variant-caps", <%helpers:longhand name="font-size" need_clone="True" animation_value_type="ComputedValue" - spec="https://drafts.csswg.org/css-fonts/#propdef-font-size"> + allow_quirks="True" spec="https://drafts.csswg.org/css-fonts/#propdef-font-size"> use app_units::Au; use properties::longhands::system_font::SystemFont; use properties::style_structs::Font; use std::fmt; use style_traits::ToCss; use values::{FONT_MEDIUM_PX, HasViewportPercentage}; - use values::specified::{FontRelativeLength, LengthOrPercentage, Length}; + use values::specified::{AllowQuirks, FontRelativeLength, LengthOrPercentage, Length}; use values::specified::{NoCalcLength, Percentage}; use values::specified::length::FontBaseSize; @@ -843,9 +843,19 @@ ${helpers.single_keyword_system("font-variant-caps", )) } } + /// | | | pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - if let Ok(lop) = input.try(|i| specified::LengthOrPercentage::parse_non_negative(context, i)) { + parse_quirky(context, input, AllowQuirks::No) + } + + /// Parses a font-size, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + use self::specified::LengthOrPercentage; + if let Ok(lop) = input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) { return Ok(SpecifiedValue::Length(lop)) } diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 142b44e1861..6a66e658aef 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1204,7 +1204,16 @@ impl LengthOrPercentage { /// Parse a non-negative length. #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No) + Self::parse_non_negative_quirky(context, input, AllowQuirks::No) + } + + /// Parse a non-negative length, with quirks. + #[inline] + pub fn parse_non_negative_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + Self::parse_internal(context, input, AllowedLengthType::NonNegative, allow_quirks) } /// Parse a length, treating dimensionless numbers as pixels diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 6b916d49a89..95010cb9d61 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [font-size: 1 (quirks)] - expected: FAIL - [height: 1 (quirks)] expected: FAIL @@ -96,9 +93,6 @@ expected: if os == "mac": FAIL - [font-size: +1 (quirks)] - expected: FAIL - [height: +1 (quirks)] expected: FAIL @@ -231,9 +225,6 @@ expected: if os == "mac": FAIL - [font-size: 1.5 (quirks)] - expected: FAIL - [height: 1.5 (quirks)] expected: FAIL @@ -315,9 +306,6 @@ expected: if os == "mac": FAIL - [font-size: +1.5 (quirks)] - expected: FAIL - [height: +1.5 (quirks)] expected: FAIL From 65f74ea93463942f1d3b9660992a16fa9b9267c2 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 17:31:03 +0200 Subject: [PATCH 12/22] Implement the unitless length quirk for physical size properties --- .../properties/longhand/position.mako.rs | 1 + components/style/values/specified/length.rs | 11 ++++++++- .../quirks-mode/unitless-length.html.ini | 24 ------------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 263e45579f3..590b7cb8980 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -158,6 +158,7 @@ ${helpers.predefined_type("flex-basis", "computed::LengthOrPercentageOrAuto::Auto", "parse_non_negative", spec=spec % size, + allow_quirks=not logical, animation_value_type="ComputedValue", logical = logical)} % if product == "gecko": % for min_max in ["min", "max"]: diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 6a66e658aef..2581db7290d 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1360,7 +1360,16 @@ impl LengthOrPercentageOrAuto { /// Parse a non-negative length, percentage, or auto. #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative, AllowQuirks::No) + Self::parse_non_negative_quirky(context, input, AllowQuirks::No) + } + + /// Parse a non-negative length, percentage, or auto. + #[inline] + pub fn parse_non_negative_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + Self::parse_internal(context, input, AllowedLengthType::NonNegative, allow_quirks) } /// Returns the `auto` value. diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 95010cb9d61..385892d38e5 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [height: 1 (quirks)] - expected: FAIL - [letter-spacing: 1 (quirks)] expected: FAIL @@ -75,9 +72,6 @@ [vertical-align: 1 (quirks)] expected: FAIL - [width: 1 (quirks)] - expected: FAIL - [word-spacing: 1 (quirks)] expected: FAIL @@ -93,9 +87,6 @@ expected: if os == "mac": FAIL - [height: +1 (quirks)] - expected: FAIL - [letter-spacing: +1 (quirks)] expected: FAIL @@ -156,9 +147,6 @@ [vertical-align: +1 (quirks)] expected: FAIL - [width: +1 (quirks)] - expected: FAIL - [word-spacing: +1 (quirks)] expected: FAIL @@ -225,9 +213,6 @@ expected: if os == "mac": FAIL - [height: 1.5 (quirks)] - expected: FAIL - [letter-spacing: 1.5 (quirks)] expected: FAIL @@ -288,9 +273,6 @@ [vertical-align: 1.5 (quirks)] expected: FAIL - [width: 1.5 (quirks)] - expected: FAIL - [word-spacing: 1.5 (quirks)] expected: FAIL @@ -306,9 +288,6 @@ expected: if os == "mac": FAIL - [height: +1.5 (quirks)] - expected: FAIL - [letter-spacing: +1.5 (quirks)] expected: FAIL @@ -369,9 +348,6 @@ [vertical-align: +1.5 (quirks)] expected: FAIL - [width: +1.5 (quirks)] - expected: FAIL - [word-spacing: +1.5 (quirks)] expected: FAIL From 72186c200c358f60acc122dae24f24da3b232d33 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 17:47:56 +0200 Subject: [PATCH 13/22] Implement the unitless length quirk for letter-spacing --- .../properties/longhand/inherited_text.mako.rs | 3 ++- .../quirks-mode/unitless-length.html.ini | 18 ------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 57385c98217..779bb9532f5 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -411,6 +411,7 @@ ${helpers.single_keyword("text-align-last", use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; + use values::specified::AllowQuirks; impl HasViewportPercentage for SpecifiedValue { fn has_viewport_percentage(&self) -> bool { @@ -487,7 +488,7 @@ ${helpers.single_keyword("text-align-last", if input.try(|input| input.expect_ident_matching("normal")).is_ok() { Ok(SpecifiedValue::Normal) } else { - specified::Length::parse(context, input).map(SpecifiedValue::Specified) + specified::Length::parse_quirky(context, input, AllowQuirks::Yes).map(SpecifiedValue::Specified) } } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 385892d38e5..a584a4c7e62 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [letter-spacing: 1 (quirks)] - expected: FAIL - [margin-left: 1 (quirks)] expected: FAIL @@ -87,9 +84,6 @@ expected: if os == "mac": FAIL - [letter-spacing: +1 (quirks)] - expected: FAIL - [margin-left: +1 (quirks)] expected: FAIL @@ -162,9 +156,6 @@ expected: if os == "mac": FAIL - [letter-spacing: -1 (quirks)] - expected: FAIL - [margin-left: -1 (quirks)] expected: FAIL @@ -213,9 +204,6 @@ expected: if os == "mac": FAIL - [letter-spacing: 1.5 (quirks)] - expected: FAIL - [margin-left: 1.5 (quirks)] expected: FAIL @@ -288,9 +276,6 @@ expected: if os == "mac": FAIL - [letter-spacing: +1.5 (quirks)] - expected: FAIL - [margin-left: +1.5 (quirks)] expected: FAIL @@ -363,9 +348,6 @@ expected: if os == "mac": FAIL - [letter-spacing: -1.5 (quirks)] - expected: FAIL - [margin-left: -1.5 (quirks)] expected: FAIL From bcc6d4580decab9305d4208554733dca739b6e99 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 24 Apr 2017 17:48:16 +0200 Subject: [PATCH 14/22] Implement the unitless length quirk for margin-* --- .../style/properties/longhand/margin.mako.rs | 1 + .../quirks-mode/unitless-length.html.ini | 54 ------------------- 2 files changed, 1 insertion(+), 54 deletions(-) diff --git a/components/style/properties/longhand/margin.mako.rs b/components/style/properties/longhand/margin.mako.rs index 1fe4e7cca61..5c8a62aa01f 100644 --- a/components/style/properties/longhand/margin.mako.rs +++ b/components/style/properties/longhand/margin.mako.rs @@ -15,6 +15,7 @@ ${helpers.predefined_type("margin-%s" % side[0], "LengthOrPercentageOrAuto", "computed::LengthOrPercentageOrAuto::Length(Au(0))", alias=maybe_moz_logical_alias(product, side, "-moz-margin-%s"), + allow_quirks=not side[1], animation_value_type="ComputedValue", logical = side[1], spec = spec, allowed_in_page_rule=True)} % endfor diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index a584a4c7e62..3a7420644f1 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,15 +12,6 @@ expected: if os == "mac": FAIL - [margin-left: 1 (quirks)] - expected: FAIL - - [margin-top: 1 (quirks)] - expected: FAIL - - [margin-bottom: 1 (quirks)] - expected: FAIL - [margin: 1 (quirks)] expected: FAIL @@ -84,15 +75,6 @@ expected: if os == "mac": FAIL - [margin-left: +1 (quirks)] - expected: FAIL - - [margin-top: +1 (quirks)] - expected: FAIL - - [margin-bottom: +1 (quirks)] - expected: FAIL - [margin: +1 (quirks)] expected: FAIL @@ -156,15 +138,6 @@ expected: if os == "mac": FAIL - [margin-left: -1 (quirks)] - expected: FAIL - - [margin-top: -1 (quirks)] - expected: FAIL - - [margin-bottom: -1 (quirks)] - expected: FAIL - [margin: -1 (quirks)] expected: FAIL @@ -204,15 +177,6 @@ expected: if os == "mac": FAIL - [margin-left: 1.5 (quirks)] - expected: FAIL - - [margin-top: 1.5 (quirks)] - expected: FAIL - - [margin-bottom: 1.5 (quirks)] - expected: FAIL - [margin: 1.5 (quirks)] expected: FAIL @@ -276,15 +240,6 @@ expected: if os == "mac": FAIL - [margin-left: +1.5 (quirks)] - expected: FAIL - - [margin-top: +1.5 (quirks)] - expected: FAIL - - [margin-bottom: +1.5 (quirks)] - expected: FAIL - [margin: +1.5 (quirks)] expected: FAIL @@ -348,15 +303,6 @@ expected: if os == "mac": FAIL - [margin-left: -1.5 (quirks)] - expected: FAIL - - [margin-top: -1.5 (quirks)] - expected: FAIL - - [margin-bottom: -1.5 (quirks)] - expected: FAIL - [margin: -1.5 (quirks)] expected: FAIL From 2aea6d89076b96b223d71b70d40c6a3fc1f230f6 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 00:37:32 +0200 Subject: [PATCH 15/22] Implement the unitless length quirk for margin --- components/style/properties/helpers.mako.rs | 7 +++-- .../style/properties/shorthand/margin.mako.rs | 3 +- .../quirks-mode/unitless-length.html.ini | 30 ------------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 6563b97df15..478e1be659b 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -809,7 +809,8 @@ % endif -<%def name="four_sides_shorthand(name, sub_property_pattern, parser_function, needs_context=True, **kwargs)"> +<%def name="four_sides_shorthand(name, sub_property_pattern, parser_function, + needs_context=True, allow_quirks=False, **kwargs)"> <% sub_properties=' '.join(sub_property_pattern % side for side in ['top', 'right', 'bottom', 'left']) %> <%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)"> #[allow(unused_imports)] @@ -819,7 +820,9 @@ pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { let (top, right, bottom, left) = - % if needs_context: + % if allow_quirks: + try!(parse_four_sides(input, |i| ${parser_function}_quirky(context, i, specified::AllowQuirks::Yes))); + % elif needs_context: try!(parse_four_sides(input, |i| ${parser_function}(context, i))); % else: try!(parse_four_sides(input, ${parser_function})); diff --git a/components/style/properties/shorthand/margin.mako.rs b/components/style/properties/shorthand/margin.mako.rs index 4dcaa71e626..07b6ba6bbed 100644 --- a/components/style/properties/shorthand/margin.mako.rs +++ b/components/style/properties/shorthand/margin.mako.rs @@ -6,4 +6,5 @@ ${helpers.four_sides_shorthand("margin", "margin-%s", "specified::LengthOrPercentageOrAuto::parse", spec="https://drafts.csswg.org/css-box/#propdef-margin", - allowed_in_page_rule=True)} + allowed_in_page_rule=True, + allow_quirks=True)} diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 3a7420644f1..57b312ab152 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [margin: 1 (quirks)] - expected: FAIL - [max-height: 1 (quirks)] expected: FAIL @@ -75,9 +72,6 @@ expected: if os == "mac": FAIL - [margin: +1 (quirks)] - expected: FAIL - [max-height: +1 (quirks)] expected: FAIL @@ -138,9 +132,6 @@ expected: if os == "mac": FAIL - [margin: -1 (quirks)] - expected: FAIL - [padding: -1 (quirks)] expected: FAIL @@ -177,9 +168,6 @@ expected: if os == "mac": FAIL - [margin: 1.5 (quirks)] - expected: FAIL - [max-height: 1.5 (quirks)] expected: FAIL @@ -240,9 +228,6 @@ expected: if os == "mac": FAIL - [margin: +1.5 (quirks)] - expected: FAIL - [max-height: +1.5 (quirks)] expected: FAIL @@ -303,9 +288,6 @@ expected: if os == "mac": FAIL - [margin: -1.5 (quirks)] - expected: FAIL - [padding: -1.5 (quirks)] expected: FAIL @@ -1314,27 +1296,15 @@ expected: if os == "mac": FAIL - [margin: 1px 2 (quirks)] - expected: FAIL - [padding: 1px 2 (quirks)] expected: FAIL - [margin: 1 2px (quirks)] - expected: FAIL - [padding: 1 2px (quirks)] expected: FAIL - [margin: 1 +2 (quirks)] - expected: FAIL - [padding: 1 +2 (quirks)] expected: FAIL - [margin: 1 -2 (quirks)] - expected: FAIL - [padding: 1 -2 (quirks)] expected: FAIL From 37118e1e459d7cd40d0a416d41b5340c7777c9e6 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 00:59:01 +0200 Subject: [PATCH 16/22] Implement the unitless length quirk for physical size extremums --- .../properties/longhand/position.mako.rs | 14 ++++-- components/style/values/specified/length.rs | 46 +++++++++++++++--- ports/geckolib/glue.rs | 2 +- .../quirks-mode/unitless-length.html.ini | 48 ------------------- 4 files changed, 51 insertions(+), 59 deletions(-) diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 590b7cb8980..757c270bb49 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -179,7 +179,7 @@ ${helpers.predefined_type("flex-basis", use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; - use values::specified::${MinMax}Length; + use values::specified::{AllowQuirks, ${MinMax}Length}; impl HasViewportPercentage for SpecifiedValue { fn has_viewport_percentage(&self) -> bool { @@ -201,7 +201,11 @@ ${helpers.predefined_type("flex-basis", ${MinMax}Length::${initial} } fn parse(context: &ParserContext, input: &mut Parser) -> Result { + % if logical: let ret = ${MinMax}Length::parse(context, input); + % else: + let ret = ${MinMax}Length::parse_quirky(context, input, AllowQuirks::Yes); + % endif // Keyword values don't make sense in the block direction; don't parse them % if "block" in size: if let Ok(${MinMax}Length::ExtremumLength(..)) = ret { @@ -256,13 +260,17 @@ ${helpers.predefined_type("flex-basis", "computed::LengthOrPercentage::Length(Au(0))", "parse_non_negative", spec=spec % ("min-%s" % size), - animation_value_type="ComputedValue", logical = logical)} + animation_value_type="ComputedValue", + logical=logical, + allow_quirks=not logical)} ${helpers.predefined_type("max-%s" % size, "LengthOrPercentageOrNone", "computed::LengthOrPercentageOrNone::None", "parse_non_negative", spec=spec % ("min-%s" % size), - animation_value_type="ComputedValue", logical = logical)} + animation_value_type="ComputedValue", + logical=logical, + allow_quirks=not logical)} % endif % endfor diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 2581db7290d..d3ebba44726 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -1434,7 +1434,10 @@ impl ToCss for LengthOrPercentageOrNone { } } impl LengthOrPercentageOrNone { - fn parse_internal(context: &ParserContext, input: &mut Parser, num_context: AllowedLengthType) + fn parse_internal(context: &ParserContext, + input: &mut Parser, + num_context: AllowedLengthType, + allow_quirks: AllowQuirks) -> Result { match try!(input.next()) { @@ -1442,8 +1445,9 @@ impl LengthOrPercentageOrNone { NoCalcLength::parse_dimension(context, value.value, unit).map(LengthOrPercentageOrNone::Length), Token::Percentage(ref value) if num_context.is_ok(value.unit_value) => Ok(LengthOrPercentageOrNone::Percentage(Percentage(value.unit_value))), - Token::Number(ref value) if value.value == 0. => { - if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() { + Token::Number(value) if num_context.is_ok(value.value) => { + if value.value != 0. && !context.length_parsing_mode.allows_unitless_lengths() && + !allow_quirks.allowed(context.quirks_mode) { return Err(()) } Ok(LengthOrPercentageOrNone::Length( @@ -1461,17 +1465,27 @@ impl LengthOrPercentageOrNone { _ => Err(()) } } + /// Parse a non-negative LengthOrPercentageOrNone. #[inline] pub fn parse_non_negative(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::NonNegative) + Self::parse_non_negative_quirky(context, input, AllowQuirks::No) + } + + /// Parse a non-negative LengthOrPercentageOrNone, with quirks. + #[inline] + pub fn parse_non_negative_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) + -> Result { + Self::parse_internal(context, input, AllowedLengthType::NonNegative, allow_quirks) } } impl Parse for LengthOrPercentageOrNone { #[inline] fn parse(context: &ParserContext, input: &mut Parser) -> Result { - Self::parse_internal(context, input, AllowedLengthType::All) + Self::parse_internal(context, input, AllowedLengthType::All, AllowQuirks::No) } } @@ -1615,8 +1629,17 @@ impl ToCss for MinLength { impl Parse for MinLength { fn parse(context: &ParserContext, input: &mut Parser) -> Result { + MinLength::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl MinLength { + /// Parses, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { input.try(ExtremumLength::parse).map(MinLength::ExtremumLength) - .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) + .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) .map(MinLength::LengthOrPercentage)) .or_else(|()| input.expect_ident_matching("auto").map(|()| MinLength::Auto)) } @@ -1656,8 +1679,17 @@ impl ToCss for MaxLength { impl Parse for MaxLength { fn parse(context: &ParserContext, input: &mut Parser) -> Result { + MaxLength::parse_quirky(context, input, AllowQuirks::No) + } +} + +impl MaxLength { + /// Parses, with quirks. + pub fn parse_quirky(context: &ParserContext, + input: &mut Parser, + allow_quirks: AllowQuirks) -> Result { input.try(ExtremumLength::parse).map(MaxLength::ExtremumLength) - .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative(context, i)) + .or_else(|()| input.try(|i| LengthOrPercentage::parse_non_negative_quirky(context, i, allow_quirks)) .map(MaxLength::LengthOrPercentage)) .or_else(|()| { match_ignore_ascii_case! { &try!(input.expect_ident()), diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index f9dadbfb7f1..d8a855aeba8 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -511,7 +511,7 @@ pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyl Arc::new(Stylesheet::from_str( "", unsafe { dummy_url_data() }.clone(), origin, Arc::new(shared_lock.wrap(MediaList::empty())), - shared_lock, None, &RustLogReporter, QuirksMode::NoQuirks, Wh0u64) + shared_lock, None, &RustLogReporter, QuirksMode::NoQuirks, 0u64) ).into_strong() } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 57b312ab152..3584ede282b 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,18 +12,6 @@ expected: if os == "mac": FAIL - [max-height: 1 (quirks)] - expected: FAIL - - [max-width: 1 (quirks)] - expected: FAIL - - [min-height: 1 (quirks)] - expected: FAIL - - [min-width: 1 (quirks)] - expected: FAIL - [padding-top: 1 (quirks)] expected: FAIL @@ -72,18 +60,6 @@ expected: if os == "mac": FAIL - [max-height: +1 (quirks)] - expected: FAIL - - [max-width: +1 (quirks)] - expected: FAIL - - [min-height: +1 (quirks)] - expected: FAIL - - [min-width: +1 (quirks)] - expected: FAIL - [padding-top: +1 (quirks)] expected: FAIL @@ -168,18 +144,6 @@ expected: if os == "mac": FAIL - [max-height: 1.5 (quirks)] - expected: FAIL - - [max-width: 1.5 (quirks)] - expected: FAIL - - [min-height: 1.5 (quirks)] - expected: FAIL - - [min-width: 1.5 (quirks)] - expected: FAIL - [padding-top: 1.5 (quirks)] expected: FAIL @@ -228,18 +192,6 @@ expected: if os == "mac": FAIL - [max-height: +1.5 (quirks)] - expected: FAIL - - [max-width: +1.5 (quirks)] - expected: FAIL - - [min-height: +1.5 (quirks)] - expected: FAIL - - [min-width: +1.5 (quirks)] - expected: FAIL - [padding-top: +1.5 (quirks)] expected: FAIL From 3f947395ad907c07ff6bc8a49d43cb17b29aa2dd Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 01:03:56 +0200 Subject: [PATCH 17/22] Implement the unitless length quirk for padding-* --- .../style/properties/longhand/padding.mako.rs | 3 +- .../quirks-mode/unitless-length.html.ini | 61 ------------------- 2 files changed, 2 insertions(+), 62 deletions(-) diff --git a/components/style/properties/longhand/padding.mako.rs b/components/style/properties/longhand/padding.mako.rs index 593deb769ac..ce74320f220 100644 --- a/components/style/properties/longhand/padding.mako.rs +++ b/components/style/properties/longhand/padding.mako.rs @@ -18,5 +18,6 @@ alias=maybe_moz_logical_alias(product, side, "-moz-padding-%s"), animation_value_type="ComputedValue", logical = side[1], - spec = spec)} + spec = spec, + allow_quirks=not side[1])} % endfor diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 3584ede282b..65232359b5a 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,18 +12,6 @@ expected: if os == "mac": FAIL - [padding-top: 1 (quirks)] - expected: FAIL - - [padding-right: 1 (quirks)] - expected: FAIL - - [padding-bottom: 1 (quirks)] - expected: FAIL - - [padding-left: 1 (quirks)] - expected: FAIL - [padding: 1 (quirks)] expected: FAIL @@ -60,18 +48,6 @@ expected: if os == "mac": FAIL - [padding-top: +1 (quirks)] - expected: FAIL - - [padding-right: +1 (quirks)] - expected: FAIL - - [padding-bottom: +1 (quirks)] - expected: FAIL - - [padding-left: +1 (quirks)] - expected: FAIL - [padding: +1 (quirks)] expected: FAIL @@ -144,18 +120,6 @@ expected: if os == "mac": FAIL - [padding-top: 1.5 (quirks)] - expected: FAIL - - [padding-right: 1.5 (quirks)] - expected: FAIL - - [padding-bottom: 1.5 (quirks)] - expected: FAIL - - [padding-left: 1.5 (quirks)] - expected: FAIL - [padding: 1.5 (quirks)] expected: FAIL @@ -192,18 +156,6 @@ expected: if os == "mac": FAIL - [padding-top: +1.5 (quirks)] - expected: FAIL - - [padding-right: +1.5 (quirks)] - expected: FAIL - - [padding-bottom: +1.5 (quirks)] - expected: FAIL - - [padding-left: +1.5 (quirks)] - expected: FAIL - [padding: +1.5 (quirks)] expected: FAIL @@ -1247,16 +1199,3 @@ [top: calc(2 * 2px) (standards)] expected: if os == "mac": FAIL - - [padding: 1px 2 (quirks)] - expected: FAIL - - [padding: 1 2px (quirks)] - expected: FAIL - - [padding: 1 +2 (quirks)] - expected: FAIL - - [padding: 1 -2 (quirks)] - expected: FAIL - From dd6d3d62c6c799ba8248b7c585e33bb131d0ba51 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 01:12:55 +0200 Subject: [PATCH 18/22] Implement the unitless length quirk for padding --- .../style/properties/shorthand/padding.mako.rs | 3 ++- .../quirks-mode/unitless-length.html.ini | 18 ------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/components/style/properties/shorthand/padding.mako.rs b/components/style/properties/shorthand/padding.mako.rs index a0e94f8bdcb..c07a80b1e04 100644 --- a/components/style/properties/shorthand/padding.mako.rs +++ b/components/style/properties/shorthand/padding.mako.rs @@ -5,4 +5,5 @@ <%namespace name="helpers" file="/helpers.mako.rs" /> ${helpers.four_sides_shorthand("padding", "padding-%s", "specified::LengthOrPercentage::parse", - spec="https://drafts.csswg.org/css-box-3/#propdef-padding")} + spec="https://drafts.csswg.org/css-box-3/#propdef-padding", + allow_quirks=True)} diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 65232359b5a..e3cbb4dc262 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [padding: 1 (quirks)] - expected: FAIL - [text-indent: 1 (quirks)] expected: FAIL @@ -48,9 +45,6 @@ expected: if os == "mac": FAIL - [padding: +1 (quirks)] - expected: FAIL - [text-indent: +1 (quirks)] expected: FAIL @@ -84,9 +78,6 @@ expected: if os == "mac": FAIL - [padding: -1 (quirks)] - expected: FAIL - [text-indent: -1 (quirks)] expected: FAIL @@ -120,9 +111,6 @@ expected: if os == "mac": FAIL - [padding: 1.5 (quirks)] - expected: FAIL - [text-indent: 1.5 (quirks)] expected: FAIL @@ -156,9 +144,6 @@ expected: if os == "mac": FAIL - [padding: +1.5 (quirks)] - expected: FAIL - [text-indent: +1.5 (quirks)] expected: FAIL @@ -192,9 +177,6 @@ expected: if os == "mac": FAIL - [padding: -1.5 (quirks)] - expected: FAIL - [text-indent: -1.5 (quirks)] expected: FAIL From 16dd554534ceb81063d0522ff2f2c4f89bb95666 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 01:16:57 +0200 Subject: [PATCH 19/22] Implement the unitless length quirk for text-indent --- .../properties/longhand/inherited_text.mako.rs | 3 ++- .../quirks-mode/unitless-length.html.ini | 18 ------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 779bb9532f5..27edd52c0f0 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -184,7 +184,8 @@ ${helpers.predefined_type("text-indent", "LengthOrPercentage", "computed::LengthOrPercentage::Length(Au(0))", animation_value_type="ComputedValue", - spec="https://drafts.csswg.org/css-text/#propdef-text-indent")} + spec="https://drafts.csswg.org/css-text/#propdef-text-indent", + allow_quirks=True)} // Also known as "word-wrap" (which is more popular because of IE), but this is the preferred // name per CSS-TEXT 6.2. diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index e3cbb4dc262..60709b5ab99 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -12,9 +12,6 @@ expected: if os == "mac": FAIL - [text-indent: 1 (quirks)] - expected: FAIL - [top: 1 (quirks)] expected: if os == "mac": FAIL @@ -45,9 +42,6 @@ expected: if os == "mac": FAIL - [text-indent: +1 (quirks)] - expected: FAIL - [top: +1 (quirks)] expected: if os == "mac": FAIL @@ -78,9 +72,6 @@ expected: if os == "mac": FAIL - [text-indent: -1 (quirks)] - expected: FAIL - [top: -1 (quirks)] expected: if os == "mac": FAIL @@ -111,9 +102,6 @@ expected: if os == "mac": FAIL - [text-indent: 1.5 (quirks)] - expected: FAIL - [top: 1.5 (quirks)] expected: if os == "mac": FAIL @@ -144,9 +132,6 @@ expected: if os == "mac": FAIL - [text-indent: +1.5 (quirks)] - expected: FAIL - [top: +1.5 (quirks)] expected: if os == "mac": FAIL @@ -177,9 +162,6 @@ expected: if os == "mac": FAIL - [text-indent: -1.5 (quirks)] - expected: FAIL - [top: -1.5 (quirks)] expected: if os == "mac": FAIL From 59a7819aa9849828f9c59e5a4e11be45a7d1463e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 19:39:34 +0200 Subject: [PATCH 20/22] Implement the unitless length quirk for vertical-align --- .../style/properties/longhand/box.mako.rs | 3 ++- .../quirks-mode/unitless-length.html.ini | 18 ------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 2806a04e803..c2ee7ab1f89 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -264,6 +264,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed", use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; + use values::specified::AllowQuirks; <% vertical_align = data.longhands_by_name["vertical-align"] %> <% vertical_align.keyword = Keyword("vertical-align", @@ -306,7 +307,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed", /// baseline | sub | super | top | text-top | middle | bottom | text-bottom /// | | pub fn parse(context: &ParserContext, input: &mut Parser) -> Result { - input.try(|i| specified::LengthOrPercentage::parse(context, i)) + input.try(|i| specified::LengthOrPercentage::parse_quirky(context, i, AllowQuirks::Yes)) .map(SpecifiedValue::LengthOrPercentage) .or_else(|_| { match_ignore_ascii_case! { &try!(input.expect_ident()), diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 60709b5ab99..701b162c251 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -24,9 +24,6 @@ expected: if os == "mac": FAIL - [vertical-align: 1 (quirks)] - expected: FAIL - [word-spacing: 1 (quirks)] expected: FAIL @@ -54,9 +51,6 @@ expected: if os == "mac": FAIL - [vertical-align: +1 (quirks)] - expected: FAIL - [word-spacing: +1 (quirks)] expected: FAIL @@ -84,9 +78,6 @@ expected: if os == "mac": FAIL - [vertical-align: -1 (quirks)] - expected: FAIL - [word-spacing: -1 (quirks)] expected: FAIL @@ -114,9 +105,6 @@ expected: if os == "mac": FAIL - [vertical-align: 1.5 (quirks)] - expected: FAIL - [word-spacing: 1.5 (quirks)] expected: FAIL @@ -144,9 +132,6 @@ expected: if os == "mac": FAIL - [vertical-align: +1.5 (quirks)] - expected: FAIL - [word-spacing: +1.5 (quirks)] expected: FAIL @@ -174,9 +159,6 @@ expected: if os == "mac": FAIL - [vertical-align: -1.5 (quirks)] - expected: FAIL - [word-spacing: -1.5 (quirks)] expected: FAIL From d53eb777e1e6c7fec47b9de971def141810d7939 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 25 Apr 2017 09:22:54 +0200 Subject: [PATCH 21/22] Implement the unitless length quirk for word-spacing --- .../properties/longhand/inherited_text.mako.rs | 3 ++- .../quirks-mode/unitless-length.html.ini | 18 ------------------ 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 27edd52c0f0..091b10a8bf5 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -499,6 +499,7 @@ ${helpers.single_keyword("text-align-last", use std::fmt; use style_traits::ToCss; use values::HasViewportPercentage; + use values::specified::AllowQuirks; impl HasViewportPercentage for SpecifiedValue { fn has_viewport_percentage(&self) -> bool { @@ -574,7 +575,7 @@ ${helpers.single_keyword("text-align-last", if input.try(|input| input.expect_ident_matching("normal")).is_ok() { Ok(SpecifiedValue::Normal) } else { - specified::LengthOrPercentage::parse(context, input) + specified::LengthOrPercentage::parse_quirky(context, input, AllowQuirks::Yes) .map(SpecifiedValue::Specified) } } diff --git a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini index 701b162c251..307046ccfdf 100644 --- a/tests/wpt/metadata/quirks-mode/unitless-length.html.ini +++ b/tests/wpt/metadata/quirks-mode/unitless-length.html.ini @@ -24,9 +24,6 @@ expected: if os == "mac": FAIL - [word-spacing: 1 (quirks)] - expected: FAIL - [bottom: +1 (quirks)] expected: if os == "mac": FAIL @@ -51,9 +48,6 @@ expected: if os == "mac": FAIL - [word-spacing: +1 (quirks)] - expected: FAIL - [bottom: -1 (quirks)] expected: if os == "mac": FAIL @@ -78,9 +72,6 @@ expected: if os == "mac": FAIL - [word-spacing: -1 (quirks)] - expected: FAIL - [bottom: 1.5 (quirks)] expected: if os == "mac": FAIL @@ -105,9 +96,6 @@ expected: if os == "mac": FAIL - [word-spacing: 1.5 (quirks)] - expected: FAIL - [bottom: +1.5 (quirks)] expected: if os == "mac": FAIL @@ -132,9 +120,6 @@ expected: if os == "mac": FAIL - [word-spacing: +1.5 (quirks)] - expected: FAIL - [bottom: -1.5 (quirks)] expected: if os == "mac": FAIL @@ -159,9 +144,6 @@ expected: if os == "mac": FAIL - [word-spacing: -1.5 (quirks)] - expected: FAIL - [bottom: \\31 (quirks)] expected: if os == "mac": FAIL From 1091af6fee5bd69165417bbcf19d66e2ea7c3d84 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 27 Apr 2017 10:40:05 +0200 Subject: [PATCH 22/22] Copy the damn unitless-length.html test in /_mozilla/ It's the exact same thing as the one in WPT, but without the intermittent 'top' and 'bottom' failures which are unrelated to the damn quirk. --- tests/wpt/mozilla/meta/MANIFEST.json | 10 + .../tests/mozilla/unitless-length.html | 219 ++++++++++++++++++ 2 files changed, 229 insertions(+) create mode 100644 tests/wpt/mozilla/tests/mozilla/unitless-length.html diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 391b2f83b8b..5f70f04ee64 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -19874,6 +19874,12 @@ {} ] ], + "mozilla/unitless-length.html": [ + [ + "/_mozilla/mozilla/unitless-length.html", + {} + ] + ], "mozilla/variadic-interface.html": [ [ "/_mozilla/mozilla/variadic-interface.html", @@ -31497,6 +31503,10 @@ "47ee847e660eb907a7bd916cf37cf3ceba68ea7d", "testharness" ], + "mozilla/unitless-length.html": [ + "dfb31d3f9c4f24913055924c375f08b990b63e49", + "testharness" + ], "mozilla/variadic-interface.html": [ "9edd5150d36fabae42077a034655a8457eb75bff", "testharness" diff --git a/tests/wpt/mozilla/tests/mozilla/unitless-length.html b/tests/wpt/mozilla/tests/mozilla/unitless-length.html new file mode 100644 index 00000000000..a79520844db --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/unitless-length.html @@ -0,0 +1,219 @@ + + + + The unitless length quirk + + + + + +
+ + + + + +