Changeset 31310 in webkit


Ignore:
Timestamp:
Mar 26, 2008, 3:10:08 AM (17 years ago)
Author:
mjs@apple.com
Message:

WebCore:

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

Reviewed by Maciej.

  • platform/graphics/Font.cpp: (WebCore::Font::floatWidth): Allow expressing a run that has extra "context" characters beyond the end, and reporting of how many characters were actually consumed, to support multichar glyphs in SVG fonts.
  • platform/graphics/Font.h:
  • rendering/SVGInlineTextBox.cpp: (WebCore::SVGInlineTextBox::calculateGlyphWidth): Pass along extra chars in argument and chars consumed out argument. (WebCore::SVGInlineTextBox::calculateGlyphHeight): Pass along extra chars in argument. (WebCore::SVGInlineTextBox::calculateGlyphBoundaries): Add boilerplate; may not handle multichar glyphs right but I don't know what effects this would have.
  • rendering/SVGInlineTextBox.h:
  • rendering/SVGRootInlineBox.cpp: (WebCore::cummulatedWidthOrHeightOfTextChunk): Add boilerplate; may not handle multichar glyphs right but again I am not sure what effect this would have. (WebCore::SVGRootInlineBox::buildLayoutInformationForTextBox): Account for multichar glyphs - let glyph selection consider extra chars, and account for the fact that a glyph may have consumed multiple chars.
  • rendering/SVGRootInlineBox.h:
  • svg/SVGFont.cpp: (WebCore::SVGTextRunWalker::walk): This is the place where glyph selection happens, so this is where we accout for multichar glyphs (both looking at extra chars past the end of the run, and reporting how many chars were consumed). (WebCore::floatWidthOfSubStringUsingSVGFont): Pass aforementioned info through the layers. (WebCore::Font::floatWidthUsingSVGFont): ditto (WebCore::Font::drawTextUsingSVGFont): ditto (WebCore::Font::selectionRectForTextUsingSVGFont): ditto
  • svg/SVGTextContentElement.cpp: (WebCore::cummulatedCharacterRangeLength): ditto (WebCore::SVGInlineTextBoxQueryWalker::chunkPortionCallback): ditto

LayoutTests:

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

Reviewed by Maciej.

  • svg/text/multichar-glyph.svg: Added. New test case for both rendering and getStartPositionOfChar access of multichar glyphs.
  • platform/mac/svg/text/multichar-glyph-expected.txt: Added.

The following test results changed, all appear to be improvements.


  • platform/mac/svg/W3C-SVG-1.1/fonts-glyph-04-t-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/text-altglyph-01-b-expected.txt:
  • platform/mac/svg/W3C-SVG-1.1/text-text-06-t-expected.txt:
  • platform/mac/svg/text/text-altglyph-01-b-expected.txt:
  • platform/mac/svg/text/text-text-06-t-expected.txt:
