Closed Bug 1645713 Opened 5 years ago Closed 5 years ago

FindNearestCommonAncestor does more work than BuildTextRunsScanner::ContinueTextRunAcrossFrames needs

Categories

(Core :: Layout: Text and Fonts, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: heycam, Assigned: heycam)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Profiling a page with a lot of text, I find 2.5% of Reflow time spent under nsLayoutUtils::FindNearestCommonAncestor. That function loops all the way up to the root frame for the two arguments, but for its use in BuildTextRunsScanner::ContinueTextRunAcrossFrames, we know that the two text frames are within the same block. We can add a variation of FindNearestCommonAncestor that only looks up to the closest block.

https://share.firefox.dev/3d5N990

There's a case that this patch crashes on, due to the two text frames being in different blocks as they're fragmented across columns: layout/base/crashtests/538267-1.html. It means that we return null from FindNearestCommonAncestorFrameWithinBlock and then we assert. It seems like it should be safe to return false from ContinueTextRunAcrossFrames in this case, rather than trying harder to find a common ancestor to check styles up the tree. Does that sound right, Jonathan?

Flags: needinfo?(jfkthame)

There's a case that this patch crashes on, due to the two text frames being in different blocks as they're fragmented across columns

Ugh... should've known there'd be some case that would complicate life! That suggests the same thing can happen across a page break, too.

In theory, we shouldn't allow that to interrupt text run creation, as there could be contextual shaping effects that depend on context and should be maintained even across the break; but I think that's such an obscure edge case that it's OK to ignore it for now. In almost all cases, interrupting shaping will be the right thing to do, and I'm not even sure how easily we'd be able to tell if it wasn't. (We have more serious issues to worry about regarding how line-breaks interact with shaping, anyhow.)

Please leave a comment in the code noting this case, though, to remind us if/when we ever revisit this.

Flags: needinfo?(jfkthame)
Pushed by cmccormack@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ac246edd1e36 Do less work when finding common ancestor for text run creation. r=jfkthame
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
Regressed by: 1654925
Has Regression Range: --- → yes
Keywords: regression
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: