Skip to content

Commit 34bfeab

Browse files
committed
remove staticLayoutContribution
this is for spreadsheets in CellEngine when you double-click a column to fit it to text, but lineboxes are going away soon since they aren't needed in painting. CellEngine can pretty easily just find the max of items[i].x + items[i].measure() instead. I don't think this API made much sense generally (only in relation to this one use case) and it has some TODOs that would be kinda hard.
1 parent 80d22b9 commit 34bfeab

2 files changed

Lines changed: 0 additions & 59 deletions

File tree

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -709,18 +709,6 @@ environment.wasmLocator = function () {
709709
};
710710
```
711711

712-
## Other
713-
714-
### `staticLayoutContribution`
715-
716-
```ts
717-
function staticLayoutContribution(box: BlockContainer): number;
718-
```
719-
720-
Returns the inline size in CSS pixels taken up by the layout, not including empty space after lines or the effect of any `width` properties. `layout` must be called before this.
721-
722-
The intended usage is this: after laying out text into a desired size, use `staticLayoutContribution` to get the size without any remaining empty space at the end of the lines, then `layout` again into that size to get a tightly fitting layout.
723-
724712
# HarfBuzz
725713

726714
Glyph layout is performed by [HarfBuzz](https://github.com/harfbuzz/harfbuzz) compiled to WebAssembly. This allows for a level of correctness that isn't possible by using the `measureText` API to position spans of text. If you color the "V" in the text "AV" differently in Google Sheets, you will notice kerning is lost, and the letters appear further apart than they should be. That's because two `measureText` and `fillText` calls were made on the letters, so contextual glyph advances were lost. Dropflow uses HarfBuzz on more coarse shaping boundaries (not when color is changed) so that the font is more correctly supported.

src/api.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -212,53 +212,6 @@ export function t(text: string): TextNode {
212212
return new TextNode(id(), text);
213213
}
214214

215-
export function staticLayoutContribution(layout: Layout, box: BlockContainer): number {
216-
let intrinsicSize = 0;
217-
218-
const containingBlock = box.getContainingBlock();
219-
const definiteSize = box.getDefiniteOuterInlineSize(containingBlock);
220-
if (definiteSize !== undefined) {
221-
const marginLineLeft = box.style.getMarginLineLeft(containingBlock);
222-
const marginLineRight = box.style.getMarginLineRight(containingBlock);
223-
return definiteSize + (marginLineLeft === 'auto' ? 0 : marginLineLeft)
224-
+ (marginLineRight === 'auto' ? 0 : marginLineRight)
225-
}
226-
227-
if (box.isBlockContainerOfInlines()) {
228-
for (const line of box.lineboxes) {
229-
intrinsicSize = Math.max(intrinsicSize, line.width);
230-
}
231-
// TODO: floats
232-
} else {
233-
for (let i = box.treeStart + 1; i <= box.treeFinal; i++) {
234-
const child = layout.tree[i];
235-
if (child.isBlockContainer()) {
236-
intrinsicSize = Math.max(intrinsicSize, staticLayoutContribution(layout, child));
237-
} else if (child.isBox()) {
238-
// TODO:
239-
intrinsicSize = Math.max(intrinsicSize, child.getBorderArea().inlineSize);
240-
}
241-
if (child.isBox()) i = child.treeFinal;
242-
}
243-
}
244-
245-
const marginLineLeft = box.style.getMarginLineLeft(containingBlock);
246-
const marginLineRight = box.style.getMarginLineRight(containingBlock);
247-
const borderLineLeftWidth = box.style.getBorderLineLeftWidth(containingBlock);
248-
const paddingLineLeft = box.style.getPaddingLineLeft(containingBlock);
249-
const paddingLineRight = box.style.getPaddingLineRight(containingBlock);
250-
const borderLineRightWidth = box.style.getBorderLineRightWidth(containingBlock);
251-
252-
intrinsicSize += (marginLineLeft === 'auto' ? 0 : marginLineLeft)
253-
+ borderLineLeftWidth
254-
+ paddingLineLeft
255-
+ paddingLineRight
256-
+ borderLineRightWidth
257-
+ (marginLineRight === 'auto' ? 0 : marginLineRight);
258-
259-
return intrinsicSize;
260-
}
261-
262215
type LoadableResource = FontFace | Image;
263216

264217
export interface LoadWalkerContext {

0 commit comments

Comments
 (0)