You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2018/04/28 06:54:05 UTC
[37/48] incubator-weex git commit: * [android] Merge WeexCore-master
to master.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/bridge/WXJSObject.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXJSObject.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXJSObject.java
index 6101d06..4c92a70 100644
--- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXJSObject.java
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXJSObject.java
@@ -26,7 +26,6 @@ public class WXJSObject {
public static final int NUMBER = 1;
public static final int String = 2;
public static final int JSON = 3;
- public static final int WSON = 4;
public Object data;
public int type;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/bridge/WXJsFunctions.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXJsFunctions.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXJsFunctions.java
new file mode 100644
index 0000000..53108ef
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXJsFunctions.java
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.bridge;
+
+import com.taobao.weex.common.IWXJsFunctions;
+
+/**
+ * Created by darin on 27/03/2018.
+ */
+
+public class WXJsFunctions implements IWXJsFunctions {
+ @Override
+ public native void initWxBridge(Object bridge, String className);
+
+ @Override
+ public native void jsHandleSetJSVersion(String jsVersion);
+
+ @Override
+ public native void jsHandleReportException(String instanceId, String func, String exceptionString);
+
+ @Override
+ public native void jsHandleCallNative(String instanceId, byte[] tasks, String callback);
+
+ @Override
+ public native void jsHandleCallNativeModule(String instanceId, String module, String method, byte[] arguments, byte[] options);
+
+
+ @Override
+ public native void jsHandleCallNativeComponent(String instanceId, String componentRef, String method, byte[] arguments, byte[] options);
+
+
+ @Override
+ public native void jsHandleCallAddElement(String instanceId, String ref, String dom, String index);
+
+
+ @Override
+ public native void jsHandleSetTimeout(String callbackId, String time);
+
+
+ @Override
+ public native void jsHandleCallNativeLog(byte[] str_array);
+
+
+ @Override
+ public native void jsFunctionCallCreateBody(String pageId, String domStr);
+
+
+ @Override
+ public native void jsFunctionCallUpdateFinish(String instanceId, byte[] tasks, String callback);
+
+
+ @Override
+ public native void jsFunctionCallCreateFinish(String pageId);
+
+
+ @Override
+ public native void jsFunctionCallRefreshFinish(String instanceId, byte[] tasks, String callback);
+
+
+ @Override
+ public native void jsFunctionCallUpdateAttrs(String pageId, String ref, String data);
+
+
+ @Override
+ public native void jsFunctionCallUpdateStyle(String pageId, String ref, String data);
+
+
+ @Override
+ public native void jsFunctionCallRemoveElement(String pageId, String ref);
+
+
+ @Override
+ public native void jsFunctionCallMoveElement(String pageId, String ref, String parentRef, String index_str);
+
+
+ @Override
+ public native void jsFunctionCallAddEvent(String pageId, String ref, String event);
+
+
+ @Override
+ public native void jsFunctionCallRemoveEvent(String pageId, String ref, String event);
+
+
+ @Override
+ public native void jsHandleSetInterval(String instanceId, String callbackId, String time);
+
+
+ @Override
+ public native void jsHandleClearInterval(String instanceId, String callbackId);
+
+
+ @Override
+ public native void jsHandleCallGCanvasLinkNative(String contextId, int type, String val);
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/bridge/WXModuleManager.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXModuleManager.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXModuleManager.java
index 6bc4af4..20f8b55 100644
--- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXModuleManager.java
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXModuleManager.java
@@ -6,9 +6,9 @@
* to you 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
@@ -31,10 +31,8 @@ import com.taobao.weex.common.Destroyable;
import com.taobao.weex.common.WXErrorCode;
import com.taobao.weex.common.WXException;
import com.taobao.weex.common.WXModule;
-import com.taobao.weex.dom.DOMAction;
-import com.taobao.weex.dom.WXDomModule;
-import com.taobao.weex.dom.action.Actions;
import com.taobao.weex.ui.config.ConfigModuleFactory;
+import com.taobao.weex.ui.module.WXDomModule;
import com.taobao.weex.ui.module.WXTimerModule;
import com.taobao.weex.utils.WXExceptionUtils;
import com.taobao.weex.utils.WXLogUtils;
@@ -82,7 +80,7 @@ public class WXModuleManager {
return false;
}
- if (TextUtils.equals(moduleName, WXDomModule.WXDOM)) {
+ if (TextUtils.equals(moduleName,WXDomModule.WXDOM)) {
WXLogUtils.e("Cannot registered module with name 'dom'.");
return false;
}
@@ -121,6 +119,7 @@ public class WXModuleManager {
}
});
return true;
+
}
static boolean registerNativeModule(String moduleName, ModuleFactory factory) throws WXException {
@@ -180,14 +179,14 @@ public class WXModuleManager {
return null;
}
} catch (Exception e) {
- WXExceptionUtils.commitCriticalExceptionRT(instanceId,
- WXErrorCode.WX_KEY_EXCEPTION_INVOKE_REGISTER_CONTENT_FAILED,
- "callModuleMethod",
- WXErrorCode.WX_KEY_EXCEPTION_INVOKE_REGISTER_CONTENT_FAILED.getErrorMsg()
- + "callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. "
- + WXLogUtils.getStackTrace(e),
- null);
- WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e);
+ WXExceptionUtils.commitCriticalExceptionRT(instanceId,
+ WXErrorCode.WX_KEY_EXCEPTION_INVOKE_REGISTER_CONTENT_FAILED,
+ "callModuleMethod",
+ WXErrorCode.WX_KEY_EXCEPTION_INVOKE_REGISTER_CONTENT_FAILED.getErrorMsg()
+ + "callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. "
+ + WXLogUtils.getStackTrace(e),
+ null);
+ WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e);
return null;
} finally {
if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) {
@@ -203,8 +202,8 @@ public class WXModuleManager {
}
// we are in preRender mode
if(invoker.isRunOnUIThread()) {/*ASYNC CALL*/
- DOMAction moduleInvocationAction = Actions.getModuleInvocationAction(wxModule,args,invoker);
- WXSDKManager.getInstance().getWXDomManager().postAction(instance.getInstanceId(), moduleInvocationAction,false);
+// DOMAction moduleInvocationAction = Actions.getModuleInvocationAction(wxModule,args,invoker);
+// WXSDKManager.getInstance().getWXDomManager().postAction(instance.getInstanceId(), moduleInvocationAction,false);
return null;
} else {/*SYNC CALL*/
return instance.getNativeInvokeHelper().invoke(wxModule,invoker,args);
@@ -485,5 +484,4 @@ public class WXModuleManager {
}
}
}
-
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/bridge/WXValidateProcessor.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXValidateProcessor.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXValidateProcessor.java
index d657fae..86be2b1 100644
--- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXValidateProcessor.java
+++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXValidateProcessor.java
@@ -21,7 +21,7 @@ package com.taobao.weex.bridge;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.WXSDKInstance;
-import com.taobao.weex.dom.WXDomObject;
+import com.taobao.weex.ui.component.WXComponent;
/**
* Created by fengjunjie
@@ -34,7 +34,7 @@ public interface WXValidateProcessor {
WXComponentValidateResult onComponentValidate(WXSDKInstance wxsdkInstance,
String componentName,
- WXDomObject parentDomObject);
+ WXComponent parentComponent);
boolean needValidate(String bundleUrl);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
index e35fc65..5777bd2 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/Constants.java
@@ -121,12 +121,12 @@ public class Constants {
String LOADMOREOFFSET = "loadmoreoffset";
String RECYCLE_IMAGE = "recycleImage";
String LAYOUT = "layout";
- String COLUMN_WIDTH= "columnWidth";
- String COLUMN_COUNT= "columnCount";
- String COLUMN_GAP= "columnGap";
+ String COLUMN_WIDTH = "columnWidth";
+ String COLUMN_COUNT = "columnCount";
+ String COLUMN_GAP = "columnGap";
+ String SHOW_SCROLLBAR = "showScrollbar";
String LEFT_GAP= "leftGap";
String RIGHT_GAP= "rightGap";
- String SHOW_SCROLLBAR= "showScrollbar";
String OVERFLOW = "overflow";
String TYPE = "type";
String PLACEHOLDER = "placeholder";
@@ -191,7 +191,7 @@ public class Constants {
String DIRECTION = "direction";
String RTL = "rtl";
-
+
String STICKY_OFFSET = "stickyOffset";
String HAS_FIXED_SIZE = "hasFixedSize";
String KEEP_POSITION_LAYOUT_DELAY = "keepPositionLayoutDelay";
@@ -207,10 +207,6 @@ public class Constants {
String INCLUDE_FONT_PADDING = "includeFontPadding";
String ENABLE_COPY = "enableCopy";
- String THUMB_TINT_COLOR = "thumbTintColor";
- String ON_THUMB_TINT_COLOR = "onThumbTintColor";
- String TINT_COLOR = "tintColor";
- String ON_TINT_COLOR = "onTintColor";
interface Recycler{
String LIST_DATA = "listData";
@@ -229,7 +225,6 @@ public class Constants {
String FLAT = "flat";
String RIPPLE_ENABLED = "rippleEnabled";
-
String SHOULD_STOP_PROPAGATION_INIT_RESULT = "shouldStopPropagationInitResult";
String SHOULD_STOP_PROPAGATION_INTERVAL = "shouldStopPropagationInterval";
@@ -245,8 +240,8 @@ public class Constants {
int AUTO = -1;
int COLUMN_GAP_NORMAL = 32;
int COLUMN_COUNT_NORMAL = 1;
- String MULTI_COLUMN= "multi-column";
- String GRID= "grid";
+ String MULTI_COLUMN = "multi-column";
+ String GRID = "grid";
String STICKY = "sticky";
String FIXED = "fixed";
String LEFT = "left";
@@ -322,7 +317,7 @@ public class Constants {
String ON_TRANSITION_END = "transitionEnd";
- interface SLOT_LIFECYCLE{
+ interface SLOT_LIFECYCLE {
String CREATE = "create";
String ATTACH = "attach";
String DETACH = "detach";
@@ -357,7 +352,7 @@ public class Constants {
String SAVE_PATH = "v8";
}
- public interface TimeFunction{
+ public interface TimeFunction {
String LINEAR = "linear";
String EASE_IN_OUT = "ease-in-out";
String EASE_IN = "ease-in";
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/IWXBridge.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/IWXBridge.java b/android/sdk/src/main/java/com/taobao/weex/common/IWXBridge.java
index 0933ce3..6f9fa9e 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/IWXBridge.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/IWXBridge.java
@@ -18,11 +18,13 @@
*/
package com.taobao.weex.common;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.bridge.WXJSObject;
import com.taobao.weex.bridge.WXParams;
+import com.taobao.weex.dom.CSSShorthand;
+import com.taobao.weex.layout.ContentBoxMeasurement;
+
+import java.util.HashMap;
+import java.util.HashSet;
/**
* Bridge interface, native bridge and debug bridge both need to implement this interface
@@ -60,8 +62,16 @@ public interface IWXBridge extends IWXObject {
*/
byte[] execJSWithResult(String instanceId, String namespace, String function, WXJSObject[] args);
+ int execJSService(String javascript);
-/**
+ /**
+ * take the heap snapshot and serialize the heap to a local file.
+ *
+ * @param filename
+ */
+ void takeHeapSnapshot(String filename);
+
+ /**
* createInstance
* @param instanceId
* @param namespace
@@ -80,59 +90,97 @@ public interface IWXBridge extends IWXObject {
* @return
*/
int destoryInstance(String instanceId, String namespace, String function, WXJSObject[] args);
- int execJSService(String javascript);
-
- /**
+
+ /**
* execJSOnInstance
* @param instanceId
* @param script
* @param type
* @return
*/
-
String execJSOnInstance(String instanceId, String script, int type);
/**
- * take the heap snapshot and serialize the heap to a local file.
- *
- * @param filename
- */
- void takeHeapSnapshot(String filename);
-
- /**
* js call native
-
*/
- int callNative(String instanceId, JSONArray tasks, String callback);
+ int callNative(String instanceId, byte[] tasks, String callback);
- int callAddElement(String instanceId, String ref, JSONObject dom, String index, String callback);
+ int callNative(String instanceId, String tasks, String callback);
void reportJSException(String instanceId, String func, String exception);
- Object callNativeModule(String instanceId, String module, String method, byte [] arguments, byte [] options);
+ Object callNativeModule(String instanceId, String module, String method, byte[] arguments, byte[] options);
- void callNativeComponent(String instanceId, String componentRef, String method, byte [] arguments, byte [] options);
+ void callNativeComponent(String instanceId, String ref, String method, byte[] arguments, byte[] options);
- int callCreateBody(String instanceId, String tasks, String callback);
+ int callUpdateFinish(String instanceId, byte[] tasks, String callback);
- int callUpdateFinish(String instanceId, byte [] tasks, String callback);
+ int callRefreshFinish(String instanceId, byte[] tasks, String callback);
- int callCreateFinish(String instanceId, byte [] tasks, String callback);
+ void reportServerCrash(String instanceId, String crashFile);
- int callRefreshFinish(String instanceId, byte [] tasks, String callback);
- int callUpdateAttrs(String instanceId, String ref, byte [] tasks, String callback);
+ public int callCreateBody(String instanceId, String componentType, String ref,
+ HashMap<String, String> styles, HashMap<String, String> attributes, HashSet<String> events,
+ float[] margins, float[] paddings, float[] borders);
- int callUpdateStyle(String instanceId, String ref, byte [] tasks, String callback);
+ public int callAddElement(String instanceId, String componentType, String ref, int index, String parentRef,
+ HashMap<String, String> styles, HashMap<String, String> attributes, HashSet<String> events,
+ float[] margins, float[] paddings, float[] borders);
- int callRemoveElement(String instanceId, String ref, String callback);
+ int callRemoveElement(String instanceId, String ref);
- int callMoveElement(String instanceId, String ref, String parentref, String index, String callback);
+ int callMoveElement(String instanceId, String ref, String parentref, int index);
- int callAddEvent(String instanceId, String ref, String event, String callback);
+ int callAddEvent(String instanceId, String ref, String event);
- int callRemoveEvent(String instanceId, String ref, String event, String callback);
+ int callRemoveEvent(String instanceId, String ref, String event);
- void reportServerCrash(String instanceId, String crashFile);
+ public int callUpdateStyle(String instanceId, String ref,
+ HashMap<String, Object> styles,
+ HashMap<String, String> paddings,
+ HashMap<String, String> margins,
+ HashMap<String, String> borders);
+
+ int callUpdateAttrs(String instanceId, String ref,
+ HashMap<String, String> attrs);
+
+ int callLayout(String instanceId, String ref, int top, int bottom, int left, int right, int height, int width, int index);
+
+ int callCreateFinish(String instanceId);
+
+ int callHasTransitionPros(String instanceId, String ref, HashMap<String, String> styles);
+
+ void bindMeasurementToWXCore(String instanceId, String ref, ContentBoxMeasurement contentBoxMeasurement);
+
+ void setRenderContainerWrapContent(boolean wrap, String instanceId);
+
+ int printFirstScreenRenderTime(String instanceId);
+
+ int printRenderFinishTime(String instanceId);
+
+ void setDefaultHeightAndWidthIntoRootDom(String instanceId, float defaultWidth, float defaultHeight, boolean isWidthWrapContent, boolean isHeightWrapContent);
+
+ void onInstanceClose(String instanceId);
+
+ void forceLayout(String instanceId);
+
+ boolean notifyLayout(String instanceId);
+
+ void setStyleWidth(String instanceId, String ref, float value);
+
+ void setStyleHeight(String instanceId, String ref, float value);
+
+ void setMargin(String instanceId, String ref, CSSShorthand.EDGE edge, float value);
+
+ void setPadding(String instanceId, String ref, CSSShorthand.EDGE edge, float value);
+
+ void setPosition(String instanceId, String ref, CSSShorthand.EDGE edge, float value);
+
+ void markDirty(String instanceId, String ref, boolean dirty);
+
+ void registerCoreEnv(String key, String value);
+
+ void setViewPortWidth(String instanceId, float value);
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/IWXDebugProxy.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/IWXDebugProxy.java b/android/sdk/src/main/java/com/taobao/weex/common/IWXDebugProxy.java
index bcd6acf..0345378 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/IWXDebugProxy.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/IWXDebugProxy.java
@@ -26,7 +26,7 @@ public interface IWXDebugProxy {
String ACTION_INSTANCE_RELOAD = "INSTANCE_RELOAD";
- void start();
+ void start(IWXJsFunctions jsFunctions);
void stop(boolean reload);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/IWXJsFunctions.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/IWXJsFunctions.java b/android/sdk/src/main/java/com/taobao/weex/common/IWXJsFunctions.java
new file mode 100644
index 0000000..fbe592b
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/common/IWXJsFunctions.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.common;
+
+/**
+ * Created by darin on 27/03/2018.
+ */
+
+public interface IWXJsFunctions {
+
+ void initWxBridge(Object bridge, String className);
+
+ void jsHandleSetJSVersion(String jsVersion);
+
+ void jsHandleReportException(String instanceId, String func, String exceptionString);
+
+ void jsHandleCallNative(String instanceId, byte[] tasks, String callback);
+
+ void jsHandleCallNativeModule(String instanceId, String module, String method, byte[]
+ arguments, byte[] options);
+
+ void jsHandleCallNativeComponent(String instanceId, String componentRef, String method,
+ byte[] arguments, byte[] options);
+
+ void jsHandleCallAddElement(String instanceId, String ref, String dom, String index);
+
+ void jsHandleSetTimeout(String callbackId, String time);
+
+ void jsHandleCallNativeLog(byte[] str_array);
+
+ void jsFunctionCallCreateBody(String pageId, String domStr);
+
+ void jsFunctionCallUpdateFinish(String instanceId, byte[] tasks, String callback);
+
+ void jsFunctionCallCreateFinish(String pageId);
+
+ void jsFunctionCallRefreshFinish(String instanceId, byte[] tasks, String callback);
+
+ void jsFunctionCallUpdateAttrs(String pageId, String ref, String data);
+
+ void jsFunctionCallUpdateStyle(String pageId, String ref, String data);
+
+ void jsFunctionCallRemoveElement(String pageId, String ref);
+
+ void jsFunctionCallMoveElement(String pageId, String ref, String parentRef, String index_str);
+
+ void jsFunctionCallAddEvent(String pageId, String ref, String event);
+
+ void jsFunctionCallRemoveEvent(String pageId, String ref, String event);
+
+ void jsHandleSetInterval(String instanceId, String callbackId, String time);
+
+ void jsHandleClearInterval(String instanceId, String callbackId);
+
+ void jsHandleCallGCanvasLinkNative(String contextId, int type, String val);
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/IWXTask.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/IWXTask.java b/android/sdk/src/main/java/com/taobao/weex/common/IWXTask.java
deleted file mode 100644
index 1ea659d..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/common/IWXTask.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.common;
-
-public interface IWXTask {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java b/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
index 2bd2d16..0f77ec9 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/WXErrorCode.java
@@ -6,9 +6,9 @@
* to you 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
@@ -22,9 +22,9 @@ package com.taobao.weex.common;
public enum WXErrorCode {
- /*
- * environment
- **/
+ /*
+ * environment
+ **/
/**
* Failure for load so library
*/
@@ -213,7 +213,7 @@ public enum WXErrorCode {
*/
WX_RENDER_ERR_JS_CREATE_INSTANCE("-9600", "WX_RENDER_ERR_JS_CREATE_INSTANCE",ErrorType.RENDER_ERROR,ErrorGroup.JS),
WX_RENDER_ERR_JS_RUNTIME("-9601", "WX_RENDER_ERR for js error",ErrorType.RENDER_ERROR,
- ErrorGroup.JS),
+ ErrorGroup.JS),
/**
@@ -244,7 +244,7 @@ public enum WXErrorCode {
* once this case occured,network requist response header and statuscode need track into errmsg.
*/
WX_DEGRAD_ERR_BUNDLE_CONTENTTYPE_ERROR("-1004", "degradeToH5|wx_user_intercept_error |Content-Type is not application/javascript, " +
- "Weex render template must be javascript, please check your request!",ErrorType.DEGRAD_ERROR,ErrorGroup.NET),
+ "Weex render template must be javascript, please check your request!",ErrorType.DEGRAD_ERROR,ErrorGroup.NET),
/**
* degrade for other reason. such as white screen which block error for some unknown reason.
@@ -278,7 +278,7 @@ public enum WXErrorCode {
}
public void appendErrMsg(String err) {
- appendMsg=err;
+ appendMsg=err;
}
public String getErrorCode() {
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/WXJSExceptionInfo.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/WXJSExceptionInfo.java b/android/sdk/src/main/java/com/taobao/weex/common/WXJSExceptionInfo.java
index 6fd207e..59a47ae 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/WXJSExceptionInfo.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/WXJSExceptionInfo.java
@@ -6,9 +6,9 @@
* to you 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
@@ -132,13 +132,13 @@ public class WXJSExceptionInfo {
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("WeexSDKVersion:").append(mWeexVersion)
- .append(" JSFrameworkVersion:").append(mJsFrameworkVersion)
- .append(" instanceId:").append(mInstanceId)
- .append(" bundleUrl:").append(mBundleUrl)
- .append(" errCode:").append(mErrCode.getErrorCode())
- .append(" function:").append(mFunction)
- .append(" exception:").append(mException)
- .append(" extParams:").append(mExtParams);
+ .append(" JSFrameworkVersion:").append(mJsFrameworkVersion)
+ .append(" instanceId:").append(mInstanceId)
+ .append(" bundleUrl:").append(mBundleUrl)
+ .append(" errCode:").append(mErrCode.getErrorCode())
+ .append(" function:").append(mFunction)
+ .append(" exception:").append(mException)
+ .append(" extParams:").append(mExtParams);
return buffer.toString();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/common/WXPerformance.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/common/WXPerformance.java b/android/sdk/src/main/java/com/taobao/weex/common/WXPerformance.java
index 77e43e9..e09ec1d 100644
--- a/android/sdk/src/main/java/com/taobao/weex/common/WXPerformance.java
+++ b/android/sdk/src/main/java/com/taobao/weex/common/WXPerformance.java
@@ -6,9 +6,9 @@
* to you 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
@@ -19,7 +19,6 @@
package com.taobao.weex.common;
import android.support.annotation.RestrictTo;
-import android.support.annotation.RestrictTo.Scope;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.utils.WXViewUtils;
@@ -31,7 +30,7 @@ import java.util.Map;
public class WXPerformance {
- @RestrictTo(Scope.LIBRARY)
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
public enum Dimension {
JSLibVersion,
WXSDKVersion,
@@ -126,7 +125,7 @@ public class WXPerformance {
public static final String DEFAULT = "default";
- @RestrictTo(Scope.LIBRARY_GROUP)
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public static final String CACHE_TYPE = "cacheType";
public static final int VIEW_LIMIT_HEIGHT = WXViewUtils.getScreenHeight() / 2;
@@ -145,10 +144,10 @@ public class WXPerformance {
@Deprecated
public String templateUrl;
- @RestrictTo(Scope.LIBRARY_GROUP)
+ @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public String cacheType = "unknown";
- @RestrictTo(Scope.LIBRARY)
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
public long renderTimeOrigin;
public long fsRenderTime;
@@ -161,7 +160,7 @@ public class WXPerformance {
* Time used for
* {@link com.taobao.weex.bridge.WXBridgeManager#createInstance(String, String, Map, String)}
*/
- @RestrictTo(Scope.LIBRARY)
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
public long callCreateInstanceTime;
@@ -326,7 +325,7 @@ public class WXPerformance {
public String errMsg;
private StringBuilder mErrMsgBuilder;
- public String args = "";
+ public String args="";
public String connectionType;
public String requestType;
@@ -340,19 +339,45 @@ public class WXPerformance {
/**
* TODO These dimensions will be moved to elsewhere
*/
- @RestrictTo(Scope.LIBRARY)
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
@Deprecated
public String wxDims[] = new String[5];
/**
* TODO These dimensions will be moved to elsewhere
*/
- @RestrictTo(Scope.LIBRARY)
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
@Deprecated
public long measureTimes[] = new long[5];
- public WXPerformance() {
- mErrMsgBuilder = new StringBuilder();
+
+ /**
+ * RenderAction
+ */
+ public int mCallCreateBodySumTime = 0;
+ public int mCallAddElementSumTime = 0;
+
+ public int mCallLayoutSumTime = 0;
+ public int mCallLayoutUpdateDemissionSumTime = 0;
+ public int mCallLayoutApplyLayoutAndEventSumTime = 0;
+ public int mCallLayoutBindDataSumTime = 0;
+
+ public int mActionTotalSumTime = 0;
+ public int mActionLayoutCount = 0;
+ public int mActionLayoutSumTime = 0;
+
+ public int mActionAddElementCount = 0;
+ public int mActionAddElementSumTime = 0;
+
+ public int mActionCreateBodyCount = 0;
+ public int mActionCreateBodySumTime = 0;
+
+ public int mActionOtherCount = 0;
+ public int mActionOtherSumTime = 0;
+
+
+ public WXPerformance(){
+ mErrMsgBuilder=new StringBuilder();
}
public static void init() {
@@ -467,44 +492,44 @@ public class WXPerformance {
public String toString() {
if (WXEnvironment.isApkDebugable()) {
return "bizType:" + bizType + ",pageName:" + pageName + ",templateLoadTime" + templateLoadTime
- + ",localReadTime:" + localReadTime + ",JSLibInitTime:" + JSLibInitTime
- + ",JSLibSize:" + JSLibSize + ",templateUrl" + templateUrl
- + ",JSTemplateSize:" + JSTemplateSize + ",communicateTime:" + communicateTime
- + ",screenRenderTime:" + screenRenderTime
- + ",firstScreenJSFExecuteTime:" + firstScreenJSFExecuteTime
- + ",componentCount:" + componentCount
- + ",syncTaskTime:" + syncTaskTime
- + ",pureNetworkTime:" + pureNetworkTime
- + ",networkTime:" + networkTime
- + ",actualNetworkTime:" + actualNetworkTime
- + ",packageSpendTime:" + packageSpendTime
- + ",connectionType:" + connectionType
- + ",requestType:" + requestType
- + ",initInvokeTime:" + WXEnvironment.sSDKInitInvokeTime + ",initExecuteTime:" + WXEnvironment.sSDKInitExecuteTime
- + ",SDKInitTime:" + WXEnvironment.sSDKInitTime
- + ",totalTime:" + totalTime + ",JSLibVersion:" + JSLibVersion + ",WXSDKVersion:" + WXSDKVersion
- + ",errCode:" + errCode + ",renderFailedDetail:" + renderFailedDetail
- + ",arg:" + args
- + ",errMsg:" + getErrMsg();
+ + ",localReadTime:" + localReadTime + ",JSLibInitTime:" + JSLibInitTime
+ + ",JSLibSize:" + JSLibSize + ",templateUrl" + templateUrl
+ + ",JSTemplateSize:" + JSTemplateSize + ",communicateTime:" + communicateTime
+ + ",screenRenderTime:" + screenRenderTime
+ + ",firstScreenJSFExecuteTime:" + firstScreenJSFExecuteTime
+ + ",componentCount:" + componentCount
+ + ",syncTaskTime:" + syncTaskTime
+ + ",pureNetworkTime:" + pureNetworkTime
+ + ",networkTime:" + networkTime
+ + ",actualNetworkTime:" + actualNetworkTime
+ + ",packageSpendTime:" + packageSpendTime
+ + ",connectionType:" + connectionType
+ + ",requestType:" + requestType
+ + ",initInvokeTime:" + WXEnvironment.sSDKInitInvokeTime + ",initExecuteTime:" + WXEnvironment.sSDKInitExecuteTime
+ + ",SDKInitTime:" + WXEnvironment.sSDKInitTime
+ + ",totalTime:" + totalTime + ",JSLibVersion:" + JSLibVersion + ",WXSDKVersion:" + WXSDKVersion
+ + ",errCode:" + errCode + ",renderFailedDetail:" + renderFailedDetail
+ + ",arg:" + args
+ + ",errMsg:" + getErrMsg();
}
return super.toString();
}
public String getPerfData() {
return "networkTime:" + networkTime
- + " actualNetworkTime:" + actualNetworkTime
- + " connectionType:" + connectionType
- + " requestType:" + requestType
- + " firstScreenRenderTime:" + screenRenderTime
- + " firstScreenJSFExecuteTime:" + firstScreenJSFExecuteTime
- + " componentCount:" + componentCount
- + " JSTemplateSize:" + JSTemplateSize
- + " SDKInitTime:" + WXEnvironment.sSDKInitTime
- + " totalTime:" + totalTime
- + " JSLibVersion:" + JSLibVersion
- + " WXSDKVersion:" + WXSDKVersion
- + " pageName:" + pageName
- + " useScroller:" + useScroller;
+ + " actualNetworkTime:" + actualNetworkTime
+ + " connectionType:" + connectionType
+ + " requestType:" + requestType
+ + " firstScreenRenderTime:" + screenRenderTime
+ + " firstScreenJSFExecuteTime:" + firstScreenJSFExecuteTime
+ + " componentCount:" + componentCount
+ + " JSTemplateSize:" + JSTemplateSize
+ + " SDKInitTime:" + WXEnvironment.sSDKInitTime
+ + " totalTime:" + totalTime
+ + " JSLibVersion:" + JSLibVersion
+ + " WXSDKVersion:" + WXSDKVersion
+ + " pageName:" + pageName
+ + " useScroller:" + useScroller;
}
@@ -516,7 +541,6 @@ public class WXPerformance {
mErrMsgBuilder.append(msg);
}
-
public void beforeInstanceRender(String instanceId) {
renderTimeOrigin = System.currentTimeMillis();
}
@@ -524,4 +548,11 @@ public class WXPerformance {
public void afterInstanceDestroy(String instanceId) {
}
-}
\ No newline at end of file
+ public int renderSumTime() {
+ return mActionAddElementSumTime + mActionCreateBodySumTime + mActionLayoutSumTime + mActionOtherSumTime;
+ }
+
+ public int renderSumCount() {
+ return mActionAddElementCount + mActionCreateBodyCount + mActionLayoutCount + mActionOtherCount;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/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
deleted file mode 100644
index 6bb55a5..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/ApplyStyleConsumer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java
deleted file mode 100644
index 93b5070..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/BasicEditTextDomObject.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.text.TextPaint;
-import com.taobao.weex.common.Constants;
-import com.taobao.weex.dom.flex.CSSConstants;
-import com.taobao.weex.dom.flex.CSSNode;
-import com.taobao.weex.dom.flex.MeasureOutput;
-import com.taobao.weex.ui.component.WXText;
-import com.taobao.weex.utils.TypefaceUtil;
-import com.taobao.weex.utils.WXViewUtils;
-
-import static com.taobao.weex.dom.WXStyle.UNSET;
-
-/**
- * Created by sospartan on 7/12/16.
- */
-public class BasicEditTextDomObject extends WXDomObject {
-
- private TextPaint mPaint = new TextPaint();
-
- // private int mFontSize = UNSET;
- private int mLineHeight = UNSET;
-// private String mFontFamily = null;
-
- public BasicEditTextDomObject() {
- super();
- mPaint.setTextSize(WXViewUtils.getRealPxByWidth(WXText.sDEFAULT_SIZE,getViewPortWidth()));
- setMeasureFunction(new MeasureFunction() {
- @Override
- public void measure(CSSNode node, float width, MeasureOutput measureOutput) {
- if (CSSConstants.isUndefined(width)) {
- width = node.cssstyle.maxWidth;
- }
- measureOutput.height = getMeasureHeight();
- measureOutput.width = width;
- }
- });
- }
-
- @Override
- public void layoutBefore() {
- super.layoutBefore();
- updateStyleAndAttrs();
- }
-
- protected final float getMeasuredLineHeight() {
- return mLineHeight != UNSET && mLineHeight > 0 ? mLineHeight : mPaint.getFontMetrics(null);
- }
-
- protected float getMeasureHeight() {
- return getMeasuredLineHeight();
- }
-
- protected void updateStyleAndAttrs() {
- if (getStyles().size() > 0) {
- int fontSize = UNSET, fontStyle = UNSET, fontWeight = UNSET;
- String fontFamily = null;
- if (getStyles().containsKey(Constants.Name.FONT_SIZE)) {
- fontSize = WXStyle.getFontSize(getStyles(),getViewPortWidth());
- }
-
- if (getStyles().containsKey(Constants.Name.FONT_FAMILY)) {
- fontFamily = WXStyle.getFontFamily(getStyles());
- }
-
- if (getStyles().containsKey(Constants.Name.FONT_STYLE)) {
- fontStyle = WXStyle.getFontStyle(getStyles());
- }
-
- if (getStyles().containsKey(Constants.Name.FONT_WEIGHT)) {
- fontWeight = WXStyle.getFontWeight(getStyles());
- }
-
- int lineHeight = WXStyle.getLineHeight(getStyles(),getViewPortWidth());
- if (lineHeight != UNSET)
- mLineHeight = lineHeight;
-
- if (fontSize != UNSET)
- mPaint.setTextSize(fontSize);
-
- if (fontFamily != null) {
- TypefaceUtil.applyFontStyle(mPaint, fontStyle, fontWeight, fontFamily);
- }
-
- this.dirty();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java
deleted file mode 100644
index 9053d6d..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.text.TextUtils;
-
-import com.taobao.weex.dom.flex.CSSAlign;
-
-final class CSSAlignConvert {
-
- public static CSSAlign convert2AlignItems(String s) {
- CSSAlign align = CSSAlign.STRETCH;
- if (TextUtils.isEmpty(s)) {
- align = CSSAlign.STRETCH;
- } else if (s.equals("stretch")) {
- align = CSSAlign.STRETCH;
- } else if (s.equals("flex-end")) {
- align = CSSAlign.FLEX_END;
- } else if (s.equals("auto")) {
- align = CSSAlign.AUTO;
- } else if (s.equals("center")) {
- align = CSSAlign.CENTER;
- }
-
- return align;
- }
-
- public static CSSAlign convert2AlignSelf(String s) {
- CSSAlign align = CSSAlign.AUTO;
- if (TextUtils.isEmpty(s)) {
- align = CSSAlign.AUTO;
- } else if (s.equals("flex-start")) {
- align = CSSAlign.FLEX_START;
- } else if (s.equals("flex-end")) {
- align = CSSAlign.FLEX_END;
- } else if (s.equals("stretch")) {
- align = CSSAlign.STRETCH;
- } else if (s.equals("center")) {
- align = CSSAlign.CENTER;
- }
-
- return align;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/CSSConstants.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSConstants.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSConstants.java
new file mode 100755
index 0000000..221d046
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/CSSConstants.java
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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;
+
+public class CSSConstants {
+
+ public static final float UNDEFINED = Float.NaN;
+
+ public static boolean isUndefined(float value) {
+ return Float.compare(value, UNDEFINED) == 0;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java
deleted file mode 100644
index 2e30981..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.text.TextUtils;
-
-import com.taobao.weex.dom.flex.CSSFlexDirection;
-
-class CSSFlexDirectionConvert {
-
- public static CSSFlexDirection convert(String s) {
- CSSFlexDirection cssFlexDirection = CSSFlexDirection.ROW;
- if (TextUtils.isEmpty(s)) {
- cssFlexDirection = CSSFlexDirection.ROW;
- } else if (s.equals("column")) {
- cssFlexDirection = CSSFlexDirection.COLUMN;
- } else if (s.equals("column-reverse")) {
- cssFlexDirection = CSSFlexDirection.COLUMN_REVERSE;
- } else if (s.equals("row")) {
- cssFlexDirection = CSSFlexDirection.ROW;
- } else if (s.equals("row-reverse")) {
- cssFlexDirection = CSSFlexDirection.ROW_REVERSE;
- }
- return cssFlexDirection;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java
deleted file mode 100644
index 69fff9c..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.text.TextUtils;
-
-import com.taobao.weex.dom.flex.CSSJustify;
-
-class CSSJustifyConvert {
-
- public static CSSJustify convert(String s) {
- CSSJustify cssJustify = CSSJustify.FLEX_START;
- if (TextUtils.isEmpty(s) || s.equals("flex-start")) {
- cssJustify = CSSJustify.FLEX_START;
- } else if (s.equals("flex-end")) {
- cssJustify = CSSJustify.FLEX_END;
- } else if (s.equals("center")) {
- cssJustify = CSSJustify.CENTER;
- } else if (s.equals("space-between")) {
- cssJustify = CSSJustify.SPACE_BETWEEN;
- } else if (s.equals("space-around")) {
- cssJustify = CSSJustify.SPACE_AROUND;
- }
- return cssJustify;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java
deleted file mode 100644
index 673b8be..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.text.TextUtils;
-
-import com.taobao.weex.dom.flex.CSSPositionType;
-
-class CSSPositionTypeConvert {
-
- public static CSSPositionType convert(String s) {
- CSSPositionType position = CSSPositionType.RELATIVE;
- if (TextUtils.isEmpty(s) || s.equals("relative") || s.equals("sticky")) {
- position = CSSPositionType.RELATIVE;
- } else if (s.equals("absolute") || s.equals("fixed")) {
- position = CSSPositionType.ABSOLUTE;
- }
- return position;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/CSSShorthand.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSShorthand.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSShorthand.java
new file mode 100644
index 0000000..1af2de5
--- /dev/null
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/CSSShorthand.java
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.RestrictTo;
+import com.taobao.weex.dom.CSSShorthand.CSSProperty;
+import java.util.Arrays;
+
+public class CSSShorthand<T extends Enum<? extends CSSProperty>> implements Cloneable {
+
+ interface CSSProperty{
+ }
+
+ public static enum EDGE implements CSSProperty{
+ TOP, BOTTOM, LEFT, RIGHT, ALL;
+ }
+
+ public static enum CORNER implements CSSProperty{
+ BORDER_TOP_LEFT, BORDER_TOP_RIGHT,
+ BORDER_BOTTOM_RIGHT, BORDER_BOTTOM_LEFT, ALL;
+ }
+
+ public static enum TYPE {
+ MARGIN, PADDING, BORDER;
+ }
+
+ private float[] values;
+
+ public CSSShorthand(float []values){
+ replace(values);
+ }
+
+ public CSSShorthand() {
+ this(false);
+ }
+
+ CSSShorthand(boolean fillWithNaN) {
+ values = new float[Math.max(EDGE.values().length,CORNER.values().length)];
+ if (fillWithNaN) {
+ Arrays.fill(values, Float.NaN);
+ }
+ }
+
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public void set(@NonNull EDGE edge, float value){
+ setInternal(edge, value);
+ }
+
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public void set(@NonNull CORNER edge, float value) {
+ setInternal(edge, value);
+ }
+
+ /**
+ * {@link EDGE#ALL} is not supported, 0 will be returned.
+ * @throws IndexOutOfBoundsException
+ * @param edge
+ * @return
+ */
+ public float get(@NonNull EDGE edge){
+ return getInternal(edge);
+ }
+
+ /**
+ * {@link CORNER#ALL} is not supported, 0 will be returned.
+ * @throws IndexOutOfBoundsException
+ * @param edge
+ * @return
+ */
+ public float get(@NonNull CORNER edge) {
+ return getInternal(edge);
+ }
+
+ @RestrictTo(RestrictTo.Scope.LIBRARY)
+ public final void replace(float []values){
+ this.values = values;
+ }
+
+ @Override
+ public CSSShorthand clone() throws CloneNotSupportedException {
+ return (CSSShorthand) super.clone();
+ }
+
+ private void setInternal(@NonNull Enum<? extends CSSProperty> edge, float value){
+ if (edge == EDGE.ALL || edge == CORNER.ALL) {
+ Arrays.fill(values, value);
+ } else {
+ values[edge.ordinal()] = value;
+ }
+ }
+
+ private float getInternal(@NonNull Enum<? extends CSSProperty> edge){
+ return (edge == EDGE.ALL || edge == CORNER.ALL) ? 0 : values[edge.ordinal()];
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java b/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java
deleted file mode 100644
index 9440a45..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.text.TextUtils;
-
-import com.taobao.weex.dom.flex.CSSWrap;
-
-class CSSWrapConvert {
-
- public static CSSWrap convert(String s) {
- CSSWrap cssWrap = CSSWrap.NOWRAP;
- if (TextUtils.isEmpty(s)) {
- return cssWrap;
- } else if (s.equals("wrap")) {
- return CSSWrap.WRAP;
- }
- return cssWrap;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/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
deleted file mode 100644
index 9011ade..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/DOMAction.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.dom.action.Action;
-
-/**
- * Created by sospartan on 23/02/2017.
- */
-
-public interface DOMAction extends Action{
- void executeDom(DOMActionContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/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
deleted file mode 100644
index 7668d3d..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContext.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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();
-
- void markDirty();
-
- WXSDKInstance getInstance();
-
- WXDomObject getDomByRef(String ref);
-
- @Deprecated
- WXDomObject.Consumer getRemoveElementConsumer();
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/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
deleted file mode 100644
index a8f7615..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/DOMActionContextImpl.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.text.TextUtils;
-import android.util.Pair;
-
-import com.taobao.weex.WXEnvironment;
-import com.taobao.weex.WXSDKInstance;
-import com.taobao.weex.WXSDKManager;
-import com.taobao.weex.dom.action.Actions;
-import com.taobao.weex.dom.flex.CSSLayoutContext;
-import com.taobao.weex.tracing.Stopwatch;
-import com.taobao.weex.tracing.WXTracing;
-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;
- }
- long start = System.currentTimeMillis();
- long startNanos = System.nanoTime();
- WXDomObject rootDom = mRegistry.get(WXDomObject.ROOT);
- layout(rootDom);
-
- if (WXTracing.isAvailable()) {
- WXTracing.TraceEvent batchEvent = WXTracing.newEvent("domBatch", mInstanceId, -1);
- batchEvent.duration = Stopwatch.millisUntilNow(startNanos);
- batchEvent.ts = start;
- batchEvent.ph = "X";
- WXTracing.submit(batchEvent);
- }
- if(WXEnvironment.isApkDebugable()){
- WXLogUtils.d("mInstanceId " + mInstanceId + " batch used " + (System.currentTimeMillis() - start));
- }
- }
-
- 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);
- }
-
- start = System.currentTimeMillis();
- rootDom.traverseTree( new WXDomObject.Consumer() {
- @Override
- public void accept(WXDomObject dom) {
- if (!dom.hasUpdate() || mDestroy) {
- return;
- }
- dom.layoutAfter();
- }
- }, new ApplyUpdateConsumer());
-
-
- if (instance != null) {
- instance.applyUpdateTime(System.currentTimeMillis() - start);
- }
-
- start = System.currentTimeMillis();
- updateDomObj();
- if (instance != null) {
- instance.updateDomObjTime(System.currentTimeMillis() - start);
- }
- parseAnimation();
-
- boolean isPreRenderMode = instance != null && instance.isPreRenderMode();
- if(!isPreRenderMode) {
- consumeRenderTasks();
- }
- mAddDom.clear();
- animations.clear();
- mDirty = false;
- if (instance != null) {
- instance.batchTime(System.currentTimeMillis() - start0);
- }
- }
-
- void consumeRenderTasks() {
- int count = mNormalTasks.size();
- for (int i = 0; i < count && !mDestroy; ++i) {
- mWXRenderManager.runOnThread(mInstanceId, mNormalTasks.get(i));
- }
- mNormalTasks.clear();
- }
-
- 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) {
- postRenderTask(Actions.getAnimationAction(pair.first, animationBean));
- }
- }
- }
- }
-
- /**
- * 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));
- }
- }
- }
-
- @Override
- public void addAnimationForElement(String ref, Map<String, Object> animMap) {
- animations.add(new Pair<>(ref,animMap));
- mDirty = true;
- }
-
- @Override
- public void postRenderTask(RenderAction action) {
- mNormalTasks.add(new RenderActionTask(action, mWXRenderManager.getRenderContext(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 void markDirty() {
- if(!mDestroy){
- if(!mDirty){
- mDirty = true;
- }
- }
- }
-
- @Override
- public WXSDKInstance getInstance() {
- return mWXRenderManager.getWXSDKInstance(mInstanceId);
- }
-
- @Override
- public WXDomObject getDomByRef(String ref) {
- return mRegistry.get(ref);
- }
-
- 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.getInstanceViewPortWidth(mInstanceId));
- 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/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/DomContext.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/DomContext.java b/android/sdk/src/main/java/com/taobao/weex/dom/DomContext.java
deleted file mode 100644
index ad65eeb..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/DomContext.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.content.Context;
-
-/**
- * Created by sospartan on 31/10/2016.
- */
-
-public interface DomContext {
- Context getUIContext();
- String getInstanceId();
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java
deleted file mode 100644
index c19ca59..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/ImmutableDomObject.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 com.taobao.weex.dom.flex.Spacing;
-
-/**
- * Created by sospartan on 25/10/2016.
- */
-
-public interface ImmutableDomObject {
- String getRef();
- @NonNull Spacing getMargin();
- float getLayoutWidth();
- float getLayoutHeight();
-
- /**
- * Use {@link #getCSSLayoutLeft()} ()} instead
- */
- @Deprecated
- float getLayoutX();
-
- /**
- * Use {@link #getCSSLayoutTop()} instead
- */
- @Deprecated
- float getLayoutY();
-
- public float getCSSLayoutTop();
-
- public float getCSSLayoutBottom();
-
- public float getCSSLayoutLeft();
-
- public float getCSSLayoutRight();
- boolean isFixed();
- @NonNull WXStyle getStyles();
- @NonNull WXEvent getEvents();
- @NonNull WXAttr getAttrs();
- @NonNull Spacing getPadding();
- @NonNull Spacing getBorder();
- Object getExtra();
- String getType();
-
- public final ImmutableDomObject DESTROYED = WXDomObject.DESTROYED;
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/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
deleted file mode 100644
index cb461c0..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/RenderAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.dom.action.Action;
-
-/**
- * Created by sospartan on 23/02/2017.
- */
-
-public interface RenderAction extends Action{
- void executeRender(RenderActionContext context);
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/2f8caedb/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
deleted file mode 100644
index 884cfeb..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionContext.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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/2f8caedb/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
deleted file mode 100644
index bac1574..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/dom/RenderActionTask.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.os.SystemClock;
-
-import com.taobao.weex.dom.action.AbstractAddElementAction;
-import com.taobao.weex.dom.action.TraceableAction;
-import com.taobao.weex.tracing.Stopwatch;
-import com.taobao.weex.tracing.WXTracing;
-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;
- private final long mStartMillis = SystemClock.uptimeMillis();
-
- public RenderActionTask(RenderAction action, RenderActionContext context){
- mRenderTask = action;
- mContext = context;
- }
-
- @Override
- public void execute() {
- if (WXTracing.isAvailable() && mRenderTask instanceof TraceableAction) {
- ((TraceableAction) mRenderTask).mUIQueueTime = SystemClock.uptimeMillis() - mStartMillis;
- }
- long start = System.currentTimeMillis();
- long uiNanos = System.nanoTime();
- mRenderTask.executeRender(mContext);
-
- if (WXTracing.isAvailable()) {
- uiNanos = System.nanoTime() - uiNanos;
- if (mRenderTask instanceof TraceableAction) {
- if (!(mRenderTask instanceof AbstractAddElementAction)) {
- WXTracing.TraceEvent uiExecuteEvent = WXTracing.newEvent("UIExecute", mContext.getInstance().getInstanceId(), ((TraceableAction) mRenderTask).mTracingEventId);
- uiExecuteEvent.duration = Stopwatch.nanosToMillis(uiNanos);
- uiExecuteEvent.ts = start;
- uiExecuteEvent.submit();
- }
- ((TraceableAction) mRenderTask).onFinishUIExecute();
- }
- }
- }
-}