diff --git a/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserver.cpp b/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserver.cpp index d7ee1b49ae2..539db81b804 100644 --- a/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserver.cpp +++ b/packages/react-native/ReactCommon/react/renderer/observers/intersection/IntersectionObserver.cpp @@ -87,7 +87,7 @@ static Rect computeIntersection( const Rect& rootBoundingRect, const Rect& targetBoundingRect, const ShadowNodeFamily::AncestorList& targetToRootAncestors, - bool hasCustomRoot) { + bool hasExplicitRoot) { auto absoluteIntersectionRect = Rect::intersect(rootBoundingRect, targetBoundingRect); @@ -109,7 +109,7 @@ static Rect computeIntersection( auto clippedTargetFromRoot = getClippedTargetBoundingRect(targetToRootAncestors); - auto clippedTargetBoundingRect = hasCustomRoot ? Rect{ + auto clippedTargetBoundingRect = hasExplicitRoot ? Rect{ .origin=rootBoundingRect.origin + clippedTargetFromRoot.origin, .size=clippedTargetFromRoot.size} : clippedTargetFromRoot; @@ -135,14 +135,14 @@ std::optional IntersectionObserver::updateIntersectionObservation( const RootShadowNode& rootShadowNode, HighResTimeStamp time) { - bool hasCustomRoot = observationRootShadowNodeFamily_.has_value(); + bool hasExplicitRoot = observationRootShadowNodeFamily_.has_value(); - auto rootAncestors = hasCustomRoot + auto rootAncestors = hasExplicitRoot ? observationRootShadowNodeFamily_.value()->getAncestors(rootShadowNode) : ShadowNodeFamily::AncestorList{}; // Absolute coordinates of the root - auto rootBoundingRect = hasCustomRoot + auto rootBoundingRect = hasExplicitRoot ? getBoundingRect(rootAncestors) : getRootNodeBoundingRect(rootShadowNode); @@ -151,13 +151,13 @@ IntersectionObserver::updateIntersectionObservation( // Absolute coordinates of the target auto targetBoundingRect = getBoundingRect(targetAncestors); - if ((hasCustomRoot && rootAncestors.empty()) || targetAncestors.empty()) { + if ((hasExplicitRoot && rootAncestors.empty()) || targetAncestors.empty()) { // If observation root or target is not a descendant of `rootShadowNode` return setNotIntersectingState( rootBoundingRect, targetBoundingRect, {}, time); } - auto targetToRootAncestors = hasCustomRoot + auto targetToRootAncestors = hasExplicitRoot ? targetShadowNodeFamily_->getAncestors(*getShadowNode(rootAncestors)) : targetAncestors; @@ -165,7 +165,7 @@ IntersectionObserver::updateIntersectionObservation( rootBoundingRect, targetBoundingRect, targetToRootAncestors, - hasCustomRoot); + hasExplicitRoot); Float targetBoundingRectArea = targetBoundingRect.size.width * targetBoundingRect.size.height; diff --git a/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js b/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js index 405cca9490c..61beb046dce 100644 --- a/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js +++ b/packages/react-native/src/private/webapis/intersectionobserver/__tests__/IntersectionObserver-itest.js @@ -129,7 +129,7 @@ describe('IntersectionObserver', () => { ); }); - it('should provide access to custom `root`', () => { + it('should provide access to explicit `root`', () => { const rootRef = React.createRef(); const root = Fantom.createRoot(); @@ -1144,7 +1144,7 @@ describe('IntersectionObserver', () => { }); }); - describe('with custom root', () => { + describe('with explicit root', () => { it('should report partial non-intersecting initial state correctly', () => { const nodeRef = createRef(); const scrollNodeRef = createRef(); @@ -1911,7 +1911,7 @@ describe('IntersectionObserver', () => { expect(entries.length).toBe(1); expect(entries[0]).toBeInstanceOf(IntersectionObserverEntry); expect(entries[0].intersectionRatio).toBe(1); - // This is the ratio of intersection area / (custom) root area + // This is the ratio of intersection area / (explicit) root area expect(entries[0].rnRootIntersectionRatio).toBe(0.25); expect(entries[0].isIntersecting).toBe(true); expect(entries[0].target).toBe(node); @@ -1976,7 +1976,7 @@ describe('IntersectionObserver', () => { expect(entries.length).toBe(1); expect(entries[0]).toBeInstanceOf(IntersectionObserverEntry); expect(entries[0].intersectionRatio).toBe(0.5); - // This is the ratio of intersection area / (custom) root area + // This is the ratio of intersection area / (explicit) root area expect(entries[0].rnRootIntersectionRatio).toBe(0.5); expect(entries[0].isIntersecting).toBe(true); expect(entries[0].target).toBe(node);