[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    [patch] cssRules / ID selectors
From:       Paul Temple <paul.temple () gmx ! net>
Date:       2005-02-13 2:41:22
Message-ID: 200502130341.22842.paul.temple () gmx ! net
[Download RAW message or body]

Here's my latest patch.

I also attached a html file so you can easily test
CSSSelector::selectorText() with any selector.
For now I don't explain what I did and why, as I assume
there are some people in this list knowing that piece of code
more than I do (even after these many, many hours of working with
it... many more hours than I thought were necessary to fix this
"small" bug). If there are questions, that are not answered by my
test results or csstest.html, I'll of course answer them... :)

These are the styles that I tested:
      .aaa { color:red; }
      body { color:red; }
      div:focus { color:red; }
      span body p div { color:red; }
      .bbb:hover { color:red; }
      input[type="button"] { color:red; }
      #eee { color:red; }
      [id="fff"] { color:red; }
      span.xxx { color:red; }
      #ggg:active { color:red; }
      table#vvv { color:red; }
      img#uuu:link { color:red; }
      p.special:hover { color:red; }
      span > p { color:red; }
      span + p { color:red; }
      span:lang(de) { color:red; }
      span[class] { color:red; }
      span[class="warning"] { color:red; }
      span[class~="warning"] { color:red; }
      span[lang|="en"] { color:red; }

These are the test results _without_ my patch (I also added 
kdDebug()
to CSSStyleRule::selectorText() ):

testkhtml: .aaa
testkhtml: body
testkhtml: div:focus
testkhtml: span body p div
testkhtml: .bbb/a:hover
testkhtml: input[type="button"]
khtml (css): WARNING: Unhandled case in 
CSSStyleRuleImpl::selectorText : match=1
testkhtml: *[id"eee"]
testkhtml: #fff
testkhtml: span.xxx[class~="xxx"]
khtml (css): WARNING: Unhandled case in 
CSSStyleRuleImpl::selectorText : match=1
testkhtml: *[id"ggg"]/a:active
khtml (css): WARNING: Unhandled case in 
CSSStyleRuleImpl::selectorText : match=1
testkhtml: table[id"vvv"]
khtml (css): WARNING: Unhandled case in 
CSSStyleRuleImpl::selectorText : match=1
testkhtml: img[id"uuu"]/a:link
testkhtml: p.special[class~="special"]/a:hover
testkhtml: span > p
testkhtml: span + p
testkhtml: span:lang(
testkhtml: span[class ""]
testkhtml: span[class="warning"]
testkhtml: span.warning[class~="warning"]
testkhtml: span[lang|="en"]

And these are the result with my patch applied:

testkhtml: .aaa
testkhtml: body
testkhtml: div:focus
testkhtml: span body p div
testkhtml: .bbb:hover
testkhtml: input[type="button"]
testkhtml: #eee
testkhtml: *[id="fff"]
testkhtml: span.xxx
testkhtml: #ggg:active
testkhtml: table#vvv
testkhtml: img#uuu:link
testkhtml: p.special:hover
testkhtml: span > p
testkhtml: span + p
testkhtml: span:lang(
testkhtml: span[class ""]
testkhtml: span[class="warning"]
testkhtml: span.warning
testkhtml: span[lang|="en"]

As you can see these selectors still don't work
      span:lang(de) { color:red; }
      span[class] { color:red; }
      span[class~="warning"] { color:red; }
but they don't work or are even worse without my patch (and for
now I don't want to put more time into selectorText() so I leaves
these cases open).

Cheers,
Paul

["csstest.html" (text/html)]

<html>
  <head>
    <style type="text/css">
      .aaa { color:red; }
      body { color:red; }
      div:focus { color:red; }
      span body p div { color:red; }
      .bbb:hover { color:red; }
      input[type="button"] { color:red; }
      #eee { color:red; }
      [id="fff"] { color:red; }
      span.xxx { color:red; }
      #ggg:active { color:red; }
      table#vvv { color:red; }
      img#uuu:link { color:red; }
      p.special:hover { color:red; }
      span > p { color:red; }
      span + p { color:red; }
      span:lang(de) { color:red; }
      span[class] { color:red; }
      span[class="warning"] { color:red; }
      span[class~="warning"] { color:red; }
      span[lang|="en"] { color:red; }
    </style>
    <script language="JavaScript">
      function listCSS() {        
        var dSS = document.styleSheets;
        for(var i = 0; i < dSS.length; i++)
          for(var j = 0; j < dSS[i].cssRules.length; j++) {
            var xx = dSS[i].cssRules[j].selectorText;
            //alert(xx);
          }
      }
    </script>
  </head>
  <body onload="listCSS()">
  </body>
</html>
["css_base.patch" (text/x-diff)]

Index: css_base.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/css/css_base.cpp,v
retrieving revision 1.20
diff -u -p -r1.20 css_base.cpp
--- css_base.cpp	12 Jan 2005 14:21:16 -0000	1.20
+++ css_base.cpp	13 Feb 2005 02:11:30 -0000
@@ -292,7 +292,7 @@ DOMString CSSSelector::selectorText() co
     // #### fix namespace
     DOMString str;
     const CSSSelector* cs = this;
-    if ( cs->tag == 0xffffffff && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
+    if ( cs->tag == 0xffffffff && cs->attr == ATTR_ID && cs->match == CSSSelector::Id )
     {
         str = "#";
         str += cs->value;
@@ -311,9 +311,9 @@ DOMString CSSSelector::selectorText() co
     {
         if ( cs->tag == 0xffffffff )
             str = "*";
-        else
+        else if ( cs->tag != 0xffff )
             str = getTagName( cs->tag );
-        if ( cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
+        if ( cs->attr == ATTR_ID && cs->match == CSSSelector::Id )
         {
             str += "#";
             str += cs->value;
@@ -329,7 +329,7 @@ DOMString CSSSelector::selectorText() co
             str += cs->value;
         }
         // optional attribute
-        if ( cs->attr ) {
+        else if ( cs->attr ) {
             DOMString attrName = getAttrName( cs->attr );
             str += "[";
             str += attrName;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic