https://bugs.webkit.org/show_bug.cgi?id=223363
<rdar://problem/68279075>
Reviewed by Zalan Bujtas.
PerformanceTests:
* Layout/complex-columns.html: Added.
Source/WebCore:
When we perform line breaking in complex text, we create a persistent TextLayout object for the entire element, and ask
it questions about how wide various substrings are in the element. Our calling pattern is like this:
layout.width(a, b);
layout.width(b, c);
layout.width(c, d);
layout.width(d, e);
The implementation of TextLayout::width() is like this:
m_controller->advance(before);
float beforeWidth = m_controller->runWidthSoFar();
m_controller->advance(after);
float afterWidth = m_controller->runWidthSoFar();
This means that ComplexTextController is getting called twice in a row with the same position. However, the implementation of
ComplexTextController::advance() has:
if (offset <= m_currentCharacter) {
…
m_glyphInCurrentRun = 0;
…
}
The condition is true here, because it's getting called twice in a row with the same condition. However, when the condition
is true, we throw away all the previous work we've done during previous calls to ComplexTextController::advance().
This patch causes an 18x speedup on the performance test.
Performance Test: Layout/complex-columns.html
* platform/graphics/ComplexTextController.cpp:
(WebCore::ComplexTextController::advance):
Canonical link: https://commits.webkit.org/235412@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274567 268f45cc-cd09-0410-ab3c-d52691b4dbfc