Changeset 88613 in webkit


Ignore:
Timestamp:
Jun 12, 2011 5:40:40 AM (13 years ago)
Author:
Nikolas Zimmermann
Message:

2011-06-11 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

Add TextRun charactersLength member
https://bugs.webkit.org/show_bug.cgi?id=62501

Preparation patch 2: Propagate the maximum length of the characters buffer the TextRun operates on, even when we're only measuring a substring.
For example: In RenderText when we're measuring 'len' characters starting from "text()->characters() + start", there's a portion
of "textLength() - start" characters that we're not processing. In order to support ligatures when integrating SVG Fonts
within the GlyphPage concept, we need this extra information, to lookup ligatures even when single chars are measured.
If a font defines an eg "ffl" ligature, and we're measuring the "f" of "ffl", it shall looukp the "ffl" glyph from the font,
and skip the next two characters (this will be done in WidthIterator).

This doesn't yet affect any test, the new SVG Fonts code is not merged yet, this is the preparaion patch 2.

  • platform/graphics/Font.h: Add yet-unused "const TextRun&" parameter to drawGlyphBuffer/drawEmphasisMarks.
  • platform/graphics/FontFastPath.cpp: Ditto. This parameter will be used to looukp the TextRunRenderingContext in a follow-up patch. (WebCore::Font::drawSimpleText): (WebCore::Font::drawEmphasisMarksForSimpleText): (WebCore::Font::drawGlyphBuffer): (WebCore::Font::drawEmphasisMarks):
  • platform/graphics/TextRun.h: Add "int m_charactersLength", similar to "int m_len". It denotes the maximum length of the characters buffer

that we're holding. It defaults to the passed "len" value, but is overriden by explicit setCharactersLength calls.

