[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:29:30 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit ea2c6262178785ca632d13e640ef149de34925ca
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Mar 13 20:25:01 2003 +0000

    	Fix for 3193407, crash in CSS parser on www.hixie.ch.  Improved the grammar to
    	understand the CSS3 :not selector so that it wouldn't think of that case as an
    	error.  Also patched the error handling case that crashed on :not anyway.  Then
    	I went ahead and implemented :not (since it was trivial to add once the parser
    	was reading it in).
    
            Also fixed the regression that the * selector didn't work.  The new KHTML trunk moved
            away from a tag value of -1 in order to do @namespace support.  Since we aren't really ready
            to take that code yet, I patched our parser.y to treat * like -1 instead of 0xffff.
    
            Implemented support for a couple of new CSS3 selectors, :root and ::selection.  Also :last-child and :only-child.
    
            Fixed a trivial bug (demonstrated in the CSS3 test suite) with the matching of the ~= selector.
    
            Reviewed by darin
    
            * khtml/css/Makefile.am:
            * khtml/css/css_base.cpp:
            (CSSSelector::extractPseudoType):
            * khtml/css/css_base.h:
            * khtml/css/cssstyleselector.cpp:
            * khtml/css/parser.cpp:
            * khtml/css/parser.y:
            * khtml/rendering/render_style.h:
            * khtml/rendering/render_text.cpp:
            (TextRun::paintSelection):
            (RenderText::paintObject):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3821 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 1e82275..c0e7f2c 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,33 @@
+2003-03-13  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3193407, crash in CSS parser on www.hixie.ch.  Improved the grammar to
+	understand the CSS3 :not selector so that it wouldn't think of that case as an
+	error.  Also patched the error handling case that crashed on :not anyway.  Then
+	I went ahead and implemented :not (since it was trivial to add once the parser
+	was reading it in).
+	
+        Also fixed the regression that the * selector didn't work.  The new KHTML trunk moved
+        away from a tag value of -1 in order to do @namespace support.  Since we aren't really ready
+        to take that code yet, I patched our parser.y to treat * like -1 instead of 0xffff.
+        
+        Implemented support for a couple of new CSS3 selectors, :root and ::selection.  Also :last-child and :only-child.
+        
+        Fixed a trivial bug (demonstrated in the CSS3 test suite) with the matching of the ~= selector.
+ 
+        Reviewed by darin
+
+        * khtml/css/Makefile.am:
+        * khtml/css/css_base.cpp:
+        (CSSSelector::extractPseudoType):
+        * khtml/css/css_base.h:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/parser.cpp:
+        * khtml/css/parser.y:
+        * khtml/rendering/render_style.h:
+        * khtml/rendering/render_text.cpp:
+        (TextRun::paintSelection):
+        (RenderText::paintObject):
+
 === Safari-67 ===
 
 2003-03-13  Darin Adler  <darin at apple.com>
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 1e82275..c0e7f2c 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,33 @@
+2003-03-13  David Hyatt  <hyatt at apple.com>
+
+	Fix for 3193407, crash in CSS parser on www.hixie.ch.  Improved the grammar to
+	understand the CSS3 :not selector so that it wouldn't think of that case as an
+	error.  Also patched the error handling case that crashed on :not anyway.  Then
+	I went ahead and implemented :not (since it was trivial to add once the parser
+	was reading it in).
+	
+        Also fixed the regression that the * selector didn't work.  The new KHTML trunk moved
+        away from a tag value of -1 in order to do @namespace support.  Since we aren't really ready
+        to take that code yet, I patched our parser.y to treat * like -1 instead of 0xffff.
+        
+        Implemented support for a couple of new CSS3 selectors, :root and ::selection.  Also :last-child and :only-child.
+        
+        Fixed a trivial bug (demonstrated in the CSS3 test suite) with the matching of the ~= selector.
+ 
+        Reviewed by darin
+
+        * khtml/css/Makefile.am:
+        * khtml/css/css_base.cpp:
+        (CSSSelector::extractPseudoType):
+        * khtml/css/css_base.h:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/parser.cpp:
+        * khtml/css/parser.y:
+        * khtml/rendering/render_style.h:
+        * khtml/rendering/render_text.cpp:
+        (TextRun::paintSelection):
+        (RenderText::paintObject):
+
 === Safari-67 ===
 
 2003-03-13  Darin Adler  <darin at apple.com>
diff --git a/WebCore/khtml/css/Makefile.am b/WebCore/khtml/css/Makefile.am
index 4cc2560..83e76f4 100644
--- a/WebCore/khtml/css/Makefile.am
+++ b/WebCore/khtml/css/Makefile.am
@@ -6,7 +6,7 @@ EXTRA_DIST = parser.y
 
 parser.cpp: $(srcdir)/parser.y
 	cd $(srcdir); \
-	$(YACC) -d -p cssyy parser.y && mv parser.tab.c $<; \
+	$(YACC) -d -p cssyy parser.y && mv parser.tab.c parser.cpp; \
 	if test -f parser.tab.h; then \
 	if cmp -s parser.tab.h parser.h; then rm -f parser.tab.h; \
 	else mv parser.tab.h parser.h; fi \
diff --git a/WebCore/khtml/css/css_base.cpp b/WebCore/khtml/css/css_base.cpp
index 2540a90..895e252 100644
--- a/WebCore/khtml/css/css_base.cpp
+++ b/WebCore/khtml/css/css_base.cpp
@@ -197,6 +197,26 @@ void CSSSelector::extractPseudoType() const
             case 'l':
                 if (value == "link")
                     _pseudoType = PseudoLink;
+                else if (value == "lang(")
+                    _pseudoType = PseudoLang;
+                else if (value == "last-child")
+                    _pseudoType = PseudoLastChild;
+                break;
+            case 'n':
+                if (value == "not(")
+                    _pseudoType = PseudoNot;
+                break;
+            case 'o':
+                if (value == "only-child")
+                    _pseudoType = PseudoOnlyChild;
+                break;
+            case 'r':
+                if (value == "root")
+                    _pseudoType = PseudoRoot;
+                break;
+            case 's':
+                if (value == "selection")
+                    _pseudoType = PseudoSelection;
                 break;
             case 't':
                 if (value == "target")
diff --git a/WebCore/khtml/css/css_base.h b/WebCore/khtml/css/css_base.h
index c95ed1a..a50fcb5 100644
--- a/WebCore/khtml/css/css_base.h
+++ b/WebCore/khtml/css/css_base.h
@@ -51,11 +51,13 @@ namespace DOM {
     {
     public:
 	CSSSelector()
-	    : tagHistory(0), attr(0), tag(-1), relation( Descendant ),
-	      match( None ), nonCSSHint( false ), pseudoId( 0 ), _pseudoType(PseudoNotParsed) {}
+	    : tagHistory(0), simpleSelector(0), attr(0), tag(-1), relation( Descendant ),
+	      match( None ), nonCSSHint( false ), pseudoId( 0 ), _pseudoType(PseudoNotParsed)
+        {}
 
 	~CSSSelector() {
 	    delete tagHistory;
+            delete simpleSelector;
 	}
 
 	/**
@@ -104,6 +106,8 @@ namespace DOM {
 	    PseudoOther,
 	    PseudoEmpty,
 	    PseudoFirstChild,
+            PseudoLastChild,
+            PseudoOnlyChild,
 	    PseudoFirstLine,
 	    PseudoFirstLetter,
 	    PseudoLink,
@@ -114,7 +118,10 @@ namespace DOM {
             PseudoTarget,
 	    PseudoBefore,
 	    PseudoAfter,
-	    PseudoFunction
+            PseudoLang,
+            PseudoNot,
+            PseudoRoot,
+            PseudoSelection
 	};
 
 	inline PseudoType pseudoType() const
@@ -126,6 +133,7 @@ namespace DOM {
 
 	mutable DOM::DOMString value;
 	CSSSelector *tagHistory;
+        CSSSelector* simpleSelector; // Used for :not.
 	int          attr;
 	int          tag;
 
@@ -133,7 +141,7 @@ namespace DOM {
 	Match 	 match         : 4;
 	bool	nonCSSHint : 1;
 	unsigned int pseudoId : 3;
-	mutable PseudoType _pseudoType : 4;
+	mutable PseudoType _pseudoType : 5;
 
     private:
 	void extractPseudoType() const;
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 9ef494e..f6a9ca4 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -777,6 +777,12 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
                     return false;
                 break;
             }
+
+            // The selector's value can't contain a space, or it's totally bogus.
+            spacePos = sel->value.find(' ');
+            if (spacePos != -1)
+                return false;
+            
             QString str = value.string();
             QString selStr = sel->value.string();
             int pos = str.find(selStr, 0, strictParsing);
@@ -847,11 +853,40 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
                 break;
             case CSSSelector::PseudoFirstChild: {
                 // first-child matches the first child that is an element!
-                DOM::NodeImpl *n = e->parentNode()->firstChild();
-                while ( n && !n->isElementNode() )
-                    n = n->nextSibling();
-                if ( n == e )
-                    return true;
+                if (e->parentNode()) {
+                    DOM::NodeImpl* n = e->previousSibling();
+                    while ( n && !n->isElementNode() )
+                        n = n->previousSibling();
+                    if ( !n )
+                        return true;
+                }
+                break;
+            }
+            case CSSSelector::PseudoLastChild: {
+                // last-child matches the last child that is an element!
+                if (e->parentNode()) {
+                    DOM::NodeImpl* n = e->nextSibling();
+                    while ( n && !n->isElementNode() )
+                        n = n->nextSibling();
+                    if ( !n )
+                        return true;
+                }
+                break;
+            }
+            case CSSSelector::PseudoOnlyChild: {
+                // If both first-child and last-child apply, then only-child applies.
+                if (e->parentNode()) {
+                    DOM::NodeImpl* n = e->previousSibling();
+                    while ( n && !n->isElementNode() )
+                        n = n->previousSibling();
+                    if ( !n ) {
+                        n = e->nextSibling();
+                        while ( n && !n->isElementNode() )
+                            n = n->nextSibling();
+                        if ( !n )
+                            return true;
+                    }
+                }
                 break;
             }
             case CSSSelector::PseudoFirstLine:
@@ -914,16 +949,37 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
                         return true;
                 }
                 break;
+            case CSSSelector::PseudoRoot:
+                if (e == e->getDocument()->documentElement())
+                    return true;
+                break;
+            case CSSSelector::PseudoNot: {
+                // check the simple selector
+                for (CSSSelector* subSel = sel->simpleSelector; subSel;
+                     subSel = subSel->tagHistory) {
+                    // :not cannot nest.  I don't really know why this is a restriction in CSS3,
+                    // but it is, so let's honor it.
+                    if (subSel->simpleSelector)
+                        break;
+                    if (!checkOneSelector(subSel, e))
+                        return true;
+                }
+                break;
+            }
+            case CSSSelector::PseudoSelection:
+                dynamicPseudo = RenderStyle::SELECTION;
+                return true;
             case CSSSelector::PseudoBefore:
                 dynamicPseudo = RenderStyle::BEFORE;
                 return true;
             case CSSSelector::PseudoAfter:
                 dynamicPseudo = RenderStyle::AFTER;
                 return true;
+                
             case CSSSelector::PseudoNotParsed:
                 assert(false);
                 break;
-            case CSSSelector::PseudoFunction:
+            case CSSSelector::PseudoLang:
                 /* not supported for now */
             case CSSSelector::PseudoOther:
                 break;
diff --git a/WebCore/khtml/css/parser.cpp b/WebCore/khtml/css/parser.cpp
index e854aee..84c641e 100644
--- a/WebCore/khtml/css/parser.cpp
+++ b/WebCore/khtml/css/parser.cpp
@@ -176,7 +176,7 @@ static int cssyylex( YYSTYPE *yylval ) {
 
 
 
-#define	YYFINAL		259
+#define	YYFINAL		261
 #define	YYFLAG		-32768
 #define	YYNTBASE	60
 
@@ -225,12 +225,13 @@ static const short yyprhs[] = {     0,
    157,   163,   165,   170,   173,   175,   179,   182,   185,   189,
    192,   194,   196,   198,   201,   204,   206,   208,   210,   212,
    215,   218,   223,   232,   234,   236,   238,   240,   242,   244,
-   246,   248,   251,   258,   260,   263,   265,   269,   271,   275,
-   279,   285,   290,   295,   302,   308,   311,   314,   315,   317,
-   321,   324,   327,   330,   331,   333,   336,   339,   342,   345,
-   348,   350,   352,   355,   358,   361,   364,   367,   370,   373,
-   376,   379,   382,   385,   388,   391,   394,   397,   400,   403,
-   406,   409,   415,   418,   422,   426,   429,   435,   439,   441
+   246,   248,   251,   255,   262,   264,   267,   269,   273,   275,
+   279,   283,   289,   294,   299,   306,   312,   315,   318,   319,
+   321,   325,   328,   331,   334,   335,   337,   340,   343,   346,
+   349,   352,   354,   356,   359,   362,   365,   368,   371,   374,
+   377,   380,   383,   386,   389,   392,   395,   398,   401,   404,
+   407,   410,   413,   419,   422,   426,   430,   433,   439,   443,
+   445
 };
 
 static const short yyrhs[] = {    66,
@@ -259,26 +260,26 @@ static const short yyrhs[] = {    66,
     55,     0,    15,    64,    89,    91,    64,    92,    64,    55,
      0,    56,     0,     5,     0,     6,     0,     7,     0,     8,
      0,     9,     0,    11,     0,    10,     0,    13,    11,     0,
-    13,    45,    64,    11,    64,    57,     0,    96,     0,    95,
-    96,     0,    95,     0,     1,   108,     1,     0,     1,     0,
-    96,    49,    64,     0,     1,    49,    64,     0,     1,   108,
-     1,    49,    64,     0,    95,    96,    49,    64,     0,    95,
-     1,    49,    64,     0,    95,     1,   108,     1,    49,    64,
-     0,    97,    13,    64,    99,    98,     0,    11,    64,     0,
-    24,    64,     0,     0,   101,     0,    99,   100,   101,     0,
-    99,     1,     0,    58,    64,     0,    50,    64,     0,     0,
-   102,     0,    80,   102,     0,    10,    64,     0,    11,    64,
-     0,    44,    64,     0,    46,    64,     0,   104,     0,   103,
-     0,    43,    64,     0,    42,    64,     0,    28,    64,     0,
-    29,    64,     0,    30,    64,     0,    31,    64,     0,    32,
-    64,     0,    33,    64,     0,    34,    64,     0,    35,    64,
-     0,    36,    64,     0,    37,    64,     0,    38,    64,     0,
-    39,    64,     0,    40,    64,     0,    26,    64,     0,    25,
-    64,     0,    27,    64,     0,    41,    64,     0,    45,    64,
-    99,    57,    64,     0,    12,    64,     0,    59,     1,   107,
-     0,    59,     1,    49,     0,     1,   107,     0,    47,     1,
-   108,     1,    48,     0,    47,     1,    48,     0,   107,     0,
-   108,     1,   107,     0
+    13,    13,    11,     0,    13,    45,    64,    84,    64,    57,
+     0,    96,     0,    95,    96,     0,    95,     0,     1,   108,
+     1,     0,     1,     0,    96,    49,    64,     0,     1,    49,
+    64,     0,     1,   108,     1,    49,    64,     0,    95,    96,
+    49,    64,     0,    95,     1,    49,    64,     0,    95,     1,
+   108,     1,    49,    64,     0,    97,    13,    64,    99,    98,
+     0,    11,    64,     0,    24,    64,     0,     0,   101,     0,
+    99,   100,   101,     0,    99,     1,     0,    58,    64,     0,
+    50,    64,     0,     0,   102,     0,    80,   102,     0,    10,
+    64,     0,    11,    64,     0,    44,    64,     0,    46,    64,
+     0,   104,     0,   103,     0,    43,    64,     0,    42,    64,
+     0,    28,    64,     0,    29,    64,     0,    30,    64,     0,
+    31,    64,     0,    32,    64,     0,    33,    64,     0,    34,
+    64,     0,    35,    64,     0,    36,    64,     0,    37,    64,
+     0,    38,    64,     0,    39,    64,     0,    40,    64,     0,
+    26,    64,     0,    25,    64,     0,    27,    64,     0,    41,
+    64,     0,    45,    64,    99,    57,    64,     0,    12,    64,
+     0,    59,     1,   107,     0,    59,     1,    49,     0,     1,
+   107,     0,    47,     1,   108,     1,    48,     0,    47,     1,
+    48,     0,   107,     0,   108,     1,   107,     0
 };
 
 #endif
@@ -291,14 +292,15 @@ static const short yyrline[] = { 0,
    349,   352,   356,   360,   364,   368,   372,   378,   392,   394,
    403,   425,   429,   434,   438,   443,   445,   446,   449,   451,
    454,   474,   488,   502,   508,   512,   531,   537,   542,   547,
-   554,   575,   580,   585,   593,   599,   606,   607,   608,   611,
-   620,   644,   650,   658,   662,   665,   668,   671,   674,   679,
-   681,   684,   690,   698,   702,   707,   710,   716,   724,   728,
-   734,   740,   745,   751,   759,   784,   791,   793,   796,   801,
-   814,   820,   824,   827,   832,   834,   835,   836,   842,   843,
-   844,   846,   851,   853,   854,   855,   856,   857,   858,   859,
-   860,   861,   862,   863,   864,   865,   866,   867,   868,   869,
-   870,   874,   889,   896,   903,   911,   937,   939,   942,   944
+   554,   575,   580,   585,   595,   601,   608,   609,   610,   613,
+   622,   646,   652,   660,   664,   667,   670,   673,   676,   681,
+   683,   686,   692,   698,   706,   710,   715,   718,   724,   732,
+   736,   742,   748,   753,   759,   767,   792,   799,   801,   804,
+   809,   822,   828,   832,   835,   840,   842,   843,   844,   850,
+   851,   852,   854,   859,   861,   862,   863,   864,   865,   866,
+   867,   868,   869,   870,   871,   872,   873,   874,   875,   876,
+   877,   878,   882,   897,   904,   911,   919,   945,   947,   950,
+   952
 };
 #endif
 
@@ -332,12 +334,13 @@ static const short yyr1[] = {     0,
     81,    82,    82,    82,    83,    83,    83,    84,    84,    84,
     85,    85,    86,    86,    86,    87,    87,    87,    87,    88,
     89,    90,    90,    91,    91,    91,    91,    91,    91,    92,
-    92,    93,    93,    94,    94,    94,    94,    94,    95,    95,
-    95,    95,    95,    95,    96,    97,    98,    98,    99,    99,
-    99,   100,   100,   100,   101,   101,   101,   101,   101,   101,
-   101,   101,   102,   102,   102,   102,   102,   102,   102,   102,
+    92,    93,    93,    93,    94,    94,    94,    94,    94,    95,
+    95,    95,    95,    95,    95,    96,    97,    98,    98,    99,
+    99,    99,   100,   100,   100,   101,   101,   101,   101,   101,
+   101,   101,   101,   102,   102,   102,   102,   102,   102,   102,
    102,   102,   102,   102,   102,   102,   102,   102,   102,   102,
-   102,   103,   104,   105,   105,   106,   107,   107,   108,   108
+   102,   102,   103,   104,   105,   105,   106,   107,   107,   108,
+   108
 };
 
 static const short yyr2[] = {     0,
@@ -349,12 +352,13 @@ static const short yyr2[] = {     0,
      5,     1,     4,     2,     1,     3,     2,     2,     3,     2,
      1,     1,     1,     2,     2,     1,     1,     1,     1,     2,
      2,     4,     8,     1,     1,     1,     1,     1,     1,     1,
-     1,     2,     6,     1,     2,     1,     3,     1,     3,     3,
-     5,     4,     4,     6,     5,     2,     2,     0,     1,     3,
-     2,     2,     2,     0,     1,     2,     2,     2,     2,     2,
-     1,     1,     2,     2,     2,     2,     2,     2,     2,     2,
+     1,     2,     3,     6,     1,     2,     1,     3,     1,     3,
+     3,     5,     4,     4,     6,     5,     2,     2,     0,     1,
+     3,     2,     2,     2,     0,     1,     2,     2,     2,     2,
+     2,     1,     1,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     5,     2,     3,     3,     2,     5,     3,     1,     3
+     2,     2,     5,     2,     3,     3,     2,     5,     3,     1,
+     3
 };
 
 static const short yydefact[] = {    13,
@@ -362,189 +366,191 @@ static const short yydefact[] = {    13,
      8,     8,     8,     2,     3,     4,    17,     0,    16,    15,
      9,     8,     0,     0,     0,    12,    11,    19,     0,     0,
     61,    66,     0,     0,     8,    62,     8,     0,     0,    55,
-     8,     0,    63,    67,    68,    69,    88,     8,     0,     0,
-    84,     0,     8,     8,     8,     8,     8,     8,     8,     8,
+     8,     0,    63,    67,    68,    69,    89,     8,     0,     0,
+    85,     0,     8,     8,     8,     8,     8,     8,     8,     8,
      8,     8,     8,     8,     8,     8,     8,     8,     8,     8,
      8,     8,     8,     8,     8,     8,     8,    50,    49,     0,
-     0,    99,   105,   112,   111,     0,     0,    10,   138,   139,
-     0,    14,    82,     8,    70,     0,     0,    54,     8,     8,
-    57,     8,     8,     0,    58,     0,    65,    60,    64,     8,
-     0,    96,     6,     0,    85,     8,     8,   107,   108,   133,
-   129,   128,   130,   115,   116,   117,   118,   119,   120,   121,
-   122,   123,   124,   125,   126,   127,   131,   114,   113,   109,
-     0,   110,   106,   101,     7,     8,     8,     0,     0,     0,
-     0,     0,     8,     0,     0,    10,    22,    23,    24,    21,
-    26,    25,    18,     0,     0,     8,     0,     5,     0,     0,
-    46,    47,    56,    59,    90,    87,     8,     0,     8,    89,
-     0,     0,   103,   102,   100,    29,    28,    30,    31,     8,
-   136,     0,    34,     0,     0,    20,   137,   140,     8,    71,
-    75,    76,    77,    78,    79,    72,    74,     8,     0,     0,
-     8,    93,     0,    92,     0,     8,    34,    43,    42,     8,
-     0,    35,    45,    44,   135,   134,     0,     0,    51,    91,
-     8,     8,    95,   132,     0,     0,    41,    37,     8,     8,
-    83,    81,    80,     8,    94,    97,    27,    39,     0,     0,
-     0,    36,    73,    38,     8,    40,     0,     0,     0
+     0,   100,   106,   113,   112,     0,     0,    10,   139,   140,
+     0,    14,    82,     0,     8,    70,     0,     0,    54,     8,
+     8,    57,     8,     8,     0,    58,     0,    65,    60,    64,
+     8,     0,    97,     6,     0,    86,     8,     8,   108,   109,
+   134,   130,   129,   131,   116,   117,   118,   119,   120,   121,
+   122,   123,   124,   125,   126,   127,   128,   132,   115,   114,
+   110,     0,   111,   107,   102,     7,     8,     8,     0,     0,
+     0,     0,     0,     8,     0,     0,    10,    22,    23,    24,
+    21,    26,    25,    18,     0,    83,     0,     8,     0,     5,
+     0,     0,    46,    47,    56,    59,    91,    88,     8,     0,
+     8,    90,     0,     0,   104,   103,   101,    29,    28,    30,
+    31,     8,   137,     0,    34,     0,     0,    20,   138,   141,
+     8,    71,    75,    76,    77,    78,    79,    72,    74,     8,
+     0,     0,     8,    94,     0,    93,     0,     8,    34,    43,
+    42,     8,     0,    35,    45,    44,   136,   135,     0,     0,
+    51,    92,     8,     8,    96,   133,     0,     0,    41,    37,
+     8,     8,    84,    81,    80,     8,    95,    98,    27,    39,
+     0,     0,     0,    36,    73,    38,     8,    40,     0,     0,
+     0
 };
 
-static const short yydefgoto[] = {   257,
-     5,     6,     7,    10,    17,     8,    28,    87,   156,    88,
-   190,   235,   221,   157,   251,   222,   158,   159,   104,    80,
-    37,    38,    39,    40,    41,    42,    43,    44,   167,    45,
-   208,   244,    46,    49,    50,    51,    52,   233,    81,   148,
-    82,    83,    84,    85,   161,   162,    90,    91
+static const short yydefgoto[] = {   259,
+     5,     6,     7,    10,    17,     8,    28,    87,   157,    88,
+   192,   237,   223,   158,   253,   224,   159,   160,   105,    80,
+    37,    38,    39,    40,    41,    42,    43,    44,   169,    45,
+   210,   246,    46,    49,    50,    51,    52,   235,    81,   149,
+    82,    83,    84,    85,   162,   163,    90,    91
 };
 
-static const short yypact[] = {   143,
-    12,    -7,    59,    63,-32768,-32768,-32768,-32768,    -8,    28,
--32768,-32768,-32768,   110,   110,   110,   134,   154,-32768,-32768,
--32768,-32768,    73,    13,   432,-32768,-32768,   112,    -3,    44,
--32768,-32768,    85,   129,-32768,-32768,-32768,    32,   380,-32768,
-   111,   166,-32768,-32768,-32768,-32768,    60,-32768,   136,    91,
-   142,   147,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+static const short yypact[] = {   118,
+    17,   -21,    -3,    39,-32768,-32768,-32768,-32768,    58,    98,
+-32768,-32768,-32768,    94,    94,    94,   162,   144,-32768,-32768,
+-32768,-32768,   121,    13,   434,-32768,-32768,   135,   130,    31,
+-32768,-32768,     2,   108,-32768,-32768,-32768,    32,   382,-32768,
+   185,   168,-32768,-32768,-32768,-32768,    62,-32768,   113,    99,
+   124,   172,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   377,
-   281,-32768,-32768,-32768,-32768,   146,   103,-32768,-32768,-32768,
-   191,-32768,-32768,-32768,-32768,    17,    96,-32768,-32768,-32768,
--32768,-32768,-32768,   184,   110,   166,-32768,   110,-32768,-32768,
-   200,   110,-32768,    82,   155,-32768,-32768,   110,   110,   110,
-   110,   110,   110,   110,   110,   110,   110,   110,   110,   110,
-   110,   110,   110,   110,   110,   110,   110,   110,   110,   110,
-   432,   110,-32768,-32768,-32768,-32768,-32768,   469,   124,     2,
-   158,   208,-32768,   222,   224,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,   134,   128,    18,-32768,   127,-32768,    13,    73,
-   110,   110,-32768,   110,   110,   153,-32768,   227,-32768,   110,
-   432,   332,   110,   110,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,   161,    24,   165,   172,   134,-32768,-32768,-32768,   110,
--32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   181,   386,
--32768,   110,   175,   110,   230,-32768,    97,-32768,-32768,-32768,
-    33,-32768,-32768,-32768,-32768,-32768,    16,    15,-32768,   110,
--32768,-32768,-32768,   110,   183,    41,   110,-32768,-32768,-32768,
--32768,-32768,-32768,-32768,   110,   110,-32768,   110,    24,    20,
-   139,-32768,-32768,-32768,-32768,   110,   233,   236,-32768
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   379,
+   283,-32768,-32768,-32768,-32768,   157,   103,-32768,-32768,-32768,
+   192,-32768,-32768,   200,-32768,-32768,     8,    89,-32768,-32768,
+-32768,-32768,-32768,-32768,   114,    94,   168,-32768,    94,-32768,
+-32768,   202,    94,-32768,   101,   175,-32768,-32768,    94,    94,
+    94,    94,    94,    94,    94,    94,    94,    94,    94,    94,
+    94,    94,    94,    94,    94,    94,    94,    94,    94,    94,
+    94,   434,    94,-32768,-32768,-32768,-32768,-32768,   471,   137,
+   120,   179,   226,-32768,   229,   230,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,   162,   159,-32768,   121,-32768,    33,-32768,
+    13,   121,    94,    94,-32768,    94,    94,   145,-32768,   231,
+-32768,    94,   434,   334,    94,    94,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,   155,    20,   163,   167,   162,-32768,-32768,
+-32768,    94,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+   186,   388,-32768,    94,   174,    94,   232,-32768,    82,-32768,
+-32768,-32768,    44,-32768,-32768,-32768,-32768,-32768,    19,    18,
+-32768,    94,-32768,-32768,-32768,    94,   189,    34,    94,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,    94,    94,-32768,    94,
+    20,    22,   141,-32768,-32768,-32768,-32768,    94,   235,   239,
+-32768
 };
 
 static const short yypgoto[] = {-32768,
 -32768,-32768,-32768,    -5,   -79,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,    26,-32768,-32768,   -19,-32768,-32768,-32768,-32768,
-   -83,-32768,    67,   140,-32768,   204,   -32,-32768,-32768,-32768,
--32768,-32768,-32768,    77,-32768,   197,-32768,-32768,   -22,-32768,
-   100,   169,-32768,-32768,-32768,-32768,    -6,   -36
+-32768,-32768,    21,-32768,-32768,    -4,-32768,-32768,-32768,-32768,
+   -83,-32768,    73,   -93,-32768,   205,   -32,-32768,-32768,-32768,
+-32768,-32768,-32768,    77,-32768,   199,-32768,-32768,   -96,-32768,
+   102,   170,-32768,-32768,-32768,-32768,    -6,   -42
 };
 
 
-#define	YYLAST		522
+#define	YYLAST		524
 
 
 static const short yytable[] = {    14,
-    15,    16,    20,   160,    21,    23,    24,    25,   163,   109,
-   111,   188,     9,    47,    -8,    21,    30,    21,    21,    21,
-    21,    -8,    21,    48,   242,   243,    21,   166,   199,    96,
-    21,    97,    98,   238,   220,   105,   108,    22,    18,    11,
-    19,   238,   112,    18,    89,   189,    21,   118,   119,   120,
-   121,   122,   123,   124,   125,   126,   127,   128,   129,   130,
-   131,   132,   133,   134,   135,   136,   137,   138,   139,   140,
-   141,   142,   241,   109,   253,    21,   196,   178,    99,   239,
-   150,   100,   240,    31,    32,    33,    34,    35,   165,   -33,
-   240,   114,    92,   169,   170,    93,   171,   172,    21,    21,
-   174,    48,    -1,   151,   175,    12,    18,   220,   110,    13,
-   180,   181,    21,    31,    32,    33,    34,    35,   182,   152,
-   153,   154,    32,    33,    34,    35,    36,    86,    18,    94,
-   177,   201,   202,   203,   204,   205,    26,    27,   -86,    95,
-   183,   184,   187,   168,   191,   -32,   149,   193,    -8,    31,
-    32,    33,    34,    35,    29,    -8,    36,   198,   215,   117,
-   200,   155,     1,     2,     3,     4,   107,   255,    -8,   198,
-    18,   212,   186,   214,    18,   197,    -8,    32,    33,    34,
-    35,   206,   207,   113,   217,   219,   254,   224,   226,    -8,
-   116,   164,    36,   227,    31,    32,    33,    34,    35,    18,
-   176,   211,   228,   179,    18,   230,   198,    18,   192,   218,
-   234,    18,    -8,   223,   237,    -8,    -8,    -8,    18,    -8,
-   225,    18,   194,   231,   195,   245,   246,   213,   229,   252,
-   144,   247,   258,   248,   249,   259,   210,    36,   250,  -104,
-  -104,  -104,   236,   173,   106,   209,   115,   185,   143,   256,
-     0,     0,     0,   232,  -104,  -104,  -104,  -104,  -104,  -104,
-  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,
-  -104,  -104,  -104,  -104,  -104,  -104,     0,   -98,   -98,   146,
-  -104,   144,  -104,     0,     0,     0,     0,   147,     0,     0,
-  -104,  -104,  -104,     0,     0,     0,     0,     0,     0,     0,
-     0,     0,     0,     0,     0,  -104,  -104,  -104,  -104,  -104,
-  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,
-  -104,  -104,  -104,  -104,  -104,  -104,  -104,     0,   145,     0,
-   146,  -104,   144,  -104,     0,     0,     0,     0,   147,     0,
-     0,  -104,  -104,  -104,     0,     0,     0,     0,     0,     0,
-     0,     0,     0,     0,     0,     0,  -104,  -104,  -104,  -104,
-  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,
-  -104,  -104,  -104,  -104,  -104,  -104,  -104,  -104,     0,     0,
-   101,   146,  -104,     0,  -104,     0,   101,     0,   216,   147,
-   -48,   -48,   -48,   -48,   -48,     0,   -48,   -48,   -48,   -48,
-   -48,    56,    57,    58,    59,    60,    61,    62,    63,    64,
-    65,    66,    67,    68,    69,    70,    71,    72,    73,    74,
-     0,     0,     0,     0,     0,     0,   -52,     0,     0,   -52,
-   102,   103,   -53,   -48,    21,   -53,   102,   103,     0,   -48,
-     0,    53,    54,    55,     0,     0,     0,     0,     0,     0,
-     0,     0,     0,     0,     0,     0,    56,    57,    58,    59,
-    60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
-    70,    71,    72,    73,    74,    75,    76,    77,    53,    54,
-    55,     0,    78,     0,    79,     0,     0,     0,     0,     0,
-     0,     0,     0,    56,    57,    58,    59,    60,    61,    62,
+    15,    16,    20,   161,   112,    23,    24,    25,   164,   110,
+    21,   175,    93,    47,    94,    21,    30,     9,   168,    -8,
+    21,    21,    21,    48,    21,    11,    -8,   244,   245,    97,
+   222,    98,    99,    21,   240,   106,   109,   203,   204,   205,
+   206,   207,   113,    12,   240,   184,    95,   119,   120,   121,
+   122,   123,   124,   125,   126,   127,   128,   129,   130,   131,
+   132,   133,   134,   135,   136,   137,   138,   139,   140,   141,
+   142,   143,   180,   201,   110,   243,   255,   198,   100,    92,
+   151,   101,   -33,   242,    21,    13,   217,   208,   209,   167,
+   241,    21,   222,   242,   171,   172,    21,   173,   174,   115,
+    21,   176,    -1,   152,    18,   177,    19,    22,    18,    48,
+   111,   182,   183,    31,    32,    33,    34,    35,    96,   153,
+   154,   155,    21,    21,    31,    32,    33,    34,    35,   190,
+   -32,    31,    32,    33,    34,    35,   170,     1,     2,     3,
+     4,   185,   186,   189,    29,   193,   -87,    18,   195,   179,
+    86,    31,    32,    33,    34,    35,    36,   150,   200,    -8,
+   114,   156,   202,   191,    26,    27,    -8,    36,   108,   257,
+    -8,   200,   117,   214,    36,   216,    18,    89,    -8,    32,
+    33,    34,    35,    18,   118,   188,   219,   221,   256,   226,
+   228,    18,   165,   213,    36,   229,    32,    33,    34,    35,
+    -8,    18,   178,   220,   230,    18,   199,   232,   200,    18,
+   166,   225,   236,    18,    -8,   227,   239,    -8,    -8,    -8,
+    18,    -8,   233,   181,    -8,    18,   194,   247,   248,   196,
+   197,   215,   145,   231,   260,   250,   251,   249,   261,   238,
+   252,  -105,  -105,  -105,   212,   107,   254,   211,   116,   144,
+   187,   258,     0,     0,     0,   234,  -105,  -105,  -105,  -105,
+  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,
+  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,     0,   -99,
+   -99,   147,  -105,   145,  -105,     0,     0,     0,     0,   148,
+     0,     0,  -105,  -105,  -105,     0,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,  -105,  -105,  -105,
+  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,
+  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,     0,
+   146,     0,   147,  -105,   145,  -105,     0,     0,     0,     0,
+   148,     0,     0,  -105,  -105,  -105,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,  -105,  -105,
+  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,
+  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,  -105,
+     0,     0,   102,   147,  -105,     0,  -105,     0,   102,     0,
+   218,   148,   -48,   -48,   -48,   -48,   -48,     0,   -48,   -48,
+   -48,   -48,   -48,    56,    57,    58,    59,    60,    61,    62,
     63,    64,    65,    66,    67,    68,    69,    70,    71,    72,
-    73,    74,    75,    76,    77,     0,     0,     0,     0,    78,
-     0,    79
+    73,    74,     0,     0,     0,     0,     0,     0,   -52,     0,
+     0,   -52,   103,   104,   -53,   -48,    21,   -53,   103,   104,
+     0,   -48,     0,    53,    54,    55,     0,     0,     0,     0,
+     0,     0,     0,     0,     0,     0,     0,     0,    56,    57,
+    58,    59,    60,    61,    62,    63,    64,    65,    66,    67,
+    68,    69,    70,    71,    72,    73,    74,    75,    76,    77,
+    53,    54,    55,     0,    78,     0,    79,     0,     0,     0,
+     0,     0,     0,     0,     0,    56,    57,    58,    59,    60,
+    61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
+    71,    72,    73,    74,    75,    76,    77,     0,     0,     0,
+     0,    78,     0,    79
 };
 
 static const short yycheck[] = {     5,
-     6,     7,     9,    87,     3,    11,    12,    13,    88,    42,
-    47,    10,     1,     1,     3,     3,    22,     3,     3,     3,
-     3,    10,     3,    11,    10,    11,     3,    11,    11,    35,
-     3,    37,     1,     1,    11,    41,    42,    10,    47,    47,
-    49,     1,    48,    47,    48,    44,     3,    53,    54,    55,
+     6,     7,     9,    87,    47,    11,    12,    13,    88,    42,
+     3,   105,    11,     1,    13,     3,    22,     1,    11,     3,
+     3,     3,     3,    11,     3,    47,    10,    10,    11,    35,
+    11,    37,     1,     3,     1,    41,    42,     5,     6,     7,
+     8,     9,    48,    47,     1,   142,    45,    53,    54,    55,
     56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
     66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
-    76,    77,    57,   106,    55,     3,   156,   114,    47,    47,
-    86,    50,    50,    11,    12,    13,    14,    15,    94,    49,
-    50,     1,    49,    99,   100,    11,   102,   103,     3,     3,
-   106,    11,     0,     1,   110,    47,    47,    11,    49,    47,
-   116,   117,     3,    11,    12,    13,    14,    15,   141,    17,
-    18,    19,    12,    13,    14,    15,    54,    16,    47,    45,
-    49,     5,     6,     7,     8,     9,     3,     4,    48,    11,
-   146,   147,   149,    48,   151,    49,     1,   153,     3,    11,
-    12,    13,    14,    15,     1,    10,    54,   164,   181,    13,
-   166,    59,    20,    21,    22,    23,     1,   251,     3,   176,
-    47,   177,    49,   179,    47,    48,    11,    12,    13,    14,
-    15,    55,    56,    48,   190,   192,    48,   194,   195,    44,
-    49,     1,    54,   199,    11,    12,    13,    14,    15,    47,
-     1,    49,   208,    49,    47,   211,   213,    47,     1,    49,
-   216,    47,    47,    49,   220,    50,    51,    52,    47,    54,
-    49,    47,     1,    49,     1,   231,   232,     1,    48,   249,
-     1,    49,     0,   239,   240,     0,   170,    54,   244,    10,
-    11,    12,   217,   104,    41,   169,    50,   148,    80,   255,
-    -1,    -1,    -1,    24,    25,    26,    27,    28,    29,    30,
-    31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
-    41,    42,    43,    44,    45,    46,    -1,    48,    49,    50,
-    51,     1,    53,    -1,    -1,    -1,    -1,    58,    -1,    -1,
-    10,    11,    12,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
-    30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
-    40,    41,    42,    43,    44,    45,    46,    -1,    48,    -1,
-    50,    51,     1,    53,    -1,    -1,    -1,    -1,    58,    -1,
-    -1,    10,    11,    12,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,
-    29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
-    39,    40,    41,    42,    43,    44,    45,    46,    -1,    -1,
-     1,    50,    51,    -1,    53,    -1,     1,    -1,    57,    58,
-    11,    12,    13,    14,    15,    -1,    11,    12,    13,    14,
-    15,    25,    26,    27,    28,    29,    30,    31,    32,    33,
-    34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
-    -1,    -1,    -1,    -1,    -1,    -1,    47,    -1,    -1,    50,
-    51,    52,    47,    54,     3,    50,    51,    52,    -1,    54,
-    -1,    10,    11,    12,    -1,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,
+    76,    77,   115,   167,   107,    57,    55,   157,    47,    49,
+    86,    50,    49,    50,     3,    47,   183,    55,    56,    95,
+    47,     3,    11,    50,   100,   101,     3,   103,   104,     1,
+     3,   107,     0,     1,    47,   111,    49,    10,    47,    11,
+    49,   117,   118,    11,    12,    13,    14,    15,    11,    17,
+    18,    19,     3,     3,    11,    12,    13,    14,    15,    10,
+    49,    11,    12,    13,    14,    15,    48,    20,    21,    22,
+    23,   147,   148,   150,     1,   152,    48,    47,   154,    49,
+    16,    11,    12,    13,    14,    15,    54,     1,   165,     3,
+    48,    59,   168,    44,     3,     4,    10,    54,     1,   253,
+     3,   178,    49,   179,    54,   181,    47,    48,    11,    12,
+    13,    14,    15,    47,    13,    49,   192,   194,    48,   196,
+   197,    47,     1,    49,    54,   201,    12,    13,    14,    15,
+    44,    47,     1,    49,   210,    47,    48,   213,   215,    47,
+    11,    49,   218,    47,    47,    49,   222,    50,    51,    52,
+    47,    54,    49,    49,    57,    47,     1,   233,   234,     1,
+     1,     1,     1,    48,     0,   241,   242,    49,     0,   219,
+   246,    10,    11,    12,   172,    41,   251,   171,    50,    80,
+   149,   257,    -1,    -1,    -1,    24,    25,    26,    27,    28,
     29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
-    39,    40,    41,    42,    43,    44,    45,    46,    10,    11,
-    12,    -1,    51,    -1,    53,    -1,    -1,    -1,    -1,    -1,
-    -1,    -1,    -1,    25,    26,    27,    28,    29,    30,    31,
+    39,    40,    41,    42,    43,    44,    45,    46,    -1,    48,
+    49,    50,    51,     1,    53,    -1,    -1,    -1,    -1,    58,
+    -1,    -1,    10,    11,    12,    -1,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,    27,
+    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+    38,    39,    40,    41,    42,    43,    44,    45,    46,    -1,
+    48,    -1,    50,    51,     1,    53,    -1,    -1,    -1,    -1,
+    58,    -1,    -1,    10,    11,    12,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,
+    27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
+    37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
+    -1,    -1,     1,    50,    51,    -1,    53,    -1,     1,    -1,
+    57,    58,    11,    12,    13,    14,    15,    -1,    11,    12,
+    13,    14,    15,    25,    26,    27,    28,    29,    30,    31,
     32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
-    42,    43,    44,    45,    46,    -1,    -1,    -1,    -1,    51,
-    -1,    53
+    42,    43,    -1,    -1,    -1,    -1,    -1,    -1,    47,    -1,
+    -1,    50,    51,    52,    47,    54,     3,    50,    51,    52,
+    -1,    54,    -1,    10,    11,    12,    -1,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    25,    26,
+    27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
+    37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
+    10,    11,    12,    -1,    51,    -1,    53,    -1,    -1,    -1,
+    -1,    -1,    -1,    -1,    -1,    25,    26,    27,    28,    29,
+    30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+    40,    41,    42,    43,    44,    45,    46,    -1,    -1,    -1,
+    -1,    51,    -1,    53
 };
 #define YYPURE 1
 
@@ -1441,7 +1447,7 @@ case 61:
 case 62:
 #line 575 "parser.y"
 {
-	yyval.element = 0xffff;
+	yyval.element = -1;
     ;
     break;}
 case 63:
@@ -1455,22 +1461,24 @@ case 64:
 #line 585 "parser.y"
 {
 	yyval.selector = yyvsp[-1].selector;
-        CSSSelector *end = yyvsp[-1].selector;
-        while( end->tagHistory )
-            end = end->tagHistory;
-        end->relation = CSSSelector::SubSelector;
-        end->tagHistory = yyvsp[0].selector;
+        if (yyval.selector) {
+            CSSSelector *end = yyvsp[-1].selector;
+            while( end->tagHistory )
+                end = end->tagHistory;
+            end->relation = CSSSelector::SubSelector;
+            end->tagHistory = yyvsp[0].selector;
+        }
     ;
     break;}
 case 65:
-#line 593 "parser.y"
+#line 595 "parser.y"
 {
         delete yyvsp[-1].selector;
         yyval.selector = 0;
     ;
     break;}
 case 66:
-#line 600 "parser.y"
+#line 602 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->match = CSSSelector::Id;
@@ -1479,7 +1487,7 @@ case 66:
     ;
     break;}
 case 70:
-#line 612 "parser.y"
+#line 614 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->match = CSSSelector::List;
@@ -1488,7 +1496,7 @@ case 70:
     ;
     break;}
 case 71:
-#line 621 "parser.y"
+#line 623 "parser.y"
 {
 	CSSParser *p = static_cast<CSSParser *>(parser);
 	DOM::DocumentImpl *doc = p->document();
@@ -1512,7 +1520,7 @@ case 71:
     ;
     break;}
 case 72:
-#line 645 "parser.y"
+#line 647 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->attr = yyvsp[-1].attribute;
@@ -1520,7 +1528,7 @@ case 72:
     ;
     break;}
 case 73:
-#line 650 "parser.y"
+#line 652 "parser.y"
 {
 	yyval.selector = new CSSSelector();
 	yyval.selector->attr = yyvsp[-5].attribute;
@@ -1529,80 +1537,88 @@ case 73:
     ;
     break;}
 case 74:
-#line 659 "parser.y"
+#line 661 "parser.y"
 {
 	yyval.val = CSSSelector::Exact;
     ;
     break;}
 case 75:
-#line 662 "parser.y"
+#line 664 "parser.y"
 {
 	yyval.val = CSSSelector::List;
     ;
     break;}
 case 76:
-#line 665 "parser.y"
+#line 667 "parser.y"
 {
 	yyval.val = CSSSelector::Hyphen;
     ;
     break;}
 case 77:
-#line 668 "parser.y"
+#line 670 "parser.y"
 {
 	yyval.val = CSSSelector::Begin;
     ;
     break;}
 case 78:
-#line 671 "parser.y"
+#line 673 "parser.y"
 {
 	yyval.val = CSSSelector::End;
     ;
     break;}
 case 79:
-#line 674 "parser.y"
+#line 676 "parser.y"
 {
 	yyval.val = CSSSelector::Contain;
     ;
     break;}
 case 82:
-#line 685 "parser.y"
+#line 687 "parser.y"
 {
-	yyval.selector = new CSSSelector();
-	yyval.selector->match = CSSSelector::Pseudo;
-	yyval.selector->value = domString(yyvsp[0].string);
+        yyval.selector = new CSSSelector();
+        yyval.selector->match = CSSSelector::Pseudo;
+        yyval.selector->value = domString(yyvsp[0].string);
     ;
     break;}
 case 83:
-#line 690 "parser.y"
+#line 693 "parser.y"
 {
-	yyval.selector = new CSSSelector();
-	yyval.selector->match = CSSSelector::Pseudo;
-	yyval.selector->_pseudoType = CSSSelector::PseudoFunction;
-	yyval.selector->value = domString(yyvsp[-2].string);
+        yyval.selector = new CSSSelector();
+        yyval.selector->match = CSSSelector::Pseudo;
+        yyval.selector->value = domString(yyvsp[0].string);
     ;
     break;}
 case 84:
-#line 699 "parser.y"
+#line 698 "parser.y"
 {
-	yyval.ok = yyvsp[0].ok;
+        yyval.selector = new CSSSelector();
+        yyval.selector->match = CSSSelector::Pseudo;
+        yyval.selector->simpleSelector = yyvsp[-2].selector;
+        yyval.selector->value = domString(yyvsp[-4].string);
     ;
     break;}
 case 85:
-#line 702 "parser.y"
+#line 707 "parser.y"
+{
+	yyval.ok = yyvsp[0].ok;
+    ;
+    break;}
+case 86:
+#line 710 "parser.y"
 {
 	yyval.ok = yyvsp[-1].ok;
 	if ( yyvsp[0].ok )
 	    yyval.ok = yyvsp[0].ok;
     ;
     break;}
-case 86:
-#line 707 "parser.y"
+case 87:
+#line 715 "parser.y"
 {
 	yyval.ok = yyvsp[0].ok;
     ;
     break;}
-case 87:
-#line 710 "parser.y"
+case 88:
+#line 718 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1610,8 +1626,8 @@ case 87:
 #endif
     ;
     break;}
-case 88:
-#line 716 "parser.y"
+case 89:
+#line 724 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1619,14 +1635,14 @@ case 88:
 #endif
     ;
     break;}
-case 89:
-#line 725 "parser.y"
+case 90:
+#line 733 "parser.y"
 {
 	yyval.ok = yyvsp[-2].ok;
     ;
     break;}
-case 90:
-#line 728 "parser.y"
+case 91:
+#line 736 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1634,8 +1650,8 @@ case 90:
 #endif
     ;
     break;}
-case 91:
-#line 734 "parser.y"
+case 92:
+#line 742 "parser.y"
 {
 	yyval.ok = false;
 #ifdef CSS_DEBUG
@@ -1643,16 +1659,16 @@ case 91:
 #endif
     ;
     break;}
-case 92:
-#line 740 "parser.y"
+case 93:
+#line 748 "parser.y"
 {
 	yyval.ok = yyvsp[-3].ok;
 	if ( yyvsp[-2].ok )
 	    yyval.ok = yyvsp[-2].ok;
     ;
     break;}
-case 93:
-#line 745 "parser.y"
+case 94:
+#line 753 "parser.y"
 {
 	yyval.ok = yyvsp[-3].ok;
 #ifdef CSS_DEBUG
@@ -1660,8 +1676,8 @@ case 93:
 #endif
     ;
     break;}
-case 94:
-#line 751 "parser.y"
+case 95:
+#line 759 "parser.y"
 {
 	yyval.ok = yyvsp[-5].ok;
 #ifdef CSS_DEBUG
@@ -1669,8 +1685,8 @@ case 94:
 #endif
     ;
     break;}
-case 95:
-#line 760 "parser.y"
+case 96:
+#line 768 "parser.y"
 {
 	yyval.ok = false;
 	CSSParser *p = static_cast<CSSParser *>(parser);
@@ -1694,30 +1710,30 @@ case 95:
 	p->valueList = 0;
     ;
     break;}
-case 96:
-#line 785 "parser.y"
+case 97:
+#line 793 "parser.y"
 {
 	QString str = qString(yyvsp[-1].string);
 	yyval.prop_id = getPropertyID( str.lower().latin1(), str.length() );
     ;
     break;}
-case 97:
-#line 792 "parser.y"
+case 98:
+#line 800 "parser.y"
 { yyval.b = true; ;
     break;}
-case 98:
-#line 793 "parser.y"
+case 99:
+#line 801 "parser.y"
 { yyval.b = false; ;
     break;}
-case 99:
-#line 797 "parser.y"
+case 100:
+#line 805 "parser.y"
 {
 	yyval.valueList = new ValueList;
 	yyval.valueList->addValue( yyvsp[0].value );
     ;
     break;}
-case 100:
-#line 801 "parser.y"
+case 101:
+#line 809 "parser.y"
 {
         yyval.valueList = yyvsp[-2].valueList;
 	if ( yyval.valueList ) {
@@ -1732,45 +1748,45 @@ case 100:
         }
     ;
     break;}
-case 101:
-#line 814 "parser.y"
+case 102:
+#line 822 "parser.y"
 {
         delete yyvsp[-1].valueList;
         yyval.valueList = 0;
     ;
     break;}
-case 102:
-#line 821 "parser.y"
+case 103:
+#line 829 "parser.y"
 {
 	yyval.tok = '/';
     ;
     break;}
-case 103:
-#line 824 "parser.y"
+case 104:
+#line 832 "parser.y"
 {
 	yyval.tok = ',';
     ;
     break;}
-case 104:
-#line 827 "parser.y"
+case 105:
+#line 835 "parser.y"
 {
         yyval.tok = 0;
   ;
     break;}
-case 105:
-#line 833 "parser.y"
+case 106:
+#line 841 "parser.y"
 { yyval.value = yyvsp[0].value; ;
     break;}
-case 106:
-#line 834 "parser.y"
+case 107:
+#line 842 "parser.y"
 { yyval.value = yyvsp[0].value; yyval.value.fValue *= yyvsp[-1].val; ;
     break;}
-case 107:
-#line 835 "parser.y"
+case 108:
+#line 843 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_STRING; ;
     break;}
-case 108:
-#line 836 "parser.y"
+case 109:
+#line 844 "parser.y"
 {
       QString str = qString( yyvsp[-1].string );
       yyval.value.id = getValueID( str.lower().latin1(), str.length() );
@@ -1778,102 +1794,102 @@ case 108:
       yyval.value.string = yyvsp[-1].string;
   ;
     break;}
-case 109:
-#line 842 "parser.y"
+case 110:
+#line 850 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_URI; ;
     break;}
-case 110:
-#line 843 "parser.y"
+case 111:
+#line 851 "parser.y"
 { yyval.value.id = 0; yyval.value.iValue = 0; yyval.value.unit = CSSPrimitiveValue::CSS_UNKNOWN;/* ### */ ;
     break;}
-case 111:
-#line 844 "parser.y"
+case 112:
+#line 852 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[0].string; yyval.value.unit = CSSPrimitiveValue::CSS_RGBCOLOR; ;
     break;}
