/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #if __has_include("FBReactNativeSpecJSI.h") // CocoaPod headers on Apple #include "FBReactNativeSpecJSI.h" #else #include #endif #include #include #include namespace facebook::react { class NativeDOM : public NativeDOMCxxSpec { public: NativeDOM(std::shared_ptr jsInvoker); #pragma mark - Methods from the `Node` interface (for `ReadOnlyNode`). double compareDocumentPosition( jsi::Runtime& rt, jsi::Value nativeNodeReference, jsi::Value otherNativeNodeReference); std::vector getChildNodes( jsi::Runtime& rt, jsi::Value nativeNodeReference); jsi::Value getParentNode(jsi::Runtime& rt, jsi::Value nativeNodeReference); bool isConnected(jsi::Runtime& rt, jsi::Value nativeNodeReference); #pragma mark - Methods from the `Element` interface (for `ReactNativeElement`). std::tuple< /* topWidth: */ int, /* rightWidth: */ int, /* bottomWidth: */ int, /* leftWidth: */ int> getBorderWidth( jsi::Runtime& rt, std::shared_ptr shadowNode); std::tuple< /* x: */ double, /* y: */ double, /* width: */ double, /* height: */ double> getBoundingClientRect( jsi::Runtime& rt, std::shared_ptr shadowNode, bool includeTransform); std::tuple getInnerSize( jsi::Runtime& rt, std::shared_ptr shadowNode); std::tuple getScrollPosition( jsi::Runtime& rt, std::shared_ptr shadowNode); std::tuple getScrollSize( jsi::Runtime& rt, std::shared_ptr shadowNode); std::string getTagName( jsi::Runtime& rt, std::shared_ptr shadowNode); std::string getTextContent( jsi::Runtime& rt, std::shared_ptr shadowNode); bool hasPointerCapture( jsi::Runtime& rt, std::shared_ptr shadowNode, double pointerId); void releasePointerCapture( jsi::Runtime& rt, std::shared_ptr shadowNode, double pointerId); void setPointerCapture( jsi::Runtime& rt, std::shared_ptr shadowNode, double pointerId); #pragma mark - Methods from the `HTMLElement` interface (for `ReactNativeElement`). std::tuple< /* offsetParent: */ jsi::Value, /* top: */ double, /* left: */ double> getOffset(jsi::Runtime& rt, std::shared_ptr shadowNode); #pragma mark - Special methods to handle the root node. jsi::Value linkRootNode( jsi::Runtime& rt, SurfaceId surfaceId, jsi::Value instanceHandle); #pragma mark - Legacy layout APIs (for `ReactNativeElement`). void measure( jsi::Runtime& rt, std::shared_ptr shadowNode, jsi::Function callback); void measureInWindow( jsi::Runtime& rt, std::shared_ptr shadowNode, jsi::Function callback); void measureLayout( jsi::Runtime& rt, std::shared_ptr shadowNode, std::shared_ptr relativeToShadowNode, jsi::Function onFail, jsi::Function onSuccess); #pragma mark - Legacy direct manipulation APIs (for `ReactNativeElement`). void setNativeProps( jsi::Runtime& rt, std::shared_ptr shadowNode, jsi::Value updatePayload); }; } // namespace facebook::react