Get correct offsets for nodes nested in iframes for BoxModelHighlighterRenderer
Categories
(DevTools :: Inspector, defect, P2)
Tracking
(Fission Milestone:M6)
Fission Milestone | M6 |
People
(Reporter: rcaliman, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
735 bytes,
text/html
|
Details |
The Fission-ready BoxModelHighlighter
has two parts:
- an observer,
BoxModelHighlighterObserver
, which measures the target node for changes in size/position (this lives in the content process); - a renderer,
BoxModelHighlighterRenderer
, which draws the highlighter on top of the inspected node (this lives in the parent process).
Before Fission, for nodes within iframes, it was possible to use Node.getBoxQuads()
to measure a node's offsets against the top-level document using the relativeTo
option. After Fission, we cannot pass references to documents from another process (ex: top-level document which contains the iframe)
In order for the renderer to position the highligther correctly, the offsets of a node from within the iframe need to account for the iframe's offsets in relation to the top-level document.
There are a few ideas to solve this:
a) somehow get a reference to the top-level document as a referenceTo
in node.getBoxQuads()
in auto-refresh.js (i.e. boundaryWindow
should be the top-level document window)`
b) configure a custom option on the getBoxQuads()
platform API so that it always returns offsets in relation to the top-level document (i.e.: no need to explicitly pass it as referenceTo
)
c) recursively get iframe offsets in relation to their parent (if another iframe) or top-level document and account for these offsets when positioning the highlighter for a node in the renderer. This would likely be expensive, because the observer is running in a requestAnimationFrame()
loop in order to react to any changes in node position from animations, transitions, resizes, etc.
Reporter | ||
Comment 1•5 years ago
|
||
Document containing an iframe on another domain (glitch.me): https://bronze-baboon.glitch.me/
When working correctly, the Fission-ready BoxModelHiglighterRenderer
should draw the highlighter correctly over the green <div>
in the iframe.
Updated•5 years ago
|
Updated•5 years ago
|
Comment 2•5 years ago
|
||
Razvan, what do I need to do to reproduce the problem? When I load the testcase, the highlighter is drawn correctly on the green box div in the iframe.
Reporter | ||
Comment 3•5 years ago
|
||
(In reply to Brad Werth [:bradwerth] from comment #2)
Razvan, what do I need to do to reproduce the problem? When I load the testcase, the highlighter is drawn correctly on the green box div in the iframe.
Sorry about the confusion! The test-case doesn't highlight a problem yet because the highlighter can't yet reach content within remote frames. This is part of the Fission work.
But the test case serves as a starting point. There are two Node.getBoxQuads()
calls: one for iframe from the top-level document and one for the node from within the iframe. The second call, the one for the <div>
within the iframe, needs to return adjusted coordinates which take into account the offset of the iframe itself.
From conversations on https://bugzilla.mozilla.org/show_bug.cgi?id=1593756#c4, it seems we can't change the default behavior. So the second call should include the custom flag to return the adjusted quads.
Essentially, once given a flag (either custom or by specifying the top-level document's BrowsingContextID), the call to Node.getBoxQuads()
from within the iframe should return offsets increased by 100 (the top and left margin of the iframe):
DOMQuad {
p1: DOMPoint { x: 200, y: 200, z: 0, … }
p2: DOMPoint { x: 300, y: 200, z: 0, … }
p3: DOMPoint { x: 300, y: 300, z: 0, … }
p4: DOMPoint { x: 200, y: 300, z: 0, … }
}
Comment 4•4 years ago
|
||
Tracking Fission DevTools bugs for Fission Nightly (M6)
Reporter | ||
Updated•4 years ago
|
Updated•4 years ago
|
Reporter | ||
Comment 5•4 years ago
|
||
Solved by Bug 1593756
Description
•