Skip to content

Fix issue #8: ColorType(int,int,int,int) sign-extends on high alpha - #36

Merged
Thrameos merged 1 commit into
masterfrom
backport/colortype-alpha-sign-extend
Sep 6, 2026
Merged

Thrameos merged 1 commit into
masterfrom
backport/colortype-alpha-sign-extend

Conversation

@Thrameos

@Thrameos Thrameos commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Closes #8

Summary

  • CefSettings.ColorType's packing constructor computed the ARGB value entirely in 32-bit int arithmetic, then relied on implicit widening to store it into the long color_value field.
  • When alpha >= 0x80, the intermediate int result's sign bit was set, so Java's implicit int -> long widening sign-extended it, leaving color_value's upper 32 bits all set to 1 instead of the plain unsigned 32-bit ARGB value the field's own Javadoc describes.
  • Fixed by packing in long-typed arithmetic and masking to 32 bits.

Test plan

  • Added CefSettingsTest (colorTypeHighAlphaDoesNotSignExtend, colorTypeLowAlpha) as a regression test — verified both pass post-fix.
  • Compiled and ran standalone via the JUnit console launcher (no native rebuild needed — pure Java value-object change).

This is a small, focused backport of a single self-contained fix (no other changes bundled in), following the same shape as PR #1.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HBFmQs6JDypYP5qdC99yDq

@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.06%. Comparing base (be68fe1) to head (d4a4169).

Additional details and impacted files
@@             Coverage Diff              @@
##             master      #36      +/-   ##
============================================
+ Coverage     38.01%   38.06%   +0.05%     
  Complexity      735      735              
============================================
  Files           243      244       +1     
  Lines         14863    14872       +9     
  Branches       2449     2449              
============================================
+ Hits           5650     5661      +11     
+ Misses         8011     8007       -4     
- Partials       1202     1204       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Packed ARGB components via 32-bit int arithmetic and only then widened
to the long-typed color_value field. With alpha >= 0x80 the packed int
was negative, and Java's implicit int->long widening sign-extended it,
so getColor() returned a value with the long's upper 32 bits all set to
1 instead of the plain unsigned 32-bit ARGB value the field's own
Javadoc describes. Fixed by packing in long-typed arithmetic and
masking to 32 bits.

Adds CefSettingsTest as a regression test.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HBFmQs6JDypYP5qdC99yDq
@Thrameos
Thrameos force-pushed the backport/colortype-alpha-sign-extend branch from b2c2c05 to d4a4169 Compare September 5, 2026 21:23
@Thrameos Thrameos added the bug Something isn't working label Sep 6, 2026
@Thrameos
Thrameos merged commit a5e869a into master Sep 6, 2026
9 checks passed
@Thrameos
Thrameos deleted the backport/colortype-alpha-sign-extend branch September 6, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CefSettings.ColorType: alpha >= 0x80 sign-extends into a negative long, not the intended unsigned ARGB value

1 participant