Skip to content

Commit 9d6fa7d

Browse files
lunaleapsmeta-codesync[bot]
authored andcommitted
Use 'explicit root' instead of 'custom root' terminology (facebook#54177)
Summary: Pull Request resolved: facebook#54177 Changelog: [Internal] - Rename the term "custom root" to "explicit root" to align with w3c spec. And "implicit root" for the document root. Reviewed By: mdvacca Differential Revision: D84795887 fbshipit-source-id: afec23f6763af56c6de1d3fce2f9501187559fb9
1 parent ae5728b commit 9d6fa7d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserver.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static Rect computeIntersection(
8787
const Rect& rootBoundingRect,
8888
const Rect& targetBoundingRect,
8989
const ShadowNodeFamily::AncestorList& targetToRootAncestors,
90-
bool hasCustomRoot) {
90+
bool hasExplicitRoot) {
9191
auto absoluteIntersectionRect =
9292
Rect::intersect(rootBoundingRect, targetBoundingRect);
9393

@@ -109,7 +109,7 @@ static Rect computeIntersection(
109109
auto clippedTargetFromRoot =
110110
getClippedTargetBoundingRect(targetToRootAncestors);
111111

112-
auto clippedTargetBoundingRect = hasCustomRoot ? Rect{
112+
auto clippedTargetBoundingRect = hasExplicitRoot ? Rect{
113113
.origin=rootBoundingRect.origin + clippedTargetFromRoot.origin,
114114
.size=clippedTargetFromRoot.size}
115115
: clippedTargetFromRoot;
@@ -135,14 +135,14 @@ std::optional<IntersectionObserverEntry>
135135
IntersectionObserver::updateIntersectionObservation(
136136
const RootShadowNode& rootShadowNode,
137137
HighResTimeStamp time) {
138-
bool hasCustomRoot = observationRootShadowNodeFamily_.has_value();
138+
bool hasExplicitRoot = observationRootShadowNodeFamily_.has_value();
139139

140-
auto rootAncestors = hasCustomRoot
140+
auto rootAncestors = hasExplicitRoot
141141
? observationRootShadowNodeFamily_.value()->getAncestors(rootShadowNode)
142142
: ShadowNodeFamily::AncestorList{};
143143

144144
// Absolute coordinates of the root
145-
auto rootBoundingRect = hasCustomRoot
145+
auto rootBoundingRect = hasExplicitRoot
146146
? getBoundingRect(rootAncestors)
147147
: getRootNodeBoundingRect(rootShadowNode);
148148

@@ -151,21 +151,21 @@ IntersectionObserver::updateIntersectionObservation(
151151
// Absolute coordinates of the target
152152
auto targetBoundingRect = getBoundingRect(targetAncestors);
153153

154-
if ((hasCustomRoot && rootAncestors.empty()) || targetAncestors.empty()) {
154+
if ((hasExplicitRoot && rootAncestors.empty()) || targetAncestors.empty()) {
155155
// If observation root or target is not a descendant of `rootShadowNode`
156156
return setNotIntersectingState(
157157
rootBoundingRect, targetBoundingRect, {}, time);
158158
}
159159

160-
auto targetToRootAncestors = hasCustomRoot
160+
auto targetToRootAncestors = hasExplicitRoot
161161
? targetShadowNodeFamily_->getAncestors(*getShadowNode(rootAncestors))
162162
: targetAncestors;
163163

164164
auto intersectionRect = computeIntersection(
165165
rootBoundingRect,
166166
targetBoundingRect,
167167
targetToRootAncestors,
168-
hasCustomRoot);
168+
hasExplicitRoot);
169169

170170
Float targetBoundingRectArea =
171171
targetBoundingRect.size.width * targetBoundingRect.size.height;

packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe('IntersectionObserver', () => {
129129
);
130130
});
131131

132-
it('should provide access to custom `root`', () => {
132+
it('should provide access to explicit `root`', () => {
133133
const rootRef = React.createRef<HostInstance>();
134134

135135
const root = Fantom.createRoot();
@@ -1144,7 +1144,7 @@ describe('IntersectionObserver', () => {
11441144
});
11451145
});
11461146

1147-
describe('with custom root', () => {
1147+
describe('with explicit root', () => {
11481148
it('should report partial non-intersecting initial state correctly', () => {
11491149
const nodeRef = createRef<HostInstance>();
11501150
const scrollNodeRef = createRef<HostInstance>();
@@ -1911,7 +1911,7 @@ describe('IntersectionObserver', () => {
19111911
expect(entries.length).toBe(1);
19121912
expect(entries[0]).toBeInstanceOf(IntersectionObserverEntry);
19131913
expect(entries[0].intersectionRatio).toBe(1);
1914-
// This is the ratio of intersection area / (custom) root area
1914+
// This is the ratio of intersection area / (explicit) root area
19151915
expect(entries[0].rnRootIntersectionRatio).toBe(0.25);
19161916
expect(entries[0].isIntersecting).toBe(true);
19171917
expect(entries[0].target).toBe(node);
@@ -1976,7 +1976,7 @@ describe('IntersectionObserver', () => {
19761976
expect(entries.length).toBe(1);
19771977
expect(entries[0]).toBeInstanceOf(IntersectionObserverEntry);
19781978
expect(entries[0].intersectionRatio).toBe(0.5);
1979-
// This is the ratio of intersection area / (custom) root area
1979+
// This is the ratio of intersection area / (explicit) root area
19801980
expect(entries[0].rnRootIntersectionRatio).toBe(0.5);
19811981
expect(entries[0].isIntersecting).toBe(true);
19821982
expect(entries[0].target).toBe(node);

0 commit comments

Comments
 (0)