Skip to content

Commit d739bc3

Browse files
committed
Merge commit '73ad6514cc91d3df6b9c39713860ca71e8479ef3' into realize-last-focused
2 parents 7c23f47 + 73ad651 commit d739bc3

File tree

104 files changed

+1029
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1029
-349
lines changed

.circleci/config.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ jobs:
417417
- with_brew_cache_span:
418418
steps:
419419
- brew_install:
420-
package: cmake ninja
420+
package: cmake
421421

422422
- run:
423423
name: Setup the CocoaPods environment
@@ -455,8 +455,8 @@ jobs:
455455
- run:
456456
name: Run Ruby Tests
457457
command: |
458-
cd scripts/cocoapods
459-
sh run_tests.sh
458+
cd scripts
459+
sh run_ruby_tests.sh
460460
- run_yarn
461461
- run: |
462462
cd packages/rn-tester
@@ -474,7 +474,7 @@ jobs:
474474
- with_brew_cache_span:
475475
steps:
476476
- brew_install:
477-
package: watchman cmake ninja
477+
package: watchman cmake
478478
- run:
479479
name: "Brew: Tap wix/brew"
480480
command: brew tap wix/brew >/dev/null
@@ -745,7 +745,7 @@ jobs:
745745
- with_brew_cache_span:
746746
steps:
747747
- brew_install:
748-
package: cmake ninja
748+
package: cmake
749749

750750
- run:
751751
name: Install CocoaPods dependencies
@@ -987,17 +987,19 @@ jobs:
987987
environment:
988988
- HERMES_WS_DIR: *hermes_workspace_root
989989
steps:
990+
- checkout
990991
- *attach_hermes_workspace
991992
- restore_cache:
992993
key: v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
993994
- run:
994995
name: Set up workspace
995996
command: |
996997
mkdir -p /tmp/hermes/osx-bin
998+
cp ~/react-native/sdks/hermes-engine/utils/* "$HERMES_WS_DIR/hermes/utils/."
997999
- run:
9981000
name: Install dependencies
9991001
command: |
1000-
brew install cmake ninja
1002+
brew install cmake
10011003
- run:
10021004
name: Build HermesC for macOS
10031005
command: |

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## v0.68.2
4+
5+
### Changed
6+
7+
- Bump used version of react-native-codegen to 0.0.17 ([dfda480a98](https://github.com/facebook/react-native/commit/dfda480a9888d95c542cea40f25e8e783565c1db) by [@cortinico](https://github.com/cortinico))
8+
- Bump react-native-codegen to 0.0.17 ([a5ddc2e165](https://github.com/facebook/react-native/commit/a5ddc2e16523ea336ffbecf7acfd4820469a29e7) by [@cortinico](https://github.com/cortinico))
9+
10+
### Fixed
11+
12+
#### Android specific
13+
14+
- Working around Long paths limitation on Windows ([62ef6f5fa1](https://github.com/facebook/react-native/commit/62ef6f5fa1ecb918bde130a6024b65afcd34c7e3) by [@mganandraj](https://github.com/mganandraj))
15+
316
## v0.68.1
417

518
### Changed

Libraries/Components/ScrollView/ScrollView.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ type IOSProps = $ReadOnly<{|
190190
* @platform ios
191191
*/
192192
contentInset?: ?EdgeInsetsProp,
193-
/**
194-
* Used to manually set the starting scroll offset.
195-
* The default value is `{x: 0, y: 0}`.
196-
* @platform ios
197-
*/
198-
contentOffset?: ?PointProp,
199193
/**
200194
* When true, the scroll view bounces when it reaches the end of the
201195
* content if the content is larger then the scroll view along the axis of
@@ -457,6 +451,11 @@ export type Props = $ReadOnly<{|
457451
* ```
458452
*/
459453
contentContainerStyle?: ?ViewStyleProp,
454+
/**
455+
* Used to manually set the starting scroll offset.
456+
* The default value is `{x: 0, y: 0}`.
457+
*/
458+
contentOffset?: ?PointProp,
460459
/**
461460
* When true, the scroll view stops on the next index (in relation to scroll
462461
* position at release) regardless of how fast the gesture is. This can be

Libraries/Components/TextInput/TextInput.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,14 @@ type AndroidProps = $ReadOnly<{|
392392
| 'off'
393393
),
394394

395+
/**
396+
* When provided it will set the color of the cursor (or "caret") in the component.
397+
* Unlike the behavior of `selectionColor` the cursor color will be set independently
398+
* from the color of the text selection box.
399+
* @platform android
400+
*/
401+
cursorColor?: ?ColorValue,
402+
395403
/**
396404
* When `false`, if there is a small amount of space available around a text input
397405
* (e.g. landscape orientation on a phone), the OS may choose to have the user edit

Libraries/Lists/VirtualizeUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function elementsThatOverlapOffsets(
2525
offset: number,
2626
...
2727
},
28-
zoomScale: number,
28+
zoomScale: number = 1,
2929
): Array<number> {
3030
const out = [];
3131
let outLength = 0;
@@ -115,7 +115,7 @@ export function computeWindowedRenderLimits(
115115
if (itemCount === 0) {
116116
return prev;
117117
}
118-
const {offset, velocity, visibleLength, zoomScale} = scrollMetrics;
118+
const {offset, velocity, visibleLength, zoomScale = 1} = scrollMetrics;
119119

120120
// Start with visible area, then compute maximum overscan region by expanding from there, biased
121121
// in the direction of scroll. Total overscan area is capped, which should cap memory consumption

Libraries/Lists/VirtualizedList.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
842842
this._updateViewableItems(data);
843843

844844
const {contentLength, offset, visibleLength} = this._scrollMetrics;
845+
const distanceFromEnd = contentLength - visibleLength - offset;
845846

846847
// Wait until the scroll view metrics have been set up. And until then,
847848
// we will trust the initialNumToRender suggestion
@@ -851,7 +852,6 @@ class VirtualizedList extends React.PureComponent<Props, State> {
851852

852853
let newCellsAroundViewport: {first: number, last: number};
853854
if (this._isVirtualizationDisabled()) {
854-
const distanceFromEnd = contentLength - visibleLength - offset;
855855
const renderAhead =
856856
distanceFromEnd < onEndReachedThreshold * visibleLength
857857
? maxToRenderPerBatchOrDefault(props.maxToRenderPerBatch)
@@ -866,9 +866,20 @@ class VirtualizedList extends React.PureComponent<Props, State> {
866866
};
867867
} else {
868868
// If we have a non-zero initialScrollIndex and run this before we've scrolled,
869-
// wait until we've scrolled the view to the right place. And until then,
869+
// we'll wipe out the initialNumToRender rendered elements starting at initialScrollIndex.
870+
// So let's wait until we've scrolled the view to the right place. And until then,
870871
// we will trust the initialScrollIndex suggestion.
871-
if (this.props.initialScrollIndex && !this._hasDoneInitialScroll) {
872+
873+
// Thus, we want to recalculate the windowed render limits if any of the following hold:
874+
// - initialScrollIndex is undefined or is 0
875+
// - initialScrollIndex > 0 AND scrolling is complete
876+
// - initialScrollIndex > 0 AND the end of the list is visible (this handles the case
877+
// where the list is shorter than the visible area)
878+
if (
879+
this.props.initialScrollIndex &&
880+
!this._scrollMetrics.offset &&
881+
Math.abs(distanceFromEnd) >= Number.EPSILON
882+
) {
872883
return cellsAroundViewport;
873884
}
874885

@@ -1381,7 +1392,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
13811392
},
13821393
} = {};
13831394
_footerLength = 0;
1384-
_hasDoneInitialScroll = false;
1395+
// Used for preventing scrollToIndex from being called multiple times for initialScrollIndex
1396+
_hasTriggeredInitialScrollToIndex = false;
13851397
_hasInteracted = false;
13861398
_hasMore = false;
13871399
_hasWarned: {[string]: boolean} = {};
@@ -1736,15 +1748,15 @@ class VirtualizedList extends React.PureComponent<Props, State> {
17361748
height > 0 &&
17371749
this.props.initialScrollIndex != null &&
17381750
this.props.initialScrollIndex > 0 &&
1739-
!this._hasDoneInitialScroll
1751+
!this._hasTriggeredInitialScrollToIndex
17401752
) {
17411753
if (this.props.contentOffset == null) {
17421754
this.scrollToIndex({
17431755
animated: false,
17441756
index: this.props.initialScrollIndex,
17451757
});
17461758
}
1747-
this._hasDoneInitialScroll = true;
1759+
this._hasTriggeredInitialScrollToIndex = true;
17481760
}
17491761
if (this.props.onContentSizeChange) {
17501762
this.props.onContentSizeChange(width, height);

Libraries/Lists/__tests__/VirtualizedList-test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ it('adjusts render area with non-zero initialScrollIndex', () => {
885885
viewport: {width: 10, height: 50},
886886
content: {width: 10, height: 200},
887887
});
888+
simulateScroll(component, {x: 0, y: 10}); // simulate scroll offset for initialScrollIndex
888889

889890
performAllBatches();
890891
});
@@ -914,8 +915,8 @@ it('renders new items when data is updated with non-zero initialScrollIndex', ()
914915

915916
ReactTestRenderer.act(() => {
916917
simulateLayout(component, {
917-
viewport: {width: 10, height: 50},
918-
content: {width: 10, height: 200},
918+
viewport: {width: 10, height: 20},
919+
content: {width: 10, height: 20},
919920
});
920921
performAllBatches();
921922
});

React-Core.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Pod::Spec.new do |s|
4747
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
4848
s.header_dir = "React"
4949
s.framework = "JavaScriptCore"
50-
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/Headers/Public/FlipperKit\" \"$(PODS_ROOT)/Headers/Public/ReactCommon\" \"$(PODS_ROOT)/Headers/Public/React-RCTFabric\"", "DEFINES_MODULE" => "YES" }
50+
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/Headers/Public/FlipperKit\" \"$(PODS_ROOT)/Headers/Public/ReactCommon\" \"$(PODS_ROOT)/Headers/Public/React-RCTFabric\"", "DEFINES_MODULE" => "YES", "GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}" }
5151
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}
5252
s.default_subspec = "Default"
5353

React/CoreModules/RCTLogBox.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter
5757
if (strongSelf->_bridgelessSurfacePresenter) {
5858
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
5959
surfacePresenter:strongSelf->_bridgelessSurfacePresenter];
60+
[strongSelf->_view show];
6061
} else if (strongSelf->_bridge && strongSelf->_bridge.valid) {
6162
if (strongSelf->_bridge.surfacePresenter) {
6263
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow()
6364
surfacePresenter:strongSelf->_bridge.surfacePresenter];
6465
} else {
6566
strongSelf->_view = [[RCTLogBoxView alloc] initWithWindow:RCTKeyWindow() bridge:strongSelf->_bridge];
6667
}
68+
[strongSelf->_view show];
6769
}
68-
69-
[strongSelf->_view show];
7070
});
7171
}
7272
}

React/Fabric/RCTSurfaceTouchHandler.mm

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,17 @@ static BOOL AnyTouchesChanged(NSSet<UITouch *> *touches)
221221
return NO;
222222
}
223223

224+
static BOOL IsViewListeningToEvent(UIView *view, ViewEvents::Offset eventType)
225+
{
226+
if ([view.class conformsToProtocol:@protocol(RCTComponentViewProtocol)]) {
227+
auto props = ((id<RCTComponentViewProtocol>)view).props;
228+
if (SharedViewProps viewProps = std::dynamic_pointer_cast<ViewProps const>(props)) {
229+
return viewProps->events[eventType];
230+
}
231+
}
232+
return NO;
233+
}
234+
224235
/**
225236
* Surprisingly, `__unsafe_unretained id` pointers are not regular pointers
226237
* and `std::hash<>` cannot hash them.
@@ -558,28 +569,60 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0))
558569
NSTimeInterval timestamp = CACurrentMediaTime();
559570

560571
// Entering
561-
// root -> child
572+
573+
// We only want to emit events to JS if there is a view that is currently listening to said event
574+
// so we only send those event to the JS side if the element which has been entered is itself listening,
575+
// or if one of its parents is listening in case those listeners care about the capturing phase. Adding the ability
576+
// for native to distingusih between capturing listeners and not could be an optimization to futher reduce the number
577+
// of events we send to JS
578+
BOOL hasParentEnterListener = NO;
579+
562580
for (UIView *componentView in [eventPathViews reverseObjectEnumerator]) {
563-
if (![_currentlyHoveredViews containsObject:componentView]) {
581+
BOOL shouldEmitEvent =
582+
hasParentEnterListener || IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerEnter2);
583+
584+
if (shouldEmitEvent && ![_currentlyHoveredViews containsObject:componentView]) {
564585
SharedTouchEventEmitter eventEmitter =
565586
GetTouchEmitterFromView(componentView, [recognizer locationInView:componentView]);
566587
if (eventEmitter != nil) {
567588
PointerEvent event = CreatePointerEventFromIncompleteHoverData(componentView, clientLocation, timestamp);
568589
eventEmitter->onPointerEnter2(event);
569590
}
570591
}
592+
593+
if (shouldEmitEvent && !hasParentEnterListener) {
594+
hasParentEnterListener = YES;
595+
}
571596
}
572597

573598
// Leaving
574-
// child -> root
575-
for (UIView *componentView in _currentlyHoveredViews) {
576-
if (![eventPathViews containsObject:componentView]) {
577-
SharedTouchEventEmitter eventEmitter =
578-
GetTouchEmitterFromView(componentView, [recognizer locationInView:componentView]);
579-
if (eventEmitter != nil) {
580-
PointerEvent event = CreatePointerEventFromIncompleteHoverData(componentView, clientLocation, timestamp);
581-
eventEmitter->onPointerLeave2(event);
582-
}
599+
600+
// pointerleave events need to be emited from the deepest target to the root but
601+
// we also need to efficiently keep track of if a view has a parent which is listening to the leave events,
602+
// so we first iterate from the root to the target, collecting the views which need events fired for, of which
603+
// we reverse iterate (now from target to root), actually emitting the events.
604+
NSMutableOrderedSet *viewsToEmitLeaveEventsTo = [NSMutableOrderedSet orderedSet];
605+
606+
BOOL hasParentLeaveListener = NO;
607+
for (UIView *componentView in [_currentlyHoveredViews reverseObjectEnumerator]) {
608+
BOOL shouldEmitEvent =
609+
hasParentLeaveListener || IsViewListeningToEvent(componentView, ViewEvents::Offset::PointerLeave2);
610+
611+
if (shouldEmitEvent && ![eventPathViews containsObject:componentView]) {
612+
[viewsToEmitLeaveEventsTo addObject:componentView];
613+
}
614+
615+
if (shouldEmitEvent && !hasParentLeaveListener) {
616+
hasParentLeaveListener = YES;
617+
}
618+
}
619+
620+
for (UIView *componentView in [viewsToEmitLeaveEventsTo reverseObjectEnumerator]) {
621+
SharedTouchEventEmitter eventEmitter =
622+
GetTouchEmitterFromView(componentView, [recognizer locationInView:componentView]);
623+
if (eventEmitter != nil) {
624+
PointerEvent event = CreatePointerEventFromIncompleteHoverData(componentView, clientLocation, timestamp);
625+
eventEmitter->onPointerLeave2(event);
583626
}
584627
}
585628

0 commit comments

Comments
 (0)