Skip to content

Commit

Permalink
fix(devtools): fix dom box size return (0,0,0,0)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilikethese committed Dec 20, 2023
1 parent 305cc5a commit 825a4fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class DevToolsUtil {

static void PostDomTask(const std::weak_ptr<DomManager>& weak_dom_manager, std::function<void()> func);

static bool ShouldAvoidPostDomManagerTask(const std::string& event_name);

private:
static std::shared_ptr<DomNode> GetHitNode(const std::shared_ptr<DomNode>& root_node, const std::shared_ptr<DomNode>& node, double x, double y);
static bool IsLocationHitNode(const std::shared_ptr<DomNode>& root_node, const std::shared_ptr<DomNode>& dom_node, double x, double y);
Expand Down
9 changes: 9 additions & 0 deletions devtools/devtools-integration/native/src/devtools_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,13 @@ void DevToolsUtil::PostDomTask(const std::weak_ptr<DomManager>& weak_dom_manager
dom_manager->PostTask(hippy::dom::Scene(std::move(ops)));
}
}

/**
* Specific methods like getLocationOnScreen should wait in the dom manager task runner. To avoid a deadlock, the
* callback must not be posted in the same task runner.
*/
bool DevToolsUtil::ShouldAvoidPostDomManagerTask(const std::string& event_name) {
return event_name == kGetLocationOnScreen;
}

} // namespace hippy::devtools
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "jni/jni_env.h"
#include "renderer/native_render_manager.h"

#ifdef ENABLE_INSPECTOR
#include "devtools/devtools_utils.h"
#endif

using DomArgument = hippy::dom::DomArgument;
using DomEvent = hippy::dom::DomEvent;
Expand Down Expand Up @@ -291,6 +294,12 @@ void DoCallBack(JNIEnv *j_env, jobject j_object,

callback(std::make_shared<DomArgument>(*params));
}};
#ifdef ENABLE_INSPECTOR
if (hippy::devtools::DevToolsUtil::ShouldAvoidPostDomManagerTask(func_name)) {
ops[0]();
return;
}
#endif
dom_manager->PostTask(Scene(std::move(ops)));
}

Expand Down

0 comments on commit 825a4fb

Please sign in to comment.