Location:
trunk
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r31309 r31310  
     12008-03-24  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        - test case and new results for "SVGTextElement.getStartPositionOfChar does not correctly account for multichar glyphs"
     6        http://bugs.webkit.org/show_bug.cgi?id=18046
     7
     8        * svg/text/multichar-glyph.svg: Added. New test case for both rendering and getStartPositionOfChar
     9        access of multichar glyphs.
     10        * platform/mac/svg/text/multichar-glyph-expected.txt: Added.
     11
     12        The following test results changed, all appear to be improvements.
     13       
     14        * platform/mac/svg/W3C-SVG-1.1/fonts-glyph-04-t-expected.txt:
     15        * platform/mac/svg/W3C-SVG-1.1/text-altglyph-01-b-expected.txt:
     16        * platform/mac/svg/W3C-SVG-1.1/text-text-06-t-expected.txt:
     17        * platform/mac/svg/text/text-altglyph-01-b-expected.txt:
     18        * platform/mac/svg/text/text-text-06-t-expected.txt:
     19
    1202008-03-25  Beth Dakin  <bdakin@apple.com>
    221
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/fonts-glyph-04-t-expected.txt

    r30635 r31310  
    33layer at (0,0) size 480x360
    44  RenderSVGRoot {svg} at (0.50,0.50) size 479x359
    5     RenderSVGContainer {g} at (100,60) size 64x150
     5    RenderSVGContainer {g} at (100,60) size 25x150
    66      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    7       RenderSVGText {text} at (100,100) size 64x50 contains 1 chunk(s)
    8         RenderSVGInlineText {#text} at (0,-40) size 64x50
     7      RenderSVGText {text} at (100,100) size 25x50 contains 1 chunk(s)
     8        RenderSVGInlineText {#text} at (0,-40) size 25x50
    99          chunk 1 text run 1 at (100.00,100.00) startOffset 0 endOffset 3 width 25.00: "ffl"
    10       RenderSVGText {text} at (100,200) size 64x50 contains 1 chunk(s)
    11         RenderSVGInlineText {#text} at (0,-40) size 64x50
     10      RenderSVGText {text} at (100,200) size 25x50 contains 1 chunk(s)
     11        RenderSVGInlineText {#text} at (0,-40) size 25x50
    1212          chunk 1 text run 1 at (100.00,200.00) startOffset 0 endOffset 3 width 25.00: "ffl"
    1313    RenderSVGText {text} at (10,340) size 284x46 contains 1 chunk(s)
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-altglyph-01-b-expected.txt

    r31240 r31310  
    33layer at (0,0) size 480x360
    44  RenderSVGRoot {svg} at (0.50,0.50) size 479x359
    5     RenderSVGContainer {g} at (5,14) size 463.67x271.67
     5    RenderSVGContainer {g} at (5,14) size 463x271.67
    66      RenderSVGText {text} at (5,50) size 403x44 contains 1 chunk(s)
    77        RenderSVGInlineText {#text} at (0,-36) size 403x44
     
    1111          chunk 1 text run 1 at (5.00,90.00) startOffset 0 endOffset 32 width 463.00: "and many-to-many chars to glyphs"
    1212      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    13       RenderSVGContainer {g} at (49.33,137.33) size 419.33x148.33
     13      RenderSVGContainer {g} at (49.33,137.33) size 389.33x148.33
    1414        RenderSVGText {text} at (140,190) size 188x67 contains 1 chunk(s)
    1515          RenderSVGTSpan {altGlyph} at (0,0) size 38x67
     
    4242          RenderSVGInlineText {#text} at (75,-52) size 38x67
    4343            chunk 1 text run 3 at (125.00,270.00) startOffset 0 endOffset 1 width 37.50: "D"
    44         RenderSVGText {text} at (280,270) size 188x67 contains 1 chunk(s)
    45           RenderSVGInlineText {#text} at (0,-52) size 188x67
     44        RenderSVGText {text} at (280,270) size 158x67 contains 1 chunk(s)
     45          RenderSVGInlineText {#text} at (0,-52) size 158x67
    4646            chunk 1 text run 1 at (280.00,270.00) startOffset 0 endOffset 5 width 157.50: "SASSY"
    4747    RenderSVGText {text} at (10,340) size 264x46 contains 1 chunk(s)
  • trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-06-t-expected.txt

    r30635 r31310  
    33layer at (0,0) size 480x360
    44  RenderSVGRoot {svg} at (0.50,0.50) size 479x359
    5     RenderSVGContainer {g} at (30,55) size 278x209
     5    RenderSVGContainer {g} at (30,55) size 274x209
    66      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    77      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
     
    99          RenderPath {line} at (-0.50,-15) size 1x15 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00L0.00,-15.00"]
    1010          RenderPath {rect} at (-4,-4) size 8x8 [fill={[type=SOLID] [color=#000000]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    11       RenderSVGContainer {g} at (30,55) size 278x209 [transform={m=((1.00,0.00)(0.00,1.00)) t=(20.00,30.00)}]
     11      RenderSVGContainer {g} at (30,55) size 274x209 [transform={m=((1.00,0.00)(0.00,1.00)) t=(20.00,30.00)}]
    1212        RenderSVGContainer {g} at (30,59) size 71x154 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,40.00)}]
    1313          RenderSVGText {text} at (0,0) size 62x14 contains 1 chunk(s)
     
    2020            RenderSVGInlineText {#text} at (0,-11) size 71x14
    2121              chunk 1 text run 1 at (0.00,140.00) startOffset 0 endOffset 15 width 71.00: "x/y positioning"
    22         RenderSVGContainer {g} at (126,55) size 182x19 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,40.00)}]
     22        RenderSVGContainer {g} at (126,55) size 178x19 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,40.00)}]
    2323          RenderSVGContainer {use} at (126,55) size 8x19
    2424            RenderSVGContainer {g} at (126,55) size 8x19 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,0.00)}]
     
    5151                RenderPath {line} at (249.50,55) size 1x15 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L0.00,-15.00"]
    5252                RenderPath {rect} at (246,66) size 8x8 [fill={[type=SOLID] [color=#8888FF]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    53           RenderSVGText {text} at (10,0) size 178x10 contains 6 chunk(s)
    54             RenderSVGInlineText {#text} at (0,-8) size 178x10
    55               chunk 1 text run 1 at (10.00,0.00) startOffset 0 endOffset 1 width 8.00: "f"
    56               chunk 2 text run 1 at (180.00,0.00) startOffset 1 endOffset 2 width 8.00: "i"
    57               chunk 3 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
    58               chunk 4 text run 1 at (70.00,0.00) startOffset 3 endOffset 4 width 15.00: "2"
    59               chunk 5 text run 1 at (100.00,0.00) startOffset 4 endOffset 5 width 15.00: "3"
    60               chunk 6 text run 1 at (130.00,0.00) startOffset 5 endOffset 6 width 15.00: "4"
    61         RenderSVGContainer {g} at (116,85) size 80x79 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,80.00)}]
     53          RenderSVGText {text} at (10,0) size 135x10 contains 5 chunk(s)
     54            RenderSVGInlineText {#text} at (0,-8) size 135x10
     55              chunk 1 text run 1 at (10.00,0.00) startOffset 0 endOffset 2 width 15.00: "fi"
     56              chunk 2 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
     57              chunk 3 text run 1 at (70.00,0.00) startOffset 3 endOffset 4 width 15.00: "2"
     58              chunk 4 text run 1 at (100.00,0.00) startOffset 4 endOffset 5 width 15.00: "3"
     59              chunk 5 text run 1 at (130.00,0.00) startOffset 5 endOffset 6 width 15.00: "4"
     60        RenderSVGContainer {g} at (116,85) size 79x79 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,80.00)}]
    6261          RenderSVGContainer {use} at (116,85) size 8x19
    6362            RenderSVGContainer {g} at (116,85) size 8x19 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,-10.00)}]
     
    9089                RenderPath {line} at (179.50,125) size 1x15 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L0.00,-15.00"]
    9190                RenderPath {rect} at (176,136) size 8x8 [fill={[type=SOLID] [color=#8888FF]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    92           RenderSVGText {text} at (0,-10) size 76x70 contains 1 chunk(s)
    93             RenderSVGInlineText {#text} at (0,-8) size 76x70
     91          RenderSVGText {text} at (0,-10) size 75x50 contains 1 chunk(s)
     92            RenderSVGInlineText {#text} at (0,-8) size 75x50
    9493              chunk 1 text run 1 at (0.00,-10.00) startOffset 0 endOffset 6 width 75.00: "fi1234"
    95         RenderSVGContainer {g} at (126,185) size 182x79 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,180.00)}]
     94        RenderSVGContainer {g} at (126,185) size 178x79 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,180.00)}]
    9695          RenderSVGContainer {use} at (126,185) size 8x19
    9796            RenderSVGContainer {g} at (126,185) size 8x19 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,-10.00)}]
     
    124123                RenderPath {line} at (249.50,225) size 1x15 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L0.00,-15.00"]
    125124                RenderPath {rect} at (246,236) size 8x8 [fill={[type=SOLID] [color=#8888FF]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    126           RenderSVGText {text} at (10,-10) size 178x70 contains 6 chunk(s)
    127             RenderSVGInlineText {#text} at (0,-8) size 178x70
    128               chunk 1 text run 1 at (10.00,-10.00) startOffset 0 endOffset 1 width 8.00: "f"
    129               chunk 2 text run 1 at (180.00,50.00) startOffset 1 endOffset 2 width 8.00: "i"
    130               chunk 3 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
    131               chunk 4 text run 1 at (70.00,10.00) startOffset 3 endOffset 4 width 15.00: "2"
    132               chunk 5 text run 1 at (100.00,20.00) startOffset 4 endOffset 5 width 15.00: "3"
    133               chunk 6 text run 1 at (130.00,30.00) startOffset 5 endOffset 6 width 15.00: "4"
     125          RenderSVGText {text} at (10,-10) size 135x50 contains 5 chunk(s)
     126            RenderSVGInlineText {#text} at (0,-8) size 135x50
     127              chunk 1 text run 1 at (10.00,-10.00) startOffset 0 endOffset 2 width 15.00: "fi"
     128              chunk 2 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
     129              chunk 3 text run 1 at (70.00,10.00) startOffset 3 endOffset 4 width 15.00: "2"
     130              chunk 4 text run 1 at (100.00,20.00) startOffset 4 endOffset 5 width 15.00: "3"
     131              chunk 5 text run 1 at (130.00,30.00) startOffset 5 endOffset 6 width 15.00: "4"
    134132    RenderSVGText {text} at (10,340) size 264x46 contains 1 chunk(s)
    135133      RenderSVGInlineText {#text} at (0,-36) size 264x46
  • trunk/LayoutTests/platform/mac/svg/text/text-altglyph-01-b-expected.txt

    r31240 r31310  
    33layer at (0,0) size 800x600
    44  RenderSVGRoot {svg} at (0.83,0.83) size 798.33x598.33
    5     RenderSVGContainer {g} at (8.33,23.33) size 772.78x452.78
     5    RenderSVGContainer {g} at (8.33,23.33) size 771.67x452.78
    66      RenderSVGText {text} at (5,50) size 403x44 contains 1 chunk(s)
    77        RenderSVGInlineText {#text} at (0,-36) size 403x44
     
    1111          chunk 1 text run 1 at (5.00,90.00) startOffset 0 endOffset 32 width 463.00: "and many-to-many chars to glyphs"
    1212      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    13       RenderSVGContainer {g} at (82.22,228.89) size 698.89x247.22
     13      RenderSVGContainer {g} at (82.22,228.89) size 648.89x247.22
    1414        RenderSVGText {text} at (140,190) size 188x67 contains 1 chunk(s)
    1515          RenderSVGTSpan {altGlyph} at (0,0) size 38x67
     
    4242          RenderSVGInlineText {#text} at (75,-52) size 38x67
    4343            chunk 1 text run 3 at (125.00,270.00) startOffset 0 endOffset 1 width 37.50: "D"
    44         RenderSVGText {text} at (280,270) size 188x67 contains 1 chunk(s)
    45           RenderSVGInlineText {#text} at (0,-52) size 188x67
     44        RenderSVGText {text} at (280,270) size 158x67 contains 1 chunk(s)
     45          RenderSVGInlineText {#text} at (0,-52) size 158x67
    4646            chunk 1 text run 1 at (280.00,270.00) startOffset 0 endOffset 5 width 157.50: "SASSY"
    4747    RenderSVGText {text} at (10,340) size 264x46 contains 1 chunk(s)
  • trunk/LayoutTests/platform/mac/svg/text/text-text-06-t-expected.txt

    r30635 r31310  
    33layer at (0,0) size 800x600
    44  RenderSVGRoot {svg} at (0.83,0.83) size 798.33x598.33
    5     RenderSVGContainer {g} at (50,91.67) size 463.33x348.33
     5    RenderSVGContainer {g} at (50,91.67) size 456.67x348.33
    66      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
    77      RenderSVGHiddenContainer {defs} at (0,0) size 0x0
     
    99          RenderPath {line} at (-0.50,-15) size 1x15 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#000000]}] [data="M0.00,0.00L0.00,-15.00"]
    1010          RenderPath {rect} at (-4,-4) size 8x8 [fill={[type=SOLID] [color=#000000]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    11       RenderSVGContainer {g} at (50,91.67) size 463.33x348.33 [transform={m=((1.00,0.00)(0.00,1.00)) t=(20.00,30.00)}]
     11      RenderSVGContainer {g} at (50,91.67) size 456.67x348.33 [transform={m=((1.00,0.00)(0.00,1.00)) t=(20.00,30.00)}]
    1212        RenderSVGContainer {g} at (50,98.33) size 118.33x256.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,40.00)}]
    1313          RenderSVGText {text} at (0,0) size 62x14 contains 1 chunk(s)
     
    2020            RenderSVGInlineText {#text} at (0,-11) size 71x14
    2121              chunk 1 text run 1 at (0.00,140.00) startOffset 0 endOffset 15 width 71.00: "x/y positioning"
    22         RenderSVGContainer {g} at (210,91.67) size 303.33x31.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,40.00)}]
     22        RenderSVGContainer {g} at (210,91.67) size 296.67x31.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,40.00)}]
    2323          RenderSVGContainer {use} at (210,91.67) size 13.33x31.67
    2424            RenderSVGContainer {g} at (210,91.67) size 13.33x31.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,0.00)}]
     
    5151                RenderPath {line} at (415.83,91.67) size 1.67x25 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L0.00,-15.00"]
    5252                RenderPath {rect} at (410,110) size 13.33x13.33 [fill={[type=SOLID] [color=#8888FF]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    53           RenderSVGText {text} at (10,0) size 178x10 contains 6 chunk(s)
    54             RenderSVGInlineText {#text} at (0,-8) size 178x10
    55               chunk 1 text run 1 at (10.00,0.00) startOffset 0 endOffset 1 width 8.00: "f"
    56               chunk 2 text run 1 at (180.00,0.00) startOffset 1 endOffset 2 width 8.00: "i"
    57               chunk 3 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
    58               chunk 4 text run 1 at (70.00,0.00) startOffset 3 endOffset 4 width 15.00: "2"
    59               chunk 5 text run 1 at (100.00,0.00) startOffset 4 endOffset 5 width 15.00: "3"
    60               chunk 6 text run 1 at (130.00,0.00) startOffset 5 endOffset 6 width 15.00: "4"
    61         RenderSVGContainer {g} at (193.33,141.67) size 133.33x131.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,80.00)}]
     53          RenderSVGText {text} at (10,0) size 135x10 contains 5 chunk(s)
     54            RenderSVGInlineText {#text} at (0,-8) size 135x10
     55              chunk 1 text run 1 at (10.00,0.00) startOffset 0 endOffset 2 width 15.00: "fi"
     56              chunk 2 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
     57              chunk 3 text run 1 at (70.00,0.00) startOffset 3 endOffset 4 width 15.00: "2"
     58              chunk 4 text run 1 at (100.00,0.00) startOffset 4 endOffset 5 width 15.00: "3"
     59              chunk 5 text run 1 at (130.00,0.00) startOffset 5 endOffset 6 width 15.00: "4"
     60        RenderSVGContainer {g} at (193.33,141.67) size 131.67x131.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,80.00)}]
    6261          RenderSVGContainer {use} at (193.33,141.67) size 13.33x31.67
    6362            RenderSVGContainer {g} at (193.33,141.67) size 13.33x31.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,-10.00)}]
     
    9089                RenderPath {line} at (299.17,208.33) size 1.67x25 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L0.00,-15.00"]
    9190                RenderPath {rect} at (293.33,226.67) size 13.33x13.33 [fill={[type=SOLID] [color=#8888FF]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    92           RenderSVGText {text} at (0,-10) size 76x70 contains 1 chunk(s)
    93             RenderSVGInlineText {#text} at (0,-8) size 76x70
     91          RenderSVGText {text} at (0,-10) size 75x50 contains 1 chunk(s)
     92            RenderSVGInlineText {#text} at (0,-8) size 75x50
    9493              chunk 1 text run 1 at (0.00,-10.00) startOffset 0 endOffset 6 width 75.00: "fi1234"
    95         RenderSVGContainer {g} at (210,308.33) size 303.33x131.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,180.00)}]
     94        RenderSVGContainer {g} at (210,308.33) size 296.67x131.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(100.00,180.00)}]
    9695          RenderSVGContainer {use} at (210,308.33) size 13.33x31.67
    9796            RenderSVGContainer {g} at (210,308.33) size 13.33x31.67 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,-10.00)}]
     
    124123                RenderPath {line} at (415.83,375) size 1.67x25 [stroke={[type=SOLID] [color=#FF0000]}] [fill={[type=SOLID] [color=#8888FF]}] [data="M0.00,0.00L0.00,-15.00"]
    125124                RenderPath {rect} at (410,393.33) size 13.33x13.33 [fill={[type=SOLID] [color=#8888FF]}] [data="M-4.00,-4.00L4.00,-4.00L4.00,4.00L-4.00,4.00"]
    126           RenderSVGText {text} at (10,-10) size 178x70 contains 6 chunk(s)
    127             RenderSVGInlineText {#text} at (0,-8) size 178x70
    128               chunk 1 text run 1 at (10.00,-10.00) startOffset 0 endOffset 1 width 8.00: "f"
    129               chunk 2 text run 1 at (180.00,50.00) startOffset 1 endOffset 2 width 8.00: "i"
    130               chunk 3 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
    131               chunk 4 text run 1 at (70.00,10.00) startOffset 3 endOffset 4 width 15.00: "2"
    132               chunk 5 text run 1 at (100.00,20.00) startOffset 4 endOffset 5 width 15.00: "3"
    133               chunk 6 text run 1 at (130.00,30.00) startOffset 5 endOffset 6 width 15.00: "4"
     125          RenderSVGText {text} at (10,-10) size 135x50 contains 5 chunk(s)
     126            RenderSVGInlineText {#text} at (0,-8) size 135x50
     127              chunk 1 text run 1 at (10.00,-10.00) startOffset 0 endOffset 2 width 15.00: "fi"
     128              chunk 2 text run 1 at (40.00,0.00) startOffset 2 endOffset 3 width 15.00: "1"
     129              chunk 3 text run 1 at (70.00,10.00) startOffset 3 endOffset 4 width 15.00: "2"
     130              chunk 4 text run 1 at (100.00,20.00) startOffset 4 endOffset 5 width 15.00: "3"
     131              chunk 5 text run 1 at (130.00,30.00) startOffset 5 endOffset 6 width 15.00: "4"
    134132    RenderSVGText {text} at (10,340) size 264x46 contains 1 chunk(s)
    135133      RenderSVGInlineText {#text} at (0,-36) size 264x46
  • trunk/WebCore/ChangeLog

    r31309 r31310  
     12008-03-24  Maciej Stachowiak  <mjs@apple.com>
     2
     3        Reviewed by Maciej.
     4
     5        - fixed "SVGTextElement.getStartPositionOfChar does not correctly account for multichar glyphs"
     6        http://bugs.webkit.org/show_bug.cgi?id=18046
     7
     8        * platform/graphics/Font.cpp:
     9        (WebCore::Font::floatWidth): Allow expressing a run that has extra "context" characters beyond the end,
     10        and reporting of how many characters were actually consumed, to support multichar glyphs in SVG fonts.
     11        * platform/graphics/Font.h:
     12        * rendering/SVGInlineTextBox.cpp:
     13        (WebCore::SVGInlineTextBox::calculateGlyphWidth): Pass along extra chars in argument and chars consumed out
     14        argument.
     15        (WebCore::SVGInlineTextBox::calculateGlyphHeight): Pass along extra chars in argument.
     16        (WebCore::SVGInlineTextBox::calculateGlyphBoundaries): Add boilerplate; may not handle multichar glyphs
     17        right but I don't know what effects this would have.
     18        * rendering/SVGInlineTextBox.h:
     19        * rendering/SVGRootInlineBox.cpp:
     20        (WebCore::cummulatedWidthOrHeightOfTextChunk): Add boilerplate; may not handle multichar glyphs right
     21        but again I am not sure what effect this would have.
     22        (WebCore::SVGRootInlineBox::buildLayoutInformationForTextBox): Account for multichar glyphs - let glyph
     23        selection consider extra chars, and account for the fact that a glyph may have consumed multiple chars.
     24        * rendering/SVGRootInlineBox.h:
     25        * svg/SVGFont.cpp:
     26        (WebCore::SVGTextRunWalker::walk): This is the place where glyph selection happens, so this is where
     27        we accout for multichar glyphs (both looking at extra chars past the end of the run, and reporting how
     28        many chars were consumed).
     29        (WebCore::floatWidthOfSubStringUsingSVGFont): Pass aforementioned info through the layers.
     30        (WebCore::Font::floatWidthUsingSVGFont): ditto
     31        (WebCore::Font::drawTextUsingSVGFont): ditto
     32        (WebCore::Font::selectionRectForTextUsingSVGFont): ditto
     33        * svg/SVGTextContentElement.cpp:
     34        (WebCore::cummulatedCharacterRangeLength): ditto
     35        (WebCore::SVGInlineTextBoxQueryWalker::chunkPortionCallback): ditto
     36
    1372008-03-25  Beth Dakin  <bdakin@apple.com>
    238
  • trunk/WebCore/platform/graphics/Font.cpp

    r29857 r31310  
    709709}
    710710
     711float Font::floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed) const
     712{
     713#if ENABLE(SVG_FONTS)
     714    if (primaryFont()->isSVGFont())
     715        return floatWidthUsingSVGFont(run, extraCharsAvailable, charsConsumed);
     716#endif
     717
     718    charsConsumed = run.length();
     719    if (canUseGlyphCache(run))
     720        return floatWidthForSimpleText(run, 0);
     721    return floatWidthForComplexText(run);
     722}
     723
    711724float Font::floatWidthForSimpleText(const TextRun& run, GlyphBuffer* glyphBuffer) const
    712725{
  • trunk/WebCore/platform/graphics/Font.h

    r29857 r31310  
    171171    int width(const TextRun&) const;
    172172    float floatWidth(const TextRun&) const;
     173    float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed) const;
    173174
    174175    int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const;
     
    235236    void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
    236237    float floatWidthUsingSVGFont(const TextRun&) const;
     238    float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed) const;
    237239    FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const;
    238240    int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const;
  • trunk/WebCore/rendering/SVGInlineTextBox.cpp

    r29663 r31310  
    7575}
    7676
    77 float SVGInlineTextBox::calculateGlyphWidth(RenderStyle* style, int offset) const
     77float SVGInlineTextBox::calculateGlyphWidth(RenderStyle* style, int offset, int extraCharsAvailable, int& charsConsumed) const
    7878{
    7979    ASSERT(style);
    80     return style->font().floatWidth(svgTextRunForInlineTextBox(textObject()->text()->characters() + offset, 1, style, this, 0));
    81 }
    82 
    83 float SVGInlineTextBox::calculateGlyphHeight(RenderStyle* style, int offset) const
     80    return style->font().floatWidth(svgTextRunForInlineTextBox(textObject()->text()->characters() + offset, 1, style, this, 0), extraCharsAvailable, charsConsumed);
     81}
     82
     83float SVGInlineTextBox::calculateGlyphHeight(RenderStyle* style, int offset, int extraCharsAvailable) const
    8484{
    8585    ASSERT(style);
     
    9797    float glyphWidth = 0.0f;
    9898
     99    // FIXME: account for multi-character glyphs
     100    int charsConsumed;
    99101    if (!m_reversed)
    100         glyphWidth = calculateGlyphWidth(style, offset);
     102        glyphWidth = calculateGlyphWidth(style, offset, 0, charsConsumed);
    101103    else
    102         glyphWidth = calculateGlyphWidth(style, start() + end() - offset);
     104        glyphWidth = calculateGlyphWidth(style, start() + end() - offset, 0, charsConsumed);
    103105
    104106    float x1 = svgChar.x;
  • trunk/WebCore/rendering/SVGInlineTextBox.h

    r29663 r31310  
    5959
    6060        // Helper functions shared with SVGRootInlineBox     
    61         float calculateGlyphWidth(RenderStyle*, int offset) const;
    62         float calculateGlyphHeight(RenderStyle*, int offset) const;
     61        float calculateGlyphWidth(RenderStyle* style, int offset, int extraCharsAvailable, int& charsConsumed) const;
     62        float calculateGlyphHeight(RenderStyle*, int offset, int extraCharsAvailable) const;
    6363
    6464        FloatRect calculateGlyphBoundaries(RenderStyle*, int offset, const SVGChar&) const;
  • trunk/WebCore/rendering/SVGRootInlineBox.cpp

    r30430 r31310  
    711711                int offset = box->m_reversed ? box->end() - i - positionOffset + 1 : box->start() + i + positionOffset - 1;
    712712
     713                // FIXME: does this need to change to handle multichar glyphs?
     714                int charsConsumed = 1;
    713715                if (calcWidthOnly) {
    714                     float lastGlyphWidth = box->calculateGlyphWidth(style, offset);
     716                    float lastGlyphWidth = box->calculateGlyphWidth(style, offset, 0, charsConsumed);
    715717                    length += currentCharacter.x - lastCharacter.x - lastGlyphWidth;
    716718                } else {
    717                     float lastGlyphHeight = box->calculateGlyphHeight(style, offset);
     719                    float lastGlyphHeight = box->calculateGlyphHeight(style, offset, 0);
    718720                    length += currentCharacter.y - lastCharacter.y - lastGlyphHeight;
    719721                }
     
    11111113    bool isVerticalText = isVerticalWritingMode(svgStyle);
    11121114
    1113     for (unsigned i = 0; i < length; ++i) {
     1115    int charsConsumed = 0;
     1116    for (unsigned i = 0; i < length; i += charsConsumed) {
    11141117        SVGChar svgChar;
    11151118
     
    11201123        float glyphHeight = 0.0f;
    11211124
     1125        int extraCharsAvailable = length - i - 1;
     1126
    11221127        if (textBox->m_reversed) {
    1123             glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->end() - i);
    1124             glyphHeight = svgTextBox->calculateGlyphHeight(style, textBox->end() - i);
     1128            glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->end() - i, extraCharsAvailable, charsConsumed);
     1129            glyphHeight = svgTextBox->calculateGlyphHeight(style, textBox->end() - i, extraCharsAvailable);
    11251130        } else {
    1126             glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->start() + i);
    1127             glyphHeight = svgTextBox->calculateGlyphHeight(style, textBox->start() + i);
     1131            glyphWidth = svgTextBox->calculateGlyphWidth(style, textBox->start() + i, extraCharsAvailable, charsConsumed);
     1132            glyphHeight = svgTextBox->calculateGlyphHeight(style, textBox->start() + i, extraCharsAvailable);
    11281133        }
    11291134
     
    13001305            info.curx += glyphAdvance + spacing;
    13011306
    1302         // Advance to next character
    1303         info.svgChars.append(svgChar);
    1304         info.processedSingleCharacter();
     1307        // Advance to next character group
     1308        for (int k = 0; k < charsConsumed; ++k) {
     1309            info.svgChars.append(svgChar);
     1310            info.processedSingleCharacter();
     1311            svgChar.drawnSeperated = false;
     1312            svgChar.newTextChunk = false;
     1313        }
    13051314    }
    13061315}
  • trunk/WebCore/svg/SVGFont.cpp

    r29840 r31310  
    250250        bool foundGlyph = false;
    251251        int characterLookupRange;
     252        int endOfScanRange = to + m_walkerData.extraCharsAvailable;
    252253
    253254        for (int i = from; i < to; ++i) {
     
    255256            // We have to check wheter the current character & the next character define a ligature. This needs to be
    256257            // extended to the n-th next character (where n is 'characterLookupRange'), to check for any possible ligature.
    257             characterLookupRange = maximumHashKeyLength + i >= to ? to - i : maximumHashKeyLength;
    258 
     258            characterLookupRange = maximumHashKeyLength + i >= endOfScanRange ? endOfScanRange - i : maximumHashKeyLength;
     259
     260            // FIXME: instead of checking from longest string to shortest, this should really scan in order
     261            // of the glyphs and pick the first match
    259262            while (characterLookupRange > 0 && !foundGlyph) {
    260263                String lookupString(run.data(run.rtl() ? run.length() - (i + characterLookupRange) : i), characterLookupRange);
     
    273276                        ASSERT(characterLookupRange > 0);
    274277                        i += characterLookupRange - 1;
     278                        m_walkerData.charsConsumed += characterLookupRange;
    275279
    276280                        foundGlyph = true;
     
    284288
    285289            if (!foundGlyph) {
     290                ++m_walkerData.charsConsumed;
    286291                if (SVGMissingGlyphElement* element = m_fontElement->firstMissingGlyphElement()) {
    287292                    // <missing-glyph> element support
     
    318323    int from;
    319324    int to;
     325    int extraCharsAvailable;
     326    int charsConsumed;
    320327
    321328    float scale;
     
    344351}
    345352
    346 static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int from, int to)
     353static float floatWidthOfSubStringUsingSVGFont(const Font* font, const TextRun& run, int extraCharsAvailable, int from, int to, int& charsConsumed)
    347354{
    348355    int newFrom = to > from ? from : to;
     
    365372        data.from = from;
    366373        data.to = to;
     374        data.extraCharsAvailable = extraCharsAvailable;
     375        data.charsConsumed = 0;
    367376        data.scale = convertEmUnitToPixel(font->size(), fontFaceElement->unitsPerEm(), 1.0f);
    368377        data.length = 0.0f;
     
    381390        SVGTextRunWalker<SVGTextRunWalkerMeasuredLengthData> runWalker(fontData, fontElement, data, floatWidthUsingSVGFontCallback, floatWidthMissingGlyphCallback);
    382391        runWalker.walk(run, isVerticalText, language, 0, run.length());
     392        charsConsumed = data.charsConsumed;
    383393        return data.length;
    384394    }
     
    389399float Font::floatWidthUsingSVGFont(const TextRun& run) const
    390400{
    391     return floatWidthOfSubStringUsingSVGFont(this, run, 0, run.length());
     401    int charsConsumed;
     402    return floatWidthOfSubStringUsingSVGFont(this, run, 0, 0, run.length(), charsConsumed);
     403}
     404
     405float Font::floatWidthUsingSVGFont(const TextRun& run, int extraCharsAvailable, int& charsConsumed) const
     406{
     407    return floatWidthOfSubStringUsingSVGFont(this, run, extraCharsAvailable, 0, run.length(), charsConsumed);
    392408}
    393409
     
    396412    float scale;
    397413    bool isVerticalText;
     414    int extraCharsAvailable;
     415    int charsConsumed;
    398416
    399417    float xStartOffset;
     
    494512        ASSERT(data.activePaintServer);
    495513
     514        int charsConsumed;
    496515        data.isVerticalText = false;
    497         data.xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, run.rtl() ? to : 0, run.rtl() ? run.length() : from);
     516        data.xStartOffset = floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed);
    498517        data.glyphOrigin = FloatPoint();
    499518        data.context = context;
     
    514533        }
    515534
     535        data.extraCharsAvailable = 0;
     536
    516537        SVGTextRunWalker<SVGTextRunWalkerDrawTextData> runWalker(fontData, fontElement, data, drawTextUsingSVGFontCallback, drawTextMissingGlyphCallback);
    517538        runWalker.walk(run, data.isVerticalText, language, from, to);
     
    521542FloatRect Font::selectionRectForTextUsingSVGFont(const TextRun& run, const IntPoint& point, int height, int from, int to) const
    522543{
    523     return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(this, run, run.rtl() ? to : 0, run.rtl() ? run.length() : from),
    524                      point.y(), floatWidthOfSubStringUsingSVGFont(this, run, from, to), height);
     544    int charsConsumed;
     545    return FloatRect(point.x() + floatWidthOfSubStringUsingSVGFont(this, run, 0, run.rtl() ? to : 0, run.rtl() ? run.length() : from, charsConsumed),
     546                     point.y(), floatWidthOfSubStringUsingSVGFont(this, run, 0, from, to, charsConsumed), height);
    525547}
    526548
  • trunk/WebCore/svg/SVGGlyphElement.h

    r29700 r31310  
    5252        SVGGlyphIdentifier()
    5353            : isValid(false)
     54            , priority(0)
    5455            , orientation(Both)
    5556            , arabicForm(None)
     
    8384
    8485        bool isValid : 1;
     86        int priority;
    8587
    8688        Orientation orientation : 2;
  • trunk/WebCore/svg/SVGTextContentElement.cpp

    r31160 r31310  
    8080                newOffset = textBox->start() + textBox->end() - newOffset;
    8181
     82            // FIXME: does this handle multichar glyphs ok? not sure
     83            int charsConsumed = 0;
    8284            if (isVerticalText)
    83                 textLength += textBox->calculateGlyphHeight(style, newOffset);
     85                textLength += textBox->calculateGlyphHeight(style, newOffset, 0);
    8486            else
    85                 textLength += textBox->calculateGlyphWidth(style, newOffset);
     87                textLength += textBox->calculateGlyphWidth(style, newOffset, 0, charsConsumed);
    8688        }
    8789
     
    194196                        newOffset = textBox->start() + textBox->end() - newOffset;
    195197
     198                    int charsConsumed;
    196199                    if (isVerticalText)
    197                         m_queryPointResult.move(it->x, it->y + textBox->calculateGlyphHeight(style, newOffset));
     200                        m_queryPointResult.move(it->x, it->y + textBox->calculateGlyphHeight(style, newOffset, end - it));
    198201                    else
    199                         m_queryPointResult.move(it->x + textBox->calculateGlyphWidth(style, newOffset), it->y);
     202                        m_queryPointResult.move(it->x + textBox->calculateGlyphWidth(style, newOffset, end - it, charsConsumed), it->y);
    200203
    201204                    m_stopProcessing = true;
Note: See TracChangeset for help on using the changeset viewer.