From 1da42403ec84fcbb634a816bec0618e47d5e0b70 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sat, 5 Sep 2020 18:44:16 +0000 Subject: Issue #1525 - Kill marquee element (uplift) --- layout/base/crashtests/265027-1.html | 19 - layout/base/crashtests/265986-1.html | 10 - layout/base/crashtests/265999-1.html | 8 - layout/base/crashtests/367498-2.html | 14 - layout/base/crashtests/404491-1.html | 5 - layout/base/crashtests/580129-1.html | 19 - layout/base/crashtests/580494-1.html | 1 - layout/base/crashtests/597924-1.html | 16 - layout/generic/crashtests/265867-1.html | 11 - layout/generic/crashtests/348510-1.html | 7 - layout/generic/crashtests/348510-2.html | 7 - layout/generic/crashtests/363722-1.html | 9 - layout/generic/crashtests/363722-2.html | 10 - layout/generic/crashtests/370866-1.xhtml | 14 - layout/generic/crashtests/379917-1.xhtml | 35 - layout/generic/crashtests/398332-3.html | 4 - layout/generic/crashtests/421671.html | 202 ------ layout/generic/crashtests/619021.html | 5 - layout/generic/crashtests/724235.html | 28 - layout/reftests/bidi/logicalmarquee.html | 11 - layout/reftests/bidi/marquee-ref.html | 11 - layout/reftests/bidi/reftest-stylo.list | 3 - layout/reftests/bidi/reftest.list | 3 - layout/reftests/bidi/visualmarquee.html | 11 - layout/reftests/marquee/1160342-1.html | 10 - layout/reftests/marquee/1160342-2.html | 10 - layout/reftests/marquee/1160342-ref.html | 10 - layout/reftests/marquee/166591-dynamic-1-ref.html | 6 - layout/reftests/marquee/166591-dynamic-1.html | 11 - layout/reftests/marquee/336736-1-ref.html | 5 - layout/reftests/marquee/336736-1a.html | 13 - layout/reftests/marquee/336736-1b.html | 13 - layout/reftests/marquee/406073-1-ref.html | 11 - layout/reftests/marquee/406073-1.html | 23 - layout/reftests/marquee/407016-2-ref.html | 5 - layout/reftests/marquee/407016-2.html | 7 - layout/reftests/marquee/413027-4-ref.html | 10 - layout/reftests/marquee/413027-4.html | 15 - layout/reftests/marquee/425247-1-ref.html | 9 - layout/reftests/marquee/425247-1.html | 9 - layout/reftests/marquee/425247-2-ref.html | 9 - layout/reftests/marquee/425247-2.html | 9 - layout/reftests/marquee/429849-1-ref.html | 10 - layout/reftests/marquee/429849-1.html | 10 - layout/reftests/marquee/reftest-stylo.list | 16 - layout/reftests/marquee/reftest.list | 11 - layout/reftests/moz.build | 2 - layout/reftests/reftest-stylo.list | 3 - layout/reftests/reftest.list | 3 - layout/reftests/writing-mode/reftest-stylo.list | 2 - layout/reftests/writing-mode/reftest.list | 2 - .../writing-mode/ua-style-sheet-size-1-ref.html | 22 - .../writing-mode/ua-style-sheet-size-1.html | 19 - .../writing-mode/ua-style-sheet-size-2-ref.html | 22 - .../writing-mode/ua-style-sheet-size-2.html | 19 - layout/style/contenteditable.css | 9 - layout/style/moz.build | 1 - layout/style/nsCSSParser.cpp | 24 +- layout/style/res/html.css | 17 - layout/style/xbl-marquee/jar.mn | 8 - layout/style/xbl-marquee/moz.build | 7 - layout/style/xbl-marquee/xbl-marquee.css | 12 - layout/style/xbl-marquee/xbl-marquee.xml | 733 --------------------- 63 files changed, 11 insertions(+), 1589 deletions(-) delete mode 100644 layout/base/crashtests/265027-1.html delete mode 100644 layout/base/crashtests/265986-1.html delete mode 100644 layout/base/crashtests/265999-1.html delete mode 100644 layout/base/crashtests/367498-2.html delete mode 100644 layout/base/crashtests/404491-1.html delete mode 100644 layout/base/crashtests/580129-1.html delete mode 100644 layout/base/crashtests/580494-1.html delete mode 100644 layout/base/crashtests/597924-1.html delete mode 100644 layout/generic/crashtests/265867-1.html delete mode 100644 layout/generic/crashtests/348510-1.html delete mode 100644 layout/generic/crashtests/348510-2.html delete mode 100644 layout/generic/crashtests/363722-1.html delete mode 100644 layout/generic/crashtests/363722-2.html delete mode 100644 layout/generic/crashtests/370866-1.xhtml delete mode 100644 layout/generic/crashtests/379917-1.xhtml delete mode 100644 layout/generic/crashtests/398332-3.html delete mode 100644 layout/generic/crashtests/421671.html delete mode 100644 layout/generic/crashtests/619021.html delete mode 100644 layout/generic/crashtests/724235.html delete mode 100644 layout/reftests/bidi/logicalmarquee.html delete mode 100644 layout/reftests/bidi/marquee-ref.html delete mode 100644 layout/reftests/bidi/visualmarquee.html delete mode 100644 layout/reftests/marquee/1160342-1.html delete mode 100644 layout/reftests/marquee/1160342-2.html delete mode 100644 layout/reftests/marquee/1160342-ref.html delete mode 100644 layout/reftests/marquee/166591-dynamic-1-ref.html delete mode 100644 layout/reftests/marquee/166591-dynamic-1.html delete mode 100644 layout/reftests/marquee/336736-1-ref.html delete mode 100644 layout/reftests/marquee/336736-1a.html delete mode 100644 layout/reftests/marquee/336736-1b.html delete mode 100644 layout/reftests/marquee/406073-1-ref.html delete mode 100644 layout/reftests/marquee/406073-1.html delete mode 100644 layout/reftests/marquee/407016-2-ref.html delete mode 100644 layout/reftests/marquee/407016-2.html delete mode 100644 layout/reftests/marquee/413027-4-ref.html delete mode 100644 layout/reftests/marquee/413027-4.html delete mode 100644 layout/reftests/marquee/425247-1-ref.html delete mode 100644 layout/reftests/marquee/425247-1.html delete mode 100644 layout/reftests/marquee/425247-2-ref.html delete mode 100644 layout/reftests/marquee/425247-2.html delete mode 100644 layout/reftests/marquee/429849-1-ref.html delete mode 100644 layout/reftests/marquee/429849-1.html delete mode 100644 layout/reftests/marquee/reftest-stylo.list delete mode 100644 layout/reftests/marquee/reftest.list delete mode 100644 layout/reftests/writing-mode/ua-style-sheet-size-1-ref.html delete mode 100644 layout/reftests/writing-mode/ua-style-sheet-size-1.html delete mode 100644 layout/reftests/writing-mode/ua-style-sheet-size-2-ref.html delete mode 100644 layout/reftests/writing-mode/ua-style-sheet-size-2.html delete mode 100644 layout/style/xbl-marquee/jar.mn delete mode 100644 layout/style/xbl-marquee/moz.build delete mode 100644 layout/style/xbl-marquee/xbl-marquee.css delete mode 100644 layout/style/xbl-marquee/xbl-marquee.xml (limited to 'layout') diff --git a/layout/base/crashtests/265027-1.html b/layout/base/crashtests/265027-1.html deleted file mode 100644 index 9b455da41..000000000 --- a/layout/base/crashtests/265027-1.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - -Attack of the marquees! - - diff --git a/layout/base/crashtests/265986-1.html b/layout/base/crashtests/265986-1.html deleted file mode 100644 index 8d4ca290f..000000000 --- a/layout/base/crashtests/265986-1.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - -W - - diff --git a/layout/base/crashtests/265999-1.html b/layout/base/crashtests/265999-1.html deleted file mode 100644 index 7e6e3d416..000000000 --- a/layout/base/crashtests/265999-1.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/layout/base/crashtests/367498-2.html b/layout/base/crashtests/367498-2.html deleted file mode 100644 index 2c85ac0a4..000000000 --- a/layout/base/crashtests/367498-2.html +++ /dev/null @@ -1,14 +0,0 @@ - - - -
- - - - - -
-
- - - diff --git a/layout/base/crashtests/404491-1.html b/layout/base/crashtests/404491-1.html deleted file mode 100644 index 540a0f6a1..000000000 --- a/layout/base/crashtests/404491-1.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/layout/base/crashtests/580129-1.html b/layout/base/crashtests/580129-1.html deleted file mode 100644 index 228051b5a..000000000 --- a/layout/base/crashtests/580129-1.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - diff --git a/layout/base/crashtests/580494-1.html b/layout/base/crashtests/580494-1.html deleted file mode 100644 index c76125f74..000000000 --- a/layout/base/crashtests/580494-1.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/layout/base/crashtests/597924-1.html b/layout/base/crashtests/597924-1.html deleted file mode 100644 index d855997ee..000000000 --- a/layout/base/crashtests/597924-1.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - diff --git a/layout/generic/crashtests/265867-1.html b/layout/generic/crashtests/265867-1.html deleted file mode 100644 index e9da8c7f6..000000000 --- a/layout/generic/crashtests/265867-1.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/layout/generic/crashtests/348510-1.html b/layout/generic/crashtests/348510-1.html deleted file mode 100644 index 6e00e71f1..000000000 --- a/layout/generic/crashtests/348510-1.html +++ /dev/null @@ -1,7 +0,0 @@ - - - -
-
-
-aaaaaaa diff --git a/layout/generic/crashtests/348510-2.html b/layout/generic/crashtests/348510-2.html deleted file mode 100644 index 8f8c998cf..000000000 --- a/layout/generic/crashtests/348510-2.html +++ /dev/null @@ -1,7 +0,0 @@ -- - - -
-
-a \ No newline at end of file diff --git a/layout/generic/crashtests/363722-1.html b/layout/generic/crashtests/363722-1.html deleted file mode 100644 index f83671c5a..000000000 --- a/layout/generic/crashtests/363722-1.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - I am a double-marquee. - - - - diff --git a/layout/generic/crashtests/363722-2.html b/layout/generic/crashtests/363722-2.html deleted file mode 100644 index 1a12a227e..000000000 --- a/layout/generic/crashtests/363722-2.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - [inside OUTER marquee] - - [inside INNER marquee] - - - - diff --git a/layout/generic/crashtests/370866-1.xhtml b/layout/generic/crashtests/370866-1.xhtml deleted file mode 100644 index dbc673cc4..000000000 --- a/layout/generic/crashtests/370866-1.xhtml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - -
- X -
- - - - diff --git a/layout/generic/crashtests/379917-1.xhtml b/layout/generic/crashtests/379917-1.xhtml deleted file mode 100644 index a99bd7f4a..000000000 --- a/layout/generic/crashtests/379917-1.xhtml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - -
xע -m -
- - - diff --git a/layout/generic/crashtests/398332-3.html b/layout/generic/crashtests/398332-3.html deleted file mode 100644 index 991aa6d3d..000000000 --- a/layout/generic/crashtests/398332-3.html +++ /dev/null @@ -1,4 +0,0 @@ -"Ë”Öqü®Û; - - - diff --git a/layout/generic/crashtests/421671.html b/layout/generic/crashtests/421671.html deleted file mode 100644 index e3919e635..000000000 --- a/layout/generic/crashtests/421671.html +++ /dev/null @@ -1,202 +0,0 @@ - - - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> - -<a> -<a> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -<a> -<a> -<a> -<a> - -<a> -<a> - -<a> -<a> \ No newline at end of file diff --git a/layout/generic/crashtests/619021.html b/layout/generic/crashtests/619021.html deleted file mode 100644 index 586c0f2db..000000000 --- a/layout/generic/crashtests/619021.html +++ /dev/null @@ -1,5 +0,0 @@ -<foo> <marquee> <marquee> <marquee> <marquee> <marquee> <marquee> -<foo> <marquee> <foo> <marquee> <foo> <object> <marquee> <foo> -<marquee> <marquee> <foo> <foo> <marquee> <marquee> <foo> <marquee> -<marquee> <marquee> <foo> <marquee> <foo> <foo> <marquee> <marquee> -<marquee> </marquee> <foo> <foo> <pre> diff --git a/layout/generic/crashtests/724235.html b/layout/generic/crashtests/724235.html deleted file mode 100644 index 7054a99f5..000000000 --- a/layout/generic/crashtests/724235.html +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -<title>Testcase for bug 724235</title> -</head> - -<body onload="setTimeout(function(){m=document.getElementsByTagName('marquee')[0]; m.style.fontSize='72px'},0)"> - -<a href="#"> - -<center> - -<marquee>This is a marquee ... </marquee> - -<table> - <tr> - <td><a href="#">click me to CRASH!</a></td> - </tr> -</table> - -<iframe></iframe> - -<script>document.body.offsetHeight;</script> - -<a href="#"></a> - - -</body></html> diff --git a/layout/reftests/bidi/logicalmarquee.html b/layout/reftests/bidi/logicalmarquee.html deleted file mode 100644 index cb13827de..000000000 --- a/layout/reftests/bidi/logicalmarquee.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML> -<html> - <head> - <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8-i"> - <title>Marquee in Logical Hebrew</title> - </head> - - <body> - <marquee scrollamount="0" behavior="alternate" direction="right">&#x05E2;&#x05D3; &#x05E9;&#x05D9;&#x05E4;&#x05D5;&#x05D7; &#x05D4;&#x05D9;&#x05D5;&#x05DD; &#x05D5;&#x05E0;&#x05E1;&#x05D5; &#x05D4;&#x05E6;&#x05DC;&#x05D9;&#x05DC;&#x05D9;&#x05DD;</marquee> - </body> -</html> diff --git a/layout/reftests/bidi/marquee-ref.html b/layout/reftests/bidi/marquee-ref.html deleted file mode 100644 index d8778dc88..000000000 --- a/layout/reftests/bidi/marquee-ref.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML> -<html> - <head> - <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8-i"> - <title>Marquee in Logical Hebrew</title> - </head> - - <body> - <div dir="rtl" align="left">&#x05E2;&#x05D3; &#x05E9;&#x05D9;&#x05E4;&#x05D5;&#x05D7; &#x05D4;&#x05D9;&#x05D5;&#x05DD; &#x05D5;&#x05E0;&#x05E1;&#x05D5; &#x05D4;&#x05E6;&#x05DC;&#x05D9;&#x05DC;&#x05D9;&#x05DD;</div> - </body> -</html> diff --git a/layout/reftests/bidi/reftest-stylo.list b/layout/reftests/bidi/reftest-stylo.list index b6a48f9ca..d0a854e7f 100644 --- a/layout/reftests/bidi/reftest-stylo.list +++ b/layout/reftests/bidi/reftest-stylo.list @@ -21,9 +21,6 @@ skip == bidiSVG-03.svg bidiSVG-03.svg == bidiSVG-04.svg bidiSVG-04.svg == bidiSVG-05.svg bidiSVG-05.svg random-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) HTTP(..) == bidiMirroring.svg bidiMirroring.svg -fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == visualmarquee.html visualmarquee.html -fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == logicalmarquee.html logicalmarquee.html -== visualmarquee.html visualmarquee.html # test for glyph mirroring in right-to-left text == mirroring-01.html mirroring-01.html # quote marks are not supposed to mirror, but Unicode 5.0 said they should, so some systems do it diff --git a/layout/reftests/bidi/reftest.list b/layout/reftests/bidi/reftest.list index eeabd0beb..5044e657f 100644 --- a/layout/reftests/bidi/reftest.list +++ b/layout/reftests/bidi/reftest.list @@ -18,9 +18,6 @@ random-if(cocoaWidget) == bidi-006-j.html bidi-006-ref.html # bug 734313 fuzzy-if(skiaContent,1,1) == bidiSVG-04.svg bidiSVG-04-ref.svg == bidiSVG-05.svg bidiSVG-05-ref.svg random-if(/^Windows\x20NT\x205\.1/.test(http.oscpu)) HTTP(..) == bidiMirroring.svg bidiMirroring-ref.svg -fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == visualmarquee.html marquee-ref.html -fuzzy-if(Android,9,134) random-if(layersGPUAccelerated) == logicalmarquee.html marquee-ref.html -== visualmarquee.html logicalmarquee.html # test for glyph mirroring in right-to-left text == mirroring-01.html mirroring-01-ref.html # quote marks are not supposed to mirror, but Unicode 5.0 said they should, so some systems do it diff --git a/layout/reftests/bidi/visualmarquee.html b/layout/reftests/bidi/visualmarquee.html deleted file mode 100644 index 932fd775a..000000000 --- a/layout/reftests/bidi/visualmarquee.html +++ /dev/null @@ -1,11 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> -<html> - <head> - <meta http-equiv="Content-type" content="text/html; charset=iso-8859-8"> - <title>Marquee in Visual Hebrew</title> - </head> - - <body> - <marquee scrollamount="0" behavior="alternate" direction="right">&#x05DD;&#x05D9;&#x05DC;&#x05D9;&#x05DC;&#x05E6;&#x05D4; &#x05D5;&#x05E1;&#x05E0;&#x05D5; &#x05DD;&#x05D5;&#x05D9;&#x05D4; &#x05D7;&#x05D5;&#x05E4;&#x05D9;&#x05E9; &#x05D3;&#x05E2;</marquee> - </body> -</html> diff --git a/layout/reftests/marquee/1160342-1.html b/layout/reftests/marquee/1160342-1.html deleted file mode 100644 index 85e7215fb..000000000 --- a/layout/reftests/marquee/1160342-1.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title>Bug 1160342 - Implement marquee using mutation observers</title> -</head> -<body onload="document.getElementById('a').setAttribute('behavior', 'alternate')"> -<marquee id="a" scrollamount=0 direction=right> -This text should be visible -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/1160342-2.html b/layout/reftests/marquee/1160342-2.html deleted file mode 100644 index 99b288568..000000000 --- a/layout/reftests/marquee/1160342-2.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title>Bug 1160342 - Implement marquee using mutation observers</title> -</head> -<body onload="document.getElementById('a').setAttribute('direction', 'right')"> -<marquee id="a" behavior=alternate scrollamount=0> -This text should be visible -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/1160342-ref.html b/layout/reftests/marquee/1160342-ref.html deleted file mode 100644 index d56c90642..000000000 --- a/layout/reftests/marquee/1160342-ref.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title>Bug 1160342 - Implement marquee using mutation observers</title> -</head> -<body> -<marquee id="a" behavior=alternate scrollamount=0 direction=right> -This text should be visible -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/166591-dynamic-1-ref.html b/layout/reftests/marquee/166591-dynamic-1-ref.html deleted file mode 100644 index a9bed7d5f..000000000 --- a/layout/reftests/marquee/166591-dynamic-1-ref.html +++ /dev/null @@ -1,6 +0,0 @@ -<html><head> -</head> -<body> -<div id="test"><marquee behavior="alternate" scrollamount="0">dynamic marquee</marquee></div> -</body> -</html> \ No newline at end of file diff --git a/layout/reftests/marquee/166591-dynamic-1.html b/layout/reftests/marquee/166591-dynamic-1.html deleted file mode 100644 index 278b2a37b..000000000 --- a/layout/reftests/marquee/166591-dynamic-1.html +++ /dev/null @@ -1,11 +0,0 @@ -<html><head> -<script> -function init() { - document.getElementById('test').innerHTML = '<marquee behavior="alternate" scrollamount="0">dynamic marquee</marquee>'; -} -</script> -</head> -<body onload="init();"> -<div id="test"></div> -</body> -</html> \ No newline at end of file diff --git a/layout/reftests/marquee/336736-1-ref.html b/layout/reftests/marquee/336736-1-ref.html deleted file mode 100644 index 116e5ade2..000000000 --- a/layout/reftests/marquee/336736-1-ref.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -<div style="background: green; width: 50px">&nbsp;</div> -</body> -</html> diff --git a/layout/reftests/marquee/336736-1a.html b/layout/reftests/marquee/336736-1a.html deleted file mode 100644 index fb54f3060..000000000 --- a/layout/reftests/marquee/336736-1a.html +++ /dev/null @@ -1,13 +0,0 @@ -<html> -<body dir="rtl"> -<!-- The "alternate" behavior is necessary for the - marquee text to start out on the screen. --> -<marquee - direction="right" - scrollamount="0" - behavior="alternate" -> -<div style="background: green; width: 50px">&nbsp;</div> -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/336736-1b.html b/layout/reftests/marquee/336736-1b.html deleted file mode 100644 index 85338167c..000000000 --- a/layout/reftests/marquee/336736-1b.html +++ /dev/null @@ -1,13 +0,0 @@ -<html> -<body> -<!-- The "alternate" behavior is necessary for the - marquee text to start out on the screen. --> -<marquee - direction="right" - scrollamount="0" - behavior="alternate" -> -<div style="background: green; width: 50px">&nbsp;</div> -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/406073-1-ref.html b/layout/reftests/marquee/406073-1-ref.html deleted file mode 100644 index 751bb5db7..000000000 --- a/layout/reftests/marquee/406073-1-ref.html +++ /dev/null @@ -1,11 +0,0 @@ -<html class="reftest-wait"> -<body style="border:3px solid;" onload="setTimeout(doe, 0)"> -<marquee behavior="alternate" scrollamount="100"><span style="background-color: lime;">marquee</span></marquee> - <script> - function doe() { - document.getElementsByTagName('marquee')[0].stop(); - document.documentElement.className = ""; - } - </script> -</body> -</html> diff --git a/layout/reftests/marquee/406073-1.html b/layout/reftests/marquee/406073-1.html deleted file mode 100644 index 01787afda..000000000 --- a/layout/reftests/marquee/406073-1.html +++ /dev/null @@ -1,23 +0,0 @@ -<html class="reftest-wait"> -<body style="border:3px solid;" onload="setTimeout(doe, 0)"> -<marquee behavior="alternate" scrollamount="100"><span style="background-color: lime;">marquee</span></marquee> - <script> - function doe() { - document.getElementsByTagName('marquee')[0].stop(); - document.getElementsByTagName('marquee')[0].start(); - document.getElementsByTagName('marquee')[0].stop(); - document.getElementsByTagName('marquee')[0].start(); - document.getElementsByTagName('marquee')[0].stop(); - document.getElementsByTagName('marquee')[0].start(); - document.getElementsByTagName('marquee')[0].stop(); - document.getElementsByTagName('marquee')[0].start(); - document.getElementsByTagName('marquee')[0].stop(); - document.getElementsByTagName('marquee')[0].start(); - document.getElementsByTagName('marquee')[0].stop(); - document.getElementsByTagName('marquee')[0].start(); - document.getElementsByTagName('marquee')[0].stop(); - document.documentElement.className = ""; - } - </script> -</body> -</html> diff --git a/layout/reftests/marquee/407016-2-ref.html b/layout/reftests/marquee/407016-2-ref.html deleted file mode 100644 index 25fee1b7d..000000000 --- a/layout/reftests/marquee/407016-2-ref.html +++ /dev/null @@ -1,5 +0,0 @@ -<html> -<body> -<div style="background-color: lime; height: 50px;"></div> -</body> -</html> diff --git a/layout/reftests/marquee/407016-2.html b/layout/reftests/marquee/407016-2.html deleted file mode 100644 index 65e1273b9..000000000 --- a/layout/reftests/marquee/407016-2.html +++ /dev/null @@ -1,7 +0,0 @@ -<html> -<body> -<marquee scrollamount="0" style="height: 50px; background-color: lime;"> -<div style="width: 9999px;">&nbsp;</div> -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/413027-4-ref.html b/layout/reftests/marquee/413027-4-ref.html deleted file mode 100644 index 22fdd42e6..000000000 --- a/layout/reftests/marquee/413027-4-ref.html +++ /dev/null @@ -1,10 +0,0 @@ -<html><head> -<title>Testcase for bug 413027 - Marquee height is sized too small, clipping text vertically</title> -</head> -<body> - -<div style="background-color: lime; width: 600px; float:left;"> - <div style="margin: 100px 0px; padding-left: 2px;">text</div> -</div> - -</body></html> diff --git a/layout/reftests/marquee/413027-4.html b/layout/reftests/marquee/413027-4.html deleted file mode 100644 index d57f2f121..000000000 --- a/layout/reftests/marquee/413027-4.html +++ /dev/null @@ -1,15 +0,0 @@ -<html><head> -<title>Testcase for bug 413027 - Marquee height is sized too small, clipping text vertically</title> -</head> -<body> - -<marquee scrollamount="0" behavior="alternate" direction="right" style="background-color: lime; width: 600px;"> -<div> -<!-- padding-left used to avoid risk of an antialiasing pixel that may - project to the left of the origin, causing a spurious test failure - (see bugs 476927, 475968) --> - <div style="margin: 100px 0px; padding-left: 2px;">text</div> -</div> -</marquee> - -</body></html> diff --git a/layout/reftests/marquee/425247-1-ref.html b/layout/reftests/marquee/425247-1-ref.html deleted file mode 100644 index 3b3a84d41..000000000 --- a/layout/reftests/marquee/425247-1-ref.html +++ /dev/null @@ -1,9 +0,0 @@ -<html><head> -<title>Bug 425247 – Marquee with uppercase UP or DOWN as direction doesn't work properly</title> -</head> -<body> -<marquee direction="up" bgcolor="magenta" behavior="alternate" scrollamount="0"> -<marquee bgcolor="yellow" behavior="alternate" scrollamount="0">marquee up</marquee> -</marquee> -</body> -</html> \ No newline at end of file diff --git a/layout/reftests/marquee/425247-1.html b/layout/reftests/marquee/425247-1.html deleted file mode 100644 index dfa5021c4..000000000 --- a/layout/reftests/marquee/425247-1.html +++ /dev/null @@ -1,9 +0,0 @@ -<html><head> -<title>Bug 425247 – Marquee with uppercase UP or DOWN as direction doesn't work properly</title> -</head> -<body> -<MARQUEE DIRECTION=UP BGCOLOR=MAGENTA BEHAVIOR=ALTERNATE SCROLLAMOUNT=0> -<MARQUEE BGCOLOR=YELLOW BEHAVIOR=ALTERNATE SCROLLAMOUNT=0>marquee up</MARQUEE> -</MARQUEE> -</body> -</html> \ No newline at end of file diff --git a/layout/reftests/marquee/425247-2-ref.html b/layout/reftests/marquee/425247-2-ref.html deleted file mode 100644 index 564d74979..000000000 --- a/layout/reftests/marquee/425247-2-ref.html +++ /dev/null @@ -1,9 +0,0 @@ -<html><head> -<title>Bug 425247 – Marquee with uppercase UP or DOWN as direction doesn't work properly</title> -</head> -<body> -<marquee direction="down" bgcolor="magenta" behavior="alternate" scrollamount="0"> -<marquee bgcolor="yellow" behavior="alternate" scrollamount="0">marquee down</marquee> -</marquee> -</body> -</html> \ No newline at end of file diff --git a/layout/reftests/marquee/425247-2.html b/layout/reftests/marquee/425247-2.html deleted file mode 100644 index 4cb66b901..000000000 --- a/layout/reftests/marquee/425247-2.html +++ /dev/null @@ -1,9 +0,0 @@ -<html><head> -<title>Bug 425247 – Marquee with uppercase UP or DOWN as direction doesn't work properly</title> -</head> -<body> -<MARQUEE DIRECTION=DOWN BGCOLOR=MAGENTA BEHAVIOR=ALTERNATE SCROLLAMOUNT=0> -<MARQUEE BGCOLOR=YELLOW BEHAVIOR=ALTERNATE SCROLLAMOUNT=0>marquee down</MARQUEE> -</MARQUEE> -</body> -</html> \ No newline at end of file diff --git a/layout/reftests/marquee/429849-1-ref.html b/layout/reftests/marquee/429849-1-ref.html deleted file mode 100644 index 3b9c3166e..000000000 --- a/layout/reftests/marquee/429849-1-ref.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title>Bug 429849 – marquee text not on one line , part of this line on top and second part on bottom</title> -</head> -<body> -<marquee behavior=alternate scrollamount=0 direction=right> -This text should be on one line -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/429849-1.html b/layout/reftests/marquee/429849-1.html deleted file mode 100644 index 6b1757fd0..000000000 --- a/layout/reftests/marquee/429849-1.html +++ /dev/null @@ -1,10 +0,0 @@ -<html> -<head> -<title>Bug 429849 – marquee text not on one line , part of this line on top and second part on bottom</title> -</head> -<body> -<marquee behavior=alternate scrollamount=0 direction=right> -This text <script>document.body.offsetHeight;</script>should be on one line -</marquee> -</body> -</html> diff --git a/layout/reftests/marquee/reftest-stylo.list b/layout/reftests/marquee/reftest-stylo.list deleted file mode 100644 index 26c77acf9..000000000 --- a/layout/reftests/marquee/reftest-stylo.list +++ /dev/null @@ -1,16 +0,0 @@ -# DO NOT EDIT! This is a auto-generated temporary list for Stylo testing -random-if((B2G&&browserIsRemote)||Mulet) == 166591-dynamic-1.html 166591-dynamic-1.html -# Initial mulet triage: parity with B2G/B2G Desktop -skip-if(B2G) fuzzy-if(Android,8,50) == 336736-1a.html 336736-1a.html -# Bug 1168747 for random b2g timeouts -skip-if(B2G) fuzzy-if(Android,8,50) == 336736-1b.html 336736-1b.html -# Bug 1168747 for random b2g timeouts -== 406073-1.html 406073-1.html -== 407016-2.html 407016-2.html -fuzzy-if(Android,8,220) == 413027-4.html 413027-4.html -fuzzy-if(Android,8,30) == 425247-1.html 425247-1.html -fuzzy-if(Android,8,30) == 425247-2.html 425247-2.html -random == 429849-1.html 429849-1.html -# bug 432288 -== 1160342-1.html 1160342-1.html -== 1160342-2.html 1160342-2.html diff --git a/layout/reftests/marquee/reftest.list b/layout/reftests/marquee/reftest.list deleted file mode 100644 index f033b4634..000000000 --- a/layout/reftests/marquee/reftest.list +++ /dev/null @@ -1,11 +0,0 @@ -== 166591-dynamic-1.html 166591-dynamic-1-ref.html -fuzzy-if(Android,8,50) == 336736-1a.html 336736-1-ref.html -fuzzy-if(Android,8,50) == 336736-1b.html 336736-1-ref.html -== 406073-1.html 406073-1-ref.html -== 407016-2.html 407016-2-ref.html -fuzzy-if(Android,8,220) == 413027-4.html 413027-4-ref.html -fuzzy-if(Android,8,30) == 425247-1.html 425247-1-ref.html -fuzzy-if(Android,8,30) == 425247-2.html 425247-2-ref.html -random == 429849-1.html 429849-1-ref.html # bug 432288 -== 1160342-1.html 1160342-ref.html -== 1160342-2.html 1160342-ref.html diff --git a/layout/reftests/moz.build b/layout/reftests/moz.build index d486e5639..3ab3d4246 100644 --- a/layout/reftests/moz.build +++ b/layout/reftests/moz.build @@ -201,8 +201,6 @@ with Files('list-item/**'): BUG_COMPONENT = ('Core', 'Layout: Block and Inline') with Files('margin-collapsing/**'): BUG_COMPONENT = ('Core', 'Layout: Block and Inline') -with Files('marquee/**'): - BUG_COMPONENT = ('Core', 'CSS Parsing and Computation') with Files('mathml/**'): BUG_COMPONENT = ('Core', 'MathML') with Files('native-theme/**'): diff --git a/layout/reftests/reftest-stylo.list b/layout/reftests/reftest-stylo.list index 7d4078f22..54afc3dac 100644 --- a/layout/reftests/reftest-stylo.list +++ b/layout/reftests/reftest-stylo.list @@ -249,9 +249,6 @@ include mathml/reftest-stylo.list # margin-collapsing include margin-collapsing/reftest-stylo.list -# marquee/ -include marquee/reftest-stylo.list - # native-theme/ # skipping for B2G since something around radio-nonnative.html makes the whole suite hang skip-if(B2G||Android||Mulet) include native-theme/reftest-stylo.list diff --git a/layout/reftests/reftest.list b/layout/reftests/reftest.list index b2da025d5..b06eba58e 100644 --- a/layout/reftests/reftest.list +++ b/layout/reftests/reftest.list @@ -247,9 +247,6 @@ include mathml/reftest.list # margin-collapsing include margin-collapsing/reftest.list -# marquee/ -include marquee/reftest.list - # native-theme/ # (no XUL theme on Android) skip-if(Android) include native-theme/reftest.list diff --git a/layout/reftests/writing-mode/reftest-stylo.list b/layout/reftests/writing-mode/reftest-stylo.list index 5574d9b5b..76f6813e6 100644 --- a/layout/reftests/writing-mode/reftest-stylo.list +++ b/layout/reftests/writing-mode/reftest-stylo.list @@ -65,8 +65,6 @@ HTTP(..) == 1115916-1-vertical-metrics.html 1115916-1-vertical-metrics.html == ua-style-sheet-border-3.html ua-style-sheet-border-3.html == ua-style-sheet-border-4.html ua-style-sheet-border-4.html == ua-style-sheet-border-5.html ua-style-sheet-border-5.html -== ua-style-sheet-size-1.html ua-style-sheet-size-1.html -== ua-style-sheet-size-2.html ua-style-sheet-size-2.html == ua-style-sheet-fieldset-1.html ua-style-sheet-fieldset-1.html skip-if(Android||B2G||Mulet||(winWidget&&!/^Windows\x20NT\x205\.1/.test(http.oscpu))) == ua-style-sheet-textarea-1.html ua-style-sheet-textarea-1.html diff --git a/layout/reftests/writing-mode/reftest.list b/layout/reftests/writing-mode/reftest.list index b670dbd13..13c58d2cb 100644 --- a/layout/reftests/writing-mode/reftest.list +++ b/layout/reftests/writing-mode/reftest.list @@ -58,8 +58,6 @@ fuzzy(116,94) fuzzy-if(winWidget,135,124) HTTP(..) == 1115916-1-vertical-metrics == ua-style-sheet-border-3.html ua-style-sheet-border-3-ref.html == ua-style-sheet-border-4.html ua-style-sheet-border-4-ref.html == ua-style-sheet-border-5.html ua-style-sheet-border-5-ref.html -== ua-style-sheet-size-1.html ua-style-sheet-size-1-ref.html -== ua-style-sheet-size-2.html ua-style-sheet-size-2-ref.html == ua-style-sheet-fieldset-1.html ua-style-sheet-fieldset-1-ref.html skip-if(Android||(winWidget&&!/^Windows\x20NT\x205\.1/.test(http.oscpu))) == ua-style-sheet-textarea-1.html ua-style-sheet-textarea-1a-ref.html diff --git a/layout/reftests/writing-mode/ua-style-sheet-size-1-ref.html b/layout/reftests/writing-mode/ua-style-sheet-size-1-ref.html deleted file mode 100644 index 06f6d5700..000000000 --- a/layout/reftests/writing-mode/ua-style-sheet-size-1-ref.html +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE html> -<meta charset=utf-8> -<title>Test for logical margins on marquee elements in the UA style sheet</title> -<style> -.v-rl { writing-mode: vertical-rl; } -.ltr, .rtl, .v-rl { border: 1px solid blue; padding: 16px; } -marquee { background-color: yellow; color: transparent; } -.ltr marquee { width: -moz-available; height: auto; } -.rtl marquee { width: -moz-available; height: auto; } -.v-rl marquee { width: auto; height: -moz-available; } -</style> -<div class=ltr> - <marquee>A</marquee> -</div> -<div class=rtl dir=rtl> - <marquee>A</marquee> -</div> -<!-- disabled until bug 1132308 -<div class=v-rl> - <marquee>A</marquee> -</div> ---> diff --git a/layout/reftests/writing-mode/ua-style-sheet-size-1.html b/layout/reftests/writing-mode/ua-style-sheet-size-1.html deleted file mode 100644 index 754908501..000000000 --- a/layout/reftests/writing-mode/ua-style-sheet-size-1.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE html> -<meta charset=utf-8> -<title>Test for logical sizes on marquee elements in the UA style sheet</title> -<style> -.v-rl { writing-mode: vertical-rl; } -.ltr, .rtl, .v-rl { border: 1px solid blue; padding: 16px; } -marquee { background-color: yellow; color: transparent; } -</style> -<div class=ltr> - <marquee>A</marquee> -</div> -<div class=rtl dir=rtl> - <marquee>A</marquee> -</div> -<!-- disabled until bug 1132308 -<div class=v-rl> - <marquee>A</marquee> -</div> ---> diff --git a/layout/reftests/writing-mode/ua-style-sheet-size-2-ref.html b/layout/reftests/writing-mode/ua-style-sheet-size-2-ref.html deleted file mode 100644 index 3c53326ba..000000000 --- a/layout/reftests/writing-mode/ua-style-sheet-size-2-ref.html +++ /dev/null @@ -1,22 +0,0 @@ -<!DOCTYPE html> -<meta charset=utf-8> -<title>Test for logical margins on marquee elements in the UA style sheet</title> -<style> -.v-rl { writing-mode: vertical-rl; } -.ltr, .rtl, .v-rl { border: 1px solid blue; padding: 16px; } -marquee { background-color: yellow; color: transparent; } -.ltr marquee { width: -moz-available; height: 200px; } -.rtl marquee { width: -moz-available; height: 200px; } -.v-rl marquee { width: 200px; height: -moz-available; } -</style> -<div class=ltr> - <marquee direction=down>A</marquee> -</div> -<div class=rtl dir=rtl> - <marquee direction=down>A</marquee> -</div> -<!-- disabled until bug 1132308 -<div class=v-rl> - <marquee direction=down>A</marquee> -</div> ---> diff --git a/layout/reftests/writing-mode/ua-style-sheet-size-2.html b/layout/reftests/writing-mode/ua-style-sheet-size-2.html deleted file mode 100644 index 1c0be6f4b..000000000 --- a/layout/reftests/writing-mode/ua-style-sheet-size-2.html +++ /dev/null @@ -1,19 +0,0 @@ -<!DOCTYPE html> -<meta charset=utf-8> -<title>Test for logical sizes on marquee elements in the UA style sheet</title> -<style> -.v-rl { writing-mode: vertical-rl; } -.ltr, .rtl, .v-rl { border: 1px solid blue; padding: 16px; } -marquee { background-color: yellow; color: transparent; } -</style> -<div class=ltr> - <marquee direction=down>A</marquee> -</div> -<div class=rtl dir=rtl> - <marquee direction=down>A</marquee> -</div> -<!-- disabled until bug 1132308 -<div class=v-rl> - <marquee direction=down>A</marquee> -</div> ---> diff --git a/layout/style/contenteditable.css b/layout/style/contenteditable.css index c550bc7c9..6d569f75e 100644 --- a/layout/style/contenteditable.css +++ b/layout/style/contenteditable.css @@ -80,15 +80,6 @@ input[contenteditable="true"][type="file"] { -moz-user-focus: none !important; } -/* emulation of non-standard HTML <marquee> tag */ -marquee:-moz-read-write { - -moz-binding: url('chrome://xbl-marquee/content/xbl-marquee.xml#marquee-horizontal-editable'); -} - -marquee[direction="up"]:-moz-read-write, marquee[direction="down"]:-moz-read-write { - -moz-binding: url('chrome://xbl-marquee/content/xbl-marquee.xml#marquee-vertical-editable'); -} - *|*:-moz-read-write > input[type="hidden"], input[contenteditable="true"][type="hidden"] { border: 1px solid black !important; diff --git a/layout/style/moz.build b/layout/style/moz.build index ff06b5101..bdc86ee99 100644 --- a/layout/style/moz.build +++ b/layout/style/moz.build @@ -19,7 +19,6 @@ with Files('CSSRuleList.*'): with Files('nsDOM*'): BUG_COMPONENT = ('Core', 'DOM: CSS Object Model') -DIRS += ['xbl-marquee'] TEST_DIRS += ['test'] XPIDL_SOURCES += [ diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 556e35406..f6b84bfac 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -5941,8 +5941,6 @@ CSSParserImpl::ParseAttributeSelector(int32_t& aDataMask, "language", "defer", "type", - // additional attributes not in HTML4 - "direction", // marquee nullptr }; short i = 0; @@ -15318,17 +15316,17 @@ CSSParserImpl::ParseFontFeatureSettings(nsCSSValue& aValue) return true; } -bool -CSSParserImpl::ParseFontVariationSettings(nsCSSValue& aValue) -{ - // TODO: Actually implement this. - - // This stub is here because websites insist on considering this - // very hardware-dependent and O.S.-variable low-level font-control - // as a "critical feature" which it isn't as there is 0 guarantee - // that font variation settings are supported or honored by any - // operating system used by the client. - return true; +bool +CSSParserImpl::ParseFontVariationSettings(nsCSSValue& aValue) +{ + // TODO: Actually implement this. + + // This stub is here because websites insist on considering this + // very hardware-dependent and O.S.-variable low-level font-control + // as a "critical feature" which it isn't as there is 0 guarantee + // that font variation settings are supported or honored by any + // operating system used by the client. + return true; } bool diff --git a/layout/style/res/html.css b/layout/style/res/html.css index 44e41c8d0..b975bf0c9 100644 --- a/layout/style/res/html.css +++ b/layout/style/res/html.css @@ -64,7 +64,6 @@ legend, li, listing, main, -marquee, menu, nav, noframes, @@ -819,25 +818,9 @@ dialog:not([open]) { display: none; } -/* emulation of non-standard HTML <marquee> tag */ -marquee { - inline-size: -moz-available; - display: inline-block; - vertical-align: text-bottom; - text-align: start; - -moz-binding: url('chrome://xbl-marquee/content/xbl-marquee.xml#marquee-horizontal'); -} - -marquee[direction="up"], marquee[direction="down"] { - -moz-binding: url('chrome://xbl-marquee/content/xbl-marquee.xml#marquee-vertical'); - block-size: 200px; -} - /* PRINT ONLY rules follow */ @media print { - marquee { -moz-binding: none; } - } /* Ruby */ diff --git a/layout/style/xbl-marquee/jar.mn b/layout/style/xbl-marquee/jar.mn deleted file mode 100644 index 9247cb4a1..000000000 --- a/layout/style/xbl-marquee/jar.mn +++ /dev/null @@ -1,8 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -toolkit.jar: -% content xbl-marquee %content/xbl-marquee/ contentaccessible=yes - content/xbl-marquee/xbl-marquee.xml - content/xbl-marquee/xbl-marquee.css diff --git a/layout/style/xbl-marquee/moz.build b/layout/style/xbl-marquee/moz.build deleted file mode 100644 index eb4454d28..000000000 --- a/layout/style/xbl-marquee/moz.build +++ /dev/null @@ -1,7 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/layout/style/xbl-marquee/xbl-marquee.css b/layout/style/xbl-marquee/xbl-marquee.css deleted file mode 100644 index e6d3ee94b..000000000 --- a/layout/style/xbl-marquee/xbl-marquee.css +++ /dev/null @@ -1,12 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* PRINT ONLY rules */ -@media print { - - marquee > * > * { - margin: 0 !important; - padding: 0 !important; - } /* This hack is needed until bug 119078 gets fixed */ -} diff --git a/layout/style/xbl-marquee/xbl-marquee.xml b/layout/style/xbl-marquee/xbl-marquee.xml deleted file mode 100644 index bb837624d..000000000 --- a/layout/style/xbl-marquee/xbl-marquee.xml +++ /dev/null @@ -1,733 +0,0 @@ -<?xml version="1.0"?> -<!-- This Source Code Form is subject to the terms of the Mozilla Public - - License, v. 2.0. If a copy of the MPL was not distributed with this - - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - -<bindings id="marqueeBindings" - xmlns="http://www.mozilla.org/xbl" - xmlns:html="http://www.w3.org/1999/xhtml" - xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" - xmlns:xbl="http://www.mozilla.org/xbl"> - - - <binding id="marquee" bindToUntrustedContent="true"> - - <resources> - <stylesheet src="chrome://xbl-marquee/content/xbl-marquee.css"/> - </resources> - <implementation> - - <property name="scrollAmount" exposeToUntrustedContent="true"> - <getter> - <![CDATA[ - this._mutationActor(this._mutationObserver.takeRecords()); - return this._scrollAmount; - ]]> - </getter> - <setter> - <![CDATA[ - var val = parseInt(val); - if (val < 0) { - return; - } - if (isNaN(val)) { - val = 0; - } - this.setAttribute("scrollamount", val); - ]]> - </setter> - </property> - - <property name="scrollDelay" exposeToUntrustedContent="true"> - <getter> - <![CDATA[ - this._mutationActor(this._mutationObserver.takeRecords()); - var val = parseInt(this.getAttribute("scrolldelay")); - - if (val <= 0 || isNaN(val)) { - return this._scrollDelay; - } - - return val; - ]]> - </getter> - <setter> - var val = parseInt(val); - if (val > 0 ) { - this.setAttribute("scrolldelay", val); - } - </setter> - </property> - - <property name="trueSpeed" exposeToUntrustedContent="true"> - <getter> - <![CDATA[ - if (!this.hasAttribute("truespeed")) { - return false; - } - - return true; - ]]> - </getter> - <setter> - <![CDATA[ - if (val) { - this.setAttribute("truespeed", ""); - } else { - this.removeAttribute('truespeed'); - } - ]]> - </setter> - </property> - - <property name="direction" exposeToUntrustedContent="true"> - <getter> - this._mutationActor(this._mutationObserver.takeRecords()); - return this._direction; - </getter> - <setter> - <![CDATA[ - if (typeof val == 'string') { - val = val.toLowerCase(); - } else { - return; - } - if (val != 'left' && val != 'right' && val != 'up' && val != 'down') { - val = 'left'; - } - - this.setAttribute("direction", val); - ]]> - </setter> - </property> - - <property name="behavior" exposeToUntrustedContent="true"> - <getter> - this._mutationActor(this._mutationObserver.takeRecords()); - return this._behavior; - </getter> - <setter> - if (typeof val == 'string') { - val = val.toLowerCase(); - } - if (val == "alternate" || val == "slide" || val == 'scroll') { - this.setAttribute("behavior", val); - } - </setter> - </property> - - - <property name="loop" exposeToUntrustedContent="true"> - <getter> - <![CDATA[ - this._mutationActor(this._mutationObserver.takeRecords()); - return this._loop; - ]]> - </getter> - <setter> - <![CDATA[ - var val = parseInt(val); - if (val == -1 || val > 0) { - this.setAttribute("loop", val); - } - ]]> - </setter> - </property> - - - <property name="onstart" exposeToUntrustedContent="true"> - <getter> - return this.getAttribute("onstart"); - </getter> - <setter> - this._setEventListener("start", val, true); - this.setAttribute("onstart", val); - </setter> - </property> - - <property name="onfinish" exposeToUntrustedContent="true"> - <getter> - return this.getAttribute("onfinish"); - </getter> - <setter> - this._setEventListener("finish", val, true); - this.setAttribute("onfinish", val); - </setter> - </property> - - <property name="onbounce" exposeToUntrustedContent="true"> - <getter> - return this.getAttribute("onbounce"); - </getter> - <setter> - this._setEventListener("bounce", val, true); - this.setAttribute("onbounce", val); - </setter> - </property> - - <property name="outerDiv" - onget="return document.getAnonymousNodes(this)[0]" - /> - - <property name="innerDiv" - onget="return document.getAnonymousElementByAttribute(this, 'class', 'innerDiv');" - /> - - <property name="height" exposeToUntrustedContent="true" - onget="return this.getAttribute('height');" - onset="this.setAttribute('height', val);" - /> - - <property name="width" exposeToUntrustedContent="true" - onget="return this.getAttribute('width');" - onset="this.setAttribute('width', val);" - /> - - <method name="_set_scrollDelay"> - <parameter name="aValue"/> - <body> - <![CDATA[ - aValue = parseInt(aValue); - if (aValue <= 0) { - return; - } else if (isNaN(aValue)) { - this._scrollDelay = 85; - } else if (aValue < 60) { - if (this.trueSpeed == true) { - this._scrollDelay = aValue; - } else { - this._scrollDelay = 60; - } - } else { - this._scrollDelay = aValue; - } - ]]> - </body> - </method> - - <method name="_set_scrollAmount"> - <parameter name="aValue"/> - <body> - <![CDATA[ - aValue = parseInt(aValue); - if (isNaN(aValue)) { - this._scrollAmount = 6; - } else if (aValue < 0) { - return; - } else { - this._scrollAmount = aValue; - } - ]]> - </body> - </method> - - <method name="_set_behavior"> - <parameter name="aValue"/> - <body> - <![CDATA[ - if (typeof aValue == 'string') { - aValue = aValue.toLowerCase(); - } - if (aValue != 'alternate' && aValue != 'slide' && aValue != 'scroll') { - this._behavior = 'scroll'; - } else { - this._behavior = aValue; - } - ]]> - </body> - </method> - - <method name="_set_direction"> - <parameter name="aValue"/> - <body> - <![CDATA[ - if (typeof aValue == 'string') { - aValue = aValue.toLowerCase(); - } - if (aValue != 'left' && aValue != 'right' && aValue != 'up' && aValue != 'down') { - aValue = 'left'; - } - - if (aValue != this._direction) { - this.startNewDirection = true; - } - this._direction = aValue; - ]]> - </body> - </method> - - <method name="_set_loop"> - <parameter name="aValue"/> - <body> - <![CDATA[ - var aValue = parseInt(aValue); - if (aValue == 0) { - return; - } - if (isNaN(aValue) || aValue <= -1) { - aValue = -1; - } - this._loop = aValue; - ]]> - </body> - </method> - - <method name="_setEventListener"> - <parameter name="aName"/> - <parameter name="aValue"/> - <parameter name="aIgnoreNextCall"/> - <body> - <![CDATA[ - // _setEventListener is only used for setting the attribute event - // handlers, which we want to ignore if our document is sandboxed - // without the allow-scripts keyword. - if (document.hasScriptsBlockedBySandbox) { - return true; - } - - // attribute event handlers should only be added if the - // document's CSP allows it. - if (!document.inlineScriptAllowedByCSP) { - return true; - } - - if (this._ignoreNextCall) { - return this._ignoreNextCall = false; - } - - if (aIgnoreNextCall) { - this._ignoreNextCall = true; - } - - if (typeof this["_on" + aName] == 'function') { - this.removeEventListener(aName, this["_on" + aName], false); - } - - switch (typeof aValue) - { - case "function": - this["_on" + aName] = aValue; - this.addEventListener(aName, this["_on" + aName], false); - break; - - case "string": - if (!aIgnoreNextCall) { - try { - // Function Xrays make this simple and safe. \o/ - this["_on" + aName] = new window.Function("event", aValue); - } - catch(e) { - return false; - } - this.addEventListener(aName, this["_on" + aName], false); - } - else { - this["_on" + aName] = aValue; - } - break; - - case "object": - this["_on" + aName] = aValue; - break; - - default: - this._ignoreNextCall = false; - throw new Error("Invalid argument for Marquee::on" + aName); - } - return true; - ]]> - </body> - </method> - - <method name="_fireEvent"> - <parameter name="aName"/> - <parameter name="aBubbles"/> - <parameter name="aCancelable"/> - <body> - <![CDATA[ - var e = document.createEvent("Events"); - e.initEvent(aName, aBubbles, aCancelable); - this.dispatchEvent(e); - ]]> - </body> - </method> - - <method name="start" exposeToUntrustedContent="true"> - <body> - <![CDATA[ - if (this.runId == 0) { - var myThis = this; - var lambda = function myTimeOutFunction(){myThis._doMove(false);} - this.runId = window.setTimeout(lambda, this._scrollDelay - this._deltaStartStop); - this._deltaStartStop = 0; - } - ]]> - </body> - </method> - - <method name="stop" exposeToUntrustedContent="true"> - <body> - <![CDATA[ - if (this.runId != 0) { - this._deltaStartStop = Date.now()- this._lastMoveDate; - clearTimeout(this.runId); - } - - this.runId = 0; - ]]> - </body> - </method> - - <method name="_doMove"> - <parameter name="aResetPosition"/> - <body> - <![CDATA[ - this._lastMoveDate = Date.now(); - - //startNewDirection is true at first load and whenever the direction is changed - if (this.startNewDirection) { - this.startNewDirection = false; //we only want this to run once every scroll direction change - - var corrvalue = 0; - - switch (this._direction) - { - case "up": - var height = document.defaultView.getComputedStyle(this, "").height; - this.outerDiv.style.height = height; - if (this.originalHeight > this.outerDiv.offsetHeight) { - corrvalue = this.originalHeight - this.outerDiv.offsetHeight; - } - this.innerDiv.style.padding = height + " 0"; - this.dirsign = 1; - this.startAt = (this._behavior == 'alternate') ? (this.originalHeight - corrvalue) : 0; - this.stopAt = (this._behavior == 'alternate' || this._behavior == 'slide') ? - (parseInt(height) + corrvalue) : (this.originalHeight + parseInt(height)); - break; - - case "down": - var height = document.defaultView.getComputedStyle(this, "").height; - this.outerDiv.style.height = height; - if (this.originalHeight > this.outerDiv.offsetHeight) { - corrvalue = this.originalHeight - this.outerDiv.offsetHeight; - } - this.innerDiv.style.padding = height + " 0"; - this.dirsign = -1; - this.startAt = (this._behavior == 'alternate') ? - (parseInt(height) + corrvalue) : (this.originalHeight + parseInt(height)); - this.stopAt = (this._behavior == 'alternate' || this._behavior == 'slide') ? - (this.originalHeight - corrvalue) : 0; - break; - - case "right": - if (this.innerDiv.offsetWidth > this.outerDiv.offsetWidth) { - corrvalue = this.innerDiv.offsetWidth - this.outerDiv.offsetWidth; - } - this.dirsign = -1; - this.stopAt = (this._behavior == 'alternate' || this._behavior == 'slide') ? - (this.innerDiv.offsetWidth - corrvalue) : 0; - this.startAt = this.outerDiv.offsetWidth + ((this._behavior == 'alternate') ? - corrvalue : (this.innerDiv.offsetWidth + this.stopAt)); - break; - - case "left": - default: - if (this.innerDiv.offsetWidth > this.outerDiv.offsetWidth) { - corrvalue = this.innerDiv.offsetWidth - this.outerDiv.offsetWidth; - } - this.dirsign = 1; - this.startAt = (this._behavior == 'alternate') ? (this.innerDiv.offsetWidth - corrvalue) : 0; - this.stopAt = this.outerDiv.offsetWidth + - ((this._behavior == 'alternate' || this._behavior == 'slide') ? - corrvalue : (this.innerDiv.offsetWidth + this.startAt)); - } - - if (aResetPosition) { - this.newPosition = this.startAt; - this._fireEvent("start", false, false); - } - } //end if - - this.newPosition = this.newPosition + (this.dirsign * this._scrollAmount); - - if ((this.dirsign == 1 && this.newPosition > this.stopAt) || - (this.dirsign == -1 && this.newPosition < this.stopAt)) - { - switch (this._behavior) - { - case 'alternate': - // lets start afresh - this.startNewDirection = true; - - // swap direction - const swap = {left: "right", down: "up", up: "down", right: "left"}; - this._direction = swap[this._direction]; - this.newPosition = this.stopAt; - - if ((this._direction == "up") || (this._direction == "down")) { - this.outerDiv.scrollTop = this.newPosition; - } else { - this.outerDiv.scrollLeft = this.newPosition; - } - - if (this._loop != 1) { - this._fireEvent("bounce", false, true); - } - break; - - case 'slide': - if (this._loop > 1) { - this.newPosition = this.startAt; - } - break; - - default: - this.newPosition = this.startAt; - - if ((this._direction == "up") || (this._direction == "down")) { - this.outerDiv.scrollTop = this.newPosition; - } else { - this.outerDiv.scrollLeft = this.newPosition; - } - - //dispatch start event, even when this._loop == 1, comp. with IE6 - this._fireEvent("start", false, false); - } - - if (this._loop > 1) { - this._loop--; - } else if (this._loop == 1) { - if ((this._direction == "up") || (this._direction == "down")) { - this.outerDiv.scrollTop = this.stopAt; - } else { - this.outerDiv.scrollLeft = this.stopAt; - } - this.stop(); - this._fireEvent("finish", false, true); - return; - } - } - else { - if ((this._direction == "up") || (this._direction == "down")) { - this.outerDiv.scrollTop = this.newPosition; - } else { - this.outerDiv.scrollLeft = this.newPosition; - } - } - - var myThis = this; - var lambda = function myTimeOutFunction(){myThis._doMove(false);} - this.runId = window.setTimeout(lambda, this._scrollDelay); - ]]> - </body> - </method> - - <method name="init"> - <body> - <![CDATA[ - this.stop(); - - if ((this._direction != "up") && (this._direction != "down")) { - var width = window.getComputedStyle(this, "").width; - this.innerDiv.parentNode.style.margin = '0 ' + width; - - //XXX Adding the margin sometimes causes the marquee to widen, - // see testcase from bug bug 364434: - // https://bugzilla.mozilla.org/attachment.cgi?id=249233 - // Just add a fixed width with current marquee's width for now - if (width != window.getComputedStyle(this, "").width) { - var width = window.getComputedStyle(this, "").width; - this.outerDiv.style.width = width; - this.innerDiv.parentNode.style.margin = '0 ' + width; - } - } - else { - // store the original height before we add padding - this.innerDiv.style.padding = 0; - this.originalHeight = this.innerDiv.offsetHeight; - } - - this._doMove(true); - ]]> - </body> - </method> - - <method name="_mutationActor"> - <parameter name="aMutations"/> - <body> - <![CDATA[ - while (aMutations.length > 0) { - var mutation = aMutations.shift(); - var attrName = mutation.attributeName.toLowerCase(); - var oldValue = mutation.oldValue; - var target = mutation.target; - var newValue = target.getAttribute(attrName); - - if (oldValue != newValue) { - switch (attrName) { - case "loop": - target._set_loop(newValue); - if (target.rundId == 0) { - target.start(); - } - break; - case "scrollamount": - target._set_scrollAmount(newValue); - break; - case "scrolldelay": - target._set_scrollDelay(newValue); - target.stop(); - target.start(); - break; - case "truespeed": - //needed to update target._scrollDelay - var myThis = target; - var lambda = function() {myThis._set_scrollDelay(myThis.getAttribute('scrolldelay'));} - window.setTimeout(lambda, 0); - break; - case "behavior": - target._set_behavior(newValue); - target.startNewDirection = true; - if ((oldValue == "slide" && target.newPosition == target.stopAt) || - newValue == "alternate" || newValue == "slide") { - target.stop(); - target._doMove(true); - } - break; - case "direction": - if (!newValue) { - newValue = "left"; - } - target._set_direction(newValue); - break; - case "width": - case "height": - target.startNewDirection = true; - break; - case "onstart": - target._setEventListener("start", newValue); - break; - case "onfinish": - target._setEventListener("finish", newValue); - break; - case "onbounce": - target._setEventListener("bounce", newValue); - break; - } - } - } - ]]> - </body> - </method> - - <constructor> - <![CDATA[ - // Set up state. - this._scrollAmount = 6; - this._scrollDelay = 85; - this._direction = "left"; - this._behavior = "scroll"; - this._loop = -1; - this.dirsign = 1; - this.startAt = 0; - this.stopAt = 0; - this.newPosition = 0; - this.runId = 0; - this.originalHeight = 0; - this.startNewDirection = true; - - // hack needed to fix js error, see bug 386470 - var myThis = this; - var lambda = function myScopeFunction() { if (myThis.init) myThis.init(); } - - this._set_direction(this.getAttribute('direction')); - this._set_behavior(this.getAttribute('behavior')); - this._set_scrollDelay(this.getAttribute('scrolldelay')); - this._set_scrollAmount(this.getAttribute('scrollamount')); - this._set_loop(this.getAttribute('loop')); - this._setEventListener("start", this.getAttribute("onstart")); - this._setEventListener("finish", this.getAttribute("onfinish")); - this._setEventListener("bounce", this.getAttribute("onbounce")); - this.startNewDirection = true; - - this._mutationObserver = new MutationObserver(this._mutationActor); - this._mutationObserver.observe(this, { attributes: true, - attributeOldValue: true, - attributeFilter: ['loop', 'scrollamount', 'scrolldelay', '', 'truespeed', 'behavior', - 'direction', 'width', 'height', 'onstart', 'onfinish', 'onbounce'] }); - - // init needs to be run after the page has loaded in order to calculate - // the correct height/width - if (document.readyState == "complete") { - lambda(); - } else { - window.addEventListener("load", lambda, false); - } - ]]> - </constructor> - </implementation> - - </binding> - - <binding id="marquee-horizontal" bindToUntrustedContent="true" - extends="chrome://xbl-marquee/content/xbl-marquee.xml#marquee" - inheritstyle="false"> - - <!-- White-space isn't allowed because a marquee could be - inside 'white-space: pre' --> - <content> - <html:div style="display: -moz-box; overflow: hidden; width: -moz-available;" - ><html:div style="display: -moz-box;" - ><html:div class="innerDiv" style="display: table; border-spacing: 0;" - ><html:div - ><children - /></html:div - ></html:div - ></html:div - ></html:div> - </content> - - </binding> - - <binding id="marquee-vertical" bindToUntrustedContent="true" - extends="chrome://xbl-marquee/content/xbl-marquee.xml#marquee" - inheritstyle="false"> - - <!-- White-space isn't allowed because a marquee could be - inside 'white-space: pre' --> - <content> - <html:div style="overflow: hidden; width: -moz-available;" - ><html:div class="innerDiv" - ><children - /></html:div - ></html:div> - </content> - - </binding> - - <binding id="marquee-horizontal-editable" bindToUntrustedContent="true" - inheritstyle="false"> - - <!-- White-space isn't allowed because a marquee could be - inside 'white-space: pre' --> - <content> - <html:div style="display: inline-block; overflow: auto; width: -moz-available;" - ><children - /></html:div> - </content> - - </binding> - - <binding id="marquee-vertical-editable" bindToUntrustedContent="true" - inheritstyle="false"> - - <!-- White-space isn't allowed because a marquee could be - inside 'white-space: pre' --> - <content> - <html:div style="overflow: auto; height: inherit; width: -moz-available;" - ><children/></html:div> - </content> - - </binding> - -</bindings> -- cgit v1.2.3 From abaea77ccbc3658186b2027d2721451e8acb34a3 Mon Sep 17 00:00:00 2001 From: athenian200 <athenian200@outlook.com> Date: Thu, 3 Sep 2020 18:55:28 -0500 Subject: Issue #1641 - Implement CSS flow-root keyword This is just a clean port of 1322191 and follow-up 1325970. It really seems to add create a new way to access existing code relating to block formatting and floating elements rather than implementing new functionality, and it is mercifully straightforwards. --- layout/base/nsCSSFrameConstructor.cpp | 8 +++++--- layout/base/nsLayoutUtils.cpp | 34 ++++++++++++++++++++++++++++++++++ layout/forms/nsLegendFrame.cpp | 4 +--- layout/generic/ReflowInput.cpp | 1 + layout/generic/nsBlockFrame.cpp | 7 ++++--- layout/generic/nsFrameStateBits.h | 3 +++ layout/generic/nsHTMLParts.h | 3 +-- layout/style/nsCSSKeywordList.h | 1 + layout/style/nsCSSProps.cpp | 3 +++ layout/style/nsRuleNode.cpp | 2 ++ layout/style/nsStyleConsts.h | 1 + layout/style/nsStyleStruct.h | 6 ++++-- layout/style/test/property_database.js | 4 ++++ layout/xul/nsXULLabelFrame.cpp | 4 +--- 14 files changed, 65 insertions(+), 16 deletions(-) (limited to 'layout') diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 6642a090d..d28e60740 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -2614,7 +2614,8 @@ nsCSSFrameConstructor::ConstructDocElementFrame(Element* aDocEle newFrame = frameItems.FirstChild(); NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames"); } else { - MOZ_ASSERT(display->mDisplay == StyleDisplay::Block, + MOZ_ASSERT(display->mDisplay == StyleDisplay::Block || + display->mDisplay == StyleDisplay::FlowRoot, "Unhandled display type for root element"); contentFrame = NS_NewBlockFormattingContext(mPresShell, styleContext); nsFrameItems frameItems; @@ -4758,6 +4759,7 @@ nsCSSFrameConstructor::FindDisplayData(const nsStyleDisplay* aDisplay, static const FrameConstructionDataByDisplay sDisplayData[] = { FCDATA_FOR_DISPLAY(StyleDisplay::None, UNREACHABLE_FCDATA()), FCDATA_FOR_DISPLAY(StyleDisplay::Block, UNREACHABLE_FCDATA()), + FCDATA_FOR_DISPLAY(StyleDisplay::FlowRoot, UNREACHABLE_FCDATA()), // To keep the hash table small don't add inline frames (they're // typically things like FONT and B), because we can quickly // find them if we need to. @@ -4943,7 +4945,7 @@ nsCSSFrameConstructor::ConstructNonScrollableBlockWithConstructor( StyleDisplay::InlineBlock == aDisplay->mDisplay || clipPaginatedOverflow) && !aParentFrame->IsSVGText()) { - flags = NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT; + flags = NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS; if (clipPaginatedOverflow) { flags |= NS_BLOCK_CLIP_PAGINATED_OVERFLOW; } @@ -5112,7 +5114,7 @@ nsCSSFrameConstructor::FlushAccumulatedBlock(nsFrameConstructorState& aState, // is not a suitable block. nsContainerFrame* blockFrame = NS_NewMathMLmathBlockFrame(mPresShell, blockContext); - blockFrame->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT); + blockFrame->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS); InitAndRestoreFrame(aState, aContent, aParentFrame, blockFrame); ReparentFrames(this, blockFrame, aBlockItems); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 5de6f2013..9b204d734 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -149,6 +149,7 @@ using namespace mozilla::gfx; #define GRID_ENABLED_PREF_NAME "layout.css.grid.enabled" #define GRID_TEMPLATE_SUBGRID_ENABLED_PREF_NAME "layout.css.grid-template-subgrid-value.enabled" #define WEBKIT_PREFIXES_ENABLED_PREF_NAME "layout.css.prefixes.webkit" +#define DISPLAY_FLOW_ROOT_ENABLED_PREF_NAME "layout.css.display-flow-root.enabled" #define DISPLAY_CONTENTS_ENABLED_PREF_NAME "layout.css.display-contents.enabled" #define TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME "layout.css.text-align-unsafe-value.enabled" #define FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME "layout.css.float-logical-values.enabled" @@ -314,6 +315,37 @@ WebkitPrefixEnabledPrefChangeCallback(const char* aPrefName, void* aClosure) } } +// When the pref "layout.css.display-flow-root.enabled" changes, this function is +// invoked to let us update kDisplayKTable, to selectively disable or restore +// the entries for "flow-root" in that table. +static void +DisplayFlowRootEnabledPrefChangeCallback(const char* aPrefName, void* aClosure) +{ + NS_ASSERTION(strcmp(aPrefName, DISPLAY_FLOW_ROOT_ENABLED_PREF_NAME) == 0, + "Did you misspell " DISPLAY_FLOW_ROOT_ENABLED_PREF_NAME " ?"); + + static bool sIsDisplayFlowRootKeywordIndexInitialized; + static int32_t sIndexOfFlowRootInDisplayTable; + bool isDisplayFlowRootEnabled = + Preferences::GetBool(DISPLAY_FLOW_ROOT_ENABLED_PREF_NAME, false); + + if (!sIsDisplayFlowRootKeywordIndexInitialized) { + // First run: find the position of "flow-root" in kDisplayKTable. + sIndexOfFlowRootInDisplayTable = + nsCSSProps::FindIndexOfKeyword(eCSSKeyword_flow_root, + nsCSSProps::kDisplayKTable); + sIsDisplayFlowRootKeywordIndexInitialized = true; + } + + // OK -- now, stomp on or restore the "flow-root" entry in kDisplayKTable, + // depending on whether the pref is enabled vs. disabled. + if (sIndexOfFlowRootInDisplayTable >= 0) { + nsCSSProps::kDisplayKTable[sIndexOfFlowRootInDisplayTable].mKeyword = + isDisplayFlowRootEnabled ? eCSSKeyword_flow_root : eCSSKeyword_UNKNOWN; + } +} + + // When the pref "layout.css.display-contents.enabled" changes, this function is // invoked to let us update kDisplayKTable, to selectively disable or restore // the entries for "contents" in that table. @@ -7635,6 +7667,8 @@ static const PrefCallbacks kPrefCallbacks[] = { WebkitPrefixEnabledPrefChangeCallback }, { TEXT_ALIGN_UNSAFE_ENABLED_PREF_NAME, TextAlignUnsafeEnabledPrefChangeCallback }, + { DISPLAY_FLOW_ROOT_ENABLED_PREF_NAME, + DisplayFlowRootEnabledPrefChangeCallback }, { DISPLAY_CONTENTS_ENABLED_PREF_NAME, DisplayContentsEnabledPrefChangeCallback }, { FLOAT_LOGICAL_VALUES_ENABLED_PREF_NAME, diff --git a/layout/forms/nsLegendFrame.cpp b/layout/forms/nsLegendFrame.cpp index 95efc2c87..b985ed8fc 100644 --- a/layout/forms/nsLegendFrame.cpp +++ b/layout/forms/nsLegendFrame.cpp @@ -24,9 +24,7 @@ NS_NewLegendFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) #endif nsIFrame* f = new (aPresShell) nsLegendFrame(aContext); - if (f) { - f->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT); - } + f->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS); return f; } diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index 78eca8c6c..e55b629e3 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -844,6 +844,7 @@ ReflowInput::InitFrameType(nsIAtom* aFrameType) case StyleDisplay::Flex: case StyleDisplay::WebkitBox: case StyleDisplay::Grid: + case StyleDisplay::FlowRoot: case StyleDisplay::RubyTextContainer: frameType = NS_CSS_FRAME_TYPE_BLOCK; break; diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 57838207d..41437c8f8 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -305,7 +305,7 @@ NS_NewBlockFormattingContext(nsIPresShell* aPresShell, nsStyleContext* aStyleContext) { nsBlockFrame* blockFrame = NS_NewBlockFrame(aPresShell, aStyleContext); - blockFrame->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT); + blockFrame->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS); return blockFrame; } @@ -6896,10 +6896,11 @@ nsBlockFrame::Init(nsIContent* aContent, // (http://dev.w3.org/csswg/css-writing-modes/#block-flow) // If the box has contain: paint (or contain: strict), then it should also // establish a formatting context. - if ((GetParent() && StyleVisibility()->mWritingMode != + if (StyleDisplay()->mDisplay == mozilla::StyleDisplay::FlowRoot || + (GetParent() && StyleVisibility()->mWritingMode != GetParent()->StyleVisibility()->mWritingMode) || StyleDisplay()->IsContainPaint()) { - AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT); + AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS); } if ((GetStateBits() & diff --git a/layout/generic/nsFrameStateBits.h b/layout/generic/nsFrameStateBits.h index f8b1e541c..ba43e37d4 100644 --- a/layout/generic/nsFrameStateBits.h +++ b/layout/generic/nsFrameStateBits.h @@ -483,6 +483,9 @@ FRAME_STATE_BIT(Block, 22, NS_BLOCK_MARGIN_ROOT) // used to reserve space for the floated frames. FRAME_STATE_BIT(Block, 23, NS_BLOCK_FLOAT_MGR) +// For setting the relevant bits on a block formatting context: +#define NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS (NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT) + FRAME_STATE_BIT(Block, 24, NS_BLOCK_HAS_LINE_CURSOR) FRAME_STATE_BIT(Block, 25, NS_BLOCK_HAS_OVERFLOW_LINES) diff --git a/layout/generic/nsHTMLParts.h b/layout/generic/nsHTMLParts.h index 89a7a6edd..b11d49e08 100644 --- a/layout/generic/nsHTMLParts.h +++ b/layout/generic/nsHTMLParts.h @@ -27,8 +27,7 @@ class nsTableColFrame; // These are all the block specific frame bits, they are copied from // the prev-in-flow to a newly created next-in-flow, except for the // NS_BLOCK_FLAGS_NON_INHERITED_MASK bits below. -#define NS_BLOCK_FLAGS_MASK (NS_BLOCK_MARGIN_ROOT | \ - NS_BLOCK_FLOAT_MGR | \ +#define NS_BLOCK_FLAGS_MASK (NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS | \ NS_BLOCK_CLIP_PAGINATED_OVERFLOW | \ NS_BLOCK_HAS_FIRST_LETTER_STYLE | \ NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET | \ diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 34a46ffce..9045da9ff 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -285,6 +285,7 @@ CSS_KEY(flex, flex) CSS_KEY(flex-end, flex_end) CSS_KEY(flex-start, flex_start) CSS_KEY(flip, flip) +CSS_KEY(flow-root, flow_root) CSS_KEY(forwards, forwards) CSS_KEY(fraktur, fraktur) CSS_KEY(from-image, from_image) diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index ac2978c27..24c97cf33 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -1345,6 +1345,9 @@ KTableEntry nsCSSProps::kDisplayKTable[] = { // The next entry is controlled by the layout.css.display-contents.enabled // pref. { eCSSKeyword_contents, StyleDisplay::Contents }, + // The next entry is controlled by the layout.css.display-flow-root.enabled + // pref. + { eCSSKeyword_flow_root, StyleDisplay::FlowRoot }, { eCSSKeyword_UNKNOWN, -1 } }; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 1a451a2ef..036d97f86 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -250,6 +250,7 @@ nsRuleNode::EnsureBlockDisplay(StyleDisplay& display, case StyleDisplay::Flex: case StyleDisplay::WebkitBox: case StyleDisplay::Grid: + case StyleDisplay::FlowRoot: // do not muck with these at all - already blocks // This is equivalent to nsStyleDisplay::IsBlockOutside. (XXX Maybe we // should just call that?) @@ -293,6 +294,7 @@ nsRuleNode::EnsureInlineDisplay(StyleDisplay& display) // see if the display value is already inline switch (display) { case StyleDisplay::Block: + case StyleDisplay::FlowRoot: display = StyleDisplay::InlineBlock; break; case StyleDisplay::Table: diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 6d207aec9..f54387aa8 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -524,6 +524,7 @@ enum class FillMode : uint32_t; enum class StyleDisplay : uint8_t { None = 0, Block, + FlowRoot, Inline, InlineBlock, ListItem, diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 4bda817dd..f49cdc43e 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -2890,7 +2890,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay return mozilla::StyleDisplay::Block == mDisplay || mozilla::StyleDisplay::ListItem == mDisplay || mozilla::StyleDisplay::InlineBlock == mDisplay || - mozilla::StyleDisplay::TableCaption == mDisplay; + mozilla::StyleDisplay::TableCaption == mDisplay || + mozilla::StyleDisplay::FlowRoot == mDisplay; // Should TABLE_CELL be included here? They have // block frames nested inside of them. // (But please audit all callers before changing.) @@ -2902,7 +2903,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay mozilla::StyleDisplay::WebkitBox == mDisplay || mozilla::StyleDisplay::Grid == mDisplay || mozilla::StyleDisplay::ListItem == mDisplay || - mozilla::StyleDisplay::Table == mDisplay; + mozilla::StyleDisplay::Table == mDisplay || + mozilla::StyleDisplay::FlowRoot == mDisplay; } static bool IsDisplayTypeInlineOutside(mozilla::StyleDisplay aDisplay) { diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index c75f7b498..2d6352148 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -7892,6 +7892,10 @@ if (IsCSSPropertyPrefEnabled("layout.css.background-clip-text.enabled")) { ); } +if (IsCSSPropertyPrefEnabled("layout.css.display-flow-root.enabled")) { + gCSSProperties["display"].other_values.push("flow-root"); +} + // Copy aliased properties' fields from their alias targets. for (var prop in gCSSProperties) { var entry = gCSSProperties[prop]; diff --git a/layout/xul/nsXULLabelFrame.cpp b/layout/xul/nsXULLabelFrame.cpp index 22b875461..41e7e4d76 100644 --- a/layout/xul/nsXULLabelFrame.cpp +++ b/layout/xul/nsXULLabelFrame.cpp @@ -16,9 +16,7 @@ nsIFrame* NS_NewXULLabelFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { nsXULLabelFrame* it = new (aPresShell) nsXULLabelFrame(aContext); - - it->AddStateBits(NS_BLOCK_FLOAT_MGR | NS_BLOCK_MARGIN_ROOT); - + it->AddStateBits(NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS); return it; } -- cgit v1.2.3 From 157f218c8d9f026eb530bb87cb23c2b81fd42a54 Mon Sep 17 00:00:00 2001 From: athenian200 <athenian200@outlook.com> Date: Sun, 6 Sep 2020 13:51:08 -0500 Subject: Issue #1629 - Part 4: Ensure isExplicitlyEnabled is false upon sheet creation. This clarifies the assumptions the code is making and the order in which the variables pass through the loading process. The new variable is set after the sheet is created and prepared, and is assumed to be false in the beginning. --- layout/style/Loader.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'layout') diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index df523174d..1038ff53f 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -2272,7 +2272,8 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet, state = eSheetComplete; } else { bool isAlternate; - bool isExplicitlyEnabled; + // For now, child sheets are not explicitly enabled. + bool isExplicitlyEnabled = false; const nsSubstring& empty = EmptyString(); // For now, use CORS_NONE for child sheets rv = CreateSheet(aURL, nullptr, principal, @@ -2396,7 +2397,9 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL, StyleSheetState state; bool isAlternate; - bool isExplicitlyEnabled; + // Sheets can only be explicitly enabled after creation and preparation, so + // set isExplicitlyEnabled to false. + bool isExplicitlyEnabled = false; RefPtr<StyleSheet> sheet; bool syncLoad = (aObserver == nullptr); const nsSubstring& empty = EmptyString(); -- cgit v1.2.3 From f43c37cabe419a38b64c68225a4256d795443aae Mon Sep 17 00:00:00 2001 From: athenian200 <athenian200@outlook.com> Date: Wed, 9 Sep 2020 01:40:15 -0500 Subject: Issue #1629 - Part 5: Remove pointless local variables. Since the local variable is always initialized to false, we don't actually need to declare it and can just pass "false" directly as a parameter to the PrepareSheet function's bool. I was worried about code readability at first, but some well-placed comments took care of that. --- layout/style/Loader.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'layout') diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 1038ff53f..a06dd3737 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -2272,8 +2272,6 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet, state = eSheetComplete; } else { bool isAlternate; - // For now, child sheets are not explicitly enabled. - bool isExplicitlyEnabled = false; const nsSubstring& empty = EmptyString(); // For now, use CORS_NONE for child sheets rv = CreateSheet(aURL, nullptr, principal, @@ -2283,8 +2281,9 @@ Loader::LoadChildSheet(StyleSheet* aParentSheet, parentData ? parentData->mSyncLoad : false, false, empty, state, &isAlternate, &sheet); NS_ENSURE_SUCCESS(rv, rv); - - PrepareSheet(sheet, empty, empty, aMedia, nullptr, isAlternate, isExplicitlyEnabled); + // For now, child sheets are not explicitly enabled (seventh argument is + // always false here). + PrepareSheet(sheet, empty, empty, aMedia, nullptr, isAlternate, false); } rv = InsertChildSheet(sheet, aParentSheet, aParentRule); @@ -2397,9 +2396,6 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL, StyleSheetState state; bool isAlternate; - // Sheets can only be explicitly enabled after creation and preparation, so - // set isExplicitlyEnabled to false. - bool isExplicitlyEnabled = false; RefPtr<StyleSheet> sheet; bool syncLoad = (aObserver == nullptr); const nsSubstring& empty = EmptyString(); @@ -2409,7 +2405,10 @@ Loader::InternalLoadNonDocumentSheet(nsIURI* aURL, false, empty, state, &isAlternate, &sheet); NS_ENSURE_SUCCESS(rv, rv); - PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate, isExplicitlyEnabled); + // Sheets can only be explicitly enabled after creation and preparation, so + // we always pass false for the initial value of the explicitly enabled flag + // when calling PrepareSheet. + PrepareSheet(sheet, empty, empty, nullptr, nullptr, isAlternate, false); if (state == eSheetComplete) { LOG((" Sheet already complete")); -- cgit v1.2.3 From 7564818c79cf67d0dcf866579d5b74647b96dae6 Mon Sep 17 00:00:00 2001 From: Moonchild <moonchild@palemoon.org> Date: Sat, 12 Sep 2020 20:20:02 +0200 Subject: Issue #1650 - Add null check. There are situations where nsCSSClipPathinstance->CreateClipPath(dt) returns null. We need to check for this before trying to use its functions. If there is no clip path, then always return "no hit". --- layout/svg/nsCSSClipPathInstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'layout') diff --git a/layout/svg/nsCSSClipPathInstance.cpp b/layout/svg/nsCSSClipPathInstance.cpp index 01f7de248..e923eaa0e 100644 --- a/layout/svg/nsCSSClipPathInstance.cpp +++ b/layout/svg/nsCSSClipPathInstance.cpp @@ -59,7 +59,7 @@ nsCSSClipPathInstance::HitTestBasicShapeClip(nsIFrame* aFrame, RefPtr<Path> path = instance.CreateClipPath(drawTarget); float pixelRatio = float(nsPresContext::AppUnitsPerCSSPixel()) / aFrame->PresContext()->AppUnitsPerDevPixel(); - return path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix()); + return path ? path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix()) : false; } already_AddRefed<Path> -- cgit v1.2.3 From 075fa012868017c9cb49f1b92960bf02f4bf27ca Mon Sep 17 00:00:00 2001 From: Moonchild <moonchild@palemoon.org> Date: Wed, 16 Sep 2020 19:39:33 +0000 Subject: Issue #1643 - Part 4: Hook up all the plumbing. --- layout/base/nsPresShell.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'layout') diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 63f512af4..0544a69a4 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -9090,6 +9090,11 @@ PresShell::DidDoReflow(bool aInterruptible) docShell->NotifyReflowObservers(aInterruptible, mLastReflowStart, now); } + // Notify resize observers on reflow. + if (!mPresContext->HasPendingInterrupt()) { + mDocument->ScheduleResizeObserversNotification(); + } + if (sSynthMouseMove) { SynthesizeMouseMove(false); } -- cgit v1.2.3 From b862145e9c7f0802ea5fa7e02c003744dbca9ec2 Mon Sep 17 00:00:00 2001 From: athenian200 <athenian200@outlook.com> Date: Wed, 16 Sep 2020 17:34:03 -0500 Subject: Issue #1647 - Part 1: Implement percentage for CSS opacity keywords This preliminary step allows percentages to be computed and display correctly, but unfortunately it fails a test after changing VARIANT_HN to VARIANT_HPN because that allows values to be serialized as percentages. However, not doing this means percentages are rejected as valid values for the user to input. The way the style system is setup makes it hard to change this for opacity without changing it for everything else, especially since some code-saving speed hacks in Bug 636029 and Bug 441367 that make a lot of assumptions about this stuff very rigid. --- layout/style/nsCSSPropList.h | 10 +++++----- layout/style/nsRuleNode.cpp | 15 +++++++++++++++ layout/style/test/property_database.js | 18 +++++++++--------- 3 files changed, 29 insertions(+), 14 deletions(-) (limited to 'layout') diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index f62aa3827..906ed7ee0 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -1703,7 +1703,7 @@ CSS_PROP_SVG( FillOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mFillOpacity), eStyleAnimType_float) @@ -1841,7 +1841,7 @@ CSS_PROP_SVGRESET( FloodOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN, + VARIANT_HPN, nullptr, offsetof(nsStyleSVGReset, mFloodOpacity), eStyleAnimType_float) @@ -3070,7 +3070,7 @@ CSS_PROP_EFFECTS( CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR | CSS_PROPERTY_CREATES_STACKING_CONTEXT, "", - VARIANT_HN, + VARIANT_HPN, nullptr, offsetof(nsStyleEffects, mOpacity), eStyleAnimType_float) @@ -3761,7 +3761,7 @@ CSS_PROP_SVGRESET( StopOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN, + VARIANT_HPN, nullptr, offsetof(nsStyleSVGReset, mStopOpacity), eStyleAnimType_float) @@ -3836,7 +3836,7 @@ CSS_PROP_SVG( StrokeOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mStrokeOpacity), eStyleAnimType_float) diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 036d97f86..3863ec292 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1579,6 +1579,21 @@ SetFactor(const nsCSSValue& aValue, float& aField, RuleNodeCacheConditions& aCon case eCSSUnit_Null: return; + case eCSSUnit_Percent: + aField = aValue.GetPercentValue(); + if (aFlags & SETFCT_POSITIVE) { + NS_ASSERTION(aField >= 0.0f, "negative value for positive-only property"); + if (aField < 0.0f) + aField = 0.0f; + } + if (aFlags & SETFCT_OPACITY) { + if (aField < 0.0f) + aField = 0.0f; + if (aField > 1.0f) + aField = 1.0f; + } + return; + case eCSSUnit_Number: aField = aValue.GetFloatValue(); if (aFlags & SETFCT_POSITIVE) { diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 2d6352148..2fc50a539 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -3540,7 +3540,7 @@ var gCSSProperties = { inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "1", "17", "397.376", "3e1", "3e+1", "3e0", "3e+0", "3e-0" ], - other_values: [ "0", "0.4", "0.0000", "-3", "3e-1" ], + other_values: [ "0", "0.4", "0.0000", "-3", "3e-1" "-100%", "50%"], invalid_values: [ "0px", "1px" ] }, "-moz-orient": { @@ -4272,8 +4272,8 @@ var gCSSProperties = { domProp: "fillOpacity", inherited: true, type: CSS_TYPE_LONGHAND, - initial_values: [ "1", "2.8", "1.000", "context-fill-opacity", "context-stroke-opacity" ], - other_values: [ "0", "0.3", "-7.3" ], + initial_values: [ "1", "2.8", "1.000", "300%", "context-fill-opacity", "context-stroke-opacity" ], + other_values: [ "0", "0.3", "-7.3", "-100%", "50%"], invalid_values: [] }, "fill-rule": { @@ -4305,8 +4305,8 @@ var gCSSProperties = { domProp: "floodOpacity", inherited: false, type: CSS_TYPE_LONGHAND, - initial_values: [ "1", "2.8", "1.000" ], - other_values: [ "0", "0.3", "-7.3" ], + initial_values: [ "1", "2.8", "1.000", "300%"], + other_values: [ "0", "0.3", "-7.3", "-100%", "50%"], invalid_values: [] }, "image-rendering": { @@ -4380,8 +4380,8 @@ var gCSSProperties = { domProp: "stopOpacity", inherited: false, type: CSS_TYPE_LONGHAND, - initial_values: [ "1", "2.8", "1.000" ], - other_values: [ "0", "0.3", "-7.3" ], + initial_values: [ "1", "2.8", "1.000", "300%" ], + other_values: [ "0", "0.3", "-7.3", "-100%", "50%" ], invalid_values: [] }, "stroke": { @@ -4436,8 +4436,8 @@ var gCSSProperties = { domProp: "strokeOpacity", inherited: true, type: CSS_TYPE_LONGHAND, - initial_values: [ "1", "2.8", "1.000", "context-fill-opacity", "context-stroke-opacity" ], - other_values: [ "0", "0.3", "-7.3" ], + initial_values: [ "1", "2.8", "1.000", "300%", "context-fill-opacity", "context-stroke-opacity" ], + other_values: [ "0", "0.3", "-7.3", "-100%", "50% ], invalid_values: [] }, "stroke-width": { -- cgit v1.2.3 From f2866a5420b4645d888fc50b22f7cbdd8a178042 Mon Sep 17 00:00:00 2001 From: athenian200 <athenian200@outlook.com> Date: Thu, 17 Sep 2020 16:01:38 -0500 Subject: Issue #1647 - Part 2: Implement VARIANT_OPACITY to correctly serialize. Even though percentages are already treated as floats internally by the style system for computation purposes, you have to go out of your way to stop them from being read back out as percentages. What I do here amounts to storing the percentage token in the "wrong" container, the one normally used for floats. This allows a value that was read in as a percentage to be read back out as something else, which is normally prevented by the design of the style system. --- layout/inspector/inDOMUtils.cpp | 4 ++-- layout/style/nsCSSParser.cpp | 30 +++++++++++++++++++++--------- layout/style/nsCSSPropList.h | 10 +++++----- layout/style/nsCSSProps.h | 1 + layout/style/nsRuleNode.cpp | 15 --------------- layout/style/test/property_database.js | 8 ++++---- 6 files changed, 33 insertions(+), 35 deletions(-) (limited to 'layout') diff --git a/layout/inspector/inDOMUtils.cpp b/layout/inspector/inDOMUtils.cpp index e212e20df..2095fb775 100644 --- a/layout/inspector/inDOMUtils.cpp +++ b/layout/inspector/inDOMUtils.cpp @@ -846,7 +846,7 @@ PropertySupportsVariant(nsCSSPropertyID aPropertyID, uint32_t aVariant) case eCSSProperty_grid_row_end: case eCSSProperty_font_weight: case eCSSProperty_initial_letter: - supported = VARIANT_NUMBER; + supported = VARIANT_NUMBER | VARIANT_OPACITY; break; default: @@ -909,7 +909,7 @@ inDOMUtils::CssPropertySupportsType(const nsAString& aProperty, uint32_t aType, break; case TYPE_NUMBER: // Include integers under "number"? - variant = VARIANT_NUMBER | VARIANT_INTEGER; + variant = VARIANT_NUMBER | VARIANT_INTEGER | VARIANT_OPACITY; break; default: // Unknown type diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index f6b84bfac..1525c5f9a 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -1300,7 +1300,7 @@ protected: } bool ParseNonNegativeNumber(nsCSSValue& aValue) { - return ParseSingleTokenNonNegativeVariant(aValue, VARIANT_NUMBER, nullptr); + return ParseSingleTokenNonNegativeVariant(aValue, VARIANT_NUMBER | VARIANT_OPACITY, nullptr); } // Helpers for some common ParseSingleTokenOneOrLargerVariant calls. @@ -1310,7 +1310,7 @@ protected: } bool ParseOneOrLargerNumber(nsCSSValue& aValue) { - return ParseSingleTokenOneOrLargerVariant(aValue, VARIANT_NUMBER, nullptr); + return ParseSingleTokenOneOrLargerVariant(aValue, VARIANT_NUMBER | VARIANT_OPACITY, nullptr); } // http://dev.w3.org/csswg/css-values/#custom-idents @@ -7789,6 +7789,7 @@ CSSParserImpl::ParseNonNegativeVariant(nsCSSValue& aValue, VARIANT_NUMBER | VARIANT_LENGTH | VARIANT_PERCENT | + VARIANT_OPACITY | VARIANT_INTEGER)) == 0, "need to update code below to handle additional variants"); @@ -7829,6 +7830,7 @@ CSSParserImpl::ParseOneOrLargerVariant(nsCSSValue& aValue, // that we specifically handle. MOZ_ASSERT((aVariantMask & ~(VARIANT_ALL_NONNUMERIC | VARIANT_NUMBER | + VARIANT_OPACITY | VARIANT_INTEGER)) == 0, "need to update code below to handle additional variants"); @@ -7957,9 +7959,9 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue, } } } - // Check VARIANT_NUMBER and VARIANT_INTEGER before VARIANT_LENGTH or - // VARIANT_ZERO_ANGLE. - if (((aVariantMask & VARIANT_NUMBER) != 0) && + // Check VARIANT_NUMBER, number tokens for VARIANT_OPACITY, and + // VARIANT_INTEGER before VARIANT_LENGTH or VARIANT_ZERO_ANGLE. + if (((aVariantMask & (VARIANT_NUMBER | VARIANT_OPACITY)) != 0) && (eCSSToken_Number == tk->mType)) { aValue.SetFloatValue(tk->mNumber, eCSSUnit_Number); return CSSParseResult::Ok; @@ -7969,6 +7971,7 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue, aValue.SetIntValue(tk->mInteger, eCSSUnit_Integer); return CSSParseResult::Ok; } + if (((aVariantMask & (VARIANT_LENGTH | VARIANT_ANGLE | VARIANT_FREQUENCY | VARIANT_TIME)) != 0 && eCSSToken_Dimension == tk->mType) || @@ -7994,6 +7997,15 @@ CSSParserImpl::ParseVariant(nsCSSValue& aValue, aValue.SetPercentValue(tk->mNumber); return CSSParseResult::Ok; } + // We need to store eCSSToken_Percentage in eCSSUnit_Number in order to + // serialize opacity according to spec. All percentage tokens are stored + // as floats, so no type conversion is needed to make this possible. + // Percentage tokens have to be evaluated later than number tokens. + if (((aVariantMask & VARIANT_OPACITY) != 0) && + (eCSSToken_Percentage == tk->mType)) { + aValue.SetFloatValue(tk->mNumber, eCSSUnit_Number); + return CSSParseResult::Ok; + } if (mUnitlessLengthQuirk) { // NONSTANDARD: Nav interprets unitless numbers as px if (((aVariantMask & VARIANT_LENGTH) != 0) && (eCSSToken_Number == tk->mType)) { @@ -8472,7 +8484,7 @@ CSSParserImpl::ParseImageRect(nsCSSValue& aImage) break; } - static const int32_t VARIANT_SIDE = VARIANT_NUMBER | VARIANT_PERCENT; + static const int32_t VARIANT_SIDE = VARIANT_NUMBER | VARIANT_PERCENT | VARIANT_OPACITY; if (!ParseSingleTokenNonNegativeVariant(top, VARIANT_SIDE, nullptr) || !ExpectSymbol(',', true) || !ParseSingleTokenNonNegativeVariant(right, VARIANT_SIDE, nullptr) || @@ -10881,7 +10893,7 @@ CSSParserImpl::ParseWebkitGradientColorStop(nsCSSValueGradient* aGradient) if (mToken.mIdent.LowerCaseEqualsLiteral("color-stop")) { // Parse stop location, followed by comma. if (!ParseSingleTokenVariant(stop->mLocation, - VARIANT_NUMBER | VARIANT_PERCENT, + VARIANT_NUMBER | VARIANT_PERCENT | VARIANT_OPACITY, nullptr) || !ExpectSymbol(',', true)) { SkipUntil(')'); // Skip to end of color-stop(...) expression. @@ -16044,7 +16056,7 @@ static bool GetFunctionParseInformation(nsCSSKeyword aToken, {VARIANT_LBCALC, VARIANT_LBCALC, VARIANT_LBCALC}, {VARIANT_ANGLE_OR_ZERO}, {VARIANT_ANGLE_OR_ZERO, VARIANT_ANGLE_OR_ZERO}, - {VARIANT_NUMBER}, + {VARIANT_NUMBER|VARIANT_OPACITY}, {VARIANT_LENGTH|VARIANT_NONNEGATIVE_DIMENSION}, {VARIANT_LB|VARIANT_NONNEGATIVE_DIMENSION}, {VARIANT_NUMBER, VARIANT_NUMBER}, @@ -17626,7 +17638,7 @@ CSSParserImpl::ParseScrollSnapPoints(nsCSSValue& aValue, nsCSSPropertyID aPropID nsCSSKeywords::LookupKeyword(mToken.mIdent) == eCSSKeyword_repeat) { nsCSSValue lengthValue; if (ParseNonNegativeVariant(lengthValue, - VARIANT_LENGTH | VARIANT_PERCENT | VARIANT_CALC, + VARIANT_LENGTH | VARIANT_PERCENT | VARIANT_OPACITY | VARIANT_CALC, nullptr) != CSSParseResult::Ok) { REPORT_UNEXPECTED(PEExpectedNonnegativeNP); SkipUntil(')'); diff --git a/layout/style/nsCSSPropList.h b/layout/style/nsCSSPropList.h index 906ed7ee0..890019245 100644 --- a/layout/style/nsCSSPropList.h +++ b/layout/style/nsCSSPropList.h @@ -1703,7 +1703,7 @@ CSS_PROP_SVG( FillOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_INHERIT | VARIANT_OPACITY | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mFillOpacity), eStyleAnimType_float) @@ -1841,7 +1841,7 @@ CSS_PROP_SVGRESET( FloodOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN, + VARIANT_INHERIT | VARIANT_OPACITY, nullptr, offsetof(nsStyleSVGReset, mFloodOpacity), eStyleAnimType_float) @@ -3070,7 +3070,7 @@ CSS_PROP_EFFECTS( CSS_PROPERTY_CAN_ANIMATE_ON_COMPOSITOR | CSS_PROPERTY_CREATES_STACKING_CONTEXT, "", - VARIANT_HPN, + VARIANT_INHERIT | VARIANT_OPACITY, nullptr, offsetof(nsStyleEffects, mOpacity), eStyleAnimType_float) @@ -3761,7 +3761,7 @@ CSS_PROP_SVGRESET( StopOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN, + VARIANT_INHERIT | VARIANT_OPACITY, nullptr, offsetof(nsStyleSVGReset, mStopOpacity), eStyleAnimType_float) @@ -3836,7 +3836,7 @@ CSS_PROP_SVG( StrokeOpacity, CSS_PROPERTY_PARSE_VALUE, "", - VARIANT_HPN | VARIANT_OPENTYPE_SVG_KEYWORD, + VARIANT_INHERIT | VARIANT_OPACITY | VARIANT_OPENTYPE_SVG_KEYWORD, kContextOpacityKTable, offsetof(nsStyleSVG, mStrokeOpacity), eStyleAnimType_float) diff --git a/layout/style/nsCSSProps.h b/layout/style/nsCSSProps.h index aabbac07a..34d457c08 100644 --- a/layout/style/nsCSSProps.h +++ b/layout/style/nsCSSProps.h @@ -43,6 +43,7 @@ #define VARIANT_IDENTIFIER 0x002000 // D #define VARIANT_IDENTIFIER_NO_INHERIT 0x004000 // like above, but excluding // 'inherit' and 'initial' +#define VARIANT_OPACITY 0x008000 // Take floats and percents as input, output float. #define VARIANT_AUTO 0x010000 // A #define VARIANT_INHERIT 0x020000 // H eCSSUnit_Initial, eCSSUnit_Inherit, eCSSUnit_Unset #define VARIANT_NONE 0x040000 // O diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 3863ec292..036d97f86 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -1579,21 +1579,6 @@ SetFactor(const nsCSSValue& aValue, float& aField, RuleNodeCacheConditions& aCon case eCSSUnit_Null: return; - case eCSSUnit_Percent: - aField = aValue.GetPercentValue(); - if (aFlags & SETFCT_POSITIVE) { - NS_ASSERTION(aField >= 0.0f, "negative value for positive-only property"); - if (aField < 0.0f) - aField = 0.0f; - } - if (aFlags & SETFCT_OPACITY) { - if (aField < 0.0f) - aField = 0.0f; - if (aField > 1.0f) - aField = 1.0f; - } - return; - case eCSSUnit_Number: aField = aValue.GetFloatValue(); if (aFlags & SETFCT_POSITIVE) { diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 2fc50a539..bc4383630 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -3540,7 +3540,7 @@ var gCSSProperties = { inherited: false, type: CSS_TYPE_LONGHAND, initial_values: [ "1", "17", "397.376", "3e1", "3e+1", "3e0", "3e+0", "3e-0" ], - other_values: [ "0", "0.4", "0.0000", "-3", "3e-1" "-100%", "50%"], + other_values: [ "0", "0.4", "0.0000", "-3", "3e-1" "-100%", "50%" ], invalid_values: [ "0px", "1px" ] }, "-moz-orient": { @@ -4273,7 +4273,7 @@ var gCSSProperties = { inherited: true, type: CSS_TYPE_LONGHAND, initial_values: [ "1", "2.8", "1.000", "300%", "context-fill-opacity", "context-stroke-opacity" ], - other_values: [ "0", "0.3", "-7.3", "-100%", "50%"], + other_values: [ "0", "0.3", "-7.3", "-100%", "50%" ], invalid_values: [] }, "fill-rule": { @@ -4305,8 +4305,8 @@ var gCSSProperties = { domProp: "floodOpacity", inherited: false, type: CSS_TYPE_LONGHAND, - initial_values: [ "1", "2.8", "1.000", "300%"], - other_values: [ "0", "0.3", "-7.3", "-100%", "50%"], + initial_values: [ "1", "2.8", "1.000", "300%" ], + other_values: [ "0", "0.3", "-7.3", "-100%", "50%" ], invalid_values: [] }, "image-rendering": { -- cgit v1.2.3 From 312f0b3a767112621278c97c1f5099e37238b337 Mon Sep 17 00:00:00 2001 From: Moonchild <moonchild@palemoon.org> Date: Wed, 23 Sep 2020 08:24:14 +0000 Subject: Issue #1655: Update MediaQueryList to the current draft spec. This make MediaQueryList inherit from EventTarget and adds MediaQueryListEvent as an interface as well as the onchange() method. This should not affect compatibility with other code; the event object is a MediaQueryListEvent instance, which is recognized as a MediaListQuery instance. --- layout/base/nsPresContext.cpp | 26 +---- layout/style/MediaQueryList.cpp | 215 +++++++++++++++++++++++++++------------- layout/style/MediaQueryList.h | 48 +++++---- 3 files changed, 179 insertions(+), 110 deletions(-) (limited to 'layout') diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index befb5deb2..1d90b967a 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1931,33 +1931,13 @@ nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint, if (!PR_CLIST_IS_EMPTY(mDocument->MediaQueryLists())) { // We build a list of all the notifications we're going to send - // before we send any of them. (The spec says the notifications - // should be a queued task, so any removals that happen during the - // notifications shouldn't affect what gets notified.) Furthermore, - // we hold strong pointers to everything we're going to make - // notification calls to, since each notification involves calling - // arbitrary script that might otherwise destroy these objects, or, - // for that matter, |this|. - // - // Note that we intentionally send the notifications to media query - // list in the order they were created and, for each list, to the - // listeners in the order added. - nsTArray<MediaQueryList::HandleChangeData> notifyList; + // before we send any of them. for (PRCList *l = PR_LIST_HEAD(mDocument->MediaQueryLists()); l != mDocument->MediaQueryLists(); l = PR_NEXT_LINK(l)) { + nsAutoMicroTask mt; MediaQueryList *mql = static_cast<MediaQueryList*>(l); - mql->MediumFeaturesChanged(notifyList); + mql->MaybeNotify(); } - - if (!notifyList.IsEmpty()) { - for (uint32_t i = 0, i_end = notifyList.Length(); i != i_end; ++i) { - nsAutoMicroTask mt; - MediaQueryList::HandleChangeData &d = notifyList[i]; - d.callback->Call(*d.mql); - } - } - - // NOTE: When |notifyList| goes out of scope, our destructor could run. } } diff --git a/layout/style/MediaQueryList.cpp b/layout/style/MediaQueryList.cpp index db3781b76..5838645be 100644 --- a/layout/style/MediaQueryList.cpp +++ b/layout/style/MediaQueryList.cpp @@ -1,5 +1,4 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -7,19 +6,26 @@ /* implements DOM interface for querying and observing media queries */ #include "mozilla/dom/MediaQueryList.h" +#include "mozilla/dom/MediaQueryListEvent.h" +#include "mozilla/dom/EventTarget.h" +#include "mozilla/dom/EventTargetBinding.h" #include "nsPresContext.h" #include "nsIMediaList.h" #include "nsCSSParser.h" #include "nsIDocument.h" +// Fixed event target type +#define ONCHANGE_STRING NS_LITERAL_STRING("change") + namespace mozilla { namespace dom { MediaQueryList::MediaQueryList(nsIDocument *aDocument, const nsAString &aMediaQueryList) - : mDocument(aDocument), - mMediaList(new nsMediaList), - mMatchesValid(false) + : mDocument(aDocument) + , mMediaList(new nsMediaList) + , mMatchesValid(false) + , mIsKeptAlive(false) { PR_INIT_CLIST(this); @@ -36,30 +42,24 @@ MediaQueryList::~MediaQueryList() NS_IMPL_CYCLE_COLLECTION_CLASS(MediaQueryList) -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(MediaQueryList) +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MediaQueryList, DOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallbacks) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MediaQueryList) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MediaQueryList, DOMEventTargetHelper) if (tmp->mDocument) { PR_REMOVE_LINK(tmp); NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument) } - tmp->RemoveAllListeners(); + tmp->Disconnect(); NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK_END -NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(MediaQueryList) - -NS_INTERFACE_MAP_BEGIN(MediaQueryList) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_MAP_ENTRY(nsISupports) - NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(MediaQueryList) -NS_INTERFACE_MAP_END +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MediaQueryList) +NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) -NS_IMPL_CYCLE_COLLECTING_ADDREF(MediaQueryList) -NS_IMPL_CYCLE_COLLECTING_RELEASE(MediaQueryList) +NS_IMPL_ADDREF_INHERITED(MediaQueryList, DOMEventTargetHelper) +NS_IMPL_RELEASE_INHERITED(MediaQueryList, DOMEventTargetHelper) void MediaQueryList::GetMedia(nsAString &aMedia) @@ -80,57 +80,124 @@ MediaQueryList::Matches() } void -MediaQueryList::AddListener(MediaQueryListListener& aListener) +MediaQueryList::AddListener(EventListener* aListener, ErrorResult& aRv) { - if (!HasListeners()) { - // When we have listeners, the pres context owns a reference to - // this. This is a cyclic reference that can only be broken by - // cycle collection. - NS_ADDREF_THIS(); + if (!aListener) { + return; } + AddEventListenerOptionsOrBoolean options; + options.SetAsBoolean() = false; + + AddEventListener(ONCHANGE_STRING, aListener, options, Nullable<bool>(), aRv); +} + +void +MediaQueryList::AddEventListener(const nsAString& aType, + EventListener* aCallback, + const AddEventListenerOptionsOrBoolean& aOptions, + const dom::Nullable<bool>& aWantsUntrusted, + ErrorResult& aRv) +{ if (!mMatchesValid) { MOZ_ASSERT(!HasListeners(), "when listeners present, must keep mMatches current"); RecomputeMatches(); } - for (uint32_t i = 0; i < mCallbacks.Length(); ++i) { - if (aListener == *mCallbacks[i]) { - // Already registered - return; - } + DOMEventTargetHelper::AddEventListener(aType, aCallback, aOptions, + aWantsUntrusted, aRv); + + if (aRv.Failed()) { + return; } - if (!mCallbacks.AppendElement(&aListener, fallible)) { - if (!HasListeners()) { - // Append failed; undo the AddRef above. - NS_RELEASE_THIS(); - } + UpdateMustKeepAlive(); +} + +void +MediaQueryList::RemoveListener(EventListener* aListener, ErrorResult& aRv) +{ + if (!aListener) { + return; } + + EventListenerOptionsOrBoolean options; + options.SetAsBoolean() = false; + + RemoveEventListener(ONCHANGE_STRING, aListener, options, aRv); } void -MediaQueryList::RemoveListener(MediaQueryListListener& aListener) -{ - for (uint32_t i = 0; i < mCallbacks.Length(); ++i) { - if (aListener == *mCallbacks[i]) { - mCallbacks.RemoveElementAt(i); - if (!HasListeners()) { - // See NS_ADDREF_THIS() in AddListener. - NS_RELEASE_THIS(); - } - break; - } +MediaQueryList::RemoveEventListener(const nsAString& aType, + EventListener* aCallback, + const EventListenerOptionsOrBoolean& aOptions, + ErrorResult& aRv) +{ + DOMEventTargetHelper::RemoveEventListener(aType, aCallback, aOptions, aRv); + + if (aRv.Failed()) { + return; + } + + UpdateMustKeepAlive(); +} + +EventHandlerNonNull* +MediaQueryList::GetOnchange() +{ + if (NS_IsMainThread()) { + return GetEventHandler(nsGkAtoms::onchange, EmptyString()); + } + return GetEventHandler(nullptr, ONCHANGE_STRING); +} + +void +MediaQueryList::SetOnchange(EventHandlerNonNull* aCallback) +{ + if (NS_IsMainThread()) { + SetEventHandler(nsGkAtoms::onchange, EmptyString(), aCallback); + } else { + SetEventHandler(nullptr, ONCHANGE_STRING, aCallback); } + + UpdateMustKeepAlive(); } void -MediaQueryList::RemoveAllListeners() +MediaQueryList::UpdateMustKeepAlive() { - bool hadListeners = HasListeners(); - mCallbacks.Clear(); - if (hadListeners) { + bool toKeepAlive = HasListeners(); + if (toKeepAlive == mIsKeptAlive) { + return; + } + + // When we have listeners, the pres context owns a reference to + // this. This is a cyclic reference that can only be broken by + // cycle collection. + + mIsKeptAlive = toKeepAlive; + + if (toKeepAlive) { + NS_ADDREF_THIS(); + } else { + NS_RELEASE_THIS(); + } +} + +bool +MediaQueryList::HasListeners() +{ + return HasListenersFor(ONCHANGE_STRING); +} + +void +MediaQueryList::Disconnect() +{ + DisconnectFromOwner(); + + if (mIsKeptAlive) { + mIsKeptAlive = false; // See NS_ADDREF_THIS() in AddListener. NS_RELEASE_THIS(); } @@ -169,27 +236,6 @@ MediaQueryList::RecomputeMatches() mMatchesValid = true; } -void -MediaQueryList::MediumFeaturesChanged( - nsTArray<HandleChangeData>& aListenersToNotify) -{ - mMatchesValid = false; - - if (HasListeners()) { - bool oldMatches = mMatches; - RecomputeMatches(); - if (mMatches != oldMatches) { - for (uint32_t i = 0, i_end = mCallbacks.Length(); i != i_end; ++i) { - HandleChangeData *d = aListenersToNotify.AppendElement(fallible); - if (d) { - d->mql = this; - d->callback = mCallbacks[i]; - } - } - } - } -} - nsISupports* MediaQueryList::GetParentObject() const { @@ -202,5 +248,36 @@ MediaQueryList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) return MediaQueryListBinding::Wrap(aCx, this, aGivenProto); } +void +MediaQueryList::MaybeNotify() +{ + mMatchesValid = false; + + if (!HasListeners()) { + return; + } + + bool oldMatches = mMatches; + RecomputeMatches(); + + // No need to notify the change. + if (mMatches == oldMatches) { + return; + } + + MediaQueryListEventInit init; + init.mBubbles = false; + init.mCancelable = false; + init.mMatches = mMatches; + mMediaList->GetText(init.mMedia); + + RefPtr<MediaQueryListEvent> event = + MediaQueryListEvent::Constructor(this, ONCHANGE_STRING, init); + event->SetTrusted(true); + + bool dummy; + DispatchEvent(event, &dummy); +} + } // namespace dom } // namespace mozilla diff --git a/layout/style/MediaQueryList.h b/layout/style/MediaQueryList.h index 5ba568528..d2acb34c1 100644 --- a/layout/style/MediaQueryList.h +++ b/layout/style/MediaQueryList.h @@ -16,6 +16,7 @@ #include "prclist.h" #include "mozilla/Attributes.h" #include "nsWrapperCache.h" +#include "mozilla/DOMEventTargetHelper.h" #include "mozilla/dom/MediaQueryListBinding.h" class nsIDocument; @@ -24,8 +25,7 @@ class nsMediaList; namespace mozilla { namespace dom { -class MediaQueryList final : public nsISupports, - public nsWrapperCache, +class MediaQueryList final : public DOMEventTargetHelper, public PRCList { public: @@ -37,33 +37,45 @@ private: ~MediaQueryList(); public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaQueryList) + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaQueryList, DOMEventTargetHelper) nsISupports* GetParentObject() const; - struct HandleChangeData { - RefPtr<MediaQueryList> mql; - RefPtr<mozilla::dom::MediaQueryListListener> callback; - }; - - // Appends listeners that need notification to aListenersToNotify - void MediumFeaturesChanged(nsTArray<HandleChangeData>& aListenersToNotify); - - bool HasListeners() const { return !mCallbacks.IsEmpty(); } - - void RemoveAllListeners(); + void MaybeNotify(); JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; // WebIDL methods void GetMedia(nsAString& aMedia); bool Matches(); - void AddListener(mozilla::dom::MediaQueryListListener& aListener); - void RemoveListener(mozilla::dom::MediaQueryListListener& aListener); + void AddListener(EventListener* aListener, ErrorResult& aRv); + void RemoveListener(EventListener* aListener, ErrorResult& aRv); + + EventHandlerNonNull* GetOnchange(); + void SetOnchange(EventHandlerNonNull* aCallback); + + using nsIDOMEventTarget::AddEventListener; + using nsIDOMEventTarget::RemoveEventListener; + + virtual void AddEventListener(const nsAString& aType, + EventListener* aCallback, + const AddEventListenerOptionsOrBoolean& aOptions, + const Nullable<bool>& aWantsUntrusted, + ErrorResult& aRv) override; + virtual void RemoveEventListener(const nsAString& aType, + EventListener* aCallback, + const EventListenerOptionsOrBoolean& aOptions, + ErrorResult& aRv) override; + + bool HasListeners(); + + void Disconnect(); private: void RecomputeMatches(); + + void UpdateMustKeepAlive(); // We only need a pointer to the document to support lazy // reevaluation following dynamic changes. However, this lazy @@ -84,7 +96,7 @@ private: RefPtr<nsMediaList> mMediaList; bool mMatches; bool mMatchesValid; - nsTArray<RefPtr<mozilla::dom::MediaQueryListListener>> mCallbacks; + bool mIsKeptAlive; }; } // namespace dom -- cgit v1.2.3