Simplify (and optimize) SVGTextQuery::characterNumberAtPositionCallback

This method needs to iterate the glyphs within a fragment and check if the
queried point is contained within any of them.
Currently a fragment offset is converted to a offset that's suitable for
passing to mapStartEndPositionsIntoFragmentCoordinates - which then in
turn maps it into a text box-relative offset and then runs (the costly)
modifyStartEndPositionsRespectingLigatures to check if the current range
happen to fall within a "multicharacter glyph" (ligatures etc.), and then
expand the range appropriately.
This is a lot of work, that is better performed by finding the index within
the text metrics list for the corresponding RenderSVGInlineText object,
and then step through the fragment using the lengths of the individual
glyphs.
The impact on performance will vary with the length of fragments and the
length of the text content.
For a case like:

  <text ...>(AAAAAAAAAA ){99}AAAAAAAAAA</text>

  (100 groups of ten A's separated by a single whitespace)

with a negative query, the speed-up is ~1.2x. With 'word-spacing' added
(to get more fragments) the speed-up becomes ~8.7x.

Review URL: https://codereview.chromium.org/353003002

git-svn-id: svn://svn.chromium.org/blink/trunk@177089 bbb929c8-8fbe-4397-9dbb-9b2b20218538
1 file changed
tree: 9dd42b0ccb84333adde213e7a3d7a52db61fdf4d
  1. third_party/