Diff
Modified: trunk/LayoutTests/ChangeLog (175452 => 175453)
--- trunk/LayoutTests/ChangeLog 2014-11-01 11:16:06 UTC (rev 175452)
+++ trunk/LayoutTests/ChangeLog 2014-11-01 18:11:11 UTC (rev 175453)
@@ -1,3 +1,36 @@
+2014-11-01 Benjamin Poulain <[email protected]>
+
+ Fix the specificity of the extended :not() selector
+ https://bugs.webkit.org/show_bug.cgi?id=138275
+
+ Reviewed by Andreas Kling.
+
+ * fast/css/not-self-specificity-expected.html: Added.
+ * fast/css/not-self-specificity.html: Added.
+ Test that :not() itself does not influence the specificity,
+ only the nested selectors contribute to the global specificity.
+
+ * fast/css/not-specificity-1-expected.html: Added.
+ * fast/css/not-specificity-1.html: Added.
+ * fast/css/not-specificity-2-expected.html: Added.
+ * fast/css/not-specificity-2.html: Added.
+ * fast/css/not-specificity-3-expected.html: Added.
+ * fast/css/not-specificity-3.html: Added.
+ Tests for compound selectors.
+ All tests are variations of the same base testing specificity
+ and position.
+
+ * fast/css/not-specificity-4-expected.html: Added.
+ * fast/css/not-specificity-4.html: Added.
+ * fast/css/not-specificity-5-expected.html: Added.
+ * fast/css/not-specificity-5.html: Added.
+ * fast/css/not-specificity-6-expected.html: Added.
+ * fast/css/not-specificity-6.html: Added.
+ Same thing for complex selectors.
+
+ * fast/selectors/class-style-update-with-not-expected.txt:
+ Yeah, one more test fixed :)
+
2014-11-01 Hunseop Jeong <[email protected]>
[EFL] Unreviewed EFL gardening.
Added: trunk/LayoutTests/fast/css/not-self-specificity-expected.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-self-specificity-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-self-specificity-expected.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,17 @@
+<!doctype html>
+<html>
+<head>
+ <title>Test the specificity of the :not() pseudo class itself.</title>
+ <style>
+ * {
+ background-color: white;
+ color: black;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of the :not() pseudo class. The pseudo class :not() itself does not add anything to the specificity of a its selector, only the selectors inside :not() matter for specificity.</p>
+ <testcase style="color: lime; background-color: pink;">This sentence should be green on a pink background, without border.</testcase>
+ <testcase style="color: pink; background-color: lime;">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-self-specificity.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-self-specificity.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-self-specificity.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,67 @@
+<!doctype html>
+<html>
+<head>
+ <title>Test the specificity of the :not() pseudo class itself.</title>
+ <style>
+ /* -- 1. Set up the base color for everything with a very low specificity -- */
+
+ /* Each mathing of the type "notthereX should have a specificity of (0, 0, 1), the maxium of this selector should be (0, 0, 1). */
+ :not(:not(*), notthere1, notthere2, notthere3, notthere4, notthere5) {
+ background-color: white;
+ color: black;
+ }
+
+ /* The pseudo class :not() itself should have no specificity. The following rule should not have precedence over "*". */
+ :not(:not(*)) { /* Specificity: (0, 0, 0). */
+ background-color: red;
+ color: white;
+ }
+
+ /* -- 2. Test class specificity. -- */
+ .case {
+ background-color: red;
+ color: white;
+ }
+
+ body > testcase.case { /* Specificity (0, 1, 2). */
+ border: none;
+ }
+
+ testcase:not(.not-there) { /* Specificity (0, 1, 1). */
+ color: lime;
+ border: 10px solid black;
+ }
+
+ /* Specificity (0, 1, 1) since .not-there has the highest specificity inside :not(). */
+ testcase:not(:not(*), foo, .not-there, bar) {
+ background-color: pink;
+ border: 50px solid black;
+ }
+
+ /* -- 3. Test #id specificty, all those rules should override the class rules above. -- */
+ #case2 {
+ background-color: red;
+ color: white;
+ }
+
+ body > testcase#case2 { /* Specificity (1, 0, 2). */
+ border: none;
+ }
+
+ testcase:not(#case1) {
+ color: pink;
+ border: 10px solid black;
+ }
+
+ testcase:not(:not(*), foo, bar, foo.class1.class2, bar.class1.class2.class3.class4, #case1) {
+ background-color: lime;
+ border: 50px solid black;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of the :not() pseudo class. The pseudo class :not() itself does not add anything to the specificity of a its selector, only the selectors inside :not() matter for specificity.</p>
+ <testcase class="case" id="case1">This sentence should be green on a pink background, without border.</testcase>
+ <testcase class="case" id="case2">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-1-expected.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-1-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-1-expected.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<body>
+ <p>Test the specificity of :not() with compound selectors.</p>
+ <testcase style="color: green; background-color: pink;">This sentence should be green on a pink background, without border.</testcase>
+ <testcase style="color: pink; background-color: green;">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-1.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-1.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-1.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+ <style>
+ /* Specificity: (1, 1, 1). */
+ testcase.case#case1, testcase.case#case2 {
+ background-color: red;
+ color: white;
+ border: 10px solid black;
+ }
+
+ /* The maximum here is (1, 0, 1), the total is (1, 0, 2) which does not override the baseline. */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding testcase#case2.case to push to (1, 1, 2). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, testcase#case2.case) {
+ background-color: pink;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, #case2.case.case2) {
+ color: green;
+ }
+
+ /* #case2.case#case1 to push to (2, 0, 1). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, #case2#case1) {
+ border: none;
+ }
+
+ /* The maximum here is (1, 0, 1), the total is (1, 0, 2) which does not override the baseline. */
+ testcase:not(testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding testcase#case2.case to push to (1, 1, 2). */
+ testcase:not(testcase#case1.case) {
+ background-color: green;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(#case1.case.case) {
+ color: pink;
+ }
+
+ /* #case3#case1 to push to (2, 0, 1). */
+ testcase:not(#case3#case1) {
+ border: none;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of :not() with compound selectors.</p>
+ <testcase class="case" id="case1">This sentence should be green on a pink background, without border.</testcase>
+ <testcase class="case" id="case2">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-2-expected.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-2-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-2-expected.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<body>
+ <p>Test the specificity of :not() with compound selectors.</p>
+ <testcase style="color: green; background-color: pink;">This sentence should be green on a pink background, without border.</testcase>
+ <testcase style="color: pink; background-color: green;">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-2.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-2.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-2.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+ <style>
+ /* The maximum here is (1, 0, 1), the total is (1, 0, 2) which does not override the baseline. */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding testcase#case2.case to push to (1, 1, 2). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, testcase#case2.case) {
+ background-color: pink;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, #case2.case.case2) {
+ color: green;
+ }
+
+ /* #case2.case#case1 to push to (2, 0, 1). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, #case2#case1) {
+ border: none;
+ }
+
+ /* The maximum here is (1, 0, 1), the total is (1, 0, 2) which does not override the baseline. */
+ testcase:not(testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding testcase#case2.case to push to (1, 1, 2). */
+ testcase:not(testcase#case1.case) {
+ background-color: green;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(#case1.case.case) {
+ color: pink;
+ }
+
+ /* #case3#case1 to push to (2, 0, 1). */
+ testcase:not(#case3#case1) {
+ border: none;
+ }
+
+ /* Specificity: (1, 1, 1). */
+ testcase.case#case1, testcase.case#case2 {
+ background-color: red;
+ color: white;
+ border: 10px solid black;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of :not() with compound selectors.</p>
+ <testcase class="case" id="case1">This sentence should be green on a pink background, without border.</testcase>
+ <testcase class="case" id="case2">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-3-expected.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-3-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-3-expected.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<body>
+ <p>Test the specificity of :not() with compound selectors.</p>
+ <testcase style="color: green; background-color: pink;">This sentence should be green on a pink background, without border.</testcase>
+ <testcase style="color: pink; background-color: green;">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-3.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-3.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-3.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+ <style>
+ /* Specificity: (1, 1, 1). */
+ testcase.case#case1, testcase.case#case2 {
+ background-color: red;
+ color: white;
+ border: 10px solid black;
+ }
+
+ /* The maximum here is (1, 0, 1), the total is (1, 0, 2) which does not override the baseline. */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding #case2.case to push to (1, 1, 1). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, #case2.case) {
+ background-color: pink;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, #case2.case.case2) {
+ color: green;
+ }
+
+ /* #case2.case#case1 to push to (2, 0, 1). */
+ testcase:not(testcase1, testcase2, testcase1.foo, testcase1.foo.bar, testcase1.foo.bar.baz, #case2, testcase#case2, testcase1#case2, #case2#case1) {
+ border: none;
+ }
+
+ /* The maximum here is (1, 0, 1), the total is (1, 0, 2) which does not override the baseline. */
+ testcase:not(testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding testcase#case2.case to push to (1, 1, 1). */
+ testcase:not(#case1.case) {
+ background-color: green;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(#case1.case.case) {
+ color: pink;
+ }
+
+ /* #case3#case1 to push to (2, 0, 1). */
+ testcase:not(#case3#case1) {
+ border: none;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of :not() with compound selectors.</p>
+ <testcase class="case" id="case1">This sentence should be green on a pink background, without border.</testcase>
+ <testcase class="case" id="case2">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-4-expected.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-4-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-4-expected.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<body>
+ <p>Test the specificity of :not() with complex selectors.</p>
+ <testcase style="color: green; background-color: pink;">This sentence should be green on a pink background, without border.</testcase>
+ <testcase style="color: pink; background-color: green;">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-4.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-4.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-4.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+ <style>
+ /* Specificity: (1, 1, 3). */
+ html > body > testcase.case#case1, html > body > testcase.case#case2 {
+ background-color: red;
+ color: white;
+ border: 10px solid black;
+ }
+
+ /* The maximum here is (1, 0, 3), the total is (1, 0, 4) which does not override the baseline. */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding html body testcase#case2.case to push to (1, 1, 4). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, html body testcase#case2.case) {
+ background-color: pink;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, #case2.case.case2) {
+ color: green;
+ }
+
+ /* #case2#case1 to push to (2, 0, 1). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, #case2#case1) {
+ border: none;
+ }
+
+ /* The maximum here is (1, 0, 3), the total is (1, 0, 4) which does not override the baseline. */
+ testcase:not(html body testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding html body testcase#case2.case to push to (1, 1, 4). */
+ testcase:not(html body testcase#case1.case) {
+ background-color: green;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(html body #case1.case.case) {
+ color: pink;
+ }
+
+ /* #case3#case1 to push to (2, 0, 1). */
+ testcase:not(html body #case3#case1) {
+ border: none;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of :not() with complex selectors.</p>
+ <testcase class="case" id="case1">This sentence should be green on a pink background, without border.</testcase>
+ <testcase class="case" id="case2">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-5-expected.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-5-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-5-expected.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<body>
+ <p>Test the specificity of :not() with complex selectors.</p>
+ <testcase style="color: green; background-color: pink;">This sentence should be green on a pink background, without border.</testcase>
+ <testcase style="color: pink; background-color: green;">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-5.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-5.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-5.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+ <style>
+ /* The maximum here is (1, 0, 3), the total is (1, 0, 4) which does not override the baseline. */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding html body testcase#case2.case to push to (1, 1, 4). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, html body testcase#case2.case) {
+ background-color: pink;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, #case2.case.case2) {
+ color: green;
+ }
+
+ /* #case2#case1 to push to (2, 0, 1). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, #case2#case1) {
+ border: none;
+ }
+
+ /* The maximum here is (1, 0, 3), the total is (1, 0, 4) which does not override the baseline. */
+ testcase:not(html body testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding html body testcase#case2.case to push to (1, 1, 4). */
+ testcase:not(html body testcase#case1.case) {
+ background-color: green;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(html body #case1.case.case) {
+ color: pink;
+ }
+
+ /* #case3#case1 to push to (2, 0, 1). */
+ testcase:not(html body #case3#case1) {
+ border: none;
+ }
+
+ /* Specificity: (1, 1, 3). */
+ html > body > testcase.case#case1, html > body > testcase.case#case2 {
+ background-color: red;
+ color: white;
+ border: 10px solid black;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of :not() with complex selectors.</p>
+ <testcase class="case" id="case1">This sentence should be green on a pink background, without border.</testcase>
+ <testcase class="case" id="case2">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-6-expected.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-6-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-6-expected.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,8 @@
+<!doctype html>
+<html>
+<body>
+ <p>Test the specificity of :not() with complex selectors.</p>
+ <testcase style="color: green; background-color: pink;">This sentence should be green on a pink background, without border.</testcase>
+ <testcase style="color: pink; background-color: green;">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/not-specificity-6.html (0 => 175453)
--- trunk/LayoutTests/fast/css/not-specificity-6.html (rev 0)
+++ trunk/LayoutTests/fast/css/not-specificity-6.html 2014-11-01 18:11:11 UTC (rev 175453)
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+<head>
+ <style>
+ /* Specificity: (1, 1, 3). */
+ html > body > testcase.case#case1, html > body > testcase.case#case2 {
+ background-color: red;
+ color: white;
+ border: 10px solid black;
+ }
+
+ /* The maximum here is (1, 0, 3), the total is (1, 0, 4) which does not override the baseline. */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding body testcase#case2.case to push to (1, 1, 3). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, body testcase#case2.case) {
+ background-color: pink;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, #case2.case.case2) {
+ color: green;
+ }
+
+ /* #case2#case1 to push to (2, 0, 1). */
+ testcase:not(html > body testcase1, html body testcase2, html body > testcase1.foo, html body > testcase1.foo.bar, html > body testcase1.foo.bar.baz, html > body #case2, body > testcase#case2, html body > testcase1#case2, #case2#case1) {
+ border: none;
+ }
+
+ /* The maximum here is (1, 0, 3), the total is (1, 0, 4) which does not override the baseline. */
+ testcase:not(html body testcase1#case2) {
+ background-color: blue;
+ }
+
+ /* Adding html testcase#case2.case to push to (1, 1, 3). */
+ testcase:not(html testcase#case1.case) {
+ background-color: green;
+ }
+
+ /* #case2.case.case2 to push to (1, 2, 1). */
+ testcase:not(html body #case1.case.case) {
+ color: pink;
+ }
+
+ /* #case3#case1 to push to (2, 0, 1). */
+ testcase:not(html body #case3#case1) {
+ border: none;
+ }
+ </style>
+</head>
+<body>
+ <p>Test the specificity of :not() with complex selectors.</p>
+ <testcase class="case" id="case1">This sentence should be green on a pink background, without border.</testcase>
+ <testcase class="case" id="case2">This sentence should be pink on a green background, without border.</testcase>
+</body>
+</html>
Modified: trunk/LayoutTests/fast/selectors/class-style-update-with-not-expected.txt (175452 => 175453)
--- trunk/LayoutTests/fast/selectors/class-style-update-with-not-expected.txt 2014-11-01 11:16:06 UTC (rev 175452)
+++ trunk/LayoutTests/fast/selectors/class-style-update-with-not-expected.txt 2014-11-01 18:11:11 UTC (rev 175453)
@@ -27,14 +27,14 @@
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 0, 0)"
PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(0, 1, 2)"
PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(0, 1, 2)"
-FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(3, 4, 5). Was rgb(0, 1, 2).
-FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(3, 4, 5). Was rgb(0, 1, 2).
-FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(6, 7, 8). Was rgb(0, 1, 2).
-FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(6, 7, 8). Was rgb(0, 1, 2).
-FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(9, 10, 11). Was rgb(0, 1, 2).
-FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(9, 10, 11). Was rgb(0, 1, 2).
-FAIL getComputedStyle(document.querySelectorAll("target")[0]).color should be rgb(12, 13, 14). Was rgb(0, 1, 2).
-FAIL getComputedStyle(document.querySelectorAll("target")[1]).color should be rgb(12, 13, 14). Was rgb(0, 1, 2).
+PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(3, 4, 5)"
+PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(3, 4, 5)"
+PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(6, 7, 8)"
+PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(6, 7, 8)"
+PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(9, 10, 11)"
+PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(9, 10, 11)"
+PASS getComputedStyle(document.querySelectorAll("target")[0]).color is "rgb(12, 13, 14)"
+PASS getComputedStyle(document.querySelectorAll("target")[1]).color is "rgb(12, 13, 14)"
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/Source/WebCore/ChangeLog (175452 => 175453)
--- trunk/Source/WebCore/ChangeLog 2014-11-01 11:16:06 UTC (rev 175452)
+++ trunk/Source/WebCore/ChangeLog 2014-11-01 18:11:11 UTC (rev 175453)
@@ -1,3 +1,27 @@
+2014-11-01 Benjamin Poulain <[email protected]>
+
+ Fix the specificity of the extended :not() selector
+ https://bugs.webkit.org/show_bug.cgi?id=138275
+
+ Reviewed by Andreas Kling.
+
+ The current draft says "The specificity of a :not() pseudo-class
+ is the specificity of the most specifc complex selector in its selector list."
+
+ It is still unclear how :not() plays with other new selectors. Until that is clarified,
+ this only handle the simple cases.
+
+ Tests: fast/css/not-self-specificity.html
+ fast/css/not-specificity-1.html
+ fast/css/not-specificity-2.html
+ fast/css/not-specificity-3.html
+ fast/css/not-specificity-4.html
+ fast/css/not-specificity-5.html
+ fast/css/not-specificity-6.html
+
+ * css/CSSSelector.cpp:
+ (WebCore::CSSSelector::specificityForOneSelector):
+
2014-10-31 Benjamin Poulain <[email protected]>
Fix the Debug builds after r175446
Modified: trunk/Source/WebCore/css/CSSSelector.cpp (175452 => 175453)
--- trunk/Source/WebCore/css/CSSSelector.cpp 2014-11-01 11:16:06 UTC (rev 175452)
+++ trunk/Source/WebCore/css/CSSSelector.cpp 2014-11-01 18:11:11 UTC (rev 175453)
@@ -101,9 +101,22 @@
case PseudoClass:
// FIXME: PseudoAny should base the specificity on the sub-selectors.
// See http://lists.w3.org/Archives/Public/www-style/2010Sep/0530.html
+
+#if ENABLE(CSS_SELECTORS_LEVEL4)
+ if (pseudoClassType() == PseudoClassNot) {
+ ASSERT_WITH_MESSAGE(selectorList() && selectorList()->first(), "The parser should never generate a valid selector for an empty :not().");
+
+ unsigned maxSpecificity = 0;
+ for (const CSSSelector* subSelector = selectorList()->first(); subSelector; subSelector = CSSSelectorList::next(subSelector))
+ maxSpecificity = std::max(maxSpecificity, subSelector->specificity());
+ return maxSpecificity;
+ }
+ FALLTHROUGH;
+#else
if (pseudoClassType() == PseudoClassNot && selectorList())
return selectorList()->first()->specificityForOneSelector();
FALLTHROUGH;
+#endif
case Exact:
case Class:
case Set: