Commit 6f744e69 authored by olivierrobin's avatar olivierrobin Committed by Commit bot

Fix: Factor iOS native image loading into a utility function.

[ToolsMenuViewToolsCell imageForImageId:] checked that id was not-zero.
Current implementation DCHECKS.
Add tests.
This is a follow up of https://codereview.chromium.org/2602903002/

TBR=marq

Review-Url: https://codereview.chromium.org/2608693002
Cr-Commit-Position: refs/heads/master@{#440946}
parent a42dab8a
...@@ -359,8 +359,10 @@ NS_INLINE void AnimateInViews(NSArray* views, ...@@ -359,8 +359,10 @@ NS_INLINE void AnimateInViews(NSArray* views,
ToolsMenuButton* button = [[ToolsMenuButton alloc] initWithFrame:CGRectZero]; ToolsMenuButton* button = [[ToolsMenuButton alloc] initWithFrame:CGRectZero];
[button setTranslatesAutoresizingMaskIntoConstraints:NO]; [button setTranslatesAutoresizingMaskIntoConstraints:NO];
[button setImage:NativeReversableImage(imageIds[0][0], reverseForRTL) if (imageIds[0][0]) {
forState:UIControlStateNormal]; [button setImage:NativeReversableImage(imageIds[0][0], reverseForRTL)
forState:UIControlStateNormal];
}
[[button imageView] setContentMode:UIViewContentModeCenter]; [[button imageView] setContentMode:UIViewContentModeCenter];
[button setBackgroundColor:[self backgroundColor]]; [button setBackgroundColor:[self backgroundColor]];
[button setTag:commandID]; [button setTag:commandID];
...@@ -368,14 +370,20 @@ NS_INLINE void AnimateInViews(NSArray* views, ...@@ -368,14 +370,20 @@ NS_INLINE void AnimateInViews(NSArray* views,
SetA11yLabelAndUiAutomationName(button, labelID, name); SetA11yLabelAndUiAutomationName(button, labelID, name);
UIImage* pressedImage = NativeReversableImage(imageIds[0][1], reverseForRTL); if (imageIds[0][1]) {
if (pressedImage) { UIImage* pressedImage =
[button setImage:pressedImage forState:UIControlStateHighlighted]; NativeReversableImage(imageIds[0][1], reverseForRTL);
if (pressedImage) {
[button setImage:pressedImage forState:UIControlStateHighlighted];
}
} }
UIImage* disabledImage = NativeReversableImage(imageIds[0][2], reverseForRTL); if (imageIds[0][2]) {
if (disabledImage) { UIImage* disabledImage =
[button setImage:disabledImage forState:UIControlStateDisabled]; NativeReversableImage(imageIds[0][2], reverseForRTL);
if (disabledImage) {
[button setImage:disabledImage forState:UIControlStateDisabled];
}
} }
return button; return button;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment