You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ky...@apache.org on 2018/06/12 04:44:26 UTC
[02/12] 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/factory/render_creator.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_creator.h b/weex_core/Source/core/render/node/factory/render_creator.h
index b78a487..f5dddfc 100644
--- a/weex_core/Source/core/render/node/factory/render_creator.h
+++ b/weex_core/Source/core/render/node/factory/render_creator.h
@@ -16,48 +16,46 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERCREATOR_H
-#define WEEX_PROJECT_RENDERCREATOR_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_CREATOR_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_CREATOR_H_
#include <string>
namespace WeexCore {
- class IRenderObject;
+class IRenderObject;
- class RenderCreator {
+class RenderCreator {
+ private:
+ RenderCreator() {}
- private:
- explicit RenderCreator() {}
+ ~RenderCreator() {}
- ~RenderCreator() {}
-
- //just to release singleton object
- class Garbo {
- public:
- ~Garbo() {
- if (RenderCreator::g_pInstance) {
- delete RenderCreator::g_pInstance;
- }
+ // just to release singleton object
+ class Garbo {
+ public:
+ ~Garbo() {
+ if (RenderCreator::g_pInstance) {
+ delete RenderCreator::g_pInstance;
}
- };
-
- static Garbo garbo;
+ }
+ };
- public:
+ static Garbo garbo;
- static RenderCreator *GetInstance() {
- if (!g_pInstance) {
- g_pInstance = new RenderCreator();
- }
- return g_pInstance;
+ public:
+ static RenderCreator *GetInstance() {
+ if (!g_pInstance) {
+ g_pInstance = new RenderCreator();
}
+ return g_pInstance;
+ }
- IRenderObject *CreateRender(const std::string &type, const std::string &ref);
+ IRenderObject *CreateRender(const std::string &type, const std::string &ref);
- private:
- static RenderCreator *g_pInstance;
- };
-}
+ private:
+ static RenderCreator *g_pInstance;
+};
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERCREATOR_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_CREATOR_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/render_factory_interface.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_factory_interface.h b/weex_core/Source/core/render/node/factory/render_factory_interface.h
index 02d936c..ab8787a 100644
--- a/weex_core/Source/core/render/node/factory/render_factory_interface.h
+++ b/weex_core/Source/core/render/node/factory/render_factory_interface.h
@@ -16,16 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_IRENDERFACTORY_H
-#define WEEX_PROJECT_IRENDERFACTORY_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_FACTORY_INTERFACE_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_FACTORY_INTERFACE_H_
#include "core/render/node/factory/render_object_interface.h"
namespace WeexCore {
- class IRenderFactory {
- public:
- virtual IRenderObject *CreateRender() = 0;
- };
-}
+class IRenderFactory {
+ public:
+ virtual IRenderObject *CreateRender() = 0;
+};
+} // namespace WeexCore
-#endif //WEEX_PROJECT_IRENDERFACTORY_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_FACTORY_INTERFACE_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/render_list_factory.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_list_factory.h b/weex_core/Source/core/render/node/factory/render_list_factory.h
index e15c94a..50735f9 100644
--- a/weex_core/Source/core/render/node/factory/render_list_factory.h
+++ b/weex_core/Source/core/render/node/factory/render_list_factory.h
@@ -16,21 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERLISTFACTORY_H
-#define WEEX_PROJECT_RENDERLISTFACTORY_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_LIST_FACTORY_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_LIST_FACTORY_H_
-#include "core/render/node/render_list.h"
#include "core/render/node/factory/render_factory_interface.h"
+#include "core/render/node/render_list.h"
namespace WeexCore {
- class RenderListFactory : public IRenderFactory {
- public:
- IRenderObject *CreateRender() {
- return new RenderList();
- }
- };
+class RenderListFactory : public IRenderFactory {
+ public:
+ IRenderObject *CreateRender() { return new RenderList(); }
+};
-}
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERLISTFACTORY_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_LIST_FACTORY_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/render_mask_factory.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_mask_factory.h b/weex_core/Source/core/render/node/factory/render_mask_factory.h
index 7f865e4..edd516f 100644
--- a/weex_core/Source/core/render/node/factory/render_mask_factory.h
+++ b/weex_core/Source/core/render/node/factory/render_mask_factory.h
@@ -16,21 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERMASKFACTORY_H
-#define WEEX_PROJECT_RENDERMASKFACTORY_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_MASK_FACTORY_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_MASK_FACTORY_H_
-#include "core/render/node/render_mask.h"
#include "core/render/node/factory/render_factory_interface.h"
+#include "core/render/node/render_mask.h"
namespace WeexCore {
- class RenderMaskFactory : public IRenderFactory {
- public:
- IRenderObject *CreateRender() {
- return new RenderMask();
- }
- };
+class RenderMaskFactory : public IRenderFactory {
+ public:
+ IRenderObject *CreateRender() { return new RenderMask(); }
+};
-}
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERMASKFACTORY_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_MASK_FACTORY_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/render_object_interface.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_object_interface.h b/weex_core/Source/core/render/node/factory/render_object_interface.h
index 9e3922f..f080113 100644
--- a/weex_core/Source/core/render/node/factory/render_object_interface.h
+++ b/weex_core/Source/core/render/node/factory/render_object_interface.h
@@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_IRENDEROBJECT_H
-#define WEEX_PROJECT_IRENDEROBJECT_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_OBJECT_INTERFACE_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_OBJECT_INTERFACE_H_
#include <string>
@@ -25,47 +25,32 @@
namespace WeexCore {
- class IRenderObject : public WXCoreLayoutNode {
+class IRenderObject : public WXCoreLayoutNode {
+ public:
+ inline void set_ref(std::string ref) { this->ref_ = ref; }
- public:
+ inline const std::string &ref() const { return this->ref_; }
- inline void set_ref(std::string ref) {
- this->ref_ = ref;
- }
+ inline void set_page_id(std::string page_id) { this->page_id_ = page_id; }
- inline const std::string &ref() const {
- return this->ref_;
- }
+ inline const std::string &page_id() const { return this->page_id_; }
- inline void set_page_id(std::string page_id) {
- this->page_id_ = page_id;
- }
+ inline void set_type(std::string type) { this->tyle_ = type; }
- inline const std::string &page_id() const {
- return this->page_id_;
- }
+ inline const std::string &type() const { return this->tyle_; }
- inline void set_type(std::string type) {
- this->tyle_ = type;
- }
+ inline void CopyFrom(IRenderObject *src) {
+ WXCoreLayoutNode::copyFrom(src);
+ set_ref(src->ref());
+ set_page_id(src->page_id());
+ set_type(src->type());
+ }
- inline const std::string &type() const {
- return this->tyle_;
- }
+ private:
+ std::string page_id_ = "";
+ std::string ref_ = "";
+ std::string tyle_ = "";
+};
+} // namespace WeexCore
- inline void CopyFrom(IRenderObject *src) {
- WXCoreLayoutNode::copyFrom(src);
- set_ref(src->ref());
- set_page_id(src->page_id());
- set_type(src->type());
- }
-
- private:
-
- std::string page_id_ = "";
- std::string ref_ = "";
- std::string tyle_ = "";
- };
-}
-
-#endif //WEEX_PROJECT_IRENDEROBJECT_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_OBJECT_INTERFACE_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/render_scroller_factory.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_scroller_factory.h b/weex_core/Source/core/render/node/factory/render_scroller_factory.h
index 062af88..53d268e 100644
--- a/weex_core/Source/core/render/node/factory/render_scroller_factory.h
+++ b/weex_core/Source/core/render/node/factory/render_scroller_factory.h
@@ -16,21 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERSCROLLERFACTORY_H
-#define WEEX_PROJECT_RENDERSCROLLERFACTORY_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_SCROLLER_FACTORY_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_SCROLLER_FACTORY_H_
-#include "core/render/node/render_scroller.h"
#include "core/render/node/factory/render_factory_interface.h"
+#include "core/render/node/render_scroller.h"
namespace WeexCore {
- class RenderScrollerFactory : public IRenderFactory {
- public:
- IRenderObject *CreateRender() {
- return new RenderScroller();
- }
- };
+class RenderScrollerFactory : public IRenderFactory {
+ public:
+ IRenderObject *CreateRender() { return new RenderScroller(); }
+};
-}
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERSCROLLERFACTORY_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_SCROLLER_FACTORY_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/render_text_factory.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_text_factory.h b/weex_core/Source/core/render/node/factory/render_text_factory.h
index 967412a..e54d31b 100644
--- a/weex_core/Source/core/render/node/factory/render_text_factory.h
+++ b/weex_core/Source/core/render/node/factory/render_text_factory.h
@@ -16,21 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERTEXTFACTORY_H
-#define WEEX_PROJECT_RENDERTEXTFACTORY_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_TEXT_FACTORY_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_TEXT_FACTORY_H_
-#include "core/render/node/render_text.h"
#include "core/render/node/factory/render_factory_interface.h"
+#include "core/render/node/render_text.h"
namespace WeexCore {
- class RenderTextFactory : public IRenderFactory {
- public:
- IRenderObject *CreateRender() {
- return new RenderText();
- }
- };
+class RenderTextFactory : public IRenderFactory {
+ public:
+ IRenderObject *CreateRender() { return new RenderText(); }
+};
-}
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERTEXTFACTORY_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_TEXT_FACTORY_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/render_type.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/render_type.h b/weex_core/Source/core/render/node/factory/render_type.h
index 46c98ae..c7242b8 100644
--- a/weex_core/Source/core/render/node/factory/render_type.h
+++ b/weex_core/Source/core/render/node/factory/render_type.h
@@ -16,24 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERTYPE_H
-#define WEEX_PROJECT_RENDERTYPE_H
+#ifndef CORE_RENDER_NODE_FACTORY_RENDER_TYPE_H_
+#define CORE_RENDER_NODE_FACTORY_RENDER_TYPE_H_
#include <string>
namespace WeexCore {
- constexpr char kRenderCell[] = "cell";
- constexpr char kRenderCellSlot[] = "cell-slot";
- constexpr char kRenderList[] = "list";
- constexpr char kHList[] = "hlist";
- constexpr char kRenderRecycleList[] = "recycle-list";
- constexpr char kRenderMask[] = "mask";
- constexpr char kRenderScroller[] = "scroller";
- constexpr char kRenderText[] = "text";
- constexpr char kRenderHeader[] = "header";
- constexpr char kRenderFooter[] = "footer";
- constexpr char kRenderWaterfall[] = "waterfall";
- constexpr char kRenderAppBar[] = "appbar";
-}
+constexpr char kRenderCell[] = "cell";
+constexpr char kRenderCellSlot[] = "cell-slot";
+constexpr char kRenderList[] = "list";
+constexpr char kHList[] = "hlist";
+constexpr char kRenderRecycleList[] = "recycle-list";
+constexpr char kRenderMask[] = "mask";
+constexpr char kRenderScroller[] = "scroller";
+constexpr char kRenderText[] = "text";
+constexpr char kRenderHeader[] = "header";
+constexpr char kRenderFooter[] = "footer";
+constexpr char kRenderWaterfall[] = "waterfall";
+constexpr char kRenderAppBar[] = "appbar";
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERTYPE_H
+#endif // CORE_RENDER_NODE_FACTORY_RENDER_TYPE_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/factory/simple_render_factory.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/factory/simple_render_factory.h b/weex_core/Source/core/render/node/factory/simple_render_factory.h
index eb55d41..f7e9b22 100644
--- a/weex_core/Source/core/render/node/factory/simple_render_factory.h
+++ b/weex_core/Source/core/render/node/factory/simple_render_factory.h
@@ -16,22 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERCOMMONFACTORY_H
-#define WEEX_PROJECT_RENDERCOMMONFACTORY_H
+#ifndef CORE_RENDER_NODE_FACTORY_SIMPLE_RENDER_FACTORY_H_
+#define CORE_RENDER_NODE_FACTORY_SIMPLE_RENDER_FACTORY_H_
-#include "core/render/node/render_object.h"
#include "core/render/node/factory/render_factory_interface.h"
+#include "core/render/node/render_object.h"
namespace WeexCore {
- class RenderCommonFactory : public IRenderFactory {
- public:
- IRenderObject *CreateRender() {
- return new RenderObject();
- }
- };
-
-}
+class RenderCommonFactory : public IRenderFactory {
+ public:
+ IRenderObject *CreateRender() { return new RenderObject(); }
+};
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERCOMMONFACTORY_H
+#endif // CORE_RENDER_NODE_FACTORY_SIMPLE_RENDER_FACTORY_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_appbar.cpp
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_appbar.cpp b/weex_core/Source/core/render/node/render_appbar.cpp
index 8c05f41..1e9a291 100644
--- a/weex_core/Source/core/render/node/render_appbar.cpp
+++ b/weex_core/Source/core/render/node/render_appbar.cpp
@@ -16,70 +16,70 @@
* specific language governing permissions and limitations
* under the License.
*/
-#include "core/config/core_environment.h"
+#include <utility>
+
#include "base/ViewUtils.h"
+#include "core/config/core_environment.h"
#include "core/css/constants_name.h"
#include "core/render/node/render_appbar.h"
namespace WeexCore {
- std::map<std::string, std::string> *RenderAppBar::GetDefaultStyle() {
- this->default_nav_width_ = getFloat(
- WXCoreEnvironment::getInstance()->GetOption("defaultNavWidth").c_str());
+std::map<std::string, std::string> *RenderAppBar::GetDefaultStyle() {
+ this->default_nav_width_ = getFloat(
+ WXCoreEnvironment::getInstance()->GetOption("defaultNavWidth").c_str());
- this->default_overflow_width_ = getFloat(
- WXCoreEnvironment::getInstance()->GetOption("defaultOverflowWidth").c_str());
+ this->default_overflow_width_ =
+ getFloat(WXCoreEnvironment::getInstance()
+ ->GetOption("defaultOverflowWidth")
+ .c_str());
- std::string appbar_color = WXCoreEnvironment::getInstance()->GetOption("appbar_color");
- std::string appbar_background_color = WXCoreEnvironment::getInstance()->GetOption(
- "appbar_background_color");
+ std::string appbar_color =
+ WXCoreEnvironment::getInstance()->GetOption("appbar_color");
+ std::string appbar_background_color =
+ WXCoreEnvironment::getInstance()->GetOption("appbar_background_color");
- std::map<std::string, std::string> *style = new std::map<std::string, std::string>();
- style->insert(std::pair<std::string, std::string>(PADDING_LEFT, "0"));
- style->insert(std::pair<std::string, std::string>(PADDING_RIGHT, "0"));
+ std::map<std::string, std::string> *style =
+ new std::map<std::string, std::string>();
+ style->insert(std::pair<std::string, std::string>(PADDING_LEFT, "0"));
+ style->insert(std::pair<std::string, std::string>(PADDING_RIGHT, "0"));
- if (!appbar_color.empty() && appbar_color != "" && !StyleExist(COLOR))
- style->insert(std::pair<std::string, std::string>(COLOR, appbar_color));
- if (!appbar_background_color.empty() && appbar_background_color != "" &&
- !StyleExist(BACKGROUND_COLOR))
- style->insert(std::pair<std::string, std::string>(BACKGROUND_COLOR, appbar_background_color));
- return style;
- }
+ if (!appbar_color.empty() && appbar_color != "" && !StyleExist(COLOR))
+ style->insert(std::pair<std::string, std::string>(COLOR, appbar_color));
+ if (!appbar_background_color.empty() && appbar_background_color != "" &&
+ !StyleExist(BACKGROUND_COLOR))
+ style->insert(std::pair<std::string, std::string>(BACKGROUND_COLOR,
+ appbar_background_color));
+ return style;
+}
- bool RenderAppBar::StyleExist(const std::string &key) {
- std::string value = GetStyle(key);
- return !value.empty() && value != "";
- }
+bool RenderAppBar::StyleExist(const std::string &key) {
+ std::string value = GetStyle(key);
+ return !value.empty() && value != "";
+}
- StyleType RenderAppBar::ApplyStyle(const std::string &key, const std::string &value,
- const bool updating) {
- if (key == PADDING) {
- UpdateStyleInternal(key,
- value,
- 0,
- [=](float foo) {
- setPadding(kPaddingLeft, foo + this->default_nav_width_),
- setPadding(kPaddingRight, foo + this->default_overflow_width_),
- setPadding(kPaddingTop, foo),
- setPadding(kPaddingBottom, foo);
- });
- return kTypePadding;
- } else if (key == PADDING_LEFT) {
- UpdateStyleInternal(key,
- value,
- 0,
- [=](float foo) { setPadding(kPaddingLeft, foo + this->default_nav_width_); });
- return kTypePadding;
- } else if (key == PADDING_RIGHT) {
- UpdateStyleInternal(key,
- value,
- 0,
- [=](float foo) {
- setPadding(kPaddingRight, foo + this->default_overflow_width_);
- });
- return kTypePadding;
- } else {
- return RenderObject::ApplyStyle(key, value, updating);
- }
+StyleType RenderAppBar::ApplyStyle(const std::string &key,
+ const std::string &value,
+ const bool updating) {
+ if (key == PADDING) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setPadding(kPaddingLeft, foo + this->default_nav_width_),
+ setPadding(kPaddingRight, foo + this->default_overflow_width_),
+ setPadding(kPaddingTop, foo), setPadding(kPaddingBottom, foo);
+ });
+ return kTypePadding;
+ } else if (key == PADDING_LEFT) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setPadding(kPaddingLeft, foo + this->default_nav_width_);
+ });
+ return kTypePadding;
+ } else if (key == PADDING_RIGHT) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setPadding(kPaddingRight, foo + this->default_overflow_width_);
+ });
+ return kTypePadding;
+ } else {
+ return RenderObject::ApplyStyle(key, value, updating);
}
}
+} // namespace WeexCore
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_appbar.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_appbar.h b/weex_core/Source/core/render/node/render_appbar.h
index 3247c7c..24e3957 100644
--- a/weex_core/Source/core/render/node/render_appbar.h
+++ b/weex_core/Source/core/render/node/render_appbar.h
@@ -16,32 +16,29 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERAPPBAR_H
-#define WEEX_PROJECT_RENDERAPPBAR_H
+#ifndef CORE_RENDER_NODE_RENDER_APPBAR_H_
+#define CORE_RENDER_NODE_RENDER_APPBAR_H_
+#include <map>
#include <string>
#include "core/render/node/render_object.h"
namespace WeexCore {
- class RenderAppBar : public RenderObject {
+class RenderAppBar : public RenderObject {
+ private:
+ std::map<std::string, std::string> *GetDefaultStyle();
- private:
+ bool StyleExist(const std::string &key);
- std::map<std::string, std::string> *GetDefaultStyle();
+ public:
+ StyleType ApplyStyle(const std::string &key, const std::string &value,
+ const bool updating);
- bool StyleExist(const std::string &key);
+ private:
+ float default_nav_width_;
+ float default_overflow_width_;
+};
+} // namespace WeexCore
- public:
-
- StyleType ApplyStyle(const std::string &key, const std::string &value, const bool updating);
-
- private:
-
- float default_nav_width_;
- float default_overflow_width_;
-
- };
-}
-
-#endif //WEEX_PROJECT_RENDERAPPBAR_H
+#endif // CORE_RENDER_NODE_RENDER_APPBAR_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_cell.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_cell.h b/weex_core/Source/core/render/node/render_cell.h
index 9a2ced6..3421b6f 100644
--- a/weex_core/Source/core/render/node/render_cell.h
+++ b/weex_core/Source/core/render/node/render_cell.h
@@ -16,15 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERCELL_H
-#define WEEX_PROJECT_RENDERCELL_H
+#ifndef CORE_RENDER_NODE_RENDER_CELL_H_
+#define CORE_RENDER_NODE_RENDER_CELL_H_
#include "core/render/node/render_object.h"
namespace WeexCore {
- class RenderCell : public RenderObject {
+class RenderCell : public RenderObject {};
+} // namespace WeexCore
- };
-}
-
-#endif //WEEX_PROJECT_RENDERCELL_H
+#endif // CORE_RENDER_NODE_RENDER_CELL_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_list.cpp
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_list.cpp b/weex_core/Source/core/render/node/render_list.cpp
index 1854d5e..84df8ec 100644
--- a/weex_core/Source/core/render/node/render_list.cpp
+++ b/weex_core/Source/core/render/node/render_list.cpp
@@ -17,314 +17,339 @@
* under the License.
*/
#include <cmath>
+#include <utility>
-#include "core/render/node/render_list.h"
-#include "core/css/constants_name.h"
#include "base/ViewUtils.h"
+#include "core/css/constants_name.h"
#include "core/render/node/factory/render_type.h"
+#include "core/render/node/render_list.h"
#include "core/render/node/render_object.h"
#include "core/render/page/render_page.h"
namespace WeexCore {
- RenderList::~RenderList() {
- if (this->cell_slots_copys_.size() > 0) {
- for (auto it = this->cell_slots_copys_.begin(); it != this->cell_slots_copys_.end(); ++it) {
- RenderObject *child = *it;
- if (child) {
- delete child;
- child = nullptr;
- }
+RenderList::~RenderList() {
+ if (this->cell_slots_copys_.size() > 0) {
+ for (auto it = this->cell_slots_copys_.begin();
+ it != this->cell_slots_copys_.end(); ++it) {
+ RenderObject *child = *it;
+ if (child) {
+ delete child;
+ child = nullptr;
}
- this->cell_slots_copys_.clear();
}
+ this->cell_slots_copys_.clear();
+ }
- if (this->cell_slots_.size() > 0) {
- for (auto it = this->cell_slots_.begin(); it != this->cell_slots_.end(); ++it) {
- RenderObject *child = *it;
- if (child) {
- delete child;
- child = nullptr;
- }
+ if (this->cell_slots_.size() > 0) {
+ for (auto it = this->cell_slots_.begin(); it != this->cell_slots_.end();
+ ++it) {
+ RenderObject *child = *it;
+ if (child) {
+ delete child;
+ child = nullptr;
}
- this->cell_slots_.clear();
}
+ this->cell_slots_.clear();
}
+}
- void RenderList::AddCellSlotCopyTrack(RenderObject *cellSlot) {
- cellSlot->setParent(this, cellSlot);
- this->cell_slots_copys_.push_back(cellSlot);
- }
-
- std::map<std::string, std::string> *RenderList::GetDefaultStyle() {
- std::map<std::string, std::string> *style = new std::map<std::string, std::string>();
-
- bool isVertical = true;
- RenderObject *parent = (RenderObject *) getParent();
+void RenderList::AddCellSlotCopyTrack(RenderObject *cell_slot) {
+ cell_slot->setParent(this, cell_slot);
+ this->cell_slots_copys_.push_back(cell_slot);
+}
- if (parent != nullptr && !parent->type().empty()) {
- if (parent->type() == kHList) {
- isVertical = false;
- } else if (TakeOrientation() == HORIZONTAL_VALUE) {
- isVertical = false;
- }
- }
+std::map<std::string, std::string> *RenderList::GetDefaultStyle() {
+ std::map<std::string, std::string> *style =
+ new std::map<std::string, std::string>();
- std::string prop = isVertical ? HEIGHT : WIDTH;
+ bool is_vertical = true;
+ RenderObject *parent = static_cast<RenderObject *>(getParent());
- if (prop == HEIGHT && isnan(getStyleHeight()) && !this->is_set_flex_) {
- this->is_set_flex_ = true;
- style->insert(std::pair<std::string, std::string>(FLEX, "1"));
- } else if (prop == WIDTH && isnan(TakeStyleWidth()) && !this->is_set_flex_) {
- this->is_set_flex_ = true;
- style->insert(std::pair<std::string, std::string>(FLEX, "1"));
+ if (parent != nullptr && !parent->type().empty()) {
+ if (parent->type() == kHList) {
+ is_vertical = false;
+ } else if (TakeOrientation() == HORIZONTAL_VALUE) {
+ is_vertical = false;
}
-
- return style;
}
- void RenderList::set_flex(const float flex) {
- this->is_set_flex_ = true;
- WXCoreLayoutNode::set_flex(flex);
- }
+ std::string prop = is_vertical ? HEIGHT : WIDTH;
- std::map<std::string, std::string> *RenderList::GetDefaultAttr() {
- if (!this->is_pre_calculate_cell_width_) {
- PreCalculateCellWidth();
- }
- return nullptr;
+ if (prop == HEIGHT && isnan(getStyleHeight()) && !this->is_set_flex_) {
+ this->is_set_flex_ = true;
+ style->insert(std::pair<std::string, std::string>(FLEX, "1"));
+ } else if (prop == WIDTH && isnan(TakeStyleWidth()) && !this->is_set_flex_) {
+ this->is_set_flex_ = true;
+ style->insert(std::pair<std::string, std::string>(FLEX, "1"));
}
- void RenderList::PreCalculateCellWidth() {
- std::map<std::string, std::string> *attrs = new std::map<std::string, std::string>();
- if (attributes() != nullptr) {
- this->column_count_ = TakeColumnCount();
- this->column_width_ = TakeColumnWidth();
- this->column_gap_ = TakeColumnGap();
+ return style;
+}
- this->left_gap_ = TakeLeftGap();
- this->right_gap_ = TakeRightGap();
+void RenderList::set_flex(const float flex) {
+ this->is_set_flex_ = true;
+ WXCoreLayoutNode::set_flex(flex);
+}
- this->available_width_ =
- TakeStyleWidth() - getWebPxByWidth(getPaddingLeft(), GetRenderPage()->ViewPortWidth()) -
- getWebPxByWidth(getPaddingRight(), GetRenderPage()->ViewPortWidth());
+std::map<std::string, std::string> *RenderList::GetDefaultAttr() {
+ if (!this->is_pre_calculate_cell_width_) {
+ PreCalculateCellWidth();
+ }
+ return nullptr;
+}
- if (AUTO_VALUE == this->column_count_ && AUTO_VALUE == this->column_width_) {
+void RenderList::PreCalculateCellWidth() {
+ std::map<std::string, std::string> *attrs =
+ new std::map<std::string, std::string>();
+ if (attributes() != nullptr) {
+ this->column_count_ = TakeColumnCount();
+ this->column_width_ = TakeColumnWidth();
+ this->column_gap_ = TakeColumnGap();
+
+ this->left_gap_ = TakeLeftGap();
+ this->right_gap_ = TakeRightGap();
+
+ this->available_width_ =
+ TakeStyleWidth() -
+ getWebPxByWidth(getPaddingLeft(), GetRenderPage()->viewport_width()) -
+ getWebPxByWidth(getPaddingRight(), GetRenderPage()->viewport_width());
+
+ if (AUTO_VALUE == this->column_count_ &&
+ AUTO_VALUE == this->column_width_) {
+ this->column_count_ = COLUMN_COUNT_NORMAL;
+ this->column_width_ = (this->available_width_ -
+ ((this->column_count_ - 1) * this->column_gap_)) /
+ this->column_count_;
+ this->column_width_ = this->column_width_ > 0 ? this->column_width_ : 0;
+ } else if (AUTO_VALUE == this->column_width_ &&
+ AUTO_VALUE != this->column_count_) {
+ this->column_width_ =
+ (this->available_width_ - this->left_gap_ - this->right_gap_ -
+ ((this->column_count_ - 1) * this->column_gap_)) /
+ this->column_count_;
+ this->column_width_ = this->column_width_ > 0 ? this->column_width_ : 0;
+ } else if (AUTO_VALUE != this->column_width_ &&
+ AUTO_VALUE == this->column_count_) {
+ this->column_count_ =
+ static_cast<int>(round((this->available_width_ + this->column_gap_) /
+ (this->column_width_ + this->column_gap_) -
+ 0.5f));
+ this->column_count_ = this->column_count_ > 0 ? this->column_count_ : 1;
+ if (this->column_count_ <= 0) {
this->column_count_ = COLUMN_COUNT_NORMAL;
- this->column_width_ =
- (this->available_width_ - ((this->column_count_ - 1) * this->column_gap_)) /
- this->column_count_;
- this->column_width_ = this->column_width_ > 0 ? this->column_width_ : 0;
- } else if (AUTO_VALUE == this->column_width_ && AUTO_VALUE != this->column_count_) {
- this->column_width_ =
- (this->available_width_ - this->left_gap_ - this->right_gap_ -
- ((this->column_count_ - 1) * this->column_gap_)) /
- this->column_count_;
- this->column_width_ = this->column_width_ > 0 ? this->column_width_ : 0;
- } else if (AUTO_VALUE != this->column_width_ && AUTO_VALUE == this->column_count_) {
- this->column_count_ = (int) round(
- (this->available_width_ + this->column_gap_) / (this->column_width_ + this->column_gap_) -
- 0.5f);
- this->column_count_ = this->column_count_ > 0 ? this->column_count_ : 1;
- if (this->column_count_ <= 0) {
- this->column_count_ = COLUMN_COUNT_NORMAL;
- }
- this->column_width_ =
- ((this->available_width_ + this->column_gap_ - this->left_gap_ - this->right_gap_) /
- this->column_count_) - this->column_gap_;
-
- } else if (AUTO_VALUE != this->column_width_ && AUTO_VALUE != this->column_count_) {
- int columnCount = (int) round(
- (this->available_width_ + this->column_gap_ - this->left_gap_ - this->right_gap_) /
- (this->column_width_ + this->column_gap_) -
- 0.5f);
- this->column_count_ = columnCount > this->column_count_ ? this->column_count_ : columnCount;
- if (this->column_count_ <= 0) {
- this->column_count_ = COLUMN_COUNT_NORMAL;
- }
- this->column_width_ =
- ((this->available_width_ + this->column_gap_ - this->left_gap_ - this->right_gap_) /
- this->column_count_) - this->column_gap_;
- }
-
- std::string spanOffsets = CalculateSpanOffset();
-
- this->is_pre_calculate_cell_width_ = true;
- if (TakeColumnCount() > 0 || TakeColumnWidth() > 0 ||
- this->column_count_ > COLUMN_COUNT_NORMAL) {
- attrs->insert(
- std::pair<std::string, std::string>(COLUMN_COUNT, to_string(this->column_count_)));
- attrs->insert(std::pair<std::string, std::string>(COLUMN_GAP, to_string(this->column_gap_)));
- attrs->insert(
- std::pair<std::string, std::string>(COLUMN_WIDTH, to_string(this->column_width_)));
}
- if (spanOffsets.length() > 0) {
- attrs->insert(std::pair<std::string, std::string>(SPAN_OFFSETS, to_string(spanOffsets)));
+ this->column_width_ = ((this->available_width_ + this->column_gap_ -
+ this->left_gap_ - this->right_gap_) /
+ this->column_count_) -
+ this->column_gap_;
+
+ } else if (AUTO_VALUE != this->column_width_ &&
+ AUTO_VALUE != this->column_count_) {
+ int column_count =
+ static_cast<int>(round((this->available_width_ + this->column_gap_ -
+ this->left_gap_ - this->right_gap_) /
+ (this->column_width_ + this->column_gap_) -
+ 0.5f));
+ this->column_count_ =
+ column_count > this->column_count_ ? this->column_count_ : column_count;
+ if (this->column_count_ <= 0) {
+ this->column_count_ = COLUMN_COUNT_NORMAL;
}
+ this->column_width_ = ((this->available_width_ + this->column_gap_ -
+ this->left_gap_ - this->right_gap_) /
+ this->column_count_) -
+ this->column_gap_;
+ }
- for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
- RenderObject::UpdateAttr(iter->first, iter->second);
- }
+ std::string span_offsets = CalculateSpanOffset();
+
+ this->is_pre_calculate_cell_width_ = true;
+ if (TakeColumnCount() > 0 || TakeColumnWidth() > 0 ||
+ this->column_count_ > COLUMN_COUNT_NORMAL) {
+ attrs->insert(std::pair<std::string, std::string>(
+ COLUMN_COUNT, to_string(this->column_count_)));
+ attrs->insert(std::pair<std::string, std::string>(
+ COLUMN_GAP, to_string(this->column_gap_)));
+ attrs->insert(std::pair<std::string, std::string>(
+ COLUMN_WIDTH, to_string(this->column_width_)));
+ }
+ if (span_offsets.length() > 0) {
+ attrs->insert(std::pair<std::string, std::string>(
+ SPAN_OFFSETS, to_string(span_offsets)));
}
- RenderPage *page = GetRenderPage();
+ for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
+ RenderObject::UpdateAttr(iter->first, iter->second);
+ }
+ }
- if (page != nullptr)
- page->SendUpdateAttrAction(this, attrs);
+ RenderPage *page = GetRenderPage();
- if (attrs != nullptr) {
- attrs->clear();
- delete attrs;
- attrs = nullptr;
- }
+ if (page != nullptr) page->SendUpdateAttrAction(this, attrs);
+
+ if (attrs != nullptr) {
+ attrs->clear();
+ delete attrs;
+ attrs = nullptr;
}
+}
- std::string RenderList::CalculateSpanOffset() {
- std::string spanOffsets;
- if (this->left_gap_ > 0 || this->right_gap_ > 0) {
- spanOffsets.append("[");
- for (int i = 0; i < this->column_count_; i++) {
- float spanOffset = this->left_gap_ + i * ((this->column_width_ + this->column_gap_) -
- (this->available_width_ + this->column_gap_) /
- this->column_count_);
- spanOffsets.append(to_string(spanOffset));
- if (i != this->column_count_ - 1) {
- spanOffsets.append(",");
- }
+std::string RenderList::CalculateSpanOffset() {
+ std::string span_offsets;
+ if (this->left_gap_ > 0 || this->right_gap_ > 0) {
+ span_offsets.append("[");
+ for (int i = 0; i < this->column_count_; i++) {
+ float span_offset =
+ this->left_gap_ + i * ((this->column_width_ + this->column_gap_) -
+ (this->available_width_ + this->column_gap_) /
+ this->column_count_);
+ span_offsets.append(to_string(span_offset));
+ if (i != this->column_count_ - 1) {
+ span_offsets.append(",");
}
- spanOffsets.append("]");
}
- return spanOffsets;
+ span_offsets.append("]");
}
+ return span_offsets;
+}
- float RenderList::TakeStyleWidth() {
- float width = getWebPxByWidth(getLayoutWidth(), GetRenderPage()->ViewPortWidth());
- if (isnan(width) || width <= 0) {
- if (getParent() != nullptr) {
- width = getWebPxByWidth(getParent()->getLayoutWidth(), GetRenderPage()->ViewPortWidth());
- }
- if (isnan(width) || width <= 0) {
- width = getWebPxByWidth(RenderObject::getStyleWidth(), GetRenderPage()->ViewPortWidth());
- }
+float RenderList::TakeStyleWidth() {
+ float width =
+ getWebPxByWidth(getLayoutWidth(), GetRenderPage()->viewport_width());
+ if (isnan(width) || width <= 0) {
+ if (getParent() != nullptr) {
+ width = getWebPxByWidth(getParent()->getLayoutWidth(),
+ GetRenderPage()->viewport_width());
}
if (isnan(width) || width <= 0) {
- width = GetViewPortWidth();
+ width = getWebPxByWidth(RenderObject::getStyleWidth(),
+ GetRenderPage()->viewport_width());
}
- return width;
}
+ if (isnan(width) || width <= 0) {
+ width = GetViewPortWidth();
+ }
+ return width;
+}
- int RenderList::AddRenderObject(int index, RenderObject *child) {
- if (type() == kRenderRecycleList
- && (child->type() == kRenderCellSlot || child->type() == kRenderCell ||
- child->type() == kRenderHeader)) {
- child->setParent(this, child);
- this->cell_slots_.insert(this->cell_slots_.end(), child);
- index = -1;
- } else {
- index = RenderObject::AddRenderObject(index, child);
- }
+int RenderList::AddRenderObject(int index, RenderObject *child) {
+ if (type() == kRenderRecycleList &&
+ (child->type() == kRenderCellSlot || child->type() == kRenderCell ||
+ child->type() == kRenderHeader)) {
+ child->setParent(this, child);
+ this->cell_slots_.insert(this->cell_slots_.end(), child);
+ index = -1;
+ } else {
+ index = RenderObject::AddRenderObject(index, child);
+ }
- if (!this->is_pre_calculate_cell_width_) {
- PreCalculateCellWidth();
- }
+ if (!this->is_pre_calculate_cell_width_) {
+ PreCalculateCellWidth();
+ }
- if (this->column_width_ != 0 && !isnan(this->column_width_)) {
- AddRenderObjectWidth(child, false);
- }
- return index;
+ if (this->column_width_ != 0 && !isnan(this->column_width_)) {
+ AddRenderObjectWidth(child, false);
}
+ return index;
+}
- void RenderList::AddRenderObjectWidth(RenderObject *child, const bool updating) {
- if (type() == kRenderWaterfall || type() == kRenderRecycleList) {
- if (child->type() == kRenderHeader || child->type() == kRenderFooter) {
- child->ApplyStyle(WIDTH, to_string(this->available_width_), updating);
- } else if (child->is_sticky()) {
- child->ApplyStyle(WIDTH, to_string(this->available_width_), updating);
- } else if (child->type() == kRenderCell || child->type() == kRenderCellSlot) {
- child->ApplyStyle(WIDTH, to_string(this->column_width_), updating);
- }
+void RenderList::AddRenderObjectWidth(RenderObject *child,
+ const bool updating) {
+ if (type() == kRenderWaterfall || type() == kRenderRecycleList) {
+ if (child->type() == kRenderHeader || child->type() == kRenderFooter) {
+ child->ApplyStyle(WIDTH, to_string(this->available_width_), updating);
+ } else if (child->is_sticky()) {
+ child->ApplyStyle(WIDTH, to_string(this->available_width_), updating);
+ } else if (child->type() == kRenderCell ||
+ child->type() == kRenderCellSlot) {
+ child->ApplyStyle(WIDTH, to_string(this->column_width_), updating);
}
}
+}
- void RenderList::UpdateAttr(std::string key, std::string value) {
- RenderObject::UpdateAttr(key, value);
+void RenderList::UpdateAttr(std::string key, std::string value) {
+ RenderObject::UpdateAttr(key, value);
- if (!GetAttr(COLUMN_COUNT).empty() || !GetAttr(COLUMN_GAP).empty() ||
- !GetAttr(COLUMN_WIDTH).empty()) {
- PreCalculateCellWidth();
+ if (!GetAttr(COLUMN_COUNT).empty() || !GetAttr(COLUMN_GAP).empty() ||
+ !GetAttr(COLUMN_WIDTH).empty()) {
+ PreCalculateCellWidth();
- if (this->column_width_ == 0 && isnan(this->column_width_)) {
- return;
- }
+ if (this->column_width_ == 0 && isnan(this->column_width_)) {
+ return;
+ }
- int count = getChildCount();
- for (Index i = 0; i < count; i++) {
- RenderObject *child = GetChild(i);
- AddRenderObjectWidth(this, true);
- }
+ int count = getChildCount();
+ for (Index i = 0; i < count; i++) {
+ RenderObject *child = GetChild(i);
+ AddRenderObjectWidth(this, true);
}
}
+}
- float RenderList::TakeColumnCount() {
- std::string columnCount = GetAttr(COLUMN_COUNT);
-
- if (columnCount.empty() || columnCount == AUTO) {
- return AUTO_VALUE;
- }
+float RenderList::TakeColumnCount() {
+ std::string column_count = GetAttr(COLUMN_COUNT);
- float columnCountValue = getFloat(columnCount.c_str());
- return (columnCountValue > 0 && !isnan(columnCountValue)) ? columnCountValue : AUTO_VALUE;
+ if (column_count.empty() || column_count == AUTO) {
+ return AUTO_VALUE;
}
- float RenderList::TakeColumnGap() {
- std::string columnGap = GetAttr(COLUMN_GAP);
+ float column_count_value = getFloat(column_count.c_str());
+ return (column_count_value > 0 && !isnan(column_count_value)) ? column_count_value
+ : AUTO_VALUE;
+}
- if (columnGap.empty() || columnGap == NORMAL) {
- return COLUMN_GAP_NORMAL;
- }
+float RenderList::TakeColumnGap() {
+ std::string column_gap = GetAttr(COLUMN_GAP);
- float columnGapValue = getFloat(columnGap.c_str());
- return (columnGapValue > 0 && !isnan(columnGapValue)) ? columnGapValue : AUTO_VALUE;
+ if (column_gap.empty() || column_gap == NORMAL) {
+ return COLUMN_GAP_NORMAL;
}
- float RenderList::TakeColumnWidth() {
- std::string columnWidth = GetAttr(COLUMN_WIDTH);
+ float column_gap_value = getFloat(column_gap.c_str());
+ return (column_gap_value > 0 && !isnan(column_gap_value)) ? column_gap_value
+ : AUTO_VALUE;
+}
- if (columnWidth.empty() || columnWidth == AUTO) {
- return AUTO_VALUE;
- }
+float RenderList::TakeColumnWidth() {
+ std::string column_width = GetAttr(COLUMN_WIDTH);
- float columnWidthValue = getFloat(columnWidth.c_str());
- return (columnWidthValue > 0 && !isnan(columnWidthValue)) ? columnWidthValue : 0;
+ if (column_width.empty() || column_width == AUTO) {
+ return AUTO_VALUE;
}
- float RenderList::TakeLeftGap() {
- std::string leftGap = GetAttr(LEFT_GAP);
+ float column_width_value = getFloat(column_width.c_str());
+ return (column_width_value > 0 && !isnan(column_width_value)) ? column_width_value
+ : 0;
+}
- if (leftGap.empty() || leftGap == AUTO) {
- return 0;
- }
+float RenderList::TakeLeftGap() {
+ std::string left_gap = GetAttr(LEFT_GAP);
- float leftGapValue = getFloat(leftGap.c_str());
- return (leftGapValue > 0 && !isnan(leftGapValue)) ? leftGapValue : 0;
+ if (left_gap.empty() || left_gap == AUTO) {
+ return 0;
}
- float RenderList::TakeRightGap() {
- std::string rightGap = GetAttr(RIGHT_GAP);
+ float left_gap_value = getFloat(left_gap.c_str());
+ return (left_gap_value > 0 && !isnan(left_gap_value)) ? left_gap_value : 0;
+}
- if (rightGap.empty() || rightGap == AUTO) {
- return 0;
- }
+float RenderList::TakeRightGap() {
+ std::string right_gap = GetAttr(RIGHT_GAP);
- float rightGapValue = getFloat(rightGap.c_str());
- return (rightGapValue > 0 && !isnan(rightGapValue)) ? rightGapValue : 0;
+ if (right_gap.empty() || right_gap == AUTO) {
+ return 0;
}
- int RenderList::TakeOrientation() {
- std::string direction = GetAttr(SCROLL_DIRECTION);
- if (HORIZONTAL == direction) {
- return HORIZONTAL_VALUE;
- }
- return VERTICAL_VALUE;
+ float right_gap_value = getFloat(right_gap.c_str());
+ return (right_gap_value > 0 && !isnan(right_gap_value)) ? right_gap_value : 0;
+}
+
+int RenderList::TakeOrientation() {
+ std::string direction = GetAttr(SCROLL_DIRECTION);
+ if (HORIZONTAL == direction) {
+ return HORIZONTAL_VALUE;
}
+ return VERTICAL_VALUE;
}
+} // namespace WeexCore
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/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 39453e0..d3c5e7e 100644
--- a/weex_core/Source/core/render/node/render_list.h
+++ b/weex_core/Source/core/render/node/render_list.h
@@ -16,74 +16,74 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERLIST_H
-#define WEEX_PROJECT_RENDERLIST_H
+#ifndef CORE_RENDER_NODE_RENDER_LIST_H_
+#define CORE_RENDER_NODE_RENDER_LIST_H_
+
+#include <map>
+#include <string>
+#include <vector>
-#include "core/render/node/render_object.h"
#include "core/css/constants_value.h"
+#include "core/render/node/render_object.h"
namespace WeexCore {
- class RenderList : public RenderObject {
-
- public:
-
- ~RenderList();
-
- void set_flex(const float flex);
+class RenderList : public RenderObject {
+ public:
+ ~RenderList();
- void AddCellSlotCopyTrack(RenderObject *cellSlot);
+ void set_flex(const float flex);
- std::map<std::string, std::string> *GetDefaultStyle();
+ void AddCellSlotCopyTrack(RenderObject *cell_slot);
- std::map<std::string, std::string> *GetDefaultAttr();
+ std::map<std::string, std::string> *GetDefaultStyle();
- void PreCalculateCellWidth();
+ std::map<std::string, std::string> *GetDefaultAttr();
- std::string CalculateSpanOffset();
+ void PreCalculateCellWidth();
- float TakeStyleWidth();
+ std::string CalculateSpanOffset();
- int AddRenderObject(int index, RenderObject *child);
+ float TakeStyleWidth();
- void AddRenderObjectWidth(RenderObject *child, const bool updating);
+ int AddRenderObject(int index, RenderObject *child);
- void UpdateAttr(std::string key, std::string value);
+ void AddRenderObjectWidth(RenderObject *child, const bool updating);
- float TakeColumnCount();
+ void UpdateAttr(std::string key, std::string value);
- float TakeColumnGap();
+ float TakeColumnCount();
- float TakeColumnWidth();
+ float TakeColumnGap();
- float TakeLeftGap();
+ float TakeColumnWidth();
- float TakeRightGap();
+ float TakeLeftGap();
- int TakeOrientation();
+ float TakeRightGap();
- inline float CalculateFreeSpaceAlongMainAxis(const float &width, const float &height,
- const float ¤tLength) const override {
- return NAN;
- }
+ int TakeOrientation();
- inline std::vector<RenderObject *> &CellSlots() {
- return cell_slots_;
- }
+ inline float CalculateFreeSpaceAlongMainAxis(
+ const float &width, const float &height,
+ const float ¤tLength) const override {
+ return NAN;
+ }
- private:
+ inline std::vector<RenderObject *> &CellSlots() { return cell_slots_; }
- bool is_pre_calculate_cell_width_ = false;
- int column_count_ = COLUMN_COUNT_NORMAL;
- float column_width_ = AUTO_VALUE;
- float available_width_ = 0;
- float column_gap_ = COLUMN_GAP_NORMAL;
- bool is_set_flex_ = false;
- std::vector<RenderObject *> cell_slots_;
- std::vector<RenderObject *> cell_slots_copys_;
- float left_gap_ = 0;
- float right_gap_ = 0;
- };
-}
+ private:
+ bool is_pre_calculate_cell_width_ = false;
+ int column_count_ = COLUMN_COUNT_NORMAL;
+ float column_width_ = AUTO_VALUE;
+ float available_width_ = 0;
+ float column_gap_ = COLUMN_GAP_NORMAL;
+ bool is_set_flex_ = false;
+ std::vector<RenderObject *> cell_slots_;
+ std::vector<RenderObject *> cell_slots_copys_;
+ float left_gap_ = 0;
+ float right_gap_ = 0;
+};
+} // namespace WeexCore
-#endif //WEEX_PROJECT_RENDERLIST_H
+#endif // CORE_RENDER_NODE_RENDER_LIST_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_mask.cpp
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_mask.cpp b/weex_core/Source/core/render/node/render_mask.cpp
index 76965a4..df925a2 100644
--- a/weex_core/Source/core/render/node/render_mask.cpp
+++ b/weex_core/Source/core/render/node/render_mask.cpp
@@ -17,38 +17,47 @@
* under the License.
*/
#include <cstdlib>
+#include <utility>
-#include "core/render/node/render_mask.h"
+#include "base/ViewUtils.h"
#include "core/config/core_environment.h"
#include "core/css/constants_name.h"
-#include "base/ViewUtils.h"
+#include "core/render/node/render_mask.h"
namespace WeexCore {
- std::map<std::string, std::string> *RenderMask::GetDefaultStyle() {
- std::map<std::string, std::string> *style = new std::map<std::string, std::string>();
+std::map<std::string, std::string> *RenderMask::GetDefaultStyle() {
+ std::map<std::string, std::string> *style =
+ new std::map<std::string, std::string>();
- int width = WXCoreEnvironment::getInstance()->DeviceWidth();
- int height = WXCoreEnvironment::getInstance()->DeviceHeight();
+ int width = WXCoreEnvironment::getInstance()->DeviceWidth();
+ int height = WXCoreEnvironment::getInstance()->DeviceHeight();
- if (WXCoreEnvironment::getInstance()->GetOption("screen_width_pixels") != "" &&
- WXCoreEnvironment::getInstance()->GetOption("screen_height_pixels") != "") {
- width = atoi(WXCoreEnvironment::getInstance()->GetOption("screen_width_pixels").c_str());
- height = atoi(WXCoreEnvironment::getInstance()->GetOption("screen_height_pixels").c_str());
- }
-
- if (WXCoreEnvironment::getInstance()->GetOption("status_bar_height") != "") {
- int statusBarHeight = atoi(
- WXCoreEnvironment::getInstance()->GetOption("status_bar_height").c_str());
- height -= statusBarHeight;
- }
+ if (WXCoreEnvironment::getInstance()->GetOption("screen_width_pixels") !=
+ "" &&
+ WXCoreEnvironment::getInstance()->GetOption("screen_height_pixels") !=
+ "") {
+ width = atoi(WXCoreEnvironment::getInstance()
+ ->GetOption("screen_width_pixels")
+ .c_str());
+ height = atoi(WXCoreEnvironment::getInstance()
+ ->GetOption("screen_height_pixels")
+ .c_str());
+ }
- style->insert(std::pair<std::string, std::string>(POSITION, "absolute"));
- style->insert(std::pair<std::string, std::string>(WIDTH, to_string(
- getWebPxByWidth(width, GetViewPortWidth()))));
- style->insert(std::pair<std::string, std::string>(HEIGHT, to_string(
- getWebPxByWidth(height, GetViewPortWidth()))));
- style->insert(std::pair<std::string, std::string>(TOP, "0"));
- return style;
+ if (WXCoreEnvironment::getInstance()->GetOption("status_bar_height") != "") {
+ int status_bar_height = atoi(WXCoreEnvironment::getInstance()
+ ->GetOption("status_bar_height")
+ .c_str());
+ height -= status_bar_height;
}
+
+ style->insert(std::pair<std::string, std::string>(POSITION, "absolute"));
+ style->insert(std::pair<std::string, std::string>(
+ WIDTH, to_string(getWebPxByWidth(width, GetViewPortWidth()))));
+ style->insert(std::pair<std::string, std::string>(
+ HEIGHT, to_string(getWebPxByWidth(height, GetViewPortWidth()))));
+ style->insert(std::pair<std::string, std::string>(TOP, "0"));
+ return style;
}
+} // namespace WeexCore
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/weex_core/Source/core/render/node/render_mask.h
----------------------------------------------------------------------
diff --git a/weex_core/Source/core/render/node/render_mask.h b/weex_core/Source/core/render/node/render_mask.h
index eb6d4a6..38201d0 100644
--- a/weex_core/Source/core/render/node/render_mask.h
+++ b/weex_core/Source/core/render/node/render_mask.h
@@ -16,19 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-#ifndef WEEX_PROJECT_RENDERMASK_H
-#define WEEX_PROJECT_RENDERMASK_H
+#ifndef CORE_RENDER_NODE_RENDER_MASK_H_
+#define CORE_RENDER_NODE_RENDER_MASK_H_
+
+#include <map>
+#include <string>
#include "core/render/node/render_object.h"
namespace WeexCore {
- class RenderMask : public RenderObject {
-
- public:
-
- std::map <std::string, std::string> *GetDefaultStyle();
-
- };
-}
-#endif //WEEX_PROJECT_RENDERMASK_H
+class RenderMask : public RenderObject {
+ public:
+ std::map<std::string, std::string> *GetDefaultStyle();
+};
+} // namespace WeexCore
+#endif // CORE_RENDER_NODE_RENDER_MASK_H_
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ad255b3a/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 6818cff..fe0d25f 100644
--- a/weex_core/Source/core/render/node/render_object.cpp
+++ b/weex_core/Source/core/render/node/render_object.cpp
@@ -17,428 +17,448 @@
* under the License.
*/
#include "core/render/node/render_object.h"
-#include "core/manager/weex_core_manager.h"
+#include "base/ViewUtils.h"
#include "core/css/constants_name.h"
#include "core/css/constants_value.h"
#include "core/css/css_value_getter.h"
#include "core/layout/layout.h"
+#include "core/manager/weex_core_manager.h"
#include "core/render/manager/render_manager.h"
#include "core/render/page/render_page.h"
-#include "base/ViewUtils.h"
namespace WeexCore {
- RenderObject::RenderObject() {
- this->styles_ = new std::map<std::string, std::string>();
- this->attributes_ = new std::map<std::string, std::string>();
- this->events_ = new std::set<std::string>();
- this->is_root_render_ = false;
- }
+RenderObject::RenderObject() {
+ this->styles_ = new std::map<std::string, std::string>();
+ this->attributes_ = new std::map<std::string, std::string>();
+ this->events_ = new std::set<std::string>();
+ this->is_root_render_ = false;
+}
- RenderObject::~RenderObject() {
-
- this->parent_render_ = nullptr;
-
- if (this->styles_ != nullptr) {
- delete this->styles_;
- this->styles_ = nullptr;
- }
-
- if (this->attributes_ != nullptr) {
- delete this->attributes_;
- this->attributes_ = nullptr;
- }
+RenderObject::~RenderObject() {
+ this->parent_render_ = nullptr;
- if (this->events_ != nullptr) {
- delete this->events_;
- this->events_ = nullptr;
- }
-
- for (auto it = ChildListIterBegin(); it != ChildListIterEnd(); it++) {
- RenderObject *child = static_cast<RenderObject *>(*it);
- if (child != nullptr) {
- delete child;
- child = nullptr;
- }
- }
+ if (this->styles_ != nullptr) {
+ delete this->styles_;
+ this->styles_ = nullptr;
}
- void RenderObject::ApplyDefaultStyle() {
- std::map<std::string, std::string> *style = GetDefaultStyle();
-
- if (style == nullptr)
- return;
+ if (this->attributes_ != nullptr) {
+ delete this->attributes_;
+ this->attributes_ = nullptr;
+ }
- for (auto iter = style->cbegin(); iter != style->cend(); iter++)
- AddStyle(iter->first, iter->second);
+ if (this->events_ != nullptr) {
+ delete this->events_;
+ this->events_ = nullptr;
+ }
- if (style != nullptr) {
- delete style;
- style = nullptr;
+ for (auto it = ChildListIterBegin(); it != ChildListIterEnd(); it++) {
+ RenderObject *child = static_cast<RenderObject *>(*it);
+ if (child != nullptr) {
+ delete child;
+ child = nullptr;
}
}
+}
- void RenderObject::ApplyDefaultAttr() {
- std::map<std::string, std::string> *attrs = GetDefaultAttr();
+void RenderObject::ApplyDefaultStyle() {
+ std::map<std::string, std::string> *style = GetDefaultStyle();
- if (attrs == nullptr)
- return;
+ if (style == nullptr) return;
- for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
- UpdateAttr(iter->first, iter->second);
- }
+ for (auto iter = style->cbegin(); iter != style->cend(); iter++)
+ AddStyle(iter->first, iter->second);
- if (attrs != nullptr) {
- delete attrs;
- attrs = nullptr;
- }
+ if (style != nullptr) {
+ delete style;
+ style = nullptr;
}
+}
- WXCoreSize measureFunc_Impl(WXCoreLayoutNode *node, float width, MeasureMode widthMeasureMode,
- float height, MeasureMode heightMeasureMode) {
- WXCoreSize size;
- size.height = 0;
- size.width = 0;
-
- if (WeexCoreManager::getInstance()->GetMeasureFunctionAdapter() == nullptr)
- return size;
+void RenderObject::ApplyDefaultAttr() {
+ std::map<std::string, std::string> *attrs = GetDefaultAttr();
- return WeexCoreManager::getInstance()->GetMeasureFunctionAdapter()->Measure(node, width,
- widthMeasureMode,
- height,
- heightMeasureMode);
- }
+ if (attrs == nullptr) return;
- void RenderObject::BindMeasureFunc() {
- setMeasureFunc(measureFunc_Impl);
+ for (auto iter = attrs->cbegin(); iter != attrs->cend(); iter++) {
+ UpdateAttr(iter->first, iter->second);
}
- void RenderObject::OnLayoutBefore() {
- if (WeexCoreManager::getInstance()->GetMeasureFunctionAdapter() == nullptr)
- return;
- WeexCoreManager::getInstance()->GetMeasureFunctionAdapter()->LayoutBefore(this);
+ if (attrs != nullptr) {
+ delete attrs;
+ attrs = nullptr;
}
-
- void RenderObject::OnLayoutAfter(float width, float height) {
- if (WeexCoreManager::getInstance()->GetMeasureFunctionAdapter() == nullptr)
- return;
- WeexCoreManager::getInstance()->GetMeasureFunctionAdapter()->LayoutAfter(this, width, height);
+}
+
+WXCoreSize measureFunc_Impl(WXCoreLayoutNode *node, float width,
+ MeasureMode widthMeasureMode, float height,
+ MeasureMode heightMeasureMode) {
+ WXCoreSize size;
+ size.height = 0;
+ size.width = 0;
+
+ if (WeexCoreManager::getInstance()->GetMeasureFunctionAdapter() == nullptr)
+ return size;
+
+ return WeexCoreManager::getInstance()->GetMeasureFunctionAdapter()->Measure(
+ node, width, widthMeasureMode, height, heightMeasureMode);
+}
+
+void RenderObject::BindMeasureFunc() { setMeasureFunc(measureFunc_Impl); }
+
+void RenderObject::OnLayoutBefore() {
+ if (WeexCoreManager::getInstance()->GetMeasureFunctionAdapter() == nullptr)
+ return;
+ WeexCoreManager::getInstance()->GetMeasureFunctionAdapter()->LayoutBefore(
+ this);
+}
+
+void RenderObject::OnLayoutAfter(float width, float height) {
+ if (WeexCoreManager::getInstance()->GetMeasureFunctionAdapter() == nullptr)
+ return;
+ WeexCoreManager::getInstance()->GetMeasureFunctionAdapter()->LayoutAfter(
+ this, width, height);
+}
+
+StyleType RenderObject::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)) {
+ MapInsertOrAssign(this->styles_, key, value);
+ insert = true;
}
- StyleType
- RenderObject::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)) {
- MapInsertOrAssign(this->styles_, key, value);
- insert = true;
- }
-
- if (key == ALIGN_ITEMS) {
- setAlignItems(GetWXCoreAlignItem(value));
- return kTypeLayout;
- } else if (key == ALIGN_SELF) {
- setAlignSelf(GetWXCoreAlignSelf(value));
- return kTypeLayout;
- } else if (key == FLEX) {
- if (value.empty()) {
- set_flex(0);
- } else {
- float ret = getFloat(value.c_str());
- if (!isnan(ret)) {
- set_flex(ret);
- }
- }
- return kTypeLayout;
- } else if (key == FLEX_DIRECTION) {
- setFlexDirection(GetWXCoreFlexDirection(value), updating);
- return kTypeLayout;
- } else if (key == JUSTIFY_CONTENT) {
- setJustifyContent(GetWXCoreJustifyContent(value));
- return kTypeLayout;
- } else if (key == FLEX_WRAP) {
- setFlexWrap(GetWXCoreFlexWrap(value));
- return kTypeLayout;
- } else if (key == MIN_WIDTH) {
- UpdateStyleInternal(key, value, NAN, [=](float foo) { setMinWidth(foo, updating); });
- return kTypeLayout;
- } else if (key == MIN_HEIGHT) {
- UpdateStyleInternal(key, value, NAN, [=](float foo) { setMinHeight(foo); });
- return kTypeLayout;
- } else if (key == MAX_WIDTH) {
- UpdateStyleInternal(key, value, NAN, [=](float foo) { setMaxWidth(foo, updating); });
- return kTypeLayout;
- } else if (key == MAX_HEIGHT) {
- UpdateStyleInternal(key, value, NAN, [=](float foo) { setMaxHeight(foo); });
- return kTypeLayout;
- } else if (key == HEIGHT) {
- if (UpdateStyleInternal(key, value, NAN, [=](float foo) { setStyleHeight(foo); })) {
- setStyleHeightLevel(CSS_STYLE);
- }
- return kTypeLayout;
- } else if (key == WIDTH) {
- if (UpdateStyleInternal(key, value, NAN, [=](float foo) { setStyleWidth(foo, updating); })) {
- setStyleWidthLevel(CSS_STYLE);
- }
- return kTypeLayout;
- } else if (key == POSITION) {
- setStylePositionType(GetWXCorePositionType(value));
- if (value == STICKY) {
- this->is_sticky_ = true;
- }
- MapInsertOrAssign(this->styles_, key, value);
- return kTypeStyle;
- } else if (key == LEFT) {
- UpdateStyleInternal(key, value, NAN,
- [=](float foo) { setStylePosition(kPositionEdgeLeft, foo); });
- return kTypeLayout;
- } else if (key == TOP) {
- UpdateStyleInternal(key, value, NAN,
- [=](float foo) { setStylePosition(kPositionEdgeTop, foo); });
- return kTypeLayout;
- } else if (key == RIGHT) {
- UpdateStyleInternal(key, value, NAN,
- [=](float foo) { setStylePosition(kPositionEdgeRight, foo); });
- return kTypeLayout;
- } else if (key == BOTTOM) {
- UpdateStyleInternal(key, value, NAN,
- [=](float foo) { setStylePosition(kPositionEdgeBottom, foo); });
- return kTypeLayout;
- } else if (key == MARGIN) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setMargin(kMarginALL, foo); });
- return kTypeMargin;
- } else if (key == MARGIN_LEFT) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setMargin(kMarginLeft, foo); });
- return kTypeMargin;
- } else if (key == MARGIN_TOP) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setMargin(kMarginTop, foo); });
- return kTypeMargin;
- } else if (key == MARGIN_RIGHT) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setMargin(kMarginRight, foo); });
- return kTypeMargin;
- } else if (key == MARGIN_BOTTOM) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setMargin(kMarginBottom, foo); });
- return kTypeMargin;
- } else if (key == BORDER_WIDTH) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setBorderWidth(kBorderWidthALL, foo); });
- return kTypeBorder;
- } else if (key == BORDER_TOP_WIDTH) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setBorderWidth(kBorderWidthTop, foo); });
- return kTypeBorder;
- } else if (key == BORDER_RIGHT_WIDTH) {
- UpdateStyleInternal(key, value, 0,
- [=](float foo) { setBorderWidth(kBorderWidthRight, foo); });
- return kTypeBorder;
- } else if (key == BORDER_BOTTOM_WIDTH) {
- UpdateStyleInternal(key, value, 0,
- [=](float foo) { setBorderWidth(kBorderWidthBottom, foo); });
- return kTypeBorder;
- } else if (key == BORDER_LEFT_WIDTH) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setBorderWidth(kBorderWidthLeft, foo); });
- return kTypeBorder;
- } else if (key == PADDING) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setPadding(kPaddingALL, foo); });
- return kTypePadding;
- } else if (key == PADDING_LEFT) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setPadding(kPaddingLeft, foo); });
- return kTypePadding;
- } else if (key == PADDING_TOP) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setPadding(kPaddingTop, foo); });
- return kTypePadding;
- } else if (key == PADDING_RIGHT) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setPadding(kPaddingRight, foo); });
- return kTypePadding;
- } else if (key == PADDING_BOTTOM) {
- UpdateStyleInternal(key, value, 0, [=](float foo) { setPadding(kPaddingBottom, foo); });
- return kTypePadding;
+ if (key == ALIGN_ITEMS) {
+ setAlignItems(GetWXCoreAlignItem(value));
+ return kTypeLayout;
+ } else if (key == ALIGN_SELF) {
+ setAlignSelf(GetWXCoreAlignSelf(value));
+ return kTypeLayout;
+ } else if (key == FLEX) {
+ if (value.empty()) {
+ set_flex(0);
} else {
- if (!insert) {
- MapInsertOrAssign(this->styles_, key, value);
+ float ret = getFloat(value.c_str());
+ if (!isnan(ret)) {
+ set_flex(ret);
}
- return kTypeStyle;
}
- }
-
- const std::string RenderObject::GetStyle(const std::string &key) {
- if (this->styles_ == nullptr)
- return "";
-
- std::map<std::string, std::string>::iterator iter = this->styles_->find(key);
- if (iter != this->styles_->end()) {
- return iter->second;
- } else {
- return "";
+ return kTypeLayout;
+ } else if (key == FLEX_DIRECTION) {
+ setFlexDirection(GetWXCoreFlexDirection(value), updating);
+ return kTypeLayout;
+ } else if (key == JUSTIFY_CONTENT) {
+ setJustifyContent(GetWXCoreJustifyContent(value));
+ return kTypeLayout;
+ } else if (key == FLEX_WRAP) {
+ setFlexWrap(GetWXCoreFlexWrap(value));
+ return kTypeLayout;
+ } else if (key == MIN_WIDTH) {
+ UpdateStyleInternal(key, value, NAN,
+ [=](float foo) { setMinWidth(foo, updating); });
+ return kTypeLayout;
+ } else if (key == MIN_HEIGHT) {
+ UpdateStyleInternal(key, value, NAN, [=](float foo) { setMinHeight(foo); });
+ return kTypeLayout;
+ } else if (key == MAX_WIDTH) {
+ UpdateStyleInternal(key, value, NAN,
+ [=](float foo) { setMaxWidth(foo, updating); });
+ return kTypeLayout;
+ } else if (key == MAX_HEIGHT) {
+ UpdateStyleInternal(key, value, NAN, [=](float foo) { setMaxHeight(foo); });
+ return kTypeLayout;
+ } else if (key == HEIGHT) {
+ if (UpdateStyleInternal(key, value, NAN,
+ [=](float foo) { setStyleHeight(foo); })) {
+ setStyleHeightLevel(CSS_STYLE);
+ }
+ return kTypeLayout;
+ } else if (key == WIDTH) {
+ if (UpdateStyleInternal(key, value, NAN,
+ [=](float foo) { setStyleWidth(foo, updating); })) {
+ setStyleWidthLevel(CSS_STYLE);
}
+ return kTypeLayout;
+ } else if (key == POSITION) {
+ setStylePositionType(GetWXCorePositionType(value));
+ if (value == STICKY) {
+ this->is_sticky_ = true;
+ }
+ MapInsertOrAssign(this->styles_, key, value);
+ return kTypeStyle;
+ } else if (key == LEFT) {
+ UpdateStyleInternal(key, value, NAN, [=](float foo) {
+ setStylePosition(kPositionEdgeLeft, foo);
+ });
+ return kTypeLayout;
+ } else if (key == TOP) {
+ UpdateStyleInternal(key, value, NAN, [=](float foo) {
+ setStylePosition(kPositionEdgeTop, foo);
+ });
+ return kTypeLayout;
+ } else if (key == RIGHT) {
+ UpdateStyleInternal(key, value, NAN, [=](float foo) {
+ setStylePosition(kPositionEdgeRight, foo);
+ });
+ return kTypeLayout;
+ } else if (key == BOTTOM) {
+ UpdateStyleInternal(key, value, NAN, [=](float foo) {
+ setStylePosition(kPositionEdgeBottom, foo);
+ });
+ return kTypeLayout;
+ } else if (key == MARGIN) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setMargin(kMarginALL, foo); });
+ return kTypeMargin;
+ } else if (key == MARGIN_LEFT) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setMargin(kMarginLeft, foo); });
+ return kTypeMargin;
+ } else if (key == MARGIN_TOP) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setMargin(kMarginTop, foo); });
+ return kTypeMargin;
+ } else if (key == MARGIN_RIGHT) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setMargin(kMarginRight, foo); });
+ return kTypeMargin;
+ } else if (key == MARGIN_BOTTOM) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setMargin(kMarginBottom, foo); });
+ return kTypeMargin;
+ } else if (key == BORDER_WIDTH) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setBorderWidth(kBorderWidthALL, foo);
+ });
+ return kTypeBorder;
+ } else if (key == BORDER_TOP_WIDTH) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setBorderWidth(kBorderWidthTop, foo);
+ });
+ return kTypeBorder;
+ } else if (key == BORDER_RIGHT_WIDTH) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setBorderWidth(kBorderWidthRight, foo);
+ });
+ return kTypeBorder;
+ } else if (key == BORDER_BOTTOM_WIDTH) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setBorderWidth(kBorderWidthBottom, foo);
+ });
+ return kTypeBorder;
+ } else if (key == BORDER_LEFT_WIDTH) {
+ UpdateStyleInternal(key, value, 0, [=](float foo) {
+ setBorderWidth(kBorderWidthLeft, foo);
+ });
+ return kTypeBorder;
+ } else if (key == PADDING) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setPadding(kPaddingALL, foo); });
+ return kTypePadding;
+ } else if (key == PADDING_LEFT) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setPadding(kPaddingLeft, foo); });
+ return kTypePadding;
+ } else if (key == PADDING_TOP) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setPadding(kPaddingTop, foo); });
+ return kTypePadding;
+ } else if (key == PADDING_RIGHT) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setPadding(kPaddingRight, foo); });
+ return kTypePadding;
+ } else if (key == PADDING_BOTTOM) {
+ UpdateStyleInternal(key, value, 0,
+ [=](float foo) { setPadding(kPaddingBottom, foo); });
+ return kTypePadding;
+ } else {
+ if (!insert) {
+ MapInsertOrAssign(this->styles_, key, value);
+ }
+ return kTypeStyle;
}
+}
- const std::string RenderObject::GetAttr(const std::string &key) {
- if (this->attributes_ == nullptr)
- return "";
+const std::string RenderObject::GetStyle(const std::string &key) {
+ if (this->styles_ == nullptr) return "";
- std::map<std::string, std::string>::iterator iter = this->attributes_->find(key);
- if (iter != this->attributes_->end()) {
- return iter->second;
- } else {
- return "";
- }
+ std::map<std::string, std::string>::iterator iter = this->styles_->find(key);
+ if (iter != this->styles_->end()) {
+ return iter->second;
+ } else {
+ return "";
}
+}
- float RenderObject::GetViewPortWidth() {
- if (this->viewport_width_ >= 0)
- return this->viewport_width_;
+const std::string RenderObject::GetAttr(const std::string &key) {
+ if (this->attributes_ == nullptr) return "";
- RenderPage *page = GetRenderPage();
- if (page == nullptr)
- return kDefaultViewPortWidth;
-
- return page->ViewPortWidth();
+ std::map<std::string, std::string>::iterator iter =
+ this->attributes_->find(key);
+ if (iter != this->attributes_->end()) {
+ return iter->second;
+ } else {
+ return "";
}
+}
- int RenderObject::AddRenderObject(int index, RenderObject *child) {
- if (child == nullptr || index < -1) {
- return index;
- }
+float RenderObject::GetViewPortWidth() {
+ if (this->viewport_width_ >= 0) return this->viewport_width_;
- Index count = getChildCount();
- index = index >= count ? -1 : index;
- if (index == -1) {
- addChildAt(child, getChildCount());
- } else {
- addChildAt(child, index);
- }
+ RenderPage *page = GetRenderPage();
+ if (page == nullptr) return kDefaultViewPortWidth;
- child->set_parent_render(this);
+ return page->viewport_width();
+}
+int RenderObject::AddRenderObject(int index, RenderObject *child) {
+ if (child == nullptr || index < -1) {
return index;
}
- Index RenderObject::IndexOf(const RenderObject *render) {
- if (render == nullptr) {
- return -1;
- } else {
- int i = 0;
- for (auto it = ChildListIterBegin(); it != ChildListIterEnd(); it++) {
- RenderObject *child = static_cast<RenderObject *>(*it);
- if (child != nullptr) {
- if (render->ref() == child->ref())
- return i;
- }
- ++i;
- }
- }
- return -1;
+ Index count = getChildCount();
+ index = index >= count ? -1 : index;
+ if (index == -1) {
+ addChildAt(child, getChildCount());
+ } else {
+ addChildAt(child, index);
}
- bool RenderObject::UpdateStyleInternal(const std::string key, const std::string value,
- float fallback,
- std::function<void(float)> functor) {
- bool ret = false;
- if (value.empty()) {
- functor(fallback);
- ret = true;
- } else {
- float fvalue = getFloatByViewport(value, GetViewPortWidth());
- if (!isnan(fvalue)) {
- functor(fvalue);
- ret = true;
- }
- }
- return ret;
- }
+ child->set_parent_render(this);
- void RenderObject::LayoutBeforeImpl() {
- if (isDirty()) {
- OnLayoutBefore();
- }
+ return index;
+}
+Index RenderObject::IndexOf(const RenderObject *render) {
+ if (render == nullptr) {
+ return -1;
+ } else {
+ int i = 0;
for (auto it = ChildListIterBegin(); it != ChildListIterEnd(); it++) {
RenderObject *child = static_cast<RenderObject *>(*it);
if (child != nullptr) {
- child->LayoutBeforeImpl();
+ if (render->ref() == child->ref()) return i;
}
+ ++i;
}
}
-
- void RenderObject::LayoutAfterImpl() {
- if (hasNewLayout()) {
- OnLayoutAfter(getLayoutWidth(), getLayoutHeight());
- }
-
- for (auto it = ChildListIterBegin(); it != ChildListIterEnd(); it++) {
- RenderObject *child = static_cast<RenderObject *>(*it);
- if (child != nullptr) {
- child->LayoutAfterImpl();
- }
+ return -1;
+}
+
+bool RenderObject::UpdateStyleInternal(const std::string key,
+ const std::string value, float fallback,
+ std::function<void(float)> functor) {
+ bool ret = false;
+ if (value.empty()) {
+ functor(fallback);
+ ret = true;
+ } else {
+ float fvalue = getFloatByViewport(value, GetViewPortWidth());
+ if (!isnan(fvalue)) {
+ functor(fvalue);
+ ret = true;
}
}
+ return ret;
+}
- void RenderObject::CopyFrom(RenderObject *src) {
- IRenderObject::CopyFrom(src);
- this->styles_->insert(src->styles_->begin(), src->styles_->end());
- this->attributes_->insert(src->attributes_->begin(), src->attributes_->end());
- this->events_->insert(src->events_->begin(), src->events_->end());
+void RenderObject::LayoutBeforeImpl() {
+ if (isDirty()) {
+ OnLayoutBefore();
}
- void RenderObject::MapInsertOrAssign(std::map<std::string, std::string> *targetMap,
- const std::string &key, const std::string &value) {
- std::map<std::string, std::string>::iterator it = targetMap->find(key);
- if (it != targetMap->end()) {
- it->second = value;
- } else {
- targetMap->insert({key, value});
+ for (auto it = ChildListIterBegin(); it != ChildListIterEnd(); it++) {
+ RenderObject *child = static_cast<RenderObject *>(*it);
+ if (child != nullptr) {
+ child->LayoutBeforeImpl();
}
}
+}
- bool RenderObject::ViewInit() {
- return (!isnan(getStyleWidth()) && getStyleWidth() > 0) ||
- (is_root_render() && GetRenderPage() != nullptr &&
- GetRenderPage()->GetRenderContainerWidthWrapContent());
+void RenderObject::LayoutAfterImpl() {
+ if (hasNewLayout()) {
+ OnLayoutAfter(getLayoutWidth(), getLayoutHeight());
}
- RenderPage *RenderObject::GetRenderPage() {
- return RenderManager::GetInstance()->GetPage(page_id());
- }
-
- bool RenderObject::IsAppendTree() {
- std::string append = GetAttr(APPEND);
- if (append == "tree") {
- return true;
+ for (auto it = ChildListIterBegin(); it != ChildListIterEnd(); it++) {
+ RenderObject *child = static_cast<RenderObject *>(*it);
+ if (child != nullptr) {
+ child->LayoutAfterImpl();
}
- return false;
}
-
- void RenderObject::UpdateAttr(std::string key, std::string value) {
- MapInsertOrAssign(this->attributes_, key, value);
+}
+
+void RenderObject::CopyFrom(RenderObject *src) {
+ IRenderObject::CopyFrom(src);
+ this->styles_->insert(src->styles_->begin(), src->styles_->end());
+ this->attributes_->insert(src->attributes_->begin(), src->attributes_->end());
+ this->events_->insert(src->events_->begin(), src->events_->end());
+}
+
+void RenderObject::MapInsertOrAssign(
+ std::map<std::string, std::string> *targetMap, const std::string &key,
+ const std::string &value) {
+ std::map<std::string, std::string>::iterator it = targetMap->find(key);
+ if (it != targetMap->end()) {
+ it->second = value;
+ } else {
+ targetMap->insert({key, value});
}
-
- StyleType RenderObject::UpdateStyle(std::string key, std::string value) {
- return ApplyStyle(key, value, true);
+}
+
+bool RenderObject::ViewInit() {
+ return (!isnan(getStyleWidth()) && getStyleWidth() > 0) ||
+ (is_root_render() && GetRenderPage() != nullptr &&
+ GetRenderPage()->is_render_container_width_wrap_content());
+}
+
+RenderPage *RenderObject::GetRenderPage() {
+ return RenderManager::GetInstance()->GetPage(page_id());
+}
+
+bool RenderObject::IsAppendTree() {
+ std::string append = GetAttr(APPEND);
+ if (append == "tree") {
+ return true;
}
+ return false;
+}
- RenderObject* RenderObject::GetChild(const Index &index) {
- return static_cast<RenderObject*>(getChildAt(index));
- }
+void RenderObject::UpdateAttr(std::string key, std::string value) {
+ MapInsertOrAssign(this->attributes_, key, value);
+}
- void RenderObject::RemoveRenderObject(RenderObject *child) {
- removeChild(child);
- }
+StyleType RenderObject::UpdateStyle(std::string key, std::string value) {
+ return ApplyStyle(key, value, true);
+}
- void RenderObject::AddAttr(std::string key, std::string value) {
- MapInsertOrAssign(this->attributes_, key, value);
- }
+RenderObject *RenderObject::GetChild(const Index &index) {
+ return static_cast<RenderObject *>(getChildAt(index));
+}
- StyleType RenderObject::AddStyle(std::string key, std::string value) {
- return ApplyStyle(key, value, false);
- }
+void RenderObject::RemoveRenderObject(RenderObject *child) {
+ removeChild(child);
+}
- void RenderObject::AddEvent(std::string event) {
- if (this->events_ == nullptr || this->events_->empty()) {
- this->events_ = new std::set<std::string>();
- }
- this->events_->insert(event);
- }
+void RenderObject::AddAttr(std::string key, std::string value) {
+ MapInsertOrAssign(this->attributes_, key, value);
+}
+
+StyleType RenderObject::AddStyle(std::string key, std::string value) {
+ return ApplyStyle(key, value, false);
+}
- void RenderObject::RemoveEvent(const std::string &event) {
- this->events_->erase(event);
+void RenderObject::AddEvent(std::string event) {
+ if (this->events_ == nullptr || this->events_->empty()) {
+ this->events_ = new std::set<std::string>();
}
-} //end WeexCore
+ this->events_->insert(event);
+}
+
+void RenderObject::RemoveEvent(const std::string &event) {
+ this->events_->erase(event);
+}
+} // namespace WeexCore