[webkit-changes] cvs commit: WebCore/layout-tests/fast/selectors 046-expected.txt 046.html

David hyatt at opensource.apple.com
Fri Jun 10 22:31:18 PDT 2005


hyatt       05/06/10 22:31:18

  Modified:    .        ChangeLog
               khtml/css css_base.cpp css_base.h cssstyleselector.cpp
                        parser.y
  Added:       layout-tests/fast/selectors 046-expected.txt 046.html
  Log:
  	Fix for bugzilla bug 3335, add support for the CSS3 indirect adjacent sibling selector.  Patch merge
  	from KHTML tree by Nick Shanks.
  
          Reviewed by hyatt
  
          Test cases added: fast/selectors/046.html
  
          * khtml/css/css_base.cpp:
          (CSSSelector::selectorText):
          * khtml/css/css_base.h:
          (DOM::CSSSelector::):
          * khtml/css/cssstyleselector.cpp:
          (khtml::CSSStyleSelector::checkSelector):
          * khtml/css/parser.y:
          * layout-tests/fast/selectors/046-expected.txt: Added.
          * layout-tests/fast/selectors/046.html: Added.
  
  Revision  Changes    Path
  1.4257    +19 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.4256
  retrieving revision 1.4257
  diff -u -r1.4256 -r1.4257
  --- ChangeLog	11 Jun 2005 05:01:12 -0000	1.4256
  +++ ChangeLog	11 Jun 2005 05:31:10 -0000	1.4257
  @@ -1,5 +1,24 @@
   2005-06-10  David Hyatt  <hyatt at apple.com>
   
  +	Fix for bugzilla bug 3335, add support for the CSS3 indirect adjacent sibling selector.  Patch merge
  +	from KHTML tree by Nick Shanks.
  +	
  +        Reviewed by hyatt
  +
  +        Test cases added: fast/selectors/046.html
  +
  +        * khtml/css/css_base.cpp:
  +        (CSSSelector::selectorText):
  +        * khtml/css/css_base.h:
  +        (DOM::CSSSelector::):
  +        * khtml/css/cssstyleselector.cpp:
  +        (khtml::CSSStyleSelector::checkSelector):
  +        * khtml/css/parser.y:
  +        * layout-tests/fast/selectors/046-expected.txt: Added.
  +        * layout-tests/fast/selectors/046.html: Added.
  +
  +2005-06-10  David Hyatt  <hyatt at apple.com>
  +
   	Fix for 3237, background image repeats when it shouldn't.  The Radar bug is 4005553.  Patch from
   	Nate Cook.
   	
  
  
  
  1.14      +3 -1      WebCore/khtml/css/css_base.cpp
  
  Index: css_base.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_base.cpp,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- css_base.cpp	19 Nov 2004 00:12:20 -0000	1.13
  +++ css_base.cpp	11 Jun 2005 05:31:16 -0000	1.14
  @@ -303,8 +303,10 @@
       }
       if ( cs->tagHistory ) {
           DOMString tagHistoryText = cs->tagHistory->selectorText();
  -        if ( cs->relation == Sibling )
  +		if ( cs->relation == DirectAdjacent )
               str = tagHistoryText + " + " + str;
  +        else if ( cs->relation == IndirectAdjacent )
  +            str = tagHistoryText + " ~ " + str;
           else if ( cs->relation == Child )
               str = tagHistoryText + " > " + str;
           else if ( cs->relation == SubSelector )
  
  
  
  1.11      +4 -3      WebCore/khtml/css/css_base.h
  
  Index: css_base.h
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/css_base.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- css_base.h	26 Apr 2005 18:46:04 -0000	1.10
  +++ css_base.h	11 Jun 2005 05:31:16 -0000	1.11
  @@ -128,8 +128,9 @@
   	{
   	    Descendant = 0,
   	    Child,
  -	    Sibling,
  -	    SubSelector
  +	    DirectAdjacent,
  +            IndirectAdjacent,
  +            SubSelector
   	};
   
   	enum PseudoType
  @@ -172,7 +173,7 @@
   	Q_UINT32     attr;
   	Q_UINT32     tag;
   
  -        Relation relation     : 2;
  +        Relation relation     : 3;
   	Match 	 match         : 4;
   	unsigned int pseudoId : 3;
   	mutable PseudoType _pseudoType : 5;
  
  
  
  1.186     +22 -7     WebCore/khtml/css/cssstyleselector.cpp
  
  Index: cssstyleselector.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/cssstyleselector.cpp,v
  retrieving revision 1.185
  retrieving revision 1.186
  diff -u -r1.185 -r1.186
  --- cssstyleselector.cpp	11 Jun 2005 01:58:01 -0000	1.185
  +++ cssstyleselector.cpp	11 Jun 2005 05:31:16 -0000	1.186
  @@ -1026,17 +1026,32 @@
               if (!checkOneSelector(sel, elem)) return false;
               break;
           }
  -        case CSSSelector::Sibling:
  +        case CSSSelector::DirectAdjacent:
           {
               n = n->previousSibling();
  -	    while( n && !n->isElementNode() )
  -		n = n->previousSibling();
  -            if( !n ) return false;
  -            ElementImpl *elem = static_cast<ElementImpl *>(n);
  -            if (!checkOneSelector(sel, elem)) return false;
  +            while (n && !n->isElementNode())
  +                n = n->previousSibling();
  +            if (!n) return false;
  +            ElementImpl *elem = static_cast<ElementImpl*>(n);
  +            if (!checkOneSelector(sel, elem))
  +                return false;
  +            break;
  +        }
  +        case CSSSelector::IndirectAdjacent:
  +        {
  +            // FIXME: This match needs to know how to backtrack and be non-deterministic.
  +            ElementImpl *elem = 0;
  +            do {
  +                n = n->previousSibling();
  +                while (n && !n->isElementNode())
  +                    n = n->previousSibling();
  +                if (!n)
  +                    return false;
  +                elem = static_cast<ElementImpl*>(n);
  +            } while (!checkOneSelector(sel, elem));
               break;
           }
  -        case CSSSelector::SubSelector:
  +       case CSSSelector::SubSelector:
   	{
               if (onlyHoverActive)
                   onlyHoverActive = (sel->match == CSSSelector::Pseudo &&
  
  
  
  1.37      +4 -2      WebCore/khtml/css/parser.y
  
  Index: parser.y
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/css/parser.y,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- parser.y	10 May 2005 18:42:02 -0000	1.36
  +++ parser.y	11 Jun 2005 05:31:17 -0000	1.37
  @@ -518,7 +518,8 @@
   ;
   
   combinator:
  -  '+' maybe_space { $$ = CSSSelector::Sibling; }
  +    '+' maybe_space { $$ = CSSSelector::DirectAdjacent; }
  +  | '~' maybe_space { $$ = CSSSelector::IndirectAdjacent; }
     | '>' maybe_space { $$ = CSSSelector::Child; }
     | /* empty */ { $$ = CSSSelector::Descendant; }
     ;
  @@ -602,7 +603,8 @@
                   if ( doc )
                       doc->setUsesDescendantRules(true);
               }
  -            else if ($2 == CSSSelector::Sibling) {
  +            else if ($2 == CSSSelector::DirectAdjacent ||
  +                     $2 == CSSSelector::IndirectAdjacent) {
                   CSSParser *p = static_cast<CSSParser *>(parser);
                   DOM::DocumentImpl *doc = p->document();
                   if (doc)
  
  
  
  1.1                  WebCore/layout-tests/fast/selectors/046-expected.txt
  
  Index: 046-expected.txt
  ===================================================================
  layer at (0,0) size 800x600
    RenderCanvas at (0,0) size 800x600
  layer at (0,0) size 800x186
    RenderBlock {HTML} at (0,0) size 800x186
      RenderBody {BODY} at (8,16) size 784x154
        RenderBlock {DIV} at (0,0) size 784x154
          RenderBlock {P} at (0,0) size 784x18
            RenderText {TEXT} at (0,0) size 221x18
              text run at (0,0) width 221: "This paragraph should be unstyled."
          RenderBlock {P} at (0,34) size 784x18 [bgcolor=#00FF00]
            RenderText {TEXT} at (0,0) size 285x18
              text run at (0,0) width 285: "But this one should have a green background"
          RenderBlock {P} at (0,68) size 784x18 [bgcolor=#00FF00]
            RenderText {TEXT} at (0,0) size 319x18
              text run at (0,0) width 319: "And this one should also have a green background"
          RenderBlock {ADDRESS} at (0,102) size 784x18
            RenderText {TEXT} at (0,0) size 431x18
              text run at (0,0) width 431: "This address is only here to fill some space between two paragraphs"
          RenderBlock {P} at (0,136) size 784x18 [bgcolor=#00FF00]
            RenderText {TEXT} at (0,0) size 304x18
              text run at (0,0) width 304: "This paragraph should have a green background"
  
  
  
  1.1                  WebCore/layout-tests/fast/selectors/046.html
  
  Index: 046.html
  ===================================================================
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
  <html>
   <head>
    <title>Indirect adjacent combinator</title>
    <style type="text/css">.red { background-color : red }
  div.stub > p ~ p { background-color : lime }</style>
    <link rel="first" href="css3-modsel-1.html" title="Groups of selectors">
    <link rel="prev" href="css3-modsel-45c.html" title="Direct adjacent combinator and classes">
    <link rel="next" href="css3-modsel-46b.html" title="Indirect adjacent combinator">
    <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 class="stub">
    <p>This paragraph should be unstyled.</p>
    <p class="red">But this one should have a green background</p>
    <p class="red">And this one should also have a green background</p>
    <address>This address is only here to fill some space between two paragraphs</address>
   <p class="red">This paragraph should have a green background</p>
   </div>
  </body>
  </html>
  
  



More information about the webkit-changes mailing list