Closed
Bug 458381
Opened 16 years ago
Closed 16 years ago
[FIX]empty string does not represent null namespace
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: annevk, Assigned: bzbarsky)
References
()
Details
Attachments
(2 files, 3 obsolete files)
9.22 KB,
patch
|
Details | Diff | Splinter Review | |
22.31 KB,
patch
|
beltzner
:
approval1.9.1b2+
|
Details | Diff | Splinter Review |
The rule @namespace ""; does not associate the default namespace with no namespace. E.g., if I have an element test in a namespace, it should not be matched by the following rule per the CSS Namespaces Module (see section 2.1 specifically): @namespace ""; test { background:red }
Assignee | ||
Comment 1•16 years ago
|
||
This was a spec change, right? I don't recall it working this way before...
Reporter | ||
Comment 2•16 years ago
|
||
The specification never said what to do with the empty string either for the prefix or non-prefix case so we clarified that and decided it would make sense to do the same thing in both.
Reporter | ||
Comment 3•16 years ago
|
||
(FWIW, the spec in question has been through Last Call review and is currently in CR.)
Assignee | ||
Comment 4•16 years ago
|
||
Anne, none of the tests in that directory seem to test the following situation: CSS: @namespace foo "bar"; root *|* { background: red; display: block } baz { background: lime } XML: <root> <baz>This should have a green background</baz> <baz xmlns="bar">This should have a green background</baz> </root> Would you mind adding such a test? The obvious fix for this bug in Gecko would regress this testcase, you see. ;) Also, would it make sense to toss a *|t { background: lime } rule in before the background:red rule in the test for this bug, so that passing is just all lime while failure is part red, and no reading of the text is needed to see that we pass?
Assignee | ||
Comment 5•16 years ago
|
||
I'm a little torn about tests here. Ideally I could just steal Anne's tests and check them in as reftests (after some editing to make them all use the same reference)...
Assignee: nobody → bzbarsky
Status: NEW → ASSIGNED
Attachment #341639 -
Flags: superreview?(dbaron)
Attachment #341639 -
Flags: review?(dbaron)
Assignee | ||
Comment 6•16 years ago
|
||
Attachment #341639 -
Attachment is obsolete: true
Attachment #341642 -
Flags: superreview?(dbaron)
Attachment #341642 -
Flags: review?(dbaron)
Attachment #341639 -
Flags: superreview?(dbaron)
Attachment #341639 -
Flags: review?(dbaron)
Assignee | ||
Updated•16 years ago
|
Summary: empty string does not represent null namespace → [FIX]empty string does not represent null namespace
Anne's tests will be part of the official CSS3 Namespaces test suite within the next week or two, and they'll available be under the BSD license. I guess the two things that come in mind here are: Would reftests be the most efficient way to run these tests? (I was advised to use the mochitest framework for selectors tests.) And how can we keep Mozilla's set of tests in sync with W3C's tests (e.g. accepting corrections, additions, etc)? This question has a much broader scope than this bug, though...
Assignee | ||
Comment 8•16 years ago
|
||
Ah, yeah. That's right; we have selector mochitests too. I agree it's a bigger question; I was just asking dbaron what he wanted done here short term. I'm happy to write some mochitests for this.
Reporter | ||
Comment 9•16 years ago
|
||
FWIW, I added the test suggested by bz, I also checked in the tests on dev.w3.org: http://dev.w3.org/CSS/css3-namespace-test-suite/
I spent quite a while looking for the relevant part of the spec that requires this, and finally found it hidden in the terminology section: http://dev.w3.org/csswg/css3-namespace/#terminology
Comment on attachment 341642 [details] [diff] [review] Without the bogus comments > nsCSSStyleSheetInner::RebuildNameSpaces() > { > if (mNameSpaceMap) { > mNameSpaceMap->Clear(); > } else { > mNameSpaceMap = nsXMLNameSpaceMap::Create(); > if (!mNameSpaceMap) { > return; // out of memory > } > } >+ >+ // Override the default namespace map behavior for the null prefix to return >+ // the wildcard namespace instead of the null namespace. >+ mNameSpaceMap->AddPrefix(nsnull, kNameSpaceID_Unknown); Is there enough benefit to Clear-ing an existing namespace map rather than creating a new one that we shouldn't refactor this code into a CreateNameSpaceMap function so you can avoid duplicating it, and then (here, one of the two places), just unconditionally replace the namespace map? r+sr=dbaron
Attachment #341642 -
Flags: superreview?(dbaron)
Attachment #341642 -
Flags: superreview+
Attachment #341642 -
Flags: review?(dbaron)
Attachment #341642 -
Flags: review+
Assignee | ||
Comment 12•16 years ago
|
||
> Is there enough benefit to Clear-ing an existing namespace map rather than
> creating a new one
I doubt it. I'll make that change.
Assignee | ||
Comment 13•16 years ago
|
||
Attachment #341642 -
Attachment is obsolete: true
Assignee | ||
Comment 14•16 years ago
|
||
Fixed. Still not sure about the best way forward here on tests...
Flags: in-testsuite?
I think it should be relatively straightforward to set up mochitests for this. It's perhaps a little additional work to write a framework, but once it's there the cost per test would be a good bit lower than reftests, since it would all be in one file. (See, e.g., test_selectors.html, test_media_queries.html, or test_parse_rule.html .)
Assignee | ||
Comment 16•16 years ago
|
||
Oh, pushed as changeset 3143e3a43176.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 17•16 years ago
|
||
Attachment #345249 -
Flags: superreview?(dbaron)
Attachment #345249 -
Flags: review?(dbaron)
Attachment #345249 -
Flags: superreview?(dbaron)
Attachment #345249 -
Flags: superreview+
Attachment #345249 -
Flags: review?(dbaron)
Attachment #345249 -
Flags: review+
Comment on attachment 345249 [details] [diff] [review] Test plus fix for the bug in this patch it caught (*|foo being reserialized as foo if the default namespace is "") >+ (!aIsNegated || (!mIDList && !mClassList && !mPseudoClassList && !mAttrList))) Maybe condense this into a private method DefaultNamespaceApplies(PRBool aIsNegated)? Or maybe NamespacesPossible? It's really saying both: * whether the default namespace applies * whether it's possible to specify a namespace I'm not sure what a good name for the method is, given that it's both of those. { >+ // We have the default namespace (possibly including the wildcard >+ // namespace). Do nothing. Note that we need the !aIsNegated, >+ // etc. because default namespaces declarations do not affect negated >+ // selectors that are not type or universal. >+ } else if (mNameSpace != kNameSpaceID_Unknown) { It seems like instead of checking the default-namespace-applies condition in the previous else, you could assert that it does in this one. Or am I missing something? As far as the tests, I didn't know that setting innerHTML worked in XHTML. But I guess it's good that it does. Could I talk you into adding some tests for :not(), with '*', 'test', and '[attr]' as arguments to the :not(), testing that default namespaces apply to the argument of the not in the first two cases but not the third? The ensuing serialization tests should exercise this code a bit... r+sr=dbaron
Assignee | ||
Comment 19•16 years ago
|
||
> It seems like instead of checking the default-namespace-applies condition in
> the previous else, you could assert that it does in this one. Or am I missing
> something?
I spent a bunch of time thinking about this, actually. Doing it that way depends on the current parser behavior where there is no way to end up with a non-unknown mNamespace for a negated non-type selector. I guess that's ok and we just need to remember to fix this code if we ever change parser behavior.
Maybe call the method CanBeNamespaced?
I'll add the tests.
Assignee | ||
Comment 20•16 years ago
|
||
Attachment #345249 -
Attachment is obsolete: true
Assignee | ||
Comment 21•16 years ago
|
||
Comment on attachment 346304 [details] [diff] [review] With the comments addressed It'd be good to get this serialization snafu fix tested in the beta. The tests cover all these codepaths (and in fact were what caught the problem the code change is fixing).
Attachment #346304 -
Flags: approval1.9.1b2?
Comment 22•16 years ago
|
||
Comment on attachment 346304 [details] [diff] [review] With the comments addressed a=beltzner, this is already marked FIXED though? Confusing!
Attachment #346304 -
Flags: approval1.9.1b2? → approval1.9.1b2+
Assignee | ||
Comment 23•16 years ago
|
||
Sorry, about that. The bug as originally filed is fixed; this patch was just the tests plus one followup fix for an issue that the tests caught.
Assignee | ||
Comment 24•16 years ago
|
||
Pushed changeset da28a31fff2a.
Flags: in-testsuite? → in-testsuite+
You need to log in
before you can comment on or make changes to this bug.
Description
•