Closed
Bug 302971
Opened 19 years ago
Closed 16 years ago
Scientific notation in stroke-width doesnt work
Categories
(Core :: SVG, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: dblasby, Assigned: longsonr)
References
()
Details
Attachments
(3 files, 5 obsolete files)
(deleted),
image/svg+xml
|
Details | |
(deleted),
image/svg+xml
|
Details | |
(deleted),
patch
|
Details | Diff | Splinter Review |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Using stroke-width="0.0005" works, but using stroke-width="5.0E-4" doesnt.
There might be other scientific notation problems elsewhere.
Reproducible: Always
Steps to Reproduce:
1. load the "works.svg" -- you'll get a few things on the screen
2. load the "not_works.svg" -- you'll get a pink screen
3. the only difference between the 2 files is the uses of scientific notation.
Expected Results:
Both should work.
Reporter | ||
Comment 1•19 years ago
|
||
Reporter | ||
Comment 2•19 years ago
|
||
Comment 3•19 years ago
|
||
http://www.w3.org/TR/SVG11/coords.html#Units doesn't say anything about this
http://www.w3.org/TR/CSS21/syndata.html#length-units disallows this
What says that SVG allows that notation?
Comment 4•19 years ago
|
||
Follow the links from http://www.w3.org/TR/SVG/painting.html#StrokeWidthProperty
biesi
Updated•19 years ago
|
Summary: Scientfic notation in stroke-width doesnt work → Scientific notation in stroke-width doesnt work
Reporter | ||
Comment 5•19 years ago
|
||
Okay - This was my mistake, thanks for the feedback. I'm marking this as invalid.
NOTE: scientific notation does work in the adobe plugin, so its likely others
will stumble across this as well (especially for auto-generated GIS, CAD, or
scientific datasets).
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
Comment 6•19 years ago
|
||
I think Comment 4 suggests this is valid. Jonathan, is that the case? should
this be reopened?
Updated•19 years ago
|
Attachment #191220 -
Attachment mime type: image/svg → image/svg+xml
Updated•19 years ago
|
Attachment #191221 -
Attachment mime type: image/svg → image/svg+xml
Comment 7•19 years ago
|
||
Yes, you were right the first time Dave, this is valid. :-)
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Comment 8•19 years ago
|
||
So wait. Is the idea that this is not a property, but is an attribute, so the "For SVG's XML attributes" part applies? What am I missing?
Whatever we do with this bug, SVG needs some major clarification here if I can't tell what the right behavior is....
Comment 9•19 years ago
|
||
My reading is that exponents are allowed in the number/length values of properties when the properties are specified using presentational attributes (for flexibility), but not when specified using a styling language such as CSS (for compatibility (with CSS)).
Comment 10•19 years ago
|
||
Except it's clearly stated that scientific notation is not allowed in properties...
Note that SVG 1.2 tiny is not consistent with this. Perhaps we should send some mail to the WG on this issue?
Assignee | ||
Comment 11•18 years ago
|
||
Sent question to WG:
http://lists.w3.org/Archives/Public/www-svg/2007Jan/0053.html
Assignee | ||
Comment 12•18 years ago
|
||
Assignee: general → longsonr
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #253181 -
Flags: review?(bzbarsky)
Comment 13•18 years ago
|
||
I'm not going to be able to get to this review in the foreseeable future (weeks, at least). Please try David?
Note that there's a patch in the works somewhere to pretty completely rewrite this code, to make it faster, btw. You might want to coordinate with that patch author..
Assignee | ||
Comment 14•18 years ago
|
||
Comment on attachment 253181 [details] [diff] [review]
parse scientific notation in SVG XML properties
(In reply to comment #13)
Changed to dbaron as suggested.
I don't know which bug is the rewrite. A search on CSS Parse was unrevealing.
Attachment #253181 -
Flags: review?(bzbarsky) → review?(dbaron)
Comment 15•18 years ago
|
||
A search on bugs in "Style System" with the "perf" keyword doesn't give that many results. Bug 311566 is the one you want.
Comment 16•18 years ago
|
||
Comment on attachment 253181 [details] [diff] [review]
parse scientific notation in SVG XML properties
Could you remove the mSVGMode member from nsCSSParser, add GetSVGMode to both nsCSSParser and nsCSSScanner (both inline), and make SetSVGMode on nsCSSScanner be inline as well?
Where does the SVG spec say that exponential notation is allowed? In particular, on what values is it allowed? I'm surprised to see that you're monkeying with the code to set mIntegerValid, but whether you should do that depends on what the spec says. I also can't really review the parsing code without knowing what it's trying to parse.
Is there a grammatical production for what the spec says should be accepted for exponential notation? If not, what do other implementations accept and not accept? You should add tests for both acceptance and rejection cases.
Sorry I took so long to get to this.
Attachment #253181 -
Flags: review?(dbaron) → review-
Comment 17•18 years ago
|
||
Er, I found the part of the spec in http://www.w3.org/TR/SVG/types.html#BasicDataTypes . Since <integer> is unchanged from CSS, it's pretty clear you shouldn't be changing the mIntegerValid code.
Comment 18•18 years ago
|
||
This patch also seems like it is not be pushing back sufficient characters in the failure cases (such as "3.0em" -- the e needs to be the next character to read after reading the number "3.0").
Comment 19•18 years ago
|
||
Although the more interesting failure-to-Pushback cases are cases where you'd incorrectly accept something that should be an error, such as "font-size:3e+".
Assignee | ||
Comment 20•17 years ago
|
||
Note: I'm still checking for gotE in the integerValid code to avoid treating 1e-3 as an integer.
Attachment #266281 -
Flags: review?(dbaron)
Assignee | ||
Updated•17 years ago
|
Attachment #253181 -
Attachment is obsolete: true
Assignee | ||
Comment 21•17 years ago
|
||
previous patch would have accepted -e3 which is not much of a number. Should insist on getting a digit before the e.
Attachment #266281 -
Attachment is obsolete: true
Attachment #266298 -
Flags: review?(dbaron)
Attachment #266281 -
Flags: review?(dbaron)
Assignee | ||
Comment 22•17 years ago
|
||
digit check not required after all as caller ensures that a digit is present before and e.
Apologies for all the spam due to the multiple attempts.
Attachment #266298 -
Attachment is obsolete: true
Attachment #266349 -
Flags: review?(dbaron)
Attachment #266298 -
Flags: review?(dbaron)
Updated•17 years ago
|
Flags: in-testsuite?
Comment 23•17 years ago
|
||
Comment on attachment 266349 [details] [diff] [review]
hopefully final update
> // Gather up characters that make up the number
> PRUint8* lexTable = gLexTable;
>+ PRBool gotE = PR_FALSE;
> for (;;) {
> c = Read(aErrorCode);
> if (c < 0) break;
>- if (!gotDot && (c == '.') &&
>+ if (!gotDot && !gotE && (c == '.') &&
> CheckLexTable(Peek(aErrorCode), IS_DIGIT, lexTable)) {
> gotDot = PR_TRUE;
>+#ifdef MOZ_SVG
>+ } else if (!gotE && (c == 'e' || c == 'E')) {
>+ if (!IsSVGMode()) break;
Please put the break on its own line, with braces around it.
>+ PRInt32 nextChar = Peek(aErrorCode);
>+ PRInt32 sign = 0;
>+ if (nextChar == '-' || nextChar == '+') {
>+ sign = Read(aErrorCode);
>+ nextChar = Peek(aErrorCode);
>+ }
>+ if (CheckLexTable(nextChar, IS_DIGIT, lexTable)) {
>+ gotE = PR_TRUE;
>+ if (sign) {
>+ ident.Append(PRUnichar(c));
>+ c = sign;
>+ }
>+ } else {
>+ if (sign) {
>+ Unread();
>+ }
>+ break;
>+ }
>+#endif
> } else if ((c > 255) || ((lexTable[c] & IS_DIGIT) == 0)) {
> break;
> }
> ident.Append(PRUnichar(c));
> }
A bit later, there's code:
// Put back character that stopped numeric scan
Unread();
and Unread() can't be called twice. You'll need to convert things to Pushback().
>
>+#ifdef MOZ_SVG
>+ if (!gotDot && !gotE) {
>+#else
> if (!gotDot) {
>+#endif
No need for the ifdefs -- gotE is defined (and always false) when MOZ_SVG is not defined. Just make the change.
(This pattern occurs twice.)
>Index: nsCSSScanner.h
>+ NS_ASSERTION(aSVGMode == PR_TRUE || aSVGMode == PR_FALSE, "bad PRBool value");
Please wrap at <80 characters.
This is pretty complicated and hard-to-review code. Do you have testcases (for both the new feature and other code you're touching)? Could you add them as a mochitest, as part of the patch?
Attachment #266349 -
Flags: review?(dbaron) → review-
Assignee | ||
Comment 24•17 years ago
|
||
Addressed review comments.
I couldn't figure out how to get mochitests to work so I did some reftests instead.
Attachment #266349 -
Attachment is obsolete: true
Attachment #290222 -
Flags: review?(dbaron)
Comment 25•17 years ago
|
||
What part of the test documentation was unclear? We should fix it, if it's bad enough that people can't figure it out.
Comment 26•16 years ago
|
||
Comment on attachment 290222 [details] [diff] [review]
address review comments
r+sr=dbaron.
Sorry about taking so long to get to this, again. In the future, feel free to bug me if I miss something for this long.
Attachment #290222 -
Flags: superreview+
Attachment #290222 -
Flags: review?(dbaron)
Attachment #290222 -
Flags: review+
Assignee | ||
Comment 27•16 years ago
|
||
Updated to tip and reftests converted to mochitests with extra ex and em tests
Attachment #290222 -
Attachment is obsolete: true
Assignee | ||
Comment 28•16 years ago
|
||
Checked in 6276d0c9a49d.
Status: ASSIGNED → RESOLVED
Closed: 19 years ago → 16 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Assignee | ||
Comment 29•16 years ago
|
||
I had to remove the ex tests as they didn't work on Mac. The em test is still in though so there is still a test for a unit beginning with an e.
You need to log in
before you can comment on or make changes to this bug.
Description
•