|
| 1 | +/* |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + */ |
| 7 | + |
| 8 | +package com.facebook.react.uimanager |
| 9 | + |
| 10 | +import android.view.View |
| 11 | +import com.facebook.react.bridge.Callback |
| 12 | +import com.facebook.react.bridge.ReactApplicationContext |
| 13 | +import com.facebook.react.bridge.ReadableArray |
| 14 | +import com.facebook.react.common.annotations.internal.LegacyArchitecture |
| 15 | +import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel |
| 16 | +import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger |
| 17 | + |
| 18 | +/** |
| 19 | + * This class acts as a buffer for command executed on [NativeViewHierarchyManager]. It expose |
| 20 | + * similar methods as mentioned classes but instead of executing commands immediately it enqueues |
| 21 | + * those operations in a queue that is then flushed from [UIManagerModule] once JS batch of ui |
| 22 | + * operations is finished. This is to make sure that we execute all the JS operation coming from a |
| 23 | + * single batch a single loop of the main (UI) android looper. |
| 24 | + * |
| 25 | + * @deprecated This class is stubbed out and will be removed in a future release. |
| 26 | + * |
| 27 | + * TODO(7135923): Pooling of operation objects TODO(5694019): Consider a better data structure for |
| 28 | + * operations queue to save on allocations |
| 29 | + */ |
| 30 | +@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR) |
| 31 | +@Deprecated("This class is part of Legacy Architecture and will be removed in a future release") |
| 32 | +public class UIViewOperationQueue( |
| 33 | + reactContext: ReactApplicationContext, |
| 34 | + minTimeLeftInFrameForNonBatchedOperationMs: Int, |
| 35 | +) { |
| 36 | + |
| 37 | + /** A mutation or animation operation on the view hierarchy. */ |
| 38 | + public interface UIOperation { |
| 39 | + /** Executes the UI operation. */ |
| 40 | + public fun execute() |
| 41 | + } |
| 42 | + |
| 43 | + public companion object { |
| 44 | + /** Default minimum time left in frame for non-batched operations, in milliseconds. */ |
| 45 | + public const val DEFAULT_MIN_TIME_LEFT_IN_FRAME_FOR_NONBATCHED_OPERATION_MS: Int = 8 |
| 46 | + |
| 47 | + init { |
| 48 | + LegacyArchitectureLogger.assertLegacyArchitecture( |
| 49 | + "UIViewOperationQueue", |
| 50 | + LegacyArchitectureLogLevel.ERROR, |
| 51 | + ) |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + /** Profiles the next batch of UI operations. */ |
| 56 | + public fun profileNextBatch() {} |
| 57 | + |
| 58 | + /** Returns profiled batch performance counters. */ |
| 59 | + public fun getProfiledBatchPerfCounters(): Map<String, Long> = HashMap() |
| 60 | + |
| 61 | + /** Returns whether the operation queue is empty. */ |
| 62 | + public fun isEmpty(): Boolean = true |
| 63 | + |
| 64 | + /** Adds a root view with the given tag. */ |
| 65 | + public fun addRootView(tag: Int, rootView: View) {} |
| 66 | + |
| 67 | + /** Enqueues a UI operation for execution. */ |
| 68 | + protected fun enqueueUIOperation(operation: UIOperation) {} |
| 69 | + |
| 70 | + /** Enqueues removal of a root view with the given tag. */ |
| 71 | + public fun enqueueRemoveRootView(rootViewTag: Int) {} |
| 72 | + |
| 73 | + /** Enqueues setting the JS responder for the given tag. */ |
| 74 | + public fun enqueueSetJSResponder(tag: Int, initialTag: Int, blockNativeResponder: Boolean) {} |
| 75 | + |
| 76 | + /** Enqueues clearing the JS responder. */ |
| 77 | + public fun enqueueClearJSResponder() {} |
| 78 | + |
| 79 | + /** |
| 80 | + * Enqueues dispatching a command with an integer command ID. |
| 81 | + * |
| 82 | + * @deprecated Use [enqueueDispatchCommand] with a String commandId instead. |
| 83 | + */ |
| 84 | + @Deprecated("Use enqueueDispatchCommand with a String commandId instead") |
| 85 | + public fun enqueueDispatchCommand(reactTag: Int, commandId: Int, commandArgs: ReadableArray?) {} |
| 86 | + |
| 87 | + /** Enqueues dispatching a command with a string command ID. */ |
| 88 | + public fun enqueueDispatchCommand( |
| 89 | + reactTag: Int, |
| 90 | + commandId: String, |
| 91 | + commandArgs: ReadableArray?, |
| 92 | + ) {} |
| 93 | + |
| 94 | + /** Enqueues updating extra data for the given react tag. */ |
| 95 | + public fun enqueueUpdateExtraData(reactTag: Int, extraData: Any?) {} |
| 96 | + |
| 97 | + /** Enqueues creating a view with the given properties. */ |
| 98 | + public fun enqueueCreateView( |
| 99 | + themedContext: ThemedReactContext, |
| 100 | + viewReactTag: Int, |
| 101 | + viewClassName: String, |
| 102 | + initialProps: ReactStylesDiffMap?, |
| 103 | + ) {} |
| 104 | + |
| 105 | + /** Enqueues updating the instance handle for the given react tag. */ |
| 106 | + public fun enqueueUpdateInstanceHandle(reactTag: Int, instanceHandle: Long) {} |
| 107 | + |
| 108 | + /** Enqueues updating properties for the given react tag. */ |
| 109 | + public fun enqueueUpdateProperties(reactTag: Int, className: String, props: ReactStylesDiffMap) {} |
| 110 | + |
| 111 | + /** Enqueues measuring the view with the given react tag. */ |
| 112 | + public fun enqueueMeasure(reactTag: Int, callback: Callback) {} |
| 113 | + |
| 114 | + /** Enqueues measuring the view in window coordinates with the given react tag. */ |
| 115 | + public fun enqueueMeasureInWindow(reactTag: Int, callback: Callback) {} |
| 116 | + |
| 117 | + /** Enqueues finding the target view for a touch at the given coordinates. */ |
| 118 | + public fun enqueueFindTargetForTouch( |
| 119 | + reactTag: Int, |
| 120 | + targetX: Float, |
| 121 | + targetY: Float, |
| 122 | + callback: Callback, |
| 123 | + ) {} |
| 124 | + |
| 125 | + /** Enqueues sending an accessibility event for the given tag. */ |
| 126 | + public fun enqueueSendAccessibilityEvent(tag: Int, eventType: Int) {} |
| 127 | + |
| 128 | + /** Enqueues a UI block for execution. */ |
| 129 | + @Suppress("DEPRECATION") public fun enqueueUIBlock(block: UIBlock) {} |
| 130 | + |
| 131 | + /** Prepends a UI block for execution before existing queued operations. */ |
| 132 | + @Suppress("DEPRECATION") public fun prependUIBlock(block: UIBlock) {} |
| 133 | + |
| 134 | + /** Dispatches view updates for the given batch. */ |
| 135 | + public fun dispatchViewUpdates(batchId: Int, commitStartTime: Long, layoutTime: Long) {} |
| 136 | + |
| 137 | + /** Resumes the frame callback. */ |
| 138 | + internal fun resumeFrameCallback() {} |
| 139 | + |
| 140 | + /** Pauses the frame callback. */ |
| 141 | + internal fun pauseFrameCallback() {} |
| 142 | +} |
0 commit comments