Changeset 170337 in webkit


Ignore:
Timestamp:
Jun 23, 2014 5:29:44 PM (10 years ago)
Author:
mmaxfield@apple.com
Message:

Use unsigneds instead of ints for indexes into a string in text layout code
https://bugs.webkit.org/show_bug.cgi?id=133592

Reviewed by Zalan Bujtas.

Migrate much of the text-handling code to use unsigneds for indexes into a string.

No new tests because there is no behavior change.

  • WebCore.exp.in:
  • platform/graphics/Font.cpp:

(WebCore::Font::drawText):
(WebCore::Font::drawEmphasisMarks):
(WebCore::Font::adjustSelectionRectForText):
(WebCore::computeUnderlineType):

  • platform/graphics/Font.h:
  • platform/graphics/FontFastPath.cpp:

(WebCore::Font::getGlyphsAndAdvancesForSimpleText):
(WebCore::Font::drawSimpleText):
(WebCore::Font::drawEmphasisMarksForSimpleText):
(WebCore::Font::drawGlyphBuffer):
(WebCore::Font::drawEmphasisMarks):
(WebCore::Font::adjustSelectionRectForSimpleText):

  • platform/graphics/GlyphBuffer.h:

(WebCore::GlyphBuffer::size):
(WebCore::GlyphBuffer::glyphs):
(WebCore::GlyphBuffer::advances):
(WebCore::GlyphBuffer::fontDataAt):
(WebCore::GlyphBuffer::advanceAt):
(WebCore::GlyphBuffer::offsetAt):
(WebCore::GlyphBuffer::reverse):
(WebCore::GlyphBuffer::offsetInString):
(WebCore::GlyphBuffer::swap):

  • platform/graphics/GraphicsContext.cpp:

(WebCore::TextRunIterator::atEnd):

  • platform/graphics/Latin1TextIterator.h:

(WebCore::Latin1TextIterator::Latin1TextIterator):
(WebCore::Latin1TextIterator::currentCharacter):

  • platform/graphics/SimpleFontData.h:
  • platform/graphics/SurrogatePairAwareTextIterator.cpp:

(WebCore::SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator):

  • platform/graphics/SurrogatePairAwareTextIterator.h:

(WebCore::SurrogatePairAwareTextIterator::currentCharacter):

  • platform/graphics/TextRun.h:

(WebCore::TextRun::length):
(WebCore::TextRun::charactersLength):

  • platform/graphics/WidthIterator.cpp:

(WebCore::WidthIterator::glyphDataForCharacter):
(WebCore::applyFontTransforms):
(WebCore::WidthIterator::advanceInternal):
(WebCore::WidthIterator::advance):
(WebCore::WidthIterator::advanceOneCharacter):

  • platform/graphics/WidthIterator.h:
  • platform/graphics/cairo/FontCairo.cpp:

(WebCore::Font::drawGlyphs):

  • platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:

(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
(WebCore::Font::adjustSelectionRectForComplexText):

  • platform/graphics/harfbuzz/HarfBuzzShaper.cpp:

(WebCore::HarfBuzzShaper::setNormalizedBuffer):

  • platform/graphics/mac/FontComplexTextMac.cpp:

(WebCore::Font::adjustSelectionRectForComplexText):
(WebCore::Font::getGlyphsAndAdvancesForComplexText):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):

  • platform/graphics/mac/FontMac.mm:

(WebCore::Font::drawGlyphs):

  • platform/graphics/win/FontCGWin.cpp:

(WebCore::Font::drawGlyphs):

  • platform/graphics/win/FontWin.cpp:

(WebCore::Font::adjustSelectionRectForComplexText):
(WebCore::Font::getGlyphsAndAdvancesForComplexText):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):

  • platform/graphics/wince/FontWinCE.cpp:

(WebCore::Font::drawGlyphs):
(WebCore::Font::drawComplexText):
(WebCore::Font::drawEmphasisMarksForComplexText):
(WebCore::Font::selectionRectForComplexText):

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::isSelected):
(WebCore::InlineTextBox::selectionState):
(WebCore::adjustCharactersAndLengthForHyphen):
(WebCore::InlineTextBox::localSelectionRect):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::selectionStartEnd):
(WebCore::InlineTextBox::paintSelection):
(WebCore::InlineTextBox::paintCompositionBackground):
(WebCore::InlineTextBox::paintDocumentMarker):
(WebCore::InlineTextBox::paintTextMatchMarker):
(WebCore::InlineTextBox::computeRectForReplacementMarker):
(WebCore::InlineTextBox::paintCompositionUnderline):
(WebCore::InlineTextBox::positionForOffset):
(WebCore::InlineTextBox::constructTextRun):

  • rendering/InlineTextBox.h:
  • rendering/RenderCombineText.cpp:

(WebCore::RenderCombineText::getStringToRender):

  • rendering/RenderCombineText.h:
  • rendering/svg/SVGInlineFlowBox.cpp:

(WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):

  • rendering/svg/SVGInlineTextBox.cpp:

(WebCore::SVGInlineTextBox::positionForOffset):
(WebCore::SVGInlineTextBox::localSelectionRect):
(WebCore::SVGInlineTextBox::paintSelectionBackground):
(WebCore::SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates):
(WebCore::SVGInlineTextBox::paintText):

  • rendering/svg/SVGInlineTextBox.h:
  • rendering/svg/SVGTextMetricsBuilder.cpp:

(WebCore::SVGTextMetricsBuilder::currentCharacterStartsSurrogatePair):
(WebCore::SVGTextMetricsBuilder::advance):

  • rendering/svg/SVGTextQuery.cpp:

(WebCore::SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates):
(WebCore::SVGTextQuery::modifyStartEndPositionsRespectingLigatures):
(WebCore::SVGTextQuery::subStringLengthCallback):
(WebCore::SVGTextQuery::startPositionOfCharacterCallback):
(WebCore::SVGTextQuery::endPositionOfCharacterCallback):
(WebCore::SVGTextQuery::rotationOfCharacterCallback):
(WebCore::SVGTextQuery::extentOfCharacterCallback):
(WebCore::SVGTextQuery::characterNumberAtPositionCallback):

  • rendering/svg/SVGTextQuery.h:
  • rendering/svg/SVGTextRunRenderingContext.cpp:

(WebCore::SVGGlyphToPathTranslator::SVGGlyphToPathTranslator):
(WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):

  • rendering/svg/SVGTextRunRenderingContext.h:
  • svg/SVGFontData.cpp:

(WebCore::SVGFontData::applySVGGlyphSelection):

  • svg/SVGFontData.h:
