mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/SendAccessibilityEventMountItem.java (#45737)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/45737 Changelog: [Internal] Reviewed By: tdn120 Differential Revision: D60234523 fbshipit-source-id: aba84bcdb15bb21a90d5547ffbab6ccb22516fd6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3b76c8441d
commit
bb760ee46d
-57
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.react.fabric.mounting.mountitems;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
import com.facebook.react.bridge.ReactSoftExceptionLogger;
|
||||
import com.facebook.react.bridge.RetryableMountingLayerException;
|
||||
import com.facebook.react.fabric.mounting.MountingManager;
|
||||
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
final class SendAccessibilityEventMountItem implements MountItem {
|
||||
|
||||
private final String TAG = "Fabric.SendAccessibilityEvent";
|
||||
|
||||
private final int mSurfaceId;
|
||||
private final int mReactTag;
|
||||
private final int mEventType;
|
||||
|
||||
SendAccessibilityEventMountItem(int surfaceId, int reactTag, int eventType) {
|
||||
mSurfaceId = surfaceId;
|
||||
mReactTag = reactTag;
|
||||
mEventType = eventType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NonNull MountingManager mountingManager) {
|
||||
try {
|
||||
mountingManager.sendAccessibilityEvent(mSurfaceId, mReactTag, mEventType);
|
||||
} catch (RetryableMountingLayerException e) {
|
||||
// Accessibility events are similar to commands in that they're imperative
|
||||
// calls from JS, disconnected from the commit lifecycle, and therefore
|
||||
// inherently unpredictable and dangerous. If we encounter a "retryable"
|
||||
// error, that is, a known category of errors that this is likely to hit
|
||||
// due to race conditions (like the view disappearing after the event is
|
||||
// queued and before it executes), we log a soft exception and continue along.
|
||||
// Other categories of errors will still cause a hard crash.
|
||||
ReactSoftExceptionLogger.logSoftException(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSurfaceId() {
|
||||
return mSurfaceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public String toString() {
|
||||
return "SendAccessibilityEventMountItem [" + mReactTag + "] " + mEventType;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.facebook.react.fabric.mounting.mountitems
|
||||
|
||||
import com.facebook.react.bridge.ReactSoftExceptionLogger
|
||||
import com.facebook.react.bridge.RetryableMountingLayerException
|
||||
import com.facebook.react.fabric.mounting.MountingManager
|
||||
|
||||
internal class SendAccessibilityEventMountItem(
|
||||
private val _surfaceId: Int,
|
||||
private val reactTag: Int,
|
||||
private val eventType: Int
|
||||
) : MountItem {
|
||||
|
||||
private val TAG = "Fabric.SendAccessibilityEvent"
|
||||
|
||||
override public fun execute(mountingManager: MountingManager) {
|
||||
try {
|
||||
mountingManager.sendAccessibilityEvent(_surfaceId, reactTag, eventType)
|
||||
} catch (e: RetryableMountingLayerException) {
|
||||
// Accessibility events are similar to commands in that they're imperative
|
||||
// calls from JS, disconnected from the commit lifecycle, and therefore
|
||||
// inherently unpredictable and dangerous. If we encounter a "retryable"
|
||||
// error, that is, a known category of errors that this is likely to hit
|
||||
// due to race conditions (like the view disappearing after the event is
|
||||
// queued and before it executes), we log a soft exception and continue along.
|
||||
// Other categories of errors will still cause a hard crash.
|
||||
ReactSoftExceptionLogger.logSoftException(TAG, e)
|
||||
}
|
||||
}
|
||||
|
||||
override public fun getSurfaceId(): Int = _surfaceId
|
||||
|
||||
override public fun toString(): String = "SendAccessibilityEventMountItem [$reactTag] $eventType"
|
||||
}
|
||||
Reference in New Issue
Block a user