(WebCore::TextRun::TextRun):
(WebCore::TextRun::charactersLength):
(WebCore::TextRun::setCharactersLength):

  • platform/graphics/mac/FontComplexTextMac.cpp: Pass TextRun do drawGlyphBuffer/drawEmphasisMarks. (WebCore::Font::drawComplexText): (WebCore::Font::drawEmphasisMarksForComplexText):
  • platform/graphics/win/FontWin.cpp: Ditto. (WebCore::Font::drawComplexText): (WebCore::Font::drawEmphasisMarksForComplexText):
  • platform/graphics/wx/FontWx.cpp: Ditto. (WebCore::Font::drawComplexText): (WebCore::Font::drawEmphasisMarksForComplexText):
  • rendering/InlineTextBox.cpp: Call setCharactersLength on the processed TextRun. (WebCore::InlineTextBox::constructTextRun):
  • rendering/RenderBlockLineLayout.cpp: Ditto. (WebCore::textWidth): (WebCore::tryHyphenating):
  • rendering/RenderText.cpp: Ditto. (WebCore::RenderText::widthFromCache): (WebCore::RenderText::computePreferredLogicalWidths): (WebCore::RenderText::width):
  • rendering/svg/SVGInlineTextBox.cpp: Ditto. (WebCore::SVGInlineTextBox::constructTextRun):
Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r88612 r88613  
     12011-06-11  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        Add TextRun charactersLength member
     6        https://bugs.webkit.org/show_bug.cgi?id=62501
     7
     8        Preparation patch 2: Propagate the maximum length of the characters buffer the TextRun operates on, even when we're only measuring a substring.
     9        For example: In RenderText when we're measuring 'len' characters starting from "text()->characters() + start", there's a portion
     10        of "textLength() - start" characters that we're not processing. In order to support ligatures when integrating SVG Fonts
     11        within the GlyphPage concept, we need this extra information, to lookup ligatures even when single chars are measured.
     12        If a font defines an eg "ffl" ligature, and we're measuring the "f" of "ffl", it shall looukp the "ffl" glyph from the font,
     13        and skip the next two characters (this will be done in WidthIterator).
     14
     15        This doesn't yet affect any test, the new SVG Fonts code is not merged yet, this is the preparaion patch 2.
     16
     17        * platform/graphics/Font.h: Add yet-unused "const TextRun&" parameter to drawGlyphBuffer/drawEmphasisMarks.
     18        * platform/graphics/FontFastPath.cpp: Ditto. This parameter will be used to looukp the TextRunRenderingContext in a follow-up patch.
     19        (WebCore::Font::drawSimpleText):
     20        (WebCore::Font::drawEmphasisMarksForSimpleText):
     21        (WebCore::Font::drawGlyphBuffer):
     22        (WebCore::Font::drawEmphasisMarks):
     23        * platform/graphics/TextRun.h: Add "int m_charactersLength", similar to "int m_len". It denotes the maximum length of the characters buffer
     24                                       that we're holding. It defaults to the passed "len" value, but is overriden by explicit setCharactersLength calls.
     25        (WebCore::TextRun::TextRun):
     26        (WebCore::TextRun::charactersLength):
     27        (WebCore::TextRun::setCharactersLength):
     28        * platform/graphics/mac/FontComplexTextMac.cpp: Pass TextRun do drawGlyphBuffer/drawEmphasisMarks.
     29        (WebCore::Font::drawComplexText):
     30        (WebCore::Font::drawEmphasisMarksForComplexText):
     31        * platform/graphics/win/FontWin.cpp: Ditto.
     32        (WebCore::Font::drawComplexText):
     33        (WebCore::Font::drawEmphasisMarksForComplexText):
     34        * platform/graphics/wx/FontWx.cpp: Ditto.
     35        (WebCore::Font::drawComplexText):
     36        (WebCore::Font::drawEmphasisMarksForComplexText):
     37        * rendering/InlineTextBox.cpp: Call setCharactersLength on the processed TextRun.
     38        (WebCore::InlineTextBox::constructTextRun):
     39        * rendering/RenderBlockLineLayout.cpp: Ditto.
     40        (WebCore::textWidth):
     41        (WebCore::tryHyphenating):
     42        * rendering/RenderText.cpp: Ditto.
     43        (WebCore::RenderText::widthFromCache):
     44        (WebCore::RenderText::computePreferredLogicalWidths):
     45        (WebCore::RenderText::width):
     46        * rendering/svg/SVGInlineTextBox.cpp: Ditto.
     47        (WebCore::SVGInlineTextBox::constructTextRun):
     48
    1492011-06-12  Robert Hogan  <robert@webkit.org>
    250
  • trunk/Source/WebCore/platform/graphics/Font.h

    r87152 r88613  
    164164    void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const;
    165165    void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const;
    166     void drawGlyphBuffer(GraphicsContext*, const GlyphBuffer&, const FloatPoint&) const;
    167     void drawEmphasisMarks(GraphicsContext* context, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const;
     166    void drawGlyphBuffer(GraphicsContext*, const TextRun&, const GlyphBuffer&, const FloatPoint&) const;
     167    void drawEmphasisMarks(GraphicsContext*, const TextRun&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const;
    168168    float floatWidthForSimpleText(const TextRun&, GlyphBuffer*, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
    169169    int offsetForPositionForSimpleText(const TextRun&, float position, bool includePartialGlyphs) const;
  • trunk/Source/WebCore/platform/graphics/FontFastPath.cpp

    r88260 r88613  
    363363
    364364    FloatPoint startPoint(startX, point.y());
    365     drawGlyphBuffer(context, glyphBuffer, startPoint);
     365    drawGlyphBuffer(context, run, glyphBuffer, startPoint);
    366366}
    367367
     
    374374        return;
    375375
    376     drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
    377 }
    378 
    379 void Font::drawGlyphBuffer(GraphicsContext* context, const GlyphBuffer& glyphBuffer, const FloatPoint& point) const
     376    drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
     377}
     378
     379void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun&, const GlyphBuffer& glyphBuffer, const FloatPoint& point) const
    380380{   
    381381    // Draw each contiguous run of glyphs that use the same font data.
     
    419419}
    420420
    421 void Font::drawEmphasisMarks(GraphicsContext* context, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const
     421void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const
    422422{
    423423    GlyphData markGlyphData;
     
    445445    markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spaceGlyph, markFontData, 0);
    446446
    447     drawGlyphBuffer(context, markBuffer, startPoint);
     447    drawGlyphBuffer(context, run, markBuffer, startPoint);
    448448}
    449449
  • trunk/Source/WebCore/platform/graphics/TextRun.h

    r88139 r88613  
    4949    TextRun(const UChar* c, int len, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false)
    5050        : m_characters(c)
     51        , m_charactersLength(len)
    5152        , m_len(len)
    5253        , m_xpos(xpos)
     
    6566    TextRun(const String& s, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false)
    6667        : m_characters(s.characters())
     68        , m_charactersLength(s.length())
    6769        , m_len(s.length())
    6870        , m_xpos(xpos)
     
    8486    const UChar* characters() const { return m_characters; }
    8587    int length() const { return m_len; }
     88    int charactersLength() const { return m_charactersLength; }
    8689
    8790    void setText(const UChar* c, int len) { m_characters = c; m_len = len; }
     91    void setCharactersLength(int charactersLength) { m_charactersLength = charactersLength; }
    8892
    8993#if ENABLE(SVG)
     
    128132private:
    129133    const UChar* m_characters;
     134    int m_charactersLength; // Marks the end of the m_characters buffer. Default equals to m_len.
    130135    int m_len;
    131136
  • trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp

    r85411 r88613  
    9494    // Draw the glyph buffer now at the starting point returned in startX.
    9595    FloatPoint startPoint(startX, point.y());
    96     drawGlyphBuffer(context, glyphBuffer, startPoint);
     96    drawGlyphBuffer(context, run, glyphBuffer, startPoint);
    9797}
    9898
     
    105105        return;
    106106
    107     drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
     107    drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
    108108}
    109109
  • trunk/Source/WebCore/platform/graphics/win/FontWin.cpp

    r81684 r88613  
    109109    // Draw the glyph buffer now at the starting point returned in startX.
    110110    FloatPoint startPoint(startX, point.y());
    111     drawGlyphBuffer(context, glyphBuffer, startPoint);
     111    drawGlyphBuffer(context, run, glyphBuffer, startPoint);
    112112}
    113113
     
    120120        return;
    121121
    122     drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
     122    drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
    123123}
    124124
  • trunk/Source/WebCore/platform/graphics/wx/FontWx.cpp

    r87745 r88613  
    151151    // Draw the glyph buffer now at the starting point returned in startX.
    152152    FloatPoint startPoint(startX, point.y());
    153     drawGlyphBuffer(context, glyphBuffer, startPoint);
     153    drawGlyphBuffer(context, run, glyphBuffer, startPoint);
    154154#else
    155155    notImplemented();
     
    165165        return;
    166166
    167     drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
     167    drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
    168168}
    169169
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r88526 r88613  
    13191319        run.setRenderingContext(SVGTextRunRenderingContext::create(textRenderer));
    13201320
     1321    // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.
     1322    run.setCharactersLength(textRenderer->textLength());
    13211323    return run;
    13221324}
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r88526 r88613  
    15751575    if (isFixedPitch || (!from && len == text->textLength()) || text->style()->hasTextCombine())
    15761576        return text->width(from, len, font, xPos);
     1577
    15771578    TextRun run = RenderBlock::constructTextRun(text, font, text->characters() + from, len, text->style());
     1579    run.setCharactersLength(text->textLength() - from);
     1580    ASSERT(run.charactersLength() >= run.length());
     1581
    15781582    run.setAllowTabs(!collapseWhiteSpace);
    15791583    run.setXPos(xPos);
     
    16031607
    16041608    TextRun run = RenderBlock::constructTextRun(text, font, text->characters() + lastSpace, pos - lastSpace, text->style());
     1609    run.setCharactersLength(text->textLength() - lastSpace);
     1610    ASSERT(run.charactersLength() >= run.length());
     1611
    16051612    run.setAllowTabs(!collapseWhiteSpace);
    16061613    run.setXPos(xPos + lastSpaceWordSpacing);
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r88297 r88613  
    632632
    633633    TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, text()->characters() + start, len, style());
     634    run.setCharactersLength(textLength() - start);
     635    ASSERT(run.charactersLength() >= run.length());
     636
    634637    run.setAllowTabs(allowTabs());
    635638    run.setXPos(xPos);
     
    919922            } else {
    920923                TextRun run = RenderBlock::constructTextRun(this, f, txt + i, 1, style());
     924                run.setCharactersLength(len - i);
     925                ASSERT(run.charactersLength() >= run.length());
     926
    921927                run.setAllowTabs(allowTabs());
    922928                run.setXPos(leadWidth + currMaxWidth);
     
    12981304    } else {
    12991305        TextRun run = RenderBlock::constructTextRun(const_cast<RenderText*>(this), f, text()->characters() + from, len, style());
     1306        run.setCharactersLength(textLength() - from);
     1307        ASSERT(run.charactersLength() >= run.length());
     1308
    13001309        run.setAllowTabs(allowTabs());
    13011310        run.setXPos(xPos);
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r88526 r88613  
    431431    // We handle letter & word spacing ourselves.
    432432    run.disableSpacing();
     433
     434    // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring.
     435    run.setCharactersLength(text->textLength() - fragment.characterOffset);
     436    ASSERT(run.charactersLength() >= run.length());
    433437    return run;
    434438}
Note: See TracChangeset for help on using the changeset viewer.