Location:
trunk/Source/WebCore
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r170336 r170337  
     12014-06-20  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Use unsigneds instead of ints for indexes into a string in text layout code
     4        https://bugs.webkit.org/show_bug.cgi?id=133592
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Migrate much of the text-handling code to use unsigneds for indexes into a string.
     9
     10        No new tests because there is no behavior change.
     11
     12        * WebCore.exp.in:
     13        * platform/graphics/Font.cpp:
     14        (WebCore::Font::drawText):
     15        (WebCore::Font::drawEmphasisMarks):
     16        (WebCore::Font::adjustSelectionRectForText):
     17        (WebCore::computeUnderlineType):
     18        * platform/graphics/Font.h:
     19        * platform/graphics/FontFastPath.cpp:
     20        (WebCore::Font::getGlyphsAndAdvancesForSimpleText):
     21        (WebCore::Font::drawSimpleText):
     22        (WebCore::Font::drawEmphasisMarksForSimpleText):
     23        (WebCore::Font::drawGlyphBuffer):
     24        (WebCore::Font::drawEmphasisMarks):
     25        (WebCore::Font::adjustSelectionRectForSimpleText):
     26        * platform/graphics/GlyphBuffer.h:
     27        (WebCore::GlyphBuffer::size):
     28        (WebCore::GlyphBuffer::glyphs):
     29        (WebCore::GlyphBuffer::advances):
     30        (WebCore::GlyphBuffer::fontDataAt):
     31        (WebCore::GlyphBuffer::advanceAt):
     32        (WebCore::GlyphBuffer::offsetAt):
     33        (WebCore::GlyphBuffer::reverse):
     34        (WebCore::GlyphBuffer::offsetInString):
     35        (WebCore::GlyphBuffer::swap):
     36        * platform/graphics/GraphicsContext.cpp:
     37        (WebCore::TextRunIterator::atEnd):
     38        * platform/graphics/Latin1TextIterator.h:
     39        (WebCore::Latin1TextIterator::Latin1TextIterator):
     40        (WebCore::Latin1TextIterator::currentCharacter):
     41        * platform/graphics/SimpleFontData.h:
     42        * platform/graphics/SurrogatePairAwareTextIterator.cpp:
     43        (WebCore::SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator):
     44        * platform/graphics/SurrogatePairAwareTextIterator.h:
     45        (WebCore::SurrogatePairAwareTextIterator::currentCharacter):
     46        * platform/graphics/TextRun.h:
     47        (WebCore::TextRun::length):
     48        (WebCore::TextRun::charactersLength):
     49        * platform/graphics/WidthIterator.cpp:
     50        (WebCore::WidthIterator::glyphDataForCharacter):
     51        (WebCore::applyFontTransforms):
     52        (WebCore::WidthIterator::advanceInternal):
     53        (WebCore::WidthIterator::advance):
     54        (WebCore::WidthIterator::advanceOneCharacter):
     55        * platform/graphics/WidthIterator.h:
     56        * platform/graphics/cairo/FontCairo.cpp:
     57        (WebCore::Font::drawGlyphs):
     58        * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp:
     59        (WebCore::Font::drawComplexText):
     60        (WebCore::Font::drawEmphasisMarksForComplexText):
     61        (WebCore::Font::adjustSelectionRectForComplexText):
     62        * platform/graphics/harfbuzz/HarfBuzzShaper.cpp:
     63        (WebCore::HarfBuzzShaper::setNormalizedBuffer):
     64        * platform/graphics/mac/FontComplexTextMac.cpp:
     65        (WebCore::Font::adjustSelectionRectForComplexText):
     66        (WebCore::Font::getGlyphsAndAdvancesForComplexText):
     67        (WebCore::Font::drawComplexText):
     68        (WebCore::Font::drawEmphasisMarksForComplexText):
     69        * platform/graphics/mac/FontMac.mm:
     70        (WebCore::Font::drawGlyphs):
     71        * platform/graphics/win/FontCGWin.cpp:
     72        (WebCore::Font::drawGlyphs):
     73        * platform/graphics/win/FontWin.cpp:
     74        (WebCore::Font::adjustSelectionRectForComplexText):
     75        (WebCore::Font::getGlyphsAndAdvancesForComplexText):
     76        (WebCore::Font::drawComplexText):
     77        (WebCore::Font::drawEmphasisMarksForComplexText):
     78        * platform/graphics/wince/FontWinCE.cpp:
     79        (WebCore::Font::drawGlyphs):
     80        (WebCore::Font::drawComplexText):
     81        (WebCore::Font::drawEmphasisMarksForComplexText):
     82        (WebCore::Font::selectionRectForComplexText):
     83        * rendering/InlineTextBox.cpp:
     84        (WebCore::InlineTextBox::isSelected):
     85        (WebCore::InlineTextBox::selectionState):
     86        (WebCore::adjustCharactersAndLengthForHyphen):
     87        (WebCore::InlineTextBox::localSelectionRect):
     88        (WebCore::InlineTextBox::paint):
     89        (WebCore::InlineTextBox::selectionStartEnd):
     90        (WebCore::InlineTextBox::paintSelection):
     91        (WebCore::InlineTextBox::paintCompositionBackground):
     92        (WebCore::InlineTextBox::paintDocumentMarker):
     93        (WebCore::InlineTextBox::paintTextMatchMarker):
     94        (WebCore::InlineTextBox::computeRectForReplacementMarker):
     95        (WebCore::InlineTextBox::paintCompositionUnderline):
     96        (WebCore::InlineTextBox::positionForOffset):
     97        (WebCore::InlineTextBox::constructTextRun):
     98        * rendering/InlineTextBox.h:
     99        * rendering/RenderCombineText.cpp:
     100        (WebCore::RenderCombineText::getStringToRender):
     101        * rendering/RenderCombineText.h:
     102        * rendering/svg/SVGInlineFlowBox.cpp:
     103        (WebCore::SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer):
     104        * rendering/svg/SVGInlineTextBox.cpp:
     105        (WebCore::SVGInlineTextBox::positionForOffset):
     106        (WebCore::SVGInlineTextBox::localSelectionRect):
     107        (WebCore::SVGInlineTextBox::paintSelectionBackground):
     108        (WebCore::SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates):
     109        (WebCore::SVGInlineTextBox::paintText):
     110        * rendering/svg/SVGInlineTextBox.h:
     111        * rendering/svg/SVGTextMetricsBuilder.cpp:
     112        (WebCore::SVGTextMetricsBuilder::currentCharacterStartsSurrogatePair):
     113        (WebCore::SVGTextMetricsBuilder::advance):
     114        * rendering/svg/SVGTextQuery.cpp:
     115        (WebCore::SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates):
     116        (WebCore::SVGTextQuery::modifyStartEndPositionsRespectingLigatures):
     117        (WebCore::SVGTextQuery::subStringLengthCallback):
     118        (WebCore::SVGTextQuery::startPositionOfCharacterCallback):
     119        (WebCore::SVGTextQuery::endPositionOfCharacterCallback):
     120        (WebCore::SVGTextQuery::rotationOfCharacterCallback):
     121        (WebCore::SVGTextQuery::extentOfCharacterCallback):
     122        (WebCore::SVGTextQuery::characterNumberAtPositionCallback):
     123        * rendering/svg/SVGTextQuery.h:
     124        * rendering/svg/SVGTextRunRenderingContext.cpp:
     125        (WebCore::SVGGlyphToPathTranslator::SVGGlyphToPathTranslator):
     126        (WebCore::SVGTextRunRenderingContext::glyphDataForCharacter):
     127        * rendering/svg/SVGTextRunRenderingContext.h:
     128        * svg/SVGFontData.cpp:
     129        (WebCore::SVGFontData::applySVGGlyphSelection):
     130        * svg/SVGFontData.h:
     131
    11322014-06-20  Jer Noble  <jer.noble@apple.com>
    2133
  • trunk/Source/WebCore/WebCore.exp.in

    r170335 r170337  
    18581858__ZNK7WebCore3URLcvP5NSURLEv
    18591859__ZNK7WebCore4Font5widthERKNS_7TextRunEPN3WTF7HashSetIPKNS_14SimpleFontDataENS4_7PtrHashIS8_EENS4_10HashTraitsIS8_EEEEPNS_13GlyphOverflowE
    1860 __ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEiiNS0_24CustomFontNotReadyActionE
     1860__ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEjiNS0_24CustomFontNotReadyActionE
    18611861__ZNK7WebCore4FonteqERKS0_
    18621862__ZNK7WebCore4Node11textContentEb
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r170268 r170337  
    330330}
    331331
    332 float Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to, CustomFontNotReadyAction customFontNotReadyAction) const
     332float Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, int initialTo, CustomFontNotReadyAction customFontNotReadyAction) const
    333333{
    334334    // Don't draw anything while we are using custom fonts that are in the process of loading,
     
    338338        return 0;
    339339
    340     to = (to == -1 ? run.length() : to);
     340    unsigned to = initialTo < 0 ? run.length() : initialTo;
    341341
    342342    CodePath codePathToUse = codePath(run);
     
    351351}
    352352
    353 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
     353void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, int initialTo) const
    354354{
    355355    if (loadingCustomFonts())
    356356        return;
    357 
    358     if (to < 0)
    359         to = run.length();
     357   
     358    unsigned to = initialTo < 0 ? run.length() : initialTo;
    360359
    361360    CodePath codePathToUse = codePath(run);
     
    508507}
    509508
    510 void Font::adjustSelectionRectForText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
    511 {
    512     to = (to == -1 ? run.length() : to);
     509void Font::adjustSelectionRectForText(const TextRun& run, LayoutRect& selectionRect, unsigned from, int initialTo) const
     510{
     511    unsigned to = initialTo < 0 ? run.length() : initialTo;
    513512
    514513    CodePath codePathToUse = codePath(run);
     
    10551054}
    10561055   
    1057 GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, int index)
     1056GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, unsigned index)
    10581057{
    10591058    // In general, we want to skip descenders. However, skipping descenders on CJK characters leads to undesirable renderings,
    10601059    // so we want to draw through CJK characters (on a character-by-character basis).
    10611060    UChar32 baseCharacter;
    1062     int offsetInString = glyphBuffer.offsetInString(index);
    1063 
    1064     if (offsetInString == GlyphBuffer::kNoOffset) {
     1061    int initialOffsetInString = glyphBuffer.offsetInString(index);
     1062
     1063    if (initialOffsetInString == GlyphBuffer::kNoOffset) {
    10651064        // We have no idea which character spawned this glyph. Bail.
    10661065        return GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph;
    10671066    }
    10681067   
     1068    ASSERT(initialOffsetInString >= 0);
     1069    unsigned offsetInString = static_cast<unsigned>(initialOffsetInString);
     1070   
    10691071    if (textRun.is8Bit())
    10701072        baseCharacter = textRun.characters8()[offsetInString];
    1071     else {
     1073    else
    10721074        U16_NEXT(textRun.characters16(), offsetInString, textRun.length(), baseCharacter);
    1073     }
    10741075   
    10751076    // u_getIntPropertyValue with UCHAR_IDEOGRAPHIC doesn't return true for Japanese or Korean codepoints.
  • trunk/Source/WebCore/platform/graphics/Font.h

    r170268 r170337  
    105105    virtual ~GlyphToPathTranslator() { }
    106106};
    107 GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun&, const GlyphBuffer&, int index);
     107GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun&, const GlyphBuffer&, unsigned index);
    108108
    109109class Font {
     
    134134
    135135    enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady };
    136     float drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
    137     void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&) const;
    138     void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1) const;
     136    float drawText(GraphicsContext*, const TextRun&, const FloatPoint&, unsigned from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;
     137    void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&) const;
     138    void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from = 0, int to = -1) const;
    139139
    140140    DashArray dashesForIntersectionsWithRect(const TextRun&, const FloatPoint& textOrigin, const FloatRect& lineExtents) const;
     
    148148
    149149    int offsetForPosition(const TextRun&, float position, bool includePartialGlyphs) const;
    150     void adjustSelectionRectForText(const TextRun&, LayoutRect& selectionRect, int from = 0, int to = -1) const;
     150    void adjustSelectionRectForText(const TextRun&, LayoutRect& selectionRect, unsigned from = 0, int to = -1) const;
    151151
    152152    bool isSmallCaps() const { return m_fontDescription.smallCaps(); }
     
    220220
    221221    // Returns the initial in-stream advance.
    222     float getGlyphsAndAdvancesForSimpleText(const TextRun&, int from, int to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
    223     float drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
    224     void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const;
     222    float getGlyphsAndAdvancesForSimpleText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
     223    float drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, unsigned from, unsigned to) const;
     224    void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from, unsigned to) const;
    225225    void drawGlyphBuffer(GraphicsContext*, const TextRun&, const GlyphBuffer&, FloatPoint&) const;
    226226    void drawEmphasisMarks(GraphicsContext*, const TextRun&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const;
    227227    float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
    228228    int offsetForPositionForSimpleText(const TextRun&, float position, bool includePartialGlyphs) const;
    229     void adjustSelectionRectForSimpleText(const TextRun&, LayoutRect& selectionRect, int from, int to) const;
     229    void adjustSelectionRectForSimpleText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const;
    230230
    231231    bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const;
     
    235235
    236236    // Returns the initial in-stream advance.
    237     float getGlyphsAndAdvancesForComplexText(const TextRun&, int from, int to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
    238     float drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const;
    239     void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const;
     237    float getGlyphsAndAdvancesForComplexText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;
     238    float drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, unsigned from, unsigned to) const;
     239    void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from, unsigned to) const;
    240240    float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, GlyphOverflow* = 0) const;
    241241    int offsetForPositionForComplexText(const TextRun&, float position, bool includePartialGlyphs) const;
    242     void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, int from, int to) const;
     242    void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const;
    243243
    244244    friend struct WidthIterator;
  • trunk/Source/WebCore/platform/graphics/FontFastPath.cpp

    r170268 r170337  
    127127}
    128128
    129 float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
     129float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
    130130{
    131131    float initialAdvance;
     
    157157}
    158158
    159 float Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
     159float Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const
    160160{
    161161    // This glyph buffer holds our glyphs+advances+font data for each glyph.
     
    173173}
    174174
    175 void Font::drawEmphasisMarksForSimpleText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
     175void Font::drawEmphasisMarksForSimpleText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const
    176176{
    177177    GlyphBuffer glyphBuffer;
     
    196196    float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width();
    197197    float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height();
    198     int lastFrom = 0;
    199     int nextGlyph = 1;
     198    unsigned lastFrom = 0;
     199    unsigned nextGlyph = 1;
    200200#if ENABLE(SVG_FONTS)
    201201    TextRun::RenderingContext* renderingContext = run.renderingContext();
     
    211211            else
    212212#endif
     213            {
     214                ASSERT(nextGlyph >= lastFrom);
    213215                drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint);
     216            }
    214217
    215218            lastFrom = nextGlyph;
     
    270273
    271274    GlyphBuffer markBuffer;
    272     for (int i = 0; i + 1 < glyphBuffer.size(); ++i) {
     275    for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) {
    273276        float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1);
    274277        float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph;
     
    297300}
    298301
    299 void Font::adjustSelectionRectForSimpleText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
     302void Font::adjustSelectionRectForSimpleText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const
    300303{
    301304    GlyphBuffer glyphBuffer;
  • trunk/Source/WebCore/platform/graphics/GlyphBuffer.h

    r170268 r170337  
    7777public:
    7878    bool isEmpty() const { return m_fontData.isEmpty(); }
    79     int size() const { return m_fontData.size(); }
     79    unsigned size() const { return m_fontData.size(); }
    8080   
    8181    void clear()
     
    9191    }
    9292
    93     GlyphBufferGlyph* glyphs(int from) { return m_glyphs.data() + from; }
    94     GlyphBufferAdvance* advances(int from) { return m_advances.data() + from; }
    95     const GlyphBufferGlyph* glyphs(int from) const { return m_glyphs.data() + from; }
    96     const GlyphBufferAdvance* advances(int from) const { return m_advances.data() + from; }
    97 
    98     const SimpleFontData* fontDataAt(int index) const { return m_fontData[index]; }
     93    GlyphBufferGlyph* glyphs(unsigned from) { return m_glyphs.data() + from; }
     94    GlyphBufferAdvance* advances(unsigned from) { return m_advances.data() + from; }
     95    const GlyphBufferGlyph* glyphs(unsigned from) const { return m_glyphs.data() + from; }
     96    const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.data() + from; }
     97
     98    const SimpleFontData* fontDataAt(unsigned index) const { return m_fontData[index]; }
    9999
    100100    void setInitialAdvance(GlyphBufferAdvance initialAdvance) { m_initialAdvance = initialAdvance; }
     
    110110    }
    111111
    112     GlyphBufferAdvance advanceAt(int index) const
     112    GlyphBufferAdvance advanceAt(unsigned index) const
    113113    {
    114114        return m_advances[index];
    115115    }
    116116
    117     FloatSize offsetAt(int index) const
     117    FloatSize offsetAt(unsigned index) const
    118118    {
    119119#if PLATFORM(WIN)
     
    177177#endif
    178178
    179     void reverse(int from, int length)
     179    void reverse(unsigned from, unsigned length)
    180180    {
    181181        for (int i = from, end = from + length - 1; i < end; ++i, --end)
     
    195195    }
    196196   
    197     int offsetInString(int index) const
     197    int offsetInString(unsigned index) const
    198198    {
    199199        ASSERT(m_offsetsInString);
     
    202202
    203203private:
    204     void swap(int index1, int index2)
     204    void swap(unsigned index1, unsigned index2)
    205205    {
    206206        const SimpleFontData* f = m_fontData[index1];
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r170268 r170337  
    7575private:
    7676    const TextRun* m_textRun;
    77     int m_offset;
     77    unsigned m_offset;
    7878};
    7979
  • trunk/Source/WebCore/platform/graphics/Latin1TextIterator.h

    r170268 r170337  
    3131    // The passed in LChar pointer starts at 'currentCharacter'. The iterator operates on the range [currentCharacter, lastCharacter].
    3232    // 'endCharacter' denotes the maximum length of the UChar array, which might exceed 'lastCharacter'.
    33     Latin1TextIterator(const LChar* characters, int currentCharacter, int lastCharacter, int /*endCharacter*/)
     33    Latin1TextIterator(const LChar* characters, unsigned currentCharacter, unsigned lastCharacter, unsigned /*endCharacter*/)
    3434        : m_characters(characters)
    3535        , m_currentCharacter(currentCharacter)
     
    5454    }
    5555
    56     int currentCharacter() const { return m_currentCharacter; }
     56    unsigned currentCharacter() const { return m_currentCharacter; }
    5757    const LChar* characters() const { return m_characters; }
    5858
    5959private:
    6060    const LChar* m_characters;
    61     int m_currentCharacter;
    62     int m_lastCharacter;
     61    unsigned m_currentCharacter;
     62    unsigned m_lastCharacter;
    6363};
    6464
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.h

    r170268 r170337  
    9090        virtual float widthForSVGGlyph(Glyph, float fontSize) const = 0;
    9191        virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const = 0;
    92         virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const = 0;
     92        virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, unsigned currentCharacter, unsigned& advanceLength) const = 0;
    9393    };
    9494
  • trunk/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp

    r170268 r170337  
    2828namespace WebCore {
    2929
    30 SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, int currentCharacter, int lastCharacter, int endCharacter)
     30SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, unsigned currentCharacter, unsigned lastCharacter, unsigned endCharacter)
    3131    : m_characters(characters)
    3232    , m_currentCharacter(currentCharacter)
  • trunk/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h

    r170268 r170337  
    3131    // The passed in UChar pointer starts at 'currentCharacter'. The iterator operatoes on the range [currentCharacter, lastCharacter].
    3232    // 'endCharacter' denotes the maximum length of the UChar array, which might exceed 'lastCharacter'.
    33     SurrogatePairAwareTextIterator(const UChar*, int currentCharacter, int lastCharacter, int endCharacter);
     33    SurrogatePairAwareTextIterator(const UChar*, unsigned currentCharacter, unsigned lastCharacter, unsigned endCharacter);
    3434
    3535    inline bool consume(UChar32& character, unsigned& clusterLength)
     
    5353    }
    5454
    55     int currentCharacter() const { return m_currentCharacter; }
     55    unsigned currentCharacter() const { return m_currentCharacter; }
    5656    const UChar* characters() const { return m_characters; }
    5757
     
    6161
    6262    const UChar* m_characters;
    63     int m_currentCharacter;
    64     int m_lastCharacter;
    65     int m_endCharacter;
     63    unsigned m_currentCharacter;
     64    unsigned m_lastCharacter;
     65    unsigned m_endCharacter;
    6666};
    6767
  • trunk/Source/WebCore/platform/graphics/TextRun.h

    r170268 r170337  
    172172   
    173173    bool is8Bit() const { return m_is8Bit; }
    174     int length() const { return m_len; }
    175     int charactersLength() const { return m_charactersLength; }
     174    unsigned length() const { return m_len; }
     175    unsigned charactersLength() const { return m_charactersLength; }
    176176    String string() const
    177177    {
     
    218218
    219219#if ENABLE(SVG_FONTS)
    220         virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) = 0;
     220        virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, unsigned currentCharacter, unsigned& advanceLength) = 0;
    221221        virtual void drawSVGGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0;
    222222        virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, String& glyphName) const = 0;
  • trunk/Source/WebCore/platform/graphics/WidthIterator.cpp

    r170268 r170337  
    6969}
    7070
    71 GlyphData WidthIterator::glyphDataForCharacter(UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength)
     71GlyphData WidthIterator::glyphDataForCharacter(UChar32 character, bool mirror, unsigned currentCharacter, unsigned& advanceLength)
    7272{
    7373    ASSERT(m_font);
     
    100100typedef Vector<std::pair<int, OriginalAdvancesForCharacterTreatedAsSpace>, 64> CharactersTreatedAsSpace;
    101101
    102 static inline float applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int& lastGlyphCount, const SimpleFontData* fontData, WidthIterator& iterator, TypesettingFeatures typesettingFeatures, CharactersTreatedAsSpace& charactersTreatedAsSpace)
     102static inline float applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, unsigned& lastGlyphCount, const SimpleFontData* fontData, WidthIterator& iterator, TypesettingFeatures typesettingFeatures, CharactersTreatedAsSpace& charactersTreatedAsSpace)
    103103{
    104104    ASSERT(typesettingFeatures & (Kerning | Ligatures));
     
    166166    const SimpleFontData* primaryFont = m_font->primaryFont();
    167167    const SimpleFontData* lastFontData = primaryFont;
    168     int lastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0;
     168    unsigned lastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0;
    169169
    170170    UChar32 character = 0;
     
    173173    while (textIterator.consume(character, clusterLength)) {
    174174        unsigned advanceLength = clusterLength;
    175         int currentCharacter = textIterator.currentCharacter();
     175        unsigned currentCharacter = textIterator.currentCharacter();
    176176        const GlyphData& glyphData = glyphDataForCharacter(character, rtl, currentCharacter, advanceLength);
    177177        Glyph glyph = glyphData.glyph;
     
    328328}
    329329
    330 unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer)
    331 {
    332     int length = m_run.length();
     330unsigned WidthIterator::advance(unsigned offset, GlyphBuffer* glyphBuffer)
     331{
     332    unsigned length = m_run.length();
    333333
    334334    if (offset > length)
    335335        offset = length;
    336336
    337     if (m_currentCharacter >= static_cast<unsigned>(offset))
     337    if (m_currentCharacter >= offset)
    338338        return 0;
    339339
     
    349349bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer)
    350350{
    351     int oldSize = glyphBuffer.size();
     351    unsigned oldSize = glyphBuffer.size();
    352352    advance(m_currentCharacter + 1, &glyphBuffer);
    353353    float w = 0;
    354     for (int i = oldSize; i < glyphBuffer.size(); ++i)
     354    for (unsigned i = oldSize; i < glyphBuffer.size(); ++i)
    355355        w += glyphBuffer.advanceAt(i).width();
    356356    width = w;
  • trunk/Source/WebCore/platform/graphics/WidthIterator.h

    r170268 r170337  
    4242    WidthIterator(const Font*, const TextRun&, HashSet<const SimpleFontData*>* fallbackFonts = 0, bool accountForGlyphBounds = false, bool forTextEmphasis = false);
    4343
    44     unsigned advance(int to, GlyphBuffer*);
     44    unsigned advance(unsigned to, GlyphBuffer*);
    4545    bool advanceOneCharacter(float& width, GlyphBuffer&);
    4646
     
    8888
    8989private:
    90     GlyphData glyphDataForCharacter(UChar32, bool mirror, int currentCharacter, unsigned& advanceLength);
     90    GlyphData glyphDataForCharacter(UChar32, bool mirror, unsigned currentCharacter, unsigned& advanceLength);
    9191    template <typename TextIterator>
    9292    inline unsigned advanceInternal(TextIterator&, GlyphBuffer*);
  • trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp

    r170268 r170337  
    9595
    9696void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
    97                       int from, int numGlyphs, const FloatPoint& point) const
     97    unsigned from, unsigned numGlyphs, const FloatPoint& point) const
    9898{
    9999    if (!font->platformData().size())
     
    103103
    104104    float offset = point.x();
    105     for (int i = 0; i < numGlyphs; i++) {
     105    for (unsigned i = 0; i < numGlyphs; i++) {
    106106        glyphs[i].x = offset;
    107107        glyphs[i].y = point.y();
  • trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp

    r170268 r170337  
    3939namespace WebCore {
    4040
    41 float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int, int) const
     41float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned, unsigned) const
    4242{
    4343    GlyphBuffer glyphBuffer;
     
    5353}
    5454
    55 void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
     55void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, unsigned /* from */, unsigned /* to */) const
    5656{
    5757    notImplemented();
     
    8686}
    8787
    88 void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
     88void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const
    8989{
    9090    HarfBuzzShaper shaper(this, run);
  • trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp

    r170268 r170337  
    257257        runCharacters = m_run.characters16();
    258258
    259     for (int i = 0; i < m_run.length(); ++i) {
     259    for (unsigned i = 0; i < m_run.length(); ++i) {
    260260        UChar ch = runCharacters[i];
    261261        if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) {
  • trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp

    r170268 r170337  
    3838namespace WebCore {
    3939
    40 void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
     40void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const
    4141{
    4242    ComplexTextController controller(this, run);
     
    5353}
    5454
    55 float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
     55float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
    5656{
    5757    float initialAdvance;
     
    7676}
    7777
    78 float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
     78float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const
    7979{
    8080    // This glyph buffer holds our glyphs + advances + font data for each glyph.
     
    9494}
    9595
    96 void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
     96void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const
    9797{
    9898    GlyphBuffer glyphBuffer;
  • trunk/Source/WebCore/platform/graphics/mac/FontMac.mm

    r170268 r170337  
    185185}
    186186
    187 void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const
     187void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint) const
    188188{
    189189    const FontPlatformData& platformData = font->platformData();
     
    469469    void moveToNextValidGlyph();
    470470
    471     int m_index;
     471    unsigned m_index;
    472472    const TextRun& m_textRun;
    473473    const GlyphBuffer& m_glyphBuffer;
  • trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp

    r170268 r170337  
    129129
    130130void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
    131                       int from, int numGlyphs, const FloatPoint& point) const
     131    unsigned from, unsigned numGlyphs, const FloatPoint& point) const
    132132{
    133133    CGContextRef cgContext = graphicsContext->platformContext();
  • trunk/Source/WebCore/platform/graphics/win/FontWin.cpp

    r170268 r170337  
    5252}
    5353
    54 void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const
     54void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const
    5555{
    5656    UniscribeController it(this, run);
     
    6868}
    6969
    70 float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
     70float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
    7171{
    7272    if (forTextEmphasis) {
     
    9393}
    9494
    95 float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
     95float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const
    9696{
    9797    // This glyph buffer holds our glyphs + advances + font data for each glyph.
     
    110110}
    111111
    112 void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
     112void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const
    113113{
    114114    GlyphBuffer glyphBuffer;
  • trunk/Source/WebCore/platform/graphics/wince/FontWinCE.cpp

    r170268 r170337  
    6363
    6464void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer,
    65                       int from, int numGlyphs, const FloatPoint& point) const
     65    unsigned from, unsigned numGlyphs, const FloatPoint& point) const
    6666{
    6767    graphicsContext->drawText(fontData, glyphBuffer, from, numGlyphs, point);
     
    207207}
    208208
    209 float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
     209float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const
    210210{
    211211    if (to < 0)
     
    238238}
    239239
    240 void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const
     240void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, unsigned /* from */, unsigned /* to */) const
    241241{
    242242    notImplemented();
     
    322322
    323323FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& pt,
    324                                      int h, int from, int to) const
     324    int h, unsigned from, unsigned to) const
    325325{
    326326    TextRunComponents components;
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r170268 r170337  
    197197}
    198198
    199 bool InlineTextBox::isSelected(int startPos, int endPos) const
    200 {
    201     int sPos = std::max(startPos - m_start, 0);
    202     int ePos = std::min(endPos - m_start, static_cast<int>(m_len));
    203     return (sPos < ePos);
     199bool InlineTextBox::isSelected(unsigned startPos, unsigned endPos) const
     200{
     201    unsigned sPos = startPos > m_start ? startPos - m_start : 0;
     202    if (endPos <= m_start)
     203        return false;
     204    unsigned ePos = std::min(endPos - m_start, static_cast<unsigned>(m_len));
     205    return sPos < ePos;
    204206}
    205207
     
    208210    RenderObject::SelectionState state = renderer().selectionState();
    209211    if (state == RenderObject::SelectionStart || state == RenderObject::SelectionEnd || state == RenderObject::SelectionBoth) {
    210         int startPos, endPos;
    211         renderer().selectionStartEnd(startPos, endPos);
     212        int initialStartPos, initialEndPos;
     213        renderer().selectionStartEnd(initialStartPos, initialEndPos);
     214        ASSERT(initialStartPos >= 0 && initialEndPos >= 0);
     215        unsigned startPos = initialStartPos;
     216        unsigned endPos = initialEndPos;
    212217        // The position after a hard line break is considered to be past its end.
    213         int lastSelectable = start() + len() - (isLineBreak() ? 1 : 0);
     218        unsigned lastSelectable = start() + len() - (isLineBreak() ? 1 : 0);
    214219
    215220        bool start = (state != RenderObject::SelectionEnd && startPos >= m_start && startPos < m_start + m_len);
     
    232237        EllipsisBox* ellipsis = root().ellipsisBox();
    233238        if (state != RenderObject::SelectionNone) {
    234             int start, end;
     239            unsigned start, end;
    235240            selectionStartEnd(start, end);
    236241            // The ellipsis should be considered to be selected if the end of
     
    247252}
    248253
    249 static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, const RenderStyle& style, String& string, int& length)
     254static void adjustCharactersAndLengthForHyphen(BufferForAppendingHyphen& charactersWithHyphen, const RenderStyle& style, String& string, unsigned& length)
    250255{
    251256    const AtomicString& hyphenString = style.hyphenString();
     
    267272}
    268273
    269 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) const
    270 {
    271     int sPos = std::max(startPos - m_start, 0);
    272     int ePos = std::min(endPos - m_start, (int)m_len);
     274LayoutRect InlineTextBox::localSelectionRect(unsigned startPos, unsigned endPos) const
     275{
     276    unsigned sPos = startPos > m_start ? startPos - m_start : 0;
     277   
     278    if (endPos < m_start)
     279        return LayoutRect();
     280
     281    unsigned ePos = std::min(endPos - m_start, static_cast<unsigned>(m_len));
    273282   
    274283    if (sPos > ePos)
     
    285294    bool respectHyphen = ePos == m_len && hasHyphen();
    286295    TextRun textRun = constructTextRun(lineStyle, font, respectHyphen ? &charactersWithHyphen : 0);
    287     if (respectHyphen)
    288         endPos = textRun.length();
    289296
    290297    LayoutRect selectionRect = LayoutRect(LayoutPoint(logicalLeft(), selectionTop), LayoutSize(m_logicalWidth, selectionHeight));
    291298    // Avoid computing the font width when the entire line box is selected as an optimization.
    292     if (sPos || ePos != static_cast<int>(m_len))
     299    if (sPos || ePos != m_len)
    293300        font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos);
    294301    IntRect snappedSelectionRect = enclosingIntRect(selectionRect);
     
    607614
    608615    // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only).
    609     int length = m_len;
    610     int maximumLength;
     616    unsigned length = m_len;
     617    unsigned maximumLength;
    611618    String string;
    612619    if (!combinedText) {
    613620        string = renderer().text();
    614         if (static_cast<unsigned>(length) != string.length() || m_start) {
    615             ASSERT_WITH_SECURITY_IMPLICATION(static_cast<unsigned>(m_start + length) <= string.length());
     621        if (length != string.length() || m_start) {
     622            ASSERT_WITH_SECURITY_IMPLICATION(m_start + length <= string.length());
    616623            string = string.substringSharingImpl(m_start, length);
    617624        }
     625        ASSERT(renderer().textLength() >= m_start);
    618626        maximumLength = renderer().textLength() - m_start;
    619627    } else {
     
    627635        length = textRun.length();
    628636
    629     int sPos = 0;
    630     int ePos = 0;
     637    unsigned sPos = 0;
     638    unsigned ePos = 0;
    631639    if (haveSelection && (paintSelectedTextOnly || paintSelectedTextSeparately))
    632640        selectionStartEnd(sPos, ePos);
    633641
    634642    if (m_truncation != cNoTruncation) {
    635         sPos = std::min<int>(sPos, m_truncation);
    636         ePos = std::min<int>(ePos, m_truncation);
     643        sPos = std::min(sPos, static_cast<unsigned>(m_truncation));
     644        ePos = std::min(ePos, static_cast<unsigned>(m_truncation));
    637645        length = m_truncation;
    638646    }
     
    694702}
    695703
    696 void InlineTextBox::selectionStartEnd(int& sPos, int& ePos)
    697 {
    698     int startPos, endPos;
     704void InlineTextBox::selectionStartEnd(unsigned& sPos, unsigned& ePos)
     705{
     706    unsigned startPos, endPos;
    699707    if (renderer().selectionState() == RenderObject::SelectionInside) {
    700708        startPos = 0;
    701709        endPos = renderer().textLength();
    702710    } else {
    703         renderer().selectionStartEnd(startPos, endPos);
     711        int originalStartPos, originalEndPos;
     712        renderer().selectionStartEnd(originalStartPos, originalEndPos);
     713        ASSERT(originalStartPos >= 0 && originalEndPos >= 0);
     714        startPos = originalStartPos;
     715        endPos = originalEndPos;
    704716        if (renderer().selectionState() == RenderObject::SelectionStart)
    705717            endPos = renderer().textLength();
     
    707719            startPos = 0;
    708720    }
    709 
    710     sPos = std::max(startPos - m_start, 0);
    711     ePos = std::min(endPos - m_start, (int)m_len);
     721   
     722    sPos = startPos > m_start ? startPos - m_start : 0;
     723    ePos = endPos > m_start ? endPos - m_start : 0;
     724    ePos = std::min(ePos, static_cast<unsigned>(m_len));
    712725}
    713726
     
    719732
    720733    // See if we have a selection to paint at all.
    721     int sPos, ePos;
     734    unsigned sPos, ePos;
    722735    selectionStartEnd(sPos, ePos);
    723736    if (sPos >= ePos)
     
    738751    // If the text is truncated, let the thing being painted in the truncation
    739752    // draw its own highlight.
    740     int length = m_truncation != cNoTruncation ? m_truncation : m_len;
     753    unsigned length = m_truncation != cNoTruncation ? m_truncation : m_len;
    741754    String string = renderer().text();
    742755
     
    748761    BufferForAppendingHyphen charactersWithHyphen;
    749762    bool respectHyphen = ePos == length && hasHyphen();
     763    ASSERT(renderer().textLength() >= m_start);
    750764    TextRun textRun = constructTextRun(style, font, string, renderer().textLength() - m_start, respectHyphen ? &charactersWithHyphen : 0);
    751765    if (respectHyphen)
     
    771785}
    772786
    773 void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, int startPos, int endPos)
    774 {
    775     int offset = m_start;
    776     int sPos = std::max(startPos - offset, 0);
    777     int ePos = std::min(endPos - offset, (int)m_len);
     787void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, unsigned startPos, unsigned endPos)
     788{
     789    unsigned offset = m_start;
     790    unsigned sPos = startPos > offset ? startPos - offset : 0;
     791    ASSERT(endPos >= offset);
     792    unsigned ePos = std::min(endPos - offset, static_cast<unsigned>(m_len));
    778793
    779794    if (sPos >= ePos)
     
    11141129    // Determine whether we need to measure text
    11151130    bool markerSpansWholeBox = true;
    1116     if (m_start <= (int)marker->startOffset())
     1131    if (m_start <= marker->startOffset())
    11171132        markerSpansWholeBox = false;
    11181133    if ((end() + 1) != marker->endOffset()) // end points at the last char, not past it
     
    11231138    bool isDictationMarker = marker->type() == DocumentMarker::DictationAlternatives;
    11241139    if (!markerSpansWholeBox || grammar || isDictationMarker) {
    1125         int startPosition = std::max<int>(marker->startOffset() - m_start, 0);
    1126         int endPosition = std::min<int>(marker->endOffset() - m_start, m_len);
     1140        unsigned startPosition = marker->startOffset() > m_start ? marker->startOffset() - m_start : 0;
     1141        ASSERT(marker->endOffset() >= m_start);
     1142        unsigned endPosition = std::min(marker->endOffset() - m_start, static_cast<unsigned>(m_len));
    11271143       
    11281144        if (m_truncation != cNoTruncation)
    1129             endPosition = std::min<int>(endPosition, m_truncation);
     1145            endPosition = std::min(endPosition, static_cast<unsigned>(m_truncation));
    11301146
    11311147        // Calculate start & width
     
    11741190    LayoutUnit selectionHeight = this->selectionHeight();
    11751191
    1176     int sPos = std::max(marker->startOffset() - m_start, (unsigned)0);
    1177     int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len);
     1192    unsigned sPos = marker->startOffset() > m_start ? marker->startOffset() - m_start : 0;
     1193    ASSERT(marker->endOffset() >= m_start);
     1194    unsigned ePos = std::min(marker->endOffset() - m_start, static_cast<unsigned>(m_len));
    11781195    TextRun run = constructTextRun(style, font);
    11791196
     
    12071224    LayoutUnit h = selectionHeight();
    12081225   
    1209     int sPos = std::max(marker->startOffset() - m_start, (unsigned)0);
    1210     int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len);
     1226    unsigned sPos = marker->startOffset() > m_start ? marker->startOffset() - m_start : 0;
     1227    ASSERT(marker->endOffset() >= m_start);
     1228    unsigned ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len);
    12111229    TextRun run = constructTextRun(style, font);
    12121230
     
    13151333    }
    13161334    if (paintEnd != underline.endOffset) {      // end points at the last char, not past it
    1317         paintEnd = std::min(paintEnd, (unsigned)underline.endOffset);
     1335        paintEnd = std::min(paintEnd, underline.endOffset);
    13181336        useWholeWidth = false;
    13191337    }
    13201338    if (m_truncation != cNoTruncation) {
    1321         paintEnd = std::min(paintEnd, (unsigned)m_start + m_truncation);
     1339        paintEnd = std::min(paintEnd, m_start + m_truncation);
    13221340        useWholeWidth = false;
    13231341    }
     
    13801398}
    13811399
    1382 float InlineTextBox::positionForOffset(int offset) const
     1400float InlineTextBox::positionForOffset(unsigned offset) const
    13831401{
    13841402    ASSERT(offset >= m_start);
     
    13921410    const RenderStyle& lineStyle = this->lineStyle();
    13931411    const Font& font = fontToUse(lineStyle, renderer());
    1394     int from = !isLeftToRightDirection() ? offset - m_start : 0;
    1395     int to = !isLeftToRightDirection() ? m_len : offset - m_start;
     1412    unsigned from = !isLeftToRightDirection() ? offset - m_start : 0;
     1413    unsigned to = !isLeftToRightDirection() ? m_len : offset - m_start;
    13961414    // FIXME: Do we need to add rightBearing here?
    13971415    LayoutRect selectionRect = LayoutRect(logicalLeft(), 0, 0, 0);
     
    14111429    if (string.length() != length || startPos)
    14121430        string = string.substringSharingImpl(startPos, length);
    1413 
     1431   
     1432    ASSERT(renderer().textLength() >= startPos);
    14141433    return constructTextRun(style, font, string, renderer().textLength() - startPos, charactersWithHyphen);
    14151434}
    14161435
    1417 TextRun InlineTextBox::constructTextRun(const RenderStyle& style, const Font& font, String string, int maximumLength, BufferForAppendingHyphen* charactersWithHyphen) const
    1418 {
    1419     int length = string.length();
     1436TextRun InlineTextBox::constructTextRun(const RenderStyle& style, const Font& font, String string, unsigned maximumLength, BufferForAppendingHyphen* charactersWithHyphen) const
     1437{
     1438    unsigned length = string.length();
    14201439
    14211440    if (charactersWithHyphen) {
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r170268 r170337  
    111111    LayoutUnit selectionHeight() const;
    112112
    113     TextRun constructTextRun(const RenderStyle&, const Font&, BufferForAppendingHyphen* = 0) const;
    114     TextRun constructTextRun(const RenderStyle&, const Font&, String, int maximumLength, BufferForAppendingHyphen* = 0) const;
     113    TextRun constructTextRun(const RenderStyle&, const Font&, BufferForAppendingHyphen* = nullptr) const;
     114    TextRun constructTextRun(const RenderStyle&, const Font&, String, unsigned maximumLength, BufferForAppendingHyphen* = nullptr) const;
    115115
    116116public:
    117117    virtual FloatRect calculateBoundaries() const { return FloatRect(x(), y(), width(), height()); }
    118118
    119     virtual LayoutRect localSelectionRect(int startPos, int endPos) const;
    120     bool isSelected(int startPos, int endPos) const;
    121     void selectionStartEnd(int& sPos, int& ePos);
     119    virtual LayoutRect localSelectionRect(unsigned startPos, unsigned endPos) const;
     120    bool isSelected(unsigned startPos, unsigned endPos) const;
     121    void selectionStartEnd(unsigned& sPos, unsigned& ePos);
    122122
    123123protected:
     
    159159public:
    160160    virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const;
    161     virtual float positionForOffset(int offset) const;
     161    virtual float positionForOffset(unsigned offset) const;
    162162
    163163    // Needs to be public, so the static paintTextWithShadows() function can use it.
     
    165165
    166166protected:
    167     void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, int startPos, int endPos);
     167    void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, unsigned startPos, unsigned endPos);
    168168    void paintDocumentMarkers(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, bool background);
    169169    void paintCompositionUnderline(GraphicsContext*, const FloatPoint& boxOrigin, const CompositionUnderline&);
     
    188188    InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObject
    189189
    190     int m_start;
     190    unsigned m_start;
    191191    unsigned short m_len;
    192192
  • trunk/Source/WebCore/rendering/RenderCombineText.cpp

    r170268 r170337  
    7373}
    7474
    75 void RenderCombineText::getStringToRender(int start, String& string, int& length) const
     75void RenderCombineText::getStringToRender(unsigned start, String& string, unsigned& length) const
    7676{
    77     ASSERT(start >= 0);
    7877    if (m_isCombined) {
    7978        string = originalText();
     
    8382 
    8483    string = text();
    85     string = string.substringSharingImpl(static_cast<unsigned>(start), length);
     84    string = string.substringSharingImpl(start, length);
    8685}
    8786
  • trunk/Source/WebCore/rendering/RenderCombineText.h

    r170268 r170337  
    3737    void combineText();
    3838    void adjustTextOrigin(FloatPoint& textOrigin, const FloatRect& boxRect) const;
    39     void getStringToRender(int, String& string, int& length) const;
     39    void getStringToRender(unsigned, String&, unsigned& length) const;
    4040    bool isCombined() const { return m_isCombined; }
    4141    float combinedTextWidth(const Font& font) const { return font.size(); }
  • trunk/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp

    r170268 r170337  
    107107                continue;
    108108
    109             int fragmentStartPosition = 0;
    110             int fragmentEndPosition = 0;
     109            unsigned fragmentStartPosition = 0;
     110            unsigned fragmentEndPosition = 0;
    111111
    112112            const Vector<SVGTextFragment>& fragments = textBox->textFragments();
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r170268 r170337  
    102102}
    103103
    104 float SVGInlineTextBox::positionForOffset(int) const
     104float SVGInlineTextBox::positionForOffset(unsigned) const
    105105{
    106106    // SVG doesn't use the offset <-> position selection system.
     
    138138}
    139139
    140 LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition) const
    141 {
    142     int boxStart = start();
    143     startPosition = std::max(startPosition - boxStart, 0);
    144     endPosition = std::min(endPosition - boxStart, static_cast<int>(len()));
     140LayoutRect SVGInlineTextBox::localSelectionRect(unsigned startPosition, unsigned endPosition) const
     141{
     142    unsigned boxStart = start();
     143    startPosition = startPosition > boxStart ? startPosition - boxStart : 0;
     144    ASSERT(endPosition >= boxStart);
     145    endPosition = std::min(endPosition - boxStart, len());
    145146    if (startPosition >= endPosition)
    146147        return LayoutRect();
     
    150151    AffineTransform fragmentTransform;
    151152    FloatRect selectionRect;
    152     int fragmentStartPosition = 0;
    153     int fragmentEndPosition = 0;
     153    unsigned fragmentStartPosition = 0;
     154    unsigned fragmentEndPosition = 0;
    154155
    155156    unsigned textFragmentsSize = m_textFragments.size();
     
    214215    }
    215216
    216     int startPosition, endPosition;
     217    unsigned startPosition, endPosition;
    217218    selectionStartEnd(startPosition, endPosition);
    218219
    219     int fragmentStartPosition = 0;
    220     int fragmentEndPosition = 0;
     220    unsigned fragmentStartPosition = 0;
     221    unsigned fragmentEndPosition = 0;
    221222    AffineTransform fragmentTransform;
    222223    unsigned textFragmentsSize = m_textFragments.size();
     
    441442}
    442443
    443 bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, int& startPosition, int& endPosition) const
     444bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const
    444445{
    445446    if (startPosition >= endPosition)
    446447        return false;
    447 
    448     int offset = static_cast<int>(fragment.characterOffset) - start();
    449     int length = static_cast<int>(fragment.length);
     448   
     449    ASSERT(fragment.characterOffset >= start());
     450    unsigned offset = fragment.characterOffset - start();
     451    unsigned length = fragment.length;
    450452
    451453    if (startPosition >= offset + length || endPosition <= offset)
     
    454456    if (startPosition < offset)
    455457        startPosition = 0;
    456     else
     458    else {
     459        ASSERT(startPosition >= offset);
    457460        startPosition -= offset;
     461    }
    458462
    459463    if (endPosition > offset + length)
     
    627631    ASSERT(selectionStyle);
    628632
    629     int startPosition = 0;
    630     int endPosition = 0;
     633    unsigned startPosition = 0;
     634    unsigned endPosition = 0;
    631635    if (hasSelection) {
    632636        selectionStartEnd(startPosition, endPosition);
     
    656660
    657661    // Eventually draw text using regular style from the end position of the selection to the end of the current chunk part
    658     if (endPosition < static_cast<int>(fragment.length) && !paintSelectedTextOnly)
     662    if (endPosition < fragment.length && !paintSelectedTextOnly)
    659663        paintTextWithShadows(context, style, textRun, fragment, endPosition, fragment.length);
    660664}
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h

    r170268 r170337  
    4444    virtual int selectionHeight() { return static_cast<int>(ceilf(m_logicalHeight)); }
    4545    virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const;
    46     virtual float positionForOffset(int offset) const;
     46    virtual float positionForOffset(unsigned offset) const;
    4747
    4848    void paintSelectionBackground(PaintInfo&);
    4949    virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom);
    50     virtual LayoutRect localSelectionRect(int startPosition, int endPosition) const override;
     50    virtual LayoutRect localSelectionRect(unsigned startPosition, unsigned endPosition) const override;
    5151
    52     bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, int& startPosition, int& endPosition) const;
     52    bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, unsigned& startPosition, unsigned& endPosition) const;
    5353
    5454    virtual FloatRect calculateBoundaries() const;
  • trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp

    r170268 r170337  
    3838inline bool SVGTextMetricsBuilder::currentCharacterStartsSurrogatePair() const
    3939{
    40     return U16_IS_LEAD(m_run[m_textPosition]) && int(m_textPosition + 1) < m_run.charactersLength() && U16_IS_TRAIL(m_run[m_textPosition + 1]);
     40    return U16_IS_LEAD(m_run[m_textPosition]) && m_textPosition + 1 < m_run.charactersLength() && U16_IS_TRAIL(m_run[m_textPosition + 1]);
    4141}
    4242
     
    4444{
    4545    m_textPosition += m_currentMetrics.length();
    46     if (int(m_textPosition) >= m_run.charactersLength())
     46    if (m_textPosition >= m_run.charactersLength())
    4747        return false;
    4848
  • trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp

    r170268 r170337  
    134134}
    135135
    136 bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData, const SVGTextFragment& fragment, int& startPosition, int& endPosition) const
     136bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData, const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const
    137137{
    138138    // Reuse the same logic used for text selection & painting, to map our query start/length into start/endPositions of the current text fragment.
     139    ASSERT(startPosition >= queryData->processedCharacters);
     140    ASSERT(endPosition >= queryData->processedCharacters);
    139141    startPosition -= queryData->processedCharacters;
    140142    endPosition -= queryData->processedCharacters;
    141143
    142     if (startPosition >= endPosition || startPosition < 0 || endPosition < 0)
     144    if (startPosition >= endPosition)
    143145        return false;
    144146
     
    151153}
    152154
    153 void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, int& startPosition, int& endPosition) const
     155void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, unsigned& startPosition, unsigned& endPosition) const
    154156{
    155157    SVGTextLayoutAttributes* layoutAttributes = queryData->textRenderer->layoutAttributes();
     
    182184
    183185        // If the start position maps to a character in the metrics list, we don't need to modify it.
    184         if (startPosition == static_cast<int>(positionOffset))
     186        if (startPosition == positionOffset)
    185187            alterStartPosition = false;
    186188
    187189        // If the start position maps to a character in the metrics list, we don't need to modify it.
    188         if (endPosition == static_cast<int>(positionOffset))
     190        if (endPosition == positionOffset)
    189191            alterEndPosition = false;
    190192
    191193        // Detect ligatures.
    192194        if (lastPositionOffset != -1 && lastPositionOffset - positionOffset > 1) {
    193             if (alterStartPosition && startPosition > lastPositionOffset && startPosition < static_cast<int>(positionOffset)) {
     195            if (alterStartPosition && startPosition > static_cast<unsigned>(lastPositionOffset) && startPosition < positionOffset) {
    194196                startPosition = lastPositionOffset;
    195197                alterStartPosition = false;
    196198            }
    197199
    198             if (alterEndPosition && endPosition > lastPositionOffset && endPosition < static_cast<int>(positionOffset)) {
     200            if (alterEndPosition && endPosition > static_cast<unsigned>(lastPositionOffset) && endPosition < positionOffset) {
    199201                endPosition = positionOffset;
    200202                alterEndPosition = false;
     
    213215
    214216    if (lastPositionOffset != -1 && lastPositionOffset - positionOffset > 1) {
    215         if (alterStartPosition && startPosition > lastPositionOffset && startPosition < static_cast<int>(positionOffset)) {
     217        if (alterStartPosition && startPosition > static_cast<unsigned>(lastPositionOffset) && startPosition < positionOffset) {
    216218            startPosition = lastPositionOffset;
    217219            alterStartPosition = false;
    218220        }
    219221
    220         if (alterEndPosition && endPosition > lastPositionOffset && endPosition < static_cast<int>(positionOffset)) {
     222        if (alterEndPosition && endPosition > static_cast<unsigned>(lastPositionOffset) && endPosition < positionOffset) {
    221223            endPosition = positionOffset;
    222224            alterEndPosition = false;
     
    288290    SubStringLengthData* data = static_cast<SubStringLengthData*>(queryData);
    289291
    290     int startPosition = data->startPosition;
    291     int endPosition = startPosition + data->length;
     292    unsigned startPosition = data->startPosition;
     293    unsigned endPosition = startPosition + data->length;
    292294    if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition))
    293295        return false;
     
    323325    StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterData*>(queryData);
    324326
    325     int startPosition = data->position;
    326     int endPosition = startPosition + 1;
     327    unsigned startPosition = data->position;
     328    unsigned endPosition = startPosition + 1;
    327329    if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition))
    328330        return false;
     
    372374    EndPositionOfCharacterData* data = static_cast<EndPositionOfCharacterData*>(queryData);
    373375
    374     int startPosition = data->position;
    375     int endPosition = startPosition + 1;
     376    unsigned startPosition = data->position;
     377    unsigned endPosition = startPosition + 1;
    376378    if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition))
    377379        return false;
     
    420422    RotationOfCharacterData* data = static_cast<RotationOfCharacterData*>(queryData);
    421423
    422     int startPosition = data->position;
    423     int endPosition = startPosition + 1;
     424    unsigned startPosition = data->position;
     425    unsigned endPosition = startPosition + 1;
    424426    if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition))
    425427        return false;
     
    488490    ExtentOfCharacterData* data = static_cast<ExtentOfCharacterData*>(queryData);
    489491
    490     int startPosition = data->position;
    491     int endPosition = startPosition + 1;
     492    unsigned startPosition = data->position;
     493    unsigned endPosition = startPosition + 1;
    492494    if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition))
    493495        return false;
     
    523525    FloatRect extent;
    524526    for (unsigned i = 0; i < fragment.length; ++i) {
    525         int startPosition = data->processedCharacters + i;
    526         int endPosition = startPosition + 1;
     527        unsigned startPosition = data->processedCharacters + i;
     528        unsigned endPosition = startPosition + 1;
    527529        if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition))
    528530            continue;
  • trunk/Source/WebCore/rendering/svg/SVGTextQuery.h

    r170268 r170337  
    5353
    5454    void collectTextBoxesInFlowBox(InlineFlowBox*);
    55     bool mapStartEndPositionsIntoFragmentCoordinates(Data*, const SVGTextFragment&, int& startPosition, int& endPosition) const;
    56     void modifyStartEndPositionsRespectingLigatures(Data*, int& startPosition, int& endPosition) const;
     55    bool mapStartEndPositionsIntoFragmentCoordinates(Data*, const SVGTextFragment&, unsigned& startPosition, unsigned& endPosition) const;
     56    void modifyStartEndPositionsRespectingLigatures(Data*, unsigned& startPosition, unsigned& endPosition) const;
    5757
    5858private:
  • trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp

    r170268 r170337  
    104104class SVGGlyphToPathTranslator final : public GlyphToPathTranslator {
    105105public:
    106     SVGGlyphToPathTranslator(const TextRun* const, const GlyphBuffer&, const FloatPoint&, const SVGFontData&, SVGFontElement&, const int from, const int numGlyphs, float scale, bool isVerticalText);
     106    SVGGlyphToPathTranslator(const TextRun* const, const GlyphBuffer&, const FloatPoint&, const SVGFontData&, SVGFontElement&, unsigned from, unsigned numGlyphs, float scale, bool isVerticalText);
    107107private:
    108108    virtual bool containsMorePaths() override
     
    124124    FloatPoint m_glyphOrigin;
    125125    SVGGlyph m_svgGlyph;
    126     int m_index;
     126    unsigned m_index;
    127127    Glyph m_glyph;
    128128    SVGFontElement& m_fontElement;
    129     const float m_stoppingPoint;
     129    const unsigned m_stoppingPoint;
    130130    const float m_scale;
    131131    const bool m_isVerticalText;
    132132};
    133133
    134 SVGGlyphToPathTranslator::SVGGlyphToPathTranslator(const TextRun* const textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& point, const SVGFontData& svgFontData, SVGFontElement& fontElement, const int from, const int numGlyphs, float scale, bool isVerticalText)
     134SVGGlyphToPathTranslator::SVGGlyphToPathTranslator(const TextRun* const textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& point, const SVGFontData& svgFontData, SVGFontElement& fontElement, unsigned from, unsigned numGlyphs, float scale, bool isVerticalText)
    135135    : m_textRun(textRun)
    136136    , m_glyphBuffer(glyphBuffer)
     
    288288}
    289289
    290 GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength)
     290GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, unsigned currentCharacter, unsigned& advanceLength)
    291291{
    292292    const SimpleFontData* primaryFont = font.primaryFont();
  • trunk/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h

    r170268 r170337  
    4343    void setActivePaintingResource(RenderSVGResource* object) { m_activePaintingResource = object; }
    4444
    45     virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) override;
     45    virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, unsigned currentCharacter, unsigned& advanceLength) override;
    4646    virtual void drawSVGGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const override;
    4747    virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, String& glyphName) const override;
  • trunk/Source/WebCore/svg/SVGFontData.cpp

    r170268 r170337  
    131131}
    132132
    133 bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& glyphData, bool mirror, int currentCharacter, unsigned& advanceLength) const
     133bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& glyphData, bool mirror, unsigned currentCharacter, unsigned& advanceLength) const
    134134{
    135135    const TextRun& run = iterator.run();
    136136    Vector<SVGGlyph::ArabicForm>& arabicForms = iterator.arabicForms();
    137     ASSERT(int(run.charactersLength()) >= currentCharacter);
     137    ASSERT(run.charactersLength() >= currentCharacter);
    138138
    139139    // Associate text with arabic forms, if needed.
  • trunk/Source/WebCore/svg/SVGFontData.h

    r170268 r170337  
    3737    virtual float widthForSVGGlyph(Glyph, float fontSize) const override;
    3838    virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const override;
    39     virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const override;
     39    virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, unsigned currentCharacter, unsigned& advanceLength) const override;
    4040
    4141    SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement; }
Note: See TracChangeset for help on using the changeset viewer.