Context: https://bugzilla.mozilla.org/show_bug.cgi?id=317278#c4
The issue is how to handle content like <span>Hello Kit</span>ty where a word spans multiple frames and we need to break before the word. The problem is that the span's text frame doesn't know to break at the space if "Kit" fits but "Kitty" doesn't. Currently the text frame calls nsTextFrame::ComputeTotalWordDimensions to look ahead in the frame tree and try to compute the width required for the word that starts at the end of this frame. This code is really nasty. It also doesn't work in many cases ... for example, we don't know how to measure non-text-frame widths (these frames have not been reflowed yet, in general), so we give up on measuring those frames and allow breaks to happen before them. See the comment at http://lxr.mozilla.org/mozilla/source/layout/generic/nsImageFrame.cpp#1614, for example. I think a better way would be to simply allow the text frame to finish reflow with status 'complete', but record in nsLineLayout (or elsewhere) that there's a potential line break before the last word. When line layout eventually runs out of available space, we notice that we had a potential line break earlier, and reflow the line again, forcing the text frame to break at the last saved line break position. I think this case is not common so the cost should not be significant (and we may be able to optimize by only reflowing frames at or after the forced line break). In fact we may improve performance because the current lookahead approach requires us to measure the same text multiple times any time a word spans frames. Anyway it would simplify text frames a lot because the process of transforming and measuring text in a text frame could only happen in its Reflow. We also wouldn't have to do scary crawling around in a not-yet-reflowed frame tree. This general approach would also be useful in vertical situations. Currently we have problems with vertically-constrained text (pages, columns) where a frame with a thick border where the border ends up on a page boundary. We really need to move the last child to the next page, if possible, but we've already placed the child on the current page because it fitted. We need to redo the reflow, forcing the child to move to the next page. This becomes really acute when we want to handle CSS widows, orphans and page-break control. Rob _______________________________________________ dev-tech-layout mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-layout

