Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect HTML spec up to new CSS interactivity property #10956

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mfreed7
Copy link
Contributor

@mfreed7 mfreed7 commented Jan 28, 2025

I was a bit unsure about a few parts of this PR, so help would be appreciated from the editors. The idea is:

  1. Remove duplication - allow the CSS spec to define the concept of "inert".
  2. Make the inert HTML attribute set interactivity:inert via a new UA stylesheet rule.
  3. Make modal dialogs non-inert via an interactivity:auto UA stylesheet rule.
  4. {later} A rule likely needs to be added for fullscreen elements also, setting :fullscreen {interactivity: auto}.

Side-note: at this time the CSS spec isn't being published. Bot problems. But this CSS spec PR landed and should eventually contain the references added in this PR.


(See WHATWG Working Mode: Changes for more details.)


/indices.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/interactive-elements.html ( diff )
/introduction.html ( diff )
/rendering.html ( diff )

I was a bit unsure about a few parts of this PR, so help would be
appreciated from the editors. The idea is:
 1. Remove duplication - allow the CSS spec to define the *concept*
    of "inert".
 2. Make the `inert` HTML attribute set `interactivity:inert` via
    a new UA stylesheet rule.
 3. Make modal dialogs non-inert via an `interactivity:auto` UA
    stylesheet rule.
 {eventual step 4} A rule likely needs to be added for fullscreen
    elements also, setting `interactivity:auto`.
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
Copy link
Contributor Author

@mfreed7 mfreed7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
@nt1m
Copy link
Member

nt1m commented Jan 30, 2025

I think blocked by a modal dialog should be defined in terms of interactivity (either set as a presentational hint on the root, or using an UA stylesheet rule), because otherwise dialog:modal { interactivity: auto } won't do anything (because auto is the default value. I don't think this is what the current HTML spec PR does.

@mfreed7
Copy link
Contributor Author

mfreed7 commented Jan 30, 2025

I think blocked by a modal dialog should be defined in terms of interactivity (either set as a presentational hint on the root, or using an UA stylesheet rule), because otherwise dialog:modal { interactivity: auto } won't do anything (because auto is the default value. I don't think this is what the current HTML spec PR does.

I added a Note about this. But I think the concept (agreed to over in CSSWG I believe) was that both specs can set something to be inert. The problem with defining modal dialog behavior in terms of CSS is that it allows author CSS to make parts of the page "un-inerted", which is undesirable. And it can't be set to interactivity:inert/auto !important to avoid that problem, because then that doesn't allow the author to "re-inert" the dialog itself.

@lilles
Copy link
Contributor

lilles commented Jan 30, 2025

I think blocked by a modal dialog should be defined in terms of interactivity (either set as a presentational hint on the root, or using an UA stylesheet rule), because otherwise dialog:modal { interactivity: auto } won't do anything (because auto is the default value. I don't think this is what the current HTML spec PR does.

I added a Note about this. But I think the concept (agreed to over in CSSWG I believe) was that both specs can set something to be inert. The problem with defining modal dialog behavior in terms of CSS is that it allows author CSS to make parts of the page "un-inerted", which is undesirable. And it can't be set to interactivity:inert/auto !important to avoid that problem, because then that doesn't allow the author to "re-inert" the dialog itself.

Another issue is that no one's been able to come up with UA styles that actually works with shadow DOM.

Copy link
Collaborator

@noamr noamr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've stumbled upon this type of problem when implementing moveBefore things... Thanks for working on this! Added some non-authoritative nits

source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@@ -79283,56 +79287,87 @@ interface <dfn interface>VisibilityStateEntry</dfn> : <span>PerformanceEntry</sp
<p class="note">See also <code data-x="attr-inert">inert</code> for an explanation of the
attribute of the same name.</p>

<p>A node (in particular elements and text nodes) can be <dfn>inert</dfn>. When a node is
<span>inert</span>:</p>
<p>A node (in particular elements and text nodes) can be <dfn>inert</dfn>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like there are now three concepts:

  • A node is "marked as inert": done by specific APIs like dialog modal blocking
  • A node "is inert": true if either interactivity or "marked as inert"
  • An element or text node "behaves inertly": defined by CSS
    • But in a somewhat confusing way, since find-in-page and editability are defined by HTML, and some aspects of text selection (like the JS methods that cause it) are as well?
    • But I guess this was a preexisting problem; the paragraph you're deleting was already an action-at-a-distance part of the spec

I'm unsure whether it's worth separating these three concepts explicitly, but I wanted to call this out as potentially tricky.

I'm particularly confused what it means for non-element/text nodes to be inert now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this. I did have some trouble with this PR trying to decide what all of this should be called, or where it should live.

One nit: a node that "is inert" always "behaves inertly" so that's kind of one concept, right?

Anyway, happy to modify this however you see fit. Pointers appreciated. In particular the find-in-page, text selection, etc. are all (now) defined in CSS, so I at least wanted to have just one place where that's done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit: a node that "is inert" always "behaves inertly" so that's kind of one concept, right?

