- Revision
- 164203
- Author
- [email protected]
- Date
- 2014-02-16 19:19:49 -0800 (Sun, 16 Feb 2014)
Log Message
When applying style, attribute value matching should be case sensitive for SVG
https://bugs.webkit.org/show_bug.cgi?id=128882
Reviewed by Andreas Kling.
Source/WebCore:
SelectorChecker was incorrectly matching attribute values with a case insensitve comparison
in some cases.
The choice to use case sensitive matching was taking into account the document type but not
the element type. As a result, SVG (and likely MHTML) elements were incorrectly being tested
as if they were HTML element.
With the patch, WebKit also matches the behavior of Firefox, which is great.
Tests: fast/css/case-insensitive-attribute-with-svg.html
fast/selectors/querySelector-case-insensitive-attribute-match-with-svg.html
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
LayoutTests:
* fast/css/case-insensitive-attribute-with-svg-expected.html: Added.
* fast/css/case-insensitive-attribute-with-svg.html: Added.
* fast/selectors/querySelector-case-insensitive-attribute-match-with-svg-expected.txt: Added.
* fast/selectors/querySelector-case-insensitive-attribute-match-with-svg.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (164202 => 164203)
--- trunk/LayoutTests/ChangeLog 2014-02-17 03:14:48 UTC (rev 164202)
+++ trunk/LayoutTests/ChangeLog 2014-02-17 03:19:49 UTC (rev 164203)
@@ -1,3 +1,15 @@
+2014-02-16 Benjamin Poulain <[email protected]>
+
+ When applying style, attribute value matching should be case sensitive for SVG
+ https://bugs.webkit.org/show_bug.cgi?id=128882
+
+ Reviewed by Andreas Kling.
+
+ * fast/css/case-insensitive-attribute-with-svg-expected.html: Added.
+ * fast/css/case-insensitive-attribute-with-svg.html: Added.
+ * fast/selectors/querySelector-case-insensitive-attribute-match-with-svg-expected.txt: Added.
+ * fast/selectors/querySelector-case-insensitive-attribute-match-with-svg.html: Added.
+
2014-02-15 Piotr Grad <[email protected]>
Setting currentTime on HTMLMediaElement with media controller should throw exception.
Added: trunk/LayoutTests/fast/css/case-insensitive-attribute-with-svg-expected.html (0 => 164203)
--- trunk/LayoutTests/fast/css/case-insensitive-attribute-with-svg-expected.html (rev 0)
+++ trunk/LayoutTests/fast/css/case-insensitive-attribute-with-svg-expected.html 2014-02-17 03:19:49 UTC (rev 164203)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Case Insensitive and Case Sensitive Attribute matching</title>
+</head>
+<body>
+ <p>On success, there should be a large green surface visible and no red anywhere.</p>
+
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" style="margin-top:50px">
+ <rect x="50" y="0" width="50" height="50" style="fill:green" />
+ <rect x="0" y="0" width="50" height="50" style="fill:green" />
+ </svg>
+</body>
+</html>
Added: trunk/LayoutTests/fast/css/case-insensitive-attribute-with-svg.html (0 => 164203)
--- trunk/LayoutTests/fast/css/case-insensitive-attribute-with-svg.html (rev 0)
+++ trunk/LayoutTests/fast/css/case-insensitive-attribute-with-svg.html 2014-02-17 03:19:49 UTC (rev 164203)
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Case Insensitive and Case Sensitive Attribute matching</title>
+<style>
+[link=foobar], [lang=foobar] {
+ display: none;
+}
+</style>
+</head>
+<body>
+ <p>On success, there should be a large green surface visible and no red anywhere.</p>
+ <!-- None of these rects should appear, lang and link attribute matching is case insensitive for HTML documents. -->
+ <div style="background-color: red; position: absolute; left:0; width:50px; height:50px" lang="FooBar"></div>
+ <div style="background-color: red; position: absolute; left:50px; width:50px; height:50px" link="FooBar"></div>
+ <div style="background-color: red; position: absolute; left:100px; width:50px; height:50px" lang="foobar"></div>
+ <div style="background-color: red; position: absolute; left:150px; width:50px; height:50px" link="foobar"></div>
+
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" style="margin-top:50px">
+ <!-- The first green rects should be visible, attribute matching is always case sensitive for XML or SVG documents. -->
+ <rect x="50" y="0" width="50" height="50" lang="FooBar" style="fill:green" />
+ <rect x="0" y="0" width="50" height="50" link="FooBar" style="fill:green" />
+ <!-- These are regular match and should not appear. -->
+ <rect x="0" y="50" width="50" height="50" lang="foobar" style="fill:red" />
+ <rect x="50" y="50" width="50" height="50" link="foobar" style="fill:red" />
+ </svg>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/fast/selectors/querySelector-case-insensitive-attribute-match-with-svg-expected.txt (0 => 164203)
--- trunk/LayoutTests/fast/selectors/querySelector-case-insensitive-attribute-match-with-svg-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-case-insensitive-attribute-match-with-svg-expected.txt 2014-02-17 03:19:49 UTC (rev 164203)
@@ -0,0 +1,17 @@
+Some attribute needs case insensitive value matching with HTML. This test we do not incorrectly match SVG.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.querySelectorAll("[lang=foobar]").length is 3
+PASS document.querySelectorAll("[lang=foobar]")[0].id is "div1"
+PASS document.querySelectorAll("[lang=foobar]")[1].id is "div3"
+PASS document.querySelectorAll("[lang=foobar]")[2].id is "rect3"
+PASS document.querySelectorAll("[link=foobar]").length is 3
+PASS document.querySelectorAll("[link=foobar]")[0].id is "div2"
+PASS document.querySelectorAll("[link=foobar]")[1].id is "div4"
+PASS document.querySelectorAll("[link=foobar]")[2].id is "rect4"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/selectors/querySelector-case-insensitive-attribute-match-with-svg.html (0 => 164203)
--- trunk/LayoutTests/fast/selectors/querySelector-case-insensitive-attribute-match-with-svg.html (rev 0)
+++ trunk/LayoutTests/fast/selectors/querySelector-case-insensitive-attribute-match-with-svg.html 2014-02-17 03:19:49 UTC (rev 164203)
@@ -0,0 +1,35 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div style="display:none">
+ <div id=div1 style="background-color: red; position: absolute; left:0; width:50px; height:50px" lang="FooBar"></div>
+ <div id=div2 style="background-color: red; position: absolute; left:50px; width:50px; height:50px" link="FooBar"></div>
+ <div id=div3 style="background-color: red; position: absolute; left:100px; width:50px; height:50px" lang="foobar"></div>
+ <div id=div4 style="background-color: red; position: absolute; left:150px; width:50px; height:50px" link="foobar"></div>
+
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 100 100" style="margin-top:50px">
+ <rect id=rect1 x="50" y="0" width="50" height="50" lang="FooBar" style="fill:green" />
+ <rect id=rect2 x="0" y="0" width="50" height="50" link="FooBar" style="fill:green" />
+ <rect id=rect3 x="0" y="50" width="50" height="50" lang="foobar" style="fill:red" />
+ <rect id=rect4 x="50" y="50" width="50" height="50" link="foobar" style="fill:red" />
+ </svg>
+</div>
+</body>
+<script>
+description('Some attribute needs case insensitive value matching with HTML. This test we do not incorrectly match SVG.');
+
+shouldBe('document.querySelectorAll("[lang=foobar]").length', '3');
+shouldBeEqualToString('document.querySelectorAll("[lang=foobar]")[0].id', 'div1');
+shouldBeEqualToString('document.querySelectorAll("[lang=foobar]")[1].id', 'div3');
+shouldBeEqualToString('document.querySelectorAll("[lang=foobar]")[2].id', 'rect3');
+
+shouldBe('document.querySelectorAll("[link=foobar]").length', '3');
+shouldBeEqualToString('document.querySelectorAll("[link=foobar]")[0].id', 'div2');
+shouldBeEqualToString('document.querySelectorAll("[link=foobar]")[1].id', 'div4');
+shouldBeEqualToString('document.querySelectorAll("[link=foobar]")[2].id', 'rect4');
+</script>
+<script src=""
+</html>
Modified: trunk/Source/WebCore/ChangeLog (164202 => 164203)
--- trunk/Source/WebCore/ChangeLog 2014-02-17 03:14:48 UTC (rev 164202)
+++ trunk/Source/WebCore/ChangeLog 2014-02-17 03:19:49 UTC (rev 164203)
@@ -1,5 +1,27 @@
2014-02-16 Benjamin Poulain <[email protected]>
+ When applying style, attribute value matching should be case sensitive for SVG
+ https://bugs.webkit.org/show_bug.cgi?id=128882
+
+ Reviewed by Andreas Kling.
+
+ SelectorChecker was incorrectly matching attribute values with a case insensitve comparison
+ in some cases.
+
+ The choice to use case sensitive matching was taking into account the document type but not
+ the element type. As a result, SVG (and likely MHTML) elements were incorrectly being tested
+ as if they were HTML element.
+
+ With the patch, WebKit also matches the behavior of Firefox, which is great.
+
+ Tests: fast/css/case-insensitive-attribute-with-svg.html
+ fast/selectors/querySelector-case-insensitive-attribute-match-with-svg.html
+
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::checkOne):
+
+2014-02-16 Benjamin Poulain <[email protected]>
+
Split compilation state between querySelector and CSS matching
https://bugs.webkit.org/show_bug.cgi?id=128869
Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (164202 => 164203)
--- trunk/Source/WebCore/css/SelectorChecker.cpp 2014-02-17 03:14:48 UTC (rev 164202)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp 2014-02-17 03:19:49 UTC (rev 164203)
@@ -372,7 +372,7 @@
return false;
const QualifiedName& attr = selector->attribute();
- bool caseSensitive = !m_documentIsHTML || HTMLDocument::isCaseSensitiveAttribute(attr);
+ bool caseSensitive = !(m_documentIsHTML && element->isHTMLElement()) || HTMLDocument::isCaseSensitiveAttribute(attr);
if (!anyAttributeMatches(element, selector, attr, caseSensitive))
return false;