You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/03/15 08:05:16 UTC
[1/9] incubator-weex git commit: * [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,
DomModule#getComponentSize. It's low risk since it's a internal method,
users should not dirct use it.
Repository: incubator-weex
Updated Branches:
refs/heads/0.12-dev c6349812e -> a67604ced
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java b/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java
deleted file mode 100755
index 0e621c1..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderStatement.java
+++ /dev/null
@@ -1,556 +0,0 @@
-/**
- *
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright 2016 Alibaba Group
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.taobao.weex.ui;
-
-import android.graphics.Rect;
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.widget.ScrollView;
-
-import com.alibaba.fastjson.JSONObject;
-import com.taobao.weex.WXEnvironment;
-import com.taobao.weex.WXSDKInstance;
-import com.taobao.weex.WXSDKManager;
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.common.WXRenderStrategy;
-import com.taobao.weex.dom.WXDomObject;
-import com.taobao.weex.dom.flex.Spacing;
-import com.taobao.weex.ui.animation.WXAnimationBean;
-import com.taobao.weex.ui.animation.WXAnimationModule;
-import com.taobao.weex.ui.component.Scrollable;
-import com.taobao.weex.ui.component.WXComponent;
-import com.taobao.weex.ui.component.WXComponentFactory;
-import com.taobao.weex.ui.component.WXScroller;
-import com.taobao.weex.ui.component.WXVContainer;
-import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.WXViewUtils;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Class for rendering view. Method in this class should be run in main thread.
- * This class is also <strong>not</storng> thread safe.
- * This class is very similar to {@link com.taobao.weex.dom.WXDomStatement}
- * @see com.taobao.weex.dom.WXDomStatement
- */
-class WXRenderStatement {
-
- private Map<String, WXComponent> mRegistry;
- private WXSDKInstance mWXSDKInstance;
- /**
- * The container for weex root view.
- */
-
- public WXRenderStatement(WXSDKInstance instance) {
- mWXSDKInstance = instance;
- mRegistry = new HashMap<>();
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#destroy()
- */
- public void destroy() {
- mWXSDKInstance = null;
- mRegistry.clear();
- }
-
- public WXSDKInstance getWXSDKInstance() {
- return mWXSDKInstance;
- }
-
- /**
- * create RootView \uff0cevery weex Instance View has a rootView;
- * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
- */
- void createBody(WXComponent component) {
- long start = System.currentTimeMillis();
- component.createView();
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
- }
- start = System.currentTimeMillis();
- component.applyLayoutAndEvent(component);
- component.bindData(component);
-
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
- }
-
- if (component instanceof WXScroller) {
- WXScroller scroller = (WXScroller) component;
- if (scroller.getInnerView() instanceof ScrollView) {
- mWXSDKInstance.setRootScrollView((ScrollView) scroller.getInnerView());
- }
- }
- mWXSDKInstance.onRootCreated(component);
- if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
- mWXSDKInstance.onCreateFinish();
- }
- }
-
- WXComponent createBodyOnDomThread(WXDomObject dom) {
- if (mWXSDKInstance == null) {
- return null;
- }
-
- WXComponent rootComp = generateComponentTree(dom, null);
- return rootComp;
- }
-
- /**
- * set padding style of View
- */
- void setPadding(String ref, Spacing padding, Spacing border) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return;
- }
- component.setPadding(padding, border);
- }
-
- /**
- * set layout information of View
- */
- void setLayout(String ref, WXDomObject domObject) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return;
- }
- component.setLayout(domObject);
- }
-
- /**
- * set extra information of View
- */
- void setExtra(String ref, Object extra) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return;
- }
- component.updateExtra(extra);
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int)
- */
- void addComponent(WXDomObject dom, String parentRef, int index) {
- WXVContainer parent = (WXVContainer) mRegistry.get(parentRef);
- WXComponent component = generateComponentTree(dom, parent);
- parent.addChild(component, index);
- }
-
- @Nullable WXComponent createComponentOnDomThread(WXDomObject dom, String parentRef, int index) {
- WXComponent comp = mRegistry.get(parentRef);
- if(comp == null || !(comp instanceof WXVContainer)){
- return null;
- }
- return generateComponentTree(dom, (WXVContainer) comp);
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#addDom(JSONObject, String, int)
- */
- void addComponent(WXComponent component, String parentRef, int index) {
- WXVContainer parent = (WXVContainer) mRegistry.get(parentRef);
- if (parent == null || component == null) {
- return;
- }
-
- parent.addChild(component, index);
- parent.createChildViewAt(index);
- component.applyLayoutAndEvent(component);
- component.bindData(component);
- }
-
- /**
- *@see com.taobao.weex.dom.WXDomStatement#removeDom(String)
- */
- WXComponent removeComponent(String ref) {
- WXComponent component = mRegistry.get(ref);
- if (component == null || component.getParent() == null) {
- return component;
- }
- WXVContainer parent = component.getParent();
- clearRegistryForComponent(component);
- parent.remove(component,true);
- mRegistry.remove(ref);
- return component;
- }
-
- public WXComponent getComponent(String ref) {
- return mRegistry.get(ref);
- }
-
- /**
- * Clear registry information that current instance contains.
- */
- private void clearRegistryForComponent(WXComponent component) {
- WXComponent removedComponent = mRegistry.remove(component.getDomObject().getRef());
- if (removedComponent != null) {
- removedComponent.removeAllEvent();
- removedComponent.removeStickyStyle();
- }
- if (component instanceof WXVContainer) {
- WXVContainer container = (WXVContainer) component;
- int count = container.childCount();
- for (int i = count - 1; i >= 0; --i) {
- clearRegistryForComponent(container.getChild(i));
- }
- }
-
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#moveDom(String, String, int)
- */
- void move(String ref, String parentRef, int index) {
- WXComponent component = mRegistry.get(ref);
- WXComponent newParent = mRegistry.get(parentRef);
- if (component == null || component.getParent() == null
- || newParent == null || !(newParent instanceof WXVContainer)) {
- return;
- }
- WXVContainer oldParent = component.getParent();
- oldParent.remove(component,false);
- ((WXVContainer) newParent).addChild(component, index);
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#addEvent(String, String)
- */
- void addEvent(String ref, String type) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return ;
- }
- component.addEvent(type);
- }
-
- /**
- * @see WXDomObject#removeEvent(String)
- */
- void removeEvent(String ref, String type) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return ;
- }
- component.removeEvent(type);
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#updateAttrs(String, JSONObject)
- */
- void updateAttrs(String ref, Map<String, Object> attrs) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return;
- }
-
- component.updateProperties(attrs);
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#updateStyle(String, JSONObject)
- */
- void updateStyle(String ref, Map<String, Object> style) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return;
- }
-
- component.updateProperties(style);
- }
-
- /**
- * @see com.taobao.weex.dom.WXDomStatement#scrollToDom(String, JSONObject)
- */
- void scrollTo(String ref, Map<String, Object> options) {
- WXComponent component = mRegistry.get(ref);
- if (component == null) {
- return;
- }
-
- Scrollable scroller = component.getParentScroller();
- if (scroller == null) {
- return;
- }
- scroller.scrollTo(component,options);
- }
-
- /**
- * weex render finish
- * @see com.taobao.weex.dom.WXDomStatement#createFinish()
- */
- void createFinish(int width, int height) {
- if (mWXSDKInstance.getRenderStrategy() == WXRenderStrategy.APPEND_ONCE) {
- mWXSDKInstance.onCreateFinish();
- }
- mWXSDKInstance.onRenderSuccess(width, height);
- }
-
- /**
- * weex refresh finish
- * @see com.taobao.weex.dom.WXDomStatement#refreshFinish()
- */
- void refreshFinish(int width, int height) {
- mWXSDKInstance.onRefreshSuccess(width, height);
- }
-
- /**
- * weex refresh finish
- * @see WXSDKInstance#onUpdateFinish()
- */
- void updateFinish() {
- mWXSDKInstance.onUpdateFinish();
- }
-
-
- private WXComponent generateComponentTree(WXDomObject dom, WXVContainer parent) {
- if (dom == null ) {
- return null;
- }
- WXComponent component = WXComponentFactory.newInstance(mWXSDKInstance, dom,parent);
-
- mRegistry.put(dom.getRef(), component);
- if (component instanceof WXVContainer) {
- WXVContainer parentC = (WXVContainer) component;
- int count = dom.childCount();
- WXDomObject child = null;
- for (int i = 0; i < count; ++i) {
- child = dom.getChild(i);
- if (child != null) {
- parentC.addChild(generateComponentTree(child, parentC));
- }
- }
- }
-
- return component;
- }
-
- void startAnimation(@NonNull String ref, @NonNull WXAnimationBean animationBean, @Nullable String callBack) {
- WXAnimationModule.startAnimation(mWXSDKInstance, mRegistry.get(ref), animationBean, callBack);
- }
-
- public void getComponentSize(String ref, JSCallback callback) {
- WXComponent component = mRegistry.get(ref);
- Map<String, Object> options = new HashMap<>();
- if (component != null) {
- Map<String, Float> size = new HashMap<>();
- Rect sizes = component.getComponentSize();
- size.put("width", WXViewUtils.getWebPxByWidth(sizes.width(),mWXSDKInstance.getInstanceViewPortWidth()));
- size.put("height", WXViewUtils.getWebPxByWidth(sizes.height(),mWXSDKInstance.getInstanceViewPortWidth()));
- size.put("bottom",WXViewUtils.getWebPxByWidth(sizes.bottom,mWXSDKInstance.getInstanceViewPortWidth()));
- size.put("left",WXViewUtils.getWebPxByWidth(sizes.left,mWXSDKInstance.getInstanceViewPortWidth()));
- size.put("right",WXViewUtils.getWebPxByWidth(sizes.right,mWXSDKInstance.getInstanceViewPortWidth()));
- size.put("top",WXViewUtils.getWebPxByWidth(sizes.top,mWXSDKInstance.getInstanceViewPortWidth()));
- options.put("size", size);
- options.put("result", true);
- } else {
- options.put("errMsg", "Component does not exist");
- }
- callback.invoke(options);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/ui/animation/WXAnimationModule.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/animation/WXAnimationModule.java b/android/sdk/src/main/java/com/taobao/weex/ui/animation/WXAnimationModule.java
index 9da8f4d..a06ae41 100755
--- a/android/sdk/src/main/java/com/taobao/weex/ui/animation/WXAnimationModule.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/animation/WXAnimationModule.java
@@ -355,7 +355,7 @@ public class WXAnimationModule extends WXModule {
@Override
public void onAnimationEnd(Animator animation) {
if (instance == null) {
- WXLogUtils.e("WXRenderStatement-onAnimationEnd WXSDKInstance == null NPE");
+ WXLogUtils.e("RenderActionContextImpl-onAnimationEnd WXSDKInstance == null NPE");
} else {
WXSDKManager.getInstance().callback(instance.getInstanceId(),
callBack,
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index 3319414..8f00f38 100755
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -159,9 +159,11 @@ import com.taobao.weex.common.IWXObject;
import com.taobao.weex.common.WXRuntimeException;
import com.taobao.weex.dom.ImmutableDomObject;
import com.taobao.weex.dom.WXDomHandler;
+import com.taobao.weex.dom.WXDomManager;
import com.taobao.weex.dom.WXDomObject;
import com.taobao.weex.dom.WXDomTask;
import com.taobao.weex.dom.WXStyle;
+import com.taobao.weex.dom.action.Actions;
import com.taobao.weex.dom.flex.Spacing;
import com.taobao.weex.ui.IFComponentHolder;
import com.taobao.weex.ui.animation.WXAnimationModule;
@@ -821,15 +823,7 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
* @param type
*/
protected void appendEventToDOM(String type){
- Message message = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(getRef());
- task.args.add(type);
- message.obj = task;
- message.what = WXDomHandler.MsgType.WX_DOM_ADD_EVENT;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(message);
+ WXSDKManager.getInstance().getWXDomManager().postAction(getInstanceId(), Actions.getAddEvent(getRef(),type),false);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java b/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java
index 7819a8f..3e68d7c 100644
--- a/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java
+++ b/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java
@@ -216,7 +216,7 @@ import static org.junit.Assert.*;
public class WXSDKManagerTest {
public static void setRenderManager(WXRenderManager rm){
- WXSDKManager.getInstance().mWXRenderManager = rm;
+ WXSDKManager.initInstance(rm);
}
public static void setInstance(WXSDKManager m){
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java b/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java
index f5b557e..c0f1724 100644
--- a/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java
+++ b/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java
@@ -210,7 +210,10 @@ import com.taobao.weex.InitConfig;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKInstanceTest;
+import com.taobao.weex.WXSDKManager;
+import com.taobao.weex.WXSDKManagerTest;
import com.taobao.weex.bridge.WXBridgeManagerTest;
+import com.taobao.weex.dom.action.TestActions;
import com.taobao.weex.ui.WXRenderManager;
import org.junit.After;
@@ -231,7 +234,7 @@ import org.robolectric.shadows.ShadowLooper;
@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"})
public class WXDomStatementTest {
- WXDomStatement stmt;
+ DOMActionContextImpl stmt;
WXRenderManager rednerManager;
WXSDKInstance instance;
@@ -244,7 +247,8 @@ public class WXDomStatementTest {
instance = WXSDKInstanceTest.createInstance();
rednerManager = new WXRenderManager();
rednerManager.registerInstance(instance);//
- stmt = new WXDomStatement(instance.getInstanceId(),rednerManager );
+ WXSDKManagerTest.setRenderManager(rednerManager);
+ stmt = new DOMActionContextImpl(instance.getInstanceId(),rednerManager );
}
@After
@@ -256,7 +260,51 @@ public class WXDomStatementTest {
JSONObject body = new JSONObject();
body.put("type","div");
body.put("ref",WXDomObject.ROOT);
- stmt.createBody(body);
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(), TestActions.body(body),true);
+ }
+
+ void addDom(JSONObject obj,String parentRef,int index){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.addDom(obj,parentRef,index),false);
+ }
+
+ void removeDom(String ref){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.remove(ref),false);
+ }
+
+ void updateAttrs(String ref,JSONObject data){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.updateAttr(ref,data),false);
+ }
+
+ void updateStyle(String ref,JSONObject data,boolean byPesudo){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.updateStyle(ref,data,byPesudo),false);
+ }
+
+ void moveDom(String ref,String parent,int index){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.moveDom(ref,parent,index),false);
+ }
+
+ private void scrollToDom(String s, JSONObject o) {
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.scrollTo(s,o),false);
+ }
+
+ private void addEvent(String ref,String event){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.addEvent(ref,event),false);
+ }
+
+ private void removeEvent(String ref,String event){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.removeEvent(ref,event),false);
+ }
+
+ private void updateFinish(){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.updateFinish(),false);
+ }
+
+ private void createFinish(){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.createFinish(),false);
+ }
+
+ private void refreshFinish(){
+ WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.refreshFinish(),false);
}
@Test
@@ -268,7 +316,7 @@ public class WXDomStatementTest {
root.add(new WXSwitchDomObject(),0);
root.add(new TextAreaEditTextDomObject(),0);
stmt.layout(root);
- root.traverseTree(WXDomStatement.ApplyStyleConsumer.getInstance());
+ root.traverseTree(ApplyStyleConsumer.getInstance());
}
@Test
@@ -286,7 +334,7 @@ public class WXDomStatementTest {
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
stmt.batch();
}
@@ -298,14 +346,14 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","101");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
- stmt.moveDom("100",WXDomObject.ROOT,1);
+ moveDom("100",WXDomObject.ROOT,1);
stmt.batch();
}
@@ -316,14 +364,14 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","101");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
- stmt.removeDom("101");
+ removeDom("101");
stmt.batch();
}
@@ -335,11 +383,11 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
- stmt.updateAttrs("100",new JSONObject());
- stmt.updateAttrs("100",null);
+ updateAttrs("100",new JSONObject());
+ updateAttrs("100",null);
stmt.batch();
}
@@ -351,10 +399,10 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
- stmt.updateStyle("100",new JSONObject(),false);
- stmt.updateStyle("100",null,false);
+ updateStyle("100",new JSONObject(),false);
+ updateStyle("100",null,false);
stmt.batch();
}
@@ -366,10 +414,10 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
- stmt.addEvent("100","click");
- stmt.addEvent("100",null);
+ addEvent("100","click");
+ addEvent("100",null);
stmt.batch();
}
@@ -381,11 +429,11 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
- stmt.removeEvent("100",null);
- stmt.addEvent("100","click");
- stmt.removeEvent("100","click");
+ removeEvent("100",null);
+ addEvent("100","click");
+ removeEvent("100","click");
stmt.batch();
}
@@ -397,16 +445,18 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
- stmt.scrollToDom("100",null);
+ scrollToDom("100",null);
stmt.batch();
}
+
+
@Test
public void testCreateFinish() throws Exception {
createBody();
- stmt.createFinish();
+ createFinish();
stmt.batch();
}
@@ -414,7 +464,7 @@ public class WXDomStatementTest {
@Test
public void testRefreshFinish() throws Exception {
createBody();
- stmt.refreshFinish();
+ refreshFinish();
stmt.batch();
}
@@ -423,7 +473,7 @@ public class WXDomStatementTest {
public void testUpdateFinish() throws Exception {
createBody();
- stmt.updateFinish();
+ updateFinish();
stmt.batch();
}
@@ -434,7 +484,7 @@ public class WXDomStatementTest {
obj = new JSONObject();
obj.put("type","div");
obj.put("ref","100");
- stmt.addDom(obj,WXDomObject.ROOT,0);
+ addDom(obj,WXDomObject.ROOT,0);
stmt.startAnimation("100","",null);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/test/java/com/taobao/weex/dom/action/TestActions.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/test/java/com/taobao/weex/dom/action/TestActions.java b/android/sdk/src/test/java/com/taobao/weex/dom/action/TestActions.java
new file mode 100644
index 0000000..8e61b14
--- /dev/null
+++ b/android/sdk/src/test/java/com/taobao/weex/dom/action/TestActions.java
@@ -0,0 +1,59 @@
+package com.taobao.weex.dom.action;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.dom.DOMAction;
+
+/**
+ * Created by sospartan on 01/03/2017.
+ */
+
+public class TestActions {
+ public static DOMAction body(JSONObject data){
+ return new CreateBodyAction(data);
+ }
+
+
+ public static DOMAction addDom(JSONObject obj, String parentRef, int index) {
+ return new AddElementAction(obj,parentRef,index);
+ }
+
+ public static DOMAction remove(String ref) {
+ return new RemoveElementAction(ref);
+ }
+
+ public static DOMAction updateAttr(String ref, JSONObject data) {
+ return new UpdateAttributeAction(ref,data);
+ }
+
+ public static DOMAction updateStyle(String ref, JSONObject data, boolean byPesudo) {
+ return new UpdateStyleAction(ref,data,byPesudo);
+ }
+
+ public static DOMAction moveDom(String ref, String parent, int index) {
+ return new MoveElementAction(ref,parent,index);
+ }
+
+ public static DOMAction scrollTo(String ref,JSONObject data){
+ return new ScrollToElementAction(ref,data);
+ }
+
+ public static DOMAction addEvent(String ref,String event){
+ return new AddEventAction(ref,event);
+ }
+
+ public static DOMAction removeEvent(String ref,String event){
+ return new RemoveEventAction(ref,event);
+ }
+
+ public static DOMAction createFinish(){
+ return new CreateFinishAction();
+ }
+
+ public static DOMAction updateFinish(){
+ return new UpdateFinishAction();
+ }
+
+ public static DOMAction refreshFinish(){
+ return new RefreshFinishAction();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java
index 1f9ac18..1b5fd66 100755
--- a/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java
+++ b/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java
@@ -228,7 +228,7 @@ import org.robolectric.annotation.Config;
@PrepareForTest({WXSoInstallMgrSdk.class, TextUtils.class,WXComponentFactory.class})
public class WXRenderStatementTest {
- WXRenderStatement mWXRenderStatement;
+ RenderActionContextImpl mWXRenderStatement;
@Before
public void setUp() throws Exception {
@@ -238,7 +238,7 @@ public class WXRenderStatementTest {
PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true);
PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true);
WXSDKInstance instance = Mockito.mock(WXSDKInstance.class);
- mWXRenderStatement = new WXRenderStatement(instance);
+ mWXRenderStatement = new RenderActionContextImpl(instance);
}
public void testCreateBody() throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/test/pages/dom-operation.we
----------------------------------------------------------------------
diff --git a/test/pages/dom-operation.we b/test/pages/dom-operation.we
index 5a7a18c..b339132 100644
--- a/test/pages/dom-operation.we
+++ b/test/pages/dom-operation.we
@@ -10,13 +10,15 @@
</div>
<text onclick="onclick">display</text>
<text onclick="onclick2">display</text>
+ <text onclick="onclick3">{{text}}</text>
</div>
</template>
<script>
module.exports = {
data:{
display:false,
- repeat_items:[1,2,3,4,5]
+ repeat_items:[1,2,3,4,5],
+ text:"display"
},
methods:{
onclick:function(){
@@ -26,6 +28,7 @@
onclick2:function(){
this.display = false;
this.repeat_items.pop();
+ this.text = "finished"
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/test/scripts/dom.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/dom.test.js b/test/scripts/dom.test.js
index d49f112..150445a 100644
--- a/test/scripts/dom.test.js
+++ b/test/scripts/dom.test.js
@@ -63,5 +63,14 @@ describe('weex mobile index', function () {
})
})
+ it('#3 Update DOM attr', ()=>{
+ return driver
+ .elementByXPath("//div/text[3]")
+ .text()
+ .then((text)=>{
+ assert.equal("finished",text);
+ })
+ })
+
});
[8/9] incubator-weex git commit: * [android] rename
Posted by so...@apache.org.
* [android] rename
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/20f6c37b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/20f6c37b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/20f6c37b
Branch: refs/heads/0.12-dev
Commit: 20f6c37ba0174418e3be04d846a604b42c4757d1
Parents: f3390e3
Author: sospartan <so...@apache.org>
Authored: Wed Mar 15 15:56:12 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Wed Mar 15 15:56:12 2017 +0800
----------------------------------------------------------------------
.../taobao/weex/dom/DOMActionContextImpl.java | 2 +-
.../com/taobao/weex/dom/RenderActionTask.java | 227 +++++++++++++++++++
.../java/com/taobao/weex/dom/RenderTask.java | 227 -------------------
3 files changed, 228 insertions(+), 228 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/20f6c37b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
index ee86493..6248f19 100755
--- a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
@@ -555,7 +555,7 @@ class DOMActionContextImpl implements DOMActionContext {
@Override
public void postRenderTask(RenderAction statement) {
- mNormalTasks.add(new RenderTask(statement, mWXRenderManager.getWXRenderStatement(mInstanceId)));
+ mNormalTasks.add(new RenderActionTask(statement, mWXRenderManager.getWXRenderStatement(mInstanceId)));
mDirty = true;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/20f6c37b/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionTask.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionTask.java b/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionTask.java
new file mode 100644
index 0000000..9adcca1
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionTask.java
@@ -0,0 +1,227 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+import com.taobao.weex.ui.IWXRenderTask;
+
+/**
+ * Created by sospartan on 23/02/2017.
+ */
+
+class RenderActionTask implements IWXRenderTask {
+ private final RenderAction mRenderTask;
+ private final RenderActionContext mContext;
+
+ public RenderActionTask(RenderAction action, RenderActionContext context){
+ mRenderTask = action;
+ mContext = context;
+ }
+
+
+ @Override
+ public void execute() {
+ mRenderTask.executeRender(mContext);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/20f6c37b/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java b/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java
deleted file mode 100644
index a841ede..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/**
- *
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright 2016 Alibaba Group
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.taobao.weex.dom;
-
-import com.taobao.weex.ui.IWXRenderTask;
-
-/**
- * Created by sospartan on 23/02/2017.
- */
-
-class RenderTask implements IWXRenderTask {
- private final RenderAction mRenderTask;
- private final RenderActionContext mContext;
-
- public RenderTask(RenderAction action, RenderActionContext context){
- mRenderTask = action;
- mContext = context;
- }
-
-
- @Override
- public void execute() {
- mRenderTask.executeRender(mContext);
- }
-}
[5/9] incubator-weex git commit: * [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,
DomModule#getComponentSize. It's low risk since it's a internal method,
users should not dirct use it.
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java
deleted file mode 100755
index 36f2713..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomStatement.java
+++ /dev/null
@@ -1,1272 +0,0 @@
-/**
- *
- * Apache License
- * Version 2.0, January 2004
- * http://www.apache.org/licenses/
- *
- * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- *
- * 1. Definitions.
- *
- * "License" shall mean the terms and conditions for use, reproduction,
- * and distribution as defined by Sections 1 through 9 of this document.
- *
- * "Licensor" shall mean the copyright owner or entity authorized by
- * the copyright owner that is granting the License.
- *
- * "Legal Entity" shall mean the union of the acting entity and all
- * other entities that control, are controlled by, or are under common
- * control with that entity. For the purposes of this definition,
- * "control" means (i) the power, direct or indirect, to cause the
- * direction or management of such entity, whether by contract or
- * otherwise, or (ii) ownership of fifty percent (50%) or more of the
- * outstanding shares, or (iii) beneficial ownership of such entity.
- *
- * "You" (or "Your") shall mean an individual or Legal Entity
- * exercising permissions granted by this License.
- *
- * "Source" form shall mean the preferred form for making modifications,
- * including but not limited to software source code, documentation
- * source, and configuration files.
- *
- * "Object" form shall mean any form resulting from mechanical
- * transformation or translation of a Source form, including but
- * not limited to compiled object code, generated documentation,
- * and conversions to other media types.
- *
- * "Work" shall mean the work of authorship, whether in Source or
- * Object form, made available under the License, as indicated by a
- * copyright notice that is included in or attached to the work
- * (an example is provided in the Appendix below).
- *
- * "Derivative Works" shall mean any work, whether in Source or Object
- * form, that is based on (or derived from) the Work and for which the
- * editorial revisions, annotations, elaborations, or other modifications
- * represent, as a whole, an original work of authorship. For the purposes
- * of this License, Derivative Works shall not include works that remain
- * separable from, or merely link (or bind by name) to the interfaces of,
- * the Work and Derivative Works thereof.
- *
- * "Contribution" shall mean any work of authorship, including
- * the original version of the Work and any modifications or additions
- * to that Work or Derivative Works thereof, that is intentionally
- * submitted to Licensor for inclusion in the Work by the copyright owner
- * or by an individual or Legal Entity authorized to submit on behalf of
- * the copyright owner. For the purposes of this definition, "submitted"
- * means any form of electronic, verbal, or written communication sent
- * to the Licensor or its representatives, including but not limited to
- * communication on electronic mailing lists, source code control systems,
- * and issue tracking systems that are managed by, or on behalf of, the
- * Licensor for the purpose of discussing and improving the Work, but
- * excluding communication that is conspicuously marked or otherwise
- * designated in writing by the copyright owner as "Not a Contribution."
- *
- * "Contributor" shall mean Licensor and any individual or Legal Entity
- * on behalf of whom a Contribution has been received by Licensor and
- * subsequently incorporated within the Work.
- *
- * 2. Grant of Copyright License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * copyright license to reproduce, prepare Derivative Works of,
- * publicly display, publicly perform, sublicense, and distribute the
- * Work and such Derivative Works in Source or Object form.
- *
- * 3. Grant of Patent License. Subject to the terms and conditions of
- * this License, each Contributor hereby grants to You a perpetual,
- * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- * (except as stated in this section) patent license to make, have made,
- * use, offer to sell, sell, import, and otherwise transfer the Work,
- * where such license applies only to those patent claims licensable
- * by such Contributor that are necessarily infringed by their
- * Contribution(s) alone or by combination of their Contribution(s)
- * with the Work to which such Contribution(s) was submitted. If You
- * institute patent litigation against any entity (including a
- * cross-claim or counterclaim in a lawsuit) alleging that the Work
- * or a Contribution incorporated within the Work constitutes direct
- * or contributory patent infringement, then any patent licenses
- * granted to You under this License for that Work shall terminate
- * as of the date such litigation is filed.
- *
- * 4. Redistribution. You may reproduce and distribute copies of the
- * Work or Derivative Works thereof in any medium, with or without
- * modifications, and in Source or Object form, provided that You
- * meet the following conditions:
- *
- * (a) You must give any other recipients of the Work or
- * Derivative Works a copy of this License; and
- *
- * (b) You must cause any modified files to carry prominent notices
- * stating that You changed the files; and
- *
- * (c) You must retain, in the Source form of any Derivative Works
- * that You distribute, all copyright, patent, trademark, and
- * attribution notices from the Source form of the Work,
- * excluding those notices that do not pertain to any part of
- * the Derivative Works; and
- *
- * (d) If the Work includes a "NOTICE" text file as part of its
- * distribution, then any Derivative Works that You distribute must
- * include a readable copy of the attribution notices contained
- * within such NOTICE file, excluding those notices that do not
- * pertain to any part of the Derivative Works, in at least one
- * of the following places: within a NOTICE text file distributed
- * as part of the Derivative Works; within the Source form or
- * documentation, if provided along with the Derivative Works; or,
- * within a display generated by the Derivative Works, if and
- * wherever such third-party notices normally appear. The contents
- * of the NOTICE file are for informational purposes only and
- * do not modify the License. You may add Your own attribution
- * notices within Derivative Works that You distribute, alongside
- * or as an addendum to the NOTICE text from the Work, provided
- * that such additional attribution notices cannot be construed
- * as modifying the License.
- *
- * You may add Your own copyright statement to Your modifications and
- * may provide additional or different license terms and conditions
- * for use, reproduction, or distribution of Your modifications, or
- * for any such Derivative Works as a whole, provided Your use,
- * reproduction, and distribution of the Work otherwise complies with
- * the conditions stated in this License.
- *
- * 5. Submission of Contributions. Unless You explicitly state otherwise,
- * any Contribution intentionally submitted for inclusion in the Work
- * by You to the Licensor shall be under the terms and conditions of
- * this License, without any additional terms or conditions.
- * Notwithstanding the above, nothing herein shall supersede or modify
- * the terms of any separate license agreement you may have executed
- * with Licensor regarding such Contributions.
- *
- * 6. Trademarks. This License does not grant permission to use the trade
- * names, trademarks, service marks, or product names of the Licensor,
- * except as required for reasonable and customary use in describing the
- * origin of the Work and reproducing the content of the NOTICE file.
- *
- * 7. Disclaimer of Warranty. Unless required by applicable law or
- * agreed to in writing, Licensor provides the Work (and each
- * Contributor provides its Contributions) on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied, including, without limitation, any warranties or conditions
- * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- * PARTICULAR PURPOSE. You are solely responsible for determining the
- * appropriateness of using or redistributing the Work and assume any
- * risks associated with Your exercise of permissions under this License.
- *
- * 8. Limitation of Liability. In no event and under no legal theory,
- * whether in tort (including negligence), contract, or otherwise,
- * unless required by applicable law (such as deliberate and grossly
- * negligent acts) or agreed to in writing, shall any Contributor be
- * liable to You for damages, including any direct, indirect, special,
- * incidental, or consequential damages of any character arising as a
- * result of this License or out of the use or inability to use the
- * Work (including but not limited to damages for loss of goodwill,
- * work stoppage, computer failure or malfunction, or any and all
- * other commercial damages or losses), even if such Contributor
- * has been advised of the possibility of such damages.
- *
- * 9. Accepting Warranty or Additional Liability. While redistributing
- * the Work or Derivative Works thereof, You may choose to offer,
- * and charge a fee for, acceptance of support, warranty, indemnity,
- * or other liability obligations and/or rights consistent with this
- * License. However, in accepting such obligations, You may act only
- * on Your own behalf and on Your sole responsibility, not on behalf
- * of any other Contributor, and only if You agree to indemnify,
- * defend, and hold each Contributor harmless for any liability
- * incurred by, or claims asserted against, such Contributor by reason
- * of your accepting any such warranty or additional liability.
- *
- * END OF TERMS AND CONDITIONS
- *
- * APPENDIX: How to apply the Apache License to your work.
- *
- * To apply the Apache License to your work, attach the following
- * boilerplate notice, with the fields enclosed by brackets "[]"
- * replaced with your own identifying information. (Don't include
- * the brackets!) The text should be enclosed in the appropriate
- * comment syntax for the file format. We also recommend that a
- * file or class name and description of purpose be included on the
- * same "printed page" as the copyright notice for easier
- * identification within third-party archives.
- *
- * Copyright 2016 Alibaba Group
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.taobao.weex.dom;
-
-import android.support.annotation.NonNull;
-import android.support.annotation.Nullable;
-import android.support.v4.util.ArrayMap;
-import android.text.TextUtils;
-import android.util.Pair;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.taobao.weex.WXEnvironment;
-import com.taobao.weex.WXSDKInstance;
-import com.taobao.weex.WXSDKManager;
-import com.taobao.weex.adapter.IWXUserTrackAdapter;
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.common.Constants;
-import com.taobao.weex.common.WXErrorCode;
-import com.taobao.weex.dom.flex.CSSLayoutContext;
-import com.taobao.weex.dom.flex.CSSNode;
-import com.taobao.weex.dom.flex.Spacing;
-import com.taobao.weex.ui.IWXRenderTask;
-import com.taobao.weex.ui.WXRenderManager;
-import com.taobao.weex.ui.animation.WXAnimationBean;
-import com.taobao.weex.ui.component.WXComponent;
-import com.taobao.weex.ui.component.WXVContainer;
-import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.WXViewUtils;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * <p>
- * This class is responsible for creating command object of DOM operation and
- * invoking command of corresponding object.
- * </p>
- * <p>
- * In the command design pattern,
- * this class acts as the <strong>invoker </strong>in the command pattern
- * despite that it is also responsible for creating <strong>Command</strong> object.
- * And,{@link IWXRenderTask} works as the <strong>Command</strong>
- * {@link WXDomManager} works as the <strong>Client</strong>
- * {@link WXRenderManager} works as the <strong>Receiver</strong>.
- * </p>
- * <p>
- * There exists one to one correspondence between WXDomStatement and WXInstance,
- * and {@link WXDomManager} is responsible for manage the relation of correspondence.
- * </p>
- */
-class WXDomStatement {
- /** package **/ final ConcurrentHashMap<String, WXDomObject> mRegistry;
- private WXDomObject.Consumer mAddDOMConsumer;
- private String mInstanceId;
- private WXRenderManager mWXRenderManager;
- private ArrayList<IWXRenderTask> mNormalTasks;
- private Set <Pair<String, Map<String, Object>>> animations;
- private CSSLayoutContext mLayoutContext;
- private volatile boolean mDirty;
- private boolean mDestroy;
- private Map<String, AddDomInfo> mAddDom = new HashMap<>();
-
- /**
- * Create an instance of {@link WXDomStatement},
- * One {@link WXSDKInstance} corresponding to one and only one {@link WXDomStatement}.
- * And all the instance of {@link WXDomManager} share the same {@link WXRenderManager}.
- * @param instanceId the id of the {@link WXSDKInstance}.
- * One {@link WXSDKInstance} corresponding to one {@link WXDomStatement},
- * and vice versa.
- * @param renderManager This acts as the Receiver of the command pattern
- */
- public WXDomStatement(String instanceId, WXRenderManager renderManager) {
- mDestroy = false;
- mInstanceId = instanceId;
- mLayoutContext = new CSSLayoutContext();
- mRegistry = new ConcurrentHashMap<>();
- mNormalTasks = new ArrayList<>();
- animations = new LinkedHashSet<>();
- mWXRenderManager = renderManager;
- mAddDOMConsumer = new AddDOMConsumer(mRegistry);
- }
-
- /**
- * Destroy current instance, which occurred when {@link WXSDKInstance#destroy()} is called.
- */
- public void destroy() {
- mDestroy = true;
- mRegistry.clear();
- mAddDOMConsumer = null;
- mNormalTasks.clear();
- mAddDom.clear();
- mLayoutContext = null;
- mWXRenderManager = null;
- animations.clear();
- }
-
- /**
- * Rebuild the component tree.
- * The purpose of this method is moving fixed components to the root component.
- * This method will be called when {@link #batch()} is executed.
- * @param root root dom
- */
- void rebuildingFixedDomTree(WXDomObject root) {
- if (root != null && root.getFixedStyleRefs() != null) {
- int size = root.getFixedStyleRefs().size();
- for (int i = 0; i < size; i++) {
- String fixedRef = root.getFixedStyleRefs().get(i);
- WXDomObject wxDomObject = mRegistry.get(fixedRef);
- if (wxDomObject!=null && wxDomObject.parent != null) {
- wxDomObject.parent.remove(wxDomObject);
- root.add(wxDomObject, -1);
- }
- }
- }
-
- }
-
- /**
- * Batch the execution of command objects and execute all the command objects created other
- * places, e.g. call {@link IWXRenderTask#execute()}.
- * First, it will rebuild the dom tree and do pre layout staff.
- * Then call {@link com.taobao.weex.dom.flex.CSSNode#calculateLayout(CSSLayoutContext)} to
- * start calculate layout.
- * Next, call {@link ApplyUpdateConsumer} to get changed dom and creating
- * corresponding command object.
- * Finally, walk through the queue, e.g. call {@link IWXRenderTask#execute()} for every task
- * in the queue.
- */
- void batch() {
-
- if (!mDirty || mDestroy) {
- return;
- }
-
- WXDomObject rootDom = mRegistry.get(WXDomObject.ROOT);
- layout(rootDom);
- }
-
- void layout(WXDomObject rootDom) {
- if (rootDom == null) {
- return;
- }
- long start0 = System.currentTimeMillis();
-
- rebuildingFixedDomTree(rootDom);
-
- rootDom.traverseTree( new WXDomObject.Consumer() {
- @Override
- public void accept(WXDomObject dom) {
- if (!dom.hasUpdate() || mDestroy) {
- return;
- }
- dom.layoutBefore();
- }
- });
- long start = System.currentTimeMillis();
-
-
- rootDom.calculateLayout(mLayoutContext);
-
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- if (instance != null) {
- instance.cssLayoutTime(System.currentTimeMillis() - start);
- }
-
- rootDom.traverseTree( new WXDomObject.Consumer() {
- @Override
- public void accept(WXDomObject dom) {
- if (!dom.hasUpdate() || mDestroy) {
- return;
- }
- dom.layoutAfter();
- }
- });
-
- start = System.currentTimeMillis();
- rootDom.traverseTree(new ApplyUpdateConsumer());
-
- if (instance != null) {
- instance.applyUpdateTime(System.currentTimeMillis() - start);
- }
-
- start = System.currentTimeMillis();
- updateDomObj();
- if (instance != null) {
- instance.updateDomObjTime(System.currentTimeMillis() - start);
- }
- parseAnimation();
-
- int count = mNormalTasks.size();
- for (int i = 0; i < count && !mDestroy; ++i) {
- mWXRenderManager.runOnThread(mInstanceId, mNormalTasks.get(i));
- }
- mNormalTasks.clear();
- mAddDom.clear();
- animations.clear();
- mDirty = false;
- if (instance != null) {
- instance.batchTime(System.currentTimeMillis() - start0);
- }
- }
-
- class ApplyUpdateConsumer implements WXDomObject.Consumer{
-
- @Override
- public void accept(WXDomObject dom) {
- if (dom.hasUpdate()) {
- dom.markUpdateSeen();
- if (!dom.isYoung()) {
- final WXDomObject copy = dom.clone();
- if (copy == null) {
- return;
- }
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.setLayout(mInstanceId, copy.getRef(), copy);
- if(copy.getExtra() != null) {
- mWXRenderManager.setExtra(mInstanceId, copy.getRef(), copy.getExtra());
- }
- }
-
- @Override
- public String toString() {
- return "setLayout & setExtra";
- }
- });
- }
- }
- }
- }
-
- private void parseAnimation() {
- for(final Pair<String, Map<String, Object>> pair:animations) {
- if (!TextUtils.isEmpty(pair.first)) {
- final WXAnimationBean animationBean = createAnimationBean(pair.first, pair.second);
- if (animationBean != null) {
- mNormalTasks.add(new IWXRenderTask() {
- @Override
- public void execute() {
- mWXRenderManager.startAnimation(mInstanceId, pair.first, animationBean, null);
- }
-
- @Override
- public String toString() {
- return "startAnimationByStyle";
- }
- });
- }
- }
- }
- }
-
- /**
- * Create command object for creating body according to the JSONObject. And put the command
- * object in the queue.
- * @param dom the jsonObject according to which to create command object.
- */
- void createBody(JSONObject dom) {
- addDomInternal(dom,true,null,-1);
- }
-
- private class CreateBodyTask implements IWXRenderTask {
- final WXComponent mComponent;
-
- CreateBodyTask(WXComponent component) {
- mComponent = component;
- }
-
- @Override
- public void execute() {
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- if (instance == null || instance.getContext() == null) {
- WXLogUtils.e("instance is null or instance is destroy!");
- return;
- }
- try {
- mWXRenderManager.createBody(mInstanceId, mComponent);
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- } catch (Exception e) {
- WXLogUtils.e("create body failed.", e);
- }
- }
-
- @Override
- public String toString() {
- return "createBody";
- }
- }
-
- /**
- * Update all components' dom info stored in {@link #mAddDom}
- */
- private void updateDomObj() {
- long start = System.currentTimeMillis();
- Iterator<Map.Entry<String, AddDomInfo>> iterator = mAddDom.entrySet().iterator();
- Map.Entry<String, AddDomInfo> entry;
- AddDomInfo value;
- while (iterator.hasNext()) {
- entry = iterator.next();
- value = entry.getValue();
- updateDomObj(value.component);
- }
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.d("updateDomObj", "time:" + (System.currentTimeMillis() - start));
- }
- }
-
- /**
- * Update the specified component's dom and mark it as old.
- * @param component the component to be updated
- */
- private void updateDomObj(WXComponent component) {
- if (component == null) {
- return;
- }
- WXDomObject domObject = mRegistry.get(component.getRef());
- if (domObject == null) {
- return;
- }
- domObject.old();
- component.updateDom(domObject);
- if (component instanceof WXVContainer) {
- WXVContainer container = (WXVContainer) component;
- int count = container.childCount();
- for (int i = 0; i < count; ++i) {
- updateDomObj(container.getChild(i));
- }
- }
- }
-
- void invokeMethod(String ref, String method, JSONArray args){
- if(mDestroy){
- return;
- }
- WXComponent comp = mWXRenderManager.getWXComponent(mInstanceId, ref);
- if(comp == null){
- WXLogUtils.e("DomStatement","target component not found.");
- return;
- }
- comp.invoke(method,args);
- }
-
- /**
- * Add DOM node.
- * @param dom
- * @param isRoot
- * @param parentRef
- * @param index
- */
- private void addDomInternal(JSONObject dom,boolean isRoot, String parentRef, final int index){
- if (mDestroy) {
- return;
- }
-
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- if (instance == null) {
- return;
- }
- WXErrorCode errCode = isRoot ? WXErrorCode.WX_ERR_DOM_CREATEBODY : WXErrorCode.WX_ERR_DOM_ADDELEMENT;
- if (dom == null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
- }
-
- //only non-root has parent.
- WXDomObject parent;
- WXDomObject domObject = WXDomObject.parse(dom,instance);
-
- if (domObject == null || mRegistry.containsKey(domObject.getRef())) {
- if (WXEnvironment.isApkDebugable()) {
- WXLogUtils.e("[WXDomStatement] " + (isRoot ? "createBody" : "addDom") + " error,DOM object is null or already registered!!");
- }
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
- return;
- }
- if (isRoot) {
- WXDomObject.prepareRoot(domObject,
- WXViewUtils.getWebPxByWidth(WXViewUtils.getWeexHeight(mInstanceId),WXSDKManager.getInstanceViewPortWidth(mInstanceId)),
- WXViewUtils.getWebPxByWidth(WXViewUtils.getWeexWidth(mInstanceId),WXSDKManager.getInstanceViewPortWidth(mInstanceId)));
- } else if ((parent = mRegistry.get(parentRef)) == null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
- return;
- } else {
- //non-root and parent exist
- parent.add(domObject, index);
- }
-
- domObject.traverseTree(
- mAddDOMConsumer,
- ApplyStyleConsumer.getInstance()
- );
-
- //Create component in dom thread
- WXComponent component = isRoot ?
- mWXRenderManager.createBodyOnDomThread(mInstanceId, domObject) :
- mWXRenderManager.createComponentOnDomThread(mInstanceId, domObject, parentRef, index);
- if (component == null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
- //stop redner, some fatal happened.
- return;
- }
- AddDomInfo addDomInfo = new AddDomInfo();
- addDomInfo.component = component;
- mAddDom.put(domObject.getRef(), addDomInfo);
-
- IWXRenderTask task = isRoot ? new CreateBodyTask(component) : new AddDOMTask(component, parentRef, index);
- mNormalTasks.add(task);
- addAnimationForDomTree(domObject);
- mDirty = true;
-
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
-
- /**
- * Create a command object for adding a dom node to its parent in a specific location.
- * If dom's parent doesn't exist or the dom has been added in current {@link WXSDKInstance},
- * this method will return.
- * If the above request is met, then put the command object in the queue.
- * @param dom the dom object in the form of JSONObject
- * @param parentRef parent to which the dom is added.
- * @param index the location of which the dom is added.
- */
- void addDom(JSONObject dom, final String parentRef, final int index) {
- addDomInternal(dom,false,parentRef,index);
- }
-
- private class AddDOMTask implements IWXRenderTask {
- final WXComponent mComponent;
- final String mParentRef;
- final int mIndex;
- AddDOMTask(WXComponent comp,String parentRef,int index){
- mComponent = comp;
- mParentRef = parentRef;
- mIndex = index;
- }
-
- @Override
- public void execute() {
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- if(instance == null || instance.getContext()== null) {
- WXLogUtils.e("instance is null or instance is destroy!");
- return;
- }
- try {
- mWXRenderManager.addComponent(mInstanceId, mComponent, mParentRef, mIndex);
- }catch (Exception e){
- WXLogUtils.e("add component failed.", e);
- }
- }
-
- @Override
- public String toString() {
- return "AddDom";
- }
- }
-
- /**
- * Create a command object for moving the specific {@link WXDomObject} to a new parent.
- * If any of the following situation is met,
- * <ul>
- * <li> dom to be moved is null </li>
- * <li> dom's parent is null </li>
- * <li> new parent is null </li>
- * <li> parent is under {@link CSSNode#hasNewLayout()} </li>
- * </ul>
- * this method will return. Otherwise, put the command object in the queue.
- * @param ref Reference of the dom to be moved.
- * @param parentRef Reference of the new parent DOM node
- * @param index the index of the dom to be inserted in the new parent.
- */
- void moveDom(final String ref, final String parentRef, int index) {
- if (mDestroy) {
- return;
- }
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- WXDomObject domObject = mRegistry.get(ref);
- WXDomObject parentObject = mRegistry.get(parentRef);
- if (domObject == null || domObject.parent == null
- || parentObject == null || parentObject.hasNewLayout()) {
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_MOVEELEMENT);
- }
- return;
- }
- if (domObject.parent.equals(parentObject)) {
- if(parentObject.index(domObject) == index) {
- return;
- } else if(domObject.parent.index(domObject)<index){
- index = index -1;
- }
- }
-
- final int newIndex = index;
- domObject.parent.remove(domObject);
- parentObject.add(domObject, newIndex);
-
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.moveComponent(mInstanceId, ref, parentRef, newIndex);
- }
-
- @Override
- public String toString() {
- return "moveDom";
- }
- });
-
- mDirty = true;
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Create a command object for removing the specified {@link WXDomObject}.
- * If the domObject is null or its parent is null, this method returns directly.
- * Otherwise, put the command object in the queue.
- * @param ref Reference of the dom.
- */
- void removeDom(final String ref) {
- if (mDestroy) {
- return;
- }
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- WXDomObject domObject = mRegistry.get(ref);
- if (domObject == null) {
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
- }
- return;
- }
- WXDomObject parent = domObject.parent;
- if (parent == null) {
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
- }
- return;
- }
- domObject.traverseTree(new WXDomObject.Consumer() {
- @Override
- public void accept(WXDomObject dom) {
- mRegistry.remove(dom.getRef());
- }
- });
- parent.remove(domObject);
- mRegistry.remove(ref);
-
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.removeComponent(mInstanceId, ref);
- }
-
- @Override
- public String toString() {
- return "removeDom";
- }
- });
-
- mDirty = true;
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Update the attributes according to the given attribute. Then creating a
- * command object for updating corresponding view and put the command object in the queue.
- * @param ref Reference of the dom.
- * @param attrs the new style. This style is only a part of the full attribute set, and will be
- * merged into attributes
- * @see #updateStyle(String, JSONObject)
- */
- void updateAttrs(String ref, final JSONObject attrs) {
- if (mDestroy) {
- return;
- }
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- final WXDomObject domObject = mRegistry.get(ref);
- if (domObject == null) {
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATEATTRS);
- }
- return;
- }
-
- domObject.updateAttr(attrs);
-
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.updateAttrs(mInstanceId, domObject.getRef(), attrs);
- }
-
- @Override
- public String toString() {
- return "updateAttr";
- }
- });
- mDirty = true;
-
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Update styles according to the given style. Then creating a
- * command object for updating corresponding view and put the command object in the queue.
- * @param ref Reference of the dom.
- * @param style the new style. This style is only a part of the full style, and will be merged
- * into styles
- * @param byPesudo updateStyle by pesduo class
- * @see #updateAttrs(String, JSONObject)
- */
- void updateStyle(String ref, JSONObject style, boolean byPesudo) {
- if (mDestroy || style == null) {
- return;
- }
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- WXDomObject domObject = mRegistry.get(ref);
- if (domObject == null) {
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
- }
- return;
- }
-
- Map<String, Object> animationMap= new ArrayMap<>(2);
- animationMap.put(WXDomObject.TRANSFORM, style.remove(WXDomObject.TRANSFORM));
- animationMap.put(WXDomObject.TRANSFORM_ORIGIN, style.remove(WXDomObject.TRANSFORM_ORIGIN));
- animations.add(new Pair<>(ref, animationMap));
-
- if(!style.isEmpty()){
- domObject.updateStyle(style, byPesudo);
- domObject.traverseTree(ApplyStyleConsumer.getInstance());
- updateStyle(domObject, style);
- }
- mDirty = true;
-
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Create the command object for updating style and put it the queue. If the given style
- * contains border-width and padding that will affect layout, then a command object for reset
- * padding will also be created.
- * @param domObject the given dom object
- * @param update the given style.
- */
- private void updateStyle(final WXDomObject domObject, final Map<String, Object> update) {
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.updateStyle(mInstanceId, domObject.getRef(), update);
- }
-
- @Override
- public String toString() {
- return "updateStyle";
- }
- });
- if (update.containsKey(Constants.Name.PADDING) ||
- update.containsKey(Constants.Name.PADDING_TOP) ||
- update.containsKey(Constants.Name.PADDING_LEFT) ||
- update.containsKey(Constants.Name.PADDING_RIGHT) ||
- update.containsKey(Constants.Name.PADDING_BOTTOM) ||
- update.containsKey(Constants.Name.BORDER_WIDTH)) {
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- Spacing padding = domObject.getPadding();
- Spacing border = domObject.getBorder();
- mWXRenderManager.setPadding(mInstanceId, domObject.getRef(), padding, border);
- }
-
- @Override
- public String toString() {
- return "setPadding";
- }
- });
- }
- }
-
- /**
- * Create a command object for adding a default event listener to the corresponding {@link
- * WXDomObject} and put the command object in the queue.
- * When the event is triggered, the eventListener will call {@link WXSDKManager#fireEvent(String, String, String)}
- * , and the JS will handle all the operations from there.
- *
- * @param ref Reference of the dom.
- * @param type the type of the event, this may be a plain event defined in
- * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
- * .weex.ui.view.gesture.WXGestureType}
- */
- void addEvent(final String ref, final String type) {
- if (mDestroy) {
- return;
- }
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- final WXDomObject domObject = mRegistry.get(ref);
- if (domObject == null) {
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_ADDEVENT);
- }
- return;
- }
- domObject.addEvent(type);
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- WXComponent comp = mWXRenderManager.getWXComponent(mInstanceId,ref);
- if(comp != null){
- //sync dom change to component
- comp.updateDom(domObject);
- mWXRenderManager.addEvent(mInstanceId, ref, type);
- }
- }
-
- @Override
- public String toString() {
- return "Add event";
- }
- });
-
- mDirty = true;
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Create a command object for removing the event listener of the corresponding {@link
- * WXDomObject} and put the command event in the queue.
- * @param ref Reference of the dom.
- * @param type the type of the event, this may be a plain event defined in
- * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
- * .weex.ui.view.gesture.WXGestureType}
- */
- void removeEvent(final String ref, final String type) {
- if (mDestroy) {
- return;
- }
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- final WXDomObject domObject = mRegistry.get(ref);
- if (domObject == null) {
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEEVENT);
- }
- return;
- }
- domObject.removeEvent(type);
-
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- WXComponent comp = mWXRenderManager.getWXComponent(mInstanceId,ref);
- if(comp != null){
- //sync dom change to component
- comp.updateDom(domObject);
- mWXRenderManager.removeEvent(mInstanceId, ref, type);
- }
-
- }
-
- @Override
- public String toString() {
- return "removeEvent";
- }
- });
-
- mDirty = true;
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Create a command object for scroll the given view to the specified position.
- * @param ref Reference of the dom.
- * @param options the specified position
- */
- void scrollToDom(final String ref, final JSONObject options) {
- if (mDestroy) {
- return;
- }
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
-
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.scrollToComponent(mInstanceId, ref, options);
- }
-
- @Override
- public String toString() {
- return "scrollToPosition";
- }
- });
-
- mDirty = true;
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Create a command object for notifying {@link WXRenderManager} that the process of creating
- * given view is finished, and put the command object in the queue.
- */
- void createFinish() {
- if (mDestroy) {
- return;
- }
-
- final WXDomObject root = mRegistry.get(WXDomObject.ROOT);
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.createFinish(mInstanceId,
- (int) root.getLayoutWidth(),
- (int) root.getLayoutHeight());
- }
-
- @Override
- public String toString() {
- return "createFinish";
- }
- });
-
- mDirty = true;
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Create a command object for notifying {@link WXRenderManager} that the process of refreshing
- * given view is finished, and put the command object in the queue.
- */
- void refreshFinish() {
- if (mDestroy) {
- return;
- }
- final WXDomObject root = mRegistry.get(WXDomObject.ROOT);
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- int realWidth = (int) root.getLayoutWidth();
- int realHeight = (int) root.getLayoutHeight();
- mWXRenderManager.refreshFinish(mInstanceId, realWidth, realHeight);
- }
-
- @Override
- public String toString() {
- return "refreshFinish";
- }
- });
-
- mDirty = true;
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- /**
- * Create a command object for notifying {@link WXRenderManager} that the process of update
- * given view is finished, and put the command object in the queue.
- */
- void updateFinish() {
- if (mDestroy) {
- return;
- }
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.updateFinish(mInstanceId);
- }
-
- @Override
- public String toString() {
- return "updateFinish";
- }
- });
-
- WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
- if (instance != null) {
- instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
- }
- }
-
- void startAnimation(@NonNull final String ref, @NonNull String animation,
- @Nullable final String callBack){
- if (mDestroy) {
- return;
- }
- WXDomObject domObject = mRegistry.get(ref);
- if (domObject == null) {
- return;
- }
- final WXAnimationBean animationBean=createAnimationBean(ref, animation);
- if(animationBean!=null) {
- mNormalTasks.add(new IWXRenderTask() {
- @Override
- public void execute() {
- mWXRenderManager.startAnimation(mInstanceId, ref, animationBean, callBack);
- }
-
- @Override
- public String toString() {
- return "startAnimationByCall";
- }
- });
- mDirty=true;
- }
- }
-
- private void addAnimationForDomTree(WXDomObject domObject){
- animations.add(new Pair<String, Map<String, Object>>(domObject.getRef(),domObject.getStyles()));
- for(int i=0;i<domObject.childCount();i++){
- addAnimationForDomTree(domObject.getChild(i));
- }
- }
-
- private WXAnimationBean createAnimationBean(String ref, String animation){
- try {
- WXAnimationBean animationBean =
- JSONObject.parseObject(animation, WXAnimationBean.class);
- if (animationBean != null && animationBean.styles != null) {
- WXDomObject domObject=mRegistry.get(ref);
- int width=(int)domObject.getLayoutWidth();
- int height=(int)domObject.getLayoutHeight();
- animationBean.styles.init(animationBean.styles.transformOrigin,
- animationBean.styles.transform,width,height,WXSDKManager.getInstance().getSDKInstance(mInstanceId).getInstanceViewPortWidth());
- }
- return animationBean;
- } catch (RuntimeException e) {
- WXLogUtils.e("", e);
- return null;
- }
- }
-
- private WXAnimationBean createAnimationBean(String ref,Map<String, Object> style){
- if (style != null) {
- try {
- Object transform = style.get(WXDomObject.TRANSFORM);
- if (transform instanceof String && !TextUtils.isEmpty((String) transform)) {
- String transformOrigin = (String) style.get(WXDomObject.TRANSFORM_ORIGIN);
- WXAnimationBean animationBean = new WXAnimationBean();
- WXDomObject domObject = mRegistry.get(ref);
- int width = (int) domObject.getLayoutWidth();
- int height = (int) domObject.getLayoutHeight();
- animationBean.styles = new WXAnimationBean.Style();
- animationBean.styles.init(transformOrigin, (String) transform, width, height,WXSDKManager.getInstance().getSDKInstance(mInstanceId).getInstanceViewPortWidth());
- return animationBean;
- }
- }catch (RuntimeException e){
- WXLogUtils.e("", e);
- return null;
- }
- }
- return null;
- }
-
-
- private static class AddDOMConsumer implements WXDomObject.Consumer {
- final ConcurrentHashMap<String, WXDomObject> mRegistry;
- AddDOMConsumer(ConcurrentHashMap<String, WXDomObject> r){
- mRegistry = r;
- }
-
- @Override
- public void accept(WXDomObject dom) {
- //register dom
- dom.young();
- mRegistry.put(dom.getRef(), dom);
-
- //find fixed node
- WXDomObject rootDom = mRegistry.get(WXDomObject.ROOT);
- if (rootDom != null && dom.isFixed()) {
- rootDom.add2FixedDomList(dom.getRef());
- }
- }
- }
-
- static class ApplyStyleConsumer implements WXDomObject.Consumer {
- static ApplyStyleConsumer sInstance;
-
- public static ApplyStyleConsumer getInstance(){
- if(sInstance == null){
- sInstance = new ApplyStyleConsumer();
- }
- return sInstance;
- }
-
- private ApplyStyleConsumer(){};
-
- @Override
- public void accept(WXDomObject dom) {
- WXStyle style = dom.getStyles();
-
- /** merge default styles **/
- Map<String, String> defaults = dom.getDefaultStyle();
- if (defaults != null) {
- for (Map.Entry<String, String> entry : defaults.entrySet()) {
- if (!style.containsKey(entry.getKey())) {
- style.put(entry.getKey(), entry.getValue());
- }
- }
- }
-
- if (dom.getStyles().size() > 0) {
- dom.applyStyleToNode();
- }
- }
- }
-
- public void getComponentSize(final String ref, final JSCallback callback) {
- if (mDestroy) {
- Map<String, Object> options = new HashMap<>();
- options.put("result", false);
- options.put("errMsg", "Component does not exist");
- callback.invoke(options);
- return;
- }
-
- mNormalTasks.add(new IWXRenderTask() {
-
- @Override
- public void execute() {
- mWXRenderManager.getComponentSize(mInstanceId, ref, callback);
- }
-
- @Override
- public String toString() {
- return "getComponentSize";
- }
- });
- mDirty=true;
-
- }
-
- static class AddDomInfo {
-
- public WXComponent component;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java
new file mode 100644
index 0000000..8b3cf3d
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java
@@ -0,0 +1,313 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXEnvironment;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.ui.component.WXComponentFactory;
+import com.taobao.weex.ui.component.WXVContainer;
+import com.taobao.weex.utils.WXLogUtils;
+
+/**
+ * Created by sospartan on 22/02/2017.
+ */
+
+abstract class AbstractAddElementAction implements DOMAction, RenderAction {
+
+
+ protected WXComponent generateComponentTree(DOMActionContext context, WXDomObject dom, WXVContainer parent) {
+ if (dom == null) {
+ return null;
+ }
+ WXComponent component = WXComponentFactory.newInstance(context.getInstance(), dom, parent);
+
+ context.registerComponent(dom.getRef(), component);
+ if (component instanceof WXVContainer) {
+ WXVContainer parentC = (WXVContainer) component;
+ int count = dom.childCount();
+ WXDomObject child = null;
+ for (int i = 0; i < count; ++i) {
+ child = dom.getChild(i);
+ if (child != null) {
+ parentC.addChild(generateComponentTree(context, child, parentC));
+ }
+ }
+ }
+
+ return component;
+ }
+
+ /**
+ * Add DOM node.
+ */
+ protected void addDomInternal(DOMActionContext context, JSONObject dom) {
+ if (context.isDestory()) {
+ return;
+ }
+
+ WXSDKInstance instance = context.getInstance();
+ if (instance == null) {
+ return;
+ }
+ WXErrorCode errCode = getErrorCode();
+ if (dom == null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
+ }
+
+ //only non-root has parent.
+ WXDomObject domObject = WXDomObject.parse(dom, instance);
+
+ if (domObject == null || context.getDomByRef(domObject.getRef()) != null) {
+ if (WXEnvironment.isApkDebugable()) {
+ WXLogUtils.e("[DOMActionContextImpl] " + getStatementName() + " error,DOM object is null or already registered!!");
+ }
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
+ return;
+ }
+ appendDomToTree(context, domObject);
+
+ domObject.traverseTree(
+ context.getAddDOMConsumer(),
+ context.getApplyStyleConsumer()
+ );
+
+ //Create component in dom thread
+ WXComponent component = createComponent(context, domObject);
+ if (component == null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
+ //stop redner, some fatal happened.
+ return;
+ }
+ context.addDomInfo(domObject.getRef(), component);
+ context.postRenderTask(this);
+ addAnimationForDomTree(context, domObject);
+
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+
+ public void addAnimationForDomTree(DOMActionContext context, WXDomObject domObject) {
+ context.addAnimationForElement(domObject.getRef(), domObject.getStyles());
+ for (int i = 0; i < domObject.childCount(); i++) {
+ addAnimationForDomTree(context, domObject.getChild(i));
+ }
+ }
+
+ protected abstract WXComponent createComponent(DOMActionContext context, WXDomObject domObject);
+
+ protected abstract void appendDomToTree(DOMActionContext context, WXDomObject domObject);
+
+ protected abstract String getStatementName();
+
+ protected abstract WXErrorCode getErrorCode();
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractLayoutFinishAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractLayoutFinishAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractLayoutFinishAction.java
new file mode 100644
index 0000000..510d550
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractLayoutFinishAction.java
@@ -0,0 +1,240 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.common.WXRenderStrategy;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.WXDomObject;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+abstract class AbstractLayoutFinishAction implements DOMAction, RenderAction {
+
+ protected int mLayoutWidth;
+ protected int mLayoutHeight;
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+
+ WXDomObject root = context.getDomByRef(WXDomObject.ROOT);
+ mLayoutHeight = (int)root.getLayoutHeight();
+ mLayoutWidth = (int)root.getLayoutWidth();
+ context.postRenderTask(this);
+ WXSDKInstance instance = context.getInstance();
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+}
[3/9] incubator-weex git commit: * [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,
DomModule#getComponentSize. It's low risk since it's a internal method,
users should not dirct use it.
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/GetComponentRectAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/GetComponentRectAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/GetComponentRectAction.java
new file mode 100644
index 0000000..3fcd938
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/GetComponentRectAction.java
@@ -0,0 +1,314 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import android.graphics.Rect;
+import android.support.annotation.NonNull;
+import android.text.TextUtils;
+import android.view.View;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.bridge.JSCallback;
+import com.taobao.weex.bridge.SimpleJSCallback;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.utils.WXViewUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+class GetComponentRectAction implements DOMAction, RenderAction {
+ private final String mRef;
+ private final String mCallback;
+
+
+ GetComponentRectAction(String ref, String callback) {
+ this.mRef = ref;
+ this.mCallback = callback;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ JSCallback jsCallback = new SimpleJSCallback(context.getInstance().getInstanceId(), mCallback);
+ if (context.isDestory()) {
+ Map<String, Object> options = new HashMap<>();
+ options.put("result", false);
+ options.put("errMsg", "Component does not exist");
+ jsCallback.invoke(options);
+ } else {
+ context.postRenderTask(this);
+ }
+
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ JSCallback jsCallback = new SimpleJSCallback(context.getInstance().getInstanceId(), mCallback);
+ if (TextUtils.isEmpty(mRef)) {
+ Map<String, Object> options = new HashMap<>();
+ options.put("result", false);
+ options.put("errMsg", "Illegal parameter");
+ jsCallback.invoke(options);
+ } else if ("viewport".equalsIgnoreCase(mRef)) {
+ callbackViewport(context, jsCallback);
+ } else {
+ WXComponent component = context.getComponent(mRef);
+ Map<String, Object> options = new HashMap<>();
+ if (component != null) {
+ Map<String, String> size = new HashMap<>();
+ Rect sizes = component.getComponentSize();
+ size.put("width", getWebPxValue(sizes.width()));
+ size.put("height", getWebPxValue(sizes.height()));
+ size.put("bottom", getWebPxValue(sizes.bottom));
+ size.put("left", getWebPxValue(sizes.left));
+ size.put("right", getWebPxValue(sizes.right));
+ size.put("top", getWebPxValue(sizes.top));
+ options.put("size", size);
+ options.put("result", true);
+ } else {
+ options.put("errMsg", "Component does not exist");
+ }
+ jsCallback.invoke(options);
+ }
+ }
+
+ private void callbackViewport(RenderActionContext context, JSCallback jsCallback) {
+ WXSDKInstance instance = context.getInstance();
+ View container;
+ if ((container = instance.getContainerView()) != null) {
+ Map<String, Object> options = new HashMap<>();
+ Map<String, String> sizes = new HashMap<>();
+ int[] location = new int[2];
+ instance.getContainerView().getLocationOnScreen(location);
+ sizes.put("left", "0");
+ sizes.put("top", "0");
+ sizes.put("right", getWebPxValue(container.getWidth()));
+ sizes.put("bottom", getWebPxValue(container.getHeight()));
+ sizes.put("width", getWebPxValue(container.getWidth()));
+ sizes.put("height", getWebPxValue(container.getHeight()));
+ options.put("size", sizes);
+ options.put("result", true);
+ jsCallback.invoke(options);
+ } else {
+ Map<String, Object> options = new HashMap<>();
+ options.put("result", false);
+ options.put("errMsg", "Component does not exist");
+ jsCallback.invoke(options);
+ }
+ }
+
+ @NonNull
+ private String getWebPxValue(int value) {
+ return String.valueOf(WXViewUtils.getWebPxByWidth(value, WXSDKInstance.getViewPortWidth()));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/InvokeMethodAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/InvokeMethodAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/InvokeMethodAction.java
new file mode 100644
index 0000000..5ca4454
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/InvokeMethodAction.java
@@ -0,0 +1,236 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.alibaba.fastjson.JSONArray;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.utils.WXLogUtils;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+final class InvokeMethodAction implements DOMAction {
+ private final String mRef;
+ private final String mMethod;
+ private final JSONArray mArgs;
+
+ InvokeMethodAction(String ref, String method, JSONArray args) {
+ this.mRef = ref;
+ this.mMethod = method;
+ this.mArgs = args;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ WXComponent comp = context.getCompByRef(mRef);
+ if(comp == null){
+ WXLogUtils.e("DOMAction","target component not found.");
+ return;
+ }
+ comp.invoke(mMethod,mArgs);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java
new file mode 100644
index 0000000..664874d
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java
@@ -0,0 +1,281 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.ui.component.WXVContainer;
+
+/**
+ * Created by sospartan on 01/03/2017.
+ */
+final class MoveElementAction implements DOMAction, RenderAction {
+ private final String mRef;
+ private final String mParentRef;
+ private final int mIndex;
+
+ private int mNewIndex;
+
+ MoveElementAction(String ref, String parentRef, int index) {
+ mRef = ref;
+ mParentRef = parentRef;
+ mIndex = index;
+ mNewIndex = index;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+ WXSDKInstance instance = context.getInstance();
+ WXDomObject domObject = context.getDomByRef(mRef);
+ WXDomObject parentObject = context.getDomByRef(mParentRef);
+ if (domObject == null || domObject.parent == null
+ || parentObject == null || parentObject.hasNewLayout()) {
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_MOVEELEMENT);
+ }
+ return;
+ }
+ int index = mIndex;
+ if (domObject.parent.equals(parentObject)) {
+ if(parentObject.index(domObject) == index) {
+ return;
+ } else if(domObject.parent.index(domObject)< index){
+ index = index -1;
+ }
+ }
+
+ mNewIndex = index;
+ domObject.parent.remove(domObject);
+ parentObject.add(domObject, mNewIndex);
+
+ context.postRenderTask(this);
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent component = context.getComponent(mRef);
+ WXComponent newParent = context.getComponent(mParentRef);
+ if (component == null || component.getParent() == null
+ || newParent == null || !(newParent instanceof WXVContainer)) {
+ return;
+ }
+ WXVContainer oldParent = component.getParent();
+ oldParent.remove(component,false);
+ ((WXVContainer) newParent).addChild(component, mNewIndex);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/RefreshFinishAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/RefreshFinishAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/RefreshFinishAction.java
new file mode 100644
index 0000000..ae9f8fb
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/RefreshFinishAction.java
@@ -0,0 +1,221 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.dom.RenderActionContext;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+
+class RefreshFinishAction extends AbstractLayoutFinishAction {
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXSDKInstance instance = context.getInstance();
+ instance.onRefreshSuccess(mLayoutWidth, mLayoutHeight);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveElementAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveElementAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveElementAction.java
new file mode 100644
index 0000000..2186f5f
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveElementAction.java
@@ -0,0 +1,286 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.ui.component.WXVContainer;
+
+/**
+ * Created by sospartan on 27/02/2017.
+ */
+final class RemoveElementAction implements DOMAction, RenderAction {
+ private final String mRef;
+
+ RemoveElementAction(String ref) {
+ mRef = ref;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+ WXSDKInstance instance = context.getInstance();
+ WXDomObject domObject = context.getDomByRef(mRef);
+ if (domObject == null) {
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
+ }
+ return;
+ }
+ WXDomObject parent = domObject.parent;
+ if (parent == null) {
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEELEMENT);
+ }
+ return;
+ }
+ domObject.traverseTree(context.getRemoveElementConsumer());
+ parent.remove(domObject);
+ context.unregisterDOMObject(mRef);
+
+ context.postRenderTask(this);
+
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent component = context.getComponent(mRef);
+ if (component == null || component.getParent() == null) {
+ return;
+ }
+ WXVContainer parent = component.getParent();
+ clearRegistryForComponent(context, component);
+ parent.remove(component, true);
+ context.unregisterComponent(mRef);
+ }
+
+ private void clearRegistryForComponent(RenderActionContext context, WXComponent component) {
+ WXComponent removedComponent = context.unregisterComponent(component.getDomObject().getRef());
+ if (removedComponent != null) {
+ removedComponent.removeAllEvent();
+ removedComponent.removeStickyStyle();
+ }
+ if (component instanceof WXVContainer) {
+ WXVContainer container = (WXVContainer) component;
+ int count = container.childCount();
+ for (int i = count - 1; i >= 0; --i) {
+ clearRegistryForComponent(context, container.getChild(i));
+ }
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveEventAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveEventAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveEventAction.java
new file mode 100644
index 0000000..c909c60
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/RemoveEventAction.java
@@ -0,0 +1,264 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.WXSDKManager;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.IWXRenderTask;
+import com.taobao.weex.ui.component.WXComponent;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+class RemoveEventAction implements DOMAction, RenderAction {
+ private final String mRef;
+ private final String mEvent;
+
+ private WXDomObject mUpdatedDomObject;
+
+ RemoveEventAction(String ref, String event) {
+ this.mRef = ref;
+ this.mEvent = event;
+ }
+
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+ WXSDKInstance instance = context.getInstance();
+ WXDomObject domObject = context.getDomByRef(mRef);
+ if (domObject == null) {
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_REMOVEEVENT);
+ }
+ return;
+ }
+ domObject.removeEvent(mEvent);
+ mUpdatedDomObject = domObject;
+ context.postRenderTask(this);
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent comp = context.getComponent(mRef);
+ if(comp != null){
+ //sync dom change to component
+ comp.updateDom(mUpdatedDomObject);
+ comp.removeEvent(mEvent);
+ }
+ }
+}
[7/9] incubator-weex git commit: * [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,
DomModule#getComponentSize. It's low risk since it's a internal method,
users should not dirct use it.
Posted by so...@apache.org.
* [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,DomModule#getComponentSize. It's low risk since it's a internal method, users should not dirct use it.
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/f3390e3c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/f3390e3c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/f3390e3c
Branch: refs/heads/0.12-dev
Commit: f3390e3c0a8b9f013ac9e306a361b1d9a875777a
Parents: de623be
Author: sospartan <so...@gmail.com>
Authored: Thu Feb 23 16:31:50 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Wed Mar 15 15:44:00 2017 +0800
----------------------------------------------------------------------
CHANGELOG.md | 4 +
.../main/java/com/taobao/weex/WXSDKManager.java | 10 +
.../com/taobao/weex/bridge/WXBridgeManager.java | 3 +-
.../com/taobao/weex/dom/ApplyStyleConsumer.java | 245 ++++
.../java/com/taobao/weex/dom/DOMAction.java | 214 +++
.../com/taobao/weex/dom/DOMActionContext.java | 255 ++++
.../taobao/weex/dom/DOMActionContextImpl.java | 676 ++++++++++
.../java/com/taobao/weex/dom/RenderAction.java | 213 +++
.../taobao/weex/dom/RenderActionContext.java | 218 +++
.../java/com/taobao/weex/dom/RenderTask.java | 227 ++++
.../java/com/taobao/weex/dom/WXDomHandler.java | 73 +-
.../java/com/taobao/weex/dom/WXDomManager.java | 284 +---
.../java/com/taobao/weex/dom/WXDomModule.java | 431 +-----
.../java/com/taobao/weex/dom/WXDomObject.java | 4 +-
.../com/taobao/weex/dom/WXDomStatement.java | 1272 ------------------
.../dom/action/AbstractAddElementAction.java | 313 +++++
.../dom/action/AbstractLayoutFinishAction.java | 240 ++++
.../com/taobao/weex/dom/action/Actions.java | 314 +++++
.../weex/dom/action/AddElementAction.java | 295 ++++
.../taobao/weex/dom/action/AddEventAction.java | 262 ++++
.../taobao/weex/dom/action/AddRuleAction.java | 254 ++++
.../weex/dom/action/CreateBodyAction.java | 302 +++++
.../weex/dom/action/CreateFinishAction.java | 224 +++
.../weex/dom/action/GetComponentRectAction.java | 314 +++++
.../weex/dom/action/InvokeMethodAction.java | 236 ++++
.../weex/dom/action/MoveElementAction.java | 281 ++++
.../weex/dom/action/RefreshFinishAction.java | 221 +++
.../weex/dom/action/RemoveElementAction.java | 286 ++++
.../weex/dom/action/RemoveEventAction.java | 264 ++++
.../weex/dom/action/ScrollToElementAction.java | 257 ++++
.../weex/dom/action/UpdateAttributeAction.java | 263 ++++
.../weex/dom/action/UpdateFinishAction.java | 237 ++++
.../weex/dom/action/UpdateStyleAction.java | 298 ++++
.../taobao/weex/ui/RenderActionContextImpl.java | 303 +++++
.../com/taobao/weex/ui/WXRenderManager.java | 170 +--
.../com/taobao/weex/ui/WXRenderStatement.java | 556 --------
.../weex/ui/animation/WXAnimationModule.java | 2 +-
.../taobao/weex/ui/component/WXComponent.java | 12 +-
.../java/com/taobao/weex/WXSDKManagerTest.java | 2 +-
.../com/taobao/weex/dom/WXDomStatementTest.java | 110 +-
.../com/taobao/weex/dom/action/TestActions.java | 59 +
.../taobao/weex/ui/WXRenderStatementTest.java | 4 +-
test/pages/dom-operation.we | 5 +-
test/scripts/dom.test.js | 9 +
44 files changed, 7486 insertions(+), 2736 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..e44157a
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,4 @@
+## [Unreleased]
+
+### Changed
+- [android]Move DOM and render to seperate Action Object
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java
index 7f9f6dc..461faf0 100755
--- a/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKManager.java
@@ -196,6 +196,16 @@ public class WXSDKManager {
mBridgeManager = WXBridgeManager.getInstance();
}
+ private WXSDKManager(WXRenderManager renderManager) {
+ mWXRenderManager = renderManager;
+ mWXDomManager = new WXDomManager(renderManager);
+ mBridgeManager = WXBridgeManager.getInstance();
+ }
+
+ static void initInstance(WXRenderManager renderManager){
+ sManager = new WXSDKManager(renderManager);
+ }
+
public static WXSDKManager getInstance() {
if (sManager == null) {
synchronized (WXSDKManager.class) {
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
index de296ff..1db3a3b 100755
--- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java
@@ -234,6 +234,7 @@ import com.taobao.weex.common.WXRefreshData;
import com.taobao.weex.common.WXRuntimeException;
import com.taobao.weex.common.WXThread;
import com.taobao.weex.dom.WXDomModule;
+import com.taobao.weex.dom.action.Actions;
import com.taobao.weex.utils.WXFileUtils;
import com.taobao.weex.utils.WXJsonUtils;
import com.taobao.weex.utils.WXLogUtils;
@@ -638,7 +639,7 @@ public class WXBridgeManager implements Callback,BactchExecutor {
WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start);
}
WXDomModule domModule = getDomModule(instanceId);
- domModule.addElement(ref, domObject, Integer.parseInt(index));
+ domModule.postAction(Actions.getAddElement(domObject, ref,Integer.parseInt(index)),false);
}
if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) {
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/ApplyStyleConsumer.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/ApplyStyleConsumer.java b/android/sdk/src/main/java/com/taobao/weex/dom/ApplyStyleConsumer.java
new file mode 100644
index 0000000..6d3f15e
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/ApplyStyleConsumer.java
@@ -0,0 +1,245 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+import java.util.Map;
+
+/**
+ * Created by sospartan on 22/02/2017.
+ */
+class ApplyStyleConsumer implements WXDomObject.Consumer {
+ static ApplyStyleConsumer sInstance;
+
+ public static ApplyStyleConsumer getInstance() {
+ if (sInstance == null) {
+ sInstance = new ApplyStyleConsumer();
+ }
+ return sInstance;
+ }
+
+ private ApplyStyleConsumer() {
+ }
+
+ ;
+
+ @Override
+ public void accept(WXDomObject dom) {
+ WXStyle style = dom.getStyles();
+
+ /** merge default styles **/
+ Map<String, String> defaults = dom.getDefaultStyle();
+ if (defaults != null) {
+ for (Map.Entry<String, String> entry : defaults.entrySet()) {
+ if (!style.containsKey(entry.getKey())) {
+ style.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ if (dom.getStyles().size() > 0) {
+ dom.applyStyleToNode();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/DOMAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/DOMAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/DOMAction.java
new file mode 100644
index 0000000..b51b9b8
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/DOMAction.java
@@ -0,0 +1,214 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+
+/**
+ * Created by sospartan on 23/02/2017.
+ */
+
+public interface DOMAction {
+ void executeDom(DOMActionContext context);
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContext.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContext.java b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContext.java
new file mode 100644
index 0000000..f23c681
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContext.java
@@ -0,0 +1,255 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.ui.component.WXComponent;
+
+import java.util.Map;
+
+/**
+ * DOM operation context, use as compatible helper temporary.
+ * Created by sospartan on 14/02/2017.
+ */
+
+public interface DOMActionContext {
+ String getInstanceId();
+
+ /**
+ * For compatible, remove soon.
+ **/
+ WXDomObject.Consumer getAddDOMConsumer();
+
+ WXDomObject.Consumer getApplyStyleConsumer();
+
+ @Deprecated
+ void addDomInfo(String ref, WXComponent component);
+
+ void addAnimationForElement(String ref, Map<String, Object> animMap);
+
+ /**
+ * Post a Render task
+ *
+ * @param statement
+ */
+ void postRenderTask(RenderAction statement);
+
+ void registerDOMObject(String ref, WXDomObject ojb);
+
+ void unregisterDOMObject(String ref);
+
+ void registerComponent(String ref, WXComponent comp);
+
+ WXComponent getCompByRef(String ref);
+
+ boolean isDestory();
+
+ WXSDKInstance getInstance();
+
+ WXDomObject getDomByRef(String ref);
+
+ @Deprecated
+ WXDomObject.Consumer getRemoveElementConsumer();
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
new file mode 100755
index 0000000..ee86493
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
@@ -0,0 +1,676 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.text.TextUtils;
+import android.util.Pair;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXEnvironment;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.WXSDKManager;
+import com.taobao.weex.dom.flex.CSSLayoutContext;
+import com.taobao.weex.ui.IWXRenderTask;
+import com.taobao.weex.ui.WXRenderManager;
+import com.taobao.weex.ui.animation.WXAnimationBean;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.ui.component.WXVContainer;
+import com.taobao.weex.utils.WXLogUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * <p>
+ * This class is responsible for creating command object of DOM operation and
+ * invoking command of corresponding object.
+ * </p>
+ * <p>
+ * In the command design pattern,
+ * this class acts as the <strong>invoker </strong>in the command pattern
+ * despite that it is also responsible for creating <strong>Command</strong> object.
+ * And,{@link IWXRenderTask} works as the <strong>Command</strong>
+ * {@link WXDomManager} works as the <strong>Client</strong>
+ * {@link WXRenderManager} works as the <strong>Receiver</strong>.
+ * </p>
+ * <p>
+ * There exists one to one correspondence between DOMActionContextImpl and WXInstance,
+ * and {@link WXDomManager} is responsible for manage the relation of correspondence.
+ * </p>
+ */
+class DOMActionContextImpl implements DOMActionContext {
+ /** package **/ final ConcurrentHashMap<String, WXDomObject> mRegistry;
+ private WXDomObject.Consumer mAddDOMConsumer;
+ private WXDomObject.Consumer mUnregisterDomConsumer;
+ private String mInstanceId;
+ private WXRenderManager mWXRenderManager;
+ private ArrayList<IWXRenderTask> mNormalTasks;
+ private Set <Pair<String, Map<String, Object>>> animations;
+ private CSSLayoutContext mLayoutContext;
+ private volatile boolean mDirty;
+ private boolean mDestroy;
+ private Map<String, AddDomInfo> mAddDom = new HashMap<>();
+
+ /**
+ * Create an instance of {@link DOMActionContextImpl},
+ * One {@link WXSDKInstance} corresponding to one and only one {@link DOMActionContextImpl}.
+ * And all the instance of {@link WXDomManager} share the same {@link WXRenderManager}.
+ * @param instanceId the id of the {@link WXSDKInstance}.
+ * One {@link WXSDKInstance} corresponding to one {@link DOMActionContextImpl},
+ * and vice versa.
+ * @param renderManager This acts as the Receiver of the command pattern
+ */
+ public DOMActionContextImpl(String instanceId, WXRenderManager renderManager) {
+ mDestroy = false;
+ mInstanceId = instanceId;
+ mLayoutContext = new CSSLayoutContext();
+ mRegistry = new ConcurrentHashMap<>();
+ mNormalTasks = new ArrayList<>();
+ animations = new LinkedHashSet<>();
+ mWXRenderManager = renderManager;
+ mAddDOMConsumer = new AddDOMConsumer(mRegistry);
+ mUnregisterDomConsumer = new RemoveElementConsumer(mRegistry);
+ }
+
+ @Override
+ public String getInstanceId() {
+ return mInstanceId;
+ }
+
+ @Override
+ public WXDomObject.Consumer getAddDOMConsumer(){
+ return mAddDOMConsumer;
+ }
+
+ @Override
+ public WXDomObject.Consumer getRemoveElementConsumer() {
+ return mUnregisterDomConsumer;
+ }
+
+ @Override
+ public WXDomObject.Consumer getApplyStyleConsumer() {
+ return ApplyStyleConsumer.getInstance();
+ }
+
+ @Override
+ public void addDomInfo(String ref, WXComponent component) {
+ AddDomInfo addDomInfo = new AddDomInfo();
+ addDomInfo.component = component;
+ mAddDom.put(ref, addDomInfo);
+ }
+
+ /**
+ * Destroy current instance, which occurred when {@link WXSDKInstance#destroy()} is called.
+ */
+ public void destroy() {
+ mDestroy = true;
+ mRegistry.clear();
+ mAddDOMConsumer = null;
+ mNormalTasks.clear();
+ mAddDom.clear();
+ mLayoutContext = null;
+ mWXRenderManager = null;
+ animations.clear();
+ }
+
+ /**
+ * Rebuild the component tree.
+ * The purpose of this method is moving fixed components to the root component.
+ * This method will be called when {@link #batch()} is executed.
+ * @param root root dom
+ */
+ void rebuildingFixedDomTree(WXDomObject root) {
+ if (root != null && root.getFixedStyleRefs() != null) {
+ int size = root.getFixedStyleRefs().size();
+ for (int i = 0; i < size; i++) {
+ String fixedRef = root.getFixedStyleRefs().get(i);
+ WXDomObject wxDomObject = mRegistry.get(fixedRef);
+ if (wxDomObject!=null && wxDomObject.parent != null) {
+ wxDomObject.parent.remove(wxDomObject);
+ root.add(wxDomObject, -1);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Batch the execution of command objects and execute all the command objects created other
+ * places, e.g. call {@link IWXRenderTask#execute()}.
+ * First, it will rebuild the dom tree and do pre layout staff.
+ * Then call {@link com.taobao.weex.dom.flex.CSSNode#calculateLayout(CSSLayoutContext)} to
+ * start calculate layout.
+ * Next, call {@link ApplyUpdateConsumer} to get changed dom and creating
+ * corresponding command object.
+ * Finally, walk through the queue, e.g. call {@link IWXRenderTask#execute()} for every task
+ * in the queue.
+ */
+ void batch() {
+
+ if (!mDirty || mDestroy) {
+ return;
+ }
+
+ WXDomObject rootDom = mRegistry.get(WXDomObject.ROOT);
+ layout(rootDom);
+ }
+
+ void layout(WXDomObject rootDom) {
+ if (rootDom == null) {
+ return;
+ }
+ long start0 = System.currentTimeMillis();
+
+ rebuildingFixedDomTree(rootDom);
+
+ rootDom.traverseTree( new WXDomObject.Consumer() {
+ @Override
+ public void accept(WXDomObject dom) {
+ if (!dom.hasUpdate() || mDestroy) {
+ return;
+ }
+ dom.layoutBefore();
+ }
+ });
+ long start = System.currentTimeMillis();
+
+
+ rootDom.calculateLayout(mLayoutContext);
+
+ WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(mInstanceId);
+ if (instance != null) {
+ instance.cssLayoutTime(System.currentTimeMillis() - start);
+ }
+
+ rootDom.traverseTree( new WXDomObject.Consumer() {
+ @Override
+ public void accept(WXDomObject dom) {
+ if (!dom.hasUpdate() || mDestroy) {
+ return;
+ }
+ dom.layoutAfter();
+ }
+ });
+
+ start = System.currentTimeMillis();
+ rootDom.traverseTree(new ApplyUpdateConsumer());
+
+ if (instance != null) {
+ instance.applyUpdateTime(System.currentTimeMillis() - start);
+ }
+
+ start = System.currentTimeMillis();
+ updateDomObj();
+ if (instance != null) {
+ instance.updateDomObjTime(System.currentTimeMillis() - start);
+ }
+ parseAnimation();
+
+ int count = mNormalTasks.size();
+ for (int i = 0; i < count && !mDestroy; ++i) {
+ mWXRenderManager.runOnThread(mInstanceId, mNormalTasks.get(i));
+ }
+ mNormalTasks.clear();
+ mAddDom.clear();
+ animations.clear();
+ mDirty = false;
+ if (instance != null) {
+ instance.batchTime(System.currentTimeMillis() - start0);
+ }
+ }
+
+ private class ApplyUpdateConsumer implements WXDomObject.Consumer{
+
+ @Override
+ public void accept(WXDomObject dom) {
+ if (dom.hasUpdate()) {
+ dom.markUpdateSeen();
+ if (!dom.isYoung()) {
+ final WXDomObject copy = dom.clone();
+ if (copy == null) {
+ return;
+ }
+ mNormalTasks.add(new IWXRenderTask() {
+
+ @Override
+ public void execute() {
+ mWXRenderManager.setLayout(mInstanceId, copy.getRef(), copy);
+ if(copy.getExtra() != null) {
+ mWXRenderManager.setExtra(mInstanceId, copy.getRef(), copy.getExtra());
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "setLayout & setExtra";
+ }
+ });
+ }
+ }
+ }
+ }
+
+ private void parseAnimation() {
+ for(final Pair<String, Map<String, Object>> pair:animations) {
+ if (!TextUtils.isEmpty(pair.first)) {
+ final WXAnimationBean animationBean = createAnimationBean(pair.first, pair.second);
+ if (animationBean != null) {
+ mNormalTasks.add(new IWXRenderTask() {
+ @Override
+ public void execute() {
+ mWXRenderManager.startAnimation(mInstanceId, pair.first, animationBean, null);
+ }
+
+ @Override
+ public String toString() {
+ return "startAnimationByStyle";
+ }
+ });
+ }
+ }
+ }
+ }
+
+ /**
+ * Update all components' dom info stored in {@link #mAddDom}
+ */
+ private void updateDomObj() {
+ long start = System.currentTimeMillis();
+ Iterator<Map.Entry<String, AddDomInfo>> iterator = mAddDom.entrySet().iterator();
+ Map.Entry<String, AddDomInfo> entry;
+ AddDomInfo value;
+ while (iterator.hasNext()) {
+ entry = iterator.next();
+ value = entry.getValue();
+ updateDomObj(value.component);
+ }
+ if (WXEnvironment.isApkDebugable()) {
+ WXLogUtils.d("updateDomObj", "time:" + (System.currentTimeMillis() - start));
+ }
+ }
+
+ /**
+ * Update the specified component's dom and mark it as old.
+ * @param component the component to be updated
+ */
+ private void updateDomObj(WXComponent component) {
+ if (component == null) {
+ return;
+ }
+ WXDomObject domObject = mRegistry.get(component.getRef());
+ if (domObject == null) {
+ return;
+ }
+ domObject.old();
+ component.updateDom(domObject);
+ if (component instanceof WXVContainer) {
+ WXVContainer container = (WXVContainer) component;
+ int count = container.childCount();
+ for (int i = 0; i < count; ++i) {
+ updateDomObj(container.getChild(i));
+ }
+ }
+ }
+
+ void startAnimation(@NonNull final String ref, @NonNull String animation,
+ @Nullable final String callBack){
+ if (mDestroy) {
+ return;
+ }
+ WXDomObject domObject = mRegistry.get(ref);
+ if (domObject == null) {
+ return;
+ }
+ final WXAnimationBean animationBean=createAnimationBean(ref, animation);
+ if(animationBean!=null) {
+ mNormalTasks.add(new IWXRenderTask() {
+ @Override
+ public void execute() {
+ mWXRenderManager.startAnimation(mInstanceId, ref, animationBean, callBack);
+ }
+
+ @Override
+ public String toString() {
+ return "startAnimationByCall";
+ }
+ });
+ mDirty=true;
+ }
+ }
+
+ @Override
+ public void addAnimationForElement(String ref, Map<String, Object> animMap) {
+ animations.add(new Pair<>(ref,animMap));
+ mDirty = true;
+ }
+
+ @Override
+ public void postRenderTask(RenderAction statement) {
+ mNormalTasks.add(new RenderTask(statement, mWXRenderManager.getWXRenderStatement(mInstanceId)));
+ mDirty = true;
+ }
+
+ @Override
+ public void registerDOMObject(String ref, WXDomObject obj) {
+ mRegistry.put(ref,obj);
+ }
+
+ @Override
+ public void unregisterDOMObject(String ref) {
+ mRegistry.remove(ref);
+ }
+
+ @Override
+ public void registerComponent(String ref, WXComponent comp) {
+ mWXRenderManager.registerComponent(mInstanceId,ref,comp);
+ }
+
+ @Override
+ public WXComponent getCompByRef(String ref) {
+ return mWXRenderManager.getWXComponent(mInstanceId,ref);
+ }
+
+ @Override
+ public boolean isDestory() {
+ return false;
+ }
+
+ @Override
+ public WXSDKInstance getInstance() {
+ return mWXRenderManager.getWXSDKInstance(mInstanceId);
+ }
+
+ @Override
+ public WXDomObject getDomByRef(String ref) {
+ return mRegistry.get(ref);
+ }
+
+ private WXAnimationBean createAnimationBean(String ref, String animation){
+ try {
+ WXAnimationBean animationBean =
+ JSONObject.parseObject(animation, WXAnimationBean.class);
+ if (animationBean != null && animationBean.styles != null) {
+ WXDomObject domObject=mRegistry.get(ref);
+ int width=(int)domObject.getLayoutWidth();
+ int height=(int)domObject.getLayoutHeight();
+ animationBean.styles.init(animationBean.styles.transformOrigin,
+ animationBean.styles.transform,width,height,WXSDKManager.getInstance().getSDKInstance(mInstanceId).getInstanceViewPortWidth());
+ }
+ return animationBean;
+ } catch (RuntimeException e) {
+ WXLogUtils.e("", e);
+ return null;
+ }
+ }
+
+ private WXAnimationBean createAnimationBean(String ref,Map<String, Object> style){
+ if (style != null) {
+ try {
+ Object transform = style.get(WXDomObject.TRANSFORM);
+ if (transform instanceof String && !TextUtils.isEmpty((String) transform)) {
+ String transformOrigin = (String) style.get(WXDomObject.TRANSFORM_ORIGIN);
+ WXAnimationBean animationBean = new WXAnimationBean();
+ WXDomObject domObject = mRegistry.get(ref);
+ int width = (int) domObject.getLayoutWidth();
+ int height = (int) domObject.getLayoutHeight();
+ animationBean.styles = new WXAnimationBean.Style();
+ animationBean.styles.init(transformOrigin, (String) transform, width, height,WXSDKManager.getInstance().getSDKInstance(mInstanceId).getInstanceViewPortWidth());
+ return animationBean;
+ }
+ }catch (RuntimeException e){
+ WXLogUtils.e("", e);
+ return null;
+ }
+ }
+ return null;
+ }
+
+ private static class RemoveElementConsumer implements WXDomObject.Consumer {
+ final ConcurrentHashMap<String, WXDomObject> mRegistry;
+
+ RemoveElementConsumer(ConcurrentHashMap<String, WXDomObject> r) {
+ mRegistry = r;
+ }
+
+
+ @Override
+ public void accept(WXDomObject dom) {
+ mRegistry.remove(dom.getRef());
+ }
+ }
+
+
+ private static class AddDOMConsumer implements WXDomObject.Consumer {
+ final ConcurrentHashMap<String, WXDomObject> mRegistry;
+ AddDOMConsumer(ConcurrentHashMap<String, WXDomObject> r){
+ mRegistry = r;
+ }
+
+ @Override
+ public void accept(WXDomObject dom) {
+ //register dom
+ dom.young();
+ mRegistry.put(dom.getRef(), dom);
+
+ //find fixed node
+ WXDomObject rootDom = mRegistry.get(WXDomObject.ROOT);
+ if (rootDom != null && dom.isFixed()) {
+ rootDom.add2FixedDomList(dom.getRef());
+ }
+ }
+ }
+
+ static class AddDomInfo {
+
+ public WXComponent component;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/RenderAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/RenderAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/RenderAction.java
new file mode 100644
index 0000000..2d3a9e0
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/RenderAction.java
@@ -0,0 +1,213 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+/**
+ * Created by sospartan on 23/02/2017.
+ */
+
+public interface RenderAction {
+ void executeRender(RenderActionContext context);
+}
[9/9] incubator-weex git commit: Merge branch 'new-stmt' of
github.com:sospartan/incubator-weex into 0.12-dev This closes #104
Posted by so...@apache.org.
Merge branch 'new-stmt' of github.com:sospartan/incubator-weex into 0.12-dev
This closes #104
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a67604ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a67604ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a67604ce
Branch: refs/heads/0.12-dev
Commit: a67604ced9a9a407a2e87586bcd1fc42e725cc3e
Parents: c634981 20f6c37
Author: sospartan <so...@apache.org>
Authored: Wed Mar 15 16:04:54 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Wed Mar 15 16:04:54 2017 +0800
----------------------------------------------------------------------
CHANGELOG.md | 4 +
.../main/java/com/taobao/weex/WXSDKManager.java | 10 +
.../com/taobao/weex/bridge/WXBridgeManager.java | 3 +-
.../com/taobao/weex/dom/ApplyStyleConsumer.java | 245 ++++
.../java/com/taobao/weex/dom/DOMAction.java | 214 +++
.../com/taobao/weex/dom/DOMActionContext.java | 255 ++++
.../taobao/weex/dom/DOMActionContextImpl.java | 676 ++++++++++
.../java/com/taobao/weex/dom/RenderAction.java | 213 +++
.../taobao/weex/dom/RenderActionContext.java | 218 +++
.../com/taobao/weex/dom/RenderActionTask.java | 227 ++++
.../java/com/taobao/weex/dom/WXDomHandler.java | 73 +-
.../java/com/taobao/weex/dom/WXDomManager.java | 284 +---
.../java/com/taobao/weex/dom/WXDomModule.java | 431 +-----
.../java/com/taobao/weex/dom/WXDomObject.java | 4 +-
.../com/taobao/weex/dom/WXDomStatement.java | 1272 ------------------
.../dom/action/AbstractAddElementAction.java | 313 +++++
.../dom/action/AbstractLayoutFinishAction.java | 240 ++++
.../com/taobao/weex/dom/action/Actions.java | 314 +++++
.../weex/dom/action/AddElementAction.java | 295 ++++
.../taobao/weex/dom/action/AddEventAction.java | 262 ++++
.../taobao/weex/dom/action/AddRuleAction.java | 254 ++++
.../weex/dom/action/CreateBodyAction.java | 302 +++++
.../weex/dom/action/CreateFinishAction.java | 224 +++
.../weex/dom/action/GetComponentRectAction.java | 314 +++++
.../weex/dom/action/InvokeMethodAction.java | 236 ++++
.../weex/dom/action/MoveElementAction.java | 281 ++++
.../weex/dom/action/RefreshFinishAction.java | 221 +++
.../weex/dom/action/RemoveElementAction.java | 286 ++++
.../weex/dom/action/RemoveEventAction.java | 264 ++++
.../weex/dom/action/ScrollToElementAction.java | 257 ++++
.../weex/dom/action/UpdateAttributeAction.java | 263 ++++
.../weex/dom/action/UpdateFinishAction.java | 237 ++++
.../weex/dom/action/UpdateStyleAction.java | 298 ++++
.../taobao/weex/ui/RenderActionContextImpl.java | 303 +++++
.../com/taobao/weex/ui/WXRenderManager.java | 170 +--
.../com/taobao/weex/ui/WXRenderStatement.java | 556 --------
.../weex/ui/animation/WXAnimationModule.java | 2 +-
.../taobao/weex/ui/component/WXComponent.java | 12 +-
.../java/com/taobao/weex/WXSDKManagerTest.java | 2 +-
.../com/taobao/weex/dom/WXDomStatementTest.java | 110 +-
.../com/taobao/weex/dom/action/TestActions.java | 59 +
.../taobao/weex/ui/WXRenderStatementTest.java | 4 +-
test/pages/dom-operation.we | 5 +-
test/scripts/dom.test.js | 9 +
44 files changed, 7486 insertions(+), 2736 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a67604ce/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
[6/9] incubator-weex git commit: * [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,
DomModule#getComponentSize. It's low risk since it's a internal method,
users should not dirct use it.
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionContext.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionContext.java b/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionContext.java
new file mode 100644
index 0000000..8821ef6
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionContext.java
@@ -0,0 +1,218 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.ui.component.WXComponent;
+
+/**
+ * Created by sospartan on 23/02/2017.
+ */
+
+public interface RenderActionContext {
+ WXSDKInstance getInstance();
+ WXComponent getComponent(String ref);
+ WXComponent unregisterComponent(String ref);
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java b/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java
new file mode 100644
index 0000000..a841ede
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/RenderTask.java
@@ -0,0 +1,227 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom;
+
+import com.taobao.weex.ui.IWXRenderTask;
+
+/**
+ * Created by sospartan on 23/02/2017.
+ */
+
+class RenderTask implements IWXRenderTask {
+ private final RenderAction mRenderTask;
+ private final RenderActionContext mContext;
+
+ public RenderTask(RenderAction action, RenderActionContext context){
+ mRenderTask = action;
+ mContext = context;
+ }
+
+
+ @Override
+ public void execute() {
+ mRenderTask.executeRender(mContext);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/WXDomHandler.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomHandler.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomHandler.java
index 2526a97..5c3a595 100755
--- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomHandler.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomHandler.java
@@ -210,6 +210,7 @@ import android.os.Message;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.bridge.JSCallback;
+import com.taobao.weex.dom.action.Actions;
/**
* Handler for dom operations.
@@ -245,43 +246,14 @@ public class WXDomHandler implements Handler.Callback {
mWXDomManager.sendEmptyMessageDelayed(WXDomHandler.MsgType.WX_DOM_BATCH, DELAY_TIME);
}
switch (what) {
- case MsgType.WX_DOM_CREATE_BODY:
- mWXDomManager.createBody(task.instanceId, (JSONObject) task.args.get(0));
- break;
- case MsgType.WX_DOM_UPDATE_ATTRS:
- mWXDomManager.updateAttrs(task.instanceId, (String) task.args.get(0), (JSONObject) task.args.get(1));
+ case MsgType.WX_EXECUTE_ACTION:
+ mWXDomManager.executeAction(task.instanceId, (DOMAction) task.args.get(0), (boolean) task.args.get(1));
break;
case MsgType.WX_DOM_UPDATE_STYLE:
- mWXDomManager.updateStyle(
- task.instanceId,
- (String) task.args.get(0),
+ //keep this for direct native call
+ mWXDomManager.executeAction(task.instanceId, Actions.getUpdateStyle((String) task.args.get(0),
(JSONObject) task.args.get(1),
- task.args.size() > 2 && (boolean) task.args.get(2)
- );
- break;
- case MsgType.WX_DOM_ADD_DOM:
- mWXDomManager.addDom(task.instanceId, (String) task.args.get(0), (JSONObject) task.args.get(1), (Integer) task.args.get(2));
- break;
- case MsgType.WX_DOM_REMOVE_DOM:
- mWXDomManager.removeDom(task.instanceId, (String) task.args.get(0));
- break;
- case MsgType.WX_DOM_MOVE_DOM:
- mWXDomManager.moveDom(task.instanceId, (String) task.args.get(0), (String) task.args.get(1), (Integer) task.args.get(2));
- break;
- case MsgType.WX_DOM_ADD_EVENT:
- mWXDomManager.addEvent(task.instanceId, (String) task.args.get(0), (String) task.args.get(1));
- break;
- case MsgType.WX_DOM_REMOVE_EVENT:
- mWXDomManager.removeEvent(task.instanceId, (String) task.args.get(0), (String) task.args.get(1));
- break;
- case MsgType.WX_DOM_CREATE_FINISH:
- mWXDomManager.createFinish(task.instanceId);
- break;
- case MsgType.WX_DOM_REFRESH_FINISH:
- mWXDomManager.refreshFinish(task.instanceId);
- break;
- case MsgType.WX_DOM_UPDATE_FINISH:
- mWXDomManager.updateFinish(task.instanceId);
+ task.args.size() > 2 && (boolean) task.args.get(2)),false);
break;
case MsgType.WX_ANIMATION:
mWXDomManager.startAnimation(task.instanceId,
@@ -294,22 +266,6 @@ public class WXDomHandler implements Handler.Callback {
mWXDomManager.batch();
mHasBatch = false;
break;
- case MsgType.WX_DOM_SCROLLTO:
- mWXDomManager.scrollToDom(task.instanceId, (String) task.args.get(0), (JSONObject) task.args.get(1));
- break;
- case MsgType.WX_DOM_ADD_RULE:
- mWXDomManager.addRule(task.instanceId,(String) task.args.get(0), (JSONObject) task.args.get(1));
- break;
- case MsgType.WX_COMPONENT_SIZE:
- mWXDomManager.getComponentSize(task.instanceId, (String) task.args.get(0), (JSCallback) task.args.get(1));
- break;
- case MsgType.WX_DOM_INVOKE:
- mWXDomManager.invokeMethod(
- task.instanceId,
- (String)task.args.get(0),
- (String)task.args.get(1),
- (JSONArray)task.args.get(2));
- break;
default:
break;
}
@@ -319,24 +275,41 @@ public class WXDomHandler implements Handler.Callback {
public static class MsgType {
+ @Deprecated
public static final int WX_DOM_CREATE_BODY = 0x0;
+ @Deprecated
public static final int WX_DOM_UPDATE_ATTRS = 0x01;
+ @Deprecated
public static final int WX_DOM_UPDATE_STYLE = 0x02;
+ @Deprecated
public static final int WX_DOM_ADD_DOM = 0x03;
+ @Deprecated
public static final int WX_DOM_REMOVE_DOM = 0x04;
+ @Deprecated
public static final int WX_DOM_MOVE_DOM = 0x05;
+ @Deprecated
public static final int WX_DOM_ADD_EVENT = 0x06;
+ @Deprecated
public static final int WX_DOM_REMOVE_EVENT = 0x07;
+ @Deprecated
public static final int WX_DOM_SCROLLTO = 0x08;
+ @Deprecated
public static final int WX_DOM_CREATE_FINISH = 0x09;
+ @Deprecated
public static final int WX_DOM_REFRESH_FINISH = 0x0a;
+ @Deprecated
public static final int WX_DOM_UPDATE_FINISH = 0x0b;
public static final int WX_ANIMATION=0xc;
+ @Deprecated
public static final int WX_DOM_ADD_RULE=0xd;
+ @Deprecated
public static final int WX_DOM_INVOKE=0xe;
+ public static final int WX_EXECUTE_ACTION = 0xfe;
public static final int WX_DOM_BATCH = 0xff;
+ @Deprecated
public static final int WX_COMPONENT_SIZE= 0xff1;
+
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/WXDomManager.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomManager.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomManager.java
index d7ebaa7..6bb5dbb 100755
--- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomManager.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomManager.java
@@ -208,31 +208,22 @@ import android.os.Handler;
import android.os.Message;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.text.TextUtils;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.WXEnvironment;
-import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
-import com.taobao.weex.bridge.JSCallback;
-import com.taobao.weex.common.Constants;
import com.taobao.weex.common.WXRuntimeException;
import com.taobao.weex.common.WXThread;
import com.taobao.weex.ui.WXRenderManager;
-import com.taobao.weex.utils.FontDO;
-import com.taobao.weex.utils.TypefaceUtil;
import com.taobao.weex.utils.WXUtils;
-import java.util.HashMap;
+import java.util.ArrayList;
import java.util.Iterator;
-import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
/**
* Class for managing dom operation. This class works as the client in the command pattern, it
- * will call {@link WXDomStatement} for creating command object and invoking corresponding
+ * will call {@link DOMActionContextImpl} for creating command object and invoking corresponding
* operation.
* Methods in this class normally need to be invoked in dom thread, otherwise, {@link
* WXRuntimeException} may be thrown.
@@ -243,7 +234,7 @@ public final class WXDomManager {
/** package **/
Handler mDomHandler;
private WXRenderManager mWXRenderManager;
- private ConcurrentHashMap<String, WXDomStatement> mDomRegistries;
+ private ConcurrentHashMap<String, DOMActionContextImpl> mDomRegistries;
public WXDomManager(WXRenderManager renderManager) {
mWXRenderManager = renderManager;
@@ -281,7 +272,7 @@ public final class WXDomManager {
if (!WXUtils.isUiThread()) {
throw new WXRuntimeException("[WXDomManager] removeDomStatement");
}
- final WXDomStatement statement = mDomRegistries.remove(instanceId);
+ final DOMActionContextImpl statement = mDomRegistries.remove(instanceId);
if (statement != null) {
post(new Runnable() {
@@ -315,228 +306,27 @@ public final class WXDomManager {
mDomThread = null;
}
- /**
- * Invoke {@link WXDomStatement} for creating body according to the JSONObject.
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param element the jsonObject according to which to create command object.
- */
- void createBody(String instanceId, JSONObject element) {
- throwIfNotDomThread();
- WXDomStatement statement = new WXDomStatement(instanceId, mWXRenderManager);
- mDomRegistries.put(instanceId, statement);
- statement.createBody(element);
- }
-
private boolean isDomThread() {
return !WXEnvironment.isApkDebugable() || Thread.currentThread().getId() == mDomThread.getId();
}
/**
- * Batch the execution of {@link WXDomStatement}
+ * Batch the execution of {@link DOMActionContextImpl}
*/
void batch() {
throwIfNotDomThread();
- Iterator<Entry<String, WXDomStatement>> iterator = mDomRegistries.entrySet().iterator();
+ Iterator<Entry<String, DOMActionContextImpl>> iterator = mDomRegistries.entrySet().iterator();
while (iterator.hasNext()) {
iterator.next().getValue().batch();
}
}
- /**
- * Invoke {@link WXDomStatement} for adding a dom node to its parent in a specific location.
- *
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param element the dom object in the form of JSONObject
- * @param parentRef parent to which the dom is added.
- * @param index the location of which the dom is added.
- */
- void addDom(String instanceId, String parentRef, JSONObject element, int index) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.addDom(element, parentRef, index);
- }
-
- void invokeMethod(String instanceId, String ref, String method, JSONArray args){
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.invokeMethod(ref,method,args);
- }
-
private void throwIfNotDomThread(){
if (!isDomThread()) {
throw new WXRuntimeException("dom operation must be done in dom thread");
}
}
- /**
- * Invoke {@link WXDomStatement} for removing the specified {@link WXDomObject}.
- *
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param ref of the dom.
- */
- //removeElement(ref:String)
- void removeDom(String instanceId, String ref) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.removeDom(ref);
- }
-
-
- /**
- * Invoke {@link WXDomStatement} for moving the specific {@link WXDomObject} to a new parent.
- *
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param ref of the dom to be moved.
- * @param parentRef of the new parent DOM node
- * @param index the index of the dom to be inserted in the new parent.
- */
- void moveDom(String instanceId, String ref, String parentRef, int index) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.moveDom(ref, parentRef, index);
- }
-
- /**
- * Invoke {@link WXDomStatement} for updating the attributes according to the
- * given attribute.
- *
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param ref of the dom.
- * @param attr the new attribute. This attribute is only a part of the full attribute, and will be
- * merged into attributes
- */
- void updateAttrs(String instanceId, String ref, JSONObject attr) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.updateAttrs(ref, attr);
- }
-
- /**
- * Invoke {@link WXDomStatement} for updating style
- *
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param ref the given dom object
- * @param style the given style.
- */
- void updateStyle(String instanceId, String ref, JSONObject style, boolean byPesudo) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.updateStyle(ref, style, byPesudo);
- }
-
- /**
- * Invoke {@link WXDomStatement} for adding a default event listener to the corresponding {@link
- * WXDomObject}.
- *
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param ref of the dom.
- * @param type the type of the event, this may be a plain event defined in
- * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
- * .weex.ui.view.gesture.WXGestureType}
- */
- void addEvent(String instanceId, String ref, String type) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.addEvent(ref, type);
- }
-
- /**
- * Invoke the {@link WXDomStatement} for removing the event listener of the corresponding {@link
- * WXDomObject}.
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance
- * @param ref of the dom.
- * @param type the type of the event, this may be a plain event defined in
- * {@link com.taobao.weex.common.Constants.Event} or a gesture defined in {@link com.taobao
- * .weex.ui.view.gesture.WXGestureType}
- */
- void removeEvent(String instanceId, String ref, String type) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.removeEvent(ref, type);
- }
-
- /**
- * Invoke the {@link WXDomStatement} for scrolling the given view to the specified position.
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance to
- * scroll.
- * @param ref of the dom.
- * @param options the specified position
- */
- void scrollToDom(String instanceId, String ref, JSONObject options) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.scrollToDom(ref, options);
- }
-
- /**
- * Notify the creating of whole dom tree has finished. This message is sent by JS.
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance to
- * notify.
- */
- void createFinish(String instanceId) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.createFinish();
- }
-
- /**
- * Notify the refreshing has finished.
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance to
- * notify.
- */
- void refreshFinish(String instanceId) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.refreshFinish();
- }
-
- /**
- * Notify the update has finished.
- * @param instanceId {@link com.taobao.weex.WXSDKInstance#mInstanceId} for the instance to
- * notify.
- */
- void updateFinish(String instanceId) {
- throwIfNotDomThread();
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.updateFinish();
- }
-
void startAnimation(@NonNull String instanceId,
@NonNull String ref,
@NonNull String animation,
@@ -544,56 +334,46 @@ public final class WXDomManager {
if (!isDomThread()) {
throw new WXRuntimeException("RefreshFinish operation must be done in dom thread");
}
- WXDomStatement statement = mDomRegistries.get(instanceId);
+ DOMActionContextImpl statement = mDomRegistries.get(instanceId);
if (statement == null) {
return;
}
statement.startAnimation(ref,animation,callBack);
}
- public void addRule(String instanceId,final String type,final JSONObject jsonObject) {
- if (Constants.Name.FONT_FACE.equals(type)) {
- FontDO fontDO = parseFontDO(jsonObject, mWXRenderManager.getWXSDKInstance(instanceId));
- if (fontDO != null && !TextUtils.isEmpty(fontDO.getFontFamilyName())) {
- FontDO cacheFontDO = TypefaceUtil.getFontDO(fontDO.getFontFamilyName());
- if (cacheFontDO == null || !TextUtils.equals(cacheFontDO.getUrl(), fontDO.getUrl())) {
- TypefaceUtil.putFontDO(fontDO);
- TypefaceUtil.loadTypeface(fontDO);
- } else {
- TypefaceUtil.loadTypeface(cacheFontDO);
- }
+ public void executeAction(String instanceId, DOMAction action, boolean createContext) {
+ DOMActionContext context = mDomRegistries.get(instanceId);
+ if(context == null){
+ if(createContext){
+ DOMActionContextImpl oldStatement = new DOMActionContextImpl(instanceId, mWXRenderManager);
+ mDomRegistries.put(instanceId, oldStatement);
+ context = oldStatement;
+ }else{
+ //Instance not existed.
+ return;
}
}
- }
-
- private FontDO parseFontDO(JSONObject jsonObject,WXSDKInstance instance) {
- if(jsonObject == null) {
- return null;
- }
- String src = jsonObject.getString(Constants.Name.SRC);
- String name = jsonObject.getString(Constants.Name.FONT_FAMILY);
+ action.executeDom(context);
- return new FontDO(name, src,instance);
}
+
/**
- * Gets the coordinate information of the control
- * @param instanceId wxsdkinstance id
- * @param ref ref
- * @param callback callback
+ * @param action
+ * @param createContext only true when create body
*/
- public void getComponentSize(String instanceId, String ref, JSCallback callback) {
- if (!isDomThread()) {
- throw new WXRuntimeException("getComponentSize operation must be done in dom thread");
- }
- WXDomStatement statement = mDomRegistries.get(instanceId);
- if (statement == null) {
- Map<String, Object> options = new HashMap<>();
- options.put("result", false);
- options.put("errMsg", "Component does not exist");
- callback.invoke(options);
+ public void postAction(String instanceId,DOMAction action, boolean createContext){
+ if(action == null){
return;
}
- statement.getComponentSize(ref, callback);
+ Message msg = Message.obtain();
+ msg.what = WXDomHandler.MsgType.WX_EXECUTE_ACTION;
+ WXDomTask task = new WXDomTask();
+ task.instanceId = instanceId;
+ task.args = new ArrayList<>();
+ task.args.add(action);
+ task.args.add(createContext);
+ msg.obj = task;
+ sendMessage(msg);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/WXDomModule.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomModule.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomModule.java
index 046366c..fcf6b40 100755
--- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomModule.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomModule.java
@@ -205,23 +205,18 @@
package com.taobao.weex.dom;
import android.os.Message;
-import android.support.annotation.NonNull;
-import android.text.TextUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
-import com.taobao.weex.bridge.SimpleJSCallback;
import com.taobao.weex.bridge.WXBridgeManager;
import com.taobao.weex.common.WXModule;
+import com.taobao.weex.dom.action.Actions;
import com.taobao.weex.utils.WXLogUtils;
-import com.taobao.weex.utils.WXViewUtils;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
/**
@@ -239,20 +234,20 @@ public final class WXDomModule extends WXModule {
/** package **/
// method
- static final String CREATE_BODY = "createBody";
- static final String UPDATE_ATTRS = "updateAttrs";
- static final String UPDATE_STYLE = "updateStyle";
- static final String REMOVE_ELEMENT = "removeElement";
- static final String ADD_ELEMENT = "addElement";
- static final String MOVE_ELEMENT = "moveElement";
- static final String ADD_EVENT = "addEvent";
- static final String REMOVE_EVENT = "removeEvent";
- static final String CREATE_FINISH = "createFinish";
- static final String REFRESH_FINISH = "refreshFinish";
- static final String UPDATE_FINISH = "updateFinish";
- static final String SCROLL_TO_ELEMENT = "scrollToElement";
- static final String ADD_RULE = "addRule";
- static final String GET_COMPONENT_RECT = "getComponentRect";
+ public static final String CREATE_BODY = "createBody";
+ public static final String UPDATE_ATTRS = "updateAttrs";
+ public static final String UPDATE_STYLE = "updateStyle";
+ public static final String REMOVE_ELEMENT = "removeElement";
+ public static final String ADD_ELEMENT = "addElement";
+ public static final String MOVE_ELEMENT = "moveElement";
+ public static final String ADD_EVENT = "addEvent";
+ public static final String REMOVE_EVENT = "removeEvent";
+ public static final String CREATE_FINISH = "createFinish";
+ public static final String REFRESH_FINISH = "refreshFinish";
+ public static final String UPDATE_FINISH = "updateFinish";
+ public static final String SCROLL_TO_ELEMENT = "scrollToElement";
+ public static final String ADD_RULE = "addRule";
+ public static final String GET_COMPONENT_RECT = "getComponentRect";
public static final String WXDOM = "dom";
@@ -284,95 +279,14 @@ public final class WXDomModule extends WXModule {
if (method == null) {
return null;
}
+ //TODO\uff1aadd pooling
try {
- switch (method) {
- case CREATE_BODY:
- if (args == null) {
- return null;
- }
- createBody((JSONObject) args.get(0));
- break;
- case UPDATE_ATTRS:
- if (args == null) {
- return null;
- }
- updateAttrs((String) args.get(0), (JSONObject) args.get(1));
- break;
- case UPDATE_STYLE:
- if (args == null) {
- return null;
- }
- updateStyle((String) args.get(0), (JSONObject) args.get(1));
- break;
- case REMOVE_ELEMENT:
- if (args == null) {
- return null;
- }
- removeElement((String) args.get(0));
- break;
- case ADD_ELEMENT:
- if (args == null) {
- return null;
- }
- addElement((String) args.get(0), (JSONObject) args.get(1), (Integer) args.get(2));
- break;
- case MOVE_ELEMENT:
- if (args == null) {
- return null;
- }
- moveElement((String) args.get(0), (String) args.get(1), (Integer) args.get(2));
- break;
- case ADD_EVENT:
- if (args == null) {
- return null;
- }
- addEvent((String) args.get(0), (String) args.get(1));
- break;
- case REMOVE_EVENT:
- if (args == null) {
- return null;
- }
- removeEvent((String) args.get(0), (String) args.get(1));
- break;
- case CREATE_FINISH:
- createFinish();
- break;
- case REFRESH_FINISH:
- refreshFinish();
- break;
- case UPDATE_FINISH:
- updateFinish();
- break;
- case SCROLL_TO_ELEMENT:
- if (args == null) {
- return null;
- }
- JSONObject option =null;
- if(args.size()>1) {
- option = (JSONObject) args.get(1);
- }
- scrollToElement((String) args.get(0),option);
- break;
- case ADD_RULE:
- if (args == null) {
- return null;
- }
- addRule((String) args.get(0), (JSONObject) args.get(1));
- break;
- case GET_COMPONENT_RECT:
- if(args == null){
- return null;
- }
- getComponentRect((String) args.get(0),(String) args.get(1));
- break;
- case INVOKE_METHOD:
- if(args == null){
- return null;
- }
- invokeMethod((String) args.get(0),(String) args.get(1),(JSONArray) args.get(2));
- break;
+ DOMAction action = Actions.get(method,args);
+ if(action == null){
+ WXLogUtils.e("Unknown dom action.");
}
+ postAction(action,CREATE_BODY.equals(method));
} catch (IndexOutOfBoundsException e) {
// no enougn args
e.printStackTrace();
@@ -394,309 +308,14 @@ public final class WXDomModule extends WXModule {
return;
}
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- List<Object> msgArgs = new ArrayList<>();
- msgArgs.add(ref);
- msgArgs.add(method);
- msgArgs.add(args);
-
- task.args = msgArgs;
- msg.what = WXDomHandler.MsgType.WX_DOM_INVOKE;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Create a body for the current {@link com.taobao.weex.WXSDKInstance} according to given
- * parameter.
- * @param element info about how to create a body
- */
- public void createBody(JSONObject element) {
- if (element == null) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(element);
- msg.what = WXDomHandler.MsgType.WX_DOM_CREATE_BODY;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Update attributes
- * @param ref
- * @param attr the expected attr
- */
- public void updateAttrs(String ref, JSONObject attr) {
- if (TextUtils.isEmpty(ref) || attr == null || attr.size() < 1) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- task.args.add(attr);
- msg.what = WXDomHandler.MsgType.WX_DOM_UPDATE_ATTRS;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Update DOM style.
- * @param ref DOM reference
- * @param style the expected style
- */
- public void updateStyle(String ref, JSONObject style) {
- if (TextUtils.isEmpty(ref) || style == null || style.size() < 1) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- task.args.add(style);
- msg.what = WXDomHandler.MsgType.WX_DOM_UPDATE_STYLE;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Remove a node for the node tree.
- * @param ref reference of the node to be removed.
- */
- public void removeElement(String ref) {
- if (TextUtils.isEmpty(ref)) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- msg.what = WXDomHandler.MsgType.WX_DOM_REMOVE_DOM;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Add a {@link WXDomObject} to the specified parent as its given n-th child.
- * @param parentRef reference of the parent.
- * @param element the node to be added
- * @param index the expected index that the new dom in its new parent
- */
- public void addElement(String parentRef, JSONObject element, Integer index) {
- if (element == null
- || TextUtils.isEmpty(parentRef)) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(parentRef);
- task.args.add(element);
- task.args.add(index);
- msg.what = WXDomHandler.MsgType.WX_DOM_ADD_DOM;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Move the DomElement to the specified parent as its given n-th child.
- * @param ref reference of the node to be moved.
- * @param parentRef reference of the parent.
- * @param index the expected index that the dom in its new parent
- */
- public void moveElement(String ref, String parentRef, Integer index) {
- if (TextUtils.isEmpty(ref)
- || TextUtils.isEmpty(parentRef)) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- task.args.add(parentRef);
- task.args.add(index);
- msg.what = WXDomHandler.MsgType.WX_DOM_MOVE_DOM;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Add eventListener for the specified {@link WXDomObject}
- * @param ref reference of the node
- * @param type the type of the event listener to be added.
- */
- public void addEvent(String ref, String type) {
- if (TextUtils.isEmpty(ref) || TextUtils.isEmpty(type)) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- task.args.add(type);
- msg.what = WXDomHandler.MsgType.WX_DOM_ADD_EVENT;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Remove eventListener for the specified {@link WXDomObject}
- * @param ref reference of the node
- * @param type the type of the event listener to be removed.
- */
- public void removeEvent(String ref, String type) {
- if (TextUtils.isEmpty(ref) || TextUtils.isEmpty(type)) {
- return;
- }
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- task.args.add(type);
- msg.what = WXDomHandler.MsgType.WX_DOM_REMOVE_EVENT;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Notify the {@link WXDomManager} that creation of dom tree is finished.
- * This notify is given by JS.
- */
- public void createFinish() {
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- msg.what = WXDomHandler.MsgType.WX_DOM_CREATE_FINISH;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- /**
- * Notify the {@link WXDomManager} that refreshing of dom tree is finished.
- * This notify is given by JS.
- */
- public void refreshFinish() {
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- msg.what = WXDomHandler.MsgType.WX_DOM_REFRESH_FINISH;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- public void updateFinish() {
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- msg.what = WXDomHandler.MsgType.WX_DOM_UPDATE_FINISH;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
-
- /**
- * Scroll the specified {@link WXDomObject} to given offset in given duration
- * @param ref reference of specified dom object
- * @param options scroll option, like {offset:0, duration:300}
- */
- public void scrollToElement(String ref, JSONObject options) {
- if (TextUtils.isEmpty(ref) ) {
- return;
- }
-
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- task.args.add(options);
- msg.what = WXDomHandler.MsgType.WX_DOM_SCROLLTO;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
-
- public void addRule(String type, JSONObject options) {
- if (TextUtils.isEmpty(type) || options == null) {
- return;
- }
-
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(type);
- task.args.add(options);
- msg.what = WXDomHandler.MsgType.WX_DOM_ADD_RULE;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
+ postAction(Actions.getInvokeMethod(ref,method,args),false);
}
/**
- * By ref the width and height of the component.
- *
- * @param ref the refer of component
- * @param callback function id
+ * @param action
+ * @param createContext only true when create body
*/
- public void getComponentRect(String ref, String callback) {
- if (mWXSDKInstance == null) {
- return;
- }
- SimpleJSCallback jsCallback = new SimpleJSCallback(mWXSDKInstance.getInstanceId(), callback);
- if (TextUtils.isEmpty(ref)) {
- Map<String, Object> options = new HashMap<>();
- options.put("result", false);
- options.put("errMsg", "Illegal parameter");
- jsCallback.invoke(options);
- return;
- } else if ("viewport".equalsIgnoreCase(ref)) {
- if (mWXSDKInstance.getContainerView() != null) {
- Map<String, Object> options = new HashMap<>();
- Map<String, Float> sizes = new HashMap<>();
- int[] location = new int[2];
- mWXSDKInstance.getContainerView().getLocationOnScreen(location);
- sizes.put("left", 0f);
- sizes.put("top", 0f);
- sizes.put("right", getWebPxValue(mWXSDKInstance.getContainerView().getWidth()));
- sizes.put("bottom", getWebPxValue(mWXSDKInstance.getContainerView().getHeight()));
- sizes.put("width", getWebPxValue(mWXSDKInstance.getContainerView().getWidth()));
- sizes.put("height", getWebPxValue(mWXSDKInstance.getContainerView().getHeight()));
- options.put("size", sizes);
- options.put("result", true);
- jsCallback.invoke(options);
- } else {
- Map<String, Object> options = new HashMap<>();
- options.put("result", false);
- options.put("errMsg", "Component does not exist");
- jsCallback.invoke(options);
- }
- } else {
- Message msg = Message.obtain();
- WXDomTask task = new WXDomTask();
- task.instanceId = mWXSDKInstance.getInstanceId();
- task.args = new ArrayList<>();
- task.args.add(ref);
- task.args.add(jsCallback);
- msg.what = WXDomHandler.MsgType.WX_COMPONENT_SIZE;
- msg.obj = task;
- WXSDKManager.getInstance().getWXDomManager().sendMessage(msg);
- }
- }
-
- @NonNull
- private float getWebPxValue(int value) {
- return WXViewUtils.getWebPxByWidth(value,mWXSDKInstance.getInstanceViewPortWidth());
+ public void postAction(DOMAction action, boolean createContext){
+ WXSDKManager.getInstance().getWXDomManager().postAction(mWXSDKInstance.getInstanceId(),action,createContext);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
index b2fae6c..8963a37 100755
--- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
@@ -272,7 +272,7 @@ public class WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject
private boolean mYoung = false;
- /** package **/ void traverseTree(Consumer...consumers){
+ public void traverseTree(Consumer...consumers){
if (consumers == null) {
return;
}
@@ -855,7 +855,7 @@ public class WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject
return domObject;
}
- interface Consumer{
+ public interface Consumer{
void accept(WXDomObject dom);
}
}
[2/9] incubator-weex git commit: * [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,
DomModule#getComponentSize. It's low risk since it's a internal method,
users should not dirct use it.
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/ScrollToElementAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/ScrollToElementAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/ScrollToElementAction.java
new file mode 100644
index 0000000..3c27d46
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/ScrollToElementAction.java
@@ -0,0 +1,257 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.WXSDKManager;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.ui.IWXRenderTask;
+import com.taobao.weex.ui.component.Scrollable;
+import com.taobao.weex.ui.component.WXComponent;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+final class ScrollToElementAction implements DOMAction, RenderAction {
+ private final JSONObject mOptions;
+ private final String mRef;
+
+ public ScrollToElementAction(String ref, JSONObject options) {
+ this.mRef = ref;
+ this.mOptions = options;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+ WXSDKInstance instance = context.getInstance();
+ context.postRenderTask(this);
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent component = context.getComponent(mRef);
+ if (component == null) {
+ return;
+ }
+
+ Scrollable scroller = component.getParentScroller();
+ if (scroller == null) {
+ return;
+ }
+ scroller.scrollTo(component,mOptions);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateAttributeAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateAttributeAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateAttributeAction.java
new file mode 100644
index 0000000..a307831
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateAttributeAction.java
@@ -0,0 +1,263 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
+
+/**
+ * Created by sospartan on 28/02/2017.
+ */
+
+class UpdateAttributeAction implements DOMAction, RenderAction {
+ private final String mRef;
+ private final JSONObject mData;
+
+
+ UpdateAttributeAction(String ref, JSONObject data) {
+ mRef = ref;
+ mData = data;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+ WXSDKInstance instance = context.getInstance();
+ final WXDomObject domObject = context.getDomByRef(mRef);
+ if (domObject == null) {
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATEATTRS);
+ }
+ return;
+ }
+
+ domObject.updateAttr(mData);
+ context.postRenderTask(this);
+
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent comp = context.getComponent(mRef);
+ if (comp == null) {
+ return;
+ }
+
+ comp.updateProperties(mData);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateFinishAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateFinishAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateFinishAction.java
new file mode 100644
index 0000000..fd3475e
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateFinishAction.java
@@ -0,0 +1,237 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+
+final class UpdateFinishAction implements DOMAction, RenderAction {
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+ context.postRenderTask(this);
+
+ WXSDKInstance instance = context.getInstance();
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ context.getInstance().onUpdateFinish();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java
new file mode 100644
index 0000000..e8d75de
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/UpdateStyleAction.java
@@ -0,0 +1,298 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import android.support.v4.util.ArrayMap;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.Constants;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.dom.flex.Spacing;
+import com.taobao.weex.ui.component.WXComponent;
+
+import java.util.Map;
+
+/**
+ * Created by sospartan on 28/02/2017.
+ */
+
+class UpdateStyleAction implements DOMAction, RenderAction {
+ private final String mRef;
+ private final JSONObject mData;
+ private final boolean mIsCausedByPesudo;
+
+ private Spacing mPadding;
+ private Spacing mBorder;
+
+ UpdateStyleAction(String ref, JSONObject data) {
+ this(ref, data, false);
+ }
+
+ UpdateStyleAction(String ref, JSONObject data, boolean byPesudo) {
+ this.mRef = ref;
+ this.mData = data;
+ this.mIsCausedByPesudo = byPesudo;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory() || mData == null) {
+ return;
+ }
+ WXSDKInstance instance = context.getInstance();
+ WXDomObject domObject = context.getDomByRef(mRef);
+ if (domObject == null) {
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_UPDATESTYLE);
+ }
+ return;
+ }
+ mPadding = domObject.getPadding();
+ mBorder = domObject.getBorder();
+
+ Map<String, Object> animationMap = new ArrayMap<>(2);
+ animationMap.put(WXDomObject.TRANSFORM, mData.remove(WXDomObject.TRANSFORM));
+ animationMap.put(WXDomObject.TRANSFORM_ORIGIN, mData.remove(WXDomObject.TRANSFORM_ORIGIN));
+
+ context.addAnimationForElement(mRef, animationMap);
+
+ if (!mData.isEmpty()) {
+ domObject.updateStyle(mData, mIsCausedByPesudo);
+ domObject.traverseTree(context.getApplyStyleConsumer());
+ context.postRenderTask(this);
+ }
+
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent component = context.getComponent(mRef);
+ if (component == null) {
+ return;
+ }
+ component.updateProperties(mData);
+
+ if (mData.containsKey(Constants.Name.PADDING) ||
+ mData.containsKey(Constants.Name.PADDING_TOP) ||
+ mData.containsKey(Constants.Name.PADDING_LEFT) ||
+ mData.containsKey(Constants.Name.PADDING_RIGHT) ||
+ mData.containsKey(Constants.Name.PADDING_BOTTOM) ||
+ mData.containsKey(Constants.Name.BORDER_WIDTH)) {
+ Spacing padding = mPadding;
+ Spacing border = mBorder;
+ component.setPadding(padding, border);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/ui/RenderActionContextImpl.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/RenderActionContextImpl.java b/android/sdk/src/main/java/com/taobao/weex/ui/RenderActionContextImpl.java
new file mode 100755
index 0000000..1093952
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/RenderActionContextImpl.java
@@ -0,0 +1,303 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.ui;
+
+import android.graphics.Rect;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.bridge.JSCallback;
+import com.taobao.weex.common.WXRenderStrategy;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.dom.flex.Spacing;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.ui.animation.WXAnimationBean;
+import com.taobao.weex.ui.animation.WXAnimationModule;
+import com.taobao.weex.ui.component.Scrollable;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.ui.component.WXComponentFactory;
+import com.taobao.weex.ui.component.WXVContainer;
+import com.taobao.weex.utils.WXViewUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Class for rendering view. Method in this class should be run in main thread.
+ * This class is also <strong>not</storng> thread safe.
+ * This class is very similar to {@link com.taobao.weex.dom.WXDomStatement}
+ * @see com.taobao.weex.dom.WXDomStatement
+ */
+class RenderActionContextImpl implements RenderActionContext {
+
+ private Map<String, WXComponent> mRegistry;
+ private WXSDKInstance mWXSDKInstance;
+ /**
+ * The container for weex root view.
+ */
+
+ public RenderActionContextImpl(WXSDKInstance instance) {
+ mWXSDKInstance = instance;
+ mRegistry = new HashMap<>();
+ }
+
+ /**
+ * @see com.taobao.weex.dom.WXDomStatement#destroy()
+ */
+ public void destroy() {
+ mWXSDKInstance = null;
+ mRegistry.clear();
+ }
+
+ public WXSDKInstance getWXSDKInstance() {
+ return mWXSDKInstance;
+ }
+
+ /**
+ * set layout information of View
+ */
+ void setLayout(String ref, WXDomObject domObject) {
+ WXComponent component = mRegistry.get(ref);
+ if (component == null) {
+ return;
+ }
+ component.setLayout(domObject);
+ }
+
+ /**
+ * set extra information of View
+ */
+ void setExtra(String ref, Object extra) {
+ WXComponent component = mRegistry.get(ref);
+ if (component == null) {
+ return;
+ }
+ component.updateExtra(extra);
+ }
+
+ @Override
+ public WXSDKInstance getInstance() {
+ return mWXSDKInstance;
+ }
+
+ @Override
+ public WXComponent getComponent(String ref) {
+ return mRegistry.get(ref);
+ }
+
+ void startAnimation(@NonNull String ref, @NonNull WXAnimationBean animationBean, @Nullable String callBack) {
+ WXAnimationModule.startAnimation(mWXSDKInstance, mRegistry.get(ref), animationBean, callBack);
+ }
+
+ public void registerComponent(String ref, WXComponent comp) {
+ mRegistry.put(ref,comp);
+ }
+
+ public WXComponent unregisterComponent(String ref) {
+ return mRegistry.remove(ref);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java b/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java
index 3fc130d..719c84e 100755
--- a/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/WXRenderManager.java
@@ -209,28 +209,25 @@ import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.taobao.weex.WXSDKInstance;
-import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.common.WXRuntimeException;
import com.taobao.weex.common.WXThread;
import com.taobao.weex.dom.WXDomObject;
-import com.taobao.weex.dom.flex.Spacing;
import com.taobao.weex.ui.animation.WXAnimationBean;
import com.taobao.weex.ui.component.WXComponent;
import com.taobao.weex.utils.WXUtils;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
- * Manager class for render operation, mainly for managing {@link WXRenderStatement}.
+ * Manager class for render operation, mainly for managing {@link RenderActionContextImpl}.
* This is <strong>not</strong> a thread-safe class
*/
public class WXRenderManager {
- private ConcurrentHashMap<String, WXRenderStatement> mRegistries;
+ private ConcurrentHashMap<String, RenderActionContextImpl> mRegistries;
private WXRenderHandler mWXRenderHandler;
public WXRenderManager() {
@@ -238,7 +235,7 @@ public class WXRenderManager {
mWXRenderHandler = new WXRenderHandler();
}
- public WXRenderStatement getWXRenderStatement(String instanceId) {
+ public RenderActionContextImpl getWXRenderStatement(String instanceId) {
return mRegistries.get(instanceId);
}
@@ -246,12 +243,12 @@ public class WXRenderManager {
if(instanceId == null || TextUtils.isEmpty(ref)){
return null;
}
- WXRenderStatement stmt = getWXRenderStatement(instanceId);
+ RenderActionContextImpl stmt = getWXRenderStatement(instanceId);
return stmt == null?null:stmt.getComponent(ref);
}
public WXSDKInstance getWXSDKInstance(String instanceId) {
- WXRenderStatement statement = mRegistries.get(instanceId);
+ RenderActionContextImpl statement = mRegistries.get(instanceId);
if (statement == null) {
return null;
}
@@ -270,7 +267,7 @@ public class WXRenderManager {
if (!WXUtils.isUiThread()) {
throw new WXRuntimeException("[WXRenderManager] removeRenderStatement can only be called in main thread");
}
- WXRenderStatement statement = mRegistries.remove(instanceId);
+ RenderActionContextImpl statement = mRegistries.remove(instanceId);
if (statement != null) {
statement.destroy();
}
@@ -291,27 +288,11 @@ public class WXRenderManager {
}
public void registerInstance(WXSDKInstance instance) {
- mRegistries.put(instance.getInstanceId(), new WXRenderStatement(instance));
- }
-
- public void createBody(String instanceId, WXComponent component) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.createBody(component);
- }
-
- public WXComponent createBodyOnDomThread(String instanceId, WXDomObject domObject) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return null;
- }
- return statement.createBodyOnDomThread(domObject);
+ mRegistries.put(instance.getInstanceId(), new RenderActionContextImpl(instance));
}
public void setLayout(String instanceId, String ref, WXDomObject domObject) {
- WXRenderStatement statement = mRegistries.get(instanceId);
+ RenderActionContextImpl statement = mRegistries.get(instanceId);
if (statement == null) {
return;
}
@@ -322,130 +303,17 @@ public class WXRenderManager {
* Set extra info, other than attribute and style
*/
public void setExtra(String instanceId, String ref, Object extra) {
- WXRenderStatement statement = mRegistries.get(instanceId);
+ RenderActionContextImpl statement = mRegistries.get(instanceId);
if (statement == null) {
return;
}
statement.setExtra(ref, extra);
}
- public void setPadding(String instanceId, String ref, Spacing padding, Spacing border) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.setPadding(ref, padding, border);
- }
-
- public void addComponent(String instanceId, WXDomObject dom, String parentRef, int index) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.addComponent(dom, parentRef, index);
- }
-
- public @Nullable WXComponent createComponentOnDomThread(String instanceId, WXDomObject dom, String parentRef, int index) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return null;
- }
- return statement.createComponentOnDomThread(dom, parentRef, index);
- }
-
- public void addComponent(String instanceId, WXComponent component, String parentRef, int index) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.addComponent(component, parentRef, index);
- }
-
- public void removeComponent(String instanceId, String ref) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.removeComponent(ref);
- }
-
- public void moveComponent(String instanceId, String ref, String parentRef, int index) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.move(ref, parentRef, index);
- }
-
- public void updateAttrs(String instanceId, String ref, Map<String, Object> attrs) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.updateAttrs(ref, attrs);
- }
-
- public void updateStyle(String instanceId, String ref, Map<String, Object> style) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.updateStyle(ref, style);
- }
-
- public void addEvent(String instanceId, String ref, String type) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return ;
- }
- statement.addEvent(ref, type);
- }
-
- public void removeEvent(String instanceId, String ref, String type) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return ;
- }
- statement.removeEvent(ref, type);
- }
-
- public void scrollToComponent(String instanceId, String ref, Map<String, Object> options) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.scrollTo(ref, options);
- }
-
- public void createFinish(String instanceId, int width, int height) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.createFinish(width, height);
- }
-
- public void refreshFinish(String instanceId, int width, int height) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.refreshFinish(width, height);
- }
-
- public void updateFinish(String instanceId) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- return;
- }
- statement.updateFinish();
- }
-
-
public void startAnimation(String instanceId, @NonNull String ref,
@NonNull WXAnimationBean animationBean, @Nullable String
callBack) {
- WXRenderStatement statement = mRegistries.get(instanceId);
+ RenderActionContextImpl statement = mRegistries.get(instanceId);
if (statement == null) {
return;
}
@@ -456,8 +324,8 @@ public class WXRenderManager {
ArrayList<WXSDKInstance> instances = null;
if (mRegistries != null && !mRegistries.isEmpty()) {
instances = new ArrayList<WXSDKInstance>();
- for (Map.Entry<String, WXRenderStatement> entry : mRegistries.entrySet()) {
- WXRenderStatement renderStatement = entry.getValue();
+ for (Map.Entry<String, RenderActionContextImpl> entry : mRegistries.entrySet()) {
+ RenderActionContextImpl renderStatement = entry.getValue();
if (renderStatement != null) {
instances.add(renderStatement.getWXSDKInstance());
}
@@ -466,15 +334,11 @@ public class WXRenderManager {
return instances;
}
- public void getComponentSize(String instanceId, String ref, JSCallback callback) {
- WXRenderStatement statement = mRegistries.get(instanceId);
- if (statement == null) {
- Map<String, Object> options = new HashMap<>();
- options.put("result", false);
- options.put("errMsg", "Component does not exist");
- callback.invoke(options);
- return;
+ public void registerComponent(String instanceId, String ref, WXComponent comp) {
+ RenderActionContextImpl statement = mRegistries.get(instanceId);
+ if (statement != null) {
+ statement.registerComponent(ref,comp);
}
- statement.getComponentSize(ref, callback);
}
+
}
[4/9] incubator-weex git commit: * [android] new dom statement
pential break changes: WXRenderStatement#getComponentSize,
DomModule#getComponentSize. It's low risk since it's a internal method,
users should not dirct use it.
Posted by so...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/Actions.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/Actions.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/Actions.java
new file mode 100644
index 0000000..dbe7383
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/Actions.java
@@ -0,0 +1,314 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.dom.DOMAction;
+import static com.taobao.weex.dom.WXDomModule.*;
+
+/**
+ * Created by sospartan on 01/03/2017.
+ */
+
+public class Actions {
+
+ public static DOMAction get(String actionName,JSONArray args){
+ switch (actionName) {
+ case CREATE_BODY:
+ if (args == null) {
+ return null;
+ }
+ return new CreateBodyAction(args.getJSONObject(0));
+ case UPDATE_ATTRS:
+ if (args == null) {
+ return null;
+ }
+ return new UpdateAttributeAction(args.getString(0),args.getJSONObject(1));
+ case UPDATE_STYLE:
+ if (args == null) {
+ return null;
+ }
+ return new UpdateStyleAction(args.getString(0),args.getJSONObject(1));
+ case REMOVE_ELEMENT:
+ if (args == null) {
+ return null;
+ }
+ return new RemoveElementAction(args.getString(0));
+ case ADD_ELEMENT:
+ if (args == null) {
+ return null;
+ }
+ return new AddElementAction(args.getJSONObject(1),args.getString(0),args.getInteger(2));
+ case MOVE_ELEMENT:
+ if (args == null) {
+ return null;
+ }
+ return new MoveElementAction(args.getString(0),args.getString(1),args.getInteger(2));
+ case ADD_EVENT:
+ if (args == null) {
+ return null;
+ }
+ return new AddEventAction(args.getString(0),args.getString(1));
+ case REMOVE_EVENT:
+ if (args == null) {
+ return null;
+ }
+ return new RemoveEventAction(args.getString(0),args.getString(1));
+ case CREATE_FINISH:
+ return new CreateFinishAction();
+ case REFRESH_FINISH:
+ return new RefreshFinishAction();
+ case UPDATE_FINISH:
+ return new UpdateFinishAction();
+ case SCROLL_TO_ELEMENT:
+ if (args == null) {
+ return null;
+ }
+ return new ScrollToElementAction(args.getString(0),args.getJSONObject(1));
+ case ADD_RULE:
+ if (args == null) {
+ return null;
+ }
+ return new AddRuleAction(args.getString(0),args.getJSONObject(1));
+ case GET_COMPONENT_RECT:
+ if(args == null){
+ return null;
+ }
+ return new GetComponentRectAction(args.getString(0),args.getString(1));
+ case INVOKE_METHOD:
+ if(args == null){
+ return null;
+ }
+ return new InvokeMethodAction(args.getString(0),args.getString(1),args.getJSONArray(2));
+ }
+
+ return null;
+ }
+
+
+ public static DOMAction getInvokeMethod(String ref,String method,JSONArray args){
+ return new InvokeMethodAction(ref,method,args);
+ }
+
+ /**
+ * Bridge will get this action directly.
+ * @param data
+ * @param parentRef
+ * @param index
+ * @return
+ */
+ public static DOMAction getAddElement(JSONObject data, String parentRef, int index){
+ return new AddElementAction(data,parentRef,index);
+ }
+
+ public static DOMAction getUpdateStyle(String ref, JSONObject data, boolean byPesudo){
+ return new UpdateStyleAction(ref,data,byPesudo);
+ }
+
+ public static DOMAction getAddEvent(String ref, String type) {
+ return new AddEventAction(ref,type);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/AddElementAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/AddElementAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/AddElementAction.java
new file mode 100644
index 0000000..99070a8
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/AddElementAction.java
@@ -0,0 +1,295 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.ui.component.WXVContainer;
+import com.taobao.weex.utils.WXLogUtils;
+
+/**
+ * Created by sospartan on 22/02/2017.
+ */
+
+final class AddElementAction extends AbstractAddElementAction {
+ private final String mParentRef;
+ private final int mAddIndex;
+ private final JSONObject mData;
+
+ private String mRef;
+
+
+ AddElementAction(JSONObject data, String parentRef, int index) {
+ mParentRef = parentRef;
+ mAddIndex = index;
+ mData = data;
+ }
+
+ @Override
+ protected WXComponent createComponent(DOMActionContext context, WXDomObject domObject) {
+ WXComponent comp = context.getCompByRef(mParentRef);
+ if (comp == null || !(comp instanceof WXVContainer)) {
+ return null;
+ }
+ return generateComponentTree(context, domObject, (WXVContainer) comp);
+ }
+
+ @Override
+ protected void appendDomToTree(DOMActionContext context, WXDomObject domObject) {
+ WXDomObject parent;
+ mRef = domObject.getRef();
+ if ((parent = context.getDomByRef(mParentRef)) == null) {
+ context.getInstance().commitUTStab(IWXUserTrackAdapter.DOM_MODULE, getErrorCode());
+ return;
+ } else {
+ //non-root and parent exist
+ parent.add(domObject, mAddIndex);
+ }
+ }
+
+ @Override
+ protected String getStatementName() {
+ return "addDom";
+ }
+
+ @Override
+ protected WXErrorCode getErrorCode() {
+ return WXErrorCode.WX_ERR_DOM_ADDELEMENT;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ addDomInternal(context, mData);
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent component = context.getComponent(mRef);
+ WXSDKInstance instance = context.getInstance();
+ if (instance == null || instance.getContext() == null) {
+ WXLogUtils.e("instance is null or instance is destroy!");
+ return;
+ }
+ try {
+ WXVContainer parent = (WXVContainer) context.getComponent(mParentRef);
+ if (parent == null || component == null) {
+ return;
+ }
+
+ parent.addChild(component, mAddIndex);
+ parent.createChildViewAt(mAddIndex);
+ component.applyLayoutAndEvent(component);
+ component.bindData(component);
+ } catch (Exception e) {
+ WXLogUtils.e("add component failed.", e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/AddEventAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/AddEventAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/AddEventAction.java
new file mode 100644
index 0000000..bf54957
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/AddEventAction.java
@@ -0,0 +1,262 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderAction;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
+
+/**
+ * Created by sospartan on 01/03/2017.
+ */
+class AddEventAction implements DOMAction, RenderAction {
+ private final String mRef;
+ private final String mEvent;
+
+ private WXDomObject mUpdatedDom;
+
+ AddEventAction(String ref, String event) {
+ mRef = ref;
+ mEvent = event;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (context.isDestory()) {
+ return;
+ }
+ WXSDKInstance instance = context.getInstance();
+ WXDomObject domObject = context.getDomByRef(mRef);
+ if (domObject == null) {
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_ERR_DOM_ADDEVENT);
+ }
+ return;
+ }
+ domObject.addEvent(mEvent);
+ mUpdatedDom = domObject;
+ context.postRenderTask(this);
+
+ if (instance != null) {
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ }
+ }
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent comp = context.getComponent(mRef);
+ if(comp != null){
+ //sync dom change to component
+ comp.updateDom(mUpdatedDom);
+ comp.addEvent(mEvent);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/AddRuleAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/AddRuleAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/AddRuleAction.java
new file mode 100644
index 0000000..50a443e
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/AddRuleAction.java
@@ -0,0 +1,254 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import android.text.TextUtils;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.common.Constants;
+import com.taobao.weex.dom.DOMAction;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.utils.FontDO;
+import com.taobao.weex.utils.TypefaceUtil;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+final class AddRuleAction implements DOMAction {
+ private final String mType;
+ private final JSONObject mData;
+
+ public AddRuleAction(String type, JSONObject data) {
+ this.mType = type;
+ this.mData = data;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ if (Constants.Name.FONT_FACE.equals(mType)) {
+ FontDO fontDO = parseFontDO(mData, context.getInstance());
+ if (fontDO != null && !TextUtils.isEmpty(fontDO.getFontFamilyName())) {
+ FontDO cacheFontDO = TypefaceUtil.getFontDO(fontDO.getFontFamilyName());
+ if (cacheFontDO == null || !TextUtils.equals(cacheFontDO.getUrl(), fontDO.getUrl())) {
+ TypefaceUtil.putFontDO(fontDO);
+ TypefaceUtil.loadTypeface(fontDO);
+ } else {
+ TypefaceUtil.loadTypeface(cacheFontDO);
+ }
+ }
+ }
+ }
+
+ private FontDO parseFontDO(JSONObject jsonObject,WXSDKInstance instance) {
+ if(jsonObject == null) {
+ return null;
+ }
+ String src = jsonObject.getString(Constants.Name.SRC);
+ String name = jsonObject.getString(Constants.Name.FONT_FAMILY);
+
+ return new FontDO(name, src,instance);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateBodyAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateBodyAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateBodyAction.java
new file mode 100644
index 0000000..787ecf5
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateBodyAction.java
@@ -0,0 +1,302 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import android.widget.ScrollView;
+
+import com.alibaba.fastjson.JSONObject;
+import com.taobao.weex.WXEnvironment;
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.WXSDKManager;
+import com.taobao.weex.adapter.IWXUserTrackAdapter;
+import com.taobao.weex.common.WXErrorCode;
+import com.taobao.weex.common.WXRenderStrategy;
+import com.taobao.weex.dom.DOMActionContext;
+import com.taobao.weex.dom.RenderActionContext;
+import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
+import com.taobao.weex.ui.component.WXScroller;
+import com.taobao.weex.utils.WXLogUtils;
+import com.taobao.weex.utils.WXViewUtils;
+
+/**
+ * Created by sospartan on 14/02/2017.
+ */
+
+class CreateBodyAction extends AbstractAddElementAction {
+ private final JSONObject mData;
+
+ CreateBodyAction(JSONObject data) {
+ mData = data;
+ }
+
+ @Override
+ public void executeDom(DOMActionContext context) {
+ addDomInternal(context, mData);
+ }
+
+ @Override
+ protected WXComponent createComponent(DOMActionContext context, WXDomObject domObject) {
+ return generateComponentTree(context, domObject, null);
+ }
+
+ @Override
+ protected void appendDomToTree(DOMActionContext context, WXDomObject domObject) {
+ String instanceId = context.getInstanceId();
+ WXDomObject.prepareRoot(domObject,
+ WXViewUtils.getWebPxByWidth(WXViewUtils.getWeexHeight(instanceId), WXSDKManager.getInstanceViewPortWidth(instanceId)),
+ WXViewUtils.getWebPxByWidth(WXViewUtils.getWeexWidth(instanceId), WXSDKManager.getInstanceViewPortWidth(instanceId)));
+ }
+
+ @Override
+ protected WXErrorCode getErrorCode() {
+ return WXErrorCode.WX_ERR_DOM_CREATEBODY;
+ }
+
+ @Override
+ protected String getStatementName() {
+ return "createBody";
+ }
+
+
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXComponent component = context.getComponent(WXDomObject.ROOT);
+ WXSDKInstance instance = context.getInstance();
+ if (instance == null || instance.getContext() == null) {
+ WXLogUtils.e("instance is null or instance is destroy!");
+ return;
+ }
+ try {
+ long start = System.currentTimeMillis();
+ component.createView();
+ if (WXEnvironment.isApkDebugable()) {
+ WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
+ }
+ start = System.currentTimeMillis();
+ component.applyLayoutAndEvent(component);
+ component.bindData(component);
+
+ if (WXEnvironment.isApkDebugable()) {
+ WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
+ }
+
+ if (component instanceof WXScroller) {
+ WXScroller scroller = (WXScroller) component;
+ if (scroller.getInnerView() instanceof ScrollView) {
+ instance.setRootScrollView((ScrollView) scroller.getInnerView());
+ }
+ }
+ instance.onRootCreated(component);
+ if (instance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
+ instance.onCreateFinish();
+ }
+ instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, WXErrorCode.WX_SUCCESS);
+ } catch (Exception e) {
+ WXLogUtils.e("create body failed.", e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f3390e3c/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateFinishAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateFinishAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateFinishAction.java
new file mode 100644
index 0000000..2072ef9
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/CreateFinishAction.java
@@ -0,0 +1,224 @@
+/**
+ *
+ * Apache License
+ * Version 2.0, January 2004
+ * http://www.apache.org/licenses/
+ *
+ * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ *
+ * 1. Definitions.
+ *
+ * "License" shall mean the terms and conditions for use, reproduction,
+ * and distribution as defined by Sections 1 through 9 of this document.
+ *
+ * "Licensor" shall mean the copyright owner or entity authorized by
+ * the copyright owner that is granting the License.
+ *
+ * "Legal Entity" shall mean the union of the acting entity and all
+ * other entities that control, are controlled by, or are under common
+ * control with that entity. For the purposes of this definition,
+ * "control" means (i) the power, direct or indirect, to cause the
+ * direction or management of such entity, whether by contract or
+ * otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ * outstanding shares, or (iii) beneficial ownership of such entity.
+ *
+ * "You" (or "Your") shall mean an individual or Legal Entity
+ * exercising permissions granted by this License.
+ *
+ * "Source" form shall mean the preferred form for making modifications,
+ * including but not limited to software source code, documentation
+ * source, and configuration files.
+ *
+ * "Object" form shall mean any form resulting from mechanical
+ * transformation or translation of a Source form, including but
+ * not limited to compiled object code, generated documentation,
+ * and conversions to other media types.
+ *
+ * "Work" shall mean the work of authorship, whether in Source or
+ * Object form, made available under the License, as indicated by a
+ * copyright notice that is included in or attached to the work
+ * (an example is provided in the Appendix below).
+ *
+ * "Derivative Works" shall mean any work, whether in Source or Object
+ * form, that is based on (or derived from) the Work and for which the
+ * editorial revisions, annotations, elaborations, or other modifications
+ * represent, as a whole, an original work of authorship. For the purposes
+ * of this License, Derivative Works shall not include works that remain
+ * separable from, or merely link (or bind by name) to the interfaces of,
+ * the Work and Derivative Works thereof.
+ *
+ * "Contribution" shall mean any work of authorship, including
+ * the original version of the Work and any modifications or additions
+ * to that Work or Derivative Works thereof, that is intentionally
+ * submitted to Licensor for inclusion in the Work by the copyright owner
+ * or by an individual or Legal Entity authorized to submit on behalf of
+ * the copyright owner. For the purposes of this definition, "submitted"
+ * means any form of electronic, verbal, or written communication sent
+ * to the Licensor or its representatives, including but not limited to
+ * communication on electronic mailing lists, source code control systems,
+ * and issue tracking systems that are managed by, or on behalf of, the
+ * Licensor for the purpose of discussing and improving the Work, but
+ * excluding communication that is conspicuously marked or otherwise
+ * designated in writing by the copyright owner as "Not a Contribution."
+ *
+ * "Contributor" shall mean Licensor and any individual or Legal Entity
+ * on behalf of whom a Contribution has been received by Licensor and
+ * subsequently incorporated within the Work.
+ *
+ * 2. Grant of Copyright License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * copyright license to reproduce, prepare Derivative Works of,
+ * publicly display, publicly perform, sublicense, and distribute the
+ * Work and such Derivative Works in Source or Object form.
+ *
+ * 3. Grant of Patent License. Subject to the terms and conditions of
+ * this License, each Contributor hereby grants to You a perpetual,
+ * worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ * (except as stated in this section) patent license to make, have made,
+ * use, offer to sell, sell, import, and otherwise transfer the Work,
+ * where such license applies only to those patent claims licensable
+ * by such Contributor that are necessarily infringed by their
+ * Contribution(s) alone or by combination of their Contribution(s)
+ * with the Work to which such Contribution(s) was submitted. If You
+ * institute patent litigation against any entity (including a
+ * cross-claim or counterclaim in a lawsuit) alleging that the Work
+ * or a Contribution incorporated within the Work constitutes direct
+ * or contributory patent infringement, then any patent licenses
+ * granted to You under this License for that Work shall terminate
+ * as of the date such litigation is filed.
+ *
+ * 4. Redistribution. You may reproduce and distribute copies of the
+ * Work or Derivative Works thereof in any medium, with or without
+ * modifications, and in Source or Object form, provided that You
+ * meet the following conditions:
+ *
+ * (a) You must give any other recipients of the Work or
+ * Derivative Works a copy of this License; and
+ *
+ * (b) You must cause any modified files to carry prominent notices
+ * stating that You changed the files; and
+ *
+ * (c) You must retain, in the Source form of any Derivative Works
+ * that You distribute, all copyright, patent, trademark, and
+ * attribution notices from the Source form of the Work,
+ * excluding those notices that do not pertain to any part of
+ * the Derivative Works; and
+ *
+ * (d) If the Work includes a "NOTICE" text file as part of its
+ * distribution, then any Derivative Works that You distribute must
+ * include a readable copy of the attribution notices contained
+ * within such NOTICE file, excluding those notices that do not
+ * pertain to any part of the Derivative Works, in at least one
+ * of the following places: within a NOTICE text file distributed
+ * as part of the Derivative Works; within the Source form or
+ * documentation, if provided along with the Derivative Works; or,
+ * within a display generated by the Derivative Works, if and
+ * wherever such third-party notices normally appear. The contents
+ * of the NOTICE file are for informational purposes only and
+ * do not modify the License. You may add Your own attribution
+ * notices within Derivative Works that You distribute, alongside
+ * or as an addendum to the NOTICE text from the Work, provided
+ * that such additional attribution notices cannot be construed
+ * as modifying the License.
+ *
+ * You may add Your own copyright statement to Your modifications and
+ * may provide additional or different license terms and conditions
+ * for use, reproduction, or distribution of Your modifications, or
+ * for any such Derivative Works as a whole, provided Your use,
+ * reproduction, and distribution of the Work otherwise complies with
+ * the conditions stated in this License.
+ *
+ * 5. Submission of Contributions. Unless You explicitly state otherwise,
+ * any Contribution intentionally submitted for inclusion in the Work
+ * by You to the Licensor shall be under the terms and conditions of
+ * this License, without any additional terms or conditions.
+ * Notwithstanding the above, nothing herein shall supersede or modify
+ * the terms of any separate license agreement you may have executed
+ * with Licensor regarding such Contributions.
+ *
+ * 6. Trademarks. This License does not grant permission to use the trade
+ * names, trademarks, service marks, or product names of the Licensor,
+ * except as required for reasonable and customary use in describing the
+ * origin of the Work and reproducing the content of the NOTICE file.
+ *
+ * 7. Disclaimer of Warranty. Unless required by applicable law or
+ * agreed to in writing, Licensor provides the Work (and each
+ * Contributor provides its Contributions) on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied, including, without limitation, any warranties or conditions
+ * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ * PARTICULAR PURPOSE. You are solely responsible for determining the
+ * appropriateness of using or redistributing the Work and assume any
+ * risks associated with Your exercise of permissions under this License.
+ *
+ * 8. Limitation of Liability. In no event and under no legal theory,
+ * whether in tort (including negligence), contract, or otherwise,
+ * unless required by applicable law (such as deliberate and grossly
+ * negligent acts) or agreed to in writing, shall any Contributor be
+ * liable to You for damages, including any direct, indirect, special,
+ * incidental, or consequential damages of any character arising as a
+ * result of this License or out of the use or inability to use the
+ * Work (including but not limited to damages for loss of goodwill,
+ * work stoppage, computer failure or malfunction, or any and all
+ * other commercial damages or losses), even if such Contributor
+ * has been advised of the possibility of such damages.
+ *
+ * 9. Accepting Warranty or Additional Liability. While redistributing
+ * the Work or Derivative Works thereof, You may choose to offer,
+ * and charge a fee for, acceptance of support, warranty, indemnity,
+ * or other liability obligations and/or rights consistent with this
+ * License. However, in accepting such obligations, You may act only
+ * on Your own behalf and on Your sole responsibility, not on behalf
+ * of any other Contributor, and only if You agree to indemnify,
+ * defend, and hold each Contributor harmless for any liability
+ * incurred by, or claims asserted against, such Contributor by reason
+ * of your accepting any such warranty or additional liability.
+ *
+ * END OF TERMS AND CONDITIONS
+ *
+ * APPENDIX: How to apply the Apache License to your work.
+ *
+ * To apply the Apache License to your work, attach the following
+ * boilerplate notice, with the fields enclosed by brackets "[]"
+ * replaced with your own identifying information. (Don't include
+ * the brackets!) The text should be enclosed in the appropriate
+ * comment syntax for the file format. We also recommend that a
+ * file or class name and description of purpose be included on the
+ * same "printed page" as the copyright notice for easier
+ * identification within third-party archives.
+ *
+ * Copyright 2016 Alibaba Group
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.taobao.weex.dom.action;
+
+import com.taobao.weex.WXSDKInstance;
+import com.taobao.weex.common.WXRenderStrategy;
+import com.taobao.weex.dom.RenderActionContext;
+
+/**
+ * Created by sospartan on 02/03/2017.
+ */
+
+final class CreateFinishAction extends AbstractLayoutFinishAction {
+ @Override
+ public void executeRender(RenderActionContext context) {
+ WXSDKInstance instance = context.getInstance();
+ if (instance.getRenderStrategy() == WXRenderStrategy.APPEND_ONCE) {
+ instance.onCreateFinish();
+ }
+ instance.onRenderSuccess(mLayoutWidth, mLayoutHeight);
+ }
+}