[LayoutNG] Fix O(N^2) in NGInlineNode::ShapeText
When shaping the content of an inline node in NGInlineNode::ShapeText we assume that the number of runs is small and iterate over all of the runs for each inline item. This assumption holds true for most content, there are certain cases where the assumption is incorrect however, such as the euckr-decode-ksc_5601.html WPT test where each CJK glyph is wrapped in a span and separated by space characters of a different glyph. This causes each of the 10k+ items to iterate over 10+ runs which is very expensive. This patch adds an optional context argument to ShapeResult::SubRange so that context (the relevant run) may be maintained across invocations and thereby avoids an extra loop over all of the runs for each SubRange call. Change-Id: I2ee610a60e33fe4389277fc275a9b8d670453a31 Reviewed-on: https://chromium-review.googlesource.com/c/1354561Reviewed-by:Adenilson Cavalcanti <cavalcantii@chromium.org> Commit-Queue: Emil A Eklund <eae@chromium.org> Cr-Commit-Position: refs/heads/master@{#612403}
Showing
Please register or sign in to comment