moved PtrJNode map to YGJtypes.h and passing layout context as data in LayoutPassEnd Event
Summary: Move PtrJNodeMap to header file so that it can be accessed in events subscribers outside yoga Reviewed By: davidaurelio Differential Revision: D15619629 fbshipit-source-id: 1bf213efd38ec7bcac6a38070f21fa837c5f17da
This commit is contained in:
committed by
Facebook Github Bot
parent
a4bdd9cd9b
commit
c393ed1381
@@ -75,34 +75,6 @@ const short int LAYOUT_BORDER_START_INDEX = 14;
|
||||
|
||||
bool useBatchingForLayoutOutputs;
|
||||
|
||||
class PtrJNodeMap {
|
||||
using JNodeArray = JArrayClass<JYogaNode::javaobject>;
|
||||
std::map<YGNodeRef, size_t> ptrsToIdxs_;
|
||||
alias_ref<JNodeArray> javaNodes_;
|
||||
|
||||
public:
|
||||
PtrJNodeMap() : ptrsToIdxs_{}, javaNodes_{} {}
|
||||
PtrJNodeMap(
|
||||
alias_ref<JArrayLong> nativePointers,
|
||||
alias_ref<JNodeArray> javaNodes)
|
||||
: javaNodes_{javaNodes} {
|
||||
auto pin = nativePointers->pinCritical();
|
||||
auto ptrs = pin.get();
|
||||
for (size_t i = 0, n = pin.size(); i < n; ++i) {
|
||||
ptrsToIdxs_[(YGNodeRef) ptrs[i]] = i;
|
||||
}
|
||||
}
|
||||
|
||||
local_ref<JYogaNode> ref(YGNodeRef node) {
|
||||
auto idx = ptrsToIdxs_.find(node);
|
||||
if (idx == ptrsToIdxs_.end()) {
|
||||
return local_ref<JYogaNode>{};
|
||||
} else {
|
||||
return javaNodes_->getElement(idx->second);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
union YGNodeContext {
|
||||
|
Reference in New Issue
Block a user