Closed Bug 372782 Opened 17 years ago Closed 17 years ago

add alpha-component rounding to computed style code

Categories

(Core :: DOM: CSS Object Model, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dbaron, Assigned: dbaron)

References

Details

Attachments

(1 file)

To the code from bug 347912 we should add rounding as done in the patch to bug 372770 so that we don't output over-precise alpha components.
Steps to reproduce:
 1. load attachment 257575 [details].
 2. look at the last cell of the last line

Expected results: rgba(128, 17, 41, 0.7)

Actual results: rgba(128, 17, 41, 0.701961)
Attached patch patchSplinter Review
This adds the functions going both directions to nsStyleUtil so that the relationship is clearer to future maintainers.
Attachment #257588 - Flags: superreview?(bzbarsky)
Attachment #257588 - Flags: review?(bzbarsky)
Although, it occurs to me that perhaps people will want to do math more often on computed style output, and perhaps we should just leave the computed style code alone, take the rest of the patch, and wontfix this bug.  Thoughts?
Comment on attachment 257588 [details] [diff] [review]
patch

>+nsStyleUtil::ColorComponentToFloat(PRUint8 aAlpha)
>+  if (NSToIntRound(rounded * 255.0f) != aAlpha) {

FloatToColorComponent() here?

I think this is reasonable to do... I doubt people are that much more likely to do math on the computed style, really.
Attachment #257588 - Flags: superreview?(bzbarsky)
Attachment #257588 - Flags: superreview+
Attachment #257588 - Flags: review?(bzbarsky)
Attachment #257588 - Flags: review+
Checked in to trunk with above change.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
Depends on: 379316
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: