selectors should match attribute name with case sensitivity based on element & docume...
authorrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2013 01:00:10 +0000 (01:00 +0000)
committerrwlbuis@webkit.org <rwlbuis@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Aug 2013 01:00:10 +0000 (01:00 +0000)
commit8bfdf83bcd0d786b74ef84f9ab49d9c903c78209
treece652c7de5d3f871b420a0b324e3ad3b3ac81fb6
parent548e9c67183c0eaa5e8312f6d5932b03b3130890
selectors should match attribute name with case sensitivity based on element & document type
https://bugs.webkit.org/show_bug.cgi?id=71152

Reviewed by Darin Adler.

Source/WebCore:

Support case-sensitive attribute name selecting for non HTML. In order to do this we have to
store the attribute name in the selector as-is when css parsing, and get the lowercase localName
on demand for case-insensitive matching. The only time we want case-insensitive matching is when
we try to match a HTML element in a HTML document.

Tests: fast/dom/SelectorAPI/attrname-case-insensitive.html
       fast/dom/SelectorAPI/attrname-case-sensitive.xhtml
       svg/css/case-sensitive-attrname-selectors.html

* css/CSSGrammar.y.in: do not lowercase attribute selector name.
* css/CSSParserValues.h:
(WebCore::CSSParserSelector::setAttribute):
* css/CSSSelector.cpp:
(WebCore::CSSSelector::setAttribute):
* css/CSSSelector.h: allow access to lowered version of attribute localName if needed.
(WebCore::CSSSelector::attributeCanonicalLocalName):
* css/SelectorChecker.cpp:
(WebCore::anyAttributeMatches): do only case-insensitive matching for HTML.
(WebCore::SelectorChecker::checkOne):
* css/SelectorChecker.h:
(WebCore::SelectorChecker::checkExactAttribute): do only case-insensitive matching for HTML.
* css/SelectorCheckerFastPath.cpp:
(WebCore::HTMLNames::checkExactAttributeValue):
* css/SelectorCheckerFastPath.h:
(WebCore::SelectorCheckerFastPath::matchesRightmostAttributeSelector):
* dom/Attribute.h:
(WebCore::Attribute::matches): use more convenient parameters.

LayoutTests:

Results matches FireFox nightly.

* fast/dom/SelectorAPI/attrname-case-insensitive-expected.txt: Added.
* fast/dom/SelectorAPI/attrname-case-insensitive.html: Check that in HTML documents CSS selectors
use case-insensitive attribute name matching for HTML elements, case-sensitive otherwise.
* fast/dom/SelectorAPI/attrname-case-sensitive-expected.txt: Added.
* fast/dom/SelectorAPI/attrname-case-sensitive.xhtml: Check that in XHTML documents CSS selectors
always use case-sensitive attribute name matching.
* svg/css/case-sensitive-attrname-selectors-expected.txt: Added.
* svg/css/case-sensitive-attrname-selectors.html: Check that in HTML documents CSS selectors in stylesheets
use case-insensitive attribute name matching for HTML elements, case-sensitive otherwise.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@153631 268f45cc-cd09-0410-ab3c-d52691b4dbfc
17 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/SelectorAPI/attrname-case-insensitive-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/SelectorAPI/attrname-case-insensitive.html [new file with mode: 0644]
LayoutTests/fast/dom/SelectorAPI/attrname-case-sensitive-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/SelectorAPI/attrname-case-sensitive.xhtml [new file with mode: 0644]
LayoutTests/svg/css/case-sensitive-attrname-selectors-expected.txt [new file with mode: 0644]
LayoutTests/svg/css/case-sensitive-attrname-selectors.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/css/CSSGrammar.y.in
Source/WebCore/css/CSSParserValues.h
Source/WebCore/css/CSSSelector.cpp
Source/WebCore/css/CSSSelector.h
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/css/SelectorChecker.h
Source/WebCore/css/SelectorCheckerFastPath.cpp
Source/WebCore/css/SelectorCheckerFastPath.h
Source/WebCore/dom/Attribute.h