add alpha-component rounding to computed style code

RESOLVED FIXED

Status

()

RESOLVED FIXED
12 years ago
12 years ago

People

(Reporter: dbaron, Assigned: dbaron)

Tracking

Trunk
Points:
---
Bug Flags:
in-testsuite ?

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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)
Created attachment 257588 [details] [diff] [review]
patch

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
Last Resolved: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.