Fabric: Dispatching `onLayout` events to only nodes which requested it
Summary: @public The current Fabric architecture, in general, does not support "subscribing" for events, so all kinds of events are always delivered no matter have JavaScript components `on`-handlers for them or not. At this point, we are not sure should it be this way or not. But we are sure that for some extremely noisy events (like onLayout) we have to make an exception right now (otherwise overall performance will suffer). So, this diff implements that for `onLayout`. Reviewed By: fkgozali Differential Revision: D8597408 fbshipit-source-id: 6933b7cb96e24f0660bd7850b625ff27e3146a2b
This commit is contained in:
Родитель
250cc3c594
Коммит
6942408a47
|
@ -115,6 +115,13 @@ void ShadowTree::emitLayoutEvents(const TreeMutationInstructionList &instruction
|
|||
if (viewEventEmitter) {
|
||||
// Now we know that both (old and new) shadow nodes must be `LayoutableShadowNode` subclasses.
|
||||
assert(std::dynamic_pointer_cast<const LayoutableShadowNode>(newShadowNode));
|
||||
|
||||
// Checking if the `onLayout` event was requested for the particular Shadow Node.
|
||||
const auto &viewProps = std::dynamic_pointer_cast<const ViewProps>(newShadowNode->getProps());
|
||||
if (viewProps && !viewProps->onLayout) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO(T29661055): Consider using `std::reinterpret_pointer_cast`.
|
||||
const auto &newLayoutableShadowNode =
|
||||
std::dynamic_pointer_cast<const LayoutableShadowNode>(newShadowNode);
|
||||
|
|
|
@ -37,7 +37,8 @@ ViewProps::ViewProps(const ViewProps &sourceProps, const RawProps &rawProps):
|
|||
shouldRasterize(convertRawProp(rawProps, "shouldRasterize", sourceProps.shouldRasterize)),
|
||||
zIndex(convertRawProp(rawProps, "zIndex", sourceProps.zIndex)),
|
||||
pointerEvents(convertRawProp(rawProps, "pointerEvents", sourceProps.pointerEvents)),
|
||||
hitSlop(convertRawProp(rawProps, "hitSlop", sourceProps.hitSlop)) {};
|
||||
hitSlop(convertRawProp(rawProps, "hitSlop", sourceProps.hitSlop)),
|
||||
onLayout(convertRawProp(rawProps, "onLayout", sourceProps.onLayout)) {};
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
// Events
|
||||
const PointerEventsMode pointerEvents {};
|
||||
const EdgeInsets hitSlop {};
|
||||
const bool onLayout {false};
|
||||
|
||||
#pragma mark - DebugStringConvertible
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче