Closed Bug 475191 Opened 16 years ago Closed 15 years ago

bgcolor="lightred" mysteriously comes out blue (quirks mode color parsing)

Categories

(Core :: CSS Parsing and Computation, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: kes-kes, Unassigned)

References

()

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 if I set color = lightred it displayed as blue Reproducible: Always Steps to Reproduce: <table border=1> <tr bgcolor='lightred'> <td> HELLO </table> Actual Results: display blue Expected Results: display red
Attached file test case
I see this as well, but I'm sure it's a bug in our graphic drivers (there are some with red/blue issues), because the color is blue in Fx, IE and Safari (Opera is black). Please try wether this happens for you in other browsers (Internet Explorer, Opera or whatever you got installed) as well.
I guess Firefox is treating the letters in "lightred" as hex, and somehow it comes out as equivalent to #0000ed despite the extra letters. If you use a standards-mode doctype, Firefox won't try to do that, and will simply ignore the invalid bgcolor ;)
The comments at http://nedbatchelder.com/blog/200701/color_parsing_brainteaser.html explain what's going on pretty well: Firefox is happy to accept not only #rgb and #rrggbb but also #rrrgggbbb and #rrrrggggbbbb. http://mxr.mozilla.org/mozilla-central/ident?i=NS_LooseHexToRGB I have no idea why, though! This code pretty much hasn't changed since 1999, and the checkins around that time did not include bug numbers: http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/gfx/src/nsColor.cpp I guess I should be happy that Firefox, IE, and Safari all do the same thing.
Component: General → HTML: Parser
Product: Firefox → Core
QA Contact: general → parser
Version: unspecified → Trunk
Summary: wrong display color → bgcolor="lightred" mysteriously comes out blue
Summary: bgcolor="lightred" mysteriously comes out blue → bgcolor="lightred" mysteriously comes out blue (quirks mode color parsing)
HTML5 will probably standardize something, since color parsing with a missing "#" is an important quirk: <Hixie> the idea is for the spec to be a complete description of how to implement a user agent (web browser, command line tool, search engine, whatever) in a manner that is compatible with existing content <Hixie> so that no implementor ever feels the need to do anything not in the spec for compatibility http://simon.html5.org/specs/html-color-attributes http://simon.html5.org/test/html/rendering/color-attributes/ I don't think it's worth changing anything until that spec materializes.
If you really want 'lightred' to work as a color name you could just include it in the list of color names that firefox recognizes. Just specify an RGB value for light red and stick it in the list. http://mxr.mozilla.org/mozilla-central/source/gfx/public/nsColorNameList.h
It seems that Firefox is taking the string 'lightred' and treating it as a loose hex. So basically, it's not only light red that does this but also if you put other strings like 'lightaxb' which would still give you a color. So if you want to change the way Firefox handles the parsing of the color, you can modify the nsAttrValue.cpp file, where you can easily change it so it would ignore incorrect colors. http://mxr.mozilla.org/mozilla-central/source/content/base/src/nsAttrValue.cpp
Confirming, but not an HTML parser bug.
Status: UNCONFIRMED → NEW
Component: HTML: Parser → DOM
Ever confirmed: true
QA Contact: parser → general
Component: DOM → Style System (CSS)
QA Contact: general → style-system
lightred isn't a color name defined by any specification as far as I can tell.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
I wouldn't say INVALID. data:text/html,<table border=1><tr bgcolor='lightred'><td> HELLO</table> this makes a blue bg data:text/html,<table border=1><tr bgcolor='lightgreen'><td> HELLO</table> makes a light green bg data:text/html,<table border=1><tr bgcolor='lightblue'><td> HELLO</table> makes a light blue bg Some don't work (eg lightbrown). But the common denominator of all values that don't work is that the bg is black. Why should "lightred" produce a dark blue bg? PS FYI "lightblack" also produces a dark blue, a slightly darker shade than "lightred" does.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
The complete list of light-* colors is listed in CSS3COLOR <http://www.w3.org/TR/css3-color/>: lightcoral, lightcyan, lightgoldenrodyellow, lightgray, lightgreen, lightgrey, lightpink, lightsalmon, lightseagreen, lightskyblue, lightslategray, lightslategrey, lightsteelblue and lightyellow. Supporting any others is a bug. If you want to add lightred to that list, you can suggest it on <www-style@w3.org>.
Status: REOPENED → RESOLVED
Closed: 15 years ago15 years ago
Resolution: --- → INVALID
(In reply to comment #10) > Some don't work (eg lightbrown). But the common denominator of all values that > don't work is that the bg is black. [SNIP] > PS FYI "lightblack" also produces a dark blue, a slightly darker shade than > "lightred" does. See comment 7 for an explanation of why the invalid color names end up producing the color values you observed.
Status: RESOLVED → REOPENED
Resolution: INVALID → ---
This is probably a duplicate, but I wouldn't call it invalid. We *are* doing something with that color, and the thing in question that we're doing is unexpected.
Depends on: 121738
With bug 121738 fixed "lightred" stays blue and matches IE and WebKit. -> INVALID per HTML5 spec and browser compatibility.
Status: REOPENED → RESOLVED
Closed: 15 years ago15 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: