Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

[Android] Fix Waterfall Can't Change Column Count Bug #2105

Merged
merged 1 commit into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions weex_core/Source/core/render/node/render_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ||
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions weex_core/Source/core/render/node/render_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion weex_core/Source/core/render/node/render_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down