Skip to content
  • rwlbuis@webkit.org's avatar
    selectors should match attribute name with case sensitivity based on element & document type · a8f8ec60
    rwlbuis@webkit.org authored
    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: http://svn.webkit.org/repository/webkit/trunk@153631 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    a8f8ec60