-case 112:
-#line 846 "parser.y"
+case 113:
+#line 854 "parser.y"
 {
       yyval.value = yyvsp[0].value;
   ;
     break;}
-case 113:
-#line 852 "parser.y"
+case 114:
+#line 860 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_NUMBER; ;
     break;}
-case 114:
-#line 853 "parser.y"
+case 115:
+#line 861 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PERCENTAGE; ;
     break;}
-case 115:
-#line 854 "parser.y"
+case 116:
+#line 862 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PX; ;
     break;}
-case 116:
-#line 855 "parser.y"
+case 117:
+#line 863 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_CM; ;
     break;}
-case 117:
-#line 856 "parser.y"
+case 118:
+#line 864 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_MM; ;
     break;}
-case 118:
-#line 857 "parser.y"
+case 119:
+#line 865 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_IN; ;
     break;}
-case 119:
-#line 858 "parser.y"
+case 120:
+#line 866 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PT; ;
     break;}
-case 120:
-#line 859 "parser.y"
+case 121:
+#line 867 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PC; ;
     break;}
-case 121:
-#line 860 "parser.y"
+case 122:
+#line 868 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_DEG; ;
     break;}
-case 122:
-#line 861 "parser.y"
+case 123:
+#line 869 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_RAD; ;
     break;}
