@shijiu/jsview 1.9.730 → 1.9.747

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dom/jsv-browser-debug-dom.js +1 -1
  2. package/dom/jsv-dom.js +1 -1
  3. package/dom/jsv-engine-js-browser.js +1 -1
  4. package/dom/jsv-forge-define.js +1 -1
  5. package/package.json +14 -17
  6. package/patches/node_modules/vite/dist/node/chunks/dep-0fc8e132.js +8 -1
  7. package/patches/node_modules/vite/dist/node/jsview.vite.config.js +12 -6
  8. package/dom/jsview-dom/README.md +0 -5
  9. package/dom/jsview-dom/package-lock.json-perfect +0 -3898
  10. package/dom/jsview-dom/package.json +0 -23
  11. package/dom/jsview-dom/rollup/browser-debug-dom.rollup.config.js +0 -15
  12. package/dom/jsview-dom/rollup/dom.rollup.config.js +0 -14
  13. package/dom/jsview-dom/rollup/engine-js-browser.rollup.config.js +0 -14
  14. package/dom/jsview-dom/rollup/forge-define.rollup.config.js +0 -14
  15. package/dom/jsview-dom/scripts/release_dist.sh +0 -36
  16. package/dom/jsview-dom/src/dom-browser-hook/HookDocument.js +0 -118
  17. package/dom/jsview-dom/src/dom-browser-hook/OriginDocument.js +0 -19
  18. package/dom/jsview-dom/src/dom-browser-hook/StyleFormatCheck.js +0 -559
  19. package/dom/jsview-dom/src/dom-browser-hook/index.js +0 -6
  20. package/dom/jsview-dom/src/dom-wrapper/ForgeExtension.js +0 -226
  21. package/dom/jsview-dom/src/dom-wrapper/JsViewForgeApp.js +0 -85
  22. package/dom/jsview-dom/src/dom-wrapper/JsViewProxy.js +0 -51
  23. package/dom/jsview-dom/src/dom-wrapper/event/AnimationEvent.js +0 -7
  24. package/dom/jsview-dom/src/dom-wrapper/event/Event.js +0 -12
  25. package/dom/jsview-dom/src/dom-wrapper/event/FocusEvent.js +0 -9
  26. package/dom/jsview-dom/src/dom-wrapper/event/KeyboardEvent.js +0 -43
  27. package/dom/jsview-dom/src/dom-wrapper/event/LoadEvent.js +0 -8
  28. package/dom/jsview-dom/src/dom-wrapper/index.js +0 -16
  29. package/dom/jsview-dom/src/dom-wrapper/node/AnchorElement.js +0 -24
  30. package/dom/jsview-dom/src/dom-wrapper/node/AudioElement.js +0 -60
  31. package/dom/jsview-dom/src/dom-wrapper/node/Comment.js +0 -10
  32. package/dom/jsview-dom/src/dom-wrapper/node/DivElement.js +0 -498
  33. package/dom/jsview-dom/src/dom-wrapper/node/Document.js +0 -274
  34. package/dom/jsview-dom/src/dom-wrapper/node/Element.js +0 -852
  35. package/dom/jsview-dom/src/dom-wrapper/node/FDivElement.js +0 -48
  36. package/dom/jsview-dom/src/dom-wrapper/node/HeadElement.js +0 -47
  37. package/dom/jsview-dom/src/dom-wrapper/node/ImageElement.js +0 -203
  38. package/dom/jsview-dom/src/dom-wrapper/node/JsvAudioTrackElement.js +0 -22
  39. package/dom/jsview-dom/src/dom-wrapper/node/JsvElement.js +0 -40
  40. package/dom/jsview-dom/src/dom-wrapper/node/LinkElement.js +0 -48
  41. package/dom/jsview-dom/src/dom-wrapper/node/MediaElement.js +0 -230
  42. package/dom/jsview-dom/src/dom-wrapper/node/Node.js +0 -178
  43. package/dom/jsview-dom/src/dom-wrapper/node/SVGElement.js +0 -9
  44. package/dom/jsview-dom/src/dom-wrapper/node/ScriptElement.js +0 -45
  45. package/dom/jsview-dom/src/dom-wrapper/node/StyleElement.js +0 -33
  46. package/dom/jsview-dom/src/dom-wrapper/node/StyleElementCache.js +0 -41
  47. package/dom/jsview-dom/src/dom-wrapper/node/Text.js +0 -22
  48. package/dom/jsview-dom/src/dom-wrapper/node/UnknownElement.js +0 -4
  49. package/dom/jsview-dom/src/dom-wrapper/node/VideoElement.js +0 -237
  50. package/dom/jsview-dom/src/dom-wrapper/style/BorderImage.js +0 -25
  51. package/dom/jsview-dom/src/dom-wrapper/style/Inset.js +0 -26
  52. package/dom/jsview-dom/src/dom-wrapper/style/JsvStyleVariable.js +0 -65
  53. package/dom/jsview-dom/src/dom-wrapper/style/KeyframeRule.js +0 -11
  54. package/dom/jsview-dom/src/dom-wrapper/style/StyleDeclaration.js +0 -609
  55. package/dom/jsview-dom/src/dom-wrapper/style/StyleSheet.js +0 -51
  56. package/dom/jsview-dom/src/dom-wrapper/style/StyleValue.js +0 -385
  57. package/dom/jsview-dom/src/dom-wrapper/style/TextStylePackMap.js +0 -43
  58. package/dom/jsview-dom/src/dom-wrapper/style/URL.js +0 -144
  59. package/dom/jsview-dom/src/dom-wrapper/utils/EventHandler.js +0 -42
  60. package/dom/jsview-dom/src/dom-wrapper/utils/FDivRoot.js +0 -86
  61. package/dom/jsview-dom/src/dom-wrapper/utils/JsvLazySyncCache.js +0 -64
  62. package/dom/jsview-dom/src/dom-wrapper/utils/Log.js +0 -42
  63. package/dom/jsview-dom/src/dom-wrapper/utils/MutationObserver.js +0 -32
  64. package/dom/jsview-dom/src/dom-wrapper/utils/focusableNode.js +0 -715
  65. package/dom/jsview-dom/src/engine-js/ForgeDefine.js +0 -8
  66. package/dom/jsview-dom/src/engine-js/ForgeExtensionDefine.js +0 -14
  67. package/dom/jsview-dom/src/engine-js/browser/PlatformUtils.js +0 -100
  68. package/dom/jsview-dom/src/engine-js/browser/animation_base.js +0 -313
  69. package/dom/jsview-dom/src/engine-js/browser/animation_keyframe.js +0 -64
  70. package/dom/jsview-dom/src/engine-js/browser/animation_progress.js +0 -287
  71. package/dom/jsview-dom/src/engine-js/browser/animation_proxy.js +0 -906
  72. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/demux.js +0 -143
  73. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/gifDecoder.js +0 -12
  74. package/dom/jsview-dom/src/engine-js/browser/apic_decoder/libwebp-0.6.0.min.js +0 -160
  75. package/dom/jsview-dom/src/engine-js/browser/console_log.js +0 -25
  76. package/dom/jsview-dom/src/engine-js/browser/dynamic_key_frames.js +0 -95
  77. package/dom/jsview-dom/src/engine-js/browser/easing.js +0 -114
  78. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/element_transform.js +0 -122
  79. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/gjk.js +0 -450
  80. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/mat.js +0 -102
  81. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/range_model.js +0 -296
  82. package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/test_collide.js +0 -10
  83. package/dom/jsview-dom/src/engine-js/browser/index.js +0 -38
  84. package/dom/jsview-dom/src/engine-js/browser/latex_parse.js +0 -336
  85. package/dom/jsview-dom/src/engine-js/browser/layout_params.js +0 -113
  86. package/dom/jsview-dom/src/engine-js/browser/layout_view.js +0 -3545
  87. package/dom/jsview-dom/src/engine-js/browser/layout_view_debug.js +0 -15
  88. package/dom/jsview-dom/src/engine-js/browser/media.js +0 -379
  89. package/dom/jsview-dom/src/engine-js/browser/page_base.js +0 -941
  90. package/dom/jsview-dom/src/engine-js/browser/particle_view.js +0 -526
  91. package/dom/jsview-dom/src/engine-js/browser/platform_timer.js +0 -61
  92. package/dom/jsview-dom/src/engine-js/browser/react_utils.js +0 -5
  93. package/dom/jsview-dom/src/engine-js/browser/rect_utils.js +0 -91
  94. package/dom/jsview-dom/src/engine-js/browser/render_bridge.js +0 -128
  95. package/dom/jsview-dom/src/engine-js/browser/render_texture_proxy.js +0 -155
  96. package/dom/jsview-dom/src/engine-js/browser/renderer_deprecated.js +0 -75
  97. package/dom/jsview-dom/src/engine-js/browser/sound_pool.js +0 -139
  98. package/dom/jsview-dom/src/engine-js/browser/steps_animation.js +0 -192
  99. package/dom/jsview-dom/src/engine-js/browser/text_style_cache.js +0 -454
  100. package/dom/jsview-dom/src/engine-js/browser/text_utils.js +0 -299
  101. package/dom/jsview-dom/src/engine-js/browser/text_view.js +0 -428
  102. package/dom/jsview-dom/src/engine-js/browser/texture_manager.js +0 -1060
  103. package/dom/jsview-dom/src/engine-js/browser/url.js +0 -69
  104. package/dom/jsview-dom/src/engine-js/browser/velocity.js +0 -40
  105. package/dom/jsview-dom/src/engine-js/browser/view_sensor/autofroze_sensor.js +0 -77
  106. package/dom/jsview-dom/src/engine-js/browser/view_sensor/drag_impact_sensor.js +0 -67
  107. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor.js +0 -98
  108. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_callback.js +0 -21
  109. package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_manager.js +0 -24
  110. package/dom/jsview-dom/src/engine-js/browser/view_sensor/index.js +0 -9
  111. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor.js +0 -268
  112. package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor_manager.js +0 -84
  113. package/dom/jsview-dom/src/engine-js/browser/view_sensor/visible_sensor.js +0 -213
  114. package/dom/jsview-dom/src/engine-js/browser/view_store.js +0 -41
  115. package/dom/jsview-dom/src/engine-js/index.js +0 -2
  116. package/dom/jsview-dom/src/engine-js/native/README.md +0 -1
