Repository: incubator-weex
Updated Branches:
  refs/heads/master ad1d9b4f9 -> dd60f6fd7


[WEEX-386] Fix waterfall updateAttr


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/dd60f6fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/dd60f6fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/dd60f6fd

Branch: refs/heads/master
Commit: dd60f6fd7f90a86c5706a0c18e579f465d4e757f
Parents: ad1d9b4
Author: miomin <miomin...@foxmail.com>
Authored: Thu May 24 19:19:25 2018 +0800
Committer: miomin <miomin...@foxmail.com>
Committed: Sun May 27 00:24:35 2018 +0800

----------------------------------------------------------------------
 weex_core/Source/core/render/node/render_list.h | 36 ++++++++++----------
 .../Source/core/render/page/render_page.cpp     | 17 +++++++++
 weex_core/Source/core/render/page/render_page.h |  2 ++
 3 files changed, 37 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dd60f6fd/weex_core/Source/core/render/node/render_list.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_list.h 
b/weex_core/Source/core/render/node/render_list.h
index 2cb0897..ab22409 100644
--- a/weex_core/Source/core/render/node/render_list.h
+++ b/weex_core/Source/core/render/node/render_list.h
@@ -117,13 +117,13 @@ namespace WeexCore {
 
     std::map<std::string, std::string> *GetDefaultAttr() {
       if (!mIsPreCalculateCellWidth) {
-        return preCalculateCellWidth();
+        preCalculateCellWidth();
       }
       return nullptr;
     }
 
 
-    std::map<std::string, std::string> *preCalculateCellWidth() {
+    inline void preCalculateCellWidth() {
         std::map<std::string, std::string> *attrs = new std::map<std::string, 
std::string>();
         if (Attributes() != nullptr) {
             mColumnCount = getColumnCount();
@@ -170,8 +170,22 @@ namespace WeexCore {
             if (spanOffsets.length() > 0) {
                 attrs->insert(std::pair<std::string, 
std::string>(SPAN_OFFSETS, to_string(spanOffsets)));
             }
+
+            for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
+              RenderObject::UpdateAttr(iter->first, iter->second);
+            }
         }
-        return attrs;
+
+      RenderPage *page = GetRenderPage();
+
+      if (page != nullptr)
+        page->SendUpdateAttrAction(this, attrs);
+
+      if (attrs != nullptr) {
+        attrs->clear();
+        delete attrs;
+        attrs = nullptr;
+      }
     }
 
     std::string calcSpanOffset() {
@@ -239,25 +253,11 @@ namespace WeexCore {
         }
     }
 
-    void UpdatePreCalculateCellAttrs(std::map<std::string, std::string> * 
attrs){
-        if (attrs == nullptr){
-            return;
-        }
-
-        for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
-            RenderObject::UpdateAttr(iter->first, iter->second);
-        }
-        if (attrs != nullptr) {
-            delete attrs;
-            attrs = nullptr;
-        }
-    }
-
     void UpdateAttr(std::string key, std::string value) {
       RenderObject::UpdateAttr(key, value);
 
       if(!GetAttr(COLUMN_COUNT).empty() || !GetAttr(COLUMN_GAP).empty() || 
!GetAttr(COLUMN_WIDTH).empty()){
-          UpdatePreCalculateCellAttrs(preCalculateCellWidth());
+          preCalculateCellWidth();
 
         if(mColumnWidth == 0 && isnan(mColumnWidth)) {
           return;

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dd60f6fd/weex_core/Source/core/render/page/render_page.cpp
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/page/render_page.cpp 
b/weex_core/Source/core/render/page/render_page.cpp
index 5575692..592b35f 100644
--- a/weex_core/Source/core/render/page/render_page.cpp
+++ b/weex_core/Source/core/render/page/render_page.cpp
@@ -557,6 +557,23 @@ namespace WeexCore {
     PostRenderAction(action);
   }
 
+  void RenderPage::SendUpdateAttrAction(RenderObject *render,
+                                        std::map<std::string, std::string> 
*attrs) {
+    std::vector<std::pair<std::string, std::string>> *vAttrs = new 
std::vector<std::pair<std::string, std::string>>();
+    for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
+      vAttrs->insert(vAttrs->begin(), std::pair<std::string, 
std::string>(iter->first, iter->second));
+    }
+
+    render_action *action = new RenderActionUpdateAttr(PageId(), 
render->Ref(), vAttrs);
+    PostRenderAction(action);
+
+    if (vAttrs != nullptr) {
+      vAttrs->clear();
+      delete vAttrs;
+      vAttrs = nullptr;
+    }
+  }
+
   void RenderPage::SendCreateFinishAction() {
     render_action *action = new RenderActionCreateFinish(PageId());
     PostRenderAction(action);

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/dd60f6fd/weex_core/Source/core/render/page/render_page.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/page/render_page.h 
b/weex_core/Source/core/render/page/render_page.h
index 4a96a87..dacda5a 100644
--- a/weex_core/Source/core/render/page/render_page.h
+++ b/weex_core/Source/core/render/page/render_page.h
@@ -115,6 +115,8 @@ namespace WeexCore {
 
     void LayoutImmediately();
 
+    void SendUpdateAttrAction(RenderObject *render, std::map<std::string, 
std::string> *attrs);
+
     inline RenderObject *GetRenderObject(const std::string &ref) {
         std::map<std::string, RenderObject *>::iterator iter = 
mRenderObjectRegisterMap.find(ref);
         if (iter != mRenderObjectRegisterMap.end()) {

Reply via email to