-case 123:
-#line 862 "parser.y"
+case 124:
+#line 870 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_GRAD; ;
     break;}
-case 124:
-#line 863 "parser.y"
+case 125:
+#line 871 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_MS; ;
     break;}
-case 125:
-#line 864 "parser.y"
+case 126:
+#line 872 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_S; ;
     break;}
-case 126:
-#line 865 "parser.y"
+case 127:
+#line 873 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_HZ; ;
     break;}
-case 127:
-#line 866 "parser.y"
+case 128:
+#line 874 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_KHZ; ;
     break;}
-case 128:
-#line 867 "parser.y"
+case 129:
+#line 875 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_EMS; ;
     break;}
-case 129:
-#line 868 "parser.y"
+case 130:
+#line 876 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = Value::Q_EMS; ;
     break;}
-case 130:
-#line 869 "parser.y"
+case 131:
+#line 877 "parser.y"
 { yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_EXS; ;
     break;}
-case 131:
-#line 870 "parser.y"
+case 132:
+#line 878 "parser.y"
 { yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_DIMENSION ;
     break;}
-case 132:
-#line 875 "parser.y"
+case 133:
+#line 883 "parser.y"
 {
       Function *f = new Function;
       f->name = yyvsp[-4].string;
@@ -1883,12 +1899,12 @@ case 132:
       yyval.value.function = f;
   ;
     break;}
