Bug 221504 - CSSModelImpl provides the WRONG ICSSSelectorList
Summary: CSSModelImpl provides the WRONG ICSSSelectorList
Status: VERIFIED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.css (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0.1   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 92848
  Show dependency tree
 
Reported: 2008-03-05 08:51 EST by Yaron Mazor CLA
Modified: 2008-07-21 13:40 EDT (History)
0 users

See Also:
thatnitind: review+


Attachments
Patch to fix CSSTokenizer and add test cases (88.64 KB, patch)
2008-03-06 15:10 EST, Nick Sandonato CLA
no flags Details | Diff
Patch to fix CSSTokenizer and add test cases with pseudo-class fix (96.57 KB, patch)
2008-03-13 10:47 EDT, Nick Sandonato CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yaron Mazor CLA 2008-03-05 08:51:57 EST
Hi.

1. I have a CSS file with the following content :
   h1.myClass1, h1.myClass2 {
   }

2. I also have the following Java code which I use to retrieve the css 
   selectors:

   ICSSDocument cssDocument = ((CSSModelImpl) cssModel).getDocument();
   ICSSNodeList nodes = cssDocument.getChildNodes();
   int numOfNodes = nodes.getLength();
   for (int i = 0; i < numOfNodes; i++) {
      ICSSNode node = nodes.item(i);
      if (node instanceof ICSSStyleRule) {
         ICSSStyleRule styleRuleNode = (ICSSStyleRule) node;
         ICSSSelectorList selectorList = styleRuleNode.getSelectors();
         . . .
         . . .

3. When I activate my code, indeed I get the correct selector list with 2 
   items :
   'h1.myClass1'
   'h1.myClass2'

BUT...

4. When I changed the style rule to the following :
   h1.myClass1 , h1.myClass2 {
   }
   
   //Notice that I added one space after h1.myClass1

5. The selector list that I get has only a single item including:
   'h1.myClass1 h1.myClass2'

Looks like a parsing bug to me.
Yaron
Comment 1 Nick Sandonato CLA 2008-03-06 15:10:31 EST
Created attachment 91793 [details]
Patch to fix CSSTokenizer and add test cases

Fixes the jflex file and generated CSS Tokenizer so that a space is only considered as a selector combinator when a comma doesn't follow that space.

Also added a test case.
Comment 2 Nick Sandonato CLA 2008-03-13 10:47:18 EDT
Created attachment 92441 [details]
Patch to fix CSSTokenizer and add test cases with pseudo-class fix

This patch contains an update to the CSS jflex spec as well as the CSSTokenizer that will also correct Bug 92848.
Comment 3 Nitin Dahyabhai CLA 2008-07-17 01:09:57 EDT
Releasing.  Because of the complications with the generated class, Nick, please recheck the CVS changes and verify it in the build as quickly as possible.
Comment 4 Nick Sandonato CLA 2008-07-18 10:21:38 EDT
Verified in M-3.0.1-20080717094056.