已合并
优化createFrameNodes性能 #83536
chenyuchi创建于 4月13日
优化createFrameNodes性能 #83536
已合并
共 8 个文件变更+150-137
| @@ -37,6 +37,13 @@ interface SizeTLengthMetrics { | |||
| 37 | attribute LengthMetrics height; | 37 | attribute LengthMetrics height; |
| 38 | }; | 38 | }; |
| 39 | 39 | ||
| 40 | +[Entity=Interface] | ||
| 41 | +interface FrameNodeCreateInfo { | ||
| 42 | + attribute pointer frameNodePeer; | ||
| 43 | + attribute pointer renderNodePeer; | ||
| 44 | + attribute i32 id; | ||
| 45 | +}; | ||
| 46 | + | ||
| 40 | [Entity=Class] | 47 | [Entity=Class] |
| 41 | interface FrameNodeExtender { | 48 | interface FrameNodeExtender { |
| 42 | static pointer constructorFrameNode(boolean supportMultiThread); | 49 | static pointer constructorFrameNode(boolean supportMultiThread); |
| @@ -116,9 +123,7 @@ interface FrameNodeExtender { | |||
| 116 | static sequence<f64> convertPositionToWindow(FrameNode peer, NodePosition positionByLocal); | 123 | static sequence<f64> convertPositionToWindow(FrameNode peer, NodePosition positionByLocal); |
| 117 | static sequence<f64> convertPositionFromWindow(FrameNode peer, NodePosition positionByWindow); | 124 | static sequence<f64> convertPositionFromWindow(FrameNode peer, NodePosition positionByWindow); |
| 118 | static void applyAttributesFinish(FrameNode peer); | 125 | static void applyAttributesFinish(FrameNode peer); |
| 119 | - static sequence<pointer> createFrameNodes(i32 count); | ||
| 120 | - static sequence<pointer> getRenderNodeByFrameNodes(sequence<pointer> ptrs); | ||
| 121 | - static sequence<i32> getIdByFrameNodes(sequence<pointer> ptrs); | ||
| 122 | static pointer getFrameNodeById(FrameNode peer, String id); | 126 | static pointer getFrameNodeById(FrameNode peer, String id); |
| 123 | static pointer getFrameNodeByUniqueId(FrameNode peer, i32 id); | 127 | static pointer getFrameNodeByUniqueId(FrameNode peer, i32 id); |
| 128 | + static sequence<FrameNodeCreateInfo> getFrameNodeCreateInfoArray(i32 count); | ||
| 124 | }; | 129 | }; |
Mframeworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/generated/component/idlize.ets+38-62
| @@ -2608,6 +2608,10 @@ export class FrameNodeExtender { | |||
| 2608 | const id_casted = id as (int32) | 2608 | const id_casted = id as (int32) |
| 2609 | return FrameNodeExtender.getFrameNodeByUniqueId_serialize(id_casted) | 2609 | return FrameNodeExtender.getFrameNodeByUniqueId_serialize(id_casted) |
| 2610 | } | 2610 | } |
| 2611 | + public static getFrameNodeCreateInfoArray(count: int32): Array<FrameNodeCreateInfo> { | ||
| 2612 | + const count_casted = count as (int32) | ||
| 2613 | + return FrameNodeExtender.getFrameNodeCreateInfoArray_serialize(count_casted) | ||
| 2614 | + } | ||
| 2611 | public static reuse(peer: FrameNode): void { | 2615 | public static reuse(peer: FrameNode): void { |
| 2612 | const peer_casted = peer as (FrameNode) | 2616 | const peer_casted = peer as (FrameNode) |
| 2613 | FrameNodeExtender.reuse_serialize(peer_casted) | 2617 | FrameNodeExtender.reuse_serialize(peer_casted) |
| @@ -2705,18 +2709,6 @@ export class FrameNodeExtender { | |||
| 2705 | FrameNodeExtender.applyAttributesFinish_serialize(peer_casted) | 2709 | FrameNodeExtender.applyAttributesFinish_serialize(peer_casted) |
| 2706 | return | 2710 | return |
| 2707 | } | 2711 | } |
| 2708 | - public static createFrameNodes(count: int32): Array<KPointer> { | ||
| 2709 | - const count_casted = count as (int32) | ||
| 2710 | - return FrameNodeExtender.createFrameNodes_serialize(count_casted) | ||
| 2711 | - } | ||
| 2712 | - public static getRenderNodesByFrameNodes(ptrs: Array<KPointer>): Array<KPointer> { | ||
| 2713 | - const ptrs_casted = ptrs as (Array<KPointer>) | ||
| 2714 | - return FrameNodeExtender.getRenderNodesByFrameNodes_serialize(ptrs_casted) | ||
| 2715 | - } | ||
| 2716 | - public static getIdsByFrameNodes(ptrs: Array<KPointer>): Array<int32> { | ||
| 2717 | - const ptrs_casted = ptrs as (Array<KPointer>) | ||
| 2718 | - return FrameNodeExtender.getIdsByFrameNodes_serialize(ptrs_casted) | ||
| 2719 | - } | ||
| 2720 | public static getFrameNodeById(peer: FrameNode, id: string): KPointer { | 2712 | public static getFrameNodeById(peer: FrameNode, id: string): KPointer { |
| 2721 | const peer_casted = peer as (FrameNode) | 2713 | const peer_casted = peer as (FrameNode) |
| 2722 | const id_casted = id as (string) | 2714 | const id_casted = id as (string) |
| @@ -3158,56 +3150,6 @@ export class FrameNodeExtender { | |||
| 3158 | private static applyAttributesFinish_serialize(peer: FrameNode): void { | 3150 | private static applyAttributesFinish_serialize(peer: FrameNode): void { |
| 3159 | ArkUIGeneratedNativeModule._FrameNodeExtender_applyAttributesFinish(extractors.toFrameNodePtr(peer)) | 3151 | ArkUIGeneratedNativeModule._FrameNodeExtender_applyAttributesFinish(extractors.toFrameNodePtr(peer)) |
| 3160 | } | 3152 | } |
| 3161 | - private static createFrameNodes_serialize(count: int32): Array<KPointer> { | ||
| 3162 | - const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_createFrameNodes(count) | ||
| 3163 | - let retvalDeserializer : DeserializerBase = new DeserializerBase(retval, retval.length) | ||
| 3164 | - const bufferLength : int32 = retvalDeserializer.readInt32() | ||
| 3165 | - let buffer : Array<KPointer> = new Array<KPointer>(bufferLength) | ||
| 3166 | - for (let bufferBufCounterI = 0; bufferBufCounterI < bufferLength; bufferBufCounterI++) { | ||
| 3167 | - buffer[bufferBufCounterI] = retvalDeserializer.readPointer() | ||
| 3168 | - } | ||
| 3169 | - const returnResult : Array<KPointer> = buffer | ||
| 3170 | - retvalDeserializer.dispose() | ||
| 3171 | - return returnResult | ||
| 3172 | - } | ||
| 3173 | - private static getRenderNodesByFrameNodes_serialize(ptrs: Array<KPointer>): Array<KPointer> { | ||
| 3174 | - const thisSerializer : SerializerBase = SerializerBase.hold() | ||
| 3175 | - thisSerializer.writeInt32((ptrs.length).toInt()) | ||
| 3176 | - for (let ptrsCounterI = 0; ptrsCounterI < ptrs.length; ptrsCounterI++) { | ||
| 3177 | - const ptrsTmpElement : KPointer = ptrs[ptrsCounterI] | ||
| 3178 | - thisSerializer.writePointer(ptrsTmpElement) | ||
| 3179 | - } | ||
| 3180 | - const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_getRenderNodeByFrameNodes(thisSerializer.asBuffer(), thisSerializer.length()) | ||
| 3181 | - thisSerializer.release() | ||
| 3182 | - let retvalDeserializer : DeserializerBase = new DeserializerBase(retval, retval.length) | ||
| 3183 | - const bufferLength : int32 = retvalDeserializer.readInt32() | ||
| 3184 | - let buffer : Array<KPointer> = new Array<KPointer>(bufferLength) | ||
| 3185 | - for (let bufferBufCounterI = 0; bufferBufCounterI < bufferLength; bufferBufCounterI++) { | ||
| 3186 | - buffer[bufferBufCounterI] = retvalDeserializer.readPointer() | ||
| 3187 | - } | ||
| 3188 | - const returnResult : Array<KPointer> = buffer | ||
| 3189 | - retvalDeserializer.dispose() | ||
| 3190 | - return returnResult | ||
| 3191 | - } | ||
| 3192 | - private static getIdsByFrameNodes_serialize(ptrs: Array<KPointer>): Array<int32> { | ||
| 3193 | - const thisSerializer : SerializerBase = SerializerBase.hold() | ||
| 3194 | - thisSerializer.writeInt32((ptrs.length).toInt()) | ||
| 3195 | - for (let ptrsCounterI = 0; ptrsCounterI < ptrs.length; ptrsCounterI++) { | ||
| 3196 | - const ptrsTmpElement : KPointer = ptrs[ptrsCounterI] | ||
| 3197 | - thisSerializer.writePointer(ptrsTmpElement) | ||
| 3198 | - } | ||
| 3199 | - const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_getIdByFrameNodes(thisSerializer.asBuffer(), thisSerializer.length()) | ||
| 3200 | - thisSerializer.release() | ||
| 3201 | - let retvalDeserializer : DeserializerBase = new DeserializerBase(retval, retval.length) | ||
| 3202 | - const bufferLength : int32 = retvalDeserializer.readInt32() | ||
| 3203 | - let buffer : Array<int32> = new Array<int32>(bufferLength) | ||
| 3204 | - for (let bufferBufCounterI = 0; bufferBufCounterI < bufferLength; bufferBufCounterI++) { | ||
| 3205 | - buffer[bufferBufCounterI] = retvalDeserializer.readInt32() | ||
| 3206 | - } | ||
| 3207 | - const returnResult : Array<int32> = buffer | ||
| 3208 | - retvalDeserializer.dispose() | ||
| 3209 | - return returnResult | ||
| 3210 | - } | ||
| 3211 | static getFrameNodeById1_serialize(peer: FrameNode, id: string): KPointer { | 3153 | static getFrameNodeById1_serialize(peer: FrameNode, id: string): KPointer { |
| 3212 | const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_getFrameNodeById1(extractors.toFrameNodePtr(peer), id) | 3154 | const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_getFrameNodeById1(extractors.toFrameNodePtr(peer), id) |
| 3213 | return retval | 3155 | return retval |
| @@ -3216,6 +3158,16 @@ export class FrameNodeExtender { | |||
| 3216 | const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_getFrameNodeByUniqueId1(extractors.toFrameNodePtr(peer), id) | 3158 | const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_getFrameNodeByUniqueId1(extractors.toFrameNodePtr(peer), id) |
| 3217 | return retval | 3159 | return retval |
| 3218 | } | 3160 | } |
| 3161 | + private static getFrameNodeCreateInfoArray_serialize(count: int32): Array<FrameNodeCreateInfo> { | ||
| 3162 | + const retval = ArkUIGeneratedNativeModule._FrameNodeExtender_getFrameNodeCreateInfoArray(count) | ||
| 3163 | + let retvalDeserializer: DeserializerBase = new DeserializerBase(retval, retval.length) | ||
| 3164 | + const bufferLength: int32 = retvalDeserializer.readInt32() | ||
| 3165 | + const buffer: Array<FrameNodeCreateInfo> = new Array<FrameNodeCreateInfo>(bufferLength, (arg0: int32):FrameNodeCreateInfo => { | ||
| 3166 | + return FrameNodeCreateInfo_serializer.read(retvalDeserializer); | ||
| 3167 | + }) | ||
| 3168 | + const returnResult: Array<FrameNodeCreateInfo> = buffer | ||
| 3169 | + return returnResult | ||
| 3170 | + } | ||
| 3219 | } | 3171 | } |
| 3220 | export class GaugeExtender { | 3172 | export class GaugeExtender { |
| 3221 | public static setIndicator(node: KPointer, options?: GaugeIndicatorOptions): void { | 3173 | public static setIndicator(node: KPointer, options?: GaugeIndicatorOptions): void { |
| @@ -7074,6 +7026,11 @@ export interface SizeTLengthMetrics { | |||
| 7074 | width: arkui_Graphics_LengthMetrics; | 7026 | width: arkui_Graphics_LengthMetrics; |
| 7075 | height: arkui_Graphics_LengthMetrics; | 7027 | height: arkui_Graphics_LengthMetrics; |
| 7076 | } | 7028 | } |
| 7029 | +export interface FrameNodeCreateInfo { | ||
| 7030 | + frameNodePeer: KPointer; | ||
| 7031 | + renderNodePeer: KPointer; | ||
| 7032 | + id: int32; | ||
| 7033 | +} | ||
| 7077 | export type NavExtender_OnUpdateStack = () => void; | 7034 | export type NavExtender_OnUpdateStack = () => void; |
| 7078 | export type NavExtender_PageMapNodeBuilder = (url: string, params?: Object) => KPointer; | 7035 | export type NavExtender_PageMapNodeBuilder = (url: string, params?: Object) => KPointer; |
| 7079 | export interface SizeNumberInner { | 7036 | export interface SizeNumberInner { |
| @@ -8286,6 +8243,25 @@ export class FieldRegionInner_serializer { | |||
| 8286 | return value | 8243 | return value |
| 8287 | } | 8244 | } |
| 8288 | } | 8245 | } |
| 8246 | +export class FrameNodeCreateInfo_serializer { | ||
| 8247 | + public static write(buffer: SerializerBase, value: FrameNodeCreateInfo): void { | ||
| 8248 | + let valueSerializer: SerializerBase = buffer | ||
| 8249 | + const valueHolderForFrameNodePeer = value.frameNodePeer | ||
| 8250 | + valueSerializer.writePointer(valueHolderForFrameNodePeer) | ||
| 8251 | + const valueHolderForRenderNodePeer = value.renderNodePeer | ||
| 8252 | + valueSerializer.writePointer(valueHolderForRenderNodePeer) | ||
| 8253 | + const valueHolderForId = value.id | ||
| 8254 | + valueSerializer.writeInt32(valueHolderForId) | ||
| 8255 | + } | ||
| 8256 | + public static read(buffer: DeserializerBase): FrameNodeCreateInfo { | ||
| 8257 | + let valueDeserializer: DeserializerBase = buffer | ||
| 8258 | + const frameNodePeerTmpResult: KPointer = valueDeserializer.readPointer() | ||
| 8259 | + const renderNodePeerTmpResult: KPointer = valueDeserializer.readPointer() | ||
| 8260 | + const idTmpResult: int32 = valueDeserializer.readInt32() | ||
| 8261 | + let value: FrameNodeCreateInfo = ({frameNodePeer: frameNodePeerTmpResult, renderNodePeer: renderNodePeerTmpResult, id: idTmpResult} as FrameNodeCreateInfo) | ||
| 8262 | + return value | ||
| 8263 | + } | ||
| 8264 | +} | ||
| 8289 | export class InnerGestureObserverConfigs_serializer { | 8265 | export class InnerGestureObserverConfigs_serializer { |
| 8290 | public static write(buffer: SerializerBase, value: InnerGestureObserverConfigs): void { | 8266 | public static write(buffer: SerializerBase, value: InnerGestureObserverConfigs): void { |
| 8291 | let valueSerializer: SerializerBase = buffer | 8267 | let valueSerializer: SerializerBase = buffer |
Mframeworks/bridge/arkts_frontend/koala_projects/arkoala-arkts/arkui-ohos/generated/framework/arkts/ArkUIGeneratedNativeModule.ets+2-6
| @@ -4839,15 +4839,11 @@ export class ArkUIGeneratedNativeModule { | |||
| 4839 | @ani.unsafe.Direct | 4839 | @ani.unsafe.Direct |
| 4840 | native static _FrameNodeExtender_applyAttributesFinish(peer: KPointer): void | 4840 | native static _FrameNodeExtender_applyAttributesFinish(peer: KPointer): void |
| 4841 | @ani.unsafe.Quick | 4841 | @ani.unsafe.Quick |
| 4842 | - native static _FrameNodeExtender_createFrameNodes(count: KInt): KInteropReturnBuffer | ||
| 4843 | - @ani.unsafe.Quick | ||
| 4844 | - native static _FrameNodeExtender_getRenderNodeByFrameNodes(thisArray: KSerializerBuffer, thisLength: KInt): KInteropReturnBuffer | ||
| 4845 | - @ani.unsafe.Quick | ||
| 4846 | - native static _FrameNodeExtender_getIdByFrameNodes(thisArray: KSerializerBuffer, thisLength: KInt): KInteropReturnBuffer | ||
| 4847 | - @ani.unsafe.Quick | ||
| 4848 | native static _FrameNodeExtender_getFrameNodeById1(peer: KPointer, id: KStringPtr): KPointer | 4842 | native static _FrameNodeExtender_getFrameNodeById1(peer: KPointer, id: KStringPtr): KPointer |
| 4849 | @ani.unsafe.Direct | 4843 | @ani.unsafe.Direct |
| 4850 | native static _FrameNodeExtender_getFrameNodeByUniqueId1(peer: KPointer, id: KInt): KPointer | 4844 | native static _FrameNodeExtender_getFrameNodeByUniqueId1(peer: KPointer, id: KInt): KPointer |
| 4845 | + @ani.unsafe.Quick | ||
| 4846 | + native static _FrameNodeExtender_getFrameNodeCreateInfoArray(count: KInt): KInteropReturnBuffer | ||
| 4851 | @ani.unsafe.Direct | 4847 | @ani.unsafe.Direct |
| 4852 | native static _FullScreenExitHandler_construct(): KPointer | 4848 | native static _FullScreenExitHandler_construct(): KPointer |
| 4853 | @ani.unsafe.Direct | 4849 | @ani.unsafe.Direct |
| @@ -14,7 +14,7 @@ | |||
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | import { UIContext } from "@ohos/arkui/UIContext" | 16 | import { UIContext } from "@ohos/arkui/UIContext" |
| 17 | -import { UIEventHelper } from 'arkui/component/idlize'; | 17 | +import { UIEventHelper, FrameNodeCreateInfo } from 'arkui/component/idlize'; |
| 18 | import { NodePosition, NodeEdges, Size, LengthMetrics, SizeT } from "./Graphics" | 18 | import { NodePosition, NodeEdges, Size, LengthMetrics, SizeT } from "./Graphics" |
| 19 | import { Finalizable, toPeerPtr, KPointer, MaterializedBase, nullptr, pointer, NativeThunk, | 19 | import { Finalizable, toPeerPtr, KPointer, MaterializedBase, nullptr, pointer, NativeThunk, |
| 20 | InteropNativeModule, SerializerBase } from "@koalaui/interop" | 20 | InteropNativeModule, SerializerBase } from "@koalaui/interop" |
| @@ -665,24 +665,23 @@ export class FrameNode implements MaterializedBase { | |||
| 665 | FrameNodeExtender.disposeTree(this); | 665 | FrameNodeExtender.disposeTree(this); |
| 666 | }; | 666 | }; |
| 667 | public static createFrameNodes(uiContext: UIContext, count: int32): Array<FrameNode> { | 667 | public static createFrameNodes(uiContext: UIContext, count: int32): Array<FrameNode> { |
| 668 | - const frameNodes: FrameNode[] = []; | 668 | + |
| 669 | if (count <= 0) { | 669 | if (count <= 0) { |
| 670 | - return frameNodes; | 670 | + return []; |
| 671 | } | 671 | } |
| 672 | + const frameNodes: Array<FrameNode> = new Array<FrameNode>(count); | ||
| 672 | ArkUIAniModule._Common_Sync_InstanceId(uiContext.instanceId_); | 673 | ArkUIAniModule._Common_Sync_InstanceId(uiContext.instanceId_); |
| 673 | - const ptrs = FrameNodeExtender.createFrameNodes(count); | 674 | + const frameNodeCreateInfoArray = FrameNodeExtender.getFrameNodeCreateInfoArray(count); |
| 674 | - ptrs.forEach((ptr: KPointer) => { | 675 | + const frameNodePtrs: Array<KPointer> = new Array<KPointer>(frameNodeCreateInfoArray.length); |
| 675 | - const frameNode = new FrameNode(uiContext, undefined, 'InternalBatchFrameNode', ptr); | 676 | + for (let i = 0; i < frameNodeCreateInfoArray.length; i++) { |
| 676 | - frameNodes.push(frameNode); | 677 | + const frameNode = new FrameNode(uiContext, undefined, 'InternalBatchFrameNode', frameNodeCreateInfoArray[i].frameNodePeer); |
| 677 | - }) | 678 | + frameNode.renderNode_!.peer = new Finalizable(frameNodeCreateInfoArray[i].renderNodePeer, RenderNode.getFinalizer()); |
| 678 | - ArkUIAniModule._SetCustomCallbackWithCheckForFrameNodes(ptrs, frameNodes); | 679 | + frameNode._nodeId = frameNodeCreateInfoArray[i].id; |
| 679 | - const renderNodePtrs = FrameNodeExtender.getRenderNodesByFrameNodes(ptrs); | 680 | + FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(frameNode._nodeId, frameNode); |
| 680 | - const ids = FrameNodeExtender.getIdsByFrameNodes(ptrs); | 681 | + frameNodes[i] = frameNode; |
| 681 | - for (let i = 0; i < frameNodes.length; i++) { | 682 | + frameNodePtrs[i] = frameNodeCreateInfoArray[i].frameNodePeer; |
| 682 | - frameNodes[i].renderNode_!.peer = new Finalizable(renderNodePtrs[i], RenderNode.getFinalizer()); | ||
| 683 | - frameNodes[i]._nodeId = ids[i]; | ||
| 684 | - FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(frameNodes[i]._nodeId, frameNodes[i]); | ||
| 685 | } | 683 | } |
| 684 | + ArkUIAniModule._SetCustomCallbackWithCheckForFrameNodes(frameNodePtrs, frameNodes); | ||
| 686 | ArkUIAniModule._Common_Restore_InstanceId(); | 685 | ArkUIAniModule._Common_Restore_InstanceId(); |
| 687 | return frameNodes; | 686 | return frameNodes; |
| 688 | } | 687 | } |
| @@ -1249,6 +1249,8 @@ typedef struct Array_font_UIFontGenericInfo Array_font_UIFontGenericInfo; | |||
| 1249 | typedef struct Opt_Array_font_UIFontGenericInfo Opt_Array_font_UIFontGenericInfo; | 1249 | typedef struct Opt_Array_font_UIFontGenericInfo Opt_Array_font_UIFontGenericInfo; |
| 1250 | typedef struct Array_FractionStop Array_FractionStop; | 1250 | typedef struct Array_FractionStop Array_FractionStop; |
| 1251 | typedef struct Opt_Array_FractionStop Opt_Array_FractionStop; | 1251 | typedef struct Opt_Array_FractionStop Opt_Array_FractionStop; |
| 1252 | +typedef struct Array_FrameNodeCreateInfo Array_FrameNodeCreateInfo; | ||
| 1253 | +typedef struct Opt_Array_FrameNodeCreateInfo Opt_Array_FrameNodeCreateInfo; | ||
| 1252 | typedef struct Array_GestureActionPhase Array_GestureActionPhase; | 1254 | typedef struct Array_GestureActionPhase Array_GestureActionPhase; |
| 1253 | typedef struct Opt_Array_GestureActionPhase Opt_Array_GestureActionPhase; | 1255 | typedef struct Opt_Array_GestureActionPhase Opt_Array_GestureActionPhase; |
| 1254 | typedef struct Array_GestureRecognizer Array_GestureRecognizer; | 1256 | typedef struct Array_GestureRecognizer Array_GestureRecognizer; |
| @@ -2389,6 +2391,8 @@ typedef struct Ark_FormInfo Ark_FormInfo; | |||
| 2389 | typedef struct Opt_FormInfo Opt_FormInfo; | 2391 | typedef struct Opt_FormInfo Opt_FormInfo; |
| 2390 | typedef struct Ark_FormLinkOptions Ark_FormLinkOptions; | 2392 | typedef struct Ark_FormLinkOptions Ark_FormLinkOptions; |
| 2391 | typedef struct Opt_FormLinkOptions Opt_FormLinkOptions; | 2393 | typedef struct Opt_FormLinkOptions Opt_FormLinkOptions; |
| 2394 | +typedef struct Ark_FrameNodeCreateInfo Ark_FrameNodeCreateInfo; | ||
| 2395 | +typedef struct Opt_FrameNodeCreateInfo Opt_FrameNodeCreateInfo; | ||
| 2392 | typedef struct Ark_FullScreenEnterEvent Ark_FullScreenEnterEvent; | 2396 | typedef struct Ark_FullScreenEnterEvent Ark_FullScreenEnterEvent; |
| 2393 | typedef struct Opt_FullScreenEnterEvent Opt_FullScreenEnterEvent; | 2397 | typedef struct Opt_FullScreenEnterEvent Opt_FullScreenEnterEvent; |
| 2394 | typedef struct Ark_GaugeOptions Ark_GaugeOptions; | 2398 | typedef struct Ark_GaugeOptions Ark_GaugeOptions; |
| @@ -10595,6 +10599,15 @@ typedef struct Opt_Array_FractionStop { | |||
| 10595 | Ark_Tag tag; | 10599 | Ark_Tag tag; |
| 10596 | Array_FractionStop value; | 10600 | Array_FractionStop value; |
| 10597 | } Opt_Array_FractionStop; | 10601 | } Opt_Array_FractionStop; |
| 10602 | +typedef struct Array_FrameNodeCreateInfo { | ||
| 10603 | + /* kind: ContainerType */ | ||
| 10604 | + Ark_FrameNodeCreateInfo* array; | ||
| 10605 | + Ark_Int32 length; | ||
| 10606 | +} Array_FrameNodeCreateInfo; | ||
| 10607 | +typedef struct Opt_Array_FrameNodeCreateInfo { | ||
| 10608 | + Ark_Tag tag; | ||
| 10609 | + Array_FrameNodeCreateInfo value; | ||
| 10610 | +} Opt_Array_FrameNodeCreateInfo; | ||
| 10598 | typedef struct Array_GestureActionPhase { | 10611 | typedef struct Array_GestureActionPhase { |
| 10599 | /* kind: ContainerType */ | 10612 | /* kind: ContainerType */ |
| 10600 | Ark_GestureActionPhase* array; | 10613 | Ark_GestureActionPhase* array; |
| @@ -16215,6 +16228,16 @@ typedef struct Opt_FormLinkOptions { | |||
| 16215 | Ark_Tag tag; | 16228 | Ark_Tag tag; |
| 16216 | Ark_FormLinkOptions value; | 16229 | Ark_FormLinkOptions value; |
| 16217 | } Opt_FormLinkOptions; | 16230 | } Opt_FormLinkOptions; |
| 16231 | +typedef struct Ark_FrameNodeCreateInfo { | ||
| 16232 | + /* kind: Interface */ | ||
| 16233 | + Ark_NativePointer frameNodePeer; | ||
| 16234 | + Ark_NativePointer renderNodePeer; | ||
| 16235 | + Ark_Int32 id; | ||
| 16236 | +} Ark_FrameNodeCreateInfo; | ||
| 16237 | +typedef struct Opt_FrameNodeCreateInfo { | ||
| 16238 | + Ark_Tag tag; | ||
| 16239 | + Ark_FrameNodeCreateInfo value; | ||
| 16240 | +} Opt_FrameNodeCreateInfo; | ||
| 16218 | typedef struct Ark_FullScreenEnterEvent { | 16241 | typedef struct Ark_FullScreenEnterEvent { |
| 16219 | /* kind: Interface */ | 16242 | /* kind: Interface */ |
| 16220 | Ark_FullScreenExitHandler handler; | 16243 | Ark_FullScreenExitHandler handler; |
| @@ -29518,13 +29541,11 @@ typedef struct GENERATED_ArkUIFrameNodeExtenderAccessor { | |||
| 29518 | Array_F64 (*convertPositionFromWindow)(Ark_FrameNode peer, | 29541 | Array_F64 (*convertPositionFromWindow)(Ark_FrameNode peer, |
| 29519 | const Ark_Vector2* positionByWindow); | 29542 | const Ark_Vector2* positionByWindow); |
| 29520 | void (*applyAttributesFinish)(Ark_FrameNode peer); | 29543 | void (*applyAttributesFinish)(Ark_FrameNode peer); |
| 29521 | - Array_Pointer (*createFrameNodes)(Ark_Int32 count); | ||
| 29522 | - Array_Pointer (*getRenderNodeByFrameNodes)(const Array_Pointer* ptrs); | ||
| 29523 | - Array_I32 (*getIdByFrameNodes)(const Array_Pointer* ptrs); | ||
| 29524 | Ark_NativePointer (*getFrameNodeById1)(Ark_FrameNode peer, | 29544 | Ark_NativePointer (*getFrameNodeById1)(Ark_FrameNode peer, |
| 29525 | const Ark_String* id); | 29545 | const Ark_String* id); |
| 29526 | Ark_NativePointer (*getFrameNodeByUniqueId1)(Ark_FrameNode peer, | 29546 | Ark_NativePointer (*getFrameNodeByUniqueId1)(Ark_FrameNode peer, |
| 29527 | Ark_Int32 id); | 29547 | Ark_Int32 id); |
| 29548 | + Array_FrameNodeCreateInfo (*getFrameNodeCreateInfoArray)(Ark_Int32 count); | ||
| 29528 | } GENERATED_ArkUIFrameNodeExtenderAccessor; | 29549 | } GENERATED_ArkUIFrameNodeExtenderAccessor; |
| 29529 | 29550 | ||
| 29530 | typedef struct GENERATED_ArkUIFullScreenExitHandlerAccessor { | 29551 | typedef struct GENERATED_ArkUIFullScreenExitHandlerAccessor { |
| @@ -1494,51 +1494,6 @@ Ark_Boolean IsOnMainTreeImpl(Ark_FrameNode peer) | |||
| 1494 | auto isOnMainTree = frameNode->IsOnMainTree(); | 1494 | auto isOnMainTree = frameNode->IsOnMainTree(); |
| 1495 | return isOnMainTree; | 1495 | return isOnMainTree; |
| 1496 | } | 1496 | } |
| 1497 | -Array_Pointer CreateFrameNodesImpl(Ark_Int32 count) | ||
| 1498 | -{ | ||
| 1499 | - std::vector<Ark_NativePointer> empty; | ||
| 1500 | - auto invalid = Converter::ArkValue<Array_Pointer>(empty, Converter::FC); | ||
| 1501 | - auto countVal = Converter::Convert<int32_t>(count); | ||
| 1502 | - std::vector<Ark_NativePointer> frameNodes; | ||
| 1503 | - for (int32_t i = 0; i < countVal; i++) { | ||
| 1504 | - auto nodeId = ElementRegister::GetInstance()->MakeUniqueId(); | ||
| 1505 | - auto node = NG::CustomFrameNode::GetOrCreateCustomFrameNode(nodeId); | ||
| 1506 | - CHECK_NULL_RETURN(node, invalid); | ||
| 1507 | - node->SetExclusiveEventForChild(true); | ||
| 1508 | - node->SetIsArkTsFrameNode(true); | ||
| 1509 | - auto peer = FrameNodePeer::Create(node); | ||
| 1510 | - frameNodes.emplace_back(peer); | ||
| 1511 | - } | ||
| 1512 | - return Converter::ArkValue<Array_Pointer>(frameNodes, Converter::FC); | ||
| 1513 | -} | ||
| 1514 | -Array_Pointer GetRenderNodesByFrameNodesImpl(const Array_Pointer* ptrs) | ||
| 1515 | -{ | ||
| 1516 | - std::vector<Ark_NativePointer> empty; | ||
| 1517 | - auto invalid = Converter::ArkValue<Array_Pointer>(empty, Converter::FC); | ||
| 1518 | - auto frameNodeVec = Converter::Convert<std::vector<Ark_NativePointer>>(*ptrs); | ||
| 1519 | - std::vector<Ark_NativePointer> renderNodes; | ||
| 1520 | - for (size_t i = 0; i < frameNodeVec.size(); i++) { | ||
| 1521 | - auto node = reinterpret_cast<FrameNodePeer*>(frameNodeVec[i]); | ||
| 1522 | - CHECK_NULL_RETURN(node, invalid); | ||
| 1523 | - renderNodes.emplace_back(node->GetRenderNodePeer()); | ||
| 1524 | - } | ||
| 1525 | - return Converter::ArkValue<Array_Pointer>(renderNodes, Converter::FC); | ||
| 1526 | -} | ||
| 1527 | -Array_I32 GetIdsByFrameNodesImpl(const Array_Pointer* ptrs) | ||
| 1528 | -{ | ||
| 1529 | - std::vector<int32_t> empty; | ||
| 1530 | - auto invalid = Converter::ArkValue<Array_I32>(empty, Converter::FC); | ||
| 1531 | - auto frameNodeVec = Converter::Convert<std::vector<Ark_NativePointer>>(*ptrs); | ||
| 1532 | - std::vector<int32_t> ids; | ||
| 1533 | - for (size_t i = 0; i < frameNodeVec.size(); i ++) { | ||
| 1534 | - auto node = reinterpret_cast<FrameNodePeer*>(frameNodeVec[i]); | ||
| 1535 | - CHECK_NULL_RETURN(node, invalid); | ||
| 1536 | - auto frameNode = FrameNodePeer::GetFrameNodeByPeer(node); | ||
| 1537 | - CHECK_NULL_RETURN(frameNode, invalid); | ||
| 1538 | - ids.emplace_back(frameNode->GetId()); | ||
| 1539 | - } | ||
| 1540 | - return Converter::ArkValue<Array_I32>(ids, Converter::FC); | ||
| 1541 | -} | ||
| 1542 | Ark_NativePointer GetFrameNodeById1Impl(Ark_FrameNode peer, | 1497 | Ark_NativePointer GetFrameNodeById1Impl(Ark_FrameNode peer, |
| 1543 | const Ark_String* id) | 1498 | const Ark_String* id) |
| 1544 | { | 1499 | { |
| @@ -1559,6 +1514,30 @@ Ark_NativePointer GetFrameNodeByUniqueId1Impl(Ark_FrameNode peer, | |||
| 1559 | CHECK_NULL_RETURN(node, nullptr); | 1514 | CHECK_NULL_RETURN(node, nullptr); |
| 1560 | return FrameNodePeer::Create(OHOS::Ace::AceType::RawPtr(node)); | 1515 | return FrameNodePeer::Create(OHOS::Ace::AceType::RawPtr(node)); |
| 1561 | } | 1516 | } |
| 1517 | +Array_FrameNodeCreateInfo GetFrameNodeCreateInfoArrayImpl(Ark_Int32 count) | ||
| 1518 | +{ | ||
| 1519 | + std::vector<Ark_FrameNodeCreateInfo> empty; | ||
| 1520 | + auto invalid = Converter::ArkValue<Array_FrameNodeCreateInfo>(empty, Converter::FC); | ||
| 1521 | + auto countVal = Converter::Convert<int32_t>(count); | ||
| 1522 | + std::vector<Ark_FrameNodeCreateInfo> frameNodeCreateInfoArray; | ||
| 1523 | + for (int32_t i = 0; i < countVal; i++) { | ||
| 1524 | + auto nodeId = ElementRegister::GetInstance()->MakeUniqueId(); | ||
| 1525 | + auto node = NG::CustomFrameNode::GetOrCreateCustomFrameNode(nodeId); | ||
| 1526 | + CHECK_NULL_RETURN(node, invalid); | ||
| 1527 | + node->SetExclusiveEventForChild(true); | ||
| 1528 | + node->SetIsArkTsFrameNode(true); | ||
| 1529 | + auto frameNodePeer = FrameNodePeer::Create(node); | ||
| 1530 | + CHECK_NULL_RETURN(frameNodePeer, invalid); | ||
| 1531 | + auto renderNodePeer = frameNodePeer->GetRenderNodePeer(); | ||
| 1532 | + auto frameNode = FrameNodePeer::GetFrameNodeByPeer(frameNodePeer); | ||
| 1533 | + CHECK_NULL_RETURN(frameNode, invalid); | ||
| 1534 | + auto id = frameNode->GetId(); | ||
| 1535 | + Ark_FrameNodeCreateInfo frameNodeCreateInfo { frameNodePeer, renderNodePeer, | ||
| 1536 | + Converter::ArkValue<Ark_Int32>(id) }; | ||
| 1537 | + frameNodeCreateInfoArray.emplace_back(frameNodeCreateInfo); | ||
| 1538 | + } | ||
| 1539 | + return Converter::ArkValue<Array_FrameNodeCreateInfo>(frameNodeCreateInfoArray, Converter::FC); | ||
| 1540 | +} | ||
| 1562 | } // FrameNodeExtenderAccessor | 1541 | } // FrameNodeExtenderAccessor |
| 1563 | const GENERATED_ArkUIFrameNodeExtenderAccessor* GetFrameNodeExtenderAccessor() | 1542 | const GENERATED_ArkUIFrameNodeExtenderAccessor* GetFrameNodeExtenderAccessor() |
| 1564 | { | 1543 | { |
| @@ -1640,11 +1619,9 @@ const GENERATED_ArkUIFrameNodeExtenderAccessor* GetFrameNodeExtenderAccessor() | |||
| 1640 | FrameNodeExtenderAccessor::ConvertPositionToWindowImpl, | 1619 | FrameNodeExtenderAccessor::ConvertPositionToWindowImpl, |
| 1641 | FrameNodeExtenderAccessor::ConvertPositionFromWindowImpl, | 1620 | FrameNodeExtenderAccessor::ConvertPositionFromWindowImpl, |
| 1642 | FrameNodeExtenderAccessor::ApplyAttributesFinishImpl, | 1621 | FrameNodeExtenderAccessor::ApplyAttributesFinishImpl, |
| 1643 | - FrameNodeExtenderAccessor::CreateFrameNodesImpl, | ||
| 1644 | - FrameNodeExtenderAccessor::GetRenderNodesByFrameNodesImpl, | ||
| 1645 | - FrameNodeExtenderAccessor::GetIdsByFrameNodesImpl, | ||
| 1646 | FrameNodeExtenderAccessor::GetFrameNodeById1Impl, | 1622 | FrameNodeExtenderAccessor::GetFrameNodeById1Impl, |
| 1647 | FrameNodeExtenderAccessor::GetFrameNodeByUniqueId1Impl, | 1623 | FrameNodeExtenderAccessor::GetFrameNodeByUniqueId1Impl, |
| 1624 | + FrameNodeExtenderAccessor::GetFrameNodeCreateInfoArrayImpl, | ||
| 1648 | }; | 1625 | }; |
| 1649 | return &FrameNodeExtenderAccessorImpl; | 1626 | return &FrameNodeExtenderAccessorImpl; |
| 1650 | } | 1627 | } |
| @@ -4289,6 +4289,7 @@ ASSIGN_OPT(Opt_Array_font_UIFontFallbackGroupInfo) | |||
| 4289 | ASSIGN_OPT(Opt_Array_font_UIFontFallbackInfo) | 4289 | ASSIGN_OPT(Opt_Array_font_UIFontFallbackInfo) |
| 4290 | ASSIGN_OPT(Opt_Array_font_UIFontGenericInfo) | 4290 | ASSIGN_OPT(Opt_Array_font_UIFontGenericInfo) |
| 4291 | ASSIGN_OPT(Opt_Array_FractionStop) | 4291 | ASSIGN_OPT(Opt_Array_FractionStop) |
| 4292 | +ASSIGN_OPT(Opt_Array_FrameNodeCreateInfo) | ||
| 4292 | ASSIGN_OPT(Opt_Array_GestureActionPhase) | 4293 | ASSIGN_OPT(Opt_Array_GestureActionPhase) |
| 4293 | ASSIGN_OPT(Opt_Array_GestureRecognizer) | 4294 | ASSIGN_OPT(Opt_Array_GestureRecognizer) |
| 4294 | ASSIGN_OPT(Opt_Array_GuideLineStyle) | 4295 | ASSIGN_OPT(Opt_Array_GuideLineStyle) |
| @@ -4859,6 +4860,7 @@ ASSIGN_OPT(Opt_ForegroundEffectOptions) | |||
| 4859 | ASSIGN_OPT(Opt_FormCallbackInfo) | 4860 | ASSIGN_OPT(Opt_FormCallbackInfo) |
| 4860 | ASSIGN_OPT(Opt_FormInfo) | 4861 | ASSIGN_OPT(Opt_FormInfo) |
| 4861 | ASSIGN_OPT(Opt_FormLinkOptions) | 4862 | ASSIGN_OPT(Opt_FormLinkOptions) |
| 4863 | +ASSIGN_OPT(Opt_FrameNodeCreateInfo) | ||
| 4862 | ASSIGN_OPT(Opt_FullScreenEnterEvent) | 4864 | ASSIGN_OPT(Opt_FullScreenEnterEvent) |
| 4863 | ASSIGN_OPT(Opt_GaugeOptions) | 4865 | ASSIGN_OPT(Opt_GaugeOptions) |
| 4864 | ASSIGN_OPT(Opt_GeometryTransitionOptions) | 4866 | ASSIGN_OPT(Opt_GeometryTransitionOptions) |
| @@ -466,4 +466,41 @@ HWTEST_F(ContentSlotSyntaxTestNg, OnDetachFromMainTreeDuplicate001, TestSize.Lev | |||
| 466 | EXPECT_EQ(detachCallbackCount, 1); | 466 | EXPECT_EQ(detachCallbackCount, 1); |
| 467 | EXPECT_FALSE(nodeContent->onMainTree_); | 467 | EXPECT_FALSE(nodeContent->onMainTree_); |
| 468 | } | 468 | } |
| 469 | + | ||
| 470 | +/** | ||
| 471 | + * @tc.name: AttachNodeContentReattach001 | ||
| 472 | + * @tc.desc: Test for ContentSlotNode::AttachNodeContent when content is already attached to another slot | ||
| 473 | + * @tc.type: FUNC | ||
| 474 | + */ | ||
| 475 | +HWTEST_F(ContentSlotSyntaxTestNg, AttachNodeContentReattach001, TestSize.Level1) | ||
| 476 | +{ | ||
| 477 | + /** | ||
| 478 | + * @tc.steps: step1. Create first contentSlotNode and attach content | ||
| 479 | + * @tc.expected: content attached successfully | ||
| 480 | + */ | ||
| 481 | + auto nodeContent = AceType::RawPtr(nodeContentPtr_); | ||
| 482 | + ASSERT_NE(nodeContent, nullptr); | ||
| 483 | + ContentSlotModel::Create(nodeContent); | ||
| 484 | + auto firstSlotNode = AceType::DynamicCast<ContentSlotNode>(ViewStackProcessor::GetInstance()->Finish()); | ||
| 485 | + ASSERT_NE(firstSlotNode, nullptr); | ||
| 486 | + EXPECT_EQ(firstSlotNode->GetTag(), V2::JS_NODE_SLOT_ETS_TAG); | ||
| 487 | + | ||
| 488 | + firstSlotNode->AttachNodeContent(nodeContent); | ||
| 489 | + auto firstContentSlot = nodeContent->GetContentSlot().Upgrade(); | ||
| 490 | + EXPECT_EQ(firstContentSlot, firstSlotNode); | ||
| 491 | + | ||
| 492 | + /** | ||
| 493 | + * @tc.steps: step2. Create second contentSlotNode and attach the same content | ||
| 494 | + * @tc.expected: content detached from first slot and attached to second slot | ||
| 495 | + */ | ||
| 496 | + auto nodeId = ElementRegister::GetInstance()->MakeUniqueId(); | ||
| 497 | + auto secondSlotNode = ContentSlotNode::GetOrCreateContentSlot(nodeId); | ||
| 498 | + ASSERT_NE(secondSlotNode, nullptr); | ||
| 499 | + EXPECT_NE(secondSlotNode, firstSlotNode); | ||
| 500 | + | ||
| 501 | + secondSlotNode->AttachNodeContent(nodeContent); | ||
| 502 | + auto secondContentSlot = nodeContent->GetContentSlot().Upgrade(); | ||
| 503 | + EXPECT_EQ(secondContentSlot, secondSlotNode); | ||
| 504 | + EXPECT_NE(secondContentSlot, firstSlotNode); | ||
| 505 | +} | ||
| 469 | } // namespace OHOS::Ace::NG | 506 | } // namespace OHOS::Ace::NG |