Changeset 31342 in webkit


Ignore:
Timestamp:
Mar 26, 2008 7:34:14 PM (16 years ago)
Author:
mjs@apple.com
Message:

WebCore:

2008-03-26 Maciej Stachowiak <mjs@apple.com>

Reviewed by Hyatt and Adam.

Coded by me and Darin.


  • SVG kerning support (horizontal kerning only for now since we don't do vertical text layout right yet)


Acid3 100/100

  • DerivedSources.make:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • platform/graphics/Font.cpp: (WebCore::Font::floatWidth): (WebCore::Font::isSVGFont):
  • platform/graphics/Font.h:
  • rendering/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::calculateGlyphWidth): (WebCore::SVGInlineTextBox::calculateGlyphBoundaries):
  • rendering/SVGInlineTextBox.h:
  • rendering/SVGRootInlineBox.cpp: (WebCore::cummulatedWidthOrHeightOfTextChunk): (WebCore::SVGRootInlineBox::buildLayoutInformation): (WebCore::SVGRootInlineBox::buildLayoutInformationForTextBox):
  • rendering/SVGRootInlineBox.h: (WebCore::LastGlyphInfo::LastGlyphInfo):
  • svg/SVGFont.cpp: (WebCore::SVGTextRunWalker::walk): (WebCore::Font::svgFont): (WebCore::floatWidthOfSubStringUsingSVGFont): (WebCore::Font::floatWidthUsingSVGFont): (WebCore::Font::drawTextUsingSVGFont): (WebCore::Font::selectionRectForTextUsingSVGFont):
  • svg/SVGFontElement.cpp: (WebCore::SVGFontElement::invalidateGlyphCache): (WebCore::SVGFontElement::ensureGlyphCache): (WebCore::parseUnicodeRange): (WebCore::parseUnicodeRangeList): (WebCore::stringMatchesUnicodeRange): (WebCore::matches): (WebCore::SVGFontElement::getHorizontalKerningPairForStringsAndGlyphs):
  • svg/SVGFontElement.h:
  • svg/SVGGlyphElement.cpp: (WebCore::SVGGlyphElement::insertedIntoDocument): (WebCore::SVGGlyphElement::removedFromDocument):
  • svg/SVGHKernElement.cpp: Added. (WebCore::SVGHKernElement::SVGHKernElement): (WebCore::SVGHKernElement::~SVGHKernElement): (WebCore::SVGHKernElement::insertedIntoDocument): (WebCore::SVGHKernElement::removedFromDocument): (WebCore::SVGHKernElement::buildHorizontalKerningPair):
  • svg/SVGHKernElement.h: Added. (WebCore::SVGHorizontalKerningPair::SVGHorizontalKerningPair): (WebCore::SVGHKernElement::rendererIsNeeded):
  • svg/SVGHKernElement.idl: Added.
  • svg/SVGTextContentElement.cpp: (WebCore::cummulatedCharacterRangeLength): (WebCore::SVGInlineTextBoxQueryWalker::chunkPortionCallback):
  • svg/svgtags.in:

LayoutTests:

2008-03-26 Maciej Stachowiak <mjs@apple.com>

Reviewed by Hyatt and Adam.


  • new test case and test fixes for SVG text kerning
  • svg/text/kerning.svg: Added.
  • platform/mac/svg/text/kerning-expected.txt: Added.
  • platform/mac/svg/W3C-SVG-1.1/fonts-kern-01-t-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/masking-mask-01-b-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/render-groups-01-b-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/render-groups-03-t-expected.txt:
  • platform/mac/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.txt:
