Bug 233026 - Web Inspector: Layers Tab: the position of composited layer with box-shadow is wrong
Summary: Web Inspector: Layers Tab: the position of composited layer with box-shadow i...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Fujii Hironori
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-11-11 20:33 PST by Fujii Hironori
Modified: 2021-11-15 16:08 PST (History)
8 users (show)

See Also:


Attachments
test case (607 bytes, text/html)
2021-11-11 20:33 PST, Fujii Hironori
no flags Details
wrong screenshot (178.94 KB, image/png)
2021-11-11 20:42 PST, Fujii Hironori
no flags Details
screenshot (172.30 KB, image/png)
2021-11-11 21:02 PST, Fujii Hironori
no flags Details
Patch (5.56 KB, patch)
2021-11-11 21:59 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch (3.61 KB, patch)
2021-11-14 12:09 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff
Patch for landing (3.65 KB, patch)
2021-11-15 13:56 PST, Fujii Hironori
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fujii Hironori 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
Comment 1 Fujii Hironori 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.
Comment 2 Fujii Hironori 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.
Comment 3 Fujii Hironori 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.
Comment 4 Fujii Hironori 2021-11-11 21:59:48 PST
Created attachment 444044 [details]
Patch
Comment 5 BJ Burg 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
Comment 6 Devin Rousso 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 🤔
Comment 7 Fujii Hironori 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.
Comment 8 Fujii Hironori 2021-11-14 12:09:14 PST
Created attachment 444184 [details]
Patch
Comment 9 Devin Rousso 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),
```
Comment 10 Fujii Hironori 2021-11-15 13:56:50 PST
Created attachment 444302 [details]
Patch for landing

Thank you for the review.
Comment 11 EWS 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].
Comment 12 Radar WebKit Bug Importer 2021-11-15 16:08:26 PST
<rdar://problem/85433224>