Optimize SVGTextQuery's character offset ligature adjustment query
Optimize SVGTextQuery's character offset ligature adjustment query

For queries that take a code unit to compute some property for (basically
all *OfChar calls), the <start, end> range is mapped to the closest
glyph-boundary to allow queries within ligatures.
This adjustment step is O(N), N=number of glyphs within a text node, and
is performed for each fragment within a text box.
This means that for text boxes with a large number of fragments - and,
consequently, a large number of glyphs - there'll be O(N^2) behavior.
Since the <start, end> range is invariant for most queries, it should
suffice to compute the adjusted range once per text node [1].
The easiest way to achieve this is by adding a simple cache and reuse the
result of an adjustment query (for every fragment in a text box.)

This improves the runtime of the test in the bug from ~13s to ~120ms (or
approximately a factor 100) locally.

[1] This CL however only perform caching per text box in order to minimize
modifications to the actual adjustment code.

BUG=267504

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

git-svn-id: bf5cd6ccde378db821296732a091cfbcf5285fbd@176937 bbb929c8-8fbe-4397-9dbb-9b2b20218538

jtg-gg/blink,jtg-gg/blink,smishenk/blink-crosswalk,XiaosongWei/blink-crosswalk,XiaosongWei/blink-crosswalk,Pluto-tv/blink-crosswalk,smishenk/blink-crosswalk,jtg-gg/blink,Bysmyyr/blink-crosswalk,smishenk/blink-crosswalk,nwjs/blink,XiaosongWei/blink-crosswalk,hgl888/blink-crosswalk-efl,hgl888/blink-crosswalk-efl,smishenk/blink-crosswalk,XiaosongWei/blink-crosswalk,smishenk/blink-crosswalk,smishenk/blink-crosswalk,XiaosongWei/blink-crosswalk,modulexcite/blink,Bysmyyr/blink-crosswalk,jtg-gg/blink,smishenk/blink-crosswalk,hgl888/blink-crosswalk-efl,hgl888/blink-crosswalk-efl,jtg-gg/blink,hgl888/blink-crosswalk-efl,kurli/blink-crosswalk,modulexcite/blink,Pluto-tv/blink-crosswalk,Bysmyyr/blink-crosswalk,hgl888/blink-crosswalk-efl,hgl888/blink-crosswalk-efl,modulexcite/blink,kurli/blink-crosswalk,XiaosongWei/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,hgl888/blink-crosswalk-efl,smishenk/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,Pluto-tv/blink-crosswalk,Bysmyyr/blink-crosswalk,jtg-gg/blink,jtg-gg/blink,nwjs/blink,PeterWangIntel/blink-crosswalk,modulexcite/blink,hgl888/blink-crosswalk-efl,Pluto-tv/blink-crosswalk,PeterWangIntel/blink-crosswalk,kurli/blink-crosswalk,nwjs/blink,Bysmyyr/blink-crosswalk,modulexcite/blink,crosswalk-project/blink-crosswalk-efl,Bysmyyr/blink-crosswalk,PeterWangIntel/blink-crosswalk,modulexcite/blink,Bysmyyr/blink-crosswalk,nwjs/blink,nwjs/blink,nwjs/blink,Pluto-tv/blink-crosswalk,ondra-novak/blink,crosswalk-project/blink-crosswalk-efl,crosswalk-project/blink-crosswalk-efl,PeterWangIntel/blink-crosswalk,Bysmyyr/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,Pluto-tv/blink-crosswalk,XiaosongWei/blink-crosswalk,jtg-gg/blink,nwjs/blink,crosswalk-project/blink-crosswalk-efl,kurli/blink-crosswalk,PeterWangIntel/blink-crosswalk,nwjs/blink,hgl888/blink-crosswalk-efl,ondra-novak/blink,nwjs/blink,XiaosongWei/blink-crosswalk,jtg-gg/blink,kurli/blink-crosswalk,smishenk/blink-crosswalk,Pluto-tv/blink-crosswalk,PeterWangIntel/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,PeterWangIntel/blink-crosswalk,ondra-novak/blink,modulexcite/blink,nwjs/blink,kurli/blink-crosswalk,ondra-novak/blink,smishenk/blink-crosswalk,Pluto-tv/blink-crosswalk,XiaosongWei/blink-crosswalk,modulexcite/blink,modulexcite/blink,ondra-novak/blink,kurli/blink-crosswalk,ondra-novak/blink,ondra-novak/blink,PeterWangIntel/blink-crosswalk,modulexcite/blink,kurli/blink-crosswalk,kurli/blink-crosswalk,jtg-gg/blink,XiaosongWei/blink-crosswalk,Bysmyyr/blink-crosswalk,Pluto-tv/blink-crosswalk,kurli/blink-crosswalk,crosswalk-project/blink-crosswalk-efl,Pluto-tv/blink-crosswalk,PeterWangIntel/blink-crosswalk,Bysmyyr/blink-crosswalk,PeterWangIntel/blink-crosswalk,ondra-novak/blink,ondra-novak/blink