Skip to content

Commit 874bd4e

Browse files
Saadnajmisahrens
andauthored
[0.66] Cherry pick Transforms fix and CI fix (#1058)
* Fix transforms (#1035) * fix transforms #280 * remove duplicate * fix errors * Update from PR feedback Co-authored-by: Spencer Ahrens <[email protected]> * Disable failing CircleCI test (#1052) * Disable circleci test * Disable another test Co-authored-by: Spencer Ahrens <[email protected]>
1 parent ad5f709 commit 874bd4e

File tree

5 files changed

+43
-25
lines changed

5 files changed

+43
-25
lines changed

.circleci/config.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ jobs:
336336
- run:
337337
name: "Run Tests: JavaScript Tests"
338338
command: node ./scripts/run-ci-javascript-tests.js --maxWorkers 2
339-
- run_e2e:
340-
platform: js
339+
# TODO(macOS GH#949): Disable this failing test
340+
# - run_e2e:
341+
# platform: js
341342

342343
# Optionally, run disabled tests
343344
- when:
@@ -823,11 +824,12 @@ workflows:
823824
# run_detox_tests: true
824825
# requires:
825826
# - setup_ios
826-
- test_js:
827-
name: test_js_prev_lts
828-
executor: nodeprevlts
829-
requires:
830-
- setup_js
827+
# TODO(macOS GH#949): Disable this failing test
828+
# - test_js:
829+
# name: test_js_prev_lts
830+
# executor: nodeprevlts
831+
# requires:
832+
# - setup_js
831833
- test_docker:
832834
filters:
833835
branches:

React/Views/RCTView.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ extern const UIAccessibilityTraits SwitchAccessibilityTrait;
128128
/**
129129
* macOS Properties
130130
*/
131+
132+
@property (nonatomic, assign) CATransform3D transform3D;
133+
131134
@property (nonatomic, copy) RCTDirectEventBlock onDoubleClick;
132135
@property (nonatomic, copy) RCTDirectEventBlock onClick;
133136
@property (nonatomic, copy) RCTDirectEventBlock onMouseEnter;

React/Views/RCTView.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ - (instancetype)initWithFrame:(CGRect)frame
162162
_borderBottomEndRadius = -1;
163163
_borderStyle = RCTBorderStyleSolid;
164164
_hitTestEdgeInsets = UIEdgeInsetsZero;
165+
#if TARGET_OS_OSX // TODO(macOS GH#774)
166+
_transform3D = CATransform3DIdentity;
167+
#endif // TODO(macOS GH#774)
165168

166169
_backgroundColor = super.backgroundColor;
167170
}
@@ -1169,6 +1172,19 @@ - (void)displayLayer:(CALayer *)layer
11691172
backgroundColor = _backgroundColor.CGColor;
11701173
#endif
11711174

1175+
#if TARGET_OS_OSX // [TODO(macOS GH#1035)
1176+
CATransform3D transform = [self transform3D];
1177+
CGPoint anchorPoint = [layer anchorPoint];
1178+
if (CGPointEqualToPoint(anchorPoint, CGPointZero) && !CATransform3DEqualToTransform(transform, CATransform3DIdentity)) {
1179+
// https://developer.apple.com/documentation/quartzcore/calayer/1410817-anchorpoint
1180+
// This compensates for the fact that layer.anchorPoint is {0, 0} instead of {0.5, 0.5} on macOS for some reason.
1181+
CATransform3D originAdjust = CATransform3DTranslate(CATransform3DIdentity, self.frame.size.width / 2, self.frame.size.height / 2, 0);
1182+
transform = CATransform3DConcat(CATransform3DConcat(CATransform3DInvert(originAdjust), transform), originAdjust);
1183+
// Enable edge antialiasing in perspective transforms
1184+
[layer setAllowsEdgeAntialiasing:!(transform.m34 == 0.0f)];
1185+
}
1186+
[layer setTransform:transform];
1187+
#endif // ]TODO(macOS GH#1035)
11721188
if (useIOSBorderRendering) {
11731189
layer.cornerRadius = cornerRadii.topLeft;
11741190
layer.borderColor = borderColors.left;

React/Views/RCTViewManager.m

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,16 @@ - (RCTShadowView *)shadowView
215215

216216
RCT_CUSTOM_VIEW_PROPERTY(transform, CATransform3D, RCTView)
217217
{
218-
#if !TARGET_OS_OSX // TODO(macOS GH#774)
218+
#if TARGET_OS_OSX // [TODO(macOS GH#460)
219+
CATransform3D transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;
220+
[view setTransform3D:transform];
221+
[view setNeedsDisplay];
222+
#else // ]TODO(macOS GH#460)]
219223
view.layer.transform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.transform;
220-
// Enable edge antialiasing in perspective transforms
221-
view.layer.allowsEdgeAntialiasing = !(view.layer.transform.m34 == 0.0f);
222-
#elif TARGET_OS_OSX // [TODO(macOS GH#774)
223-
view.layer.sublayerTransform = json ? [RCTConvert CATransform3D:json] : defaultView.layer.sublayerTransform;
224-
// TODO: Improve this by enabling edge antialiasing only for transforms with rotation or skewing
225-
view.layer.edgeAntialiasingMask = !CATransform3DIsIdentity(view.layer.sublayerTransform) ? kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge : 0;
226-
#endif // ]TODO(macOS GH#774)
224+
// Enable edge antialiasing in rotation, skew, or perspective transforms
225+
view.layer.allowsEdgeAntialiasing =
226+
view.layer.transform.m12 != 0.0f || view.layer.transform.m21 != 0.0f || view.layer.transform.m34 != 0.0f;
227+
#endif // [TODO(macOS GH#460)]
227228
}
228229

229230
RCT_CUSTOM_VIEW_PROPERTY(accessibilityRole, UIAccessibilityTraits, RCTView)

scripts/run-ci-e2e-tests.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,12 @@ try {
280280
exitCode = 1;
281281
throw Error(exitCode);
282282
}
283-
// [TODO(macOS GH#949)
284-
// Comment out failing test to unblock CI
285-
// It seems It's running the flow checks against react-native-macos 0.63 instead of what is in the repo causing a failure
286-
// describe('Test: Flow check');
287-
// if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {
288-
// echo('Flow check failed.');
289-
// exitCode = 1;
290-
// throw Error(exitCode);
291-
// }
292-
// ]TODO(macOS GH#949)
283+
describe('Test: Flow check');
284+
if (exec(`${ROOT}/node_modules/.bin/flow check`).code) {
285+
echo('Flow check failed.');
286+
exitCode = 1;
287+
throw Error(exitCode);
288+
}
293289
}
294290
exitCode = 0;
295291
} finally {

0 commit comments

Comments
 (0)