Skip to content

Commit

Permalink
feat(dom): fix trigger error on layout event
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikethese authored and hippy-actions[bot] committed Sep 8, 2023
1 parent a82a4c3 commit 3624aa4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions dom/src/dom/dom_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ LayoutResult DomNode::GetLayoutInfoFromRoot() {
void DomNode::TransferLayoutOutputsRecursive(std::vector<std::shared_ptr<DomNode>>& changed_nodes) {
auto not_equal = std::not_equal_to<>();
bool changed = layout_node_->IsDirty() || layout_node_->HasNewLayout();
bool has_new_layout = layout_node_->HasNewLayout();

layout_.left = layout_node_->GetLeft();
layout_.top = layout_node_->GetTop();
Expand Down Expand Up @@ -364,19 +365,19 @@ void DomNode::TransferLayoutOutputsRecursive(std::vector<std::shared_ptr<DomNode
layout_param[kLayoutHeightKey] = HippyValue(layout_.height);
HippyValueObjectType layout_obj;
layout_obj[kLayoutLayoutKey] = layout_param;
auto event =
std::make_shared<DomEvent>(kLayoutEvent,
weak_from_this(),
std::make_shared<HippyValue>(std::move(layout_obj)));
auto root = root_node_.lock();
if (root != nullptr) {
auto manager = root->GetDomManager().lock();
if (manager != nullptr) {
std::vector<std::function<void()>> ops = {[WEAK_THIS, event] {
DEFINE_AND_CHECK_SELF(DomNode)
self->HandleEvent(event);
}};
manager->PostTask(Scene(std::move(ops)));
if (has_new_layout) {
auto event = std::make_shared<DomEvent>(kLayoutEvent, weak_from_this(),
std::make_shared<HippyValue>(std::move(layout_obj)));
auto root = root_node_.lock();
if (root != nullptr) {
auto manager = root->GetDomManager().lock();
if (manager != nullptr) {
std::vector<std::function<void()>> ops = {[WEAK_THIS, event] {
DEFINE_AND_CHECK_SELF(DomNode)
self->HandleEvent(event);
}};
manager->PostTask(Scene(std::move(ops)));
}
}
}
}
Expand Down

0 comments on commit 3624aa4

Please sign in to comment.