mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use 'explicit root' instead of 'custom root' terminology (#54177)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
1 parent
ae5728bbb4
commit
9d6fa7d77e
2 files changed
+12
-12
No files matched your search
+8
-8
@@ -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<IntersectionObserverEntry>
|
||||
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;
|
||||
|
||||
+4
-4
@@ -129,7 +129,7 @@ describe('IntersectionObserver', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should provide access to custom `root`', () => {
|
||||
it('should provide access to explicit `root`', () => {
|
||||
const rootRef = React.createRef<HostInstance>();
|
||||
|
||||
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<HostInstance>();
|
||||
const scrollNodeRef = createRef<HostInstance>();
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user