DOMSnapshot.getSnapshot layout model inconsistent for iframes
Reported by
mmcd...@gmail.com,
Feb 15 2018
|
|||||||
Issue descriptionVersion: 64 OS: Mac Architecture: x86 What steps will reproduce the problem? 1. Load a webpage with an iframe that is not located at the exact upper-right of the page 2. Call DOMSnapshot.getSnapshot on that tab through the chrome.debugger.sendCommand API What is the expected output? The bounding box of each layoutTreeNode should correspond to the position on the page (which is consistent with the behavior of DOM.getBoxModel). This was the behavior up to chromium 63. What do you see instead? The bounding box for layoutTreeNode's that describe nodes within an iframe correspond to the position within the iframe rather than within the page. This behavior started in chromium 64, and could be due to https://chromium.googlesource.com/chromium/src/+/8188223eeda59d008debc93a2b950bd6f7a931a9.
,
Feb 15 2018
The "what do you see instead" section is perhaps a bit confusing. It should probably read: For layoutTreeNode's that describe nodes within an iframe, the bounding box corresponds to the position within the iframe rather than within the page.
,
Feb 26 2018
,
Feb 26 2018
,
Feb 27 2018
Since the code mentioned is under inspector, I'm changing the component from Blink>DOM to Platform>DevTools.
,
Apr 2 2018
zoe@, based on the changes to test expectations in your CL, do you know if this change was intentional?
,
Apr 2 2018
if I remember correctly the goal behind the change was to give consistent results for pages that contain meta/CSS viewports. For example look at the test-case I added: https://chromium.googlesource.com/chromium/src/+/8188223eeda59d008debc93a2b950bd6f7a931a9/third_party/WebKit/LayoutTests/inspector-protocol/resources/dom-snapshot-viewport.html Before the change the text box's coordinates were not fully enclosed by the div's coordinates. It doesn't particularly matter how the coordinates are transformed, the issue was they were being transformed inconsistently. It's possible I overlooked the iframe test expectation implications (so easy to do with golden data tests...), let me take a closer look at iframe behavior.
,
Apr 3 2018
I've verified that the CL mentioned above changed the iframe behavior. Note that the inlineTextNodes had the "after" behavior even before my change. My change was reconciling DOM positions with text positions, which is probably why I was OK with the golden data changes. In other words my CL made things consistent, but didn't make them consistent in the way mmcduff expected, nor was I aware of DOM.getBoxModel. I probably don't care either way, though I'd consider the current code more or less *working as intended*. ___ In the case where there's no weird transformations going on, converting back and forth between the two coordinate spaces should be fairly doable in client code. However this becomes a little subtle if the iframe itself is transformed, such as by "transform: rotate(90deg)", or if the page has a viewport tag. I'm not a layout expert and could be off-base but it seems like there are a few different reasonable approaches: #1 The user may want to query the bounding box relative to containing document's layout (I think this is the way things are now) #2 The user may want to query the bounding box relative to main document's layout (mmcduff wants this over the first way) #3 The user may want to query the bounding box relative to the screen (e.g. viewport scale factor would have an effect, probably easy to compute given #2) Where approach 1 and 2 are mutually exclusive (unless we export both of them, make which one to use an option, etc.) mmcduff does this make sense? What is your use-case with respect to the above? cc-ing a couple headless chromium people in case they have any thoughts.
,
Apr 3 2018
My use case is related to automated analytics on web pages (i.e. what elements from what domains appear where in a document). You are correct that I prefer approach #2. My argument for approach #2 is that the DOMSnapshot.getSnapshot interface returns all DOM elements within a tab, and so I think it makes the most sense that all DOM.Rect's in the returned layout tree would use the same coordinate space. If it were possible to call DOMSnapshot.getSnapshot on only a single frame within a tab, it would make more sense to base the coordinates on that frame's document.
,
Apr 3 2018
Assigning to myself, unless someone else wants to take this.
,
Sep 10
Sorry for the lack of progress on this bug, been busy with other stuff. In the meanwhile https://chromium-review.googlesource.com/c/chromium/src/+/1173717 added scroll offset information, which should be useful in the common case where iframes aren't rotated.
,
Jan 11
Setting defect without priority to Pri-2.
,
Jan 11
Setting defect without priority to Pri-2. |
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by mmcd...@gmail.com
, Feb 15 2018