Bug 13802 - Background colors can't be reset to the default color
Summary: Background colors can't be reset to the default color
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 523.x (Safari 3)
Hardware: Macintosh OS X 10.4
: P4 Minor
Assignee: Nobody
URL: http://www.joomlapolis.com/component/...
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-21 15:55 PDT by Beat
Modified: 2007-05-22 18:07 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Beat 2007-05-21 15:55:35 PDT
In all browsers, except Safari and webkit, background colors can be saved and restored.

it looks like if el.style.background.slice(0,3) isn't handled properly ?

To reproduce:

Go to URL specified, go to bottom without filling out anything, hit "Send Registration": all mandatory fields becom red, all is fine there.

Now go to any mandatory field, fill in something, then hit again "Send Registration", you will see that field remains red, while in all other browsers it reverts to background color.

This is done with Javascript on the DOM in the following way:

var cbDefaultFieldBackground;
			if (me[i].value == '') {
				errorMSG +=  blablabla\n';
				if (cbDefaultFieldBackground === undefined) cbDefaultFieldBackground = ((me[i].style.getPropertyValue) ? me[i].style.getPropertyValue("background") : me[i].style.background);
				me[i].style.background = "red";
				iserror=1;
			} elseif (me[i].style.background.slice(0,3)=="red") me[i].style.background = cbDefaultFieldBackground;

Looking forward to a fix, as well as a hint how to make this function work in Safari ;-)

(I'm the author of that form generator ;-) )
Comment 1 Dave Hyatt 2007-05-21 20:35:30 PDT
Confirmed.
Comment 2 Dave Hyatt 2007-05-21 20:39:31 PDT
This is better in TOT in that the background shorthand can now be obtained from style.  It fails still, however, since values of "initial" are being incorrectly dumped into the cssText for the shorthand.
Comment 3 Dave Hyatt 2007-05-21 20:51:11 PDT
This bug basically boils down to getShorthandValue in CSSMutableStyleDeclaration being insufficient to dump the background shorthand.  Because Safari supports CSS3 multiple backgrounds, this is a pretty complicated property to dump.

Right now in the single background property case, we're dumping initial values, because we don't record knowledge that the initial reset happened implicitly in individual background layers.  If we did record this knowledge in each layer, that would at least allow us to get the single background case right.

However, I think it's probably better to just add a new method to CSSMutableStyleDeclaration, e.g., getBackgroundShorthandValue that can properly interleave the values and correctly omit any "initials" in each layer.
Comment 4 Dave Hyatt 2007-05-21 20:53:13 PDT
To the author... you can trivially work around this bug in Safari 2 by using backgroundColor instead of just background.  That will fix your page in all versions of Safari and will still work in other browsers.
Comment 5 Dave Hyatt 2007-05-21 20:54:14 PDT
You also won't have to slice out the "red" result, so it's better code anyway. :)
Comment 6 Beat 2007-05-22 00:40:08 PDT
Yes, thanks for the quick workaround proposal, works on our test-server now :-) , although doesn't take care of eventual background images and other transparency settings ;-) .

Thanks also for taking care of this bug that fast.

Also a small detail on the same code and page (feel free to fork another bug report for that one, but i felt it quite related): it looks like radio buttons and checkboxes (you can see that behavior on the same page in "spoken languages") are not taking in account the background color (red), as most other browsers do.

And Webkit is a *huge* improvement over Safari 2.0. :-) , keep the good work up !
Comment 7 David Kilzer (:ddkilzer) 2007-05-22 05:55:43 PDT
(In reply to comment #6)
> Also a small detail on the same code and page (feel free to fork another bug
> report for that one, but i felt it quite related): it looks like radio buttons
> and checkboxes (you can see that behavior on the same page in "spoken
> languages") are not taking in account the background color (red), as most other
> browsers do.

Beat, could you please file a new bug for this with a small HTML example attached?  Thanks!

Comment 8 Dave Hyatt 2007-05-22 18:07:01 PDT
Fixed in r21652.