Closed
Bug 95336
Opened 23 years ago
Closed 23 years ago
position CSS not recognized without units when element not in document
Categories
(Core :: DOM: CSS Object Model, enhancement)
Tracking
()
RESOLVED
FIXED
mozilla0.9.6
People
(Reporter: arielladog, Assigned: bzbarsky)
References
()
Details
(Keywords: compat, css-moz, Whiteboard: [fix in hand] (py8ieh: file quirky CSSOM parser bug))
Attachments
(6 files, 5 obsolete files)
996 bytes,
patch
|
Details | Diff | Splinter Review | |
361 bytes,
text/html
|
Details | |
1.89 KB,
text/html
|
Details | |
1.94 KB,
text/html
|
Details | |
2.07 KB,
application/xhtml+xml
|
Details | |
14.60 KB,
patch
|
pierre
:
review+
jst
:
superreview+
|
Details | Diff | Splinter Review |
From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90) BuildID: 2001080110 When an element is in the document, when you change a CSS property like top or left without a unit, it defaults to "px" However, when an element is not in the document, and you change a CSS property, such as top or left without the unit, the value is not assigned at all. Reproducible: Always Steps to Reproduce: 1. Dynamically create an element with document.createElement() 2. Assign it's "top" CSS property to a number with no unit appended Actual Results: No value is given to the "top" CSS property for that element Expected Results: "px" should be appended to the value you tried to assign to that element's "top" CSS property, and it should be assigned.
Since it's not legal to leave units off CSS values (please, don't actually make web pages that do this), this is an enhancement request. (I presume it works fine when the units are included.)
Severity: normal → enhancement
Reporter | ||
Comment 2•23 years ago
|
||
Because I assume this should have worked (if they have it working in such a way in the document), I assume it's more of a bug that it doesn't work while not in the document. However, the whole thing (not including units) is an enhancement.
Comment 3•23 years ago
|
||
The bug will be that we are getting the quirks mode from the document of the node instead of getting the document of the nodeinfo of the node. Should be relatively easy to fix. Reassigning to pierre -- pierre, you should be able to fix this in a couple of minutes, it's just a matter of finding the part which does the unit-assumption and then using the code I used in bug 93371 to get the quirks mode.
Comment 5•23 years ago
|
||
Comment 6•23 years ago
|
||
Comment 7•23 years ago
|
||
Shouldn't the check be inside the |else| clause after the result = NS_NewCSSParser(&cssParser); ...line? At the moment, your patch would do weird things to the existing parser if for some reason the mode had been manually switched.
Comment 8•23 years ago
|
||
I hesitated to do it that way but the thing that convinced me otherwise is that it's how GetParserFor() works already: http://lxr.mozilla.org/seamonkey/source/content/html/style/src/ nsCSSLoader.cpp#558
assignee_accessible: 1 → 0
CC list accessible: false
qacontact_accessible: 1 → 0
Not accessible to reporter
Updated•23 years ago
|
assignee_accessible: 0 → 1
CC list accessible: true
qacontact_accessible: 0 → 1
Accessible to reporter
Comment 9•23 years ago
|
||
Fixing database corruption caused by bug 95743. Pay no attention to the man behind the curtain.
Comment 10•23 years ago
|
||
Do you really wanto call SetQuirkMode() if we're in strict mode? Changing: + cssParser->SetQuirkMode(eDTDMode_strict != mode); to: + if (mode != eDTDMode_strict) {+ cssParser->SetQuirkMode(PR_TRUE); + } would avoid the call which I'm guessing is not needed if we're in strict mode, no? Your call, sr=jst either way.
Comment 11•23 years ago
|
||
I'll leave the code as-is because the real problem is that we don't do similar initializations when we create a parser. In CSSLoaderImpl::GetParserFor(), regardless of whether the parser is created or re-used, we always call: (*aParser)->SetCaseSensitive(mCaseSensitive); (*aParser)->SetQuirkMode(mNavQuirkMode); (*aParser)->SetCharset(mCharset); I am pretty much sure we should do the same in the other places where we have NS_NewCSSParser(), provided these 3 parameters can be known: http://lxr.mozilla.org/seamonkey/search?string=NS_NewCSSParser I'll look into it and see if it deserves opening a separate bug.
Comment 12•23 years ago
|
||
-> 0.9.4 since there is a fix (r=ianh/sr=jst)
Whiteboard: [fix in hand]
Target Milestone: --- → mozilla0.9.4
a=dbaron on behalf of drivers
Comment 14•23 years ago
|
||
Er, for the record, I never did say r=ianh. But whatever. Pierre: Did you determine if a bug had to be opened for those issues you raised?
Updated•23 years ago
|
Whiteboard: [fix in hand] → [fix in hand] (py8ieh: file quirky CSSOM parser bug)
Comment 15•23 years ago
|
||
Not yet. I guess I'll check in this small patch and move the bug to 0.9.5.
Comment 16•23 years ago
|
||
Fix checked in nsGenericHTMLElement.cpp. Moving the bug to 0.9.5 to check what I described on [2001-08-17 14:45].
Target Milestone: mozilla0.9.4 → mozilla0.9.5
Assignee | ||
Comment 17•23 years ago
|
||
OK... Per mail from Pierre taking this bug. Once the patch to bug 99797 is checked in I'll work on this (the code involved is the same code and at the moment I'd just generate CVS conflicts with myself).... Here's what I've found so far: 1) Whenever we have a document (which we should get from the nodeinfo) we should be able to get a CSS loader. Having a document but no css loader is worthy of asserting and returning an error (per conversation with jst). 2) Getting a parser from the CSS loader will set the quirks mode and case-sensitivity correctly. It will _not_ set the charset correctly unless the charset of the CSS loader is first set. 3) nodeinfo can have a null document pointer if the document that created an object no longer exists. In this case we should just create a new css parser using NS_NewCSSParser. If we do this we have no good way of setting its charset, quirkiness, or case-sensitivity (all that information comes from the document). If we're in HTML for a fact, we can set the case-sensitivity, but nothing else. 4) The CSS loader holds on to charset values from the last sheet that loaded over http. So the charset value set on a parser by the CSSLoader cannot be trusted. Style sheets should remember their own charset values and set them on the CSS parser in CSSOM operations on CSS rules. 5) Similarly, elements whose style attribute is being modified should have a way of setting the default inline style charset for the document on a parser. Again, per conversation with jst, it seems like a good idea to add a getInlineStyleParser to nsICSSLoader. The CSS loader can then ask the document for the inline charset, do alias translation on it as it already does for sheets loaded over http, and cache it for future use. So I'll hopefully be attaching a patch implementing this within a few days of bug 99797 getting checked in.
Assignee | ||
Comment 18•23 years ago
|
||
Assignee | ||
Comment 19•23 years ago
|
||
The patch I attached tries to get the charsets and other stuff right. In particular: 1) Style sheets store their own charset 2) The CSS loader caches the inline style charset 3) We get the css loader from the right document Possible issues: 1) There is code duplication between ParseDeclaration and ParseProperty. I can create a helper function to reduce the code duplication, but there was a thought to try to handle correctness and simplification separately on this one. This patch is trying for correctness. Pierre, if you feel that I should just go ahead and get rid of the code duplications, let me know. 2) Should the CSS loader check that the default inline style content type is indeed text/css before grabbing the charset from it? It seems to me that there is no way that function can get called if that content type is not text/css
Assignee | ||
Comment 20•23 years ago
|
||
Oh, one more note. That patch depends on the patch in bug 102096....
Comment 21•23 years ago
|
||
1) Go ahead and simplify. 2) If it's not text/css, I think we can't even have a cssLoader - so no need to check.
Assignee | ||
Comment 22•23 years ago
|
||
Assignee | ||
Updated•23 years ago
|
Attachment #51267 -
Attachment is obsolete: true
Assignee | ||
Comment 23•23 years ago
|
||
Pierre, what do you think about that one?
Assignee | ||
Comment 24•23 years ago
|
||
Comment on attachment 51432 [details] [diff] [review] Cleaned-up patch This doesn't do quite the right thing as far as nulling out pointers. Attaching better patch.
Attachment #51432 -
Attachment is obsolete: true
Assignee | ||
Comment 25•23 years ago
|
||
Assignee | ||
Comment 26•23 years ago
|
||
Assignee | ||
Updated•23 years ago
|
Attachment #51992 -
Attachment is obsolete: true
Assignee | ||
Comment 27•23 years ago
|
||
pushing out. Hopefully I can get it all reviewed and stuff during the freeze. :)
Status: NEW → ASSIGNED
Target Milestone: mozilla0.9.5 → mozilla0.9.6
Assignee | ||
Comment 28•23 years ago
|
||
Comment on attachment 52136 [details] [diff] [review] Patch based on some style comments from jst OK. More talking to jst. We _can_ use namespaces to tell whether we're in XHTML. Though that stuff is all pretty messed up.... :)
Attachment #52136 -
Attachment is obsolete: true
Assignee | ||
Comment 29•23 years ago
|
||
Comment 30•23 years ago
|
||
The latest changes make the parser case-sensitive when we are in HTML. It should be the opposite. Note that NamespaceEquals() returns 'true', not NS_OK, when the strings are equal.
Assignee | ||
Comment 31•23 years ago
|
||
The nodeinfo has kNameSpaceID_None as its namespace if we are in HTML. It has kNameSpaceID_HTML if we are in XHTML (or so jst says). So the code as written works correctly. Yes, this is incredibly broken. Yes, this means the namespace in the nodeinfo does not match the namespace the node returns when asked for its namespace. That's why I added the kNameSpaceID_XHTML define. With that, once the mess in nsNameSpaceManager gets sorted out this will still continue working.
Comment 32•23 years ago
|
||
Boris: do you have any testcases for this bug?
Assignee | ||
Comment 33•23 years ago
|
||
Not yet... I've been working on generating some, but I don't know much about charsets to be truthful. Any help on that would be greatly appreciated. I can attach some testcases for quirkiness and case-sensitivity.
Assignee | ||
Comment 34•23 years ago
|
||
Assignee | ||
Comment 35•23 years ago
|
||
Assignee | ||
Comment 36•23 years ago
|
||
What's the bug with charsets that you're trying to fix, and how does this do it? I'd think the character encoding of the HTMLCSSStyleSheet ought to be handled by the HTML parser, I don't see how the HTMLStyleSheet would have issues (although what there would be ought to be handled by the HTML parser), and the CSSStyleSheet's character encoding ought to be handled by the UnicharInputStream. Why should CSSOM operations depend on the charset? Shouldn't the scripting language or the markup language that contains the script already have converted everything to Unicode? Do you have testcases in various charsets and with various @charset rules to show that this is the right thing to do?
Assignee | ||
Comment 38•23 years ago
|
||
OK. I seem to have had a slightly wrong impression of how charsets work in the DOM. A few questions just to clarify things: 1) what's the point of http://lxr.mozilla.org/seamonkey/source/content/html/content/src/nsGenericHTMLElement.cpp#3200 (getting the Content-Style-Type charset in nsGenericHTMLElement::ParseStyleAttribute)? That seems like a fairly expensive operation that we do every time for no reason. 2) I've looked more carefully and the CSS parser does not ever use the charset that's set on it. Is there a reason to set this charset at all? All the charset stuff in this patch is aimed at addressing #2 (setting the charset on the parser to something appropriate), which I assumed was necessary due to the code cited in #1. If it is not in fact necessary, we should just clean this code up not to do all this extra pointless work.
Assignee | ||
Comment 39•23 years ago
|
||
Ok. Looks like the code in nsGenericHTMLElement was checked in as part of the fix in bug 63502. The important part of that fix in that file was that it changed - isCSS = styleType.EqualsIgnoreCase("text/css"); + isCSS = styleType.EqualsIgnoreCase("text/css", 8); I don't see the reason for adding the charset-parsing code there (the result is never used, as far as I can tell).
Assignee | ||
Comment 40•23 years ago
|
||
Comment on attachment 52189 [details] [diff] [review] This should do case-sensitivity better in cases without document. OK. Talked to dbaron a bit . The charset stuff in this patch is pointless since all that data is already in UCS2 by the time we get to it. I'll attach a simplified patch.
Attachment #52189 -
Attachment is obsolete: true
Assignee | ||
Comment 41•23 years ago
|
||
Assignee | ||
Comment 42•23 years ago
|
||
OK. That patch should me much more sane. Reviews?
Comment 43•23 years ago
|
||
Comment on attachment 53516 [details] [diff] [review] Patch to just simplify getting of parsers (and handle case-sensitivity a little more correctly) sr=jst
Attachment #53516 -
Flags: superreview+
Comment 44•23 years ago
|
||
Comment on attachment 53516 [details] [diff] [review] Patch to just simplify getting of parsers (and handle case-sensitivity a little more correctly) r=pierre
Attachment #53516 -
Flags: review+
Assignee | ||
Comment 45•23 years ago
|
||
Checked in. Thanks, all, especially dbaron for his advice and help.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•