Closed Bug 475198 Opened 15 years ago Closed 12 years ago

cssRule's selectorText and cssText don't preserve parentheses

Categories

(Core :: DOM: CSS Object Model, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: benjamin.lerner, Unassigned)

Details

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5
Build Identifier: Firefox 3.0.5 -- Shiretoko nightly

For selectors containing parentheses--e.g. treechildren::-moz-tree-row( foo bar )--syntax as indicated at https://developer.mozilla.org/en/CSS/:-moz-tree-row, getting the cssText or selectorText returns the text without parentheses or spaces--e.g. treechildren:--moz-tree-rowfoobar--which is of course not the intended result.

Reproducible: Always

Steps to Reproduce:
See the attached file.



The particular project I'm working on involves Firefox extensions and requires parsing CSS files and extracting their declarations.  Since it's an extension project, I'm going to encounter CSS rules like this containing Mozilla proprietary extensions to the CSS syntax, so I need to use Mozilla's parser...  If there's a workaround for this bug, I'd be happy to use that instead, but until then this blocks my project somewhat.
I can get the raw text of the entire CSS file using the innerHTML property of the style tag, but that doesn't help me find the legal CSS declarations in the file, or what the cssText of those declarations is.
If this helps -- it does not matter whether I use an HTML IFrame or a XUL IFrame, with CSS included from web content or chrome or a style tag.  So it's not likely to be a chrome/web permissions problem (since the example I cited was a Mozilla-private property for a XUL element)
Version: unspecified → 1.9.1 Branch
Confirmed on mozilla-central.  I'll teach my CSS parser fuzzer to look for more bugs like this.
Status: UNCONFIRMED → NEW
Ever confirmed: true
That got me bug 475214, bug 475215, and bug 475216.  Thanks for the inspiration, Ben ;)
OS: Windows XP → All
Hardware: x86 → All
Version: 1.9.1 Branch → Trunk
Sounds like nsCSSSelector::ToStringInternal needs to be taught to serialize this correctly.  If any instances of this selector were tested in layout/style/tests/test_selectors.html we would have caught this...
A (tangential) documentation & parsing question: which is the correct syntax?
a) treechildren::-moz-tree-line(selected focus)   <<-- sans comma
b) treechildren::-moz-tree-line(selected, focus)  <<-- with comma

It appears that (a) is correct according to the W3C spec, (b) is properly rejected by Firefox when I try it, (a) is recommended by https://developer.mozilla.org/en/CSS/:-moz-tree-row, and (b) is recommended by http://www.xulplanet.com/tutorials/xultu/treestyle.html (linked to from the first page), and (b) is used by e.g. AdBlock Plus.

I recognize this bug is about the CSS printing issue I raised above; I seem to have lost the link to filing MDC bugs, though.  If some kind someone could provide an answer and/or the link, I'll redirect this as appropriate :)
QA Contact: general → style-system
I think this was fixed by bug 602341.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: