forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 138
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
[fabric] Fixes to core fabric components #2117
Draft
shwanton
wants to merge
80
commits into
microsoft:main
Choose a base branch
from
shwanton:shwanton/fabric-core-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,438
−63
Draft
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
c437f2f
[fabric] Make text input first responder through the window instance
355f73b
[fabric] Fix hit testing calls going through LegacyViewManagerInterop…
35259d8
[fabric] Add support for clipsToBounds to RCTViewComponentView
db854b2
[fabric] Add text storage getter to set up text views outside text la…
de055ae
[fabric] Render Paragraph text using NSTextView
71fae19
[fabric] Support selection of Paragraph component text content
1b11edc
[fabric] Fix events being dispatched to wrong react component for Pap…
53f631f
[fabric] Fix missing import
b53775d
[fabric] Fix onPress not working for Text
5ace629
[fabric] Add native focus props to ViewComponentView
shwanton 28a761f
[fabric] Don't flatten View if focusable or enableFocusRing
shwanton 80b6b44
[fabric] Adapt transforms to CALayer top-left anchor point
0c79cb2
[fabric] Make text input resign first responder through the window in…
64b4213
[fabric] Disable view flattening in VirtualizedList cells
f74997f
[fabric] Add conditional coordinate space conversion for native view …
474fcb9
[fabric] Add iterator to SurfaceTelemetry.cpp
8Keep fadf8a8
[fabric] Disable view flattening in header/footer/empty/spacer compon…
99ae714
[fabric] Enable Automatic Spelling Correction
shwanton e8e940d
[fabric] Enable Continuous Spell Checking
shwanton a1602d3
[fabric] Enable Grammar Checking
shwanton d7d97d1
[fabric] Static cast BOOL values event data struct init for TextInput
f84e599
[fabric] Selection range should use the correct backed input range
shwanton c681a1d
[fabric][a11y] Enable accessibility property assignments for View
b2ac7c1
[fabric][a11y] Add role mapping for common traits
95fddef
[fabric][a11y] Add role mapping for desktop specific traits
7b11d43
[fabric][a11y] Make text render with static text role
1aeb068
[fabric] Add wrapper class for TextView with scroll callback support
6f29763
[fabric] Add responder property to backing text input view protocol
e017f32
[fabric] Update backed text input copy method to support view instances
3c8cdb6
[fabric] Use wrapped text view for multiline TextInput
94e4090
[fabric] Support showing/hiding the focus ring for TextInput
4c79515
[fabric] Implement escape/cancel key press callback for TextInput
042fb07
[fabric] Submit scroll view metrics when scrolling multiline TextInput
ea1810f
[fabric] Fix random TextInput cursor position changes while typing
6af8d4d
[fabric] Add submitKeyEvents property to TextInput
ea8abc6
[fabric] Implement TextInput key down event checking for submit
d7434f2
[fabric] Add support for clearing the TextInput on submit
64cd166
[fabric] Add support for the secure text entry to TextInput
737ac48
[fabric] Copy accessibility attributes when switching TextInput backi…
3ef4f80
[fabric] Add HostPlatformViewProps to ViewProps
3d5deb8
[fabric] Add HostPlatformViewEventEmitter to ViewEventEmitter
950074e
[fabric] Move focus props to HostPlatformViewProps
49b4cce
[fabric] Add valid key down/up props to View
ed98b65
[fabric] Add key down/up event emitters to View
070fd4e
[fabric] Add key down/up handling to View component
60d4b5d
[fabric] Add keyboard event handling to TextInput component
94acea9
[fabric] Fix missing includes for windows build
29de265
[fabric] Add mouse event props to View
c17a1dc
[fabric] Add mouse enter/leave tracking to the View component
2186042
[fabric] Disable view flattening for views using mouse events
403abec
[fabric] Add mouse enter/leave tracking on scroll
00e38a2
[fabric] Check for assigned event emitter before sending key/mouse ev…
160454f
[fabric] Add draggedTypes prop to View
b5b4ba9
[fabric] Add drag and drop event emitters to View
b121fc3
[fabric] Add drag and drop support to View component
2c06459
[fabric] Add drag and drop support to TextInput component
9be4bfb
[fabric] Limit draggedTypes prop values to supported options
53d0115
[fabric] Add file paste event emitter to TextInput component
81a1e3d
[fabric] Add file paste support to TextInput component
7ecb2f6
[fabric] Fix missing method declaration of View component
1b5364e
[fabric] Fix namespace in View component header
6f05e54
[fabric] Fix crash on key up in non focusable view
8b630fb
[fabric] Add missing pragma marks in macOS view event emitter
8c6444a
[fabric] Add focus/blur event emitters to View
699610c
[fabric] Add View focus/blur event emitting on first responder change
547d683
[fabric] Add double click event prop to View component
ba2378a
[fabric] Add double click support to View component
bb12e7a
[fabric] Make RCTViewComponentView to be layer-backed by enabling wan…
shwanton b0e32bb
[fabric] Clean up explicit namespace references in View component
62470f4
[fabric] Add support for setting a tool tip on View component
ed66784
[fabric] Add cursor prop to View component
6b82927
[fabric] Add support for updating cursor to View component
3a14d9b
[fabric] TextInput should get focus with `autoFocus` prop
shwanton 398ed3f
[fabric] Fix random text display for undefined text content
254f4db
[fabric] TextInput should handle pasted types prop
shwanton d6b404c
[upstream][paper] Fix crash when statically enabling wantsUpdateLayer…
a430e28
[fabric][touch-handler] Remove `cancelTouchWithEvent` till surface to…
shwanton cc052f5
[fabric] Refactor MacOS view props & emitters
shwanton fe4989a
[fabric] Revert to Core Cursor implementation
shwanton 6b0fd9c
[fabric] Fix warning & formatting
shwanton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/react-native/Libraries/Text/TextInput/Multiline/RCTWrappedTextView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#if TARGET_OS_OSX // [macOS | ||
|
||
#import <React/RCTUIKit.h> | ||
|
||
#import "RCTTextUIKit.h" | ||
|
||
#import <React/RCTBackedTextInputDelegate.h> | ||
#import <React/RCTBackedTextInputViewProtocol.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RCTWrappedTextView : RCTPlatformView <RCTBackedTextInputViewProtocol> | ||
|
||
@property (nonatomic, weak) id<RCTBackedTextInputDelegate> textInputDelegate; | ||
@property (assign) BOOL hideVerticalScrollIndicator; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END | ||
|
||
#endif // macOS] |
221 changes: 221 additions & 0 deletions
221
packages/react-native/Libraries/Text/TextInput/Multiline/RCTWrappedTextView.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,221 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#if TARGET_OS_OSX // [macOS | ||
|
||
#import <React/RCTWrappedTextView.h> | ||
|
||
#import <React/RCTUITextView.h> | ||
#import <React/RCTTextAttributes.h> | ||
|
||
@implementation RCTWrappedTextView { | ||
RCTUITextView *_forwardingTextView; | ||
RCTUIScrollView *_scrollView; | ||
RCTClipView *_clipView; | ||
} | ||
|
||
- (instancetype)initWithFrame:(CGRect)frame | ||
{ | ||
if (self = [super initWithFrame:frame]) { | ||
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
|
||
self.hideVerticalScrollIndicator = NO; | ||
|
||
_scrollView = [[RCTUIScrollView alloc] initWithFrame:self.bounds]; | ||
_scrollView.backgroundColor = [RCTUIColor clearColor]; | ||
_scrollView.drawsBackground = NO; | ||
_scrollView.borderType = NSNoBorder; | ||
_scrollView.hasHorizontalRuler = NO; | ||
_scrollView.hasVerticalRuler = NO; | ||
_scrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
[_scrollView setHasVerticalScroller:YES]; | ||
[_scrollView setHasHorizontalScroller:NO]; | ||
|
||
_clipView = [[RCTClipView alloc] initWithFrame:_scrollView.bounds]; | ||
[_scrollView setContentView:_clipView]; | ||
|
||
_forwardingTextView = [[RCTUITextView alloc] initWithFrame:_scrollView.bounds]; | ||
_forwardingTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | ||
_forwardingTextView.delegate = self; | ||
|
||
_forwardingTextView.verticallyResizable = YES; | ||
_forwardingTextView.horizontallyResizable = YES; | ||
_forwardingTextView.textContainer.containerSize = NSMakeSize(FLT_MAX, FLT_MAX); | ||
_forwardingTextView.textContainer.widthTracksTextView = YES; | ||
_forwardingTextView.textInputDelegate = self; | ||
|
||
_scrollView.documentView = _forwardingTextView; | ||
_scrollView.contentView.postsBoundsChangedNotifications = YES; | ||
|
||
// Enable the focus ring by default | ||
_scrollView.enableFocusRing = YES; | ||
[self addSubview:_scrollView]; | ||
|
||
// a register for those notifications on the content view. | ||
#if !TARGET_OS_OSX // [macOS] | ||
[[NSNotificationCenter defaultCenter] addObserver:self | ||
selector:@selector(boundsDidChange:) | ||
name:NSViewBoundsDidChangeNotification | ||
object:_scrollView.contentView]; | ||
#else // [macOS | ||
[[NSNotificationCenter defaultCenter] addObserver:self | ||
selector:@selector(scrollViewDidScroll:) | ||
name:NSViewBoundsDidChangeNotification | ||
object:_scrollView.contentView]; | ||
#endif // macOS] | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[[NSNotificationCenter defaultCenter] removeObserver:self]; | ||
} | ||
|
||
- (BOOL)isFlipped | ||
{ | ||
return YES; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Method forwarding to text view | ||
|
||
- (void)forwardInvocation:(NSInvocation *)invocation | ||
{ | ||
[invocation invokeWithTarget:_forwardingTextView]; | ||
} | ||
|
||
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector | ||
{ | ||
if ([_forwardingTextView respondsToSelector:selector]) { | ||
return [_forwardingTextView methodSignatureForSelector:selector]; | ||
} | ||
|
||
return [super methodSignatureForSelector:selector]; | ||
} | ||
|
||
- (void)boundsDidChange:(NSNotification *)notification | ||
{ | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark First Responder forwarding | ||
|
||
- (NSResponder *)responder | ||
{ | ||
return _forwardingTextView; | ||
} | ||
|
||
- (BOOL)acceptsFirstResponder | ||
{ | ||
return _forwardingTextView.acceptsFirstResponder; | ||
} | ||
|
||
- (BOOL)becomeFirstResponder | ||
{ | ||
return [_forwardingTextView becomeFirstResponder]; | ||
} | ||
|
||
- (BOOL)resignFirstResponder | ||
{ | ||
return [_forwardingTextView resignFirstResponder]; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Text Input delegate forwarding | ||
|
||
- (id<RCTBackedTextInputDelegate>)textInputDelegate | ||
{ | ||
return _forwardingTextView.textInputDelegate; | ||
} | ||
|
||
- (void)setTextInputDelegate:(id<RCTBackedTextInputDelegate>)textInputDelegate | ||
{ | ||
_forwardingTextView.textInputDelegate = textInputDelegate; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Scrolling control | ||
|
||
#if TARGET_OS_OSX // [macOS | ||
- (void)scrollViewDidScroll:(NSNotification *)notification | ||
{ | ||
[self.textInputDelegate scrollViewDidScroll:_scrollView]; | ||
} | ||
#endif // macOS] | ||
|
||
- (BOOL)scrollEnabled | ||
{ | ||
return _scrollView.isScrollEnabled; | ||
} | ||
|
||
- (void)setScrollEnabled:(BOOL)scrollEnabled | ||
{ | ||
if (scrollEnabled) { | ||
_scrollView.scrollEnabled = YES; | ||
[_clipView setConstrainScrolling:NO]; | ||
} else { | ||
_scrollView.scrollEnabled = NO; | ||
[_clipView setConstrainScrolling:YES]; | ||
} | ||
} | ||
|
||
- (BOOL)shouldShowVerticalScrollbar | ||
{ | ||
// Hide vertical scrollbar if explicity set to NO | ||
if (self.hideVerticalScrollIndicator) { | ||
return NO; | ||
} | ||
|
||
// Hide vertical scrollbar if attributed text overflows view | ||
CGSize textViewSize = [_forwardingTextView intrinsicContentSize]; | ||
NSClipView *clipView = (NSClipView *)_scrollView.contentView; | ||
if (textViewSize.height > clipView.bounds.size.height) { | ||
return YES; | ||
}; | ||
|
||
return NO; | ||
} | ||
|
||
- (void)textInputDidChange | ||
{ | ||
[_scrollView setHasVerticalScroller:[self shouldShowVerticalScrollbar]]; | ||
} | ||
|
||
- (void)setAttributedText:(NSAttributedString *)attributedText | ||
{ | ||
[_forwardingTextView setAttributedText:attributedText]; | ||
[_scrollView setHasVerticalScroller:[self shouldShowVerticalScrollbar]]; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Text Container Inset override for NSTextView | ||
|
||
// This method is there to match the textContainerInset property on RCTUITextField | ||
- (void)setTextContainerInset:(UIEdgeInsets)textContainerInsets | ||
{ | ||
// RCTUITextView has logic in setTextContainerInset[s] to convert th UIEdgeInsets to a valid NSSize struct | ||
_forwardingTextView.textContainerInsets = textContainerInsets; | ||
} | ||
|
||
#pragma mark - | ||
#pragma mark Focus ring | ||
|
||
- (BOOL)enableFocusRing | ||
{ | ||
return _scrollView.enableFocusRing; | ||
} | ||
|
||
- (void)setEnableFocusRing:(BOOL)enableFocusRing | ||
{ | ||
_scrollView.enableFocusRing = enableFocusRing; | ||
} | ||
|
||
@end | ||
|
||
#endif // macOS] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Remove mobile code since this file is macOS only. @lenaic should we nest these files in a macos specific folder?
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.
The file is macOS specific, it could be placed in its own macOS subfolder to make it more obvious.