• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16// real implemntation in C+ and exposed to JS
17// and mock implementation for testing
18class ViewStackProcessor {
19
20    // make and return new elementId
21    // will be used to create the next Component
22    // this is used for first rneder case
23    public static AllocateNewElmetIdForNextComponent(): number {
24        return -1;
25    }
26
27    // start Get access recording, and account all access to given elmtId
28    // Note this can be a different elmtId than the one used to create new Component
29    public static StartGetAccessRecordingFor(elmtId: number): void {
30    }
31
32    /**
33     * get the elmtId to which any get access shoudl be accounted
34     * note this can be the same as the currently created elmtId (top of stack)
35     * but also a different one (in case a whole subtree gets accounted its root elmtId)
36     *
37     * returns the elmtId given by StartGetAccessRecordingFor
38     * -1 no access recording
39     */
40    public static GetElmtIdToAccountFor(): number {
41        return -1;
42    }
43
44    // Stop get access recording
45    // also invalidates any reserved but unclaimed elmtId for Component creation
46    public static StopGetAccessRecording(): void {
47    }
48
49
50    /**
51     * when nesting observeComponentCreation functions, such as in the case of
52     * If, and the if branch creates a Text etc that requires an implict pop
53     *  this function is needed after executing the inner observeComponentCreation
54     *  and before read ViewStackProcessor.GetTopMostElementId(); on the outer one
55     */
56    public static ImplicitPopBeforeContinue(): void {
57    }
58
59    /**
60     * Called once JS update function has been executed, main component
61     * and its wrapping components in the stack need to be 'Finished'
62     * and then a local update be done on given main Element and
63     * wrapping Elements
64     */
65    public static FinishAndLocalUpdate(elmtId: number): void  {
66    }
67
68    static MakeUniqueId() : number {
69        return ViewStackProcessor.nextId++
70    }
71
72    private static nextId : number = 1;
73  }
74