@@ -1,941 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- /* eslint-disable */
3
- import Forge from "../ForgeDefine"
4
-
5
- let __ForgeWrapper;
6
- if (typeof ForgeExtension !== "undefined") {
7
- __ForgeWrapper = Forge;
8
- } else {
9
- __ForgeWrapper = {
10
- LogM: console.log.bind(console),
11
- LogF: console.error.bind(console),
12
- LogE: console.error.bind(console),
13
- LogW: console.warn.bind(console),
14
- LogI: console.log.bind(console),
15
- LogD: console.debug.bind(console),
16
- ThrowError: (msg)=>{ throw new Error(msg); },
17
- Assert: (assert_condition)=>{ if (!assert_condition) { /*debugger;*/throw new Error("ASSERT!!!!!");} },
18
- BaseActivity: class {}
19
- }
20
- }
21
-
22
- class __PageBase {
23
- /**
24
- * 界面子模块Base
25
- *
26
- * @public
27
- * @constructor Forge.PageBase
28
- * @param {String} name 子模块的名称(调试用的名字,可为null)
29
- * @param {Forge.LayoutViewBase} content_view ContentView
30
- * @param {Forge.BaseActivity} host_activity 宿主activity,提供TextureManager之类创建View需要的必要类
31
- **/
32
-
33
- constructor(name, content_view, host_activity) {
34
- this.PageName = name;
35
-
36
- /**
37
- * 焦点子PageBase
38
- * @protected
39
- * @name Forge.PageBase#_FocusChild
40
- * @type {Forge.PageBase}
41
- */
42
- this._FocusChild = null; // The child of this page
43
-
44
- this._LatestFocusChild = null;
45
-
46
- /**
47
- * 子节点的列表(PageBase列表)
48
- * @public
49
- * @name Forge.PageBase#SubPages
50
- * @type {Forge.PageBase[]}
51
- */
52
- this.SubPages = [];
53
-
54
- /**
55
- * 父PageBase
56
- * @protected
57
- * @name Forge.PageBase#_ParentPage
58
- * @type {Forge.PageBase}
59
- */
60
- this._ParentPage = null; // The parent of this page
61
-
62
- // Java key process
63
- this._ConsumeKeycodeUntilUp = -1;
64
-
65
- this.TouchDispatcher = null;
66
- this._Acc = 0.001;
67
-
68
- //Key lock
69
- this._KeyLock = false;
70
-
71
- this._CVSet = null;
72
-
73
- this._AutoShow = false;
74
-
75
- this._IsShowing = false;
76
-
77
- this._HostActivity = host_activity; // 初始化基础Activity,以便于获取TextureManager
78
-
79
- if (content_view) {
80
- this.SetContentView(content_view);
81
- }
82
- }
83
-
84
- OnRenderFrame () {
85
- __ForgeWrapper.LogE("OnRenderFrame() MUST override");
86
- }
87
-
88
- /**
89
- * 响应浏览器传过来的标准键值(可重载)
90
- *
91
- * @public
92
- * @func OnKeyDown
93
- * @memberof Forge.PageBase
94
- * @instance
95
- * @param {Event} ev 按键值
96
- * @return {boolean} true:消耗改键值,父节点不继续处理, false:不消耗这个键值,父节点继续处理
97
- **/
98
- OnKeyDown (ev) {
99
- return false;
100
- }
101
-
102
- /**
103
- * 响应浏览器传过来的标准键值(可重载)
104
- *
105
- * @public
106
- * @func OnKeyUp
107
- * @memberof Forge.PageBase
108
- * @instance
109
- * @param {Event} ev 按键值
110
- * @return {boolean} true:消耗改键值,父节点不继续处理, false:不消耗这个键值,父节点继续处理
111
- **/
112
- OnKeyUp (ev) {
113
- return false;
114
- }
115
-
116
- /**
117
- * 接收从浏览器传过来的标准键值(可重载,但需要调用super.DispatchKeyDown)
118
- *
119
- * @public
120
- * @func DispatchKeyDown
121
- * @memberof Forge.PageBase
122
- * @instance
123
- * @param {Event} ev 按键值
124
- * @return {boolean} true:消耗改键值,父节点不继续处理, false:不消耗这个键值,父节点继续处理
125
- **/
126
- DispatchKeyDown(ev) {
127
- if (this._KeyLock) {
128
- return true;
129
- }
130
- let consumed = false;
131
- __PageBase.LastFocusPage = this;
132
- if (this._FocusChild) {
133
- consumed = this._FocusChild.DispatchKeyDown(ev);
134
- }
135
- if (!consumed) {
136
- consumed = this.OnKeyDown(ev);
137
- }
138
-
139
- return consumed;
140
- }
141
-
142
- /**
143
- * 接收从浏览器传过来的标准键值(可重载,但需要调用super.DispatchKeyUp)
144
- *
145
- * @public
146
- * @func DispatchKeyUp
147
- * @memberof Forge.PageBase
148
- * @instance
149
- * @param {Event} ev 按键值
150
- * @return {boolean} true:消耗改键值,父节点不继续处理, false:不消耗这个键值,父节点继续处理
151
- **/
152
- DispatchKeyUp(ev) {
153
- if (this._KeyLock) {
154
- return true;
155
- }
156
- let consumed = false;
157
- if (this._FocusChild) {
158
- consumed = this._FocusChild.DispatchKeyUp(ev);
159
- }
160
- if (!consumed) {
161
- consumed = this.OnKeyUp(ev);
162
- }
163
-
164
- return consumed;
165
- }
166
-
167
- OnCustomerEvent(ev) {
168
- return false;
169
- }
170
-
171
- BubbleCustomerEvent(ev) {
172
- let consumed = this.OnCustomerEvent(ev);
173
- if (!consumed) {
174
- if (this._ParentPage) {
175
- this._ParentPage.BubbleCustomerEvent(ev);
176
- }
177
- }
178
- }
179
-
180
- /**
181
- * 调试接口:输出最后一次响应的page堆栈
182
- *
183
- * @public
184
- * @func PrintLastFocusPage
185
- * @memberof Forge.PageBase
186
- * @instance
187
- * @return {String} 最后一次响应的page堆栈
188
- **/
189
- PrintLastFocusPage() {
190
- let prt_str = "------"+this.PageName+"\n";
191
- let parent_page = this._ParentPage;
192
-
193
- if (parent_page) {
194
- prt_str += parent_page.PrintLastFocusPage();
195
- }
196
-
197
- return prt_str;
198
- }
199
-
200
- /**
201
- * (未完成)响应浏览器传过来的鼠标按下事件f
202
- *
203
- * @func OnMouseDown
204
- * @memberof Forge.PageBase
205
- * @instance
206
- * @param {Event} ev 鼠标按下事件
207
- * @return {boolean} true:消耗改键值,父节点不继续处理, false:不消耗这个键值,父节点继续处理
208
- **/
209
- OnMouseDown (ev) {
210
- return false;
211
- }
212
- /**
213
- * (未完成)使触控分发者有效
214
- *
215
- * @func EnableTouchDispatcher
216
- * @memberof Forge.PageBase
217
- * @instance
218
- **/
219
- EnableTouchDispatcher() {
220
- this.TouchDispatcher = new Forge.TouchDispatcher(this);
221
- }
222
- /**
223
- * (未完成)使触控分发者无效
224
- *
225
- * @func EnableTouchDispatcher
226
- * @memberof Forge.PageBase
227
- * @instance
228
- **/
229
- DisableTouchDispatcher() {
230
- this.TouchDispatcher = null;
231
- }
232
- /**
233
- * (未完成)获取触控View
234
- *
235
- * @func GetTouchView
236
- * @memberof Forge.PageBase
237
- * @instance
238
- * @return {Forge.LayoutView} 触控view
239
- **/
240
- GetTouchView() {
241
- return null;
242
- }
243
- /**
244
- * (未完成)通过速度及加速度,获取滑动参数
245
- *
246
- * @func GetSwipeParams
247
- * @memberof Forge.PageBase
248
- * @instance
249
- * @return {Object} 时长、距离 格式:{"durationX":duration_x, "durationY":duration_y,"distanceX":distance_x,"distanceY":distance_y}
250
- **/
251
- GetSwipeParams(v_x, v_y, acc) {
252
- let _acc = typeof acc === "undefined" || acc === 0 ? this._Acc:acc;
253
- let duration_x = Math.floor(Math.abs(v_x / _acc));
254
- let duration_y = Math.floor(Math.abs(v_y / _acc));
255
- let distance_x = v_x * v_x / 2 / _acc;
256
- if (v_x < 0) {
257
- distance_x = -distance_x;
258
- }
259
- let distance_y = v_y * v_y / 2 / _acc;
260
- if (v_y < 0) {
261
- distance_y = -distance_y;
262
- }
263
- return {"durationX":duration_x, "durationY":duration_y,"distanceX":distance_x,"distanceY":distance_y};
264
- }
265
- /**
266
- * (未完成)响应浏览器传过来的触控事件
267
- *
268
- * @func OnTouch
269
- * @memberof Forge.PageBase
270
- * @instance
271
- * @param {Forge.TouchEvent} ev 触控事件
272
- * @return {boolean} true:消耗改键值,父节点不继续处理, false:不消耗这个键值,父节点继续处理
273
- **/
274
- OnTouch (ev) {
275
- return false;
276
- }
277
- /**
278
- * (未完成)接收从浏览器传过来的触控事件
279
- *
280
- * @func DispatchTouch
281
- * @memberof Forge.PageBase
282
- * @instance
283
- * @param {Forge.TouchEvent} ev 触控事件
284
- * @return {boolean} true:消耗该键值,父节点不继续处理, false:不消耗这个键值,父节点继续处理
285
- **/
286
- DispatchTouch(ev) {
287
- let consumed = false;
288
- if (this.TouchDispatcher) {
289
- consumed = this.TouchDispatcher.OnTouch(ev);
290
- }
291
- return consumed;
292
- }
293
- /**
294
- * 失去触控点时触发该函数调用
295
- * @param ev
296
- * @constructor
297
- */
298
- LostTouchFocus(ev) {
299
-
300
- }
301
- /**
302
- * (Deprecated)响应从浏览器传过来的特殊JAVA键值(比如返回键,菜单键)<br>
303
- * 【注意】此为兼容函数,新应用请使用OnPlatformKey替代此函数
304
- *
305
- * @func OnJavaKey
306
- * @memberof Forge.PageBase
307
- * @instance
308
- * @param {int} keycode JAVA的按键值(参阅android的KeyCode定义)
309
- * @param {int} keyaction 0:按键按下,1:按键抬起
310
- * @return {boolean} true:父节点继续处理,Root节点仍为true时JAVA层继续处理, false:消耗改键值,父节点不继续处理
311
- **/
312
- OnJavaKey (keycode, keyaction) {
313
- return true;
314
- }
315
-
316
- /**
317
- * (Deprecated)响应从浏览器传过来的平台相关的特殊键值(比如返回键,菜单键)
318
- *
319
- * @func OnPlatformKey
320
- * @memberof Forge.PageBase
321
- * @instance
322
- * @param {int} keycode 键值,参考Forge.KeyMap
323
- * @param {int} keyaction 0:按键按下, 1:按键抬起
324
- * @return {boolean} 是否让父节点接收到键值,false:父节点将收不到键值。 true:父节点可收到键值
325
- **/
326
- OnPlatformKey(keycode, keyaction) {
327
- return true;
328
- }
329
-
330
- /**
331
- * (Deprecated)平台特殊键值处理函数
332
- *
333
- * @func PassPlatformKey
334
- * @memberof Forge.BaseActivity
335
- * @instance
336
- * @param {int} keycode 键值,参考Forge.KeyMap
337
- * @param {int} keyaction 0:按键按下, 1:按键抬起
338
- * @return {boolean} 是否让父节点接收到键值,false:父节点将收不到键值。 true:父节点可收到键值
339
- **/
340
- PassPlatformKey(keycode, keyaction) {
341
- if (this._KeyLock) {
342
- return false;
343
- }
344
- let if_pass_down = this.OnPlatformKey(keycode, keyaction);
345
- if (if_pass_down) {
346
- // 兼容老版本蜂鸟引擎API
347
- if_pass_down = this.OnJavaKey(keycode, keyaction);
348
- }
349
- return if_pass_down;
350
- }
351
-
352
- /**
353
- * (Deprecated)接收从浏览器传过来的特殊JAVA键值(比如返回键,菜单键)
354
- *
355
- * @func OnJavaKey
356
- * @memberof Forge.PageBase
357
- * @instance
358
- * @param {int} keycode JAVA的按键值(参阅android的KeyCode定义)
359
- * @param {int} keyaction 0:按键按下,1:按键抬起
360
- * @return {boolean} true:父节点继续处理,Root节点仍为true时JAVA层继续处理, false:消耗该键值,父节点不继续处理
361
- **/
362
- DispatchJavaKey (keycode, keyaction) {
363
- if (keycode === this._ConsumeKeycodeUntilUp) {
364
- if (keyaction === 1) {
365
- this._ConsumeKeycodeUntilUp = -1; // Found ignore key up, reset the flag
366
- }
367
- Forge.LogM("Consume Javakey until up keycode=" + keycode + " keyaction=" + keyaction);
368
- return false;
369
- }
370
- if (this._KeyLock) {
371
- return false;
372
- }
373
- if (this._ConsumeKeycodeUntilUp !== -1) {
374
- Forge.LogE("ERROR: Other key pressed before locked key release");
375
- this._ConsumeKeycodeUntilUp = -1;
376
- }
377
-
378
- let focus_child = this._FocusChild;
379
- let passthrough = true;
380
- if (focus_child) {
381
- // Process by child
382
- passthrough = focus_child.DispatchJavaKey(keycode, keyaction);
383
- }
384
-
385
- if (passthrough) {
386
- // Process by this node
387
- passthrough = this.PassPlatformKey(keycode, keyaction);
388
- }
389
-
390
- // Lock key until key-up when focus changed
391
- if (focus_child !== this._FocusChild && keyaction === 0) {
392
- this.CosumeAllKeyUnitlUpForFocusChange(keycode);
393
- }
394
-
395
- return passthrough;
396
- }
397
-
398
- /**
399
- * 锁定所有键值,直到收到key-up才解除锁定<br>
400
- * 防止按键串界面影响<br>
401
- * 锁定操作在根节点执行,当界面重新获得焦点时解除锁定
402
- *
403
- * @protected
404
- * @func CosumeAllKeyUnitlUpForFocusChange
405
- * @memberof Forge.PageBase
406
- * @instance
407
- * @param {int} keycode JAVA按键值
408
- **/
409
- CosumeAllKeyUnitlUpForFocusChange (keycode) {
410
- if (this._ParentPage) {
411
- this._ParentPage.CosumeAllKeyUnitlUpForFocusChange(keycode);
412
- } else {
413
- this._ConsumeKeycodeUntilUp = keycode;
414
- }
415
- }
416
-
417
- OnHostActivityGetFocus () {
418
- this._ConsumeKeycodeUntilUp = -1; // Reset to unlock JAVA key consume
419
- }
420
-
421
- /**
422
- * 查询本PageBase是否为焦点
423
- *
424
- * @public
425
- * @func IsFocus
426
- * @memberof Forge.PageBase
427
- * @instance
428
- * @return {boolean} 本PageBase是否为焦点
429
- **/
430
- IsFocus () {
431
- if (!this._ParentPage) {
432
- // Root will always be focused
433
- return true;
434
- }
435
- return (this._ParentPage._FocusChild === this);
436
- }
437
-
438
- _IsLeafInChain() {
439
- return this.IsFocus() && !this._FocusChild;
440
- }
441
-
442
- /**
443
- * 设置父节点
444
- *
445
- * @public
446
- * @func SetParent
447
- * @memberof Forge.PageBase
448
- * @instance
449
- * @param {Forge.PageBase|Forge.BaseActivity} parent 父节点
450
- * @param {Forge.LayoutViewBase} content_view ContentView
451
- **/
452
- SetParent (parent, content_view) {
453
- if (parent === null) {
454
- __ForgeWrapper.ThrowError("ERROR: parent is null");
455
- return;
456
- }
457
-
458
- if (content_view !== null) {
459
- this.SetContentView(content_view);
460
- }
461
-
462
- // Activity -> PageBase
463
- if (parent instanceof __ForgeWrapper.BaseActivity) {
464
- parent = parent.GetRootPageBase();
465
- }
466
-
467
- // 记录父子关系
468
- this._ParentPage = parent;
469
- parent.SubPages.push(this);
470
-
471
- // 传递hostActivity
472
- this._HostActivity = parent._HostActivity;
473
-
474
- // AutoShow时,自动进入show状态
475
- if (parent._IsShowing && this._AutoShow) {
476
- this._OnShowInternal();
477
- }
478
- }
479
-
480
- // (Deprecated)过期的API,兼容老应用
481
- SetParentPage (parent) {
482
- this.SetParent(parent);
483
- }
484
-
485
- /**
486
- * 删除指定Page
487
- *
488
- * @public
489
- * @func RemoveSubPage
490
- * @memberof Forge.PageBase
491
- * @instance
492
- * @param {Forge.PageBase} sub_page 子节点
493
- **/
494
- RemoveSubPage (sub_page) {
495
- if (sub_page === this._FocusChild)
496
- this._FocusChild = null;
497
-
498
- if (sub_page === this._LatestFocusChild)
499
- this._LatestFocusChild = null;
500
-
501
- for(let i=0; i<this.SubPages.length; i++) {
502
- if (sub_page === this.SubPages[i]) {
503
- sub_page._OnHideInternal(); // 当控制点被移除时,设置成隐藏状态
504
- this.SubPages.splice(i, 1);
505
- break;
506
- }
507
- }
508
- }
509
- /**
510
- * 清除子节点
511
- *
512
- * @public
513
- * @func ClearSubPages
514
- * @memberof Forge.PageBase
515
- * @instance
516
- * @param {nothing}
517
- **/
518
- ClearSubPages () {
519
- this.SubPages = [];
520
- this._FocusChild = null;
521
- this._LatestFocusChild = null;
522
- }
523
-
524
- /**
525
- * 取得当前父节点的引用
526
- *
527
- * @public
528
- * @func GetParentPage
529
- * @memberof Forge.PageBase
530
- * @instance
531
- * @return {Forge.PageBase} 父节点
532
- **/
533
- GetParentPage () {
534
- return this._ParentPage;
535
- }
536
-
537
- /**
538
- * 将本子界面设置为焦点(用户时间的响应目标)
539
- *
540
- * @public
541
- * @func Focus
542
- * @memberof Forge.PageBase
543
- * @param {boolean} blur_child_foucs 去除子view的Focus状态
544
- * @instance
545
- **/
546
- Focus(blur_child_foucs) {
547
- if (this.IsFocus()) {
548
- if (blur_child_foucs) {
549
- if (this._IsLeafInChain()) {
550
- __ForgeWrapper.LogI("Already focused page_name=" + this.PageName);
551
- return;
552
- }
553
- } else {
554
- __ForgeWrapper.LogI("Already focused page_name=" + this.PageName);
555
- return;
556
- }
557
- }
558
-
559
- if (__PageBase.sChangingFocusLock) {
560
- // 将Focus处理延缓,为了处理那些在onfocus和onblur中触发的新focus动作
561
- __PageBase.sDelayedFocusChanges.push(this);
562
- return;
563
- }
564
-
565
- __PageBase.sChangingFocusLock = true; // Lock the focus changing;
566
-
567
- if (this._ParentPage) {
568
- let new_focus_chain = []; // leaf to root
569
- let page_base = this;
570
- while(page_base._ParentPage && !page_base.IsFocus()) {
571
- new_focus_chain.push(page_base);
572
- page_base = page_base._ParentPage;
573
- }
574
-
575
- // Blur the previous focus chain( from leaf to root )
576
- let bluring_page_base
577
- if (blur_child_foucs && new_focus_chain.length === 0) { //若新的焦点依然在原来的Focus链上,则从新焦点的子开始blur
578
- bluring_page_base = this._FocusChild;
579
- } else {//否则从新旧Focus链最先的分支处开始blur
580
- bluring_page_base = new_focus_chain[new_focus_chain.length - 1]._ParentPage._FocusChild;
581
- }
582
- let bluring_chain = []; // root to leaf
583
- while(bluring_page_base) {
584
- bluring_chain.push(bluring_page_base);
585
- bluring_page_base = bluring_page_base._FocusChild;
586
- }
587
- for (let i = bluring_chain.length - 1; i >= 0; i--) {
588
- bluring_chain[i]._BlurInternal();
589
- }
590
-
591
- // Focus along the new focus chain( from root to leaf )
592
- for (let i = new_focus_chain.length - 1; i >= 0; i--) {
593
- new_focus_chain[i]._FocusInternal();
594
- }
595
-
596
- if (!blur_child_foucs) {
597
- // Auto do focus along the last leaf of new focus chain
598
- let top_focus_page_base = new_focus_chain[0];
599
- while (top_focus_page_base._LatestFocusChild) {
600
- if (top_focus_page_base._FocusChild === null) {
601
- // Auto focus when not focus set yet
602
- top_focus_page_base._LatestFocusChild._FocusInternal();
603
- } else {
604
- // Item with focused child not need to re-check
605
- break;
606
- }
607
- top_focus_page_base = top_focus_page_base._FocusChild;
608
- if (!top_focus_page_base) {
609
- __ForgeWrapper.ThrowError("ERROR: focus chain is broken");
610
- }
611
- }
612
- }
613
- }
614
-
615
- __PageBase.sChangingFocusLock = false;
616
-
617
- // 处理延缓中的Focus
618
- let delayed_length = __PageBase.sDelayedFocusChanges.length;
619
- if (delayed_length > 0) {
620
- // 换出延缓队列,以防新的focus动作中又有延缓触发
621
- let delayed_list = __PageBase.sDelayedFocusChanges;
622
- __PageBase.sDelayedFocusChanges = [];
623
- for (let i = 0; i < delayed_length; i++) {
624
- delayed_list[i].Focus();
625
- }
626
- }
627
- }
628
-
629
- /**
630
- * 将焦点给自己的父
631
- *
632
- * @public
633
- * @func ReturnFocusToParent
634
- * @memberof Forge.PageBase
635
- * @instance
636
- **/
637
- ReturnFocusToParent() {
638
- if (!this._ParentPage) return;
639
- if (this.IsFocus()) {
640
- this._ParentPage.Focus(true);
641
- }
642
- if (this._ParentPage._FocusChild == this) {
643
- this._ParentPage._FocusChild = null;
644
- }
645
- if (this._ParentPage._LatestFocusChild == this) {
646
- this._ParentPage._LatestFocusChild = null;
647
- }
648
- }
649
-
650
- _FocusInternal() {
651
- if (!this._ParentPage) {
652
- Forge.LogE("No dispatcher")
653
- return;
654
- }
655
-
656
- this._ParentPage._FocusChild = this;
657
- this._ParentPage._LatestFocusChild = this;
658
- this.OnFocus();
659
- }
660
-
661
- _BlurInternal () {
662
- if (!this._ParentPage) {
663
- Forge.LogE("No dispacher");
664
- }
665
- if (this._ParentPage._FocusChild !== this) {
666
- __ForgeWrapper.LogW("Not focus yet, page name=" + this.PageName);
667
- return;
668
- }
669
- this._ParentPage._FocusChild = null;
670
- this.OnBlur();
671
- }
672
-
673
- /**
674
- * 获取本子界面中获得焦点的子节点
675
- *
676
- * @public
677
- * @func GetFocusChild
678
- * @memberof Forge.PageBase
679
- * @instance
680
- * @return {Forge.PageBase} 获得焦点的子节点
681
- **/
682
- GetFocusChild() {
683
- return this._FocusChild;
684
- }
685
-
686
- /**
687
- * 让本子界面隐藏(焦点切换由外部控制,不自动切换)
688
- *
689
- * @public
690
- * @func Hide
691
- * @memberof Forge.PageBase
692
- * @instance
693
- **/
694
- Hide () {
695
- this._AutoShow = false; // 清理此状态
696
- this._OnHideInternal();
697
- }
698
-
699
- /**
700
- * 让本子界面展示并获得焦点
701
- *
702
- * @public
703
- * @func Show
704
- * @memberof Forge.PageBase
705
- * @instance
706
- * @param {boolean} get_focus 是否设置为焦点
707
- **/
708
- Show (get_focus) {
709
- this._OnShowInternal();
710
- if (get_focus)
711
- this.Focus();
712
- }
713
-
714
- /**
715
- * 焦点获得事件,如果本节点为父节点的焦点,当父节点的焦点获得焦点时,首先会执行父节点的OnFocus再执行本节点的OnFocus(可重载)
716
- *
717
- * @public
718
- * @func OnFocus
719
- * @memberof Forge.PageBase
720
- * @instance
721
- **/
722
- OnFocus () {
723
- __ForgeWrapper.LogW("No overrided Page OnFocus event, page name=" + this.PageName);
724
- }
725
-
726
-
727
- /**
728
- * 焦点丢失事件,如果本节点为父节点的焦点,当父节点的焦点丢失,首先会执行本节点的OnBlur再执行父节点的OnBlur(可重载)
729
- *
730
- * @public
731
- * @func OnBlur
732
- * @memberof Forge.PageBase
733
- * @instance
734
- **/
735
- OnBlur () {
736
- __ForgeWrapper.LogW("No overrided Page OnBlur event, page name=" + this.PageName);
737
- }
738
-
739
- /**
740
- * 当PageBase的Show时被调用,Show的调用见Forge.SceneSwitcher(可重载)
741
- *
742
- * @public
743
- * @func OnShow
744
- * @memberof Forge.PageBase
745
- * @instance
746
- **/
747
- OnShow () {
748
- __ForgeWrapper.LogW("No overrided Page OnShow event, page name=" + this.PageName);
749
- }
750
-
751
- /**
752
- * 当PageBase的Hide时被调用,Hide的调用见Forge.SceneSwitcher(可重载)
753
- *
754
- * @public
755
- * @func OnHide
756
- * @memberof Forge.PageBase
757
- * @instance
758
- **/
759
- OnHide () {
760
- __ForgeWrapper.LogW("No overrided Page OnHide event, page name=" + this.PageName);
761
- }
762
-
763
- // Protect接口,处理OnShow回调
764
- _OnShowInternal() {
765
- // 递归更新所有子节点的show状态
766
- let sub;
767
- for(let i=0; i<this.SubPages.length; i++) {
768
- sub = this.SubPages[i];
769
- if (sub._AutoShow) {
770
- sub._OnShowInternal();
771
- }
772
- }
773
-
774
- // 更新自身的show状态
775
- if (!this._IsShowing) {
776
- this._IsShowing = true;
777
- this.OnShow();
778
- }
779
- }
780
-
781
- // Protect接口,处理OnHide回调
782
- _OnHideInternal() {
783
- // 递归更新所有子节点的hide状态
784
- let sub;
785
- for(let i=0; i<this.SubPages.length; i++) {
786
- sub = this.SubPages[i];
787
- if (sub._IsShowing) {
788
- sub._OnHideInternal();
789
- }
790
- }
791
-
792
- // 更新自身的hide状态
793
- if (this._IsShowing) {
794
- this._IsShowing = false;
795
- this.OnHide();
796
- }
797
- }
798
-
799
- /**
800
- * (Deprecated)创建主界面的view的配置
801
- *
802
- * @func GetMainView
803
- * @memberof Forge.PageBase
804
- * @instance
805
- * @return {Forge.MainViewSetting} 返回主界面的主View设置
806
- **/
807
- GetMainView() {
808
- if (this._CVSet === null) {
809
- this._CVSet = new Forge.MainViewSetting(null, null);
810
- }
811
- return this._CVSet;
812
- }
813
-
814
- /**
815
- * 获取SetContentView中配置的view
816
- *
817
- * @public
818
- * @func GetContentView
819
- * @memberof Forge.PageBase
820
- * @instance
821
- * @return {Forge.LayoutView} 获取SetContentView中配置的view
822
- **/
823
- GetContentView() {
824
- if (this._CVSet === null)
825
- return null;
826
- else
827
- return this._CVSet.View;
828
- }
829
-
830
- /**
831
- * 设置主界面的ContentView
832
- *
833
- * @public
834
- * @func SetContentView
835
- * @memberof Forge.PageBase
836
- * @param {Forge.LayoutView} view 主界面
837
- * @instance
838
- **/
839
- SetContentView (view) {
840
- if (view !== null) {
841
- // 解除前一个绑定
842
- if (this._CVSet !== null) {
843
- this._CVSet.View.BindedPageBase(null);
844
- }
845
- this._CVSet = new Forge.MainViewSetting(view, null);
846
- view.BindedPageBase(this);
847
- }
848
- }
849
-
850
- /**
851
- * 内部函数,被LayoutView调用,当ContentView从根view移除时(例如被ClearViews时)
852
- */
853
- OnContentViewLostInternal() {
854
- this.OnContentViewLost();
855
- }
856
-
857
- /**
858
- * 当ContentView从根view移除时的回调(例如被ClearViews时)
859
- * 按需重载的回调函数
860
- *
861
- * @public
862
- * @func OnContentViewLost
863
- * @memberof Forge.PageBase
864
- * @instance
865
- **/
866
- OnContentViewLost() {
867
-
868
- }
869
-
870
- /**
871
- * 获取挂载的主Activity
872
- *
873
- * @public
874
- * @func GetHostActivity
875
- * @memberof Forge.PageBase
876
- * @return {Forge.TextureManager} 宿主Activity的TextureManager句柄
877
- * @instance
878
- **/
879
- GetHostActivity() {
880
- return this._HostActivity;
881
- }
882
-
883
- /**
884
- * 内部函数,设置hostActivity,创建Activity第一个PageBase时被Activity调用
885
- */
886
- SetHostActivity(host_activity) {
887
- this._HostActivity = host_activity;
888
- }
889
-
890
- /**
891
- * 获取创建Texture用的TextureManager
892
- *
893
- * @public
894
- * @func GetTextureManager
895
- * @memberof Forge.PageBase
896
- * @return {Forge.TextureManager} 宿主Activity的TextureManager句柄
897
- * @instance
898
- **/
899
- GetTextureManager() {
900
- if (this._HostActivity !== null) {
901
- return this._HostActivity.GetTextureManager();
902
- } else {
903
- return null;
904
- }
905
- }
906
-
907
- /**
908
- * 开启/关闭自动展示功能,若为自动展示,此控制点跟随父控制点一同展示和隐藏
909
- * (注意: 当Hide()被主动调用时,会自动关闭自动展示功能)
910
- *
911
- * @public
912
- * @func GetTextureManager
913
- * @memberof Forge.PageBase
914
- * @return {Forge.TextureManager} 宿主Activity的TextureManager句柄
915
- * @instance
916
- **/
917
- SetAutoShow(enable) {
918
- this._AutoShow = enable;
919
- }
920
-
921
- /**
922
- * 锁按键
923
- * @constructor
924
- */
925
- KeyLock() {
926
- this._KeyLock = true;
927
- }
928
- /**
929
- * 解锁按键
930
- * @constructor
931
- */
932
- UnKeyLock() {
933
- this._KeyLock = false;
934
- }
935
-
936
- }
937
- __PageBase.LastFocusPage = null;
938
- __PageBase.sChangingFocusLock = false;
939
- __PageBase.sDelayedFocusChanges = [];
940
-
941
- Forge.PageBase = __PageBase