Bug 7430 - Invalid opacity values are treated incorrectly
Summary: Invalid opacity values are treated incorrectly
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-23 10:51 PST by Brad Fults
Modified: 2007-01-06 16:06 PST (History)
2 users (show)

See Also:


Attachments
Test case: simple fader. (1.74 KB, text/html)
2006-02-23 10:52 PST, Brad Fults
no flags Details
reduced test case (553 bytes, text/html)
2006-05-02 05:32 PDT, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brad Fults 2006-02-23 10:51:17 PST
CSS styles exposed through the DOM should be treated as numbers (floats specifically) when the style takes a unitless float value.

A simple example of this is opacity:

el.style.opacity = 0.3; //works fine
el.style.opacity = 1.3877787807814457e-16; // fails -- Webkit invalidates the style altogether (yielding opacity == 1.0)

This will also fail for values specified in octal or hexadecimal, as they are treated as strings.

This does work as expected in Firefox 1.5 (converting the numbers), however.
Comment 1 Brad Fults 2006-02-23 10:52:05 PST
Created attachment 6681 [details]
Test case: simple fader.
Comment 2 Alexey Proskuryakov 2006-05-02 05:32:55 PDT
Created attachment 8069 [details]
reduced test case
Comment 3 Alexey Proskuryakov 2006-05-02 05:39:09 PDT
Trying to set the opacity to an invalid value such as 1e-16 has no effect in Firefox, but resets it in Safari. I'm not quite sure about what constitutes an invalid value, but the issue doesn't look like related to strings to me.
Comment 4 Brad Fults 2006-05-02 06:01:50 PDT
The so-called "invalid value" is a valid Number literal in JS. I suppose whether it's an "invalid value" depends entirely on whether the DOM as bound to by JS is supposed to only accept numbers in a specific format (decimal) or if any JS Number should be converted to a value suitable for DOM assignment.
Comment 5 Alexey Proskuryakov 2007-01-06 16:06:04 PST
(In reply to comment #4)
> The so-called "invalid value" is a valid Number literal in JS.

That's correct, but then it's converted back to a string and passed to CSS parser, which doesn't understand scientific notation.

The problem with handling invalid values has been recently fixed, see bug 7296. The test case now works just like it does in Firefox. We just don't log an error to the console yet, unlike Firefox.