-case 133:
-#line 890 "parser.y"
+case 134:
+#line 898 "parser.y"
 { yyval.string = yyvsp[-1].string; ;
     break;}
-case 134:
-#line 897 "parser.y"
+case 135:
+#line 905 "parser.y"
 {
 	yyval.rule = 0;
 #ifdef CSS_DEBUG
@@ -1896,8 +1912,8 @@ case 134:
 #endif
     ;
     break;}
-case 135:
-#line 903 "parser.y"
+case 136:
+#line 911 "parser.y"
 {
 	yyval.rule = 0;
 #ifdef CSS_DEBUG
@@ -1905,8 +1921,8 @@ case 135:
 #endif
     ;
     break;}
-case 136:
-#line 912 "parser.y"
+case 137:
+#line 920 "parser.y"
 {
 	yyval.rule = 0;
 #ifdef CSS_DEBUG
@@ -2136,6 +2152,6 @@ yyerrhandle:
     }
   return 1;
 }
-#line 947 "parser.y"
+#line 955 "parser.y"
 
 
diff --git a/WebCore/khtml/css/parser.y b/WebCore/khtml/css/parser.y
index 924be59..08d4f7b 100644
--- a/WebCore/khtml/css/parser.y
+++ b/WebCore/khtml/css/parser.y
@@ -573,7 +573,7 @@ element_name:
 	}
     }
     | '*' {
-	$$ = 0xffff;
+	$$ = -1;
     }
   ;
 
