[webkit-changes] cvs commit: WebCore/layout-tests/fast/selectors 159.html 177a.html 177b.html

Maciej mjs at opensource.apple.com
Sat Jun 11 21:07:32 PDT 2005


mjs         05/06/11 21:07:31

  Modified:    .        ChangeLog
               khtml/css css_base.cpp css_base.h cssstyleselector.cpp
                        parser.y
  Added:       layout-tests/fast/selectors 159.html 177a.html 177b.html
  Log:
          Patch from Nicholas Shanks  <contact at nickshanks.com>, by me.
  
  	- Distinguish between pseudo-elements and pseudo-classes in CSS parsing.
  	http://bugzilla.opendarwin.org/show_bug.cgi?id=3375
  
  	Merge of svn log -v -r 399829 svn://anonsvn.kde.org/home/kde
  
          Test cases added: Added the following from CSS selector test suite,
  	unfortunately 159 and 117a do not show any difference with and without the
  	patch since layout tests do not dump selection style (yet).
  
          * layout-tests/fast/selectors/159.html: Added.
          * layout-tests/fast/selectors/177a.html: Added.
          * layout-tests/fast/selectors/177b.html: Added.
  
          * khtml/css/css_base.cpp:
          (CSSSelector::specificity):
          (CSSSelector::extractPseudoType):
          (CSSSelector::selectorText):
          * khtml/css/css_base.h:
          (DOM::CSSSelector::):
          (DOM::CSSSelector::pseudoType):
          * khtml/css/cssstyleselector.cpp:
          (khtml::CSSStyleSelector::checkSelector):
          (khtml::CSSStyleSelector::checkOneSelector):
          * khtml/css/parser.y:
  
  Revision  Changes    Path
  1.4260    +29 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4259
  retrieving revision 1.4260
  diff -u -r1.4259 -r1.4260
  --- ChangeLog	11 Jun 2005 09:50:58 -0000	1.4259
  +++ ChangeLog	12 Jun 2005 04:07:27 -0000	1.4260
  @@ -1,5 +1,34 @@
   2005-06-11  Maciej Stachowiak  <mjs at apple.com>
   
  +        Patch from Nicholas Shanks  <contact at nickshanks.com>, by me.
  +
  +	- Distinguish between pseudo-elements and pseudo-classes in CSS parsing.
  +	http://bugzilla.opendarwin.org/show_bug.cgi?id=3375
  +
  +	Merge of svn log -v -r 399829 svn://anonsvn.kde.org/home/kde
  +	
  +        Test cases added: Added the following from CSS selector test suite,
  +	unfortunately 159 and 117a do not show any difference with and without the
  +	patch since layout tests do not dump selection style (yet).
  +	
  +        * layout-tests/fast/selectors/159.html: Added.
  +        * layout-tests/fast/selectors/177a.html: Added.
  +        * layout-tests/fast/selectors/177b.html: Added.
  +
  +        * khtml/css/css_base.cpp:
  +        (CSSSelector::specificity):
  +        (CSSSelector::extractPseudoType):
  +        (CSSSelector::selectorText):
  +        * khtml/css/css_base.h:
  +        (DOM::CSSSelector::):
  +        (DOM::CSSSelector::pseudoType):
  +        * khtml/css/cssstyleselector.cpp:
  +        (khtml::CSSStyleSelector::checkSelector):
  +        (khtml::CSSStyleSelector::checkOneSelector):
  +        * khtml/css/parser.y:
  +
  +2005-06-11  Maciej Stachowiak  <mjs at apple.com>
  +
           Patch from Timothy Hatcher  <timothy at colloquy.info>, reviewed by me.
   
           Test cases added:
  
  
  
  1.15      +39 -14    WebCore/khtml/css/css_base.cpp
  
  Index: css_base.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_base.cpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- css_base.cpp	11 Jun 2005 05:31:16 -0000	1.14
  +++ css_base.cpp	12 Jun 2005 04:07:30 -0000	1.15
  @@ -118,7 +118,8 @@
       case Set:
       case List:
       case Hyphen:
  -    case Pseudo:
  +    case PseudoClass:
  +    case PseudoElement:
       case Contain:
       case Begin:
       case End:
  @@ -134,7 +135,7 @@
   
   void CSSSelector::extractPseudoType() const
   {
  -    if (match != Pseudo)
  +    if (match != PseudoClass && match != PseudoElement)
           return;
       
       static AtomicString active("active");
  @@ -157,27 +158,33 @@
       static AtomicString selection("selection");
       static AtomicString target("target");
       static AtomicString visited("visited");
  +    bool element = false;	// pseudo-element
  +    bool compat = false;	// single colon compatbility mode
       
       _pseudoType = PseudoOther;
       if (value == active)
           _pseudoType = PseudoActive;
  -    else if (value == after)
  +    else if (value == after) {
           _pseudoType = PseudoAfter;
  -    else if (value == anyLink)
  +        element = compat = true;
  +    } else if (value == anyLink)
           _pseudoType = PseudoAnyLink;
  -    else if (value == before)
  +    else if (value == before) {
           _pseudoType = PseudoBefore;
  -    else if (value == drag)
  +        element = compat = true;
  +    } else if (value == drag)
           _pseudoType = PseudoDrag;
       else if (value == empty)
           _pseudoType = PseudoEmpty;
       else if (value == firstChild)
           _pseudoType = PseudoFirstChild;
  -    else if (value == firstLetter)
  +    else if (value == firstLetter) {
           _pseudoType = PseudoFirstLetter;
  -    else if (value == firstLine)
  +        element = compat = true;
  +    } else if (value == firstLine) {
           _pseudoType = PseudoFirstLine;
  -    else if (value == focus)
  +        element = compat = true;
  +    } else if (value == focus)
           _pseudoType = PseudoFocus;
       else if (value == hover)
           _pseudoType = PseudoHover;
  @@ -193,13 +200,21 @@
           _pseudoType = PseudoOnlyChild;
       else if (value == root)
           _pseudoType = PseudoRoot;
  -    else if (value == selection)
  +    else if (value == selection) {
           _pseudoType = PseudoSelection;
  -    else if (value == target)
  +        element = true;
  +    } else if (value == target)
           _pseudoType = PseudoTarget;
       else if (value == visited)
           _pseudoType = PseudoVisited;
       
  +    if (match == PseudoClass && element)
  +        if (!compat) 
  +            _pseudoType = PseudoOther;
  +        else 
  +           match = PseudoElement;
  +    else if (match == PseudoElement && !element)
  +        _pseudoType = PseudoOther;
       value = nullAtom;
   }
   
  @@ -240,11 +255,16 @@
           str = ".";
           str += cs->value.string();
       }
  -    else if ( tag == anyLocalName && cs->match == CSSSelector::Pseudo )
  +    else if ( tag == anyLocalName && cs->match == CSSSelector::PseudoClass )
       {
           str = ":";
           str += cs->value.string();
       }
  +    else if ( tag == anyLocalName && cs->match == CSSSelector::PseudoElement )
  +    {
  +        str = "::";
  +        str += cs->value.string();
  +    }
       else
       {
           if ( tag == anyLocalName )
  @@ -261,11 +281,16 @@
               str += ".";
               str += cs->value.string();
           }
  -        else if ( cs->match == CSSSelector::Pseudo )
  +        else if ( cs->match == CSSSelector::PseudoClass )
           {
               str += ":";
               str += cs->value.string();
           }
  +        else if ( cs->match == CSSSelector::PseudoElement )
  +        {
  +            str += "::";
  +            str += cs->value.string();
  +        }
           // optional attribute
           if ( cs->attr ) {
               DOMString attrName = getAttrName( cs->attr );
  @@ -277,7 +302,7 @@
                   break;
               case CSSSelector::Set:
                   str += " "; /// ## correct?
  -                       break;
  +                break;
               case CSSSelector::List:
                   str += "~=";
                   break;
  
  
  
  1.12      +12 -11    WebCore/khtml/css/css_base.h
  
  Index: css_base.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_base.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- css_base.h	11 Jun 2005 05:31:16 -0000	1.11
  +++ css_base.h	12 Jun 2005 04:07:30 -0000	1.12
  @@ -113,12 +113,13 @@
   	{
   	    None = 0,
   	    Id,
  -            Class,
  +        Class,
   	    Exact,
   	    Set,
   	    List,
   	    Hyphen,
  -	    Pseudo,
  +	    PseudoClass,
  +	    PseudoElement,
   	    Contain,   // css3: E[foo*="bar"]
   	    Begin,     // css3: E[foo^="bar"]
   	    End        // css3: E[foo$="bar"]
  @@ -138,7 +139,7 @@
   	    PseudoNotParsed = 0,
   	    PseudoOther,
   	    PseudoEmpty,
  -	    PseudoFirstChild,
  +            PseudoFirstChild,
               PseudoLastChild,
               PseudoOnlyChild,
   	    PseudoFirstLine,
  @@ -160,11 +161,11 @@
   	};
   
   	inline PseudoType pseudoType() const
  -	    {
  -		if (_pseudoType == PseudoNotParsed)
  -		    extractPseudoType();
  -		return _pseudoType;
  -	    }
  +	{
  +            if (_pseudoType == PseudoNotParsed)
  +                extractPseudoType();
  +            return _pseudoType;
  +        }
   
   	mutable DOM::AtomicString value;
   	CSSSelector* tagHistory;
  @@ -173,9 +174,9 @@
   	Q_UINT32     attr;
   	Q_UINT32     tag;
   
  -        Relation relation     : 3;
  -	Match 	 match         : 4;
  -	unsigned int pseudoId : 3;
  +        Relation relation              : 3;
  +	mutable Match  match           : 4;
  +	unsigned int pseudoId          : 3;
   	mutable PseudoType _pseudoType : 5;
   
       private:
  
  
  
  1.187     +26 -21    WebCore/khtml/css/cssstyleselector.cpp
  
  Index: cssstyleselector.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
  retrieving revision 1.186
  retrieving revision 1.187
  diff -u -r1.186 -r1.187
  --- cssstyleselector.cpp	11 Jun 2005 05:31:16 -0000	1.186
  +++ cssstyleselector.cpp	12 Jun 2005 04:07:30 -0000	1.187
  @@ -980,7 +980,7 @@
       // so, we can't allow that to apply to every element on the page.  We assume the author intended
       // to apply the rules only to links.
       bool onlyHoverActive = (sel->tag == anyQName &&
  -                            (sel->match == CSSSelector::Pseudo &&
  +                            (sel->match == CSSSelector::PseudoClass &&
                                 (sel->pseudoType() == CSSSelector::PseudoHover ||
                                  sel->pseudoType() == CSSSelector::PseudoActive)));
       bool affectedByHover = style ? style->affectedByHoverRules() : false;
  @@ -1054,7 +1054,7 @@
          case CSSSelector::SubSelector:
   	{
               if (onlyHoverActive)
  -                onlyHoverActive = (sel->match == CSSSelector::Pseudo &&
  +                onlyHoverActive = (sel->match == CSSSelector::PseudoClass &&
                                      (sel->pseudoType() == CSSSelector::PseudoHover ||
                                       sel->pseudoType() == CSSSelector::PseudoActive));
               
  @@ -1215,16 +1215,19 @@
                   && str[selStr.length()] != '-') return false;
               break;
           }
  +        case CSSSelector::PseudoClass:
  +        case CSSSelector::PseudoElement:
           default:
               break;
           }
       }
  -    if(sel->match == CSSSelector::Pseudo)
  +    if(sel->match == CSSSelector::PseudoClass || sel->match == CSSSelector::PseudoElement)
       {
           // Pseudo elements. We need to check first child here. No dynamic pseudo
           // elements for the moment
   //	kdDebug() << "CSSOrderedRule::pseudo " << value << endl;
  -	switch (sel->pseudoType()) {
  +	    switch (sel->pseudoType()) {
  +	        // Pseudo classes:
               case CSSSelector::PseudoEmpty:
                   if (!e->firstChild())
                       return true;
  @@ -1267,18 +1270,6 @@
                   }
                   break;
               }
  -            case CSSSelector::PseudoFirstLine:
  -                if ( subject ) {
  -                    dynamicPseudo=RenderStyle::FIRST_LINE;
  -                    return true;
  -                }
  -                break;
  -            case CSSSelector::PseudoFirstLetter:
  -                if ( subject ) {
  -                    dynamicPseudo=RenderStyle::FIRST_LETTER;
  -                    return true;
  -                }
  -                break;
               case CSSSelector::PseudoTarget:
                   if (e == e->getDocument()->getCSSTarget())
                       return true;
  @@ -1361,6 +1352,24 @@
                   }
                   break;
               }
  +            case CSSSelector::PseudoLang:
  +                /* not supported for now */
  +            case CSSSelector::PseudoOther:
  +                break;
  +            
  +            // Pseudo-elements:
  +            case CSSSelector::PseudoFirstLine:
  +                if ( subject ) {
  +                    dynamicPseudo=RenderStyle::FIRST_LINE;
  +                    return true;
  +                }
  +                break;
  +            case CSSSelector::PseudoFirstLetter:
  +                if ( subject ) {
  +                    dynamicPseudo=RenderStyle::FIRST_LETTER;
  +                    return true;
  +                }
  +                break;
               case CSSSelector::PseudoSelection:
                   dynamicPseudo = RenderStyle::SELECTION;
                   return true;
  @@ -1374,12 +1383,8 @@
               case CSSSelector::PseudoNotParsed:
                   assert(false);
                   break;
  -            case CSSSelector::PseudoLang:
  -                /* not supported for now */
  -            case CSSSelector::PseudoOther:
  -                break;
           }
  -	return false;
  +	    return false;
       }
       // ### add the rest of the checks...
       return true;
  
  
  
  1.38      +4 -5      WebCore/khtml/css/parser.y
  
  Index: parser.y
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/parser.y,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- parser.y	11 Jun 2005 05:31:17 -0000	1.37
  +++ parser.y	12 Jun 2005 04:07:30 -0000	1.38
  @@ -817,7 +817,7 @@
   pseudo:
       ':' IDENT {
           $$ = new CSSSelector();
  -        $$->match = CSSSelector::Pseudo;
  +        $$->match = CSSSelector::PseudoClass;
           $2.lower();
           $$->value = atomicString($2);
           if ($$->value == "empty" || $$->value == "only-child" ||
  @@ -828,16 +828,15 @@
                   doc->setUsesSiblingRules(true);
           }
       }
  -    |
  -    ':' ':' IDENT {
  +    | ':' ':' IDENT {
           $$ = new CSSSelector();
  -        $$->match = CSSSelector::Pseudo;
  +        $$->match = CSSSelector::PseudoElement;
           $3.lower();
           $$->value = atomicString($3);
       }
       | ':' FUNCTION maybe_space simple_selector maybe_space ')' {
           $$ = new CSSSelector();
  -        $$->match = CSSSelector::Pseudo;
  +        $$->match = CSSSelector::PseudoClass;
           $$->simpleSelector = $4;
           $2.lower();
           $$->value = atomicString($2);
  
  
  
  1.1                  WebCore/layout-tests/fast/selectors/159.html
  
  Index: 159.html
  ===================================================================
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  <html>
   <head>
    <title>Syntax and parsing of new pseudo-elements</title>
    <style type="text/css">
    ::selection { background: lime; }
    :selection { background: red; }
  </style>
    <link rel="first" href="css3-modsel-1.html" title="Groups of selectors">
    <link rel="prev" href="css3-modsel-158.html" title="Syntax and parsing">
    <link rel="next" href="css3-modsel-160.html" title="Syntax and parsing of unknown psuedo-classes">
    <link rel="last" href="css3-modsel-d5e.html" title="NEGATED :indeterminate with :checked">
    <link rel="up" href="./index.html">
    <link rel="top" href="../../index.html">
   </head>
   <body onload="document.execCommand('SelectAll')">
   <p>Try selecting some text in this document. It should be have a green background.</p>
  </body>
  </html>
  
  
  1.1                  WebCore/layout-tests/fast/selectors/177a.html
  
  Index: 177a.html
  ===================================================================
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  <html>
   <head>
    <title>Parsing : vs ::</title>
    <style type="text/css">
   p:selection { color: yellow; background: red; }
  </style>
    <link rel="first" href="css3-modsel-1.html" title="Groups of selectors">
    <link rel="prev" href="css3-modsel-176.html" title="Combinations: classes and IDs">
    <link rel="next" href="css3-modsel-177b.html" title="Parsing : vs ::">
    <link rel="last" href="css3-modsel-d5e.html" title="NEGATED :indeterminate with :checked">
    <link rel="up" href="./index.html">
    <link rel="top" href="../../index.html">
   </head>
   <body onload="document.execCommand('SelectAll')">
    <p>When you select this text, it shouldn&#39;t go red.</p>
  </body>
  </html>
  
  
  1.1                  WebCore/layout-tests/fast/selectors/177b.html
  
  Index: 177b.html
  ===================================================================
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  <html>
   <head>
    <title>Parsing : vs ::</title>
    <style type="text/css">
   div { color: green; }
   p::first-child { color: yellow; background: red; }
  </style>
    <link rel="first" href="css3-modsel-1.html" title="Groups of selectors">
    <link rel="prev" href="css3-modsel-177a.html" title="Parsing : vs ::">
    <link rel="next" href="css3-modsel-178.html" title="Parsing: :not and pseudo-elements">
    <link rel="last" href="css3-modsel-d5e.html" title="NEGATED :indeterminate with :checked">
    <link rel="up" href="./index.html">
    <link rel="top" href="../../index.html">
   </head>
   <body>
   <div>
    <p>This line should be green.</p>
   </div>
  </body>
  </html>
  
  



More information about the webkit-changes mailing list