cc'ing layout-dev just in case you have some better ideas. I am inspired to email
you all by seeing @mstensho fix a floating bug that had me busy for a week in a day.
The bug concerns painting of LayoutInline outlines.
LayoutInline outline is a union of fragments generated by LayoutInline,
but needs to be painted by one fragment. That fragment will have InkOverflow
that spans all outlines together.
NG solves "multiple fragments painted by one" problem by designating
first fragment of LayoutInline as "outline painting fragment".
This works well as long as LayoutInline generates at least one fragment.
Simplest failure case is <span .outline><div></div></span>
There are two ways to fix this:
1) In Layout, make sure that LayoutInline always generates at least one fragment.
@kojii
tried this, and
43 tests failed.
It would also mean more memory usage, unsure how much.
2) in Paint, detect that LayoutInline has not created any fragments, and
paint missing LayoutInline directly.
I've been trying to implement this, and it is more complex than
I thought. Some issues, and my attempts at solving them:
A) Who should paint invisible LayoutInline?
Fragment generated by LayoutInline's containing block.
I named this fragment "GhostPainter"
B) How does GhostPainter detect that it has LayoutInlines it should paint?
I do not have a good solution for this. We can't just traverse all element children
all the time, that would be too inefficient.
Even worse, I think we need to traverse not just children, but descendants,
because of this case:
<span><span .outline><div<</div></span></span>
The list of LayoutInline's with outlines cannot be stored on fragments,
because we must not relayout when outline status changes.
My current guess is, after looking at fragment trees for a while:
If GhostPainter has empty LineBox children, inside GhostPainter.GetLayoutObject
search for LayoutInline's with outline, and without fragments.
I do not think this is strictly correct, I can imagine something like
<span>foo</span><span .outline><div></div></span><span>bar</span>
not generating any empty LineBoxes.
C) GhostPainter also needs to do this search during Layout to
C.1) compute its InkOverflow.
C.2) Tell paint layer that it needs kOutline paint phase.
D) Need a bit of hacking to paint LayoutInline outline when it
is laid out by NG, but should be painted by Legacy.
I think we need to solve the search problem inside inline_layout_algorithm,
and store LayoutInlines that did not generate fragments on LineBox.
Then I can use this list to solve C) and D) efficiently.
Solving this has been tough for me, because my knowledge of
inline_layout_algorithm is limited, I cannot predict with certainty
what fragments will be generated by a layout tree.
Aleks