Location:
trunk
Files:
5 added
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r31331 r31342  
     12008-03-26  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Hyatt and Adam.
     4       
     5        - new test case and test fixes for SVG text kerning
     6
     7        * svg/text/kerning.svg: Added.
     8        * platform/mac/svg/text/kerning-expected.txt: Added.
     9
     10        * platform/mac/svg/W3C-SVG-1.1/fonts-kern-01-t-expected.txt:
     11        * platform/mac/svg/W3C-SVG-1.1/masking-mask-01-b-expected.txt:
     12        * platform/mac/svg/W3C-SVG-1.1/render-groups-01-b-expected.txt:
     13        * platform/mac/svg/W3C-SVG-1.1/render-groups-03-t-expected.txt:
     14        * platform/mac/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.txt:
     15
    1162008-03-26  Stephanie Lewis  <slewis@apple.com>
    217
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-kern-01-t-expected.txt

    r30635 r31342  
    22  RenderView at (0,0) size 480x360
    33layer at (0,0) size 480x360
    4   RenderSVGRoot {svg} at (0.50,0.50) size 482.50x359
    5     RenderSVGContainer {g} at (9.50,12) size 473.50x263.50
     4  RenderSVGRoot {svg} at (0.50,0.50) size 9344.50x359
     5    RenderSVGContainer {g} at (9.50,12) size 9335.50x263.50
    66      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    77        RenderSVGContainer {g} at (-2,-12) size 14x14
     
    1616        RenderSVGInlineText {#text} at (0,-18) size 68x23
    1717          chunk 1 (middle anchor) text run 1 at (206.00,30.00) startOffset 0 endOffset 7 width 68.00: "<hkern>"
    18       RenderSVGContainer {g} at (9.50,59.50) size 473.50x216 [transform={m=((1.00,0.00)(0.00,1.00)) t=(30.00,60.00)}]
    19         RenderSVGContainer {g} at (9.50,59.50) size 221x51
     18      RenderSVGContainer {g} at (9.50,59.50) size 9335.50x216 [transform={m=((1.00,0.00)(0.00,1.00)) t=(30.00,60.00)}]
     19        RenderSVGContainer {g} at (9.50,59.50) size 2041.50x51
    2020          RenderSVGContainer {g} at (9.50,59.50) size 21x51
    2121            RenderPath {rect} at (9.50,59.50) size 21x51 [stroke={[type=SOLID] [color=#000000]}] [data="M-20.00,0.00L0.00,0.00L0.00,50.00L-20.00,50.00"]
     
    3232            RenderSVGInlineText {#text} at (0,-11) size 73x14
    3333              chunk 1 text run 1 at (5.00,15.00) startOffset 0 endOffset 13 width 73.00: "u1=\"1\" u2=\"2\""
    34           RenderSVGContainer {g} at (31,81) size 53x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
     34          RenderSVGContainer {g} at (31,81) size 2020x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
    3535            RenderSVGContainer {use} at (31,81) size 28x28
    3636              RenderSVGContainer {g} at (31,81) size 28x28
     
    4545                  RenderPath {line} at (60,104) size 24x2 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L12.00,0.00"]
    4646                  RenderPath {rect} at (56,101) size 8x8 [fill={[type=SOLID] [color=#FF0000]}] [data="M-2.00,-2.00L2.00,-2.00L2.00,2.00L-2.00,2.00"]
    47             RenderSVGText {text} at (0,0) size 8x10 contains 1 chunk(s)
    48               RenderSVGInlineText {#text} at (0,-8) size 8x10
     47            RenderSVGText {text} at (0,0) size 1008x10 contains 1 chunk(s)
     48              RenderSVGInlineText {#text} at (0,-8) size 1008x10
    4949                chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 2 width 7.50: "12"
    50         RenderSVGContainer {g} at (9.50,114.50) size 221x51 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,55.00)}]
     50        RenderSVGContainer {g} at (9.50,114.50) size 4041.50x51 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,55.00)}]
    5151          RenderSVGContainer {g} at (9.50,114.50) size 21x51
    5252            RenderPath {rect} at (9.50,114.50) size 21x51 [stroke={[type=SOLID] [color=#000000]}] [data="M-20.00,0.00L0.00,0.00L0.00,50.00L-20.00,50.00"]
     
    6363            RenderSVGInlineText {#text} at (0,-14) size 138x18
    6464              chunk 1 text run 1 at (5.00,15.00) startOffset 0 endOffset 19 width 138.00: "g1=\"gl_1\" g2=\"gl_2\""
    65           RenderSVGContainer {g} at (31,136) size 73x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
     65          RenderSVGContainer {g} at (31,136) size 4020x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
    6666            RenderSVGContainer {use} at (31,136) size 28x28
    6767              RenderSVGContainer {g} at (31,136) size 28x28
     
    7676                  RenderPath {line} at (80,159) size 24x2 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L12.00,0.00"]
    7777                  RenderPath {rect} at (76,156) size 8x8 [fill={[type=SOLID] [color=#FF0000]}] [data="M-2.00,-2.00L2.00,-2.00L2.00,2.00L-2.00,2.00"]
    78             RenderSVGText {text} at (0,0) size 8x10 contains 1 chunk(s)
    79               RenderSVGInlineText {#text} at (0,-8) size 8x10
     78            RenderSVGText {text} at (0,0) size 2008x10 contains 1 chunk(s)
     79              RenderSVGInlineText {#text} at (0,-8) size 2008x10
    8080                chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 2 width 7.50: "12"
    8181        RenderSVGContainer {g} at (9.50,169.50) size 265.50x51 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,110.00)}]
     
    208208              RenderSVGInlineText {#text} at (0,-8) size 35x10
    209209                chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 4 width 35.00: "1234"
    210         RenderSVGContainer {g} at (249.50,114.50) size 233.50x51 [transform={m=((1.00,0.00)(0.00,1.00)) t=(240.00,55.00)}]
     210        RenderSVGContainer {g} at (249.50,114.50) size 9095.50x51 [transform={m=((1.00,0.00)(0.00,1.00)) t=(240.00,55.00)}]
    211211          RenderSVGContainer {g} at (249.50,114.50) size 21x51
    212212            RenderPath {rect} at (249.50,114.50) size 21x51 [stroke={[type=SOLID] [color=#000000]}] [data="M-20.00,0.00L0.00,0.00L0.00,50.00L-20.00,50.00"]
     
    223223            RenderSVGInlineText {#text} at (0,-14) size 208x18
    224224              chunk 1 text run 1 at (5.00,15.00) startOffset 0 endOffset 26 width 208.00: "u1=\"U+003?\" u2=\"U+0031-34\""
    225           RenderSVGContainer {g} at (271,136) size 168x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
     225          RenderSVGContainer {g} at (271,136) size 9074x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
    226226            RenderSVGContainer {use} at (271,136) size 28x28
    227227              RenderSVGContainer {g} at (271,136) size 28x28
     
    248248                  RenderPath {line} at (415,159) size 24x2 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L12.00,0.00"]
    249249                  RenderPath {rect} at (411,156) size 8x8 [fill={[type=SOLID] [color=#FF0000]}] [data="M-2.00,-2.00L2.00,-2.00L2.00,2.00L-2.00,2.00"]
    250             RenderSVGText {text} at (0,0) size 35x10 contains 1 chunk(s)
    251               RenderSVGInlineText {#text} at (0,-8) size 35x10
    252                 chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 4 width 35.00: "1234"
    253         RenderSVGContainer {g} at (249.50,169.50) size 221x51 [transform={m=((1.00,0.00)(0.00,1.00)) t=(240.00,110.00)}]
     250            RenderSVGText {text} at (0,0) size 4535x10 contains 1 chunk(s)
     251              RenderSVGInlineText {#text} at (0,-8) size 4535x10
     252                chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 4 width 35.00: "1234"
     253        RenderSVGContainer {g} at (249.50,169.50) size 2061.50x51 [transform={m=((1.00,0.00)(0.00,1.00)) t=(240.00,110.00)}]
    254254          RenderSVGContainer {g} at (249.50,169.50) size 21x51
    255255            RenderPath {rect} at (249.50,169.50) size 21x51 [stroke={[type=SOLID] [color=#000000]}] [data="M-20.00,0.00L0.00,0.00L0.00,50.00L-20.00,50.00"]
     
    266266            RenderSVGInlineText {#text} at (0,-14) size 118x18
    267267              chunk 1 text run 1 at (5.00,15.00) startOffset 0 endOffset 16 width 118.00: "u1=\"1\" g2=\"gl_2\""
    268           RenderSVGContainer {g} at (271,191) size 53x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
     268          RenderSVGContainer {g} at (271,191) size 2040x28 [transform={m=((2.00,0.00)(0.00,2.00)) t=(5.00,45.00)}]
    269269            RenderSVGContainer {use} at (271,191) size 28x28
    270270              RenderSVGContainer {g} at (271,191) size 28x28
     
    279279                  RenderPath {line} at (300,214) size 24x2 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L12.00,0.00"]
    280280                  RenderPath {rect} at (296,211) size 8x8 [fill={[type=SOLID] [color=#FF0000]}] [data="M-2.00,-2.00L2.00,-2.00L2.00,2.00L-2.00,2.00"]
    281             RenderSVGText {text} at (0,0) size 18x10 contains 1 chunk(s)
    282               RenderSVGInlineText {#text} at (0,-8) size 18x10
     281            RenderSVGText {text} at (0,0) size 1018x10 contains 1 chunk(s)
     282              RenderSVGInlineText {#text} at (0,-8) size 1018x10
    283283                chunk 1 text run 1 at (0.00,0.00) startOffset 0 endOffset 2 width 17.50: "12"
    284284      RenderSVGContainer {g} at (320,100) size 0x0 [transform={m=((1.00,0.00)(0.00,1.00)) t=(320.00,100.00)}]
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/masking-mask-01-b-expected.txt

    r30635 r31342  
    4141        RenderPath {rect} at (60,250) size 200x25 [fill={[type=SOLID] [color=#FFFFFF]}] [data="M60.00,250.00L260.00,250.00L260.00,275.00L60.00,275.00"]
    4242        RenderPath {rect} at (60,275) size 200x25 [fill={[type=SOLID] [color=#FFFFFF] [opacity=0.70]}] [data="M60.00,275.00L260.00,275.00L260.00,300.00L60.00,300.00"]
    43       RenderSVGText {text} at (60,280) size 121x110 contains 1 chunk(s)
    44         RenderSVGInlineText {#text} at (0,-88) size 121x110
     43      RenderSVGText {text} at (60,280) size 161x110 contains 1 chunk(s)
     44        RenderSVGInlineText {#text} at (0,-88) size 161x110
    4545          chunk 1 text run 1 at (60.00,280.00) startOffset 0 endOffset 3 width 121.33: "SVG"
    4646      RenderSVGText {text} at (200,225) size 200x14 contains 1 chunk(s)
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/render-groups-01-b-expected.txt

    r30635 r31342  
    1717        RenderPath {rect} at (35.10,17.10) size 415.80x280.80 [stroke={[type=SOLID] [color=#000000]}] [data="M20.00,10.00L250.00,10.00L250.00,165.00L20.00,165.00"]
    1818        RenderSVGContainer {g} at (54,-10.80) size 381.60x289.80 [opacity=0.50]
    19           RenderSVGText {text} at (30,90) size 132x120 contains 1 chunk(s)
    20             RenderSVGInlineText {#text} at (0,-96) size 132x120
     19          RenderSVGText {text} at (30,90) size 172x120 contains 1 chunk(s)
     20            RenderSVGInlineText {#text} at (0,-96) size 172x120
    2121              chunk 1 text run 1 at (30.00,90.00) startOffset 0 endOffset 3 width 132.36: "SVG"
    2222          RenderPath {rect} at (126,99) size 234x126 [fill={[type=SOLID] [color=#820032]}] [data="M70.00,55.00L200.00,55.00L200.00,125.00L70.00,125.00"]
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/render-groups-03-t-expected.txt

    r30635 r31342  
    1616        RenderPath {line} at (436.50,18) size 27x297 [stroke={[type=SOLID] [color=#FFFFFF] [stroke width=15.00]}] [fill={[type=SOLID] [color=#000000]}] [data="M250.00,10.00L250.00,175.00"]
    1717        RenderPath {rect} at (35.10,17.10) size 415.80x280.80 [stroke={[type=SOLID] [color=#000000]}] [data="M20.00,10.00L250.00,10.00L250.00,165.00L20.00,165.00"]
    18         RenderSVGText {text} at (30,90) size 132x120 contains 1 chunk(s)
    19           RenderSVGInlineText {#text} at (0,-96) size 132x120
     18        RenderSVGText {text} at (30,90) size 172x120 contains 1 chunk(s)
     19          RenderSVGInlineText {#text} at (0,-96) size 172x120
    2020            chunk 1 text run 1 at (30.00,90.00) startOffset 0 endOffset 3 width 132.36: "SVG"
    2121        RenderPath {rect} at (126,99) size 234x126 [fill={[type=SOLID] [color=#820032]}] [data="M70.00,55.00L200.00,55.00L200.00,125.00L70.00,125.00"]
  • trunk/LayoutTests/platform/mac/svg/custom/scrolling-embedded-svg-file-image-repaint-problem-expected.txt

    r30635 r31342  
    7474                                RenderPath {rect} at (35.10,17.10) size 415.80x280.80 [stroke={[type=SOLID] [color=#000000]}] [data="M20.00,10.00L250.00,10.00L250.00,165.00L20.00,165.00"]
    7575                                RenderSVGContainer {g} at (54,-10.80) size 381.60x289.80 [opacity=0.50]
    76                                   RenderSVGText {text} at (30,90) size 132x120 contains 1 chunk(s)
    77                                     RenderSVGInlineText {#text} at (0,-96) size 132x120
     76                                  RenderSVGText {text} at (30,90) size 172x120 contains 1 chunk(s)
     77                                    RenderSVGInlineText {#text} at (0,-96) size 172x120
    7878                                      chunk 1 text run 1 at (30.00,90.00) startOffset 0 endOffset 3 width 132.36: "SVG"
    7979                                  RenderPath {rect} at (126,99) size 234x126 [fill={[type=SOLID] [color=#820032]}] [data="M70.00,55.00L200.00,55.00L200.00,125.00L70.00,125.00"]
  • trunk/WebCore/ChangeLog

    r31341 r31342  
     12008-03-26  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Hyatt and Adam.
     4
     5        Coded by me and Darin.
     6       
     7        - SVG kerning support (horizontal kerning only for now since we don't do vertical text layout right yet)
     8       
     9        Acid3 100/100
     10
     11        * DerivedSources.make:
     12        * WebCore.vcproj/WebCore.vcproj:
     13        * WebCore.xcodeproj/project.pbxproj:
     14        * platform/graphics/Font.cpp:
     15        (WebCore::Font::floatWidth):
     16        (WebCore::Font::isSVGFont):
     17        * platform/graphics/Font.h:
     18        * rendering/SVGInlineTextBox.cpp:
     19        (WebCore::SVGInlineTextBox::calculateGlyphWidth):
     20        (WebCore::SVGInlineTextBox::calculateGlyphBoundaries):
     21        * rendering/SVGInlineTextBox.h:
     22        * rendering/SVGRootInlineBox.cpp:
     23        (WebCore::cummulatedWidthOrHeightOfTextChunk):
     24        (WebCore::SVGRootInlineBox::buildLayoutInformation):
     25        (WebCore::SVGRootInlineBox::buildLayoutInformationForTextBox):
     26        * rendering/SVGRootInlineBox.h:
     27        (WebCore::LastGlyphInfo::LastGlyphInfo):
     28        * svg/SVGFont.cpp:
     29        (WebCore::SVGTextRunWalker::walk):
     30        (WebCore::Font::svgFont):
     31        (WebCore::floatWidthOfSubStringUsingSVGFont):
     32        (WebCore::Font::floatWidthUsingSVGFont):
     33        (WebCore::Font::drawTextUsingSVGFont):
     34        (WebCore::Font::selectionRectForTextUsingSVGFont):
     35        * svg/SVGFontElement.cpp:
     36        (WebCore::SVGFontElement::invalidateGlyphCache):
     37        (WebCore::SVGFontElement::ensureGlyphCache):
     38        (WebCore::parseUnicodeRange):
     39        (WebCore::parseUnicodeRangeList):
     40        (WebCore::stringMatchesUnicodeRange):
     41        (WebCore::matches):
     42        (WebCore::SVGFontElement::getHorizontalKerningPairForStringsAndGlyphs):
     43        * svg/SVGFontElement.h:
     44        * svg/SVGGlyphElement.cpp:
     45        (WebCore::SVGGlyphElement::insertedIntoDocument):
     46        (WebCore::SVGGlyphElement::removedFromDocument):
     47        * svg/SVGHKernElement.cpp: Added.
     48        (WebCore::SVGHKernElement::SVGHKernElement):
     49        (WebCore::SVGHKernElement::~SVGHKernElement):
     50        (WebCore::SVGHKernElement::insertedIntoDocument):
     51        (WebCore::SVGHKernElement::removedFromDocument):
     52        (WebCore::SVGHKernElement::buildHorizontalKerningPair):
     53        * svg/SVGHKernElement.h: Added.
     54        (WebCore::SVGHorizontalKerningPair::SVGHorizontalKerningPair):
     55        (WebCore::SVGHKernElement::rendererIsNeeded):
     56        * svg/SVGHKernElement.idl: Added.
     57        * svg/SVGTextContentElement.cpp:
     58        (WebCore::cummulatedCharacterRangeLength):
     59        (WebCore::SVGInlineTextBoxQueryWalker::chunkPortionCallback):
     60        * svg/svgtags.in:
     61
    1622008-03-26  Sam Weinig  <sam@webkit.org>
    263
  • trunk/WebCore/DerivedSources.make

    r31341 r31342  
    251251    SVGGlyphElement \
    252252    SVGGradientElement \
     253    SVGHKernElement \
    253254    SVGImageElement \
    254255    SVGLangSpace \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r31341 r31342  
    1182311823                        </File>
    1182411824                        <File
     11825                                RelativePath="..\svg\SVGHKernElement.cpp"
     11826                                >
     11827                        </File>
     11828                        <File
     11829                                RelativePath="..\svg\SVGHKernElement.h"
     11830                                >
     11831                        </File>
     11832                        <File
    1182511833                                RelativePath="..\svg\SVGAngle.cpp"
    1182611834                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r31341 r31342  
    521521                650F53DC09D15DDA00C9B0C8 /* CSSGrammar.h in Headers */ = {isa = PBXBuildFile; fileRef = 650F53DB09D15DDA00C9B0C8 /* CSSGrammar.h */; };
    522522                650F53DD09D15DDF00C9B0C8 /* CSSGrammar.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6565814409D13043000E61D7 /* CSSGrammar.cpp */; };
     523                650FBF2A0D9AF047008FC292 /* SVGHKernElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 650FBF270D9AF046008FC292 /* SVGHKernElement.cpp */; };
     524                650FBF2B0D9AF047008FC292 /* SVGHKernElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 650FBF280D9AF047008FC292 /* SVGHKernElement.h */; };
     525                650FBF2C0D9AF047008FC292 /* SVGHKernElement.idl in Resources */ = {isa = PBXBuildFile; fileRef = 650FBF290D9AF047008FC292 /* SVGHKernElement.idl */; };
    523526                6515EC910D9723FF0063D49A /* JSSVGAltGlyphElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6515EC8F0D9723FF0063D49A /* JSSVGAltGlyphElement.cpp */; };
    524527                6515EC920D9723FF0063D49A /* JSSVGAltGlyphElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 6515EC900D9723FF0063D49A /* JSSVGAltGlyphElement.h */; };
     
    49014904                5DCF836C0D59159800953BC6 /* PluginInfoStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PluginInfoStore.h; sourceTree = "<group>"; };
    49024905                650F53DB09D15DDA00C9B0C8 /* CSSGrammar.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSGrammar.h; sourceTree = "<group>"; };
     4906                650FBF270D9AF046008FC292 /* SVGHKernElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGHKernElement.cpp; sourceTree = "<group>"; };
     4907                650FBF280D9AF047008FC292 /* SVGHKernElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGHKernElement.h; sourceTree = "<group>"; };
     4908                650FBF290D9AF047008FC292 /* SVGHKernElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGHKernElement.idl; sourceTree = "<group>"; };
    49034909                6515EC8F0D9723FF0063D49A /* JSSVGAltGlyphElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAltGlyphElement.cpp; sourceTree = "<group>"; };
    49044910                6515EC900D9723FF0063D49A /* JSSVGAltGlyphElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSVGAltGlyphElement.h; sourceTree = "<group>"; };
     
    1102011026                                B22277FF0D00BF1F0071B782 /* SVGAnimateTransformElement.h */,
    1102111027                                B22278000D00BF1F0071B782 /* SVGAnimateTransformElement.idl */,
     11028                                650FBF270D9AF046008FC292 /* SVGHKernElement.cpp */,
     11029                                650FBF280D9AF047008FC292 /* SVGHKernElement.h */,
     11030                                650FBF290D9AF047008FC292 /* SVGHKernElement.idl */,
    1102211031                                B22278010D00BF1F0071B782 /* SVGAnimationElement.cpp */,
    1102311032                                B22278020D00BF1F0071B782 /* SVGAnimationElement.h */,
     
    1466514674                                BCE1C43C0D9830D3003B02F2 /* JSLocation.h in Headers */,
    1466614675                                E415F1840D9A1A830033CE97 /* ElementTimeControl.h in Headers */,
     14676                                650FBF2B0D9AF047008FC292 /* SVGHKernElement.h in Headers */,
    1466714677                        );
    1466814678                        runOnlyForDeploymentPostprocessing = 0;
     
    1478114791                                BCA83E370D7CDC4E003421A8 /* Clipboard.idl in Resources */,
    1478214792                                65653F2F0D9727D200CA9723 /* SVGAltGlyphElement.idl in Resources */,
     14793                                650FBF2C0D9AF047008FC292 /* SVGHKernElement.idl in Resources */,
    1478314794                                BCE1C4230D9829F2003B02F2 /* Location.idl in Resources */,
    1478414795                        );
     
    1631216323                                65653F2D0D9727D200CA9723 /* SVGAltGlyphElement.cpp in Sources */,
    1631316324                                65AA6BB00D974A00000541AE /* DOMSVGAltGlyphElement.mm in Sources */,
     16325                                650FBF2A0D9AF047008FC292 /* SVGHKernElement.cpp in Sources */,
    1631416326                                BCE1C41C0D982981003B02F2 /* Location.cpp in Sources */,
    1631516327                                BCE1C43B0D9830D3003B02F2 /* JSLocation.cpp in Sources */,
  • trunk/WebCore/platform/graphics/Font.cpp

    r31310 r31342  
    709709}
    710710
    711 float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed) const
     711float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
    712712{
    713713#if ENABLE(SVG_FONTS)
    714714    if (primaryFont()->isSVGFont())
    715         return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed);
     715        return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed, glyphName);
    716716#endif
    717717
    718718    charsConsumed = run.length();
     719    glyphName = "";
    719720    if (canUseGlyphCache(run))
    720721        return floatWidthForSimpleText(run, 0);
     
    815816}
    816817
     818#if ENABLE(SVG_FONTS)
     819bool Font::isSVGFont() const
     820{
     821    return primaryFont()->isSVGFont();
     822}
     823#endif
     824
    817825FontSelector* Font::fontSelector() const
    818826{
  • trunk/WebCore/platform/graphics/Font.h

    r31310 r31342  
    4949class RenderObject;
    5050class SimpleFontData;
     51class SVGFontElement;
    5152class SVGPaintServer;
    5253
     
    171172    int width(const TextRun&) const;
    172173    float floatWidth(const TextRun&) const;
    173     float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed) const;
     174    float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const;
    174175
    175176    int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const;
     
    236237    void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
    237238    float floatWidthUsingSVGFont(const TextRun&) const;
    238     float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed) const;
     239    float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const;
    239240    FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const;
    240241    int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const;
     
    270271    static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0; }
    271272    static bool treatAsZeroWidthSpace(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == 0x200e || c == 0x200f || c >= 0x202a && c <= 0x202e; }
     273
     274#if ENABLE(SVG_FONTS)
     275    bool isSVGFont() const;
     276    SVGFontElement* svgFont() const;
     277#endif
     278
    272279private:
    273280    FontDescription m_fontDescription;
  • trunk/WebCore/rendering/SVGInlineTextBox.cpp

    r31310 r31342  
    7575}
    7676
    77 float SVGInlineTextBox::calculateGlyphWidth(RenderStyle* style, int offset, int extraCharsAvailable, int& charsConsumed) const
     77float SVGInlineTextBox::calculateGlyphWidth(RenderStyle* style, int offset, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
    7878{
    7979    ASSERT(style);
    80     return style->font().floatWidth(svgTextRunForInlineTextBox(textObject()->text()->characters() + offset, 1, style, this, 0), extraCharsAvailable, charsConsumed);
     80    return style->font().floatWidth(svgTextRunForInlineTextBox(textObject()->text()->characters() + offset, 1, style, this, 0), extraCharsAvailable, charsConsumed, glyphName);
    8181}
    8282
     
    9999    // FIXME: account for multi-character glyphs
    100100    int charsConsumed;
     101    String glyphName;
    101102    if (!m_reversed)
    102         glyphWidth = calculateGlyphWidth(style, offset, 0, charsConsumed);
     103        glyphWidth = calculateGlyphWidth(style, offset, 0, charsConsumed, glyphName);
    103104    else
    104         glyphWidth = calculateGlyphWidth(style, start() + end() - offset, 0, charsConsumed);
     105        glyphWidth = calculateGlyphWidth(style, start() + end() - offset, 0, charsConsumed, glyphName);
    105106
    106107    float x1 = svgChar.x;
  • trunk/WebCore/rendering/SVGInlineTextBox.h

    r31310 r31342  
    5959
    6060        // Helper functions shared with SVGRootInlineBox     
    61         float calculateGlyphWidth(RenderStyle* style, int offset, int extraCharsAvailable, int& charsConsumed) const;
     61        float calculateGlyphWidth(RenderStyle* style, int offset, int extraCharsAvailable, int& charsConsumed, String& glyphName) const;
    6262        float calculateGlyphHeight(RenderStyle*, int offset, int extraCharsAvailable) const;
    6363
  • trunk/WebCore/rendering/SVGRootInlineBox.cpp

    r31310 r31342  
    3434#include "SVGInlineFlowBox.h"
    3535#include "SVGInlineTextBox.h"
     36#include "SVGFontElement.h"
    3637#include "SVGPaintServer.h"
    3738#include "SVGRenderStyleDefs.h"
     
    713714                // FIXME: does this need to change to handle multichar glyphs?
    714715                int charsConsumed = 1;
     716                String glyphName;
    715717                if (calcWidthOnly) {
    716                     float lastGlyphWidth = box->calculateGlyphWidth(style, offset, 0, charsConsumed);
     718                    float lastGlyphWidth = box->calculateGlyphWidth(style, offset, 0, charsConsumed, glyphName);
    717719                    length += currentCharacter.x - lastCharacter.x - lastGlyphWidth;
    718720                } else {
     
    905907    }
    906908
     909    LastGlyphInfo lastGlyph;
     910   
    907911    for (InlineBox* curr = start->firstChild(); curr; curr = curr->nextOnLine()) {
    908912        if (curr->object()->isText())
    909             buildLayoutInformationForTextBox(info, static_cast<InlineTextBox*>(curr));
     913            buildLayoutInformationForTextBox(info, static_cast<InlineTextBox*>(curr), lastGlyph);
    910914        else {
    911915            ASSERT(curr->isInlineFlowBox());
     
    10971101}
    10981102
    1099 void SVGRootInlineBox::buildLayoutInformationForTextBox(SVGCharacterLayoutInfo& info, InlineTextBox* textBox)
     1103void SVGRootInlineBox::buildLayoutInformationForTextBox(SVGCharacterLayoutInfo& info, InlineTextBox* textBox, LastGlyphInfo& lastGlyph)
    11001104{
    11011105    RenderText* text = textBox->textObject();
     
    11251129        int extraCharsAvailable = length - i - 1;
    11261130
     1131        String unicodeStr;
     1132        String glyphName;
    11271133        if (textBox->m_reversed) {
    1128             glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->end() - i, extraCharsAvailable, charsConsumed);
     1134            glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->end() - i, extraCharsAvailable, charsConsumed, glyphName);
    11291135            glyphHeight = svgTextBox->calculateGlyphHeight(style, textBox->end() - i, extraCharsAvailable);
     1136            unicodeStr = String(textBox->textObject()->text()->characters() + textBox->end() - i, charsConsumed);
    11301137        } else {
    1131             glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->start() + i, extraCharsAvailable, charsConsumed);
     1138            glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->start() + i, extraCharsAvailable, charsConsumed, glyphName);
    11321139            glyphHeight = svgTextBox->calculateGlyphHeight(style, textBox->start() + i, extraCharsAvailable);
     1140            unicodeStr = String(textBox->textObject()->text()->characters() + textBox->start() + i, charsConsumed);
    11331141        }
    11341142
     
    12981306        }
    12991307
     1308        SVGFontElement* svgFont;
     1309        if (style->font().isSVGFont())
     1310            svgFont = style->font().svgFont();
     1311
     1312        double kerning = 0.0;
     1313        if (lastGlyph.isValid && style->font().isSVGFont()) {
     1314            SVGHorizontalKerningPair kerningPair;
     1315            if (svgFont->getHorizontalKerningPairForStringsAndGlyphs(lastGlyph.unicode, lastGlyph.glyphName, unicodeStr, glyphName, kerningPair))
     1316                kerning = kerningPair.kerning;
     1317        }
     1318
     1319        if (style->font().isSVGFont()) {
     1320            lastGlyph.unicode = unicodeStr;
     1321            lastGlyph.glyphName = glyphName;
     1322            lastGlyph.isValid = true;
     1323        } else {
     1324            lastGlyph.isValid = false;
     1325        }
     1326       
     1327        svgChar.x -= (float)kerning;
     1328
    13001329        // Advance to new position
    13011330        if (isVerticalText) {
     
    13031332            info.cury += glyphAdvance + spacing;
    13041333        } else
    1305             info.curx += glyphAdvance + spacing;
     1334            info.curx += glyphAdvance + spacing - (float)kerning;
    13061335
    13071336        // Advance to next character group
  • trunk/WebCore/rendering/SVGRootInlineBox.h

    r29663 r31342  
    3636class SVGInlineTextBox;
    3737
     38struct LastGlyphInfo {
     39    LastGlyphInfo() : isValid(false) { }
     40
     41    String unicode;
     42    String glyphName;
     43    bool isValid;
     44};
     45
    3846class SVGRootInlineBox : public RootInlineBox {
    3947public:
     
    6472
    6573    void buildLayoutInformation(InlineFlowBox* start, SVGCharacterLayoutInfo&);
    66     void buildLayoutInformationForTextBox(SVGCharacterLayoutInfo&, InlineTextBox*);
     74    void buildLayoutInformationForTextBox(SVGCharacterLayoutInfo&, InlineTextBox*, LastGlyphInfo&);
    6775
    6876    void buildTextChunks(Vector<SVGChar>&, Vector<SVGTextChunk>&, InlineFlowBox* start);
  • trunk/WebCore/svg/SVGFont.cpp

    r31338 r31342  
    291291                    i += identifier.nameLength - 1;
    292292                    m_walkerData.charsConsumed += identifier.nameLength;
    293                    
     293                    m_walkerData.glyphName = identifier.glyphName;
     294
    294295                    foundGlyph = true;
    295296                    SVGGlyphElement::inheritUnspecifiedAttributes(identifier, m_fontData);
     
    337338    int extraCharsAvailable;
    338339    int charsConsumed;
     340    String glyphName;
    339341
    340342    float scale;
     
    363365}
    364366
    365 static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int extraCharsAvailable, int from, int to, int& charsConsumed)
     367
     368SVGFontElement* Font::svgFont() const
     369{
     370    if (!isSVGFont())
     371        return 0;
     372
     373    SVGFontElement* fontElement = 0;
     374    SVGFontFaceElement* fontFaceElement = 0;
     375    if (svgFontAndFontFaceElementForFontData(primaryFont(), fontFaceElement, fontElement))
     376        return fontElement;
     377   
     378    return 0;
     379}
     380
     381static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int extraCharsAvailable, int from, int to, int& charsConsumed, String& glyphName)
    366382{
    367383    int newFrom = to > from ? from : to;
     
    403419        runWalker.walk(run, isVerticalText, language, 0, run.length());
    404420        charsConsumed = data.charsConsumed;
     421        glyphName = data.glyphName;
    405422        return data.length;
    406423    }
     
    412429{
    413430    int charsConsumed;
    414     return floatWidthOfSubStringUsingSVGFont(this, run, 0, 0, run.length(), charsConsumed);
    415 }
    416 
    417 float Font::floatWidthUsingSVGFont(const TextRun& run, int extraCharsAvailable, int& charsConsumed) const
    418 {
    419     return floatWidthOfSubStringUsingSVGFont(this, run, extraCharsAvailable, 0, run.length(), charsConsumed);
     431    String glyphName;
     432    return floatWidthOfSubStringUsingSVGFont(this, run, 0, 0, run.length(), charsConsumed, glyphName);
     433}
     434
     435float Font::floatWidthUsingSVGFont(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const
     436{
     437    return floatWidthOfSubStringUsingSVGFont(this, run, extraCharsAvailable, 0, run.length(), charsConsumed, glyphName);
    420438}
    421439
     
    426444    int extraCharsAvailable;
    427445    int charsConsumed;
     446    String glyphName;
    428447
    429448    float xStartOffset;
     
    525544
    526545        int charsConsumed;
     546        String glyphName;
    527547        data.isVerticalText = false;
    528         data.xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed);
     548        data.xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName);
    529549        data.glyphOrigin = FloatPoint();
    530550        data.context = context;
     
    555575{
    556576    int charsConsumed;
    557     return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed),
    558                      point.y(), floatWidthOfSubStringUsingSVGFont(this, run, 0, from, to, charsConsumed), height);
     577    String glyphName;
     578
     579    return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed, glyphName),
     580                     point.y(), floatWidthOfSubStringUsingSVGFont(this, run, 0, from, to, charsConsumed, glyphName), height);
    559581}
    560582
  • trunk/WebCore/svg/SVGFontElement.cpp

    r31324 r31342  
    3030#include "SVGNames.h"
    3131#include "SVGParserUtilities.h"
     32#include <wtf/ASCIICType.h>
     33
     34using namespace WTF;
    3235
    3336namespace WebCore {
     
    4548}
    4649
    47 void SVGFontElement::addGlyphToCache(SVGGlyphElement* glyphElement)
    48 {
    49     if (m_isGlyphCacheValid)
     50void SVGFontElement::invalidateGlyphCache()
     51{
     52    if (m_isGlyphCacheValid) {
    5053        m_glyphMap.clear();
    51     m_isGlyphCacheValid = false;
    52 }
    53 
    54 void SVGFontElement::removeGlyphFromCache(SVGGlyphElement* glyphElement)
    55 {
    56     if (m_isGlyphCacheValid)
    57         m_glyphMap.clear();
     54        m_kerningPairs.clear();
     55    }
    5856    m_isGlyphCacheValid = false;
    5957}
     
    8078            if (unicode.length())
    8179                m_glyphMap.add(unicode, glyph->buildGlyphIdentifier());
     80        } else if (child->hasTagName(hkernTag)) {
     81            SVGHKernElement* hkern = static_cast<SVGHKernElement*>(child);
     82            SVGHorizontalKerningPair kerningPair = hkern->buildHorizontalKerningPair();
     83            m_kerningPairs.append(kerningPair);
    8284        }
    8385    }
    8486       
    8587    m_isGlyphCacheValid = true;
     88}
     89   
     90// Returns the number of characters consumed or 0 if no range was found.
     91static unsigned parseUnicodeRange(const UChar* characters, unsigned length, pair<unsigned, unsigned>& range)
     92{
     93    if (length < 2)
     94        return 0;
     95    if (characters[0] != 'U')
     96        return 0;
     97    if (characters[1] != '+')
     98        return 0;
     99   
     100    // Parse the starting hex number (or its prefix).
     101    unsigned start = 0;
     102    unsigned startLength = 0;
     103    for (unsigned i = 2; i < length; ++i) {
     104        if (!isASCIIHexDigit(characters[i]))
     105            break;
     106        if (++startLength > 6)
     107            return 0;
     108        start = (start << 4) | toASCIIHexValue(characters[i]);
     109    }
     110   
     111    // Handle the case of ranges separated by "-" sign.
     112    if (2 + startLength < length && characters[2 + startLength] == '-') {
     113        if (!startLength)
     114            return 0;
     115       
     116        // Parse the ending hex number (or its prefix).
     117        unsigned end = 0;
     118        unsigned endLength = 0;
     119        for (unsigned i = 2 + startLength + 1; i < length; ++i) {
     120            if (!isASCIIHexDigit(characters[i]))
     121                break;
     122            if (++endLength > 6)
     123                return 0;
     124            end = (end << 4) | toASCIIHexValue(characters[i]);
     125        }
     126       
     127        if (!endLength)
     128            return 0;
     129       
     130        range.first = start;
     131        range.second = end;
     132        return 2 + startLength + 1 + endLength;
     133    }
     134   
     135    // Handle the case of a number with some optional trailing question marks.
     136    unsigned end = start;
     137    for (unsigned i = 2 + startLength; i < length; ++i) {
     138        if (characters[i] != '?')
     139            break;
     140        if (++startLength > 6)
     141            return 0;
     142        start <<= 4;
     143        end = (end << 4) | 0xF;
     144    }
     145   
     146    if (!startLength)
     147        return 0;
     148   
     149    range.first = start;
     150    range.second = end;
     151    return 2 + startLength;
     152}
     153   
     154static bool parseUnicodeRangeList(const UChar* characters, unsigned length, Vector<pair<unsigned, unsigned> >& ranges)
     155{
     156    ranges.clear();
     157    if (!length)
     158        return true;
     159   
     160    const UChar* remainingCharacters = characters;
     161    unsigned remainingLength = length;
     162   
     163    while (1) {
     164        pair<unsigned, unsigned> range;
     165        unsigned charactersConsumed = parseUnicodeRange(remainingCharacters, remainingLength, range);
     166        if (charactersConsumed) {
     167            ranges.append(range);
     168            remainingCharacters += charactersConsumed;
     169            remainingLength -= charactersConsumed;
     170        } else {
     171            if (!remainingLength)
     172                return false;
     173            UChar character = remainingCharacters[0];
     174            if (character == ',')
     175                return false;
     176            ranges.append(make_pair(character, character));
     177            ++remainingCharacters;
     178            --remainingLength;
     179        }
     180        if (!remainingLength)
     181            return true;
     182        if (remainingCharacters[0] != ',')
     183            return false;
     184        ++remainingCharacters;
     185        --remainingLength;
     186    }
     187}
     188
     189static bool stringMatchesUnicodeRange(const String& unicodeString, const String& unicodeRangeSpec)
     190{
     191    Vector<pair<unsigned, unsigned> > ranges;
     192    if (!parseUnicodeRangeList(unicodeRangeSpec.characters(), unicodeRangeSpec.length(), ranges))
     193        return false;
     194   
     195    if (unicodeString.length() != ranges.size())
     196        return false;
     197   
     198    for (size_t i = 0; i < unicodeString.length(); ++i) {
     199        UChar c = unicodeString[i];
     200        if (c < ranges[i].first || c > ranges[i].second)
     201            return false;
     202    }
     203   
     204    return true;
     205}
     206   
     207static bool matches(const String& u1, const String& g1, const String& u2, const String& g2, const SVGHorizontalKerningPair& kerningPair)
     208{
     209    if (kerningPair.unicode1.length() && !stringMatchesUnicodeRange(u1, kerningPair.unicode1))
     210        return false;
     211    if (kerningPair.glyphName1.length() && kerningPair.glyphName1 != g1)
     212        return false;
     213   
     214    if (kerningPair.unicode2.length() && !stringMatchesUnicodeRange(u2, kerningPair.unicode2))
     215        return false;
     216    if (kerningPair.glyphName2.length() && kerningPair.glyphName2 != g2)
     217        return false;
     218   
     219    return true;
     220}
     221   
     222bool SVGFontElement::getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2, SVGHorizontalKerningPair& kerningPair) const
     223{
     224    for (size_t i = 0; i < m_kerningPairs.size(); ++i) {
     225        if (matches(u1, g1, u2, g2, m_kerningPairs[i])) {
     226            kerningPair = m_kerningPairs[i];
     227            return true;
     228        }       
     229    }
     230   
     231    return false;
    86232}
    87233
  • trunk/WebCore/svg/SVGFontElement.h

    r31324 r31342  
    2626#include "SVGGlyphElement.h"
    2727#include "SVGGlyphMap.h"
     28#include "SVGHKernElement.h"
    2829#include "SVGStyledElement.h"
    2930
     
    4041        virtual const SVGElement* contextElement() const { return this; }
    4142
    42         void addGlyphToCache(SVGGlyphElement*);
    43         void removeGlyphFromCache(SVGGlyphElement*);
     43        void invalidateGlyphCache();
    4444
    4545        void getGlyphIdentifiersForString(const String&, Vector<SVGGlyphIdentifier>&) const;
     46
     47        bool getHorizontalKerningPairForStringsAndGlyphs(const String& u1, const String& g1, const String& u2, const String& g2, SVGHorizontalKerningPair& kerningPair) const;
    4648
    4749        SVGMissingGlyphElement* firstMissingGlyphElement() const;
     
    5052        void ensureGlyphCache() const;
    5153
     54        typedef Vector<SVGHorizontalKerningPair> KerningPairVector;
     55
     56        mutable KerningPairVector m_kerningPairs;
    5257        mutable SVGGlyphMap m_glyphMap;
    5358        mutable bool m_isGlyphCacheValid;
  • trunk/WebCore/svg/SVGGlyphElement.cpp

    r31338 r31342  
    5050    if (fontNode && fontNode->hasTagName(fontTag)) {
    5151        if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
    52             element->addGlyphToCache(this);
     52            element->invalidateGlyphCache();
    5353    }
    5454    SVGStyledElement::insertedIntoDocument();
     
    6060    if (fontNode && fontNode->hasTagName(fontTag)) {
    6161        if (SVGFontElement* element = static_cast<SVGFontElement*>(fontNode))
    62             element->removeGlyphFromCache(this);
     62            element->invalidateGlyphCache();
    6363    }
    6464    SVGStyledElement::removedFromDocument();
  • trunk/WebCore/svg/SVGTextContentElement.cpp

    r31310 r31342  
    8282            // FIXME: does this handle multichar glyphs ok? not sure
    8383            int charsConsumed = 0;
     84            String glyphName;
    8485            if (isVerticalText)
    8586                textLength += textBox->calculateGlyphHeight(style, newOffset, 0);
    8687            else
    87                 textLength += textBox->calculateGlyphWidth(style, newOffset, 0, charsConsumed);
     88                textLength += textBox->calculateGlyphWidth(style, newOffset, 0, charsConsumed, glyphName);
    8889        }
    8990
     
    197198
    198199                    int charsConsumed;
     200                    String glyphName;
    199201                    if (isVerticalText)
    200202                        m_queryPointResult.move(it->x, it->y + textBox->calculateGlyphHeight(style, newOffset, end - it));
    201203                    else
    202                         m_queryPointResult.move(it->x + textBox->calculateGlyphWidth(style, newOffset, end - it, charsConsumed), it->y);
     204                        m_queryPointResult.move(it->x + textBox->calculateGlyphWidth(style, newOffset, end - it, charsConsumed, glyphName), it->y);
    203205
    204206                    m_stopProcessing = true;
  • trunk/WebCore/svg/svgtags.in

    r31337 r31342  
    7171#if 0
    7272glyphRef
     73#endif
    7374hkern
    74 #endif
    7575image
    7676line
Note: See TracChangeset for help on using the changeset viewer.