[csswg-drafts] [css-grid] Add APIs for discovering grid information not exposed by properties (#4511)

tabatkins has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-grid] Add APIs for discovering grid information not exposed by properties ==
In #4475 we resolved to try and fix the spec for the resolved value of grid-template-columns/rows to actually be valid for the property; currently it returns the sizes of all implicit tracks within the bounds of placed items as well.

It was brought up that such information on the implicit tracks could be useful; in particular, an old issue (#1465) asks for this information, in addition to some other grid-related information, such as final item placement.

We already know there's a use-case for such data: the DevTools in various browsers consume information about track sizes and such beyond what's exposed in properties. Any 3rd-party dev tooling would want the same information, at minimum.

<https://searchfox.org/mozilla-central/source/dom/webidl/Grid.webidl> is the IDL for the internal API that Firefox presents to its devtools code:

<details>
<summary>Firefox's DevTools IDL for grid tracks, sans comments</summary> 
```js
enum GridDeclaration { "explicit", "implicit" };
enum GridTrackState { "static", "repeat", "removed" };

[Exposed=Window]
interface Grid {
  readonly attribute GridDimension rows;
  readonly attribute GridDimension cols;
  readonly attribute sequence<GridArea> areas;
};

[Exposed=Window]
interface GridDimension {
  readonly attribute GridLines lines;
  readonly attribute GridTracks tracks;
};

[Exposed=Window]
interface GridLines {
  readonly attribute unsigned long length;
  getter GridLine? item(unsigned long index);
};

[Exposed=Window]
interface GridLine {
  readonly attribute sequence<DOMString> names;

  readonly attribute double start;
  readonly attribute double breadth;

  readonly attribute GridDeclaration type;
  readonly attribute unsigned long number;
  readonly attribute long negativeNumber;
};

[Exposed=Window]
interface GridTracks {
  readonly attribute unsigned long length;
  getter GridTrack? item(unsigned long index);
};

[Exposed=Window]
interface GridTrack {
  readonly attribute double start;
  readonly attribute double breadth;
  readonly attribute GridDeclaration type;
  readonly attribute GridTrackState state;
};

[Exposed=Window]
interface GridArea {
  readonly attribute DOMString name;
  readonly attribute GridDeclaration type;
  readonly attribute unsigned long rowStart;
  readonly attribute unsigned long rowEnd;
  readonly attribute unsigned long columnStart;
  readonly attribute unsigned long columnEnd;
};
```
</details>

We should add something like this, along with some other information, namely the positioning of items in the grid.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4511 using your GitHub account

Received on Friday, 15 November 2019 20:59:03 UTC