Open Bug 2023125 Opened 18 days ago Updated 4 hours ago

Teach devtools about @container rules with multiple conditions.

Categories

(DevTools :: Inspector: Rules, task)

task

Tracking

(Not tracked)

People

(Reporter: emilio, Unassigned)

References

(Depends on 1 open bug)

Details

In bug 2016929 and bug 2022827 we're implementing multiple comma-separated conditions for @container queries, as part of interop 2026.

It seems like DevTools currently relies on .container{Name,Query} here, but those accessors can't deal with multiple conditions at all. Plus, name is optional...

Maybe we should just use the .conditionText? Or update that to use .conditions alternatively (once it's clear that's the path forward).

I don't have strong opinions... Nicolas, wdyt?

Flags: needinfo?(nchevobbe)

Thanks for filing a bug Emilio

In the client, we do use the containerName that we put in its own element https://searchfox.org/firefox-main/rev/7b08fa00f500ed877b16983a6a77d2c852aad1d0/devtools/client/inspector/rules/views/rule-editor.js#221-224

createChild(selectorContainer, "span", {
  class: "container-query-declaration",
  textContent: `@container${ancestorData.containerName ? " " + ancestorData.containerName : ""}`,
});

that we can then target to show the container information in a tooltip https://searchfox.org/firefox-main/rev/7b08fa00f500ed877b16983a6a77d2c852aad1d0/devtools/client/inspector/shared/tooltips-overlay.js#455-464

if (type === TOOLTIP_CSS_QUERY_CONTAINER) {
  // Ensure this is the correct node and not a parent.
  if (!target.closest(".container-query .container-query-declaration")) {
    return false;
  }

  await this.cssQueryContainerTooltipHelper.setContent(
    nodeInfo.value,
    this.getTooltip("interactiveTooltip")
  );

If I'm understanding what's done in https://phabricator.services.mozilla.com/D287344 , it seems like we could switch to conditions, which do expose the name and query for each condition.
I'll handle it, as this will also require changes on the client side

Flags: needinfo?(nchevobbe)

Note that we also need to update the StyleEditor at-rule sidebar to be able to display multiple conditions at https://searchfox.org/firefox-main/rev/7b08fa00f500ed877b16983a6a77d2c852aad1d0/devtools/client/styleeditor/StyleEditorUI.sys.mjs#1391

Depends on: 2019254
No longer depends on: 2016929
You need to log in before you can comment on or make changes to this bug.