Changeset 81742 in webkit


Ignore:
Timestamp:
Mar 22, 2011 6:44:38 PM (13 years ago)
Author:
ojan@chromium.org
Message:

2011-03-17 Ojan Vafai <ojan@chromium.org>

Reviewed by Antti Koivisto.

webkit should implement -moz-any selector (as -webkit-any obviously)
https://bugs.webkit.org/show_bug.cgi?id=38095

  • fast/css/css-selector-text-expected.txt:
  • fast/css/css-selector-text.html:
  • fast/css/css-set-selector-text-expected.txt:
  • fast/css/css-set-selector-text.html:
  • fast/css/pseudo-any-expected.txt: Added.
  • fast/css/pseudo-any.html: Added.
  • fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt:
  • fast/dom/SelectorAPI/not-supported-namespace-in-selector.html:
  • fast/dom/SelectorAPI/unknown-pseudo-expected.txt: Added.
  • fast/dom/SelectorAPI/unknown-pseudo.html: Added.

2011-03-17 Ojan Vafai <ojan@chromium.org>

Reviewed by Antti Koivisto.

webkit should implement -moz-any selector (as -webkit-any obviously)
https://bugs.webkit.org/show_bug.cgi?id=38095

For now, match the Mozilla implementation with respect to specificity
and only allowing simple selectors. Both of these are likely to change
pending discussion on www-style@.

Tests: fast/css/pseudo-any.html

fast/dom/SelectorAPI/unknown-pseudo.html

  • css/CSSGrammar.y: Create simple_selector_list. This is exactly like selector_list except it only allows simple selectors and creates a new vector instead of a reusable one since there can be multiple in one rule.
  • css/CSSParser.cpp: (WebCore::CSSParser::~CSSParser): (WebCore::CSSParser::lex): (WebCore::CSSParser::createFloatingSelectorVector): (WebCore::CSSParser::sinkFloatingSelectorVector):
  • css/CSSParser.h:
  • css/CSSParserValues.cpp: (WebCore::CSSParserSelector::adoptSelectorVector):
  • css/CSSParserValues.h:
  • css/CSSSelector.cpp: (WebCore::CSSSelector::specificityForOneSelector): (WebCore::CSSSelector::pseudoId): (WebCore::nameToPseudoTypeMap): (WebCore::CSSSelector::extractPseudoType): (WebCore::CSSSelector::selectorText): (WebCore::CSSSelector::setSelectorList): (WebCore::CSSSelector::RareData::RareData): (WebCore::CSSSelector::RareData::~RareData): These need to be moved into the cpp file so that we can have an OwnPtr<CSSSelectorList> in CSSSelector::RareData.
  • css/CSSSelector.h: (WebCore::CSSSelector::selectorList):
  • css/CSSSelectorList.cpp: (WebCore::forEachTagSelector):
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector): (WebCore::collectFeaturesFromSelector):
  • css/tokenizer.flex:
Location:
trunk
Files:
4 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r81741 r81742  
     12011-03-17  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        webkit should implement -moz-any selector (as -webkit-any obviously)
     6        https://bugs.webkit.org/show_bug.cgi?id=38095
     7
     8        * fast/css/css-selector-text-expected.txt:
     9        * fast/css/css-selector-text.html:
     10        * fast/css/css-set-selector-text-expected.txt:
     11        * fast/css/css-set-selector-text.html:
     12        * fast/css/pseudo-any-expected.txt: Added.
     13        * fast/css/pseudo-any.html: Added.
     14        * fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt:
     15        * fast/dom/SelectorAPI/not-supported-namespace-in-selector.html:
     16        * fast/dom/SelectorAPI/unknown-pseudo-expected.txt: Added.
     17        * fast/dom/SelectorAPI/unknown-pseudo.html: Added.
     18
    1192011-03-22  Mihai Parparita  <mihaip@chromium.org>
    220
  • trunk/LayoutTests/fast/css/css-selector-text-expected.txt

    r20477 r81742  
    4747PASS parseThenSerializeRule(':lang(a) { }') is ':lang(a) { }'
    4848PASS parseThenSerializeRule(':not(a) { }') is ':not(a) { }'
     49PASS parseThenSerializeRule(':-webkit-any(a,b,p) { }') is ':-webkit-any(a,b,p) { }'
    4950
    5051PASS parseThenSerializeRule('::after { }') is '::after { }'
     
    6667
    6768PASS parseThenSerializeRule('input:not([type="file"]):focus { }') is 'input:not([type="file"]):focus { }'
     69PASS parseThenSerializeRule(':-webkit-any([type="file"]) { }') is ':-webkit-any([type="file"]) { }'
     70PASS parseThenSerializeRule(':-webkit-any(:hover) { }') is ':-webkit-any(:hover) { }'
     71PASS parseThenSerializeRule('input:-webkit-any([type="file"],:hover,:focus):enabled { }') is 'input:-webkit-any([type="file"],:hover,:focus):enabled { }'
     72PASS parseThenSerializeRule(':-webkit-any(input[type="file"],a:hover,button:focus) { }') is ':-webkit-any(input[type="file"],a:hover,button:focus) { }'
     73PASS parseThenSerializeRule(':-webkit-any(.class1.class2.class3) { }') is ':-webkit-any(.class1.class2.class3) { }'
     74PASS parseThenSerializeRule(':-webkit-any(.class1:hover) { }') is ':-webkit-any(.class1:hover) { }'
     75PASS parseThenSerializeRule(':-webkit-any(a.class1.class2.class3:hover) { }') is ':-webkit-any(a.class1.class2.class3:hover) { }'
    6876
    6977PASS parseThenSerializeRule('*:active { }') is ':active { }'
     
    8088PASS parseThenSerializeRule(':first-letter { }') is '::first-letter { }'
    8189PASS parseThenSerializeRule(':first-line { }') is '::first-line { }'
     90PASS parseThenSerializeRule(':-webkit-any(    a.class1  ,       #id,[attr]  ) { }') is ':-webkit-any(a.class1,#id,[attr]) { }'
    8291
    8392PASS successfullyParsed is true
  • trunk/LayoutTests/fast/css/css-selector-text.html

    r25111 r81742  
    8383testSelectorRoundTrip(":lang(a)");
    8484testSelectorRoundTrip(":not(a)");
     85testSelectorRoundTrip(":-webkit-any(a,b,p)");
    8586
    8687debug('');
     
    110111
    111112testSelectorRoundTrip('input:not([type="file"]):focus');
     113testSelectorRoundTrip(':-webkit-any([type="file"])');
     114testSelectorRoundTrip(':-webkit-any(:hover)');
     115testSelectorRoundTrip('input:-webkit-any([type="file"],:hover,:focus):enabled');
     116testSelectorRoundTrip(':-webkit-any(input[type="file"],a:hover,button:focus)');
     117testSelectorRoundTrip(':-webkit-any(.class1.class2.class3)');
     118testSelectorRoundTrip(':-webkit-any(.class1:hover)');
     119testSelectorRoundTrip(':-webkit-any(a.class1.class2.class3:hover)');
    112120
    113121debug('');
     
    132140shouldBe("parseThenSerializeRule(':first-letter { }')", "'::first-letter { }'");
    133141shouldBe("parseThenSerializeRule(':first-line { }')", "'::first-line { }'");
     142shouldBe("parseThenSerializeRule(':-webkit-any(    a.class1  ,          #id,[attr]  ) { }')","':-webkit-any(a.class1,#id,[attr]) { }'");
    134143
    135144debug('');
  • trunk/LayoutTests/fast/css/css-set-selector-text-expected.txt

    r68388 r81742  
    5757PASS setThenReadSelectorText(':lang(a)') is ':lang(a)'
    5858PASS setThenReadSelectorText(':not(a)') is ':not(a)'
     59PASS setThenReadSelectorText(':-webkit-any(a,b,p)') is ':-webkit-any(a,b,p)'
    5960
    6061PASS setThenReadSelectorText('::after') is '::after'
     
    7677
    7778PASS setThenReadSelectorText('input:not([type="file"]):focus') is 'input:not([type="file"]):focus'
     79PASS setThenReadSelectorText(':-webkit-any([type="file"])') is ':-webkit-any([type="file"])'
     80PASS setThenReadSelectorText(':-webkit-any(:hover)') is ':-webkit-any(:hover)'
     81PASS setThenReadSelectorText('input:-webkit-any([type="file"],:hover,:focus):enabled') is 'input:-webkit-any([type="file"],:hover,:focus):enabled'
     82PASS setThenReadSelectorText(':-webkit-any(input[type="file"],a:hover,button:focus)') is ':-webkit-any(input[type="file"],a:hover,button:focus)'
     83PASS setThenReadSelectorText(':-webkit-any(.class1.class2.class3)') is ':-webkit-any(.class1.class2.class3)'
     84PASS setThenReadSelectorText(':-webkit-any(.class1:hover)') is ':-webkit-any(.class1:hover)'
     85PASS setThenReadSelectorText(':-webkit-any(a.class1.class2.class3:hover)') is ':-webkit-any(a.class1.class2.class3:hover)'
    7886
    7987PASS setThenReadSelectorText('*:active') is ':active'
     
    9098PASS setThenReadSelectorText(':first-letter') is '::first-letter'
    9199PASS setThenReadSelectorText(':first-line') is '::first-line'
     100PASS setThenReadSelectorText(':-webkit-any(    a.class1  ,      #id,[attr]  )') is ':-webkit-any(a.class1,#id,[attr])'
    92101
    93102PASS successfullyParsed is true
  • trunk/LayoutTests/fast/css/css-set-selector-text.html

    r68388 r81742  
    100100testSelectorRoundTrip(":lang(a)");
    101101testSelectorRoundTrip(":not(a)");
     102testSelectorRoundTrip(":-webkit-any(a,b,p)");
    102103
    103104debug('');
     
    127128
    128129testSelectorRoundTrip('input:not([type="file"]):focus');
     130testSelectorRoundTrip(':-webkit-any([type="file"])');
     131testSelectorRoundTrip(':-webkit-any(:hover)');
     132testSelectorRoundTrip('input:-webkit-any([type="file"],:hover,:focus):enabled');
     133testSelectorRoundTrip(':-webkit-any(input[type="file"],a:hover,button:focus)');
     134testSelectorRoundTrip(':-webkit-any(.class1.class2.class3)');
     135testSelectorRoundTrip(':-webkit-any(.class1:hover)');
     136testSelectorRoundTrip(':-webkit-any(a.class1.class2.class3:hover)');
    129137
    130138debug('');
     
    149157shouldBe("setThenReadSelectorText(':first-letter')", "'::first-letter'");
    150158shouldBe("setThenReadSelectorText(':first-line')", "'::first-line'");
     159shouldBe("setThenReadSelectorText(':-webkit-any(    a.class1  ,         #id,[attr]  )')","':-webkit-any(a.class1,#id,[attr])'");
    151160
    152161debug('');
  • trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector-expected.txt

    r48723 r81742  
    2828PASS: document.querySelectorAll('[|name=value]') did not throw
    2929PASS: document.body.webkitMatchesSelector('[|name=value]') did not throw
     30PASS: document.querySelector(':-webkit-any(bbb|pre)') throws: Error: NAMESPACE_ERR: DOM Exception 14
    3031PASS: document.querySelector('div [bbb|name=value]') throws: Error: NAMESPACE_ERR: DOM Exception 14
    3132PASS: document.querySelectorAll('div [bbb|name=value]') throws: Error: NAMESPACE_ERR: DOM Exception 14
  • trunk/LayoutTests/fast/dom/SelectorAPI/not-supported-namespace-in-selector.html

    r48723 r81742  
    6262        shouldNotThrow("document.body.webkitMatchesSelector('[|name=value]')");
    6363
     64        shouldThrow("document.querySelector(':-webkit-any(bbb|pre)')");
     65
    6466        shouldThrow("document.querySelector('div [bbb|name=value]')");
    6567        shouldThrow("document.querySelectorAll('div [bbb|name=value]')");
  • trunk/Source/WebCore/ChangeLog

    r81740 r81742  
     12011-03-17  Ojan Vafai  <ojan@chromium.org>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        webkit should implement -moz-any selector (as -webkit-any obviously)
     6        https://bugs.webkit.org/show_bug.cgi?id=38095
     7
     8        For now, match the Mozilla implementation with respect to specificity
     9        and only allowing simple selectors. Both of these are likely to change
     10        pending discussion on www-style@.
     11
     12        Tests: fast/css/pseudo-any.html
     13               fast/dom/SelectorAPI/unknown-pseudo.html
     14
     15        * css/CSSGrammar.y:
     16        Create simple_selector_list. This is exactly like selector_list
     17        except it only allows simple selectors and creates a new vector
     18        instead of a reusable one since there can be multiple in one rule.
     19        * css/CSSParser.cpp:
     20        (WebCore::CSSParser::~CSSParser):
     21        (WebCore::CSSParser::lex):
     22        (WebCore::CSSParser::createFloatingSelectorVector):
     23        (WebCore::CSSParser::sinkFloatingSelectorVector):
     24        * css/CSSParser.h:
     25        * css/CSSParserValues.cpp:
     26        (WebCore::CSSParserSelector::adoptSelectorVector):
     27        * css/CSSParserValues.h:
     28        * css/CSSSelector.cpp:
     29        (WebCore::CSSSelector::specificityForOneSelector):
     30        (WebCore::CSSSelector::pseudoId):
     31        (WebCore::nameToPseudoTypeMap):
     32        (WebCore::CSSSelector::extractPseudoType):
     33        (WebCore::CSSSelector::selectorText):
     34        (WebCore::CSSSelector::setSelectorList):
     35        (WebCore::CSSSelector::RareData::RareData):
     36        (WebCore::CSSSelector::RareData::~RareData):
     37        These need to be moved into the cpp file so that we can
     38        have an OwnPtr<CSSSelectorList> in CSSSelector::RareData.
     39        * css/CSSSelector.h:
     40        (WebCore::CSSSelector::selectorList):
     41        * css/CSSSelectorList.cpp:
     42        (WebCore::forEachTagSelector):
     43        * css/CSSStyleSelector.cpp:
     44        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
     45        (WebCore::collectFeaturesFromSelector):
     46        * css/tokenizer.flex:
     47
    1482011-03-22  John Bauman  <jbauman@chromium.org>
    249
  • trunk/Source/WebCore/css/CSSGrammar.y

    r80150 r81742  
    190190%token <string> URI
    191191%token <string> FUNCTION
     192%token <string> ANYFUNCTION
    192193%token <string> NOTFUNCTION
    193194
     
    248249%type <selector> selector
    249250%type <selectorList> selector_list
     251%type <selectorList> simple_selector_list
    250252%type <selector> selector_with_trailing_whitespace
    251253%type <selector> class
     
    919921        if ($$)
    920922            static_cast<CSSParser*>(parser)->updateSpecifiersWithElementName($1, starAtom, $$);
     923    }
     924  ;
     925
     926simple_selector_list:
     927    simple_selector %prec UNIMPORTANT_TOK {
     928        if ($1) {
     929            CSSParser* p = static_cast<CSSParser*>(parser);
     930            $$ = p->createFloatingSelectorVector();
     931            $$->shrink(0);
     932            $$->append(p->sinkFloatingSelector($1));
     933            p->updateLastSelectorLineAndPosition();
     934        } else
     935            $$ = 0
     936    }
     937    | simple_selector_list maybe_space ',' maybe_space simple_selector %prec UNIMPORTANT_TOK {
     938        if ($1 && $5) {
     939            CSSParser* p = static_cast<CSSParser*>(parser);
     940            $$ = $1;
     941            $$->append(p->sinkFloatingSelector($5));
     942            p->updateLastSelectorLineAndPosition();
     943        } else
     944            $$ = 0;
     945    }
     946    | simple_selector_list error {
     947        $$ = 0;
    921948    }
    922949  ;
     
    11021129        // FIXME: This call is needed to force selector to compute the pseudoType early enough.
    11031130        $$->pseudoType();
     1131    }
     1132    // use by :-webkit-any.
     1133    // FIXME: should we support generic selectors here or just simple_selectors?
     1134    // Use simple_selector_list for now to match -moz-any.
     1135    // See http://lists.w3.org/Archives/Public/www-style/2010Sep/0566.html for some
     1136    // related discussion with respect to :not.
     1137    | ':' ANYFUNCTION maybe_space simple_selector_list maybe_space ')' {
     1138        if ($4) {
     1139            CSSParser *p = static_cast<CSSParser*>(parser);
     1140            $$ = p->createFloatingSelector();
     1141            $$->setMatch(CSSSelector::PseudoClass);
     1142            $$->adoptSelectorVector(*p->sinkFloatingSelectorVector($4));
     1143            $2.lower();
     1144            $$->setValue($2);
     1145            CSSSelector::PseudoType type = $$->pseudoType();
     1146            if (type != CSSSelector::PseudoAny)
     1147                $$ = 0;
     1148        } else
     1149            $$ = 0;
    11041150    }
    11051151    // used by :nth-*(ax+b)
  • trunk/Source/WebCore/css/CSSParser.cpp

    r81684 r81742  
    175175
    176176    fastDeleteAllValues(m_floatingSelectors);
     177    deleteAllValues(m_floatingSelectorVectors);
    177178    deleteAllValues(m_floatingValueLists);
    178179    deleteAllValues(m_floatingFunctions);
     
    56925693    case UNICODERANGE:
    56935694    case FUNCTION:
     5695    case ANYFUNCTION:
    56945696    case NOTFUNCTION:
    56955697        yylval->string.characters = t;
     
    59035905    }
    59045906    return adoptPtr(selector);
     5907}
     5908
     5909Vector<OwnPtr<CSSParserSelector> >* CSSParser::createFloatingSelectorVector()
     5910{
     5911    Vector<OwnPtr<CSSParserSelector> >* selectorVector = new Vector<OwnPtr<CSSParserSelector> >;
     5912    m_floatingSelectorVectors.add(selectorVector);
     5913    return selectorVector;
     5914}
     5915
     5916Vector<OwnPtr<CSSParserSelector> >* CSSParser::sinkFloatingSelectorVector(Vector<OwnPtr<CSSParserSelector> >* selectorVector)
     5917{
     5918    if (selectorVector) {
     5919        ASSERT(m_floatingSelectorVectors.contains(selectorVector));
     5920        m_floatingSelectorVectors.remove(selectorVector);
     5921    }
     5922    return selectorVector;
    59055923}
    59065924
  • trunk/Source/WebCore/css/CSSParser.h

    r81684 r81742  
    186186        PassOwnPtr<CSSParserSelector> sinkFloatingSelector(CSSParserSelector*);
    187187
     188        Vector<OwnPtr<CSSParserSelector> >* createFloatingSelectorVector();
     189        Vector<OwnPtr<CSSParserSelector> >* sinkFloatingSelectorVector(Vector<OwnPtr<CSSParserSelector> >*);
     190
    188191        CSSParserValueList* createFloatingValueList();
    189192        CSSParserValueList* sinkFloatingValueList(CSSParserValueList*);
     
    319322        Vector<RefPtr<CSSRuleList> > m_parsedRuleLists;
    320323        HashSet<CSSParserSelector*> m_floatingSelectors;
     324        HashSet<Vector<OwnPtr<CSSParserSelector> >*> m_floatingSelectorVectors;
    321325        HashSet<CSSParserValueList*> m_floatingValueLists;
    322326        HashSet<CSSParserFunction*> m_floatingFunctions;
  • trunk/Source/WebCore/css/CSSParserValues.cpp

    r76648 r81742  
    2626#include "CSSQuirkPrimitiveValue.h"
    2727#include "CSSSelector.h"
     28#include "CSSSelectorList.h"
    2829
    2930namespace WebCore {
     
    9798}
    9899
     100void CSSParserSelector::adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector)
     101{
     102    CSSSelectorList* selectorList = fastNew<CSSSelectorList>();
     103    selectorList->adoptSelectorVector(selectorVector);
     104    m_selector->setSelectorList(adoptPtr(selectorList));
     105}
    99106}
    100107
  • trunk/Source/WebCore/css/CSSParserValues.h

    r76648 r81742  
    110110    void setRelation(CSSSelector::Relation value) { m_selector->m_relation = value; }
    111111    void setForPage() { m_selector->setForPage(); }
    112    
     112
     113    void adoptSelectorVector(Vector<OwnPtr<CSSParserSelector> >& selectorVector);
     114
    113115    CSSSelector::PseudoType pseudoType() const { return m_selector->pseudoType(); }
    114116    bool isUnknownPseudoElement() const { return m_selector->isUnknownPseudoElement(); }
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r77954 r81742  
    2828
    2929#include "CSSOMUtils.h"
     30#include "CSSSelectorList.h"
    3031#include "HTMLNames.h"
    3132#include <wtf/Assertions.h>
     
    7980    case Begin:
    8081    case End:
     82        // FIXME: PsuedoAny should base the specificity on the sub-selectors.
     83        // See http://lists.w3.org/Archives/Public/www-style/2010Sep/0530.html
    8184        if (pseudoType() == PseudoNot && simpleSelector())
    8285            s += simpleSelector()->specificityForOneSelector();
     
    212215    case PseudoLink:
    213216    case PseudoVisited:
     217    case PseudoAny:
    214218    case PseudoAnyLink:
    215219    case PseudoAutofill:
     
    266270    DEFINE_STATIC_LOCAL(AtomicString, active, ("active"));
    267271    DEFINE_STATIC_LOCAL(AtomicString, after, ("after"));
     272    DEFINE_STATIC_LOCAL(AtomicString, any, ("-webkit-any("));
    268273    DEFINE_STATIC_LOCAL(AtomicString, anyLink, ("-webkit-any-link"));
    269274    DEFINE_STATIC_LOCAL(AtomicString, autofill, ("-webkit-autofill"));
     
    365370        nameToPseudoType->set(after.impl(), CSSSelector::PseudoAfter);
    366371        nameToPseudoType->set(anyLink.impl(), CSSSelector::PseudoAnyLink);
     372        nameToPseudoType->set(any.impl(), CSSSelector::PseudoAny);
    367373        nameToPseudoType->set(autofill.impl(), CSSSelector::PseudoAutofill);
    368374        nameToPseudoType->set(before.impl(), CSSSelector::PseudoBefore);
     
    528534    case PseudoLink:
    529535    case PseudoVisited:
     536    case PseudoAny:
    530537    case PseudoAnyLink:
    531538    case PseudoAutofill:
     
    639646            str += ":";
    640647            str += cs->value();
    641             if (cs->pseudoType() == PseudoNot) {
     648
     649            switch (cs->pseudoType()) {
     650            case PseudoNot:
    642651                if (CSSSelector* subSel = cs->simpleSelector())
    643652                    str += subSel->selectorText();
    644653                str += ")";
    645             } else if (cs->pseudoType() == PseudoLang
    646                     || cs->pseudoType() == PseudoNthChild
    647                     || cs->pseudoType() == PseudoNthLastChild
    648                     || cs->pseudoType() == PseudoNthOfType
    649                     || cs->pseudoType() == PseudoNthLastOfType) {
     654                break;
     655            case PseudoLang:
     656            case PseudoNthChild:
     657            case PseudoNthLastChild:
     658            case PseudoNthOfType:
     659            case PseudoNthLastOfType:
    650660                str += cs->argument();
    651661                str += ")";
     662                break;
     663            case PseudoAny: {
     664                CSSSelector* firstSubSelector = cs->selectorList()->first();
     665                for (CSSSelector* subSelector = firstSubSelector; subSelector; subSelector = CSSSelectorList::next(subSelector)) {
     666                    if (subSelector != firstSubSelector)
     667                        str += ",";
     668                    str += subSelector->selectorText();
     669                }
     670                str += ")";
     671                break;
     672            }
     673            default:
     674                break;
    652675            }
    653676        } else if (cs->m_match == CSSSelector::PseudoElement) {
     
    743766    m_data.m_rareData->m_simpleSelector = value;
    744767}
     768   
     769void CSSSelector::setSelectorList(PassOwnPtr<CSSSelectorList> selectorList)
     770{
     771    createRareData();
     772    m_data.m_rareData->m_selectorList = selectorList;
     773}
    745774
    746775bool CSSSelector::parseNth()
     
    785814}
    786815
     816CSSSelector::RareData::RareData(PassRefPtr<AtomicStringImpl> value)
     817    : m_value(value.leakRef())
     818    , m_a(0)
     819    , m_b(0)
     820    , m_attribute(anyQName())
     821    , m_argument(nullAtom)
     822{
     823}
     824
     825CSSSelector::RareData::~RareData()
     826{
     827    if (m_value)
     828        m_value->deref();
     829}
     830   
    787831// a helper function for parsing nth-arguments
    788832bool CSSSelector::RareData::parseNth()
  • trunk/Source/WebCore/css/CSSSelector.h

    r80750 r81742  
    3030
    3131namespace WebCore {
     32    class CSSSelectorList;
    3233
    3334    // this class represents a selector for a StyleRule
     
    130131            PseudoLink,
    131132            PseudoVisited,
     133            PseudoAny,
    132134            PseudoAnyLink,
    133135            PseudoAutofill,
     
    249251        const AtomicString& argument() const { return m_hasRareData ? m_data.m_rareData->m_argument : nullAtom; }
    250252        CSSSelector* simpleSelector() const { return m_hasRareData ? m_data.m_rareData->m_simpleSelector.get() : 0; }
     253        CSSSelectorList* selectorList() const { return m_hasRareData ? m_data.m_rareData->m_selectorList.get() : 0; }
    251254       
    252255        void setTag(const QualifiedName& value) { m_tag = value; }
     
    255258        void setArgument(const AtomicString&);
    256259        void setSimpleSelector(PassOwnPtr<CSSSelector>);
     260        void setSelectorList(PassOwnPtr<CSSSelectorList>);
    257261       
    258262        bool parseNth();
     
    295299            WTF_MAKE_NONCOPYABLE(RareData); WTF_MAKE_FAST_ALLOCATED;
    296300        public:
    297             RareData(PassRefPtr<AtomicStringImpl> value)
    298                 : m_value(value.leakRef())
    299                 , m_a(0)
    300                 , m_b(0)
    301                 , m_attribute(anyQName())
    302                 , m_argument(nullAtom)
    303             {
    304             }
    305             ~RareData()
    306             {
    307                 if (m_value)
    308                     m_value->deref();
    309             }
     301            RareData(PassRefPtr<AtomicStringImpl> value);
     302            ~RareData();
    310303
    311304            bool parseNth();
     
    315308            int m_a; // Used for :nth-*
    316309            int m_b; // Used for :nth-*
    317             OwnPtr<CSSSelector> m_simpleSelector; // Used for :not.
     310            // Used for :not.
     311            // FIXME: m_selectorList instead to save memory.
     312            OwnPtr<CSSSelector> m_simpleSelector;
    318313            QualifiedName m_attribute; // used for attribute selector
    319314            AtomicString m_argument; // Used for :contains, :lang and :nth-*
     315            OwnPtr<CSSSelectorList> m_selectorList; // Used for :-webkit-any
    320316        };
    321317        void createRareData();
  • trunk/Source/WebCore/css/CSSSelectorList.cpp

    r80750 r81742  
    127127                return true;
    128128        }
     129        if (CSSSelectorList* selectorList = selector->selectorList()) {
     130            for (CSSSelector* subSelector = selectorList->first(); subSelector; subSelector = CSSSelectorList::next(subSelector)) {
     131                if (forEachTagSelector(functor, subSelector))
     132                    return true;
     133            }
     134        }
    129135    } while ((selector = selector->tagHistory()));
    130136
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r81684 r81742  
    28442844                    return true;
    28452845                break;
     2846            case CSSSelector::PseudoAny:
     2847                for (CSSSelector* selector = sel->selectorList()->first(); selector; selector = CSSSelectorList::next(selector)) {
     2848                    if (checkSelector(selector, e, selectorAttrs, dynamicPseudo, true, elementStyle, elementParentStyle) == SelectorMatches)
     2849                        return true;
     2850                }
     2851                break;
    28462852            case CSSSelector::PseudoAnyLink:
    28472853                if (e && e->isLink())
     
    33043310        features.usesLinkRules = true;
    33053311        break;
     3312    case CSSSelector::PseudoAny:
     3313        for (CSSSelector* subSelector = selector->selectorList()->first(); subSelector; subSelector = CSSSelectorList::next(subSelector))
     3314            collectFeaturesFromSelector(features, subSelector);
     3315        return;
    33063316    default:
    33073317        break;
  • trunk/Source/WebCore/css/tokenizer.flex

    r75039 r81742  
    107107{num}                   {yyTok = FLOATTOKEN; return yyTok;}
    108108
     109"-webkit-any("          {yyTok = ANYFUNCTION; return yyTok;}
    109110"not("                  {yyTok = NOTFUNCTION; return yyTok;}
    110111"url("{w}{string}{w}")" {yyTok = URI; return yyTok;}
Note: See TracChangeset for help on using the changeset viewer.