Closed Bug 1514464 Opened 5 years ago Closed 5 years ago

Clamp selection color value between 0 and 255 in nsLookAndFeel.mm

Categories

(Core :: Widget: Cocoa, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla66
Tracking Status
firefox-esr60 --- unaffected
firefox64 --- unaffected
firefox65 --- fixed
firefox66 --- fixed

People

(Reporter: ntim, Assigned: ntim)

References

Details

Attachments

(1 file)

(In reply to Markus Stange [:mstange] from bug 1513401 comment #12)
> > +    value = 255 - (255 - value) * factor;
> 
> I realized a problem in the math: if value is less that 128, this will be
> 255 - [something larger than 255], which will be negative and then
> wraparound into a large uint16_t value when assigned to "value". So I think
> the "(255 - value) * factor" part should be wrapped in a
> mozilla::clamped(..., 0, 255).
> 
> This is not that urgent to fix because macOS does not, as far as I know,
> have gray highlighting colors that are darker than 128. But it should still
> be fixed.
Assignee: nobody → ntim.bugs
Might as well take this on Beta as well since bug 1514464 is being uplifted there.
Pushed by ntim.bugs@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/655c49c71be0
Clamp selection color value between 0 and 255 in nsLookAndFeel.mm. r=mstange
Comment on attachment 9031670 [details]
Bug 1514464 - Clamp selection color value between 0 and 255 in nsLookAndFeel.mm. r=mstange

[Beta/Release Uplift Approval Request]

Feature/Bug causing the regression: Bug 1513401

User impact if declined: None, just makes the code more sane in case the OS changes the provided selection color

Is this code covered by automated tests?: No

Has the fix been verified in Nightly?: No

Needs manual test from QE?: No

If yes, steps to reproduce: 

List of other uplifts needed: None

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): low risk, one line cocoa change

String changes made/needed:
Attachment #9031670 - Flags: approval-mozilla-beta?
https://hg.mozilla.org/mozilla-central/rev/655c49c71be0
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Comment on attachment 9031670 [details]
Bug 1514464 - Clamp selection color value between 0 and 255 in nsLookAndFeel.mm. r=mstange

[Triage Comment]
Adds a bit of sanity checking to the selection color code in case the OS gives bogus values. Approved for 65.0b5.
Attachment #9031670 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: