react-native-macos 0.73.31 → 0.73.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Text/Text/RCTTextShadowView.mm +32 -10
- package/Libraries/Text/Text/RCTTextView.h +12 -0
- package/Libraries/Text/Text/RCTTextView.mm +155 -0
- package/React/Base/RCTUIKit.h +1 -0
- package/React/Base/RCTVersion.m +1 -1
- package/React/Base/macOS/RCTUIKit.m +30 -0
- package/React/Views/RCTShadowView.h +7 -0
- package/React/Views/RCTShadowView.m +19 -0
- package/React/Views/RCTView.m +0 -23
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/package.json +1 -1
|
@@ -85,16 +85,24 @@
|
|
|
85
85
|
|
|
86
86
|
NSNumber *tag = self.reactTag;
|
|
87
87
|
NSMutableArray<NSNumber *> *descendantViewTags = [NSMutableArray new];
|
|
88
|
-
[
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
NSMutableArray<NSNumber *> *virtualSubviewTags = [NSMutableArray new]; // [macOS]
|
|
89
|
+
|
|
90
|
+
// [macOS - Enumerate embedded shadow views and virtual subviews in one loop
|
|
91
|
+
[textStorage enumerateAttributesInRange:NSMakeRange(0, textStorage.length)
|
|
92
|
+
options:0
|
|
93
|
+
usingBlock:^(NSDictionary<NSAttributedStringKey, id> *_Nonnull attrs, NSRange range, __unused BOOL * _Nonnull stop) {
|
|
94
|
+
id embeddedViewAttribute = attrs[RCTBaseTextShadowViewEmbeddedShadowViewAttributeName];
|
|
95
|
+
if ([embeddedViewAttribute isKindOfClass:[RCTShadowView class]]) {
|
|
96
|
+
RCTShadowView *embeddedShadowView = (RCTShadowView *)embeddedViewAttribute;
|
|
97
|
+
[descendantViewTags addObject:embeddedShadowView.reactTag];
|
|
98
|
+
}
|
|
95
99
|
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
id tagAttribute = attrs[RCTTextAttributesTagAttributeName];
|
|
101
|
+
if ([tagAttribute isKindOfClass:[NSNumber class]] && ![tagAttribute isEqualToNumber:tag]) {
|
|
102
|
+
[virtualSubviewTags addObject:tagAttribute];
|
|
103
|
+
}
|
|
104
|
+
}];
|
|
105
|
+
// macOS]
|
|
98
106
|
|
|
99
107
|
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTUIView *> *viewRegistry) { // [macOS]
|
|
100
108
|
RCTTextView *textView = (RCTTextView *)viewRegistry[tag];
|
|
@@ -113,11 +121,25 @@
|
|
|
113
121
|
[descendantViews addObject:descendantView];
|
|
114
122
|
}];
|
|
115
123
|
|
|
124
|
+
// [macOS
|
|
125
|
+
NSMutableArray<RCTVirtualTextView *> *virtualSubviews = [NSMutableArray arrayWithCapacity:virtualSubviewTags.count];
|
|
126
|
+
[virtualSubviewTags
|
|
127
|
+
enumerateObjectsUsingBlock:^(NSNumber *_Nonnull virtualSubviewTag, NSUInteger index, BOOL *_Nonnull stop) {
|
|
128
|
+
RCTPlatformView *virtualSubview = viewRegistry[virtualSubviewTag];
|
|
129
|
+
if ([virtualSubview isKindOfClass:[RCTVirtualTextView class]]) {
|
|
130
|
+
[virtualSubviews addObject:(RCTVirtualTextView *)virtualSubview];
|
|
131
|
+
}
|
|
132
|
+
}];
|
|
133
|
+
// macOS]
|
|
134
|
+
|
|
116
135
|
// Removing all references to Shadow Views to avoid unnecessary retaining.
|
|
117
136
|
[textStorage removeAttribute:RCTBaseTextShadowViewEmbeddedShadowViewAttributeName
|
|
118
137
|
range:NSMakeRange(0, textStorage.length)];
|
|
119
138
|
|
|
120
|
-
[textView setTextStorage:textStorage
|
|
139
|
+
[textView setTextStorage:textStorage
|
|
140
|
+
contentFrame:contentFrame
|
|
141
|
+
descendantViews:descendantViews
|
|
142
|
+
virtualSubviews:virtualSubviews]; // [macOS]
|
|
121
143
|
}];
|
|
122
144
|
}
|
|
123
145
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#import <React/RCTComponent.h>
|
|
9
9
|
#import <React/RCTEventDispatcher.h> // [macOS]
|
|
10
|
+
#import <React/RCTVirtualTextView.h> // [macOS]
|
|
10
11
|
|
|
11
12
|
#import <React/RCTUIKit.h> // [macOS]
|
|
12
13
|
|
|
@@ -22,6 +23,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
22
23
|
contentFrame:(CGRect)contentFrame
|
|
23
24
|
descendantViews:(NSArray<RCTPlatformView *> *)descendantViews; // [macOS]
|
|
24
25
|
|
|
26
|
+
// [macOS
|
|
27
|
+
- (void)setTextStorage:(NSTextStorage *)textStorage
|
|
28
|
+
contentFrame:(CGRect)contentFrame
|
|
29
|
+
descendantViews:(NSArray<RCTPlatformView *> *)descendantViews
|
|
30
|
+
virtualSubviews:(NSArray<RCTVirtualTextView *> *_Nullable)virtualSubviews;
|
|
31
|
+
// macOS]
|
|
32
|
+
|
|
33
|
+
#if TARGET_OS_OSX // [macOS
|
|
34
|
+
- (NSRect)getRectForCharRange:(NSRange)charRange;
|
|
35
|
+
#endif // macOS]
|
|
36
|
+
|
|
25
37
|
/**
|
|
26
38
|
* (Experimental and unused for Paper) Pointer event handlers.
|
|
27
39
|
*/
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#endif // [macOS]
|
|
13
13
|
|
|
14
14
|
#import <React/RCTAssert.h> // [macOS]
|
|
15
|
+
#import <React/RCTUIManager.h> // [macOS]
|
|
15
16
|
#import <React/RCTUtils.h>
|
|
16
17
|
#import <React/UIView+React.h>
|
|
17
18
|
#import <React/RCTFocusChangeEvent.h> // [macOS]
|
|
@@ -62,6 +63,8 @@
|
|
|
62
63
|
|
|
63
64
|
id<RCTEventDispatcherProtocol> _eventDispatcher; // [macOS]
|
|
64
65
|
NSArray<RCTUIView *> *_Nullable _descendantViews; // [macOS]
|
|
66
|
+
NSArray<RCTVirtualTextView *> *_Nullable _virtualSubviews; // [macOS]
|
|
67
|
+
RCTUIView *_Nullable _currentHoveredSubview; // [macOS]
|
|
65
68
|
NSTextStorage *_Nullable _textStorage;
|
|
66
69
|
CGRect _contentFrame;
|
|
67
70
|
}
|
|
@@ -99,6 +102,7 @@
|
|
|
99
102
|
_textView.layoutManager.usesFontLeading = NO;
|
|
100
103
|
_textStorage = _textView.textStorage;
|
|
101
104
|
[self addSubview:_textView];
|
|
105
|
+
_currentHoveredSubview = nil;
|
|
102
106
|
#endif // macOS]
|
|
103
107
|
RCTUIViewSetContentModeRedraw(self); // [macOS]
|
|
104
108
|
}
|
|
@@ -162,6 +166,20 @@
|
|
|
162
166
|
contentFrame:(CGRect)contentFrame
|
|
163
167
|
descendantViews:(NSArray<RCTPlatformView *> *)descendantViews // [macOS]
|
|
164
168
|
{
|
|
169
|
+
// [macOS - to keep track of virtualSubviews as well
|
|
170
|
+
[self setTextStorage:textStorage
|
|
171
|
+
contentFrame:contentFrame
|
|
172
|
+
descendantViews:descendantViews
|
|
173
|
+
virtualSubviews:nil];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
- (void)setTextStorage:(NSTextStorage *)textStorage
|
|
177
|
+
contentFrame:(CGRect)contentFrame
|
|
178
|
+
descendantViews:(NSArray<RCTPlatformView *> *)descendantViews
|
|
179
|
+
virtualSubviews:(NSArray<RCTVirtualTextView *> *)virtualSubviews
|
|
180
|
+
{
|
|
181
|
+
// macOS]
|
|
182
|
+
|
|
165
183
|
// This lets the textView own its text storage on macOS
|
|
166
184
|
// We update and replace the text container `_textView.textStorage.attributedString` when text/layout changes
|
|
167
185
|
#if !TARGET_OS_OSX // [macOS]
|
|
@@ -204,9 +222,27 @@
|
|
|
204
222
|
[self addSubview:view];
|
|
205
223
|
}
|
|
206
224
|
|
|
225
|
+
_virtualSubviews = virtualSubviews; // [macOS]
|
|
226
|
+
|
|
207
227
|
[self setNeedsDisplay];
|
|
208
228
|
}
|
|
209
229
|
|
|
230
|
+
#if TARGET_OS_OSX // [macOS
|
|
231
|
+
- (NSRect)getRectForCharRange:(NSRange)charRange
|
|
232
|
+
{
|
|
233
|
+
if (_textStorage) {
|
|
234
|
+
NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject;
|
|
235
|
+
NSTextContainer *textContainer = layoutManager.textContainers.firstObject;
|
|
236
|
+
if (layoutManager && textContainer) {
|
|
237
|
+
NSRange glyphRange = [layoutManager glyphRangeForCharacterRange:charRange actualCharacterRange:nullptr];
|
|
238
|
+
return [layoutManager boundingRectForGlyphRange:glyphRange inTextContainer:textContainer];
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return {0, 0, 0, 0};
|
|
243
|
+
}
|
|
244
|
+
#endif // macOS]
|
|
245
|
+
|
|
210
246
|
- (void)drawRect:(CGRect)rect
|
|
211
247
|
{
|
|
212
248
|
[super drawRect:rect];
|
|
@@ -398,6 +434,21 @@
|
|
|
398
434
|
}
|
|
399
435
|
#else // [macOS
|
|
400
436
|
|
|
437
|
+
- (BOOL)hasMouseHoverEvent
|
|
438
|
+
{
|
|
439
|
+
if ([super hasMouseHoverEvent]) {
|
|
440
|
+
return YES;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// We only care about virtual subviews here.
|
|
444
|
+
// Embedded views (e.g., <Text> <View /> </Text>) handle mouse hover events themselves.
|
|
445
|
+
NSUInteger indexOfChildWithMouseHoverEvent = [_virtualSubviews indexOfObjectPassingTest:^BOOL(RCTVirtualTextView *_Nonnull childView, NSUInteger idx, BOOL *_Nonnull stop) {
|
|
446
|
+
*stop = [childView hasMouseHoverEvent];
|
|
447
|
+
return *stop;
|
|
448
|
+
}];
|
|
449
|
+
return indexOfChildWithMouseHoverEvent != NSNotFound;
|
|
450
|
+
}
|
|
451
|
+
|
|
401
452
|
- (NSView *)hitTest:(NSPoint)point
|
|
402
453
|
{
|
|
403
454
|
// We will forward mouse click events to the NSTextView ourselves to prevent NSTextView from swallowing events that may be handled in JS (e.g. long press).
|
|
@@ -412,6 +463,110 @@
|
|
|
412
463
|
return isTextViewClick ? self : hitView;
|
|
413
464
|
}
|
|
414
465
|
|
|
466
|
+
- (NSNumber *)reactTagAtMouseLocationFromEvent:(NSEvent *)event
|
|
467
|
+
{
|
|
468
|
+
NSPoint locationInSelf = [self convertPoint:event.locationInWindow fromView:nil];
|
|
469
|
+
NSPoint locationInInnerTextView = [self convertPoint:locationInSelf toView:_textView]; // This is needed if the parent <Text> view has padding
|
|
470
|
+
return [self reactTagAtPoint:locationInInnerTextView];
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
- (void)mouseEntered:(NSEvent *)event
|
|
474
|
+
{
|
|
475
|
+
// superclass invokes self.onMouseEnter, so do this first
|
|
476
|
+
[super mouseEntered:event];
|
|
477
|
+
|
|
478
|
+
[self updateHoveredSubviewWithEvent:event];
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
- (void)mouseExited:(NSEvent *)event
|
|
482
|
+
{
|
|
483
|
+
[self updateHoveredSubviewWithEvent:event];
|
|
484
|
+
|
|
485
|
+
// superclass invokes self.onMouseLeave, so do this last
|
|
486
|
+
[super mouseExited:event];
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
- (void)mouseMoved:(NSEvent *)event
|
|
490
|
+
{
|
|
491
|
+
[super mouseMoved:event];
|
|
492
|
+
[self updateHoveredSubviewWithEvent:event];
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
- (void)updateHoveredSubviewWithEvent:(NSEvent *)event
|
|
496
|
+
{
|
|
497
|
+
RCTUIView *hoveredView = nil;
|
|
498
|
+
|
|
499
|
+
if ([event type] != NSEventTypeMouseExited && _virtualSubviews != nil) {
|
|
500
|
+
NSNumber *reactTagOfHoveredView = [self reactTagAtMouseLocationFromEvent:event];
|
|
501
|
+
|
|
502
|
+
if (reactTagOfHoveredView == nil) {
|
|
503
|
+
// This happens if we hover over an embedded view, which will handle its own mouse events
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if ([reactTagOfHoveredView isEqualToNumber:self.reactTag]) {
|
|
508
|
+
// We're hovering over the root Text element
|
|
509
|
+
hoveredView = self;
|
|
510
|
+
} else {
|
|
511
|
+
// Maybe we're hovering over a child Text element?
|
|
512
|
+
NSUInteger index = [_virtualSubviews indexOfObjectPassingTest:^BOOL(RCTVirtualTextView *_Nonnull view, NSUInteger idx, BOOL *_Nonnull stop) {
|
|
513
|
+
*stop = [[view reactTag] isEqualToNumber:reactTagOfHoveredView];
|
|
514
|
+
return *stop;
|
|
515
|
+
}];
|
|
516
|
+
if (index != NSNotFound) {
|
|
517
|
+
hoveredView = _virtualSubviews[index];
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
if (_currentHoveredSubview == hoveredView) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
// self will always be an ancestor of any views we pass in here, so it serves as a good default option.
|
|
527
|
+
// Also, if we do set from/to nil, we have to call the relevant events on the entire subtree.
|
|
528
|
+
RCTUIManager *uiManager = [[_eventDispatcher bridge] uiManager];
|
|
529
|
+
RCTShadowView *oldShadowView = [uiManager shadowViewForReactTag:[(_currentHoveredSubview ?: self) reactTag]];
|
|
530
|
+
RCTShadowView *newShadowView = [uiManager shadowViewForReactTag:[(hoveredView ?: self) reactTag]];
|
|
531
|
+
|
|
532
|
+
// Find the common ancestor between the two shadow views
|
|
533
|
+
RCTShadowView *commonAncestor = [oldShadowView ancestorSharedWithShadowView:newShadowView];
|
|
534
|
+
|
|
535
|
+
for (RCTShadowView *exitedShadowView = oldShadowView; exitedShadowView != commonAncestor && exitedShadowView != nil; exitedShadowView = [exitedShadowView reactSuperview]) {
|
|
536
|
+
RCTPlatformView *exitedView = [uiManager viewForReactTag:[exitedShadowView reactTag]];
|
|
537
|
+
if (![exitedView isKindOfClass:[RCTUIView class]]) {
|
|
538
|
+
RCTLogError(@"Unexpected view of type %@ found in hierarchy, must be RCTUIView or subclass", [exitedView class]);
|
|
539
|
+
continue;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
RCTUIView *exitedReactView = (RCTUIView *)exitedView;
|
|
543
|
+
[self sendMouseEventWithBlock:[exitedReactView onMouseLeave]
|
|
544
|
+
locationInfo:[self locationInfoFromEvent:event]
|
|
545
|
+
modifierFlags:event.modifierFlags
|
|
546
|
+
additionalData:nil];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// We cache these so we can call them from outermost to innermost
|
|
550
|
+
NSMutableArray<RCTUIView *> *enteredViewHierarchy = [NSMutableArray new];
|
|
551
|
+
for (RCTShadowView *enteredShadowView = newShadowView; enteredShadowView != commonAncestor && enteredShadowView != nil; enteredShadowView = [enteredShadowView reactSuperview]) {
|
|
552
|
+
RCTPlatformView *enteredView = [uiManager viewForReactTag:[enteredShadowView reactTag]];
|
|
553
|
+
if (![enteredView isKindOfClass:[RCTUIView class]]) {
|
|
554
|
+
RCTLogError(@"Unexpected view of type %@ found in hierarchy, must be RCTUIView or subclass", [enteredView class]);
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
[enteredViewHierarchy addObject:(RCTUIView *)enteredView];
|
|
559
|
+
}
|
|
560
|
+
for (NSInteger i = [enteredViewHierarchy count] - 1; i >= 0; i--) {
|
|
561
|
+
[self sendMouseEventWithBlock:[[enteredViewHierarchy objectAtIndex:i] onMouseEnter]
|
|
562
|
+
locationInfo:[self locationInfoFromEvent:event]
|
|
563
|
+
modifierFlags:event.modifierFlags
|
|
564
|
+
additionalData:nil];
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
_currentHoveredSubview = hoveredView;
|
|
568
|
+
}
|
|
569
|
+
|
|
415
570
|
- (void)rightMouseDown:(NSEvent *)event
|
|
416
571
|
{
|
|
417
572
|
|
package/React/Base/RCTUIKit.h
CHANGED
|
@@ -406,6 +406,7 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path);
|
|
|
406
406
|
- (void)setNeedsDisplay;
|
|
407
407
|
|
|
408
408
|
// Methods related to mouse events
|
|
409
|
+
- (BOOL)hasMouseHoverEvent;
|
|
409
410
|
- (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow;
|
|
410
411
|
- (NSDictionary*)locationInfoFromEvent:(NSEvent*)event;
|
|
411
412
|
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -217,6 +217,7 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *bezierPath)
|
|
|
217
217
|
BOOL _clipsToBounds;
|
|
218
218
|
BOOL _hasMouseOver;
|
|
219
219
|
BOOL _userInteractionEnabled;
|
|
220
|
+
NSTrackingArea *_trackingArea;
|
|
220
221
|
BOOL _mouseDownCanMoveWindow;
|
|
221
222
|
}
|
|
222
223
|
|
|
@@ -349,6 +350,13 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
349
350
|
}
|
|
350
351
|
}
|
|
351
352
|
|
|
353
|
+
- (BOOL)hasMouseHoverEvent
|
|
354
|
+
{
|
|
355
|
+
// This can be overridden by subclasses as needed.
|
|
356
|
+
// e.g., RCTTextView, which consolidates its JS children into a single gigantic NSAttributedString
|
|
357
|
+
return self.onMouseEnter || self.onMouseLeave;
|
|
358
|
+
}
|
|
359
|
+
|
|
352
360
|
- (NSDictionary*)locationInfoFromDraggingLocation:(NSPoint)locationInWindow
|
|
353
361
|
{
|
|
354
362
|
NSPoint locationInView = [self convertPoint:locationInWindow fromView:nil];
|
|
@@ -425,6 +433,28 @@ static RCTUIView *RCTUIViewCommonInit(RCTUIView *self)
|
|
|
425
433
|
block(body);
|
|
426
434
|
}
|
|
427
435
|
|
|
436
|
+
- (void)updateTrackingAreas
|
|
437
|
+
{
|
|
438
|
+
BOOL hasMouseHoverEvent = [self hasMouseHoverEvent];
|
|
439
|
+
BOOL wouldRecreateIdenticalTrackingArea = hasMouseHoverEvent && _trackingArea && NSEqualRects(self.bounds, [_trackingArea rect]);
|
|
440
|
+
|
|
441
|
+
if (!wouldRecreateIdenticalTrackingArea) {
|
|
442
|
+
if (_trackingArea) {
|
|
443
|
+
[self removeTrackingArea:_trackingArea];
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
if (hasMouseHoverEvent) {
|
|
447
|
+
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
|
|
448
|
+
options:NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
|
|
449
|
+
owner:self
|
|
450
|
+
userInfo:nil];
|
|
451
|
+
[self addTrackingArea:_trackingArea];
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
[super updateTrackingAreas];
|
|
456
|
+
}
|
|
457
|
+
|
|
428
458
|
- (BOOL)mouseDownCanMoveWindow{
|
|
429
459
|
return _mouseDownCanMoveWindow;
|
|
430
460
|
}
|
|
@@ -241,6 +241,13 @@ typedef void (^RCTApplierBlock)(NSDictionary<NSNumber *, RCTPlatformView *> *vie
|
|
|
241
241
|
*/
|
|
242
242
|
- (CGRect)measureLayoutRelativeToAncestor:(RCTShadowView *)ancestor;
|
|
243
243
|
|
|
244
|
+
// [macOS
|
|
245
|
+
/**
|
|
246
|
+
* Returns the closest ancestor shared by this shadow view and another specified shadow view.
|
|
247
|
+
*/
|
|
248
|
+
- (RCTShadowView *)ancestorSharedWithShadowView:(RCTShadowView *)shadowView;
|
|
249
|
+
// macOS]
|
|
250
|
+
|
|
244
251
|
/**
|
|
245
252
|
* Checks if the current shadow view is a descendant of the provided `ancestor`
|
|
246
253
|
*/
|
|
@@ -182,6 +182,25 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
|
|
|
182
182
|
return (CGRect){offset, self.layoutMetrics.frame.size};
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
+
// [macOS
|
|
186
|
+
- (RCTShadowView *)ancestorSharedWithShadowView:(RCTShadowView *)shadowView
|
|
187
|
+
{
|
|
188
|
+
// TODO: Can this be optimized by climbing up both hierarchies at the same time?
|
|
189
|
+
NSMutableSet<RCTShadowView *> *selfSuperviews = [NSMutableSet set];
|
|
190
|
+
for (RCTShadowView *view = self; view != nil; view = [view reactSuperview]) {
|
|
191
|
+
[selfSuperviews addObject:view];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
for (RCTShadowView *candidateView = shadowView; candidateView != nil; candidateView = [candidateView reactSuperview]) {
|
|
195
|
+
if ([selfSuperviews containsObject:candidateView]) {
|
|
196
|
+
return candidateView;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return nil;
|
|
201
|
+
}
|
|
202
|
+
// macOS]
|
|
203
|
+
|
|
185
204
|
- (BOOL)viewIsDescendantOf:(RCTShadowView *)ancestor
|
|
186
205
|
{
|
|
187
206
|
RCTShadowView *shadowView = self;
|
package/React/Views/RCTView.m
CHANGED
|
@@ -136,7 +136,6 @@ static NSString *RCTRecursiveAccessibilityLabel(RCTUIView *view) // [macOS]
|
|
|
136
136
|
RCTUIColor *_backgroundColor; // [macOS]
|
|
137
137
|
id<RCTEventDispatcherProtocol> _eventDispatcher; // [macOS]
|
|
138
138
|
#if TARGET_OS_OSX // [macOS
|
|
139
|
-
NSTrackingArea *_trackingArea;
|
|
140
139
|
BOOL _mouseDownCanMoveWindow;
|
|
141
140
|
#endif // macOS]
|
|
142
141
|
NSMutableDictionary<NSString *, NSDictionary *> *accessibilityActionsNameMap;
|
|
@@ -1466,28 +1465,6 @@ setBorderColor() setBorderColor(Top) setBorderColor(Right) setBorderColor(Bottom
|
|
|
1466
1465
|
return [self focusable] || [super acceptsFirstResponder];
|
|
1467
1466
|
}
|
|
1468
1467
|
|
|
1469
|
-
- (void)updateTrackingAreas
|
|
1470
|
-
{
|
|
1471
|
-
BOOL hasMouseHoverEvent = self.onMouseEnter || self.onMouseLeave;
|
|
1472
|
-
BOOL wouldRecreateIdenticalTrackingArea = hasMouseHoverEvent && _trackingArea && NSEqualRects(self.bounds, [_trackingArea rect]);
|
|
1473
|
-
|
|
1474
|
-
if (!wouldRecreateIdenticalTrackingArea) {
|
|
1475
|
-
if (_trackingArea) {
|
|
1476
|
-
[self removeTrackingArea:_trackingArea];
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
if (hasMouseHoverEvent) {
|
|
1480
|
-
_trackingArea = [[NSTrackingArea alloc] initWithRect:self.bounds
|
|
1481
|
-
options:NSTrackingActiveAlways|NSTrackingMouseEnteredAndExited
|
|
1482
|
-
owner:self
|
|
1483
|
-
userInfo:nil];
|
|
1484
|
-
[self addTrackingArea:_trackingArea];
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
[super updateTrackingAreas];
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
1468
|
- (BOOL)mouseDownCanMoveWindow{
|
|
1492
1469
|
return _mouseDownCanMoveWindow;
|
|
1493
1470
|
}
|