@shijiu/jsview 1.9.719
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.
- package/dom/bin/jsview-browser-debug-dom.min.js +1 -0
- package/dom/bin/jsview-dom.min.js +1 -0
- package/dom/bin/jsview-engine-js-browser.min.js +1 -0
- package/dom/bin/jsview-forge-define.min.js +1 -0
- package/dom/browser-root-style.css +21 -0
- package/dom/jsv-browser-debug-dom.js +8 -0
- package/dom/jsv-dom.js +6 -0
- package/dom/jsv-engine-js-browser.js +6 -0
- package/dom/jsv-forge-define.js +6 -0
- package/dom/jsview-dom/README.md +5 -0
- package/dom/jsview-dom/package-lock.json-perfect +3898 -0
- package/dom/jsview-dom/package.json +23 -0
- package/dom/jsview-dom/rollup/browser-debug-dom.rollup.config.js +15 -0
- package/dom/jsview-dom/rollup/dom.rollup.config.js +14 -0
- package/dom/jsview-dom/rollup/engine-js-browser.rollup.config.js +14 -0
- package/dom/jsview-dom/rollup/forge-define.rollup.config.js +14 -0
- package/dom/jsview-dom/scripts/release_dist.sh +36 -0
- package/dom/jsview-dom/src/dom-browser-hook/HookDocument.js +118 -0
- package/dom/jsview-dom/src/dom-browser-hook/OriginDocument.js +19 -0
- package/dom/jsview-dom/src/dom-browser-hook/StyleFormatCheck.js +559 -0
- package/dom/jsview-dom/src/dom-browser-hook/index.js +6 -0
- package/dom/jsview-dom/src/dom-wrapper/ForgeExtension.js +226 -0
- package/dom/jsview-dom/src/dom-wrapper/JsViewForgeApp.js +85 -0
- package/dom/jsview-dom/src/dom-wrapper/JsViewProxy.js +51 -0
- package/dom/jsview-dom/src/dom-wrapper/event/AnimationEvent.js +7 -0
- package/dom/jsview-dom/src/dom-wrapper/event/Event.js +12 -0
- package/dom/jsview-dom/src/dom-wrapper/event/FocusEvent.js +9 -0
- package/dom/jsview-dom/src/dom-wrapper/event/KeyboardEvent.js +43 -0
- package/dom/jsview-dom/src/dom-wrapper/event/LoadEvent.js +8 -0
- package/dom/jsview-dom/src/dom-wrapper/index.js +16 -0
- package/dom/jsview-dom/src/dom-wrapper/node/AnchorElement.js +24 -0
- package/dom/jsview-dom/src/dom-wrapper/node/AudioElement.js +60 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Comment.js +10 -0
- package/dom/jsview-dom/src/dom-wrapper/node/DivElement.js +498 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Document.js +274 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Element.js +852 -0
- package/dom/jsview-dom/src/dom-wrapper/node/FDivElement.js +48 -0
- package/dom/jsview-dom/src/dom-wrapper/node/HeadElement.js +47 -0
- package/dom/jsview-dom/src/dom-wrapper/node/ImageElement.js +203 -0
- package/dom/jsview-dom/src/dom-wrapper/node/JsvAudioTrackElement.js +22 -0
- package/dom/jsview-dom/src/dom-wrapper/node/JsvElement.js +40 -0
- package/dom/jsview-dom/src/dom-wrapper/node/LinkElement.js +48 -0
- package/dom/jsview-dom/src/dom-wrapper/node/MediaElement.js +230 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Node.js +178 -0
- package/dom/jsview-dom/src/dom-wrapper/node/SVGElement.js +9 -0
- package/dom/jsview-dom/src/dom-wrapper/node/ScriptElement.js +45 -0
- package/dom/jsview-dom/src/dom-wrapper/node/StyleElement.js +33 -0
- package/dom/jsview-dom/src/dom-wrapper/node/StyleElementCache.js +41 -0
- package/dom/jsview-dom/src/dom-wrapper/node/Text.js +22 -0
- package/dom/jsview-dom/src/dom-wrapper/node/UnknownElement.js +4 -0
- package/dom/jsview-dom/src/dom-wrapper/node/VideoElement.js +237 -0
- package/dom/jsview-dom/src/dom-wrapper/style/BorderImage.js +25 -0
- package/dom/jsview-dom/src/dom-wrapper/style/Inset.js +26 -0
- package/dom/jsview-dom/src/dom-wrapper/style/JsvStyleVariable.js +65 -0
- package/dom/jsview-dom/src/dom-wrapper/style/KeyframeRule.js +11 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleDeclaration.js +609 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleSheet.js +51 -0
- package/dom/jsview-dom/src/dom-wrapper/style/StyleValue.js +385 -0
- package/dom/jsview-dom/src/dom-wrapper/style/TextStylePackMap.js +43 -0
- package/dom/jsview-dom/src/dom-wrapper/style/URL.js +144 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/EventHandler.js +42 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/FDivRoot.js +86 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/JsvLazySyncCache.js +64 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/Log.js +42 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/MutationObserver.js +32 -0
- package/dom/jsview-dom/src/dom-wrapper/utils/focusableNode.js +715 -0
- package/dom/jsview-dom/src/engine-js/ForgeDefine.js +8 -0
- package/dom/jsview-dom/src/engine-js/ForgeExtensionDefine.js +14 -0
- package/dom/jsview-dom/src/engine-js/browser/PlatformUtils.js +100 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_base.js +313 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_keyframe.js +64 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_progress.js +287 -0
- package/dom/jsview-dom/src/engine-js/browser/animation_proxy.js +906 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/demux.js +143 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/gifDecoder.js +12 -0
- package/dom/jsview-dom/src/engine-js/browser/apic_decoder/libwebp-0.6.0.min.js +160 -0
- package/dom/jsview-dom/src/engine-js/browser/console_log.js +25 -0
- package/dom/jsview-dom/src/engine-js/browser/dynamic_key_frames.js +95 -0
- package/dom/jsview-dom/src/engine-js/browser/easing.js +114 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/element_transform.js +122 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/gjk.js +450 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/mat.js +102 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/range_model.js +296 -0
- package/dom/jsview-dom/src/engine-js/browser/html_shared_tools/test_collide.js +10 -0
- package/dom/jsview-dom/src/engine-js/browser/index.js +38 -0
- package/dom/jsview-dom/src/engine-js/browser/latex_parse.js +336 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_params.js +113 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_view.js +3545 -0
- package/dom/jsview-dom/src/engine-js/browser/layout_view_debug.js +15 -0
- package/dom/jsview-dom/src/engine-js/browser/media.js +379 -0
- package/dom/jsview-dom/src/engine-js/browser/page_base.js +941 -0
- package/dom/jsview-dom/src/engine-js/browser/particle_view.js +526 -0
- package/dom/jsview-dom/src/engine-js/browser/platform_timer.js +61 -0
- package/dom/jsview-dom/src/engine-js/browser/react_utils.js +5 -0
- package/dom/jsview-dom/src/engine-js/browser/rect_utils.js +91 -0
- package/dom/jsview-dom/src/engine-js/browser/render_bridge.js +128 -0
- package/dom/jsview-dom/src/engine-js/browser/render_texture_proxy.js +155 -0
- package/dom/jsview-dom/src/engine-js/browser/renderer_deprecated.js +75 -0
- package/dom/jsview-dom/src/engine-js/browser/sound_pool.js +139 -0
- package/dom/jsview-dom/src/engine-js/browser/steps_animation.js +192 -0
- package/dom/jsview-dom/src/engine-js/browser/text_style_cache.js +454 -0
- package/dom/jsview-dom/src/engine-js/browser/text_utils.js +299 -0
- package/dom/jsview-dom/src/engine-js/browser/text_view.js +428 -0
- package/dom/jsview-dom/src/engine-js/browser/texture_manager.js +1060 -0
- package/dom/jsview-dom/src/engine-js/browser/url.js +69 -0
- package/dom/jsview-dom/src/engine-js/browser/velocity.js +40 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/autofroze_sensor.js +77 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/drag_impact_sensor.js +67 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor.js +98 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_callback.js +21 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/impact_sensor_manager.js +24 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/index.js +9 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor.js +268 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/view_sensor_manager.js +84 -0
- package/dom/jsview-dom/src/engine-js/browser/view_sensor/visible_sensor.js +213 -0
- package/dom/jsview-dom/src/engine-js/browser/view_store.js +41 -0
- package/dom/jsview-dom/src/engine-js/index.js +2 -0
- package/dom/jsview-dom/src/engine-js/native/README.md +1 -0
- package/dom/target_core_revision.mjs +15 -0
- package/index.js +0 -0
- package/loader/header_script_loader.js +134 -0
- package/loader/jsview-main.js +42 -0
- package/loader/jsview.config.default.js +37 -0
- package/loader/jsview.default.config.js +37 -0
- package/loader/loader.js +183 -0
- package/loader/loader_webkit.js +40 -0
- package/package.json +31 -0
- package/patches/node_modules/@vitejs/plugin-react/dist/index.cjs +520 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +17609 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +335 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +446 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +91 -0
- package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +8038 -0
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +1700 -0
- package/patches/node_modules/postcss-js/objectifier.js +90 -0
- package/patches/node_modules/vite/dist/node/chunks/dep-0fc8e132.js +63175 -0
- package/patches/node_modules/vite/dist/node/jsview-react.vite.config.js +7 -0
- package/patches/node_modules/vite/dist/node/jsview-vue.vite.config.js +7 -0
- package/patches/node_modules/vite/dist/node/jsview.vite.config.js +56 -0
- package/patches/node_modules/vue-router/dist/vue-router.mjs +3595 -0
- package/tools/common.js +58 -0
- package/tools/jsview-jsmap-serve.js +105 -0
- package/tools/jsview-post-build.js +184 -0
- package/tools/jsview-post-install-react.js +13 -0
- package/tools/jsview-post-install-vue.js +16 -0
- package/tools/jsview-post-install.js +116 -0
- package/tools/jsview-run-android.js +67 -0
- package/tsconfig.json +34 -0
|
@@ -0,0 +1,852 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
/* eslint-disable no-extra-boolean-cast */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
import Log from "../utils/Log";
|
|
5
|
+
import Forge from "../../engine-js/ForgeDefine";
|
|
6
|
+
import Node from "./Node";
|
|
7
|
+
import FocusEvent from "../event/FocusEvent";
|
|
8
|
+
import AnimationEvent from "../event/AnimationEvent";
|
|
9
|
+
import StyleDeclaration from "../style/StyleDeclaration";
|
|
10
|
+
import {JsvLazySyncCache, gSyncTimesCounter} from "../utils/JsvLazySyncCache";
|
|
11
|
+
import ForgeExtension from "../ForgeExtension";
|
|
12
|
+
import EventHandler from "../utils/EventHandler";
|
|
13
|
+
|
|
14
|
+
class Element extends Node {
|
|
15
|
+
constructor(tag) {
|
|
16
|
+
// console.log("Element.constructor()");
|
|
17
|
+
super(Node.ELEMENT_NODE);
|
|
18
|
+
this.parentElement = null;
|
|
19
|
+
this.tagName = this.jsvGetTagName();
|
|
20
|
+
|
|
21
|
+
if(this.tagName === Element.TAG.STYLE) {
|
|
22
|
+
this.style = null;
|
|
23
|
+
this.jsvMainView = null;
|
|
24
|
+
this.jsvMaskView = null;
|
|
25
|
+
} else {
|
|
26
|
+
this.style = new StyleDeclaration();
|
|
27
|
+
this.jsvMainView = new Forge.LayoutView();
|
|
28
|
+
this.jsvMaskView = null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.jsvAnimation = null;
|
|
32
|
+
|
|
33
|
+
this.jsvStore = {
|
|
34
|
+
transition: null,
|
|
35
|
+
transitionTmp: null,
|
|
36
|
+
textContent: null,
|
|
37
|
+
textStylePack: null, // 文字StylePackCache缓存,若仅文字内容变化,则可以使用缓存
|
|
38
|
+
clientWidth: NaN,
|
|
39
|
+
clientHeight: NaN,
|
|
40
|
+
textureWidth: NaN,
|
|
41
|
+
textureHeight: NaN,
|
|
42
|
+
scopedAttributes: [],
|
|
43
|
+
};
|
|
44
|
+
this.jsvAttrChangedLazySync = null; // 记录需要延后同步的本地变化过的Attribute
|
|
45
|
+
|
|
46
|
+
this.instantSwapCallback = null;
|
|
47
|
+
this.eventHandlers = null;
|
|
48
|
+
|
|
49
|
+
this.jsvInheritClassDepth = null;
|
|
50
|
+
this.jsvHasInheritClassChildren = false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
appendChild(node) {
|
|
54
|
+
if (node.parentNode != null) {
|
|
55
|
+
this._moveChildNode(node, null);
|
|
56
|
+
} else {
|
|
57
|
+
// console.warn("Element.appendChild() this=", this, " child=", node);
|
|
58
|
+
super.appendChild(node);
|
|
59
|
+
this.jsvInsertChild(node, null);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
removeChild(node) {
|
|
64
|
+
// console.warn("Element.removeChild() this=", this, " child=", node);
|
|
65
|
+
this.jsvRemoveChild(node);
|
|
66
|
+
super.removeChild(node);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
insertBefore(node, beforeNode) {
|
|
70
|
+
if (node.parentNode != null) {
|
|
71
|
+
this._moveChildNode(node, beforeNode);
|
|
72
|
+
} else {
|
|
73
|
+
super.insertBefore(node, beforeNode);
|
|
74
|
+
this.jsvInsertChild(node, beforeNode);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
_moveChildNode(node, beforeNode) {
|
|
79
|
+
// 支持keep alive的element move操作
|
|
80
|
+
let origin_parent = node.parentNode;
|
|
81
|
+
origin_parent.moveChild(node, this, beforeNode);
|
|
82
|
+
|
|
83
|
+
// forge move child
|
|
84
|
+
// beforeNode = this.jsvBackwardFindForgeView(beforeNode);
|
|
85
|
+
if (node.jsvMaskView) {
|
|
86
|
+
let parent_view = origin_parent.jsvMaskView ? origin_parent.jsvMaskView : origin_parent.jsvMainView
|
|
87
|
+
parent_view.MoveChildView(
|
|
88
|
+
node.jsvMaskView,
|
|
89
|
+
this.jsvMaskView ? this.jsvMaskView : this.jsvMainView,
|
|
90
|
+
beforeNode ? beforeNode.jsvMaskView : null
|
|
91
|
+
);
|
|
92
|
+
console.log("moving child");
|
|
93
|
+
} else {
|
|
94
|
+
// 非div的node执行move动作
|
|
95
|
+
console.log("moving not forge child");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get childElementCount() {
|
|
100
|
+
return this.childNodes.length;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
get firstElementChild() {
|
|
104
|
+
const childCount = this.childNodes.length;
|
|
105
|
+
return (childCount > 0 ? this.childNodes[0] : null);
|
|
106
|
+
}
|
|
107
|
+
get lastElementChild() {
|
|
108
|
+
const childCount = this.childNodes.length;
|
|
109
|
+
return (childCount > 0 ? this.childNodes[childCount - 1] : null);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
set className(value) {
|
|
113
|
+
// console.log("Element.set className() value=" + value);
|
|
114
|
+
this.setAttribute("class", value)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
setAttribute(name, value) {
|
|
118
|
+
// console.log("Element.setAttribute() tag=" + this.tagName + ", name=" + name + ", value=" + value);
|
|
119
|
+
if(!name) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (name === "style") {
|
|
124
|
+
console.warn("directly style setting be ignored");
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this[name] = value;
|
|
129
|
+
// vue scoped时会设置此属性,利用Css的.class[prop]的性质设置<style scoped>
|
|
130
|
+
if (name.startsWith("data-v-")) {
|
|
131
|
+
this._jsvAppendScopedAttribute(name, 0);
|
|
132
|
+
} else if (name === "class") { // classNames设定
|
|
133
|
+
this._jsvSetClassNames(value, 0);
|
|
134
|
+
} else if (name === "jsv-inherit-class") { // 设置了这个属性后,自身的class会失效
|
|
135
|
+
this._jsvSetInheritClassDepth(parseInt(value));
|
|
136
|
+
} else if(name.startsWith(Element.ATTRIBUTE.JSVPREFIX)) {
|
|
137
|
+
name = name.replace(/-/g, '_'); // 兼容旧的ForgeJs
|
|
138
|
+
this.jsvSetAttrLazySync(name, Element.ATTRTYPE.JSV);
|
|
139
|
+
} else if (!window.JsView && name === "id") {
|
|
140
|
+
// 在PC上devtools中追加跟踪元素位置的便利性
|
|
141
|
+
if (this.jsvMainView.Element) {
|
|
142
|
+
this.jsvMainView.Element.id = value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
jsvSetAttrLazySync(name, attrib_type) {
|
|
148
|
+
if (!this.jsvAttrChangedLazySync) {
|
|
149
|
+
this.jsvAttrChangedLazySync = new JsvLazySyncCache("lazy-attr");
|
|
150
|
+
if (this.parentElement) {
|
|
151
|
+
// 晚于 jsvOnLoadForgeView, 要进行callback设置
|
|
152
|
+
this._jsvSetAttrLazySyncCallback();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
this.jsvAttrChangedLazySync.setCacheProperty(name, attrib_type);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
removeAttribute(name) {
|
|
159
|
+
// console.log("Element.removeAttribute() name=" + name);
|
|
160
|
+
this[name] = undefined;
|
|
161
|
+
if(name.startsWith(Element.ATTRIBUTE.JSVPREFIX)) {
|
|
162
|
+
this.jsvSetAttrLazySync(name, Element.ATTRTYPE.JSV);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
getAttribute(name) {
|
|
167
|
+
// console.log("Element.getAttribute() name=" + name);
|
|
168
|
+
return this[name];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
hasAttribute(name) {
|
|
172
|
+
console.log("Element.hasAttribute() name=" + name);
|
|
173
|
+
return !!this[name];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
getBoundingClientRect() {
|
|
177
|
+
if (this.jsvMainView != null) {
|
|
178
|
+
return this.jsvMainView.GetBoundingClientRect();
|
|
179
|
+
} else {
|
|
180
|
+
return Promise.reject(new Error("getBoundingClientRect while jsvMainView is null."));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
get clientWidth() {
|
|
186
|
+
return (isNaN(this.jsvStore.clientWidth) ? this.style.width : this.jsvStore.clientWidth);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
get clientHeight() {
|
|
190
|
+
return (isNaN(this.jsvStore.clientHeight) ? this.style.height : this.jsvStore.clientHeight);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
focus() {
|
|
194
|
+
console.log("Element.focus()");
|
|
195
|
+
if(!!document.activeElement) {
|
|
196
|
+
document.activeElement.onfocus();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
let oldActiveElement = document.activeElement;
|
|
200
|
+
document.activeElement = this;
|
|
201
|
+
|
|
202
|
+
if (!!oldActiveElement) {
|
|
203
|
+
let blurEvent = new FocusEvent(FocusEvent.Type.BLUR);
|
|
204
|
+
blurEvent.target = oldActiveElement;
|
|
205
|
+
document.dispatchEvent(blurEvent);
|
|
206
|
+
}
|
|
207
|
+
let focusEvent = new FocusEvent(FocusEvent.Type.FOCUS);
|
|
208
|
+
document.dispatchEvent(focusEvent);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
jsvInsertChild(node, beforeNode) {
|
|
212
|
+
// console.warn("Element.jsvInsertChild() this=", this, " child=", node);
|
|
213
|
+
node.parentElement = this;
|
|
214
|
+
|
|
215
|
+
if(node.nodeType === Node.ELEMENT_NODE
|
|
216
|
+
&& node.tagName !== Element.TAG.STYLE) {
|
|
217
|
+
if (document.jsvIsReady === false) {
|
|
218
|
+
console.warn("Element.appendChild() Failed to append child to Forge. jsvIsReady=" + document.jsvIsReady);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
node.jsvOnLoadForgeView();
|
|
223
|
+
// 如果设置了layout,会触发jsvFlushViewLayout()
|
|
224
|
+
node.style.jsvSetChangedListener(node.jsvOnStyleChanged.bind(node));
|
|
225
|
+
|
|
226
|
+
beforeNode = this.jsvBackwardFindForgeView(beforeNode);
|
|
227
|
+
let layoutParams = node.jsvMaskView.GetLayoutParams();
|
|
228
|
+
this.jsvMainView.InsertView(node.jsvMaskView,
|
|
229
|
+
(beforeNode ? beforeNode.jsvMaskView : null),
|
|
230
|
+
layoutParams);
|
|
231
|
+
// console.log("Element.appendChild() node.layoutParams=", layoutParams);
|
|
232
|
+
|
|
233
|
+
if (node.jsvInheritClassDepth > 0
|
|
234
|
+
|| node.jsvHasInheritClassChildren) {
|
|
235
|
+
this.jsvHasInheritClassChildren = true;
|
|
236
|
+
}
|
|
237
|
+
} else if (node.nodeType === Node.TEXT_NODE) {
|
|
238
|
+
this.textContent = node.textContent;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
jsvGetProxyView(get_mask_view) {
|
|
243
|
+
if (get_mask_view) {
|
|
244
|
+
return this.jsvMaskView;
|
|
245
|
+
} else {
|
|
246
|
+
return this.jsvMainView;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
jsvRemoveChild(node) {
|
|
251
|
+
node.parentElement = null;
|
|
252
|
+
|
|
253
|
+
node.jsvAttrChangedLazySync = null;
|
|
254
|
+
node.style?.jsvSetChangedListener(null);
|
|
255
|
+
node.style?.jsvDestory();
|
|
256
|
+
|
|
257
|
+
node.jsvAnimation?.Cancel();
|
|
258
|
+
node.jsvAnimation = null;
|
|
259
|
+
if(node instanceof Element) {
|
|
260
|
+
this.jsvMainView.RemoveView(node.jsvMaskView);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
jsvOnLoadForgeView() {
|
|
265
|
+
if (!!this.style.clipPath
|
|
266
|
+
|| !!this.style.overflow
|
|
267
|
+
|| !!this.style.objectFit) {
|
|
268
|
+
if(!!this.jsvMaskView) {
|
|
269
|
+
throw Error("Jsview: jsvMaskView is conflicting.");
|
|
270
|
+
}
|
|
271
|
+
this.jsvMaskView = new Forge.ClipView();
|
|
272
|
+
} else if (!this.jsvMaskView) {
|
|
273
|
+
this.jsvMaskView = this.jsvMainView;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if(this.jsvMaskView !== this.jsvMainView) {
|
|
277
|
+
this.jsvMaskView.AddView(this.jsvMainView);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// 注册Element离开tree不再显示时(时机同LayoutView从RootView Tree拿掉)的回调
|
|
281
|
+
let unload_view_callback = this.jsvCallbackOnUnloadForgeView();
|
|
282
|
+
if (unload_view_callback) {
|
|
283
|
+
this.jsvMainView.RegisterDetachCallback(unload_view_callback);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
this._jsvSetAttrLazySyncCallback();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
_jsvSetAttrLazySyncCallback() {
|
|
290
|
+
if (this.jsvAttrChangedLazySync) {
|
|
291
|
+
let _this = this;
|
|
292
|
+
this.jsvAttrChangedLazySync.setOnSyncCallback((caches) => {
|
|
293
|
+
let jsv_attr = null;
|
|
294
|
+
let css_attr = null;
|
|
295
|
+
for (let key in caches) {
|
|
296
|
+
if (_this.hasOwnProperty(key)) {
|
|
297
|
+
switch(caches[key]) {
|
|
298
|
+
case Element.ATTRTYPE.JSV: {
|
|
299
|
+
if (jsv_attr == null) {
|
|
300
|
+
jsv_attr = {};
|
|
301
|
+
}
|
|
302
|
+
jsv_attr[key] = _this[key];
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
case Element.ATTRTYPE.CSS: {
|
|
306
|
+
if (css_attr == null) {
|
|
307
|
+
css_attr = {};
|
|
308
|
+
}
|
|
309
|
+
css_attr[key] = _this[key];
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (jsv_attr) {
|
|
317
|
+
// 有jsv同步内容
|
|
318
|
+
jsv_attr = _this.jsvSetElementPropOnMask(jsv_attr); // 先作用于本element的根view
|
|
319
|
+
// 剩余内容再作用到基础view上
|
|
320
|
+
_this.jsvSetElementProp(jsv_attr);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (css_attr) {
|
|
324
|
+
// 有css同步内容
|
|
325
|
+
_this.jsvOnAttrLazySync(css_attr);
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
jsvOnAttrLazySync(caches) {
|
|
332
|
+
// nothing for element
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
jsvSetElementProp(caches) {
|
|
336
|
+
if (this.jsvMainView) {
|
|
337
|
+
this.jsvMainView.SetElementProp(caches, ForgeExtension.RootActivity);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
jsvSetElementPropOnMask(caches) {
|
|
342
|
+
// jsv_poster_on_top 必须设置给本element的主view上
|
|
343
|
+
if (caches.hasOwnProperty('jsv_poster_on_top')) {
|
|
344
|
+
let { jsv_poster_on_top, ...others } = caches;
|
|
345
|
+
this.jsvMaskView.SetElementProp({ jsv_poster_on_top }, ForgeExtension.RootActivity);
|
|
346
|
+
return others;
|
|
347
|
+
}
|
|
348
|
+
return caches;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// 若Element关系自身从系统中拿掉的时机,则Override并返回callback函数
|
|
352
|
+
jsvCallbackOnUnloadForgeView() {
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
jsvOnStyleChanged(styleTypes) {
|
|
357
|
+
// Log.D("Element.jsvOnStyleChanged() styleTypes=", styleTypes);
|
|
358
|
+
let flushedInLayoutSize = !!styleTypes[StyleDeclaration.TYPE.LAYOUT_SIZE];
|
|
359
|
+
let flushTransitioned = false;
|
|
360
|
+
if (styleTypes[StyleDeclaration.TYPE.LAYOUT_POS]) {
|
|
361
|
+
if(!flushedInLayoutSize) {
|
|
362
|
+
this.jsvFlushViewLayout();
|
|
363
|
+
// Layout刷新中带有Transform和transition的刷新
|
|
364
|
+
flushTransitioned = true;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (styleTypes[StyleDeclaration.TYPE.LAYOUT_SIZE]) {
|
|
368
|
+
this.jsvFlushViewLayout();
|
|
369
|
+
// Layout刷新中带有Transform和transition的刷新
|
|
370
|
+
flushTransitioned = true;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (styleTypes[StyleDeclaration.TYPE.TRANSFORM] && !flushTransitioned) {
|
|
374
|
+
// 单独刷新CSS Transform
|
|
375
|
+
this.jsvMaskView.ResetCssTransform(this.style.transform, this.style.transformOrigin);
|
|
376
|
+
// Transform变化触发Transition刷新
|
|
377
|
+
this.jsvFlushViewTransition();
|
|
378
|
+
flushTransitioned = true;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (styleTypes[StyleDeclaration.TYPE.BACKGROUND]) {
|
|
382
|
+
this.jsvFlushViewBackground();
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if (styleTypes[StyleDeclaration.TYPE.ANIMATION]) {
|
|
386
|
+
this.jsvFlushViewAnimation();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (styleTypes[StyleDeclaration.TYPE.TRANSITION] && !flushTransitioned) {
|
|
390
|
+
// 更新transition设置,触发transition动作
|
|
391
|
+
this.jsvFlushViewTransition();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
//更新事件
|
|
395
|
+
this.jsvFlushEventHandlers();
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
jsvFlushEventHandlers() {
|
|
399
|
+
if (this.eventHandlers === null) {
|
|
400
|
+
this.eventHandlers = EventHandler.getHandlers(this);
|
|
401
|
+
if (this.eventHandlers && this.eventHandlers.onClick) {
|
|
402
|
+
if (this.jsvMainView) {
|
|
403
|
+
this.jsvMainView.EnableDivTouch(this, null);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
jsvApplyObjectFit(origin_layout) {
|
|
410
|
+
return null; // 支持ObjectFit属性的元素会重载此方法(例如img/video)
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
jsvFlushViewLayout() {
|
|
414
|
+
if (!!this.style.clipPath
|
|
415
|
+
|| !!this.style.overflow
|
|
416
|
+
|| !!this.style.objectFit) {
|
|
417
|
+
if(!this.jsvMaskView) {
|
|
418
|
+
console.error("Element.jsvFlushViewLayout() InvalidOpt: clippath=", this.style.clipPath);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const origin_layout = {
|
|
424
|
+
x: isNaN(this.style.left) ? 0 : this.style.left, // x, y不设置时为undefined
|
|
425
|
+
y: isNaN(this.style.top) ? 0 : this.style.top,
|
|
426
|
+
width: isNaN(this.style.width) ? 0 : this.style.width,
|
|
427
|
+
height: isNaN(this.style.height) ? 0 : this.style.height,
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
let clip_for_object_fit = null;
|
|
431
|
+
if (!!this.style.objectFit) {
|
|
432
|
+
clip_for_object_fit = this.jsvApplyObjectFit(origin_layout);
|
|
433
|
+
if (this.style.objectFit === StyleDeclaration.ObjectFit.FILL) {
|
|
434
|
+
// Fill的场景,不需要进行clip
|
|
435
|
+
clip_for_object_fit = null;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// 更新CSS Transform变化
|
|
440
|
+
this.jsvMaskView.ResetCssTransform(this.style.transform, this.style.transformOrigin);
|
|
441
|
+
|
|
442
|
+
// 更新perspective(启动3D 透视功能)
|
|
443
|
+
if (this.style.perspective && this.style.perspective > 0) {
|
|
444
|
+
let origin = this.style.perspectiveOrigin ? this.style.perspectiveOrigin : null;
|
|
445
|
+
this.jsvMainView.SetPerspective(this.style.perspective, origin);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// 设置3D的背面不可见功能
|
|
449
|
+
if (this.style.backfaceVisibility) {
|
|
450
|
+
this.jsvMainView.SetBackfaceVisibility(this.style.backfaceVisibility == "visible" ? true : false)
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// 设置3D的tranformStyle设定
|
|
454
|
+
if (this.style.transformStyle) {
|
|
455
|
+
this.jsvMainView.SetTransformStyle(this.style.transformStyle);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// 将根据内容调整好的client height和client width设置给mask和main
|
|
459
|
+
this.jsvMaskView.ResetLayoutParams({
|
|
460
|
+
x: origin_layout.x, y: origin_layout.y,
|
|
461
|
+
width: this.clientWidth,
|
|
462
|
+
height: this.clientHeight
|
|
463
|
+
});
|
|
464
|
+
if (this.jsvMaskView !== this.jsvMainView) {
|
|
465
|
+
const subLayout = {x: 0, y: 0,
|
|
466
|
+
width: this.jsvMaskView.LayoutParams.Width,
|
|
467
|
+
height: this.jsvMaskView.LayoutParams.Height};
|
|
468
|
+
this.jsvMainView.ResetLayoutParams(subLayout);
|
|
469
|
+
}
|
|
470
|
+
// this.jsvMaskView.SetVisibility(this.style.visibility);
|
|
471
|
+
// 兼容display, TODO:Flex feature需要重新设计
|
|
472
|
+
let visible_set = this.style.visibility;
|
|
473
|
+
if (this.style.display == "NONE") {
|
|
474
|
+
visible_set = "HIDDEN";
|
|
475
|
+
}
|
|
476
|
+
this.jsvMaskView.SetVisibility(visible_set);
|
|
477
|
+
|
|
478
|
+
let clipRect = null;
|
|
479
|
+
if (clip_for_object_fit !== null && window.JsView /* PC/WebView场景,通过元素自身的ObjectFit来实现效果 */) {
|
|
480
|
+
// 优先使用object fit的配置,去除OpenGL描画缩小的texture时边缘乱码问题
|
|
481
|
+
// TODO: 当这个view有子view的场景,可能会有BUG
|
|
482
|
+
clipRect = {
|
|
483
|
+
x: clip_for_object_fit.x,
|
|
484
|
+
y: clip_for_object_fit.y,
|
|
485
|
+
width: clip_for_object_fit.width,
|
|
486
|
+
height: clip_for_object_fit.height};
|
|
487
|
+
} else if (!!this.style.clipPath) {
|
|
488
|
+
clipRect = {
|
|
489
|
+
x: this.style.clipPath.left,
|
|
490
|
+
y: this.style.clipPath.top,
|
|
491
|
+
width: this.jsvMaskView.LayoutParams.Width - this.style.clipPath.left - this.style.clipPath.right,
|
|
492
|
+
height: this.jsvMaskView.LayoutParams.Height - this.style.clipPath.top - this.style.clipPath.bottom,
|
|
493
|
+
};
|
|
494
|
+
} else if (this.style.overflow === StyleDeclaration.Overflow.HIDDEN
|
|
495
|
+
&& this.jsvStore.textContent === null/* 有文字时,自带显示区域限制,不需要再次进行Clip区域控制 */) {
|
|
496
|
+
clipRect = { x:0, y:0, width:this.style.width, height:this.style.height };
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if(!!clipRect) {
|
|
500
|
+
this.jsvMaskView.SetClipRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height, true);
|
|
501
|
+
} else if (this.jsvMaskView instanceof Forge.ClipView) {
|
|
502
|
+
// 恢复MaskView(ClipView)的裁剪区域
|
|
503
|
+
this.jsvMaskView.SetClipRect(0, 0, 0, 0, false)
|
|
504
|
+
}
|
|
505
|
+
if (typeof this.style.zIndex !== 'undefined' && this.style.zIndex !== null) {
|
|
506
|
+
// ZIndex设置
|
|
507
|
+
|
|
508
|
+
// 测试打印,当调查zIndex不生效时打开打印,
|
|
509
|
+
// 在JsView状态下,有共通的父节点的情况下,zIndex才会有作用
|
|
510
|
+
// let pid_link = "";
|
|
511
|
+
// let walker = this;
|
|
512
|
+
// while(walker.parentElement) {
|
|
513
|
+
// pid_link += "=" + walker.parentElement._Count;
|
|
514
|
+
// walker = walker.parentElement;
|
|
515
|
+
// }
|
|
516
|
+
// console.log("Change ZIndex to " + this.style.zIndex + " of parent chain[" + pid_link + "]");
|
|
517
|
+
|
|
518
|
+
this.jsvMaskView.SetZIndex(this.style.zIndex);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
this.jsvFlushViewTransition();
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
jsvFlushViewBackground() {
|
|
525
|
+
if(!!this.style.backgroundImage) {
|
|
526
|
+
// console.log("Element.jsvFlushViewBackground() image=" + this.style.backgroundImage);
|
|
527
|
+
this.jsvStore.textureWidth = NaN;
|
|
528
|
+
this.jsvStore.textureHeight = NaN;
|
|
529
|
+
ForgeExtension.SetBackgroundImage(this.jsvMainView,
|
|
530
|
+
this.style.backgroundImage,
|
|
531
|
+
this.style.borderRadius);
|
|
532
|
+
} else if(!!this.style.backgroundColor) {
|
|
533
|
+
// console.log("Element.jsvFlushViewBackground() color=" + this.style.backgroundColor);
|
|
534
|
+
this.jsvStore.textureWidth = NaN;
|
|
535
|
+
this.jsvStore.textureHeight = NaN;
|
|
536
|
+
ForgeExtension.SetBackgroundColor(this.jsvMainView,
|
|
537
|
+
this.style.backgroundColor,
|
|
538
|
+
this.style.borderRadius);
|
|
539
|
+
} else {
|
|
540
|
+
// 无效href, 不显示view
|
|
541
|
+
this.jsvMainView.ResetTexture(null);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
jsvFlushViewAnimation() {
|
|
546
|
+
if(!!this.jsvAnimation) {
|
|
547
|
+
this.jsvAnimation.Cancel();
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
if(!this.style.animation) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
// console.warn("Element.jsvFlushViewAnimation() anim=", this.style.animation);
|
|
554
|
+
let keyframes = document.jsvGetKeyFrames(this.style.animation.name, this.jsvStore.scopedAttributes);
|
|
555
|
+
// console.warn("Element.jsvFlushViewAnimation() keyFrames=" + keyframes);
|
|
556
|
+
|
|
557
|
+
this.jsvAnimation = new Forge.CssKeyframeAnimation(keyframes,
|
|
558
|
+
this.style.animation.duration,
|
|
559
|
+
this.style.animation.timingFunction,
|
|
560
|
+
!!this.style.width ? this.style.width : this.clientWidth,
|
|
561
|
+
this.style.height);
|
|
562
|
+
this.jsvAnimation.EnableDelay(this.style.animation.delay)
|
|
563
|
+
.SetRepeat(this.style.animation.iterationCount);
|
|
564
|
+
if (this.style.animationFillMode === 'forwards') {
|
|
565
|
+
this.jsvAnimation.Enable(Forge.AnimationEnable.KeepTransform);
|
|
566
|
+
}
|
|
567
|
+
var _this = this;
|
|
568
|
+
let animListener = new Forge.AnimationListener();
|
|
569
|
+
animListener.OnEnd((is_end)=>{
|
|
570
|
+
_this.jsvAnimation = null; // 清理动画引用
|
|
571
|
+
if (is_end) {
|
|
572
|
+
if (_this.eventHandlers && _this.eventHandlers.onAnimationEnd) {
|
|
573
|
+
let event;
|
|
574
|
+
event = new AnimationEvent("animationend");
|
|
575
|
+
event.target = _this;
|
|
576
|
+
_this.eventHandlers.onAnimationEnd(event);
|
|
577
|
+
}
|
|
578
|
+
// Instant swap
|
|
579
|
+
if (_this.instantSwapCallback == null) {
|
|
580
|
+
_this.instantSwapCallback = Forge.sRenderBridge.InstantPerformSwap.bind(Forge.sRenderBridge);
|
|
581
|
+
}
|
|
582
|
+
Promise.resolve().then(_this.instantSwapCallback);
|
|
583
|
+
} else {
|
|
584
|
+
// be animation cancel
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
this.jsvAnimation.Enable(Forge.AnimationEnable.ReleaseAfterEndCallback);
|
|
588
|
+
this.jsvAnimation.SetAnimationListener(animListener);
|
|
589
|
+
this.jsvMaskView.StartAnimation(this.jsvAnimation);
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
jsvFlushViewTransition() {
|
|
593
|
+
if (this.style.animation) {
|
|
594
|
+
// 当animation存在时,不处理transition,两个动作认为是冲突的
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
if (this.jsvStore.transitionTmp != null
|
|
599
|
+
&& this.jsvStore.transitionTmp.syncTimes != gSyncTimesCounter.cnt
|
|
600
|
+
&& this.jsvStore.transitionTmp.syncTimes != -1) {
|
|
601
|
+
// Sync Count发生变化,说明style已经生效
|
|
602
|
+
// 将 transitionTmp 交换到 transition中
|
|
603
|
+
// 执行交换,而不是不新建对象,以提高执行效率
|
|
604
|
+
// PS: 首次的交换结果是 transitionTmp 重新变回null
|
|
605
|
+
let swap = this.jsvStore.transition;
|
|
606
|
+
this.jsvStore.transition = this.jsvStore.transitionTmp;
|
|
607
|
+
this.jsvStore.transitionTmp = swap;
|
|
608
|
+
|
|
609
|
+
// 无效化syncTimes,避免状态不变时,执行错误的交换
|
|
610
|
+
if (this.jsvStore.transitionTmp != null) {
|
|
611
|
+
this.jsvStore.transitionTmp.syncTimes = -1;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (this.style.transition) {
|
|
616
|
+
if (this.jsvStore.transition) {
|
|
617
|
+
let has_animation = this._JsvBuildTransition();
|
|
618
|
+
if (!has_animation) {
|
|
619
|
+
// Style没有变更,直接返回(不需要保存值)
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
} else {
|
|
623
|
+
// 本标签的带着transition设定的首次Layout,不做transition,但需要保存style数值
|
|
624
|
+
}
|
|
625
|
+
} else {
|
|
626
|
+
// 没有transition的场景,取消掉已经启动的动画
|
|
627
|
+
if(!!this.jsvAnimation) {
|
|
628
|
+
this.jsvAnimation.Cancel();
|
|
629
|
+
this.jsvAnimation = null;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// 保存本次的值
|
|
634
|
+
let transition_ref = this.jsvStore.transitionTmp;
|
|
635
|
+
if (!transition_ref) {
|
|
636
|
+
// 写全所有属性,减少hidden class的开销
|
|
637
|
+
transition_ref = {
|
|
638
|
+
left: 0, top: 0, width: 0, height: 0,
|
|
639
|
+
opacity: 1, transform: null,
|
|
640
|
+
syncTimes: -1,
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
transition_ref.left = this.style.left;
|
|
644
|
+
transition_ref.top = this.style.top;
|
|
645
|
+
transition_ref.width = this.style.width;
|
|
646
|
+
transition_ref.height = this.style.height;
|
|
647
|
+
transition_ref.opacity = this.style.opacity;
|
|
648
|
+
transition_ref.transform = this.style.transform;
|
|
649
|
+
transition_ref.syncTimes = gSyncTimesCounter.cnt;
|
|
650
|
+
this.jsvStore.transitionTmp = transition_ref;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
_JsvBuildTransition() {
|
|
654
|
+
let transition = [];
|
|
655
|
+
for (let name in this.style.transition) {
|
|
656
|
+
let transFrom = this.jsvStore.transition[name];
|
|
657
|
+
let transTo = this.style[name];
|
|
658
|
+
if (transFrom === transTo) { // 上一次没有值或值没有变化,不需要动画
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
// console.log("Element.jsvFlushViewTransition() name=" + name + " from=" + transFrom + " to=" + transTo);
|
|
662
|
+
let singleTransition = this.style.transition[name];
|
|
663
|
+
let item = {
|
|
664
|
+
name: name,
|
|
665
|
+
dur: Math.round(singleTransition.duration),
|
|
666
|
+
tf: null,
|
|
667
|
+
dly: Math.round(singleTransition.delay),
|
|
668
|
+
from: transFrom ? transFrom : "", // 容错处理,避免传undefined出现字段丢失
|
|
669
|
+
to: transTo,
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
if (name === "transform") {
|
|
673
|
+
item["origin"] = this.style["transformOrigin"]?this.style["transformOrigin"]:"center center";
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
if(!!singleTransition.timingFunction) {
|
|
677
|
+
item.tf = singleTransition.timingFunction.Package();
|
|
678
|
+
}
|
|
679
|
+
transition.push(item);
|
|
680
|
+
|
|
681
|
+
}
|
|
682
|
+
if(transition.length <= 0) {
|
|
683
|
+
// 没有任何值改变的场合
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
var _this = this;
|
|
688
|
+
let animListener = new Forge.AnimationListener();
|
|
689
|
+
animListener.OnEnd((is_end)=>{
|
|
690
|
+
_this.jsvAnimation = null;
|
|
691
|
+
if (is_end) {
|
|
692
|
+
if (_this.eventHandlers && _this.eventHandlers.onTransitionEnd) {
|
|
693
|
+
let event = new AnimationEvent("transitionend");
|
|
694
|
+
event.target = _this;
|
|
695
|
+
_this.eventHandlers.onTransitionEnd(event);
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// Instant swap
|
|
699
|
+
if (_this.instantSwapCallback == null) {
|
|
700
|
+
_this.instantSwapCallback = Forge.sRenderBridge.InstantPerformSwap.bind(Forge.sRenderBridge);
|
|
701
|
+
}
|
|
702
|
+
Promise.resolve().then(_this.instantSwapCallback);
|
|
703
|
+
} else {
|
|
704
|
+
// be animation cancel
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
this.jsvAnimation = new Forge.CssTransitionAnimation(transition);
|
|
708
|
+
this.jsvAnimation.SetAnimationListener(animListener);
|
|
709
|
+
this.jsvMaskView.StartAnimation(this.jsvAnimation);
|
|
710
|
+
|
|
711
|
+
return true;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
jsvBackwardFindForgeView(node) {
|
|
715
|
+
let sibling = node;
|
|
716
|
+
while(sibling && !(sibling instanceof Element)) {
|
|
717
|
+
sibling = sibling.nextSibling;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
return sibling;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
static applyObjectFitCommon(element_obj, origin_layout, target_fit_view) {
|
|
724
|
+
if (target_fit_view // target fit view有可能当前节点还没生成(例如MediaView)
|
|
725
|
+
&& !isNaN(element_obj.jsvStore.textureWidth)
|
|
726
|
+
&& !isNaN(element_obj.jsvStore.textureHeight)) {
|
|
727
|
+
|
|
728
|
+
const object_fit = element_obj.style.objectFit;
|
|
729
|
+
const clip_layout = target_fit_view.ApplyObjectFit(
|
|
730
|
+
origin_layout.width, origin_layout.height,
|
|
731
|
+
element_obj.jsvStore.textureWidth, element_obj.jsvStore.textureHeight,
|
|
732
|
+
object_fit, StyleDeclaration.ObjectFit);
|
|
733
|
+
|
|
734
|
+
// 更新clientWidth/clientHeight
|
|
735
|
+
if (origin_layout.width === 0 || origin_layout.height === 0) {
|
|
736
|
+
if (!(origin_layout.width === 0 && origin_layout.height === 0)) {
|
|
737
|
+
// 内容将view撑大的场合
|
|
738
|
+
element_obj.jsvStore.clientWidth = Math.max(origin_layout.width, clip_layout.width);
|
|
739
|
+
element_obj.jsvStore.clientHeight = Math.max(origin_layout.height, clip_layout.height);
|
|
740
|
+
} else {
|
|
741
|
+
// view尺寸设定为0x0,不需要调整尺寸进行渲染
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
return clip_layout;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return null;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
_jsvAppendScopedAttribute(scopedAttribute, depth) {
|
|
752
|
+
// console.info("Element._jsvAppendScopedAttribute() scopedAttribute=" + scopedAttribute + " depth=" + depth);
|
|
753
|
+
if (depth == 0
|
|
754
|
+
|| this.jsvInheritClassDepth == depth) { // 设置自身的Scoped属性
|
|
755
|
+
this.jsvStore.scopedAttributes.push(scopedAttribute);
|
|
756
|
+
this.jsvStore.clientWidth = NaN;
|
|
757
|
+
this.jsvStore.clientHeight = NaN;
|
|
758
|
+
this.style.jsvAppendClassAttribute(scopedAttribute);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if(this.jsvHasInheritClassChildren) { // 递归设置子节点的Scoped属性
|
|
762
|
+
depth = (this.jsvInheritClassDepth == depth ? 1 : depth + 1);
|
|
763
|
+
for(const child of this.childNodes) {
|
|
764
|
+
if (child.jsvInheritClassDepth <= 0
|
|
765
|
+
&& child.jsvHasInheritClassChildren == false) {
|
|
766
|
+
continue;
|
|
767
|
+
}
|
|
768
|
+
if (!(child instanceof Element)) {
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
if (child.jsvStore.scopedAttributes.includes(scopedAttribute)) {
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
child._jsvAppendScopedAttribute(scopedAttribute, depth) ;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
_jsvSetClassNames(classNames, depth) {
|
|
781
|
+
// console.info("Element._jsvSetClassNames() classNames=" + classNames + " depth=" + depth);
|
|
782
|
+
if (depth == 0
|
|
783
|
+
|| this.jsvInheritClassDepth == depth) { // 设置自身的ClassName
|
|
784
|
+
this.style.jsvApplyClasses(classNames, this.jsvInheritClassDepth == depth);
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
if(this.jsvHasInheritClassChildren) { // 递归设置子节点的ClassName
|
|
788
|
+
depth = (this.jsvInheritClassDepth == depth ? 1 : depth + 1);
|
|
789
|
+
for(const child of this.childNodes) {
|
|
790
|
+
if (child.jsvInheritClassDepth <= 0
|
|
791
|
+
&& child.jsvHasInheritClassChildren == false) {
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
if (!(child instanceof Element)) {
|
|
795
|
+
continue;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
child._jsvSetClassNames(classNames, depth) ;
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
_jsvSetInheritClassDepth(depth) {
|
|
804
|
+
if (depth <= 0) {
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
this.jsvInheritClassDepth = depth;
|
|
809
|
+
|
|
810
|
+
let ancestor = this;
|
|
811
|
+
for (let idx = 0; idx < depth; idx++) {
|
|
812
|
+
ancestor = ancestor.parentNode;
|
|
813
|
+
if (!ancestor) {
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
if (ancestor) {
|
|
819
|
+
for (const scopedAttribute of ancestor.jsvStore.scopedAttributes) {
|
|
820
|
+
this._jsvAppendScopedAttribute(scopedAttribute, depth);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
this._jsvSetClassNames(ancestor["class"], depth)
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
Element.TAG = {
|
|
830
|
+
DIV : 'DIV',
|
|
831
|
+
IMAGE : 'IMAGE',
|
|
832
|
+
LINK : 'LINK',
|
|
833
|
+
STYLE : 'STYLE',
|
|
834
|
+
AUDIO : 'AUDIO',
|
|
835
|
+
VIDEO : 'VIDEO',
|
|
836
|
+
ANCHOR : 'A',
|
|
837
|
+
SVG : 'SVG',
|
|
838
|
+
FDIV : 'FDIV',
|
|
839
|
+
AUDIOTRACK: 'AUDIOTRACK',
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
Element.ATTRIBUTE = {
|
|
843
|
+
SRC: 'src',
|
|
844
|
+
JSVPREFIX: 'jsv',
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
Element.ATTRTYPE = {
|
|
848
|
+
JSV: Symbol('jsv'),
|
|
849
|
+
CSS: Symbol('css'),
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
export default Element;
|