@@ -584,11 +584,13 @@ specifier_list:
     }
     | specifier_list specifier {
 	$$ = $1;
-        CSSSelector *end = $1;
-        while( end->tagHistory )
-            end = end->tagHistory;
-        end->relation = CSSSelector::SubSelector;
-        end->tagHistory = $2;
+        if ($$) {
+            CSSSelector *end = $1;
+            while( end->tagHistory )
+                end = end->tagHistory;
+            end->relation = CSSSelector::SubSelector;
+            end->tagHistory = $2;
+        }
     }
     | specifier_list error {
         delete $1;
@@ -683,15 +685,21 @@ ident_or_string:
 
 pseudo:
     ':' IDENT {
-	$$ = new CSSSelector();
-	$$->match = CSSSelector::Pseudo;
-	$$->value = domString($2);
-    }
-    | ':' FUNCTION maybe_space IDENT maybe_space ')' {
-	$$ = new CSSSelector();
-	$$->match = CSSSelector::Pseudo;
-	$$->_pseudoType = CSSSelector::PseudoFunction;
-	$$->value = domString($4);
+        $$ = new CSSSelector();
+        $$->match = CSSSelector::Pseudo;
+        $$->value = domString($2);
+    }
+    |
+    ':' ':' IDENT {
+        $$ = new CSSSelector();
+        $$->match = CSSSelector::Pseudo;
+        $$->value = domString($3);
+    }
+    | ':' FUNCTION maybe_space simple_selector maybe_space ')' {
+        $$ = new CSSSelector();
+        $$->match = CSSSelector::Pseudo;
+        $$->simpleSelector = $4;
+        $$->value = domString($2);
     }
   ;
 
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 3977c05..5a23054 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -496,7 +496,7 @@ public:
     static void cleanup();
 
     // static pseudo styles. Dynamic ones are produced on the fly.
-    enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER };
+    enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION };
 
 protected:
 
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index d4c95b5..e14be94 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -84,7 +84,12 @@ void TextRun::paintSelection(const Font *f, RenderText *text, QPainter *p, Rende
     QColor c = QPainter::selectedTextBackgroundColor();
     if (textColor == c)
         c = QColor(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
+
+    RenderStyle* pseudoStyle = object()->style()->getPseudoStyle(RenderStyle::SELECTION);
+    if (pseudoStyle && pseudoStyle->backgroundColor().isValid())
+        c = pseudoStyle->backgroundColor();
     p->setPen(c); // Don't draw text at all!
+    
 #else
     QColor c = style->color();
     p->setPen(QColor(0xff-c.red(),0xff-c.green(),0xff-c.blue()));
@@ -669,18 +674,54 @@ void RenderText::paintObject(QPainter *p, int /*x*/, int y, int /*w*/, int h,
                 p->setPen(_style->color());
 
             if (s->m_len > 0) {
-                if (paintAction == PaintActionSelection) {
+                bool paintSelectedTextOnly = (paintAction == PaintActionSelection);
+                bool paintSelectedTextSeparately = false; // Whether or not we have to do multiple paints.  Only
+                                               // necessary when a custom ::selection foreground color is applied.
+                QColor selectionColor = p->pen().color();
+                if (haveSelection) {
+                    RenderStyle* pseudoStyle = style()->getPseudoStyle(RenderStyle::SELECTION);
+                    if (pseudoStyle && pseudoStyle->color() != selectionColor) {
+                        if (!paintSelectedTextOnly)
+                            paintSelectedTextSeparately = true;
+                        selectionColor = pseudoStyle->color();
+                    }
+                }
+                
+                if (!paintSelectedTextOnly && !paintSelectedTextSeparately) {
+                    font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline,
+                                   str->s, str->l, s->m_start, s->m_len,
+                                   s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR);
+                }
+                else {
                     int offset = s->m_start;
                     int sPos = QMAX( startPos - offset, 0 );
                     int ePos = QMIN( endPos - offset, s->m_len );
-                    if ( sPos < ePos ){
-                        font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s, str->l, s->m_start, s->m_len,
-                                   s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR, sPos, ePos);
+                    if (paintSelectedTextSeparately) {
+                        if (sPos >= ePos)
+                            font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline,
+                                           str->s, str->l, s->m_start, s->m_len,
+                                           s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR);
+                        else {
+                            if (sPos-1 >= 0)
+                                font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s,
+                                            str->l, s->m_start, s->m_len,
+                                            s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR, 0, sPos);
+                            if (ePos < s->m_start+s->m_len)
+                                font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s,
+                                            str->l, s->m_start, s->m_len,
+                                            s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR, ePos, -1);
+                        }
                     }
-                } else {
-                    font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s, str->l, s->m_start, s->m_len,
-                                   s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR);
-                }
+                    
+                    if ( sPos < ePos ) {
+                        if (selectionColor != p->pen().color())
+                            p->setPen(selectionColor);
+                        
+                        font->drawText(p, s->m_x + tx, s->m_y + ty + s->m_baseline, str->s,
+                                       str->l, s->m_start, s->m_len,
+                                       s->m_toAdd, s->m_reversed ? QPainter::RTL : QPainter::LTR, sPos, ePos);
+                    }
+                } 
             }
 
             if (d != TDNONE && paintAction == PaintActionForeground)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list