-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix resizeMode="cover" when image is resized #1273
Conversation
8ec794c
to
5639b8e
Compare
5639b8e
to
13f0380
Compare
@mischreiber > Does this change look good to you? |
"Needs attention" label here means that we (Microsoft, aka @mischreiber) will take a deeper look. No changes requested from the PR author yet. |
13f0380
to
7274a06
Compare
Anything needed from our side to get this change landed? |
7274a06
to
ed6a7fb
Compare
@mischrieber had wanted to take a deeper look, but is also currently OOF. Is this is blocking other changes from making their way through, we can prioritize this one over others. Come to think of it, it probably takes priority by default on account of being "older" than the others.. |
Since `RCTResizeModeCover` is implemented manually on macOS (iOS benefits from `UIViewContentModeScaleAspectFill` API), we need to reprocess the image any time the bounds of the view update. The `updateImage:` method was already called on resize, so this instead stores the original image in an ivar so it can call `RCTFillImagePreservingAspectRatio` from `updateImage:` instead.
This fixes a regression introduced by the previous commit, where images would no longer render with the `tintColor` on release builds. We must call `setTemplate:` (using `.template` property is illegal in Objective-C++ since `template` is reserved in C++) on the newly resized image instead of the original image. Confirmed icons look correct in the release build of Messenger Desktop.
ed6a7fb
to
d2b375f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to go ahead and also approve this. It's an old enough , simple PR that I'd rather not linger. We can back it out if it causes issues, @mischreiber FYI
* Fix resizeMode="cover" when image is resized Since `RCTResizeModeCover` is implemented manually on macOS (iOS benefits from `UIViewContentModeScaleAspectFill` API), we need to reprocess the image any time the bounds of the view update. The `updateImage:` method was already called on resize, so this instead stores the original image in an ivar so it can call `RCTFillImagePreservingAspectRatio` from `updateImage:` instead. * Fix rendering template images with tintColor This fixes a regression introduced by the previous commit, where images would no longer render with the `tintColor` on release builds. We must call `setTemplate:` (using `.template` property is illegal in Objective-C++ since `template` is reserved in C++) on the newly resized image instead of the original image. Confirmed icons look correct in the release build of Messenger Desktop. Co-authored-by: Scott Kyle <[email protected]>
* Fix resizeMode="cover" when image is resized Since `RCTResizeModeCover` is implemented manually on macOS (iOS benefits from `UIViewContentModeScaleAspectFill` API), we need to reprocess the image any time the bounds of the view update. The `updateImage:` method was already called on resize, so this instead stores the original image in an ivar so it can call `RCTFillImagePreservingAspectRatio` from `updateImage:` instead. * Fix rendering template images with tintColor This fixes a regression introduced by the previous commit, where images would no longer render with the `tintColor` on release builds. We must call `setTemplate:` (using `.template` property is illegal in Objective-C++ since `template` is reserved in C++) on the newly resized image instead of the original image. Confirmed icons look correct in the release build of Messenger Desktop. Co-authored-by: Scott Kyle <[email protected]>
Summary: X-link: facebook/yoga#1273 1. Simplify nan handling a bit 2. Remove string literal operators which seem dead enough to remove. These are public, so anyone could be using them, but it seems like almost nobody is. 1. FB has no usages of `using namespace facebook::yoga::literals` (exposing the literal operators) outside of Yoga tests. 1. There is only [a single usage](https://github.com/XITRIX/UIKit/blob/6dfba905ea83c89e255144f7ed90fde8c33ca81a/SDLTest/UIKit.hpp#L19) on GitHub. Differential Revision: D45419970 fbshipit-source-id: 88b95a21ec643ba54e610ec57633f5dd104a30a6
Please select one of the following
Since
RCTResizeModeCover
is implemented manually on macOS (iOS benefits fromUIViewContentModeScaleAspectFill
API), we need to reprocess the image any time the bounds of the view update. TheupdateImage:
method was already called on resize, so this instead stores the original image in an ivar so it can callRCTFillImagePreservingAspectRatio
fromupdateImage:
instead.Changelog
[macOS] [Fixed] - Fix resizeMode="cover" when image is resized
Test Plan
Before
Look at the images labeled 'Cover' and observe how they don't properly resize
resizeBefore.mov
After
resizeAfter.mov
Before
Another demo, done internally
resizeBefore1.mov
After
resizeAfter2_.mov