Skip to content

Commit 79b6a9a

Browse files
committed
add NativeDOM.h override
1 parent cb6d204 commit 79b6a9a

File tree

2 files changed

+134
-0
lines changed

2 files changed

+134
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
#include <string>
11+
12+
#if __has_include("rncoreJSI.h") // Cmake headers on Android
13+
#include "rncoreJSI.h"
14+
#elif __has_include("FBReactNativeSpecJSI.h") // CocoaPod headers on Apple
15+
#include "FBReactNativeSpecJSI.h"
16+
#else
17+
#include <FBReactNativeSpec/FBReactNativeSpecJSI.h>
18+
#endif
19+
20+
#include <react/renderer/core/ShadowNodeFamily.h>
21+
22+
namespace facebook::react {
23+
24+
class NativeDOM : public NativeDOMCxxSpec<NativeDOM> {
25+
public:
26+
NativeDOM(std::shared_ptr<CallInvoker> jsInvoker);
27+
28+
#pragma mark - Methods from the Node interface (for ReadOnlyNode).
29+
30+
double compareDocumentPosition(
31+
jsi::Runtime& rt,
32+
jsi::Value nativeNodeReference,
33+
jsi::Value otherNativeNodeReference);
34+
35+
std::vector<jsi::Value> getChildNodes(
36+
jsi::Runtime& rt,
37+
jsi::Value nativeNodeReference);
38+
39+
jsi::Value getParentNode(jsi::Runtime& rt, jsi::Value nativeNodeReference);
40+
41+
bool isConnected(jsi::Runtime& rt, jsi::Value nativeNodeReference);
42+
43+
#pragma mark - Methods from the Element interface (for ReactNativeElement).
44+
45+
std::tuple<
46+
/* topWidth: */ int,
47+
/* rightWidth: */ int,
48+
/* bottomWidth: */ int,
49+
/* leftWidth: */ int>
50+
getBorderWidth(jsi::Runtime& rt, jsi::Value nativeElementReference);
51+
52+
std::tuple<
53+
/* x: */ double,
54+
/* y: */ double,
55+
/* width: */ double,
56+
/* height: */ double>
57+
getBoundingClientRect(
58+
jsi::Runtime& rt,
59+
jsi::Value nativeElementReference,
60+
bool includeTransform);
61+
62+
std::tuple</* width: */ int, /* height: */ int> getInnerSize(
63+
jsi::Runtime& rt,
64+
jsi::Value nativeElementReference);
65+
66+
std::tuple</* scrollLeft: */ double, /* scrollTop: */ double>
67+
getScrollPosition(jsi::Runtime& rt, jsi::Value nativeElementReference);
68+
69+
std::tuple</* scrollWidth: */ int, /* scrollHeight */ int> getScrollSize(
70+
jsi::Runtime& rt,
71+
jsi::Value nativeElementReference);
72+
73+
std::string getTagName(jsi::Runtime& rt, jsi::Value nativeElementReference);
74+
75+
std::string getTextContent(jsi::Runtime& rt, jsi::Value nativeNodeReference);
76+
77+
bool hasPointerCapture(
78+
jsi::Runtime& rt,
79+
jsi::Value nativeElementReference,
80+
double pointerId);
81+
82+
void releasePointerCapture(
83+
jsi::Runtime& rt,
84+
jsi::Value nativeElementReference,
85+
double pointerId);
86+
87+
void setPointerCapture(
88+
jsi::Runtime& rt,
89+
jsi::Value nativeElementReference,
90+
double pointerId);
91+
92+
#pragma mark - Methods from the HTMLElement interface (for ReactNativeElement).
93+
94+
std::tuple<
95+
/* offsetParent: */ jsi::Value,
96+
/* top: */ double,
97+
/* left: */ double>
98+
getOffset(jsi::Runtime& rt, jsi::Value nativeElementReference);
99+
100+
#pragma mark - Special methods to handle the root node.
101+
102+
jsi::Value linkRootNode(
103+
jsi::Runtime& rt,
104+
SurfaceId surfaceId,
105+
jsi::Value instanceHandle);
106+
107+
#pragma mark - Legacy layout APIs (for ReactNativeElement).
108+
109+
void measure(
110+
jsi::Runtime& rt,
111+
jsi::Value nativeElementReference,
112+
jsi::Function callback);
113+
114+
void measureInWindow(
115+
jsi::Runtime& rt,
116+
jsi::Value nativeElementReference,
117+
jsi::Function callback);
118+
119+
void measureLayout(
120+
jsi::Runtime& rt,
121+
jsi::Value nativeElementReference,
122+
jsi::Value relativeToNativeElementReference,
123+
jsi::Function onFail,
124+
jsi::Function onSuccess);
125+
};
126+
127+
} // namespace facebook::react

vnext/overrides.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@
110110
"baseHash": "e82eb139eab8a6e122421416fb724811bfadd6fb",
111111
"issue": 14128
112112
},
113+
{
114+
"type": "patch",
115+
"file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h",
116+
"baseFile": "packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.h",
117+
"baseHash": "2e7b78e224f658c55105ccfc35d416d1743352e2",
118+
"issue": 14654
119+
},
113120
{
114121
"type": "patch",
115122
"file": "ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp",

0 commit comments

Comments
 (0)