[WEEX-407][Core] Merge to measureFunction
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a8ee2baa Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a8ee2baa Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a8ee2baa Branch: refs/heads/master Commit: a8ee2baaf26d4b85e4ee9b09cb064bce0c4b1b6f Parents: 0d96006 Author: miomin <miomin...@foxmail.com> Authored: Fri May 25 16:24:22 2018 +0800 Committer: YorkShen <shenyua...@gmail.com> Committed: Tue May 29 14:57:27 2018 +0800 ---------------------------------------------------------------------- .../java/com/taobao/weex/bridge/WXBridge.java | 7 -- .../com/taobao/weex/bridge/WXBridgeManager.java | 4 - .../java/com/taobao/weex/common/IWXBridge.java | 2 - .../android/bridge/impl/bridge_impl_android.cpp | 2 +- .../android/bridge/impl/bridge_impl_android.h | 2 +- .../bridge/impl/jsfunction_impl_android.cpp | 16 ++-- .../bridge/impl/weexcore_impl_android.cpp | 7 +- .../android/jsengine/multiprocess/WeexProxy.cpp | 2 + weex_core/Source/core/api/WeexJSCoreApi.cpp | 4 +- weex_core/Source/core/bridge/bridge.h | 2 +- .../Source/core/layout/measure_func_adapter.h | 46 ++++++++++ .../layout/measure_func_adapter_impl_android.h | 88 ++++++++++++++++++++ .../core/layout/measure_func_adapter_impl_ios.h | 55 ++++++++++++ .../Source/core/render/manager/render_manager.h | 13 ++- .../Source/core/render/node/render_object.cpp | 54 +++--------- .../Source/core/render/node/render_object.h | 8 +- 16 files changed, 229 insertions(+), 83 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java index c674ed6..6315a4f 100644 --- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java +++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridge.java @@ -66,8 +66,6 @@ public class WXBridge implements IWXBridge { private native void nativeBindMeasurementToRenderObject(long ptr); - private native void nativeBindMeasurementToWXCore(String instanceId, String ref); - private native void nativeSetRenderContainerWrapContent(boolean wrap, String instanceId); public native long[] nativeGetFirstScreenRenderTime(String instanceId); @@ -480,11 +478,6 @@ public class WXBridge implements IWXBridge { } @Override - public void bindMeasurementToWXCore(String instanceId, String ref) { - nativeBindMeasurementToWXCore(instanceId, ref); - } - - @Override public ContentBoxMeasurement getMeasurementFunc(String instanceId, String ref) { ContentBoxMeasurement obj = null; try { http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/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 1e4fa90..42f96fb 100644 --- a/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java +++ b/android/sdk/src/main/java/com/taobao/weex/bridge/WXBridgeManager.java @@ -2605,10 +2605,6 @@ public class WXBridgeManager implements Callback, BactchExecutor { return IWXBridge.INSTANCE_RENDERING; } - public void bindMeasurementToWXCore(String instanceId, String ref) { - mWXBridge.bindMeasurementToWXCore(instanceId, ref); - } - public ContentBoxMeasurement getMeasurementFunc(String instanceId, String ref) { ContentBoxMeasurement contentBoxMeasurement = null; WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/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 ee9100b..56c7c8e 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 @@ -154,8 +154,6 @@ public interface IWXBridge extends IWXObject { int callHasTransitionPros(String instanceId, String ref, HashMap<String, String> styles); - void bindMeasurementToWXCore(String instanceId, String ref); - ContentBoxMeasurement getMeasurementFunc(String instanceId, String ref); void bindMeasurementToRenderObject(long ptr); http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/android/bridge/impl/bridge_impl_android.cpp ---------------------------------------------------------------------- diff --git a/weex_core/Source/android/bridge/impl/bridge_impl_android.cpp b/weex_core/Source/android/bridge/impl/bridge_impl_android.cpp index fa230cd..634cf56 100644 --- a/weex_core/Source/android/bridge/impl/bridge_impl_android.cpp +++ b/weex_core/Source/android/bridge/impl/bridge_impl_android.cpp @@ -220,7 +220,7 @@ namespace WeexCore { return flag; } - jobject Bridge_Impl_Android::callNativeModule(const char* pageId, const char *module, const char *method, + void* Bridge_Impl_Android::callNativeModule(const char* pageId, const char *module, const char *method, const char *arguments, int argumentsLen, const char *options, int optionsLen) { RenderPage *page = RenderManager::GetInstance()->GetPage(pageId); long long startTime = getCurrentTime(); http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/android/bridge/impl/bridge_impl_android.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/android/bridge/impl/bridge_impl_android.h b/weex_core/Source/android/bridge/impl/bridge_impl_android.h index 0272ae5..72d14b5 100644 --- a/weex_core/Source/android/bridge/impl/bridge_impl_android.h +++ b/weex_core/Source/android/bridge/impl/bridge_impl_android.h @@ -68,7 +68,7 @@ namespace WeexCore { int callNative(const char* pageId, const char *task, const char *callback); - jobject callNativeModule(const char* pageId, const char *module, const char *method, + void* callNativeModule(const char* pageId, const char *module, const char *method, const char *arguments, int argumentsLength, const char *options, int optionsLength); void callNativeComponent(const char* pageId, const char* ref, const char *method, http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/android/bridge/impl/jsfunction_impl_android.cpp ---------------------------------------------------------------------- diff --git a/weex_core/Source/android/bridge/impl/jsfunction_impl_android.cpp b/weex_core/Source/android/bridge/impl/jsfunction_impl_android.cpp index e5e89af..1a50fb8 100644 --- a/weex_core/Source/android/bridge/impl/jsfunction_impl_android.cpp +++ b/weex_core/Source/android/bridge/impl/jsfunction_impl_android.cpp @@ -111,14 +111,14 @@ jsHandleCallNativeModule(JNIEnv *env, jobject object, jstring instanceId, jstrin // add for android support jobject result; - result = Bridge_Impl_Android::getInstance()->callNativeModule( - getCharFromJString(env, instanceId), - getCharFromJString(env, module), - getCharFromJString(env, method), - getCharFromJByte(env, arguments), - getJByteArraySize(env, arguments), - getCharFromJByte(env, options), - getJByteArraySize(env, options)); + result = static_cast<jobject>(Bridge_Impl_Android::getInstance()->callNativeModule( + getCharFromJString(env, instanceId), + getCharFromJString(env, module), + getCharFromJString(env, method), + getCharFromJByte(env, arguments), + getJByteArraySize(env, arguments), + getCharFromJByte(env, options), + getJByteArraySize(env, options))); jfieldID jTypeId = env->GetFieldID(jWXJSObject, "type", "I"); jint jTypeInt = env->GetIntField(result, jTypeId); http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/android/bridge/impl/weexcore_impl_android.cpp ---------------------------------------------------------------------- diff --git a/weex_core/Source/android/bridge/impl/weexcore_impl_android.cpp b/weex_core/Source/android/bridge/impl/weexcore_impl_android.cpp index 8e206ed..c73b7e7 100644 --- a/weex_core/Source/android/bridge/impl/weexcore_impl_android.cpp +++ b/weex_core/Source/android/bridge/impl/weexcore_impl_android.cpp @@ -109,7 +109,7 @@ static void BindMeasurementToRenderObject(JNIEnv* env, jobject jcaller, jlong ptr){ RenderObject *render = convert_long_to_render_object(ptr); if(render){ - render->BindMeasureFuncImplAndroid(); + render->BindMeasureFunc(); } } @@ -209,11 +209,6 @@ static jboolean NotifyLayout(JNIEnv* env, jobject jcaller, jstring instanceId) { RenderPage *page = RenderManager::GetInstance()->GetPage(jString2StrFast(env, instanceId)); if (page != nullptr) { -//#if RENDER_LOG -// LOGD("[JNI] NotifyLayout >>>> pageId: %s, needForceLayout: %s, dirty: %s", jString2StrFast(env, instanceId).c_str(), -// page->needLayout.load() ? "true" : "false", page->isDirty() ? "true" : "false"); -//#endif - if (!page->needLayout.load()) { page->needLayout.store(true); } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp ---------------------------------------------------------------------- diff --git a/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp b/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp index 0c8f70c..8014a41 100644 --- a/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp +++ b/weex_core/Source/android/jsengine/multiprocess/WeexProxy.cpp @@ -27,6 +27,7 @@ #include <dlfcn.h> #include <errno.h> +#include <core/layout/measure_func_adapter_impl_android.h> const char *s_cacheDir; bool s_start_pie = true; @@ -264,6 +265,7 @@ namespace WeexCore { jobject params) { Bridge_Impl_Android::getInstance()->setGlobalRef(jThis); + RenderManager::GetInstance()->SetMeasureFunctionAdapter(new MeasureFunctionAdapterImplAndroid()); std::unique_ptr<IPCSerializer> serializer(createIPCSerializer()); const std::vector<INIT_FRAMEWORK_PARAMS *> &initFrameworkParams = initFromParam(env, script, http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/api/WeexJSCoreApi.cpp ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/api/WeexJSCoreApi.cpp b/weex_core/Source/core/api/WeexJSCoreApi.cpp index 70ca722..a1bd22c 100644 --- a/weex_core/Source/core/api/WeexJSCoreApi.cpp +++ b/weex_core/Source/core/api/WeexJSCoreApi.cpp @@ -67,8 +67,8 @@ _callNativeModule(const char *pageId, const char *module, const char *method, // add for android support jobject result; - result = Bridge_Impl_Android::getInstance()->callNativeModule(pageId, module, method, - arguments, argumentsLength, options, optionsLength); + result = static_cast<jobject>(Bridge_Impl_Android::getInstance()->callNativeModule(pageId, module, method, + arguments, argumentsLength, options, optionsLength)); if (result == nullptr){ return ret; } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/bridge/bridge.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/bridge/bridge.h b/weex_core/Source/core/bridge/bridge.h index 591bb89..ab67fff 100644 --- a/weex_core/Source/core/bridge/bridge.h +++ b/weex_core/Source/core/bridge/bridge.h @@ -41,7 +41,7 @@ namespace WeexCore { virtual int callNative(const char* pageId, const char *task, const char *callback) = 0; - virtual jobject callNativeModule(const char* pageId, const char *module, const char *method, + virtual void* callNativeModule(const char* pageId, const char *module, const char *method, const char *arguments, int argumentsLength, const char *options, int optionsLength) = 0; virtual void callNativeComponent(const char* pageId, const char* ref, const char *method, http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/layout/measure_func_adapter.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/layout/measure_func_adapter.h b/weex_core/Source/core/layout/measure_func_adapter.h new file mode 100644 index 0000000..8e6b159 --- /dev/null +++ b/weex_core/Source/core/layout/measure_func_adapter.h @@ -0,0 +1,46 @@ +/** + * 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. + */ +#ifndef WEEX_CORE_MEASURE_FUNCTION_H +#define WEEX_CORE_MEASURE_FUNCTION_H + + +#include "layout.h" + +namespace WeexCore { + + class MeasureFunctionAdapter { + public: + + MeasureFunctionAdapter() {} + + ~MeasureFunctionAdapter() {} + + virtual WXCoreSize Measure(WXCoreLayoutNode *node, float width, MeasureMode widthMeasureMode, + float height, MeasureMode heightMeasureMode) = 0; + + virtual void LayoutBefore(WXCoreLayoutNode *node) = 0; + + virtual void LayoutAfter(WXCoreLayoutNode *node, float width, float height) = 0; + + private: + }; + +} + +#endif //WEEX_CORE_MEASURE_FUNCTION_H http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/layout/measure_func_adapter_impl_android.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/layout/measure_func_adapter_impl_android.h b/weex_core/Source/core/layout/measure_func_adapter_impl_android.h new file mode 100644 index 0000000..f165233 --- /dev/null +++ b/weex_core/Source/core/layout/measure_func_adapter_impl_android.h @@ -0,0 +1,88 @@ +/** + * 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. + */ +#include "measure_func_adapter.h" +#include <core/render/node/render_object.h> +#include <android/bridge/impl/content_box_measurement_impl_android.h> +#include <android/bridge/impl/measure_mode_impl_android.h> +#include <android/base/jni/scoped_java_ref.h> + +namespace WeexCore { + + + class MeasureFunctionAdapterImplAndroid : public MeasureFunctionAdapter { + public: + + MeasureFunctionAdapterImplAndroid() {} + + ~MeasureFunctionAdapterImplAndroid() {} + + inline WXCoreSize Measure(WXCoreLayoutNode *node, float width, + MeasureMode widthMeasureMode, float height, + MeasureMode heightMeasureMode) { + WXCoreSize size; + size.height = 0; + size.width = 0; + + jobject measureFunc = static_cast<jobject>(((RenderObject *) node)->GetMeasureFuncFromComponent()); + + if (node == nullptr || measureFunc == nullptr) { + return size; + } + + JNIEnv *env = getJNIEnv(); + + int widthMode = Unspecified(env); + int heightMode = Unspecified(env); + if (widthMeasureMode == kExactly) + widthMode = Exactly(env); + if (heightMeasureMode == kExactly) + heightMode = Exactly(env); + cumsmeasure_Imple_Android(env, measureFunc, + width, height, + widthMode, heightMode); + size.width = GetLayoutWidth(env, measureFunc); + size.height = GetLayoutHeight(env, measureFunc); + + env->DeleteLocalRef(measureFunc); + + return size; + } + + inline void LayoutBefore(WXCoreLayoutNode *node) { + jobject measureFunc = static_cast<jobject>(((RenderObject *) node)->GetMeasureFuncFromComponent()); + if(nullptr == measureFunc) { + return; + } + + JNIEnv *env = getJNIEnv(); + LayoutBeforeImplAndroid(env, measureFunc); + env->DeleteLocalRef(measureFunc); + } + + inline void LayoutAfter(WXCoreLayoutNode *node, float width, float height) { + jobject measureFunc = static_cast<jobject>(((RenderObject *) node)->GetMeasureFuncFromComponent()); + if(nullptr == measureFunc) { + return; + } + JNIEnv *env = getJNIEnv(); + LayoutAfterImplAndroid(env, measureFunc, width, height); + env->DeleteLocalRef(measureFunc); + } + }; +} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/layout/measure_func_adapter_impl_ios.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/layout/measure_func_adapter_impl_ios.h b/weex_core/Source/core/layout/measure_func_adapter_impl_ios.h new file mode 100644 index 0000000..03b53d8 --- /dev/null +++ b/weex_core/Source/core/layout/measure_func_adapter_impl_ios.h @@ -0,0 +1,55 @@ +/** + * 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. + */ +#include "measure_func_adapter.h" +#include <core/render/node/render_object.h> +#include <android/bridge/impl/content_box_measurement_impl_android.h> +#include <android/bridge/impl/measure_mode_impl_android.h> +#include <android/base/jni/scoped_java_ref.h> + +namespace WeexCore { + + + class MeasureFunctionAdapterImplIOS : public MeasureFunctionAdapter { + public: + + MeasureFunctionAdapterImplIOS() {} + + ~MeasureFunctionAdapterImplIOS() {} + + inline WXCoreSize Measure(WXCoreLayoutNode *node, float width, + MeasureMode widthMeasureMode, float height, + MeasureMode heightMeasureMode) { + WXCoreSize size; + size.height = 0; + size.width = 0; + + // TODO + + return size; + } + + inline void LayoutBefore(WXCoreLayoutNode *node) { + + } + + inline void LayoutAfter(WXCoreLayoutNode *node, float width, float height) { + + } + }; +} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/render/manager/render_manager.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/render/manager/render_manager.h b/weex_core/Source/core/render/manager/render_manager.h index fb91605..a1bf04b 100644 --- a/weex_core/Source/core/render/manager/render_manager.h +++ b/weex_core/Source/core/render/manager/render_manager.h @@ -22,6 +22,7 @@ #include <map> #include <string> #include <stdbool.h> +#include <core/layout/measure_func_adapter.h> namespace WeexCore { @@ -59,8 +60,7 @@ namespace WeexCore { bool RemoveRenderObject(const std::string &pageId, const std::string &ref); - bool - MoveRenderObject(const std::string &pageId, const std::string &ref, + bool MoveRenderObject(const std::string &pageId, const std::string &ref, const std::string &parentRef, int index); bool UpdateAttr(const std::string &pageId, const std::string &ref, const char* data); @@ -84,8 +84,17 @@ namespace WeexCore { return m_pInstance; } + void SetMeasureFunctionAdapter(MeasureFunctionAdapter *measureFunctionAdapter) { + this->m_pMeasureFunctionAdapter = measureFunctionAdapter; + } + + MeasureFunctionAdapter *GetMeasureFunctionAdapter() { + return this->m_pMeasureFunctionAdapter; + } + private: static RenderManager *m_pInstance; + MeasureFunctionAdapter *m_pMeasureFunctionAdapter; std::map<std::string, RenderPage *> mPages; }; } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/render/node/render_object.cpp ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/render/node/render_object.cpp b/weex_core/Source/core/render/node/render_object.cpp index 683fa62..d1d2cce 100644 --- a/weex_core/Source/core/render/node/render_object.cpp +++ b/weex_core/Source/core/render/node/render_object.cpp @@ -22,7 +22,7 @@ #include <android/base/jni/scoped_java_ref.h> #include <android/bridge/impl/weexcore_impl_android.h> #include <android/base/string/string_utils.h> -#include <string.h> +#include <core/layout/measure_func_adapter.h> using namespace std; namespace WeexCore { @@ -36,8 +36,6 @@ namespace WeexCore { RenderObject::~RenderObject() { - JNIEnv *env = getJNIEnv(); - mParentRender = nullptr; if (mStyles != nullptr) { @@ -99,57 +97,27 @@ namespace WeexCore { size.height = 0; size.width = 0; - jobject measureFunc = ((RenderObject *) node)->GetMeasureFuncImplAndroid(); - - if (node == nullptr || measureFunc == nullptr) { + if (RenderManager::GetInstance()->GetMeasureFunctionAdapter() == nullptr) return size; - } - - JNIEnv *env = getJNIEnv(); - int widthMode = Unspecified(env); - int heightMode = Unspecified(env); - if (widthMeasureMode == kExactly) - widthMode = Exactly(env); - if (heightMeasureMode == kExactly) - heightMode = Exactly(env); - cumsmeasure_Imple_Android(env, measureFunc, - width, height, - widthMode, heightMode); - size.width = GetLayoutWidth(env, measureFunc); - size.height = GetLayoutHeight(env, measureFunc); - - env->DeleteLocalRef(measureFunc); - - return size; + return RenderManager::GetInstance()->GetMeasureFunctionAdapter()->Measure(node, width, widthMeasureMode, height, heightMeasureMode); } - void RenderObject::BindMeasureFuncImplAndroid() { + void RenderObject::BindMeasureFunc() { setMeasureFunc(measureFunc_Impl); } - void RenderObject::BindMeasureFuncImplIOS(WXCoreMeasureFunc measureFunc_impl_ios) { - setMeasureFunc(measureFunc_impl_ios); - } - void RenderObject::onLayoutBefore() { - jobject measureFunc = this->GetMeasureFuncImplAndroid(); - if(nullptr == measureFunc) { - return; - } + if (RenderManager::GetInstance()->GetMeasureFunctionAdapter() == nullptr) + return; - JNIEnv *env = getJNIEnv(); - LayoutBeforeImplAndroid(env, measureFunc); - env->DeleteLocalRef(measureFunc); + RenderManager::GetInstance()->GetMeasureFunctionAdapter()->LayoutBefore(this); } void RenderObject::onLayoutAfter(float width, float height) { - jobject measureFunc = this->GetMeasureFuncImplAndroid(); - if(nullptr == measureFunc) { - return; - } - JNIEnv *env = getJNIEnv(); - LayoutAfterImplAndroid(env, measureFunc, width, height); - env->DeleteLocalRef(measureFunc); + if (RenderManager::GetInstance()->GetMeasureFunctionAdapter() == nullptr) + return; + + RenderManager::GetInstance()->GetMeasureFunctionAdapter()->LayoutAfter(this, width, height); } } //end WeexCore http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a8ee2baa/weex_core/Source/core/render/node/render_object.h ---------------------------------------------------------------------- diff --git a/weex_core/Source/core/render/node/render_object.h b/weex_core/Source/core/render/node/render_object.h index 195c798..cc86207 100644 --- a/weex_core/Source/core/render/node/render_object.h +++ b/weex_core/Source/core/render/node/render_object.h @@ -143,16 +143,12 @@ namespace WeexCore { ~RenderObject(); - void BindMeasureFuncImplAndroid(); - - void BindMeasureFuncImplIOS(WXCoreMeasureFunc measureFunc_impl_ios); + void BindMeasureFunc(); void onLayoutBefore(); void onLayoutAfter(float width, float height); - - virtual StyleType ApplyStyle(const std::string &key, const std::string &value, const bool updating) { bool insert = false; if(value.length() > 0 && (value.at(0) == JSON_OBJECT_MARK_CHAR || value.at(0) == JSON_ARRAY_MARK_CHAR)){ @@ -283,7 +279,7 @@ namespace WeexCore { void ApplyDefaultAttr(); - inline jobject GetMeasureFuncImplAndroid() { + inline void* GetMeasureFuncFromComponent() { if (!haveMeasureFunc()) { return nullptr; }