Skip to content

Commit

Permalink
Merge branch 'main' into feature/update-vue-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
open-hippy authored Sep 4, 2023
2 parents 0bad6f7 + 208ba93 commit 76842ec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
6 changes: 6 additions & 0 deletions dom/include/dom/dom_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class DomNode : public std::enable_shared_from_this<DomNode> {
inline void SetLayoutOnly(bool layout_only) { layout_only_ = layout_only; }
inline bool IsVirtual() { return is_virtual_; }
inline void SetIsVirtual(bool is_virtual) { is_virtual_ = is_virtual; }
inline bool IsEnableEliminated() { return enable_eliminated_; }
inline void SetEnableEliminated(bool enable_eliminated) { enable_eliminated_ = enable_eliminated; }
inline void SetIndex(int32_t index) { index_ = index; }
inline int32_t GetIndex() const { return index_; }
inline void SetRootNode(std::weak_ptr<RootNode> root_node) { root_node_ = root_node; }
Expand Down Expand Up @@ -230,6 +232,10 @@ class DomNode : public std::enable_shared_from_this<DomNode> {
bool is_virtual_{};
bool layout_only_ = false;

// Node can only be eliminated for the first time,
// and if they cannot be eliminated for the first time, they cannot be eliminated at all times.
bool enable_eliminated_ = true;

std::weak_ptr<DomNode> parent_;
std::vector<std::shared_ptr<DomNode>> children_;

Expand Down
4 changes: 0 additions & 4 deletions dom/include/dom/layer_optimized_render_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ class LayerOptimizedRenderManager : public RenderManager {

void FindValidChildren(const std::shared_ptr<DomNode>& node,
std::vector<std::shared_ptr<DomNode>>& valid_children_nodes);

// Record nodes that cannot be eliminated. Nodes can only be eliminated for the first time,
// and if they cannot be eliminated for the first time, they cannot be eliminated at all times.
std::set<uint32_t> not_eliminated_node_ids_;
};

} // namespace dom
Expand Down
18 changes: 2 additions & 16 deletions dom/src/dom/layer_optimized_render_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,6 @@ void LayerOptimizedRenderManager::DeleteRenderNode(std::weak_ptr<RootNode> root_
FOOTSTONE_DLOG(INFO) << "[Hippy Statistic] delete node size before optimize = " << nodes.size()
<< ", delete node size after optimize = " << nodes_to_delete.size();
if (!nodes_to_delete.empty()) {
for (auto& node : nodes_to_delete) {
// Recursively delete all ids on the node tree.
std::vector<std::shared_ptr<DomNode>> node_stack;
node_stack.push_back(node);
while (!node_stack.empty()) {
auto back_node = node_stack.back();
node_stack.pop_back();
not_eliminated_node_ids_.erase(back_node->GetId());
for (auto& child : back_node->GetChildren()) {
node_stack.push_back(child);
}
}
}
render_manager_->DeleteRenderNode(root_node, std::move(nodes_to_delete));
}
}
Expand Down Expand Up @@ -289,10 +276,9 @@ bool LayerOptimizedRenderManager::IsJustLayoutProp(const char *prop_name) const
}

bool LayerOptimizedRenderManager::CanBeEliminated(const std::shared_ptr<DomNode>& node) {
bool eliminated = (node->IsLayoutOnly() || node->IsVirtual()) &&
(not_eliminated_node_ids_.find(node->GetId()) == not_eliminated_node_ids_.end());
bool eliminated = (node->IsLayoutOnly() || node->IsVirtual()) && node->IsEnableEliminated();
if (!eliminated) {
not_eliminated_node_ids_.insert(node->GetId());
node->SetEnableEliminated(false);
}
return eliminated;
}
Expand Down

0 comments on commit 76842ec

Please sign in to comment.