Right, except that "behaves inertly" only applies to text and element nodes, and the definition lives in a different document from "is inert".

My suggestion, although I don't feel too strongly:

  • Have only one definition of "inert", the one in CSS. I guess it only applies to elements and text nodes.
  • Define "marked as inert" or maybe "marked as explicitly inert" in HTML, as a boolean which all nodes have. Update that boolean when blocked by a modal dialog.
  • Have a sentence like "An element or text node must be considered [inert] if it is marked as inert or...".

Copy link
Contributor Author

@mfreed7 mfreed7 Feb 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So initially I liked the "marked as explicitly inert" suggestion, but I got a bit stuck. A few things:

  1. The current definition of "blocked by a modal dialog" is a bit weird, because the definition describes when it is so blocked (when there's a dialog element in the top layer), but then "show a modal dialog" step 15 says to essentially "set it to blocked" explicitly. I think maybe that last thing is unnecessary.
  2. The existing definition of "blocked by a modal dialog" handles a few concepts easily:
    a. the fact that being blocked gets inherited through the entire tree
    b. the fact that it stops at the topmost dialog

If I add a "marked as explicitly inert" on Node, then I also need to handle both 2a and 2b above. Perhaps that could just be done in words? E.g. an element is inert if ... one of its flat tree ancestors is "marked as explicitly inert", and the topmost dialog element isn't a flat tree ancestor? I don't know if that ends up making it more or less clean. I got started on this path, and stopped before I completely finished. Hopefully you can take a look and see if I'm on the right track?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah, I see what you mean. It doesn't seem worth it to transform this into an explicit boolean on every node, as maintaining it would be a lot of work.

A middle path that stays close to the current spec while also clarifying the interaction between CSS and blocked-by-a-modal would be something like:

  • Modify the current "blocked by a modal dialog" to something like:

    A Document document is blocked by a modal dialog subject if subject is the topmost dialog element in document's top layer. While document is so blocked, every nodeelement or text node that is connected to document, with the exception of the subject element and its flat tree descendants, must become inertis considered inert via dialog blockage.

    (or maybe "explicitly inert" or something like that.)

  • Remove the explicit "Let subject's node document be blocked by the modal dialog subject." As you say, that seems redundant and broken. Probably we forgot to remove it when we improved top layer + dialog interactions in the past.

    We can relocate the note about "This will cause the..." to the next step about top layer.

  • Now we can go with something like my suggestion above, of having "An element or text node must be considered [inert] if it is [inert via dialog blockage] or (the CSS stuff)".

But I kind of like the direction you're currently going as well, as it's quite explicit.

I wonder if there's any inspiration we can take from implementations here? How is it implemented in Chromium? (And in particular, how is the interaction between the CSS interactivity and the blocked-by-a-modal-dialog interactivity handled.)

The reason I ask about how the implementation works is that I'm worried about leading us toward a spec that seems explicit and rigorous, but isn't actually easy to implement / close to existing implementations.

source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
Copy link
Contributor Author

@mfreed7 mfreed7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comments!

@@ -79283,56 +79287,87 @@ interface <dfn interface>VisibilityStateEntry</dfn> : <span>PerformanceEntry</sp
<p class="note">See also <code data-x="attr-inert">inert</code> for an explanation of the
attribute of the same name.</p>

<p>A node (in particular elements and text nodes) can be <dfn>inert</dfn>. When a node is
<span>inert</span>:</p>
<p>A node (in particular elements and text nodes) can be <dfn>inert</dfn>.</p>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this. I did have some trouble with this PR trying to decide what all of this should be called, or where it should live.

One nit: a node that "is inert" always "behaves inertly" so that's kind of one concept, right?

Anyway, happy to modify this however you see fit. Pointers appreciated. In particular the find-in-page, text selection, etc. are all (now) defined in CSS, so I at least wanted to have just one place where that's done.

source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
@@ -79283,56 +79287,87 @@ interface <dfn interface>VisibilityStateEntry</dfn> : <span>PerformanceEntry</sp
<p class="note">See also <code data-x="attr-inert">inert</code> for an explanation of the
attribute of the same name.</p>

<p>A node (in particular elements and text nodes) can be <dfn>inert</dfn>. When a node is
<span>inert</span>:</p>
<p>A node (in particular elements and text nodes) can be <dfn>inert</dfn>.</p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit: a node that "is inert" always "behaves inertly" so that's kind of one concept, right?

Right, except that "behaves inertly" only applies to text and element nodes, and the definition lives in a different document from "is inert".

My suggestion, although I don't feel too strongly:

  • Have only one definition of "inert", the one in CSS. I guess it only applies to elements and text nodes.
  • Define "marked as inert" or maybe "marked as explicitly inert" in HTML, as a boolean which all nodes have. Update that boolean when blocked by a modal dialog.
  • Have a sentence like "An element or text node must be considered [inert] if it is marked as inert or...".

source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
source Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants