CSS Selectors: fix attribute case-insensitive matching of Contain and List
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2015 05:04:46 +0000 (05:04 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Mar 2015 05:04:46 +0000 (05:04 +0000)
commit98a8fa931c5ab25d47b2b79b4f16b44cb2d47688
treee02c339258400c5bf32993c64fafe86a0331e4cd
parent565c10fc53874d950224087410ec2c78f2c6f9bb
CSS Selectors: fix attribute case-insensitive matching of Contain and List
https://bugs.webkit.org/show_bug.cgi?id=142932

Reviewed by Darin Adler.

Source/WebCore:

Fix the last two attribute selectors that were using full case-insensitive
match:
    -Contain ([foo*=bar]).
    -List (foo~=bar]).

Tests: fast/selectors/attribute-contains-value-matching-is-ascii-case-insensitive.html
       fast/selectors/attribute-list-value-matching-is-ascii-case-insensitive.html

* css/SelectorChecker.cpp:
(WebCore::attributeValueMatches):
* cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::attributeValueContains):
(WebCore::SelectorCompiler::attributeValueSpaceSeparetedListContains):

Source/WTF:

Add some utility functions to the string classes to find substrings
using ASCII case-insensitive comparisons.

* wtf/text/AtomicString.h:
(WTF::AtomicString::contains):
Add the light version that only lock one register.

(WTF::AtomicString::containsIgnoringASCIICase):
(WTF::AtomicString::findIgnoringASCIICase):

* wtf/text/StringCommon.h:
(WTF::findIgnoringASCIICase):
This is the common implementation used by StringView and StringImpl.

* wtf/text/StringImpl.cpp:
(WTF::StringImpl::findIgnoringASCIICase):
* wtf/text/StringImpl.h:
* wtf/text/StringView.cpp:
(WTF::StringView::containsIgnoringASCIICase):
(WTF::StringView::findIgnoringASCIICase):
* wtf/text/StringView.h:
* wtf/text/WTFString.h:
(WTF::String::findIgnoringASCIICase):
(WTF::String::contains):
(WTF::String::containsIgnoringASCIICase):

Tools:

Add tests for the new features and fix some existing tests using the
stringFromUTF8() utility recently added by Dhi.

* TestWebKitAPI/Tests/WTF/StringImpl.cpp:
(TestWebKitAPI::stringFromUTF8):
* TestWebKitAPI/Tests/WTF/StringView.cpp:

LayoutTests:

* fast/selectors/attribute-contains-value-matching-is-ascii-case-insensitive-expected.txt: Added.
* fast/selectors/attribute-contains-value-matching-is-ascii-case-insensitive.html: Added.
* fast/selectors/attribute-list-value-matching-is-ascii-case-insensitive-expected.txt: Added.
* fast/selectors/attribute-list-value-matching-is-ascii-case-insensitive.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181845 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/selectors/attribute-contains-value-matching-is-ascii-case-insensitive-expected.txt [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-contains-value-matching-is-ascii-case-insensitive.html [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-list-value-matching-is-ascii-case-insensitive-expected.txt [new file with mode: 0644]
LayoutTests/fast/selectors/attribute-list-value-matching-is-ascii-case-insensitive.html [new file with mode: 0644]
Source/WTF/ChangeLog
Source/WTF/wtf/text/AtomicString.h
Source/WTF/wtf/text/StringCommon.h
Source/WTF/wtf/text/StringImpl.cpp
Source/WTF/wtf/text/StringImpl.h
Source/WTF/wtf/text/StringView.cpp
Source/WTF/wtf/text/StringView.h
Source/WTF/wtf/text/WTFString.h
Source/WebCore/ChangeLog
Source/WebCore/css/SelectorChecker.cpp
Source/WebCore/cssjit/SelectorCompiler.cpp
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
Tools/TestWebKitAPI/Tests/WTF/StringView.cpp