Bug 229488 - Re-generalize top layer element concept
Summary: Re-generalize top layer element concept
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
: 229149 (view as bug list)
Depends on: 229480
Blocks: dialog-element
  Show dependency treegraph
 
Reported: 2021-08-25 00:41 PDT by Ryosuke Niwa
Modified: 2021-08-31 07:54 PDT (History)
11 users (show)

See Also:


Attachments
Patch (10.45 KB, patch)
2021-08-25 00:49 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Patch for landing (10.91 KB, patch)
2021-08-30 13:13 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Patch for landing (10.91 KB, patch)
2021-08-30 16:13 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Patch for landing (10.91 KB, patch)
2021-08-30 16:15 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryosuke Niwa 2021-08-25 00:41:02 PDT
After https://commits.webkit.org/r281548, the concept of top layer is confined to dialog element.
Re-generalize this concept for all elements so that we can use it in the full screen element.

We'd introduce a new node flag to avoid incurring any perf cost.
Comment 1 Ryosuke Niwa 2021-08-25 00:49:56 PDT
Created attachment 436377 [details]
Patch
Comment 2 Tim Nguyen (:ntim) 2021-08-25 06:24:30 PDT
Comment on attachment 436377 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=436377&action=review

> Source/WebCore/dom/Document.cpp:8474
>      m_topLayerElements.appendOrMoveToLast(element);

RELEASE_ASSERT(&element.document() == this && element.isConnected() && !element.isInTopLayer());
m_topLayerElements.append(element);

Since we're asserting `!element.isInTopLayer()`, let's use append() given the moveToLast case should not be possible.

moveToLast was supposed to be to follow spec words: "To add an element to a top layer, remove it from top layer and then append it to top layer."

Though according to both the dialog and fullscreen specs, movingToLast is not a case that can't happen: dialog requires checking dialog not being in top layer before adding it in, fullscreen does not allow dialogs to be fullscreened. Some other specs use the top layer (google's <popup> element), but they're not heavily implemented yet.
Comment 3 Antti Koivisto 2021-08-27 08:38:06 PDT
Comment on attachment 436377 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=436377&action=review

> Source/WebCore/dom/Element.cpp:3398
> +    invalidateStyle();

I think this can use invalidateStyleInternal(). The difference is that invalidateStyle() may also invalidate siblings. That is only needed for things that flip pseudo classes (yes, these need better names).
Comment 4 Ryosuke Niwa 2021-08-30 13:08:43 PDT
(In reply to Tim Nguyen (:ntim) from comment #2)
> Comment on attachment 436377 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=436377&action=review
> 
> > Source/WebCore/dom/Document.cpp:8474
> >      m_topLayerElements.appendOrMoveToLast(element);
> 
> RELEASE_ASSERT(&element.document() == this && element.isConnected() &&
> !element.isInTopLayer());
> m_topLayerElements.append(element);
> 
> Since we're asserting `!element.isInTopLayer()`, let's use append() given
> the moveToLast case should not be possible.

Yeah, I was thinking that. Will do.

(In reply to Antti Koivisto from comment #3)
> Comment on attachment 436377 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=436377&action=review
> 
> > Source/WebCore/dom/Element.cpp:3398
> > +    invalidateStyle();
> 
> I think this can use invalidateStyleInternal(). The difference is that
> invalidateStyle() may also invalidate siblings. That is only needed for
> things that flip pseudo classes (yes, these need better names).

Okay, will do. I guess I'd let it cycle through EWS again to be safe.
Comment 5 Ryosuke Niwa 2021-08-30 13:11:39 PDT
Huh, I just noticed that we're leaking top layer elements. I'd fix that as well.
Comment 6 Ryosuke Niwa 2021-08-30 13:12:12 PDT
(In reply to Ryosuke Niwa from comment #5)
> Huh, I just noticed that we're leaking top layer elements. I'd fix that as
> well.

Clarify: we'd be leaking the entire document whenever there is a top layer element when the document loses its last ref.
Comment 7 Ryosuke Niwa 2021-08-30 13:13:27 PDT
Created attachment 436804 [details]
Patch for landing
Comment 8 Ryosuke Niwa 2021-08-30 13:34:36 PDT
Comment on attachment 436804 [details]
Patch for landing

Wait for EWS.
Comment 9 EWS 2021-08-30 15:05:32 PDT
Found 5 new test failures: imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-cancel-with-select.html, imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-return-value.html, imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/element-removed-from-top-layer-has-original-position.html, imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/modal-dialog-display-contents.html, imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/top-layer-display-none.html
Comment 10 Ryosuke Niwa 2021-08-30 16:13:09 PDT
Created attachment 436823 [details]
Patch for landing
Comment 11 Ryosuke Niwa 2021-08-30 16:15:04 PDT
Created attachment 436824 [details]
Patch for landing
Comment 12 EWS 2021-08-31 00:40:58 PDT
Committed r281793 (241130@main): <https://commits.webkit.org/241130@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 436824 [details].
Comment 13 Radar WebKit Bug Importer 2021-08-31 00:41:31 PDT
<rdar://problem/82568313>
Comment 14 Tim Nguyen (:ntim) 2021-08-31 07:54:07 PDT
*** Bug 229149 has been marked as a duplicate of this bug. ***