You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2018/06/19 09:40:56 UTC

[09/50] [abbrv] incubator-weex git commit: [WEEX-442][Core] Using clang-format

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/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 91c9a16..8f50bff 100644
--- a/weex_core/Source/core/render/node/render_object.h
+++ b/weex_core/Source/core/render/node/render_object.h
@@ -16,154 +16,144 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef RenderObject_h
-#define RenderObject_h
+#ifndef CORE_RENDER_NODE_RENDER_OBJECT_H_
+#define CORE_RENDER_NODE_RENDER_OBJECT_H_
 
-#include <string>
+#include <functional>
 #include <map>
 #include <set>
-#include <functional>
+#include <string>
 
 #include "core/render/node/factory/render_object_interface.h"
 
-#define JSON_OBJECT_MARK_CHAR  '{'
-#define JSON_ARRAY_MARK_CHAR  '['
+#define JSON_OBJECT_MARK_CHAR '{'
+#define JSON_ARRAY_MARK_CHAR '['
 
-#define convert_render_object_to_long(render)    ((jlong)((intptr_t)render))
+#define convert_render_object_to_long(render) ((jlong)((intptr_t)render))
 
-#define convert_long_to_render_object(ptr)   ((RenderObject *)((intptr_t)ptr))
+#define convert_long_to_render_object(ptr) \
+  (static_cast<RenderObject *>((intptr_t)ptr))
 
 namespace WeexCore {
 
-  class RenderObject;
-
-  class RenderPage;
-
-  typedef enum StyleType {
-    kTypeStyle, kTypeLayout, kTypeMargin, kTypePadding, kTypeBorder
-  } StyleType;
-
-  class RenderObject : public IRenderObject {
-
-    friend class RenderPage;
-
-  public:
-
-    void LayoutBeforeImpl();
+class RenderObject;
 
-    void LayoutAfterImpl();
+class RenderPage;
 
-    void CopyFrom(RenderObject *src);
+typedef enum StyleType {
+  kTypeStyle,
+  kTypeLayout,
+  kTypeMargin,
+  kTypePadding,
+  kTypeBorder
+} StyleType;
 
-    void MapInsertOrAssign(std::map<std::string, std::string> *targetMap, const std::string &key,
-                           const std::string &value);
+class RenderObject : public IRenderObject {
+  friend class RenderPage;
 
-    bool ViewInit();
+ public:
+  void LayoutBeforeImpl();
 
-    virtual std::map<std::string, std::string> *GetDefaultStyle() {
-      return nullptr;
-    }
+  void LayoutAfterImpl();
 
-    virtual std::map<std::string, std::string> *GetDefaultAttr() {
-      return nullptr;
-    }
+  void CopyFrom(RenderObject *src);
 
-  protected:
+  void MapInsertOrAssign(std::map<std::string, std::string> *targetMap,
+                         const std::string &key, const std::string &value);
 
-    bool UpdateStyleInternal(const std::string key, const std::string value, float fallback,
-                             std::function<void(float)> functor);
+  bool ViewInit();
 
-  public:
+  virtual std::map<std::string, std::string> *GetDefaultStyle() {
+    return nullptr;
+  }
 
-    explicit RenderObject();
+  virtual std::map<std::string, std::string> *GetDefaultAttr() {
+    return nullptr;
+  }
 
-    ~RenderObject();
+ protected:
+  bool UpdateStyleInternal(const std::string key, const std::string value,
+                           float fallback, std::function<void(float)> functor);
 
-    void BindMeasureFunc();
+ public:
+  RenderObject();
 
-    void OnLayoutBefore();
+  ~RenderObject();
 
-    void OnLayoutAfter(float width, float height);
+  void BindMeasureFunc();
 
-    virtual StyleType ApplyStyle(const std::string &key, const std::string &value, const bool updating);
+  void OnLayoutBefore();
 
-    void ApplyDefaultStyle();
+  void OnLayoutAfter(float width, float height);
 
-    void ApplyDefaultAttr();
+  virtual StyleType ApplyStyle(const std::string &key, const std::string &value,
+                               const bool updating);
 
-    Index IndexOf(const RenderObject *render);
+  void ApplyDefaultStyle();
 
-    virtual int AddRenderObject(int index, RenderObject *child);
+  void ApplyDefaultAttr();
 
-    float GetViewPortWidth();
+  Index IndexOf(const RenderObject *render);
 
-    const std::string GetAttr(const std::string &key);
+  virtual int AddRenderObject(int index, RenderObject *child);
 
-    const std::string GetStyle(const std::string &key);
+  float GetViewPortWidth();
 
-    RenderPage *GetRenderPage();
+  const std::string GetAttr(const std::string &key);
 
-    virtual void UpdateAttr(std::string key, std::string value);
+  const std::string GetStyle(const std::string &key);
 
-    virtual StyleType UpdateStyle(std::string key, std::string value);
+  RenderPage *GetRenderPage();
 
-    bool IsAppendTree();
+  virtual void UpdateAttr(std::string key, std::string value);
 
-    RenderObject *GetChild(const Index &index);
+  virtual StyleType UpdateStyle(std::string key, std::string value);
 
-    void RemoveRenderObject(RenderObject *child);
+  bool IsAppendTree();
 
-    void AddAttr(std::string key, std::string value);
+  RenderObject *GetChild(const Index &index);
 
-    StyleType AddStyle(std::string key, std::string value);
+  void RemoveRenderObject(RenderObject *child);
 
-    void AddEvent(std::string event);
+  void AddAttr(std::string key, std::string value);
 
-    void RemoveEvent(const std::string &event);
+  StyleType AddStyle(std::string key, std::string value);
 
-  public:
+  void AddEvent(std::string event);
 
-    inline void set_parent_render(RenderObject *render) {
-      this->parent_render_ = render;
-    }
+  void RemoveEvent(const std::string &event);
 
-    inline RenderObject *parent_render() {
-      return this->parent_render_;
-    }
+ public:
+  inline void set_parent_render(RenderObject *render) {
+    this->parent_render_ = render;
+  }
 
-    inline std::map<std::string, std::string> *styles() const {
-      return this->styles_;
-    }
+  inline RenderObject *parent_render() { return this->parent_render_; }
 
-    inline std::map<std::string, std::string> * attributes() const {
-      return this->attributes_;
-    }
+  inline std::map<std::string, std::string> *styles() const {
+    return this->styles_;
+  }
 
-    inline std::set<std::string> *events() const {
-      return this->events_;
-    }
+  inline std::map<std::string, std::string> *attributes() const {
+    return this->attributes_;
+  }
 
-    inline void set_is_root_render() {
-      this->is_root_render_ = true;
-    }
+  inline std::set<std::string> *events() const { return this->events_; }
 
-    inline bool is_root_render() {
-      return this->is_root_render_;
-    }
+  inline void set_is_root_render() { this->is_root_render_ = true; }
 
-    inline bool is_sticky() {
-      return this->is_sticky_;
-    }
+  inline bool is_root_render() { return this->is_root_render_; }
 
-  private:
+  inline bool is_sticky() { return this->is_sticky_; }
 
-    RenderObject *parent_render_;
-    std::map<std::string, std::string> *styles_;
-    std::map<std::string, std::string> *attributes_;
-    std::set<std::string> *events_;
-    float viewport_width_ = -1;
-    bool is_root_render_;
-    bool is_sticky_ = false;
-  };
-} //end WeexCore
-#endif //RenderObject_h
+ private:
+  RenderObject *parent_render_;
+  std::map<std::string, std::string> *styles_;
+  std::map<std::string, std::string> *attributes_;
+  std::set<std::string> *events_;
+  float viewport_width_ = -1;
+  bool is_root_render_;
+  bool is_sticky_ = false;
+};
+}  // namespace WeexCore
+#endif  // CORE_RENDER_NODE_RENDER_OBJECT_H_

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_scroller.cpp
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_scroller.cpp b/weex_core/Source/core/render/node/render_scroller.cpp
index 139af5e..7fcdfc6 100644
--- a/weex_core/Source/core/render/node/render_scroller.cpp
+++ b/weex_core/Source/core/render/node/render_scroller.cpp
@@ -16,36 +16,40 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#include "core/render/node/render_scroller.h"
+
+#include <utility>
+
 #include "core/css/constants_name.h"
+#include "core/render/node/render_scroller.h"
 
 namespace WeexCore {
 
-  std::map<std::string, std::string> *RenderScroller::GetDefaultStyle() {
-    std::map<std::string, std::string> *style = new std::map<std::string, std::string>();
+std::map<std::string, std::string> *RenderScroller::GetDefaultStyle() {
+  std::map<std::string, std::string> *style =
+      new std::map<std::string, std::string>();
 
-    bool isVertical = true;
-    RenderObject *parent = (RenderObject *) getParent();
+  bool is_vertical = true;
+  RenderObject *parent = dynamic_cast<RenderObject *>(getParent());
 
-    if (parent != nullptr) {
-      if (parent->GetAttr(SCROLL_DIRECTION) == HORIZONTAL) {
-        isVertical = false;
-      }
+  if (parent != nullptr) {
+    if (parent->GetAttr(SCROLL_DIRECTION) == HORIZONTAL) {
+      is_vertical = false;
     }
+  }
 
-    std::string prop = isVertical ? HEIGHT : WIDTH;
-
-    if (prop == HEIGHT && isnan(getStyleHeight()) && !this->is_set_flex_) {
-      style->insert(std::pair<std::string, std::string>(FLEX, "1"));
-    } else if (prop == WIDTH && isnan(getStyleWidth()) && !this->is_set_flex_) {
-      style->insert(std::pair<std::string, std::string>(FLEX, "1"));
-    }
+  std::string prop = is_vertical ? HEIGHT : WIDTH;
 
-    return style;
+  if (prop == HEIGHT && isnan(getStyleHeight()) && !this->is_set_flex_) {
+    style->insert(std::pair<std::string, std::string>(FLEX, "1"));
+  } else if (prop == WIDTH && isnan(getStyleWidth()) && !this->is_set_flex_) {
+    style->insert(std::pair<std::string, std::string>(FLEX, "1"));
   }
 
-  void RenderScroller::set_flex(const float flex) {
-    this->is_set_flex_ = true;
-    WXCoreLayoutNode::set_flex(flex);
-  }
+  return style;
+}
+
+void RenderScroller::set_flex(const float flex) {
+  this->is_set_flex_ = true;
+  WXCoreLayoutNode::set_flex(flex);
 }
+}  // namespace WeexCore

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_scroller.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_scroller.h b/weex_core/Source/core/render/node/render_scroller.h
index fed8f0b..65e4f01 100644
--- a/weex_core/Source/core/render/node/render_scroller.h
+++ b/weex_core/Source/core/render/node/render_scroller.h
@@ -16,25 +16,27 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef WEEX_PROJECT_RENDERSCROLLER_H
-#define WEEX_PROJECT_RENDERSCROLLER_H
+#ifndef CORE_RENDER_NODE_RENDER_SCROLLER_H_
+#define CORE_RENDER_NODE_RENDER_SCROLLER_H_
+
+#include <map>
+#include <string>
 
 #include "core/render/node/render_object.h"
 
 namespace WeexCore {
-  class RenderScroller : public RenderObject {
-
-    bool is_set_flex_ = false;
-
-    std::map<std::string, std::string> *GetDefaultStyle();
+class RenderScroller : public RenderObject {
+  bool is_set_flex_ = false;
 
-    void set_flex(const float flex);
+  std::map<std::string, std::string> *GetDefaultStyle();
 
-    inline float CalculateFreeSpaceAlongMainAxis(const float &width, const float &height,
-                                     const float &current_length) const override {
-      return NAN;
-    }
+  void set_flex(const float flex);
 
-  };
-}
-#endif //WEEX_PROJECT_RENDERSCROLLER_H
+  inline float CalculateFreeSpaceAlongMainAxis(
+      const float &width, const float &height,
+      const float &current_length) const override {
+    return NAN;
+  }
+};
+}  // namespace WeexCore
+#endif  // CORE_RENDER_NODE_RENDER_SCROLLER_H_

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_text.cpp
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_text.cpp b/weex_core/Source/core/render/node/render_text.cpp
index 4aa3490..eda23e9 100644
--- a/weex_core/Source/core/render/node/render_text.cpp
+++ b/weex_core/Source/core/render/node/render_text.cpp
@@ -16,19 +16,21 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+#include <string>
+
 #include "core/render/node/render_text.h"
 #include "core/render/page/render_page.h"
 
 namespace WeexCore {
 
-  void RenderText::UpdateAttr(std::string key, std::string value) {
-    RenderObject::UpdateAttr(key, value);
-    markDirty();
-  }
+void RenderText::UpdateAttr(std::string key, std::string value) {
+  RenderObject::UpdateAttr(key, value);
+  markDirty();
+}
 
-  StyleType RenderText::UpdateStyle(std::string key, std::string value) {
-    StyleType resultType = RenderObject::ApplyStyle(key, value, true);
-    markDirty();
-    return resultType;
-  }
+StyleType RenderText::UpdateStyle(std::string key, std::string value) {
+  StyleType result_type = RenderObject::ApplyStyle(key, value, true);
+  markDirty();
+  return result_type;
 }
+}  // namespace WeexCore

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_text.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_text.h b/weex_core/Source/core/render/node/render_text.h
index 804b298..86e3733 100644
--- a/weex_core/Source/core/render/node/render_text.h
+++ b/weex_core/Source/core/render/node/render_text.h
@@ -16,20 +16,20 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef WEEX_PROJECT_RENDERTEXT_H
-#define WEEX_PROJECT_RENDERTEXT_H
+#ifndef CORE_RENDER_NODE_RENDER_TEXT_H_
+#define CORE_RENDER_NODE_RENDER_TEXT_H_
+
+#include <string>
 
 #include "core/render/node/render_object.h"
 
 namespace WeexCore {
-  class RenderText : public RenderObject {
-
-  private:
-
-    void UpdateAttr(std::string key, std::string value);
+class RenderText : public RenderObject {
+ private:
+  void UpdateAttr(std::string key, std::string value);
 
-    StyleType UpdateStyle(std::string key, std::string value);
-  };
-}
+  StyleType UpdateStyle(std::string key, std::string value);
+};
+}  // namespace WeexCore
 
-#endif //WEEX_PROJECT_RENDERTEXT_H
+#endif  // CORE_RENDER_NODE_RENDER_TEXT_H_

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/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 78ad8cd..7e9bee5 100644
--- a/weex_core/Source/core/render/page/render_page.cpp
+++ b/weex_core/Source/core/render/page/render_page.cpp
@@ -16,610 +16,605 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#include "core/render/action/render_action_add_element.h"
-#include "core/render/action/render_action_remove_element.h"
-#include "core/render/action/render_action_move_element.h"
-#include "core/render/action/render_action_createbody.h"
-#include "core/render/action/render_action_update_style.h"
-#include "core/render/action/render_action_update_attr.h"
-#include "core/render/action/render_action_layout.h"
-#include "core/render/action/render_action_createfinish.h"
-#include "core/render/action/render_action_appendtree_createfinish.h"
+#include "core/render/page/render_page.h"
+#include "base/TimeUtils.h"
+#include "base/ViewUtils.h"
+#include "core/config/core_environment.h"
+#include "core/css/constants_value.h"
 #include "core/layout/layout.h"
+#include "core/manager/weex_core_manager.h"
 #include "core/moniter/render_performance.h"
-#include "core/config/core_environment.h"
-#include "base/ViewUtils.h"
+#include "core/render/action/render_action_add_element.h"
 #include "core/render/action/render_action_add_event.h"
+#include "core/render/action/render_action_appendtree_createfinish.h"
+#include "core/render/action/render_action_createbody.h"
+#include "core/render/action/render_action_createfinish.h"
+#include "core/render/action/render_action_layout.h"
+#include "core/render/action/render_action_move_element.h"
+#include "core/render/action/render_action_remove_element.h"
 #include "core/render/action/render_action_remove_event.h"
-#include "core/css/constants_value.h"
+#include "core/render/action/render_action_update_attr.h"
+#include "core/render/action/render_action_update_style.h"
+#include "core/render/manager/render_manager.h"
 #include "core/render/node/factory/render_type.h"
 #include "core/render/node/render_list.h"
-#include "core/manager/weex_core_manager.h"
-#include "base/TimeUtils.h"
-#include "core/render/page/render_page.h"
-#include "core/render/manager/render_manager.h"
 #include "core/render/node/render_object.h"
 
 namespace WeexCore {
 
-  RenderPage::RenderPage(std::string page_id) {
-
+RenderPage::RenderPage(std::string page_id) {
 #if RENDER_LOG
-    LOGD("[RenderPage] new RenderPage >>>> pageId: %s", pageId.c_str());
+  LOGD("[RenderPage] new RenderPage >>>> pageId: %s", pageId.c_str());
 #endif
 
-    this->page_id = page_id;
-    this->render_performance = new RenderPerformance();
-    this->viewport_width = kDefaultViewPortWidth;
-    this->render_page_size.first = WXCoreEnvironment::getInstance()->DeviceWidth();
-    this->render_page_size.second = NAN;
-  }
-
-  RenderPage::~RenderPage() {
+  this->page_id_ = page_id;
+  this->render_performance_ = new RenderPerformance();
+  this->viewport_width_ = kDefaultViewPortWidth;
+  this->render_page_size_.first =
+      WXCoreEnvironment::getInstance()->DeviceWidth();
+  this->render_page_size_.second = NAN;
+}
 
+RenderPage::~RenderPage() {
 #if RENDER_LOG
-    LOGD("[RenderPage] Delete RenderPage >>>> pageId: %s", mPageId.c_str());
+  LOGD("[RenderPage] Delete RenderPage >>>> pageId: %s", mPageId.c_str());
 #endif
 
-    this->render_object_registers.clear();
+  this->render_object_registers_.clear();
 
-    if (this->render_root != nullptr) {
-      delete this->render_root;
-      this->render_root = nullptr;
-    }
+  if (this->render_root_ != nullptr) {
+    delete this->render_root_;
+    this->render_root_ = nullptr;
+  }
 
-    if (this->render_performance != nullptr) {
-      delete this->render_performance;
-      this->render_performance = nullptr;
-    }
+  if (this->render_performance_ != nullptr) {
+    delete this->render_performance_;
+    this->render_performance_ = nullptr;
   }
+}
 
-  void RenderPage::CalculateLayout() {
-    if (this->render_root == nullptr || !this->render_root->ViewInit())
-      return;
+void RenderPage::CalculateLayout() {
+  if (this->render_root_ == nullptr || !this->render_root_->ViewInit()) return;
 
 #if RENDER_LOG
-    LOGD("[RenderPage] CalculateLayout >>>> pageId: %s", mPageId.c_str());
+  LOGD("[RenderPage] CalculateLayout >>>> pageId: %s", mPageId.c_str());
 #endif
 
-    long long startTime = getCurrentTime();
-    this->render_root->LayoutBeforeImpl();
-    this->render_root->calculateLayout(this->render_page_size);
-    this->render_root->LayoutAfterImpl();
-    CssLayoutTime(getCurrentTime() - startTime);
-    TraverseTree(this->render_root, 0);
-  }
-
-  void RenderPage::TraverseTree(RenderObject *render,int index) {
+  int64_t start_time = getCurrentTime();
+  this->render_root_->LayoutBeforeImpl();
+  this->render_root_->calculateLayout(this->render_page_size_);
+  this->render_root_->LayoutAfterImpl();
+  CssLayoutTime(getCurrentTime() - start_time);
+  TraverseTree(this->render_root_, 0);
+}
 
-    if (render == nullptr)
-      return;
+void RenderPage::TraverseTree(RenderObject *render, int index) {
+  if (render == nullptr) return;
 
-    if (render->hasNewLayout()) {
-      SendLayoutAction(render, index);
-      render->setHasNewLayout(false);
-    }
-
-    for(auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd(); it++) {
-      RenderObject* child = static_cast<RenderObject*>(*it);
-      if (child != nullptr) {
-        TraverseTree(child, it-render->ChildListIterBegin());
-      }
-    }
+  if (render->hasNewLayout()) {
+    SendLayoutAction(render, index);
+    render->setHasNewLayout(false);
   }
 
-  bool RenderPage::CreateRootRender(RenderObject *root) {
-
-    if (root == nullptr)
-      return false;
-
-    SetRootRenderObject(root);
-
-    if (isnan(this->render_root->getStyleWidth())) {
-      this->render_root->setStyleWidthLevel(FALLBACK_STYLE);
-      if (GetRenderContainerWidthWrapContent())
-        this->render_root->setStyleWidthToNAN();
-      else
-        this->render_root->setStyleWidth(WXCoreEnvironment::getInstance()->DeviceWidth(), false);
-    } else {
-      this->render_root->setStyleWidthLevel(CSS_STYLE);
-    }
-    PushRenderToRegisterMap(root);
-
-    SendCreateBodyAction(root);
-    return true;
-  }
-
-  void RenderPage::SetRootRenderObject(RenderObject *root) {
-    if (root != nullptr) {
-      this->render_root = root;
-      this->render_root->set_is_root_render();
+  for (auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd();
+       it++) {
+    RenderObject *child = static_cast<RenderObject *>(*it);
+    if (child != nullptr) {
+      TraverseTree(child, it - render->ChildListIterBegin());
     }
   }
+}
 
-  bool RenderPage::AddRenderObject(const std::string &parent_ref, int insert_posiotn, RenderObject *child) {
-    RenderObject *parent = GetRenderObject(parent_ref);
-    if (parent == nullptr || child == nullptr) {
-      return false;
-    }
-
-    // add child to Render Tree
-    insert_posiotn = parent->AddRenderObject(insert_posiotn, child);
-    if (insert_posiotn < -1) {
-      return false;
-    }
+bool RenderPage::CreateRootRender(RenderObject *root) {
+  if (root == nullptr) return false;
 
-    PushRenderToRegisterMap(child);
-    SendAddElementAction(child, parent, insert_posiotn, false);
+  SetRootRenderObject(root);
 
-    Batch();
-    return true;
+  if (isnan(this->render_root_->getStyleWidth())) {
+    this->render_root_->setStyleWidthLevel(FALLBACK_STYLE);
+    if (is_render_container_width_wrap_content())
+      this->render_root_->setStyleWidthToNAN();
+    else
+      this->render_root_->setStyleWidth(
+          WXCoreEnvironment::getInstance()->DeviceWidth(), false);
+  } else {
+    this->render_root_->setStyleWidthLevel(CSS_STYLE);
   }
+  PushRenderToRegisterMap(root);
 
-  bool RenderPage::RemoveRenderObject(const std::string &ref) {
-    RenderObject *child = GetRenderObject(ref);
-    if (child == nullptr)
-      return false;
-
-    RenderObject *parent = child->parent_render();
-    if (parent == nullptr)
-      return false;
-
-    parent->RemoveRenderObject(child);
+  SendCreateBodyAction(root);
+  return true;
+}
 
-    RemoveRenderFromRegisterMap(child);
-    delete child;
-
-    SendRemoveElementAction(ref);
-    return true;
+void RenderPage::SetRootRenderObject(RenderObject *root) {
+  if (root != nullptr) {
+    this->render_root_ = root;
+    this->render_root_->set_is_root_render();
   }
+}
 
-  bool RenderPage::MoveRenderObject(const std::string &ref, const std::string &parent_ref, int index) {
-    RenderObject *child = GetRenderObject(ref);
-    if (child == nullptr)
-      return false;
-
-    RenderObject *oldParent = child->parent_render();
-    RenderObject *newParent = GetRenderObject(parent_ref);
-    if (oldParent == nullptr || newParent == nullptr)
-      return false;
-
-    if (oldParent->ref() == newParent->ref()) {
-      if (oldParent->IndexOf(child) < 0) {
-        return false;
-      } else if (oldParent->IndexOf(child) == index) {
-        return false;
-      } else if (oldParent->IndexOf(child) < index) {
-        index = index - 1;
-      }
-    }
-
-    child->getParent()->removeChild(child);
-    newParent->addChildAt(child, index);
+bool RenderPage::AddRenderObject(const std::string &parent_ref,
+                                 int insert_posiotn, RenderObject *child) {
+  RenderObject *parent = GetRenderObject(parent_ref);
+  if (parent == nullptr || child == nullptr) {
+    return false;
+  }
 
-    SendMoveElementAction(ref, parent_ref, index);
-    return true;
+  // add child to Render Tree
+  insert_posiotn = parent->AddRenderObject(insert_posiotn, child);
+  if (insert_posiotn < -1) {
+    return false;
   }
 
-  bool RenderPage::UpdateStyle(const std::string &ref, std::vector<std::pair<std::string, std::string>> *src) {
-    RenderObject *render = GetRenderObject(ref);
-    if (render == nullptr || src == nullptr || src->empty())
-      return false;
+  PushRenderToRegisterMap(child);
+  SendAddElementAction(child, parent, insert_posiotn, false);
 
-    std::vector<std::pair<std::string, std::string>> *style = nullptr;
-    std::vector<std::pair<std::string, std::string>> *margin = nullptr;
-    std::vector<std::pair<std::string, std::string>> *padding = nullptr;
-    std::vector<std::pair<std::string, std::string>> *border = nullptr;
+  Batch();
+  return true;
+}
 
-    bool flag = false;
-    int result = WeexCoreManager::getInstance()->getPlatformBridge()->callHasTransitionPros(this->page_id.c_str(), ref.c_str(), src);
-    //int result = Bridge_Impl_Android::getInstance()->callHasTransitionPros(mPageId.c_str(), ref.c_str(), src);
+bool RenderPage::RemoveRenderObject(const std::string &ref) {
+  RenderObject *child = GetRenderObject(ref);
+  if (child == nullptr) return false;
 
-    if (result == 1) {
-      SendUpdateStyleAction(render, src, margin, padding, border);
-    } else {
-      for (auto iter = src->begin(); iter != src->end(); iter++) {
-        switch (render->UpdateStyle((*iter).first, (*iter).second)) {
-          case kTypeStyle:
-            if (style == nullptr) {
-              style = new std::vector<std::pair<std::string, std::string>>();
-            }
-            style->insert(style->end(), (*iter));
-            flag = true;
-            break;
-          case kTypeMargin:
-            if (margin == nullptr) {
-              margin = new std::vector<std::pair<std::string, std::string>>();
-            }
-            render->UpdateStyleInternal((*iter).first,
-                                        (*iter).second,
-                                        0,
-                                        [=, &flag](float foo) {
-                                          (*iter).second = to_string(foo),
-                                              margin->insert(margin->end(), (*iter)),
-                                          flag = true;
-                                        });
-            break;
-          case kTypePadding:
-            if (padding == nullptr) {
-              padding = new std::vector<std::pair<std::string, std::string>>();
-            }
-            render->UpdateStyleInternal((*iter).first,
-                                        (*iter).second,
-                                        0,
-                                        [=, &flag](float foo) {
-                                          (*iter).second = to_string(foo),
-                                              padding->insert(padding->end(), (*iter)),
-                                          flag = true;
-                                        });
-            break;
-          case kTypeBorder:
-            if (border == nullptr) {
-              border = new std::vector<std::pair<std::string, std::string>>();
-            }
-            render->UpdateStyleInternal((*iter).first,
-                                        (*iter).second,
-                                        0,
-                                        [=, &flag](float foo) {
-                                          (*iter).second = to_string(foo),
-                                              border->insert(border->end(), (*iter)),
-                                          flag = true;
-                                        });
-            break;
-        }
-      }
-    }
+  RenderObject *parent = child->parent_render();
+  if (parent == nullptr) return false;
 
-    if (style != nullptr || margin != nullptr || padding != nullptr || border != nullptr)
-      SendUpdateStyleAction(render, style, margin, padding, border);
+  parent->RemoveRenderObject(child);
 
-    Batch();
+  RemoveRenderFromRegisterMap(child);
+  delete child;
 
-    if (src != nullptr) {
-      src->clear();
-      src->shrink_to_fit();
-      delete src;
-      src = nullptr;
-    }
+  SendRemoveElementAction(ref);
+  return true;
+}
 
-    if (style != nullptr) {
-      style->clear();
-      style->shrink_to_fit();
-      delete style;
-      style = nullptr;
-    }
-
-    if (margin != nullptr) {
-      margin->clear();
-      margin->shrink_to_fit();
-      delete margin;
-      margin = nullptr;
-    }
-
-    if (padding != nullptr) {
-      padding->clear();
-      padding->shrink_to_fit();
-      delete padding;
-      padding = nullptr;
-    }
+bool RenderPage::MoveRenderObject(const std::string &ref,
+                                  const std::string &parent_ref, int index) {
+  RenderObject *child = GetRenderObject(ref);
+  if (child == nullptr) return false;
 
-    if (border != nullptr) {
-      border->clear();
-      border->shrink_to_fit();
-      delete border;
-      border = nullptr;
-    }
-
-    return flag;
-  }
+  RenderObject *old_parent = child->parent_render();
+  RenderObject *new_parent = GetRenderObject(parent_ref);
+  if (old_parent == nullptr || new_parent == nullptr) return false;
 
-  bool RenderPage::UpdateAttr(const std::string &ref, std::vector<std::pair<std::string, std::string>> *attrs) {
-    RenderObject *render = GetRenderObject(ref);
-    if (render == nullptr || attrs == nullptr || attrs->empty())
+  if (old_parent->ref() == new_parent->ref()) {
+    if (old_parent->IndexOf(child) < 0) {
       return false;
-
-    SendUpdateAttrAction(render, attrs);
-
-    for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
-      render->UpdateAttr((*iter).first, (*iter).second);
-    }
-    Batch();
-    if (attrs != nullptr) {
-      attrs->clear();
-      attrs->shrink_to_fit();
-      delete attrs;
-      attrs = nullptr;
-    }
-
-    return true;
-  }
-
-  void RenderPage::SetDefaultHeightAndWidthIntoRootRender(const float default_width,
-                                                          const float default_height,
-                                                          const bool is_width_wrap_content, const bool is_height_wrap_content) {
-    this->render_page_size.first = default_width;
-    this->render_page_size.second = default_height;
-    if (this->render_root->getStyleWidthLevel() >= INSTANCE_STYLE) {
-      this->render_root->setStyleWidthLevel(INSTANCE_STYLE);
-      if (is_width_wrap_content) {
-        SetRenderContainerWidthWrapContent(true);
-        this->render_root->setStyleWidthToNAN();
-        this->render_page_size.first = NAN;
-      } else {
-        this->render_root->setStyleWidth(default_width, true);
-      }
-      updateDirty(true);
-    }
-
-    if (this->render_root->getStyleHeightLevel() >= INSTANCE_STYLE) {
-      if(!is_height_wrap_content) {
-        this->render_root->setStyleHeightLevel(INSTANCE_STYLE);
-        this->render_root->setStyleHeight(default_height);
-        updateDirty(true);
+    } else if (old_parent->IndexOf(child) == index) {
+      return false;
+    } else if (old_parent->IndexOf(child) < index) {
+      index = index - 1;
+    }
+  }
+
+  child->getParent()->removeChild(child);
+  new_parent->addChildAt(child, index);
+
+  SendMoveElementAction(ref, parent_ref, index);
+  return true;
+}
+
+bool RenderPage::UpdateStyle(
+    const std::string &ref,
+    std::vector<std::pair<std::string, std::string>> *src) {
+  RenderObject *render = GetRenderObject(ref);
+  if (render == nullptr || src == nullptr || src->empty()) return false;
+
+  std::vector<std::pair<std::string, std::string>> *style = nullptr;
+  std::vector<std::pair<std::string, std::string>> *margin = nullptr;
+  std::vector<std::pair<std::string, std::string>> *padding = nullptr;
+  std::vector<std::pair<std::string, std::string>> *border = nullptr;
+
+  bool flag = false;
+  int result =
+      WeexCoreManager::getInstance()
+          ->getPlatformBridge()
+          ->callHasTransitionPros(this->page_id_.c_str(), ref.c_str(), src);
+  // int result =
+  // Bridge_Impl_Android::getInstance()->callHasTransitionPros(mPageId.c_str(),
+  // ref.c_str(), src);
+
+  if (result == 1) {
+    SendUpdateStyleAction(render, src, margin, padding, border);
+  } else {
+    for (auto iter = src->begin(); iter != src->end(); iter++) {
+      switch (render->UpdateStyle((*iter).first, (*iter).second)) {
+        case kTypeStyle:
+          if (style == nullptr) {
+            style = new std::vector<std::pair<std::string, std::string>>();
+          }
+          style->insert(style->end(), (*iter));
+          flag = true;
+          break;
+        case kTypeMargin:
+          if (margin == nullptr) {
+            margin = new std::vector<std::pair<std::string, std::string>>();
+          }
+          render->UpdateStyleInternal(
+              (*iter).first, (*iter).second, 0, [=, &flag](float foo) {
+                (*iter).second = to_string(foo),
+                margin->insert(margin->end(), (*iter)), flag = true;
+              });
+          break;
+        case kTypePadding:
+          if (padding == nullptr) {
+            padding = new std::vector<std::pair<std::string, std::string>>();
+          }
+          render->UpdateStyleInternal(
+              (*iter).first, (*iter).second, 0, [=, &flag](float foo) {
+                (*iter).second = to_string(foo),
+                padding->insert(padding->end(), (*iter)), flag = true;
+              });
+          break;
+        case kTypeBorder:
+          if (border == nullptr) {
+            border = new std::vector<std::pair<std::string, std::string>>();
+          }
+          render->UpdateStyleInternal(
+              (*iter).first, (*iter).second, 0, [=, &flag](float foo) {
+                (*iter).second = to_string(foo),
+                border->insert(border->end(), (*iter)), flag = true;
+              });
+          break;
       }
     }
-
-    Batch();
   }
 
-  bool RenderPage::AddEvent(const std::string &ref, const std::string &event) {
-    RenderObject *render = GetRenderObject(ref);
-    if (render == nullptr)
-      return false;
+  if (style != nullptr || margin != nullptr || padding != nullptr ||
+      border != nullptr)
+    SendUpdateStyleAction(render, style, margin, padding, border);
 
-    render->AddEvent(event);
+  Batch();
 
-    RenderAction *action = new RenderActionAddEvent(this->page_id, ref, event);
-    PostRenderAction(action);
-    return true;
+  if (src != nullptr) {
+    src->clear();
+    src->shrink_to_fit();
+    delete src;
+    src = nullptr;
   }
 
-  bool RenderPage::RemoveEvent(const std::string &ref, const std::string &event) {
-    RenderObject *render = GetRenderObject(ref);
-    if (render == nullptr)
-      return false;
-
-    render->RemoveEvent(event);
-
-    RenderAction *action = new RenderActionRemoveEvent(this->page_id, ref, event);
-    PostRenderAction(action);
-    return true;
+  if (style != nullptr) {
+    style->clear();
+    style->shrink_to_fit();
+    delete style;
+    style = nullptr;
   }
 
-  bool RenderPage::CreateFinish() {
-    if (this->render_root == nullptr) {
-      return false;
-    }
-    Batch();
-    SendCreateFinishAction();
-    return true;
+  if (margin != nullptr) {
+    margin->clear();
+    margin->shrink_to_fit();
+    delete margin;
+    margin = nullptr;
   }
 
-  void RenderPage::LayoutImmediately() {
-    if(isDirty() && kUseVSync){
-      CalculateLayout();
-      this->need_layout.store(false);
-      updateDirty(false);
-    }
+  if (padding != nullptr) {
+    padding->clear();
+    padding->shrink_to_fit();
+    delete padding;
+    padding = nullptr;
   }
 
-  void RenderPage::PostRenderAction(RenderAction *action) {
-    if (action != nullptr) {
-      action->ExecuteAction();
-      delete action;
-      action = nullptr;
-    }
+  if (border != nullptr) {
+    border->clear();
+    border->shrink_to_fit();
+    delete border;
+    border = nullptr;
   }
 
-  void RenderPage::PushRenderToRegisterMap(RenderObject *render) {
-    if (render == nullptr)
-      return;
+  return flag;
+}
 
-    std::string ref = render->ref();
-    this->render_object_registers.insert(std::pair<std::string, RenderObject *>(ref, render));
+bool RenderPage::UpdateAttr(
+    const std::string &ref,
+    std::vector<std::pair<std::string, std::string>> *attrs) {
+  RenderObject *render = GetRenderObject(ref);
+  if (render == nullptr || attrs == nullptr || attrs->empty()) return false;
 
-    for(auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd(); it++) {
-      RenderObject* child = static_cast<RenderObject*>(*it);
-      if (child != nullptr) {
-        PushRenderToRegisterMap(child);
-      }
-    }
-  }
+  SendUpdateAttrAction(render, attrs);
 
-  void RenderPage::RemoveRenderFromRegisterMap(RenderObject *render) {
-    if (render == nullptr)
-      return;
-
-    this->render_object_registers.erase(render->ref());
-
-    for(auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd(); it++) {
-      RenderObject* child = static_cast<RenderObject*>(*it);
-      if (child != nullptr) {
-        RemoveRenderFromRegisterMap(child);
-      }
-    }
+  for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
+    render->UpdateAttr((*iter).first, (*iter).second);
+  }
+  Batch();
+  if (attrs != nullptr) {
+    attrs->clear();
+    attrs->shrink_to_fit();
+    delete attrs;
+    attrs = nullptr;
   }
 
-  void RenderPage::SendCreateBodyAction(RenderObject *render) {
-    if (render == nullptr)
-      return;
-
-    RenderAction *action = new RenderActionCreateBody(PageId(), render);
-    PostRenderAction(action);
+  return true;
+}
 
-    Index i = 0;
-    for(auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd(); it++) {
-      RenderObject* child = static_cast<RenderObject*>(*it);
-      if (child != nullptr) {
-        SendAddElementAction(child, render, i, true);
-      }
-      ++i;
-    }
-
-    if (i > 0 && render->IsAppendTree()) {
-      SendAppendTreeCreateFinish(render->ref());
+void RenderPage::SetDefaultHeightAndWidthIntoRootRender(
+    const float default_width, const float default_height,
+    const bool is_width_wrap_content, const bool is_height_wrap_content) {
+  this->render_page_size_.first = default_width;
+  this->render_page_size_.second = default_height;
+  if (this->render_root_->getStyleWidthLevel() >= INSTANCE_STYLE) {
+    this->render_root_->setStyleWidthLevel(INSTANCE_STYLE);
+    if (is_width_wrap_content) {
+      set_is_render_container_width_wrap_content(true);
+      this->render_root_->setStyleWidthToNAN();
+      this->render_page_size_.first = NAN;
+    } else {
+      this->render_root_->setStyleWidth(default_width, true);
     }
+    set_is_dirty(true);
   }
 
-  void RenderPage::SendAddElementAction(RenderObject *child, RenderObject *parent, int index, bool is_recursion, bool will_layout) {
-    if (child == nullptr || parent == nullptr)
-      return;
-    if(parent != nullptr && parent->type() == WeexCore::kRenderRecycleList){
-        will_layout = false;
+  if (this->render_root_->getStyleHeightLevel() >= INSTANCE_STYLE) {
+    if (!is_height_wrap_content) {
+      this->render_root_->setStyleHeightLevel(INSTANCE_STYLE);
+      this->render_root_->setStyleHeight(default_height);
+      set_is_dirty(true);
     }
+  }
 
-    RenderAction *action = new RenderActionAddElement(PageId(), child, parent, index, will_layout);
-    PostRenderAction(action);
+  Batch();
+}
 
-    Index i = 0;
-    for(auto it = child->ChildListIterBegin(); it != child->ChildListIterEnd(); it++) {
-      RenderObject* grandson = static_cast<RenderObject*>(*it);
-      if (grandson != nullptr) {
-        SendAddElementAction(grandson, child, i, true, will_layout);
-      }
-      ++i;
-    }
+bool RenderPage::AddEvent(const std::string &ref, const std::string &event) {
+  RenderObject *render = GetRenderObject(ref);
+  if (render == nullptr) return false;
 
-    if(child->type() == WeexCore::kRenderRecycleList){
-      RenderList* renderList = (RenderList*)child;
-      std::vector<RenderObject*>& cellSlots = renderList->CellSlots();
-      for(auto it = cellSlots.begin(); it != cellSlots.end(); it++) {
-        RenderObject* grandson = static_cast<RenderObject*>(*it);
-        if (grandson != nullptr) {
-          SendAddElementAction(grandson, child, -1, true, will_layout);
-        }
-        ++i;
-      }
-    }
+  render->AddEvent(event);
 
-    if (!is_recursion && i > 0 && child->IsAppendTree()) {
-      SendAppendTreeCreateFinish(child->ref());
-    }
-  }
+  RenderAction *action = new RenderActionAddEvent(this->page_id_, ref, event);
+  PostRenderAction(action);
+  return true;
+}
 
-  void RenderPage::SendRemoveElementAction(const std::string &ref) {
-    RenderAction *action = new RenderActionRemoveElement(PageId(), ref);
-    PostRenderAction(action);
-  }
+bool RenderPage::RemoveEvent(const std::string &ref, const std::string &event) {
+  RenderObject *render = GetRenderObject(ref);
+  if (render == nullptr) return false;
 
-  void RenderPage::SendMoveElementAction(const std::string &ref, const std::string &parent_ref, int index) {
-    RenderAction *action = new RenderActionMoveElement(PageId(), ref, parent_ref, index);
-    PostRenderAction(action);
-  }
+  render->RemoveEvent(event);
 
-  void RenderPage::SendLayoutAction(RenderObject *render, int index) {
-    if (render == nullptr)
-      return;
+  RenderAction *action = new RenderActionRemoveEvent(this->page_id_, ref, event);
+  PostRenderAction(action);
+  return true;
+}
 
-    RenderAction *action = new RenderActionLayout(PageId(), render, index);
-    PostRenderAction(action);
+bool RenderPage::CreateFinish() {
+  if (this->render_root_ == nullptr) {
+    return false;
   }
+  Batch();
+  SendCreateFinishAction();
+  return true;
+}
 
-  void RenderPage::SendUpdateStyleAction(RenderObject *render,
-                                         std::vector<std::pair<std::string, std::string>> *style,
-                                         std::vector<std::pair<std::string, std::string>> *margin,
-                                         std::vector<std::pair<std::string, std::string>> *padding,
-                                         std::vector<std::pair<std::string, std::string>> *border) {
-    RenderAction *action = new RenderActionUpdateStyle(PageId(), render->ref(), style, margin, padding, border);
-    PostRenderAction(action);
+void RenderPage::LayoutImmediately() {
+  if (is_dirty() && kUseVSync) {
+    CalculateLayout();
+    this->need_layout_.store(false);
+    set_is_dirty(false);
   }
+}
 
-  void RenderPage::SendUpdateAttrAction(RenderObject *render,
-                                        std::vector<std::pair<std::string, std::string>> *attrs) {
-    RenderAction *action = new RenderActionUpdateAttr(PageId(), render->ref(), attrs);
-    PostRenderAction(action);
+void RenderPage::PostRenderAction(RenderAction *action) {
+  if (action != nullptr) {
+    action->ExecuteAction();
+    delete action;
+    action = nullptr;
   }
+}
 
-  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));
-    }
+void RenderPage::PushRenderToRegisterMap(RenderObject *render) {
+  if (render == nullptr) return;
 
-    RenderAction *action = new RenderActionUpdateAttr(PageId(), render->ref(), vAttrs);
-    PostRenderAction(action);
+  std::string ref = render->ref();
+  this->render_object_registers_.insert(
+      std::pair<std::string, RenderObject *>(ref, render));
 
-    if (vAttrs != nullptr) {
-      vAttrs->clear();
-      delete vAttrs;
-      vAttrs = nullptr;
+  for (auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd();
+       it++) {
+    RenderObject *child = static_cast<RenderObject *>(*it);
+    if (child != nullptr) {
+      PushRenderToRegisterMap(child);
     }
   }
+}
 
-  void RenderPage::SendCreateFinishAction() {
-    RenderAction *action = new RenderActionCreateFinish(PageId());
-    PostRenderAction(action);
-  }
+void RenderPage::RemoveRenderFromRegisterMap(RenderObject *render) {
+  if (render == nullptr) return;
 
-  void RenderPage::SendAppendTreeCreateFinish(const std::string &ref) {
-    RenderAction *action = new RenderActionAppendTreeCreateFinish(PageId(), ref);
-    PostRenderAction(action);
-  }
-
-  void RenderPage::CssLayoutTime(const long long &time) {
-    if (this->render_performance != nullptr)
-      this->render_performance->cssLayoutTime += time;
-  }
+  this->render_object_registers_.erase(render->ref());
 
-  void RenderPage::ParseJsonTime(const long long &time) {
-    if (this->render_performance != nullptr)
-      this->render_performance->parseJsonTime += time;
-  }
-
-  void RenderPage::CallBridgeTime(const long long &time) {
-    if (this->render_performance != nullptr)
-      this->render_performance->callBridgeTime += time;
+  for (auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd();
+       it++) {
+    RenderObject *child = static_cast<RenderObject *>(*it);
+    if (child != nullptr) {
+      RemoveRenderFromRegisterMap(child);
+    }
   }
+}
 
-  std::vector<long> RenderPage::PrintFirstScreenLog() {
-    std::vector<long> ret;
-    if (this->render_performance != nullptr)
-      ret = this->render_performance->PrintPerformanceLog(onFirstScreen);
-    return ret;
-  }
+void RenderPage::SendCreateBodyAction(RenderObject *render) {
+  if (render == nullptr) return;
 
-  std::vector<long> RenderPage::PrintRenderSuccessLog() {
-    std::vector<long> ret;
-    if (this->render_performance != nullptr)
-      ret = this->render_performance->PrintPerformanceLog(onRenderSuccess);
-    return ret;
-  }
+  RenderAction *action = new RenderActionCreateBody(page_id(), render);
+  PostRenderAction(action);
 
-  void RenderPage::Batch() {
-    if ((kUseVSync && this->need_layout.load()) || !kUseVSync) {
-      CalculateLayout();
-      this->need_layout.store(false);
-      updateDirty(false);
+  Index i = 0;
+  for (auto it = render->ChildListIterBegin(); it != render->ChildListIterEnd();
+       it++) {
+    RenderObject *child = static_cast<RenderObject *>(*it);
+    if (child != nullptr) {
+      SendAddElementAction(child, render, i, true);
     }
+    ++i;
   }
 
-  RenderObject* RenderPage::GetRenderObject(const std::string &ref) {
-    std::map<std::string, RenderObject *>::iterator iter = this->render_object_registers.find(ref);
-    if (iter != this->render_object_registers.end()) {
-      return iter->second;
-    } else {
-      return nullptr;
-    }
-  }
-
-  void RenderPage::OnRenderPageInit() {
-
+  if (i > 0 && render->IsAppendTree()) {
+    SendAppendTreeCreateFinish(render->ref());
   }
+}
 
-  void RenderPage::OnRenderProcessStart() {
-
+void RenderPage::SendAddElementAction(RenderObject *child, RenderObject *parent,
+                                      int index, bool is_recursion,
+                                      bool will_layout) {
+  if (child == nullptr || parent == nullptr) return;
+  if (parent != nullptr && parent->type() == WeexCore::kRenderRecycleList) {
+    will_layout = false;
   }
 
-  void RenderPage::OnRenderProcessExited() {
+  RenderAction *action =
+      new RenderActionAddElement(page_id(), child, parent, index, will_layout);
+  PostRenderAction(action);
 
+  Index i = 0;
+  for (auto it = child->ChildListIterBegin(); it != child->ChildListIterEnd();
+       it++) {
+    RenderObject *grandson = static_cast<RenderObject *>(*it);
+    if (grandson != nullptr) {
+      SendAddElementAction(grandson, child, i, true, will_layout);
+    }
+    ++i;
   }
 
-  void RenderPage::OnRenderProcessGone() {
-
+  if (child->type() == WeexCore::kRenderRecycleList) {
+    RenderList *render_list = static_cast<RenderList *>(child);
+    std::vector<RenderObject *> &cell_slots = render_list->CellSlots();
+    for (auto it = cell_slots.begin(); it != cell_slots.end(); it++) {
+      RenderObject *grandson = static_cast<RenderObject *>(*it);
+      if (grandson != nullptr) {
+        SendAddElementAction(grandson, child, -1, true, will_layout);
+      }
+      ++i;
+    }
   }
 
-  void RenderPage::OnRenderPageClose() {
-
-  }
-} //namespace WeexCore
+  if (!is_recursion && i > 0 && child->IsAppendTree()) {
+    SendAppendTreeCreateFinish(child->ref());
+  }
+}
+
+void RenderPage::SendRemoveElementAction(const std::string &ref) {
+  RenderAction *action = new RenderActionRemoveElement(page_id(), ref);
+  PostRenderAction(action);
+}
+
+void RenderPage::SendMoveElementAction(const std::string &ref,
+                                       const std::string &parent_ref,
+                                       int index) {
+  RenderAction *action =
+      new RenderActionMoveElement(page_id(), ref, parent_ref, index);
+  PostRenderAction(action);
+}
+
+void RenderPage::SendLayoutAction(RenderObject *render, int index) {
+  if (render == nullptr) return;
+
+  RenderAction *action = new RenderActionLayout(page_id(), render, index);
+  PostRenderAction(action);
+}
+
+void RenderPage::SendUpdateStyleAction(
+    RenderObject *render,
+    std::vector<std::pair<std::string, std::string>> *style,
+    std::vector<std::pair<std::string, std::string>> *margin,
+    std::vector<std::pair<std::string, std::string>> *padding,
+    std::vector<std::pair<std::string, std::string>> *border) {
+  RenderAction *action = new RenderActionUpdateStyle(
+      page_id(), render->ref(), style, margin, padding, border);
+  PostRenderAction(action);
+}
+
+void RenderPage::SendUpdateAttrAction(
+    RenderObject *render,
+    std::vector<std::pair<std::string, std::string>> *attrs) {
+  RenderAction *action =
+      new RenderActionUpdateAttr(page_id(), render->ref(), attrs);
+  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));
+  }
+
+  RenderAction *action =
+      new RenderActionUpdateAttr(page_id(), render->ref(), vAttrs);
+  PostRenderAction(action);
+
+  if (vAttrs != nullptr) {
+    vAttrs->clear();
+    delete vAttrs;
+    vAttrs = nullptr;
+  }
+}
+
+void RenderPage::SendCreateFinishAction() {
+  RenderAction *action = new RenderActionCreateFinish(page_id());
+  PostRenderAction(action);
+}
+
+void RenderPage::SendAppendTreeCreateFinish(const std::string &ref) {
+  RenderAction *action = new RenderActionAppendTreeCreateFinish(page_id(), ref);
+  PostRenderAction(action);
+}
+
+void RenderPage::CssLayoutTime(const int64_t &time) {
+  if (this->render_performance_ != nullptr)
+    this->render_performance_->cssLayoutTime += time;
+}
+
+void RenderPage::ParseJsonTime(const int64_t &time) {
+  if (this->render_performance_ != nullptr)
+    this->render_performance_->parseJsonTime += time;
+}
+
+void RenderPage::CallBridgeTime(const int64_t &time) {
+  if (this->render_performance_ != nullptr)
+    this->render_performance_->callBridgeTime += time;
+}
+
+std::vector<int64_t> RenderPage::PrintFirstScreenLog() {
+  std::vector<int64_t> ret;
+  if (this->render_performance_ != nullptr)
+    ret = this->render_performance_->PrintPerformanceLog(onFirstScreen);
+  return ret;
+}
+
+std::vector<int64_t> RenderPage::PrintRenderSuccessLog() {
+  std::vector<int64_t> ret;
+  if (this->render_performance_ != nullptr)
+    ret = this->render_performance_->PrintPerformanceLog(onRenderSuccess);
+  return ret;
+}
+
+void RenderPage::Batch() {
+  if ((kUseVSync && this->need_layout_.load()) || !kUseVSync) {
+    CalculateLayout();
+    this->need_layout_.store(false);
+    set_is_dirty(false);
+  }
+}
+
+RenderObject *RenderPage::GetRenderObject(const std::string &ref) {
+  std::map<std::string, RenderObject *>::iterator iter =
+      this->render_object_registers_.find(ref);
+  if (iter != this->render_object_registers_.end()) {
+    return iter->second;
+  } else {
+    return nullptr;
+  }
+}
+
+void RenderPage::OnRenderPageInit() {}
+
+void RenderPage::OnRenderProcessStart() {}
+
+void RenderPage::OnRenderProcessExited() {}
+
+void RenderPage::OnRenderProcessGone() {}
+
+void RenderPage::OnRenderPageClose() {}
+}  // namespace WeexCore

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/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 f179bdc..9310e16 100644
--- a/weex_core/Source/core/render/page/render_page.h
+++ b/weex_core/Source/core/render/page/render_page.h
@@ -16,172 +16,167 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef RenderPage_H
-#define RenderPage_H
+#ifndef CORE_RENDER_PAGE_RENDER_PAGE_H_
+#define CORE_RENDER_PAGE_RENDER_PAGE_H_
 
-#include <vector>
-#include <string>
-#include <map>
-#include <cmath>
 #include <atomic>
+#include <cmath>
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
 
 namespace WeexCore {
 
-  class RenderAction;
-
-  class RenderObject;
-
-  class RenderPerformance;
-
-  class RenderPage {
-
-  private:
+class RenderAction;
 
-    void TraverseTree(RenderObject *render, int index);
+class RenderObject;
 
-    void PushRenderToRegisterMap(RenderObject *render);
+class RenderPerformance;
 
-    void RemoveRenderFromRegisterMap(RenderObject *render);
+class RenderPage {
+ private:
+  void TraverseTree(RenderObject *render, int index);
 
-    void SendCreateBodyAction(RenderObject *render);
+  void PushRenderToRegisterMap(RenderObject *render);
 
-    void
-    SendAddElementAction(RenderObject *child, RenderObject *parent, int index, bool is_recursion,
-                         bool will_layout = true);
+  void RemoveRenderFromRegisterMap(RenderObject *render);
 
-    void SendRemoveElementAction(const std::string &ref);
+  void SendCreateBodyAction(RenderObject *render);
 
-    void SendMoveElementAction(const std::string &ref, const std::string &parent_ref, int index);
+  void SendAddElementAction(RenderObject *child, RenderObject *parent,
+                            int index, bool is_recursion,
+                            bool will_layout = true);
 
-    void SendLayoutAction(RenderObject *render, int index);
+  void SendRemoveElementAction(const std::string &ref);
 
-    void SendUpdateStyleAction(RenderObject *render,
-                               std::vector<std::pair<std::string, std::string>> *style,
-                               std::vector<std::pair<std::string, std::string>> *margin,
-                               std::vector<std::pair<std::string, std::string>> *padding,
-                               std::vector<std::pair<std::string, std::string>> *border);
+  void SendMoveElementAction(const std::string &ref,
+                             const std::string &parent_ref, int index);
 
-    void SendUpdateAttrAction(RenderObject *render,
-                              std::vector<std::pair<std::string, std::string>> *attrs);
+  void SendLayoutAction(RenderObject *render, int index);
 
-    void SendCreateFinishAction();
+  void SendUpdateStyleAction(
+      RenderObject *render,
+      std::vector<std::pair<std::string, std::string>> *style,
+      std::vector<std::pair<std::string, std::string>> *margin,
+      std::vector<std::pair<std::string, std::string>> *padding,
+      std::vector<std::pair<std::string, std::string>> *border);
 
-    void SendAppendTreeCreateFinish(const std::string &ref);
+  void SendUpdateAttrAction(
+      RenderObject *render,
+      std::vector<std::pair<std::string, std::string>> *attrs);
 
-    void PostRenderAction(RenderAction *action);
+  void SendCreateFinishAction();
 
-  public:
+  void SendAppendTreeCreateFinish(const std::string &ref);
 
-    explicit RenderPage(std::string page_id);
+  void PostRenderAction(RenderAction *action);
 
-    ~RenderPage();
+ public:
 
-    void CalculateLayout();
+  explicit RenderPage(std::string page_id);
 
-    bool CreateRootRender(RenderObject *root);
+  ~RenderPage();
 
-    bool AddRenderObject(const std::string &parent_ref, int insert_posiotn, RenderObject *child);
+  void CalculateLayout();
 
-    bool RemoveRenderObject(const std::string &ref);
+  bool CreateRootRender(RenderObject *root);
 
-    bool MoveRenderObject(const std::string &ref, const std::string &parent_ref, int index);
+  bool AddRenderObject(const std::string &parent_ref, int insert_posiotn,
+                       RenderObject *child);
 
-    bool
-    UpdateStyle(const std::string &ref, std::vector<std::pair<std::string, std::string>> *styles);
+  bool RemoveRenderObject(const std::string &ref);
 
-    bool
-    UpdateAttr(const std::string &ref, std::vector<std::pair<std::string, std::string>> *attrs);
+  bool MoveRenderObject(const std::string &ref, const std::string &parent_ref,
+                        int index);
 
-    void
-    SetDefaultHeightAndWidthIntoRootRender(const float default_width, const float default_height,
-                                           const bool is_width_wrap_content,
-                                           const bool is_height_wrap_content);
+  bool UpdateStyle(const std::string &ref,
+                   std::vector<std::pair<std::string, std::string>> *styles);
 
-    bool AddEvent(const std::string &ref, const std::string &event);
+  bool UpdateAttr(const std::string &ref,
+                  std::vector<std::pair<std::string, std::string>> *attrs);
 
-    bool RemoveEvent(const std::string &ref, const std::string &event);
+  void SetDefaultHeightAndWidthIntoRootRender(
+      const float default_width, const float default_height,
+      const bool is_width_wrap_content, const bool is_height_wrap_content);
 
-    bool CreateFinish();
+  bool AddEvent(const std::string &ref, const std::string &event);
 
-    void Batch();
+  bool RemoveEvent(const std::string &ref, const std::string &event);
 
-    void CssLayoutTime(const long long &time);
+  bool CreateFinish();
 
-    void ParseJsonTime(const long long &time);
+  void Batch();
 
-    void CallBridgeTime(const long long &time);
+  void CssLayoutTime(const int64_t &time);
 
-    std::vector<long> PrintFirstScreenLog();
+  void ParseJsonTime(const int64_t &time);
 
-    std::vector<long> PrintRenderSuccessLog();
+  void CallBridgeTime(const int64_t &time);
 
-    void LayoutImmediately();
+  std::vector<int64_t> PrintFirstScreenLog();
 
-    void SendUpdateAttrAction(RenderObject *render, std::map<std::string, std::string> *attrs);
+  std::vector<int64_t> PrintRenderSuccessLog();
 
-    RenderObject *GetRenderObject(const std::string &ref);
+  void LayoutImmediately();
 
-    void SetRootRenderObject(RenderObject *root);
+  void SendUpdateAttrAction(RenderObject *render,
+                            std::map<std::string, std::string> *attrs);
 
-    // ****** Life Cycle ****** //
+  RenderObject *GetRenderObject(const std::string &ref);
 
-    void OnRenderPageInit();
+  void SetRootRenderObject(RenderObject *root);
 
-    void OnRenderProcessStart();
+  // ****** Life Cycle ****** //
 
-    void OnRenderProcessExited();
+  void OnRenderPageInit();
 
-    void OnRenderProcessGone();
+  void OnRenderProcessStart();
 
-    void OnRenderPageClose();
+  void OnRenderProcessExited();
 
+  void OnRenderProcessGone();
 
-    inline std::string PageId() {
-      return this->page_id;
-    }
+  void OnRenderPageClose();
 
-    inline float ViewPortWidth() const {
-      return this->viewport_width;
-    }
+public:
 
-    inline void SetViewPortWidth(float viewport_width) {
-      this->viewport_width = viewport_width;
-    }
+  inline std::string page_id() { return this->page_id_; }
 
-    inline bool isDirty() {
-      return this->dirty.load();
-    }
+  inline float viewport_width() const { return this->viewport_width_; }
 
-    inline void updateDirty(bool dirty) {
-      this->dirty.store(dirty);
-    }
+  inline void set_viewport_width(float viewport_width) {
+    this->viewport_width_ = viewport_width;
+  }
 
-    inline void SetRenderContainerWidthWrapContent(bool wrap) {
-      this->is_render_container_width_wrap_content.store(wrap);
-    }
+  inline bool is_dirty() { return this->is_dirty_.load(); }
 
-    inline bool GetRenderContainerWidthWrapContent() {
-      return this->is_render_container_width_wrap_content.load();
-    }
+  inline void set_is_dirty(bool dirty) { this->is_dirty_.store(dirty); }
 
-  public:
+  inline void set_is_render_container_width_wrap_content(bool wrap) {
+    this->is_render_container_width_wrap_content_.store(wrap);
+  }
 
-    static constexpr bool kUseVSync = true;
-    std::atomic_bool need_layout{false};
-    std::atomic_bool has_fore_layout_action{false};
+  inline bool is_render_container_width_wrap_content() {
+    return this->is_render_container_width_wrap_content_.load();
+  }
 
-  private:
+ public:
+  static constexpr bool kUseVSync = true;
+  std::atomic_bool need_layout_{false};
+  std::atomic_bool has_fore_layout_action_{false};
 
-    float viewport_width;
-    RenderObject *render_root = nullptr;
-    std::string page_id;
-    std::pair<float, float> render_page_size;
-    std::map<std::string, RenderObject *> render_object_registers;
-    RenderPerformance *render_performance;
-    std::atomic_bool dirty{true};
-    std::atomic_bool is_render_container_width_wrap_content{false};
-    std::atomic_bool is_render_container_height_wrap_content{false};
-  };
-}
+ private:
+  float viewport_width_;
+  RenderObject *render_root_ = nullptr;
+  std::string page_id_;
+  std::pair<float, float> render_page_size_;
+  std::map<std::string, RenderObject *> render_object_registers_;
+  RenderPerformance *render_performance_;
+  std::atomic_bool is_dirty_{true};
+  std::atomic_bool is_render_container_width_wrap_content_{false};
+  std::atomic_bool is_render_container_height_wrap_content_{false};
+};
+}  // namespace WeexCore
 
-#endif //RenderManager_h
\ No newline at end of file
+#endif  // CORE_RENDER_PAGE_RENDER_PAGE_H_