Re: [css-houdini-drafts] [text-layout] Houdini and text layout (#854)

+1 to having a breakout on this topic to scope out current thinking.

@litherum I think we agree on the broad strokes (although might be easier to discuss in person).

The direction we are pursing is similar to what you are describing however is slightly lower level. The current approach effectively allows developers to handle inline level content at the line-box level. E.g.

```js
registerLayout('inline-something', class {
  // "inline" children produce lineboxes instead of being blockified.
  static layoutOptions = {childDisplay: 'normal'}; 
  async layout(children) {
    const inline = children[0];
   
    const childFragments = [];
    let childBreakToken = null;
    do {
      // .. perform some calculation to determine the availableInlineSize.
      // E.g. should be able to polyfill shape-inside, etc.
      const lineBoxFragment = inline.layout({availableInlineSize}, childBreakToken);

      // Allowing placing the line box allows for lines to be snapped to a grid, etc, which isn't possible today.
      lineBoxFragment.blockOffset = /* something */;
      lineBoxFragment.inlineOffset = /* something */;
     
      childBreakToken = lineBoxFragment.breakToken;
      childFragments.push(lineBoxFragment);
    } while (childBreakToken); 
  }

  return {childFragments};
});
```

Example 12 in the spec deals with this + some advanced fragmentation primitives.
https://drafts.css-houdini.org/css-layout-api/#examples

As you note, this means that we don't need to deal with a lot of the current complexity with bidi resolution, etc, etc, etc.

There are variations on this API where you could "batch" calls and produce multiple line boxes, if you know you can precompute the availableInlineSize. 

As @kojiishi mentions there might be other small targeted things we can do like calculating line break opportunities as well.


-- 
GitHub Notification of comment by bfgeek
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/854#issuecomment-461583379 using your GitHub account

Received on Thursday, 7 February 2019 20:27:29 UTC