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 2019/02/13 07:09:41 UTC
[incubator-weex] branch master updated: * [Android] Fix Waterfall
Can't Change Column Count Bug (#2105)
This is an automated email from the ASF dual-hosted git repository.
kyork pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new c077fcb * [Android] Fix Waterfall Can't Change Column Count Bug (#2105)
c077fcb is described below
commit c077fcb356bfc658a75cf08086ce34796795785b
Author: codefurture <gu...@163.com>
AuthorDate: Wed Feb 13 15:09:35 2019 +0800
* [Android] Fix Waterfall Can't Change Column Count Bug (#2105)
Fix https://github.com/apache/incubator-weex/issues/1995
Demo http://dotwe.org/vue/96fcc3687dcfe91f6c5094e482936cc0
---
weex_core/Source/core/render/node/render_list.cpp | 28 +++++++++++++++++++----
weex_core/Source/core/render/node/render_list.h | 4 ++++
weex_core/Source/core/render/node/render_object.h | 2 +-
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/weex_core/Source/core/render/node/render_list.cpp b/weex_core/Source/core/render/node/render_list.cpp
index 4dc0a33..0e724e9 100644
--- a/weex_core/Source/core/render/node/render_list.cpp
+++ b/weex_core/Source/core/render/node/render_list.cpp
@@ -276,7 +276,15 @@ void RenderList::AddRenderObjectWidth(RenderObject *child,
}
}
+
+void RenderList::AddAttr(std::string key, std::string value) {
+ MapInsertOrAssign(&mOriginalAttrs, key, value);
+ RenderObject::AddAttr(key, value);
+}
+
+
void RenderList::UpdateAttr(std::string key, std::string value) {
+ MapInsertOrAssign(&mOriginalAttrs, key, value);
RenderObject::UpdateAttr(key, value);
if (!GetAttr(COLUMN_COUNT).empty() || !GetAttr(COLUMN_GAP).empty() ||
@@ -295,8 +303,18 @@ void RenderList::UpdateAttr(std::string key, std::string value) {
}
}
+static const std::string GetMapAttr(std::map<std::string,std::string>* attrs, const std::string &key) {
+ if (attrs == nullptr) return "";
+ std::map<std::string, std::string>::iterator iter = attrs->find(key);
+ if (iter != attrs->end()) {
+ return iter->second;
+ } else {
+ return "";
+ }
+}
+
float RenderList::TakeColumnCount() {
- std::string column_count = GetAttr(COLUMN_COUNT);
+ std::string column_count = GetMapAttr(&mOriginalAttrs, COLUMN_COUNT);
if (column_count.empty() || column_count == AUTO) {
return AUTO_VALUE;
@@ -308,7 +326,7 @@ float RenderList::TakeColumnCount() {
}
float RenderList::TakeColumnGap() {
- std::string column_gap = GetAttr(COLUMN_GAP);
+ std::string column_gap = GetMapAttr(&mOriginalAttrs, COLUMN_GAP);
if (column_gap.empty() || column_gap == NORMAL) {
return COLUMN_GAP_NORMAL;
@@ -320,7 +338,7 @@ float RenderList::TakeColumnGap() {
}
float RenderList::TakeColumnWidth() {
- std::string column_width = GetAttr(COLUMN_WIDTH);
+ std::string column_width = GetMapAttr(&mOriginalAttrs, COLUMN_WIDTH);
if (column_width.empty() || column_width == AUTO) {
return AUTO_VALUE;
@@ -332,7 +350,7 @@ float RenderList::TakeColumnWidth() {
}
float RenderList::TakeLeftGap() {
- std::string left_gap = GetAttr(LEFT_GAP);
+ std::string left_gap =GetMapAttr(&mOriginalAttrs, LEFT_GAP);
if (left_gap.empty() || left_gap == AUTO) {
return 0;
@@ -343,7 +361,7 @@ float RenderList::TakeLeftGap() {
}
float RenderList::TakeRightGap() {
- std::string right_gap = GetAttr(RIGHT_GAP);
+ std::string right_gap =GetMapAttr(&mOriginalAttrs, RIGHT_GAP);
if (right_gap.empty() || right_gap == AUTO) {
return 0;
diff --git a/weex_core/Source/core/render/node/render_list.h b/weex_core/Source/core/render/node/render_list.h
index eb01228..7250df9 100644
--- a/weex_core/Source/core/render/node/render_list.h
+++ b/weex_core/Source/core/render/node/render_list.h
@@ -50,6 +50,8 @@ class RenderList : public RenderObject {
void AddRenderObjectWidth(RenderObject *child, const bool updating);
+ void AddAttr(std::string key, std::string value) override;
+
void UpdateAttr(std::string key, std::string value) override;
float TakeColumnCount();
@@ -83,6 +85,8 @@ class RenderList : public RenderObject {
std::vector<RenderObject *> cell_slots_copys_;
float left_gap_ = 0;
float right_gap_ = 0;
+ std::map<std::string,std::string> mOriginalAttrs;
+
};
} // namespace WeexCore
diff --git a/weex_core/Source/core/render/node/render_object.h b/weex_core/Source/core/render/node/render_object.h
index 9522d9d..e97c50f 100644
--- a/weex_core/Source/core/render/node/render_object.h
+++ b/weex_core/Source/core/render/node/render_object.h
@@ -119,7 +119,7 @@ class RenderObject : public IRenderObject {
void RemoveRenderObject(RenderObject *child);
- void AddAttr(std::string key, std::string value);
+ virtual void AddAttr(std::string key, std::string value);
StyleType AddStyle(std::string key, std::string value);