Context
Found while reviewing #19997. Neo.util.Rectangle#intersects(other) has two return types, and the size of the argument picks one silently:
- An
other with width and height: the overlap Rectangle, or false.
- An
other with zero width or height: a point-containment test, true or false.
A caller that chains on the result therefore breaks as soon as a zero-size box shows up. On #19997's first head, DomAccess#getClippedRect intersected a torn-out pane's display: none ancestor (a 0×0 rect) and got true. The next .intersects() threw rect.intersects is not a function as a page error, which failed the hosted multi-window e2e specs. #19997 guards that call site. The trap is still in the API.
Design authority: none recorded. intersects() has no JSDoc, and its only statement of intent is the inline comment on the point branch ("We're dealing with a point here - zero dimensions").
The Problem
- One method carries two semantics, area overlap and point-in-rect, and only the caller's argument decides which.
- With no JSDoc, nothing tells a caller the result can be
true.
- Three callers use the point branch deliberately and pass a point-shaped object (
{bottom: y, right: x, x, y}). contains() is not a drop-in for them: it delegates to Rectangle.includes(), which reads left/top, and those objects don't have them.
The Architectural Reality
src/util/Rectangle.mjs: intersects() (the area branch and the point branch), contains() and the static includes() (left/top/right/bottom), and the static getIntersection().
- Point callers:
src/manager/Window.mjs (the window under a screen point) and src/manager/DragCoordinator.mjs (twice, cross-window targeting). All three pass {bottom: y, right: x, x, y}.
- Area caller:
src/main/DomAccess.mjs#getClippedRect, guarded by #19997.
The Fix
intersects(other) always returns the overlap Rectangle or false. A zero-size other returns false, because it has no visible overlap.
- Point containment gets its own method, for example
containsPoint(x, y), and the three point callers move to it.
- Both methods get JSDoc, including their return types.
Acceptance Criteria
Out of Scope
- Changing the semantics of
includes() or contains().
Related
Live latest-open sweep: checked latest 20 open issues at 2026-10-22T13:12:53Z; no equivalent found.
Keyword sweep: gh issue list --search "Rectangle intersects" (all states): no match (only #17578, unrelated).
A2A claim sweep: last 15 lane-claims; no overlapping scope.
MC sweep: "Rectangle intersects returns boolean zero width height point": no prior decision.
Own-assignment sweep: none overlapping.
Origin Session ID: 678d216d-f4f7-41da-80d7-136e627522ff
Retrieval Hint: "Rectangle intersects mixed return Boolean zero-size point branch, getClippedRect page error"
Context
Found while reviewing #19997.
Neo.util.Rectangle#intersects(other)has two return types, and the size of the argument picks one silently:otherwith width and height: the overlapRectangle, orfalse.otherwith zero width or height: a point-containment test,trueorfalse.A caller that chains on the result therefore breaks as soon as a zero-size box shows up. On #19997's first head,
DomAccess#getClippedRectintersected a torn-out pane'sdisplay: noneancestor (a 0×0 rect) and gottrue. The next.intersects()threwrect.intersects is not a functionas a page error, which failed the hosted multi-window e2e specs. #19997 guards that call site. The trap is still in the API.Design authority: none recorded.
intersects()has no JSDoc, and its only statement of intent is the inline comment on the point branch ("We're dealing with a point here - zero dimensions").The Problem
true.{bottom: y, right: x, x, y}).contains()is not a drop-in for them: it delegates toRectangle.includes(), which readsleft/top, and those objects don't have them.The Architectural Reality
src/util/Rectangle.mjs:intersects()(the area branch and the point branch),contains()and the staticincludes()(left/top/right/bottom), and the staticgetIntersection().src/manager/Window.mjs(the window under a screen point) andsrc/manager/DragCoordinator.mjs(twice, cross-window targeting). All three pass{bottom: y, right: x, x, y}.src/main/DomAccess.mjs#getClippedRect, guarded by #19997.The Fix
intersects(other)always returns the overlapRectangleorfalse. A zero-sizeotherreturnsfalse, because it has no visible overlap.containsPoint(x, y), and the three point callers move to it.Acceptance Criteria
intersects()never returnstrue. Unit cases cover an overlapping, a disjoint, a touching and a zero-sizeother.containsPoint()has unit cases for points inside, on the edge and outside.Window.mjsandDragCoordinator.mjsusecontainsPoint(), and their existing unit and e2e coverage stays green.src/,apps/orexamples/still relies on a Boolean fromintersects().Out of Scope
includes()orcontains().Related
Live latest-open sweep: checked latest 20 open issues at 2026-10-22T13:12:53Z; no equivalent found. Keyword sweep:
gh issue list --search "Rectangle intersects"(all states): no match (only #17578, unrelated). A2A claim sweep: last 15 lane-claims; no overlapping scope. MC sweep: "Rectangle intersects returns boolean zero width height point": no prior decision. Own-assignment sweep: none overlapping.Origin Session ID: 678d216d-f4f7-41da-80d7-136e627522ff Retrieval Hint: "Rectangle intersects mixed return Boolean zero-size point branch, getClippedRect page error"