Avoid resetting the metrics-list/character offset for each text box
SVGTextLayoutEngine::layoutTextOnLineOrPath needs to keep track of the
SVGTextMetrics corresponding to each glyph it layouts. To do this, the
members m_visual{Character,MetricsList}Offset are used. However, this
state is reset for each invocation, which means that finding the
starting metrics entry can yield O(N^2) behavior. For text nodes with
many (logically consecutive) text boxes, this can become noticeable.
Introduce a helper SVGTextMetricsIterator - replacing the m_visual*
members - and let it persist across calls to layoutTextOnLineOrPath.
This speeds up the case of many logically consecutive text boxes.
Using the PerfTestRunner.measurePageLoadTime harness with
separate-x.svg from the bug give the following results locally:
Before: After:
avg 101.5 ms -> 93.1 ms
median 101.1 ms -> 93.1 ms
stdev 2.8 ms -> 2.3 ms
BUG=486669
Review URL: https://codereview.chromium.org/1160623002
git-svn-id: svn://svn.chromium.org/blink/trunk@196054 bbb929c8-8fbe-4397-9dbb-9b2b20218538
3 files changed