Repository navigation
fix(node): click the center of a transformed node's bounding rect when content quads fail - #696
Merged
route merged 1 commit intoNov 7, 2026
Conversation
Contributor
Author
|
The one failing test on every Ruby version, |
thomasklemm
force-pushed
the
fix-transformed-bounding-rect-fallback
branch
from
November 4, 2026 09:52
913a5d9 to
d905ec1
Compare
Contributor
Author
|
The |
…n content quads fail When `DOM.getContentQuads` fails, `find_position` falls back to the node's bounding rect. It added half of `offsetWidth`/`offsetHeight` to the rect's left/top, but those are the untransformed layout size while the rect includes transforms, so a scaled node could be missed. Use the rect's own width and height. Fixes rubycdp#695
thomasklemm
force-pushed
the
fix-transformed-bounding-rect-fallback
branch
from
November 5, 2026 10:53
d905ec1 to
4ee94b4
Compare
Member
|
Looking good thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #695.
When
DOM.getContentQuadsfails,Node#find_position(and soNode#click) falls back tobounding_rect_coordinates. That added half ofoffsetWidth/offsetHeightto the bounding rect'sleft/top. The rect includes transforms, the offset size doesn't, so for a scaled or rotated node the point could land outside it. This uses the rect's ownwidth/height, which gives the node's visual center for any 2D transform and the same point as before for an untransformed node.The fallback now looks like this:
Test
The new example in the existing
when content quads can't be computedcontext rotates a 200×20 link by 45° and clicks it. A rotated element covers the center of its bounding rect but neither its corners nor the oldleft + offsetWidth / 2point. So the spec fails with the old formula (the URL stays at/simple) and also with a top-left-corner variant, and passes with the fix. It passed 20 of 20 repeated runs.spec/node_spec.rb: 166 examples, 0 failuresOptions::Chrome.versionandcolors protocol lines written to a terminal) fail the same way onmainin my environment: there is nochromeonPATH, and dbus messages end up in the log.Side effect
An SVG element has no
offsetWidth, so the old fallback returned[NaN, NaN]andmouse.clickraisedJSON::GeneratorError. It now gets the center of its rect. The CHANGELOG mentions this.Out of scope (unchanged)
raise if x.zero? && y.zero?guard stays as it is. With the corrected point it can also fire for a visible transformed node whose rect center lies exactly at the viewport origin. It's an existing sentinel for "no box", and changing it would be a separate behaviour change.