Changeset 88613 in webkit
- Timestamp:
- Jun 12, 2011 5:40:40 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88612 r88613 1 2011-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 1 49 2011-06-12 Robert Hogan <robert@webkit.org> 2 50 -
trunk/Source/WebCore/platform/graphics/Font.h
r87152 r88613 164 164 void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const; 165 165 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; 168 168 float floatWidthForSimpleText(const TextRun&, GlyphBuffer*, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const; 169 169 int offsetForPositionForSimpleText(const TextRun&, float position, bool includePartialGlyphs) const; -
trunk/Source/WebCore/platform/graphics/FontFastPath.cpp
r88260 r88613 363 363 364 364 FloatPoint startPoint(startX, point.y()); 365 drawGlyphBuffer(context, glyphBuffer, startPoint);365 drawGlyphBuffer(context, run, glyphBuffer, startPoint); 366 366 } 367 367 … … 374 374 return; 375 375 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) const376 drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y())); 377 } 378 379 void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun&, const GlyphBuffer& glyphBuffer, const FloatPoint& point) const 380 380 { 381 381 // Draw each contiguous run of glyphs that use the same font data. … … 419 419 } 420 420 421 void Font::drawEmphasisMarks(GraphicsContext* context, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const421 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoint& point) const 422 422 { 423 423 GlyphData markGlyphData; … … 445 445 markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spaceGlyph, markFontData, 0); 446 446 447 drawGlyphBuffer(context, markBuffer, startPoint);447 drawGlyphBuffer(context, run, markBuffer, startPoint); 448 448 } 449 449 -
trunk/Source/WebCore/platform/graphics/TextRun.h
r88139 r88613 49 49 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) 50 50 : m_characters(c) 51 , m_charactersLength(len) 51 52 , m_len(len) 52 53 , m_xpos(xpos) … … 65 66 TextRun(const String& s, bool allowTabs = false, float xpos = 0, float expansion = 0, ExpansionBehavior expansionBehavior = AllowTrailingExpansion | ForbidLeadingExpansion, TextDirection direction = LTR, bool directionalOverride = false) 66 67 : m_characters(s.characters()) 68 , m_charactersLength(s.length()) 67 69 , m_len(s.length()) 68 70 , m_xpos(xpos) … … 84 86 const UChar* characters() const { return m_characters; } 85 87 int length() const { return m_len; } 88 int charactersLength() const { return m_charactersLength; } 86 89 87 90 void setText(const UChar* c, int len) { m_characters = c; m_len = len; } 91 void setCharactersLength(int charactersLength) { m_charactersLength = charactersLength; } 88 92 89 93 #if ENABLE(SVG) … … 128 132 private: 129 133 const UChar* m_characters; 134 int m_charactersLength; // Marks the end of the m_characters buffer. Default equals to m_len. 130 135 int m_len; 131 136 -
trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp
r85411 r88613 94 94 // Draw the glyph buffer now at the starting point returned in startX. 95 95 FloatPoint startPoint(startX, point.y()); 96 drawGlyphBuffer(context, glyphBuffer, startPoint);96 drawGlyphBuffer(context, run, glyphBuffer, startPoint); 97 97 } 98 98 … … 105 105 return; 106 106 107 drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));107 drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y())); 108 108 } 109 109 -
trunk/Source/WebCore/platform/graphics/win/FontWin.cpp
r81684 r88613 109 109 // Draw the glyph buffer now at the starting point returned in startX. 110 110 FloatPoint startPoint(startX, point.y()); 111 drawGlyphBuffer(context, glyphBuffer, startPoint);111 drawGlyphBuffer(context, run, glyphBuffer, startPoint); 112 112 } 113 113 … … 120 120 return; 121 121 122 drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));122 drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y())); 123 123 } 124 124 -
trunk/Source/WebCore/platform/graphics/wx/FontWx.cpp
r87745 r88613 151 151 // Draw the glyph buffer now at the starting point returned in startX. 152 152 FloatPoint startPoint(startX, point.y()); 153 drawGlyphBuffer(context, glyphBuffer, startPoint);153 drawGlyphBuffer(context, run, glyphBuffer, startPoint); 154 154 #else 155 155 notImplemented(); … … 165 165 return; 166 166 167 drawEmphasisMarks(context, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));167 drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y())); 168 168 } 169 169 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r88526 r88613 1319 1319 run.setRenderingContext(SVGTextRunRenderingContext::create(textRenderer)); 1320 1320 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()); 1321 1323 return run; 1322 1324 } -
trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp
r88526 r88613 1575 1575 if (isFixedPitch || (!from && len == text->textLength()) || text->style()->hasTextCombine()) 1576 1576 return text->width(from, len, font, xPos); 1577 1577 1578 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 1578 1582 run.setAllowTabs(!collapseWhiteSpace); 1579 1583 run.setXPos(xPos); … … 1603 1607 1604 1608 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 1605 1612 run.setAllowTabs(!collapseWhiteSpace); 1606 1613 run.setXPos(xPos + lastSpaceWordSpacing); -
trunk/Source/WebCore/rendering/RenderText.cpp
r88297 r88613 632 632 633 633 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 634 637 run.setAllowTabs(allowTabs()); 635 638 run.setXPos(xPos); … … 919 922 } else { 920 923 TextRun run = RenderBlock::constructTextRun(this, f, txt + i, 1, style()); 924 run.setCharactersLength(len - i); 925 ASSERT(run.charactersLength() >= run.length()); 926 921 927 run.setAllowTabs(allowTabs()); 922 928 run.setXPos(leadWidth + currMaxWidth); … … 1298 1304 } else { 1299 1305 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 1300 1309 run.setAllowTabs(allowTabs()); 1301 1310 run.setXPos(xPos); -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r88526 r88613 431 431 // We handle letter & word spacing ourselves. 432 432 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()); 433 437 return run; 434 438 }
Note: See TracChangeset
for help on using the changeset viewer.