Bug 233026

Summary: Web Inspector: Layers Tab: the position of composited layer with box-shadow is wrong
Product: WebKit Reporter: Fujii Hironori <Hironori.Fujii>
Component: Web InspectorAssignee: Fujii Hironori <Hironori.Fujii>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, ews-watchlist, hi, inspector-bugzilla-changes, joepeck, pangle, ross.kirsling, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
test case
none
wrong screenshot
none
screenshot
none
Patch
none
Patch
none
Patch for landing none

Fujii Hironori
Reported 2021-11-11 20:33:13 PST
Created attachment 444038 [details] test case Web Inspector: Layer Tab: the position of composited layer with box-shadow is wrong 1. Open the test case 2. Open Web Inspector 3. Open Layer tab 4. Select canvas element 5. the position of the composited layer is wrong
Attachments
test case (607 bytes, text/html)
2021-11-11 20:33 PST, Fujii Hironori
no flags
wrong screenshot (178.94 KB, image/png)
2021-11-11 20:42 PST, Fujii Hironori
no flags
screenshot (172.30 KB, image/png)
2021-11-11 21:02 PST, Fujii Hironori
no flags
Patch (5.56 KB, patch)
2021-11-11 21:59 PST, Fujii Hironori
no flags
Patch (3.61 KB, patch)
2021-11-14 12:09 PST, Fujii Hironori
no flags
Patch for landing (3.65 KB, patch)
2021-11-15 13:56 PST, Fujii Hironori
no flags
Fujii Hironori
Comment 1 2021-11-11 20:42:30 PST
Created attachment 444039 [details] wrong screenshot The orange layer of <canvas> is placed correctly on the webview. But, the blue box layer of <canvas> in the layers tab is wrongly placed at the visible area of it.
Fujii Hironori
Comment 2 2021-11-11 20:57:47 PST
Comment on attachment 444039 [details] wrong screenshot My bad. This screenshot is wrong. the orange are is just a margin area. It's not a layer.
Fujii Hironori
Comment 3 2021-11-11 21:02:54 PST
Created attachment 444041 [details] screenshot Mac MiniBrowser can show Layer Border. Because this <canvas> has a large box-shadow, it has a large layer. Layers Tab shows <canvas> layer box placed wrongly at the visible position of the element.
Fujii Hironori
Comment 4 2021-11-11 21:59:48 PST
Blaze Burg
Comment 5 2021-11-12 13:17:14 PST
Comment on attachment 444044 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444044&action=review > Source/WebInspectorUI/ChangeLog:8 > + If an elemenet has box-shadow, Layers Tab showed the composited Nit: element
Devin Rousso
Comment 6 2021-11-12 18:15:01 PST
Comment on attachment 444044 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444044&action=review r- as this doesn't take into account older inspected targets, but the logic looks good otherwise :) > Source/WebInspectorUI/UserInterface/Models/Layer.js:-46 > - // FIXME: This should probably be moved to the backend. > - this._compositedBounds.x = this._bounds.x; > - this._compositedBounds.y = this._bounds.y; This is not a valid fix when remotely inspecting a backend that does _not_ have the above change (e.g. inspecting an older iOS). You'll need to add some sort of compatibility check. AFAICT, the only thing that's changed in the protocol that's checkable is `InspectorBackend.Enum.CSS.PseudoId.Backdrop` (from r281229), so you'd wanna do something like this ``` // COMPATIBILITY (iOS 15.0): the `bounds` and `computedBounds` properties of `LayerTree.Layer` did not account for parent element positioning. // Since support can't be tested directly, check for the `Backdrop` value in the `CSS.PseudoId` enum. // FIXME: Use explicit version checking once <https://webkit.org/b/148680> is fixed. if (!InspectorBackend.Enum.CSS.PseudoId.Backdrop) { this._compositedBounds.x = this._bounds.x; this._compositedBounds.y = this._bounds.y; } ``` > Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js:272 > - layerGroup.position.set(layer.bounds.x, -layer.bounds.y, index * zInterval); > + layerGroup.position.set(0, 0, index * zInterval); ditto (Source/WebInspectorUI/UserInterface/Models/Layer.js:44) > Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js:289 > + _createLayerMesh({x, y, width, height}, isOutline = false) ditto (Source/WebInspectorUI/UserInterface/Models/Layer.js:44) tho in this case it may be clearer to adjust the callsite instead 🤔
Fujii Hironori
Comment 7 2021-11-14 12:08:29 PST
Comment on attachment 444044 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444044&action=review >> Source/WebInspectorUI/UserInterface/Models/Layer.js:-46 >> - this._compositedBounds.y = this._bounds.y; > > This is not a valid fix when remotely inspecting a backend that does _not_ have the above change (e.g. inspecting an older iOS). You'll need to add some sort of compatibility check. AFAICT, the only thing that's changed in the protocol that's checkable is `InspectorBackend.Enum.CSS.PseudoId.Backdrop` (from r281229), so you'd wanna do something like this > ``` > // COMPATIBILITY (iOS 15.0): the `bounds` and `computedBounds` properties of `LayerTree.Layer` did not account for parent element positioning. > // Since support can't be tested directly, check for the `Backdrop` value in the `CSS.PseudoId` enum. > // FIXME: Use explicit version checking once <https://webkit.org/b/148680> is fixed. > if (!InspectorBackend.Enum.CSS.PseudoId.Backdrop) { > this._compositedBounds.x = this._bounds.x; > this._compositedBounds.y = this._bounds.y; > } > ``` Good point. This issue can be fixed without the protocol change. I think it's better. Will fix.
Fujii Hironori
Comment 8 2021-11-14 12:09:14 PST
Devin Rousso
Comment 9 2021-11-15 12:51:53 PST
Comment on attachment 444184 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=444184&action=review r=me, nice! > Source/WebInspectorUI/UserInterface/Views/Layers3DContentView.js:296 > + new THREE.Vector3(x, -y-height, 0), > + new THREE.Vector3(x+width, -y-height, 0), > + new THREE.Vector3(x+width, -y, 0), Style: please add spaces between operators ``` new THREE.Vector3(x, -y - height, 0), new THREE.Vector3(x + width, -y - height, 0), new THREE.Vector3(x + width, -y, 0), ```
Fujii Hironori
Comment 10 2021-11-15 13:56:50 PST
Created attachment 444302 [details] Patch for landing Thank you for the review.
EWS
Comment 11 2021-11-15 16:07:10 PST
Committed r285839 (244271@main): <https://commits.webkit.org/244271@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 444302 [details].
Radar WebKit Bug Importer
Comment 12 2021-11-15 16:08:26 PST
Note You need to log in before you can comment on or make changes to this bug.