From: mmaxfield@apple.com Date: Thu, 10 Jul 2014 01:42:43 +0000 (+0000) Subject: Revert r170413 and r170390 X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=1593afa2a1a1f031d336c1d5a3f2b75766b3aea1 Revert r170413 and r170390 https://bugs.webkit.org/show_bug.cgi?id=134741 Reviewed by Benjamin Poulain. These patches caused a variety of failures. I'm going to break them up into smaller chunks and commit them separately at some point in the future. Requesting a review from Ben Poulain because there were some conflicts with r170561 in InlineTextBox.cpp and InlineTextBox.h. * 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: * 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::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: (WebCore::InlineTextBox::truncation): * rendering/RenderCombineText.cpp: (WebCore::RenderCombineText::getStringToRender): * rendering/RenderCombineText.h: * rendering/RenderTextLineBoxes.cpp: (WebCore::ellipsisRectForBox): * 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: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170947 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index b8b14b3..359ab7f 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,137 @@ +2014-07-09 Myles C. Maxfield + + Revert r170413 and r170390 + https://bugs.webkit.org/show_bug.cgi?id=134741 + + Reviewed by Benjamin Poulain. + + These patches caused a variety of failures. I'm going to break them up into + smaller chunks and commit them separately at some point in the future. + + Requesting a review from Ben Poulain because there were some conflicts with + r170561 in InlineTextBox.cpp and InlineTextBox.h. + + * 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: + * 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::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: + (WebCore::InlineTextBox::truncation): + * rendering/RenderCombineText.cpp: + (WebCore::RenderCombineText::getStringToRender): + * rendering/RenderCombineText.h: + * rendering/RenderTextLineBoxes.cpp: + (WebCore::ellipsisRectForBox): + * 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: + 2014-07-08 Jeffrey Pfau Fix flaky loading tests diff --git a/Source/WebCore/WebCore.exp.in b/Source/WebCore/WebCore.exp.in index 0fd1672..0addc01 100644 --- a/Source/WebCore/WebCore.exp.in +++ b/Source/WebCore/WebCore.exp.in @@ -1868,7 +1868,7 @@ __ZNK7WebCore3URL5queryEv __ZNK7WebCore3URL8protocolEv __ZNK7WebCore3URLcvP5NSURLEv __ZNK7WebCore4Font5widthERKNS_7TextRunEPN3WTF7HashSetIPKNS_14SimpleFontDataENS4_7PtrHashIS8_EENS4_10HashTraitsIS8_EEEEPNS_13GlyphOverflowE -__ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEjiNS0_24CustomFontNotReadyActionE +__ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEiiNS0_24CustomFontNotReadyActionE __ZNK7WebCore4FonteqERKS0_ __ZNK7WebCore4Node11textContentEb __ZNK7WebCore4Node13ownerDocumentEv diff --git a/Source/WebCore/platform/graphics/Font.cpp b/Source/WebCore/platform/graphics/Font.cpp index 036cfd9..6a937a9 100644 --- a/Source/WebCore/platform/graphics/Font.cpp +++ b/Source/WebCore/platform/graphics/Font.cpp @@ -329,7 +329,7 @@ void Font::update(PassRefPtr fontSelector) const m_typesettingFeatures = computeTypesettingFeatures(); } -float Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, int initialTo, CustomFontNotReadyAction customFontNotReadyAction) const +float Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to, CustomFontNotReadyAction customFontNotReadyAction) const { // Don't draw anything while we are using custom fonts that are in the process of loading, // except if the 'force' argument is set to true (in which case it will use a fallback @@ -337,7 +337,7 @@ float Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPo if (loadingCustomFonts() && customFontNotReadyAction == DoNotPaintIfFontNotReady) return 0; - unsigned to = initialTo < 0 ? run.length() : initialTo; + to = (to == -1 ? run.length() : to); CodePath codePathToUse = codePath(run); // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050 @@ -350,12 +350,13 @@ float Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPo return drawComplexText(context, run, point, from, to); } -void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, int initialTo) const +void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const { if (loadingCustomFonts()) return; - - unsigned to = initialTo < 0 ? run.length() : initialTo; + + if (to < 0) + to = run.length(); CodePath codePathToUse = codePath(run); // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050 @@ -506,9 +507,9 @@ bool Font::fastAverageCharWidthIfAvailable(float& width) const return success; } -void Font::adjustSelectionRectForText(const TextRun& run, LayoutRect& selectionRect, unsigned from, int initialTo) const +void Font::adjustSelectionRectForText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const { - unsigned to = initialTo < 0 ? run.length() : initialTo; + to = (to == -1 ? run.length() : to); CodePath codePathToUse = codePath(run); // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050 @@ -1053,21 +1054,18 @@ bool Font::canReceiveTextEmphasis(UChar32 c) return true; } -GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, unsigned index) +GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, int index) { // In general, we want to skip descenders. However, skipping descenders on CJK characters leads to undesirable renderings, // so we want to draw through CJK characters (on a character-by-character basis). UChar32 baseCharacter; - int initialOffsetInString = glyphBuffer.offsetInString(index); + int offsetInString = glyphBuffer.offsetInString(index); - if (initialOffsetInString == GlyphBuffer::kNoOffset) { + if (offsetInString == GlyphBuffer::kNoOffset) { // We have no idea which character spawned this glyph. Bail. return GlyphToPathTranslator::GlyphUnderlineType::DrawOverGlyph; } - ASSERT(initialOffsetInString >= 0); - unsigned offsetInString = static_cast(initialOffsetInString); - if (textRun.is8Bit()) baseCharacter = textRun.characters8()[offsetInString]; else diff --git a/Source/WebCore/platform/graphics/Font.h b/Source/WebCore/platform/graphics/Font.h index f19ae6d..02b64cd 100644 --- a/Source/WebCore/platform/graphics/Font.h +++ b/Source/WebCore/platform/graphics/Font.h @@ -104,7 +104,7 @@ public: virtual void advance() = 0; virtual ~GlyphToPathTranslator() { } }; -GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun&, const GlyphBuffer&, unsigned index); +GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun&, const GlyphBuffer&, int index); class Font { public: @@ -133,9 +133,9 @@ public: void update(PassRefPtr) const; enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady }; - float drawText(GraphicsContext*, const TextRun&, const FloatPoint&, unsigned from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const; - void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&) const; - void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from = 0, int to = -1) const; + float drawText(GraphicsContext*, const TextRun&, const FloatPoint&, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const; + void drawGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int numGlyphs, const FloatPoint&) const; + void drawEmphasisMarks(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1) const; DashArray dashesForIntersectionsWithRect(const TextRun&, const FloatPoint& textOrigin, const FloatRect& lineExtents) const; @@ -147,7 +147,7 @@ public: static float width(TextLayout&, unsigned from, unsigned len, HashSet* fallbackFonts = 0); int offsetForPosition(const TextRun&, float position, bool includePartialGlyphs) const; - void adjustSelectionRectForText(const TextRun&, LayoutRect& selectionRect, unsigned from = 0, int to = -1) const; + void adjustSelectionRectForText(const TextRun&, LayoutRect& selectionRect, int from = 0, int to = -1) const; bool isSmallCaps() const { return m_fontDescription.smallCaps(); } @@ -218,14 +218,14 @@ private: enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; // Returns the initial in-stream advance. - float getGlyphsAndAdvancesForSimpleText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; - float drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, unsigned from, unsigned to) const; - void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from, unsigned to) const; + float getGlyphsAndAdvancesForSimpleText(const TextRun&, int from, int to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; + float drawSimpleText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; + void drawEmphasisMarksForSimpleText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const; void drawGlyphBuffer(GraphicsContext*, const TextRun&, const GlyphBuffer&, FloatPoint&) const; void drawEmphasisMarks(GraphicsContext*, const TextRun&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const; float floatWidthForSimpleText(const TextRun&, HashSet* fallbackFonts = 0, GlyphOverflow* = 0) const; int offsetForPositionForSimpleText(const TextRun&, float position, bool includePartialGlyphs) const; - void adjustSelectionRectForSimpleText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const; + void adjustSelectionRectForSimpleText(const TextRun&, LayoutRect& selectionRect, int from, int to) const; bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; @@ -233,12 +233,12 @@ private: static bool canExpandAroundIdeographsInComplexText(); // Returns the initial in-stream advance. - float getGlyphsAndAdvancesForComplexText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; - float drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, unsigned from, unsigned to) const; - void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from, unsigned to) const; + float getGlyphsAndAdvancesForComplexText(const TextRun&, int from, int to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; + float drawComplexText(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; + void drawEmphasisMarksForComplexText(GraphicsContext*, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, int to) const; float floatWidthForComplexText(const TextRun&, HashSet* fallbackFonts = 0, GlyphOverflow* = 0) const; int offsetForPositionForComplexText(const TextRun&, float position, bool includePartialGlyphs) const; - void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const; + void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, int from, int to) const; friend struct WidthIterator; friend class SVGTextRunRenderingContext; diff --git a/Source/WebCore/platform/graphics/FontFastPath.cpp b/Source/WebCore/platform/graphics/FontFastPath.cpp index 7f20e0b..bbed3d0 100644 --- a/Source/WebCore/platform/graphics/FontFastPath.cpp +++ b/Source/WebCore/platform/graphics/FontFastPath.cpp @@ -126,7 +126,7 @@ int Font::emphasisMarkHeight(const AtomicString& mark) const return markFontData->fontMetrics().height(); } -float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const +float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const { float initialAdvance; @@ -156,7 +156,7 @@ float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, unsigned from, return initialAdvance; } -float Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const +float Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { // This glyph buffer holds our glyphs+advances+font data for each glyph. GlyphBuffer glyphBuffer; @@ -172,7 +172,7 @@ float Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const F return startPoint.x() - startX; } -void Font::drawEmphasisMarksForSimpleText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const +void Font::drawEmphasisMarksForSimpleText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const { GlyphBuffer glyphBuffer; float initialAdvance = getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer, ForTextEmphasis); @@ -195,8 +195,8 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const G FloatPoint startPoint(point.x(), point.y() - glyphBuffer.initialAdvance().height()); float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width(); float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height(); - unsigned lastFrom = 0; - unsigned nextGlyph = 1; + int lastFrom = 0; + int nextGlyph = 1; #if ENABLE(SVG_FONTS) TextRun::RenderingContext* renderingContext = run.renderingContext(); #endif @@ -210,10 +210,7 @@ void Font::drawGlyphBuffer(GraphicsContext* context, const TextRun& run, const G renderingContext->drawSVGGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); else #endif - { - ASSERT(nextGlyph >= lastFrom); drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); - } lastFrom = nextGlyph; fontData = nextFontData; @@ -272,7 +269,7 @@ void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph(markFontData, markGlyph), point.y()); GlyphBuffer markBuffer; - for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) { + for (int i = 0; i + 1 < glyphBuffer.size(); ++i) { float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1); float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph; markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFontData, advance); @@ -299,7 +296,7 @@ float Font::floatWidthForSimpleText(const TextRun& run, HashSet()); } - int offsetInString(unsigned index) const + int offsetInString(int index) const { ASSERT(m_offsetsInString); return (*m_offsetsInString)[index]; } private: - void swap(unsigned index1, unsigned index2) + void swap(int index1, int index2) { const SimpleFontData* f = m_fontData[index1]; m_fontData[index1] = m_fontData[index2]; diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp index e09644d4..0e400ec 100644 --- a/Source/WebCore/platform/graphics/GraphicsContext.cpp +++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp @@ -74,7 +74,7 @@ public: private: const TextRun* m_textRun; - unsigned m_offset; + int m_offset; }; class InterpolationQualityMaintainer { diff --git a/Source/WebCore/platform/graphics/Latin1TextIterator.h b/Source/WebCore/platform/graphics/Latin1TextIterator.h index 6b7e599..c40189b 100644 --- a/Source/WebCore/platform/graphics/Latin1TextIterator.h +++ b/Source/WebCore/platform/graphics/Latin1TextIterator.h @@ -30,7 +30,7 @@ class Latin1TextIterator { public: // The passed in LChar pointer starts at 'currentCharacter'. The iterator operates on the range [currentCharacter, lastCharacter]. // 'endCharacter' denotes the maximum length of the UChar array, which might exceed 'lastCharacter'. - Latin1TextIterator(const LChar* characters, unsigned currentCharacter, unsigned lastCharacter, unsigned /*endCharacter*/) + Latin1TextIterator(const LChar* characters, int currentCharacter, int lastCharacter, int /*endCharacter*/) : m_characters(characters) , m_currentCharacter(currentCharacter) , m_lastCharacter(lastCharacter) @@ -53,13 +53,13 @@ public: m_currentCharacter += advanceLength; } - unsigned currentCharacter() const { return m_currentCharacter; } + int currentCharacter() const { return m_currentCharacter; } const LChar* characters() const { return m_characters; } private: const LChar* m_characters; - unsigned m_currentCharacter; - unsigned m_lastCharacter; + int m_currentCharacter; + int m_lastCharacter; }; } diff --git a/Source/WebCore/platform/graphics/SimpleFontData.h b/Source/WebCore/platform/graphics/SimpleFontData.h index 2bded5b..04a8253 100644 --- a/Source/WebCore/platform/graphics/SimpleFontData.h +++ b/Source/WebCore/platform/graphics/SimpleFontData.h @@ -89,7 +89,7 @@ public: virtual void initializeFontData(SimpleFontData*, float fontSize) = 0; virtual float widthForSVGGlyph(Glyph, float fontSize) const = 0; virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const = 0; - virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, unsigned currentCharacter, unsigned& advanceLength) const = 0; + virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const = 0; }; // Used to create platform fonts. diff --git a/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp b/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp index ce704be..9155e71 100644 --- a/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp +++ b/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp @@ -27,7 +27,7 @@ namespace WebCore { -SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, unsigned currentCharacter, unsigned lastCharacter, unsigned endCharacter) +SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, int currentCharacter, int lastCharacter, int endCharacter) : m_characters(characters) , m_currentCharacter(currentCharacter) , m_lastCharacter(lastCharacter) diff --git a/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h b/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h index 1a715c0..85c9694 100644 --- a/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h +++ b/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h @@ -30,7 +30,7 @@ class SurrogatePairAwareTextIterator { public: // The passed in UChar pointer starts at 'currentCharacter'. The iterator operatoes on the range [currentCharacter, lastCharacter]. // 'endCharacter' denotes the maximum length of the UChar array, which might exceed 'lastCharacter'. - SurrogatePairAwareTextIterator(const UChar*, unsigned currentCharacter, unsigned lastCharacter, unsigned endCharacter); + SurrogatePairAwareTextIterator(const UChar*, int currentCharacter, int lastCharacter, int endCharacter); inline bool consume(UChar32& character, unsigned& clusterLength) { @@ -52,7 +52,7 @@ public: m_currentCharacter += advanceLength; } - unsigned currentCharacter() const { return m_currentCharacter; } + int currentCharacter() const { return m_currentCharacter; } const UChar* characters() const { return m_characters; } private: @@ -60,9 +60,9 @@ private: UChar32 normalizeVoicingMarks(); const UChar* m_characters; - unsigned m_currentCharacter; - unsigned m_lastCharacter; - unsigned m_endCharacter; + int m_currentCharacter; + int m_lastCharacter; + int m_endCharacter; }; } diff --git a/Source/WebCore/platform/graphics/TextRun.h b/Source/WebCore/platform/graphics/TextRun.h index 5ba4cdf..3e1ff73 100644 --- a/Source/WebCore/platform/graphics/TextRun.h +++ b/Source/WebCore/platform/graphics/TextRun.h @@ -171,8 +171,8 @@ public: const UChar* characters16() const { ASSERT(!is8Bit()); return m_data.characters16; } bool is8Bit() const { return m_is8Bit; } - unsigned length() const { return m_len; } - unsigned charactersLength() const { return m_charactersLength; } + int length() const { return m_len; } + int charactersLength() const { return m_charactersLength; } String string() const { if (is8Bit()) @@ -217,7 +217,7 @@ public: virtual ~RenderingContext() { } #if ENABLE(SVG_FONTS) - virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, unsigned currentCharacter, unsigned& advanceLength) = 0; + virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) = 0; virtual void drawSVGGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const = 0; virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, String& glyphName) const = 0; virtual bool applySVGKerning(const SimpleFontData*, WidthIterator&, GlyphBuffer*, int from) const = 0; diff --git a/Source/WebCore/platform/graphics/WidthIterator.cpp b/Source/WebCore/platform/graphics/WidthIterator.cpp index 9889bd0..777dc297 100644 --- a/Source/WebCore/platform/graphics/WidthIterator.cpp +++ b/Source/WebCore/platform/graphics/WidthIterator.cpp @@ -68,7 +68,7 @@ WidthIterator::WidthIterator(const Font* font, const TextRun& run, HashSet, 64> CharactersTreatedAsSpace; -static inline float applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, unsigned& lastGlyphCount, const SimpleFontData* fontData, WidthIterator& iterator, TypesettingFeatures typesettingFeatures, CharactersTreatedAsSpace& charactersTreatedAsSpace) +static inline float applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int& lastGlyphCount, const SimpleFontData* fontData, WidthIterator& iterator, TypesettingFeatures typesettingFeatures, CharactersTreatedAsSpace& charactersTreatedAsSpace) { ASSERT(typesettingFeatures & (Kerning | Ligatures)); @@ -165,14 +165,14 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph const SimpleFontData* primaryFont = m_font->primaryFont(); const SimpleFontData* lastFontData = primaryFont; - unsigned lastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0; + int lastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0; UChar32 character = 0; unsigned clusterLength = 0; CharactersTreatedAsSpace charactersTreatedAsSpace; while (textIterator.consume(character, clusterLength)) { unsigned advanceLength = clusterLength; - unsigned currentCharacter = textIterator.currentCharacter(); + int currentCharacter = textIterator.currentCharacter(); const GlyphData& glyphData = glyphDataForCharacter(character, rtl, currentCharacter, advanceLength); Glyph glyph = glyphData.glyph; const SimpleFontData* fontData = glyphData.fontData; @@ -327,14 +327,14 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph return consumedCharacters; } -unsigned WidthIterator::advance(unsigned offset, GlyphBuffer* glyphBuffer) +unsigned WidthIterator::advance(int offset, GlyphBuffer* glyphBuffer) { - unsigned length = m_run.length(); + int length = m_run.length(); if (offset > length) offset = length; - if (m_currentCharacter >= offset) + if (m_currentCharacter >= static_cast(offset)) return 0; if (m_run.is8Bit()) { @@ -348,10 +348,10 @@ unsigned WidthIterator::advance(unsigned offset, GlyphBuffer* glyphBuffer) bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer) { - unsigned oldSize = glyphBuffer.size(); + int oldSize = glyphBuffer.size(); advance(m_currentCharacter + 1, &glyphBuffer); float w = 0; - for (unsigned i = oldSize; i < glyphBuffer.size(); ++i) + for (int i = oldSize; i < glyphBuffer.size(); ++i) w += glyphBuffer.advanceAt(i).width(); width = w; return glyphBuffer.size() > oldSize; diff --git a/Source/WebCore/platform/graphics/WidthIterator.h b/Source/WebCore/platform/graphics/WidthIterator.h index fdc4ba4..cd06d7c 100644 --- a/Source/WebCore/platform/graphics/WidthIterator.h +++ b/Source/WebCore/platform/graphics/WidthIterator.h @@ -41,7 +41,7 @@ struct WidthIterator { public: WidthIterator(const Font*, const TextRun&, HashSet* fallbackFonts = 0, bool accountForGlyphBounds = false, bool forTextEmphasis = false); - unsigned advance(unsigned to, GlyphBuffer*); + unsigned advance(int to, GlyphBuffer*); bool advanceOneCharacter(float& width, GlyphBuffer&); float maxGlyphBoundingBoxY() const { ASSERT(m_accountForGlyphBounds); return m_maxGlyphBoundingBoxY; } @@ -87,7 +87,7 @@ public: #endif private: - GlyphData glyphDataForCharacter(UChar32, bool mirror, unsigned currentCharacter, unsigned& advanceLength); + GlyphData glyphDataForCharacter(UChar32, bool mirror, int currentCharacter, unsigned& advanceLength); template inline unsigned advanceInternal(TextIterator&, GlyphBuffer*); diff --git a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp index 29171bf..87a2fc2 100644 --- a/Source/WebCore/platform/graphics/cairo/FontCairo.cpp +++ b/Source/WebCore/platform/graphics/cairo/FontCairo.cpp @@ -94,7 +94,7 @@ static void drawGlyphsShadow(GraphicsContext* graphicsContext, const FloatPoint& } void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, - unsigned from, unsigned numGlyphs, const FloatPoint& point) const + int from, int numGlyphs, const FloatPoint& point) const { if (!font->platformData().size()) return; @@ -102,7 +102,7 @@ void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, cons GlyphBufferGlyph* glyphs = const_cast(glyphBuffer.glyphs(from)); float offset = point.x(); - for (unsigned i = 0; i < numGlyphs; i++) { + for (int i = 0; i < numGlyphs; i++) { glyphs[i].x = offset; glyphs[i].y = point.y(); offset += glyphBuffer.advanceAt(from + i).width(); diff --git a/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp b/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp index cb08cca..e847810 100644 --- a/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp +++ b/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp @@ -38,7 +38,7 @@ namespace WebCore { -float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned, unsigned) const +float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int, int) const { GlyphBuffer glyphBuffer; HarfBuzzShaper shaper(this, run); @@ -52,7 +52,7 @@ float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const return 0; } -void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, unsigned /* from */, unsigned /* to */) const +void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const { notImplemented(); } @@ -85,7 +85,7 @@ int Font::offsetForPositionForComplexText(const TextRun& run, float x, bool) con return 0; } -void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const +void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const { HarfBuzzShaper shaper(this, run); if (shaper.shape()) { diff --git a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp index 8db0d1b..0cda5e7 100644 --- a/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp +++ b/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp @@ -254,7 +254,7 @@ void HarfBuzzShaper::setNormalizedBuffer(NormalizeMode normalizeMode) } else runCharacters = m_run.characters16(); - for (unsigned i = 0; i < m_run.length(); ++i) { + for (int i = 0; i < m_run.length(); ++i) { UChar ch = runCharacters[i]; if (::ublock_getCode(ch) == UBLOCK_COMBINING_DIACRITICAL_MARKS) { icu::Normalizer::normalize(icu::UnicodeString(runCharacters, diff --git a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp index fbe125a..8325b2f 100644 --- a/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp +++ b/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp @@ -37,7 +37,7 @@ namespace WebCore { -void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const +void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const { ComplexTextController controller(this, run); controller.advance(from); @@ -52,7 +52,7 @@ void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& sel selectionRect.setWidth(afterWidth - beforeWidth); } -float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const +float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const { float initialAdvance; @@ -75,7 +75,7 @@ float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from return initialAdvance; } -float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const +float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { // This glyph buffer holds our glyphs + advances + font data for each glyph. GlyphBuffer glyphBuffer; @@ -93,7 +93,7 @@ float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const return startPoint.x() - startX; } -void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const +void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const { GlyphBuffer glyphBuffer; float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis); diff --git a/Source/WebCore/platform/graphics/mac/FontMac.mm b/Source/WebCore/platform/graphics/mac/FontMac.mm index 6c6f141..42819db 100644 --- a/Source/WebCore/platform/graphics/mac/FontMac.mm +++ b/Source/WebCore/platform/graphics/mac/FontMac.mm @@ -184,7 +184,7 @@ static void showGlyphsWithAdvances(const FloatPoint& point, const SimpleFontData } } -void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint) const +void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const { const FontPlatformData& platformData = font->platformData(); if (!platformData.size()) @@ -468,7 +468,7 @@ private: virtual void advance() override; void moveToNextValidGlyph(); - unsigned m_index; + int m_index; const TextRun& m_textRun; const GlyphBuffer& m_glyphBuffer; const SimpleFontData* m_fontData; diff --git a/Source/WebCore/platform/graphics/win/FontCGWin.cpp b/Source/WebCore/platform/graphics/win/FontCGWin.cpp index 76b8685..10ae233 100644 --- a/Source/WebCore/platform/graphics/win/FontCGWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontCGWin.cpp @@ -128,7 +128,7 @@ static CGPathRef createPathForGlyph(HDC hdc, Glyph glyph) } void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, - unsigned from, unsigned numGlyphs, const FloatPoint& point) const + int from, int numGlyphs, const FloatPoint& point) const { CGContextRef cgContext = graphicsContext->platformContext(); bool shouldUseFontSmoothing = WebCoreShouldUseFontSmoothing(); diff --git a/Source/WebCore/platform/graphics/win/FontWin.cpp b/Source/WebCore/platform/graphics/win/FontWin.cpp index 06c6c00..c66b2c4 100644 --- a/Source/WebCore/platform/graphics/win/FontWin.cpp +++ b/Source/WebCore/platform/graphics/win/FontWin.cpp @@ -51,7 +51,7 @@ bool Font::canExpandAroundIdeographsInComplexText() return false; } -void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const +void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, int to) const { UniscribeController it(this, run); it.advance(from); @@ -67,7 +67,7 @@ void Font::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& sel selectionRect.setWidth(afterWidth - beforeWidth); } -float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const +float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const { if (forTextEmphasis) { // FIXME: Add forTextEmphasis paremeter to UniscribeController and use it. @@ -92,7 +92,7 @@ float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from return beforeWidth; } -float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const +float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { // This glyph buffer holds our glyphs + advances + font data for each glyph. GlyphBuffer glyphBuffer; @@ -109,7 +109,7 @@ float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const return startPoint.x() - startX; } -void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const +void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const { GlyphBuffer glyphBuffer; float initialAdvance = getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer, ForTextEmphasis); diff --git a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp index e0b3f63..f02848c 100644 --- a/Source/WebCore/platform/graphics/wince/FontWinCE.cpp +++ b/Source/WebCore/platform/graphics/wince/FontWinCE.cpp @@ -62,7 +62,7 @@ public: ScreenDcReleaser releaseScreenDc; void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fontData, const GlyphBuffer& glyphBuffer, - unsigned from, unsigned numGlyphs, const FloatPoint& point) const + int from, int numGlyphs, const FloatPoint& point) const { graphicsContext->drawText(fontData, glyphBuffer, from, numGlyphs, point); } @@ -206,7 +206,7 @@ static int generateComponents(TextRunComponents* components, const Font &font, c return offset; } -float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, unsigned from, unsigned to) const +float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const { if (to < 0) to = run.length(); @@ -237,7 +237,7 @@ float Font::drawComplexText(GraphicsContext* context, const TextRun& run, const return widthOfDrawnText; } -void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, unsigned /* from */, unsigned /* to */) const +void Font::drawEmphasisMarksForComplexText(GraphicsContext* /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int /* to */) const { notImplemented(); } @@ -321,7 +321,7 @@ static float cursorToX(const Font* font, const TextRunComponents& components, in } FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& pt, - int h, unsigned from, unsigned to) const + int h, int from, int to) const { TextRunComponents components; int w = generateComponents(&components, *this, run); diff --git a/Source/WebCore/rendering/InlineTextBox.cpp b/Source/WebCore/rendering/InlineTextBox.cpp index 6fe2e2f..95c46ca 100644 --- a/Source/WebCore/rendering/InlineTextBox.cpp +++ b/Source/WebCore/rendering/InlineTextBox.cpp @@ -59,7 +59,7 @@ namespace WebCore { struct SameSizeAsInlineTextBox : public InlineBox { unsigned variables[1]; - unsigned variables2[2]; + unsigned short variables2[2]; void* pointers[2]; }; @@ -196,26 +196,21 @@ LayoutUnit InlineTextBox::selectionHeight() const return root().selectionHeight(); } -bool InlineTextBox::isSelected(unsigned startPos, unsigned endPos) const +bool InlineTextBox::isSelected(int startPos, int endPos) const { - unsigned sPos = startPos > m_start ? startPos - m_start : 0; - if (endPos <= m_start) - return false; - unsigned ePos = std::min(endPos - m_start, m_len); - return sPos < ePos; + int sPos = std::max(startPos - m_start, 0); + int ePos = std::min(endPos - m_start, static_cast(m_len)); + return (sPos < ePos); } RenderObject::SelectionState InlineTextBox::selectionState() { RenderObject::SelectionState state = renderer().selectionState(); if (state == RenderObject::SelectionStart || state == RenderObject::SelectionEnd || state == RenderObject::SelectionBoth) { - int initialStartPos, initialEndPos; - renderer().selectionStartEnd(initialStartPos, initialEndPos); - ASSERT(initialStartPos >= 0 && initialEndPos >= 0); - unsigned startPos = initialStartPos; - unsigned endPos = initialEndPos; + int startPos, endPos; + renderer().selectionStartEnd(startPos, endPos); // The position after a hard line break is considered to be past its end. - unsigned lastSelectable = start() + len() - (isLineBreak() ? 1 : 0); + int lastSelectable = start() + len() - (isLineBreak() ? 1 : 0); bool start = (state != RenderObject::SelectionEnd && startPos >= m_start && startPos < m_start + m_len); bool end = (state != RenderObject::SelectionStart && endPos > m_start && endPos <= lastSelectable); @@ -236,7 +231,7 @@ RenderObject::SelectionState InlineTextBox::selectionState() if (m_truncation != cNoTruncation && root().ellipsisBox()) { EllipsisBox* ellipsis = root().ellipsisBox(); if (state != RenderObject::SelectionNone) { - unsigned start, end; + int start, end; selectionStartEnd(start, end); // The ellipsis should be considered to be selected if the end of // the selection is past the beginning of the truncation and the @@ -261,14 +256,10 @@ static const Font& fontToUse(const RenderStyle& style, const RenderText& rendere return style.font(); } -LayoutRect InlineTextBox::localSelectionRect(unsigned startPos, unsigned endPos) const +LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) const { - unsigned sPos = startPos > m_start ? startPos - m_start : 0; - - if (endPos < m_start) - return LayoutRect(); - - unsigned ePos = std::min(endPos - m_start, m_len); + int sPos = std::max(startPos - m_start, 0); + int ePos = std::min(endPos - m_start, (int)m_len); if (sPos > ePos) return LayoutRect(); @@ -283,10 +274,12 @@ LayoutRect InlineTextBox::localSelectionRect(unsigned startPos, unsigned endPos) String hyphenatedStringBuffer; bool respectHyphen = ePos == m_len && hasHyphen(); TextRun textRun = constructTextRun(lineStyle, font, respectHyphen ? &hyphenatedStringBuffer : 0); + if (respectHyphen) + endPos = textRun.length(); LayoutRect selectionRect = LayoutRect(LayoutPoint(logicalLeft(), selectionTop), LayoutSize(m_logicalWidth, selectionHeight)); // Avoid computing the font width when the entire line box is selected as an optimization. - if (sPos || ePos != m_len) + if (sPos || ePos != static_cast(m_len)) font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos); IntRect snappedSelectionRect = enclosingIntRect(selectionRect); LayoutUnit logicalWidth = snappedSelectionRect.width(); @@ -603,16 +596,15 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, } // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only). - unsigned length = m_len; - unsigned maximumLength; + int length = m_len; + int maximumLength; String string; if (!combinedText) { string = renderer().text(); - if (length != string.length() || m_start) { - ASSERT_WITH_SECURITY_IMPLICATION(m_start + length <= string.length()); + if (static_cast(length) != string.length() || m_start) { + ASSERT_WITH_SECURITY_IMPLICATION(static_cast(m_start + length) <= string.length()); string = string.substringSharingImpl(m_start, length); } - ASSERT(renderer().textLength() >= m_start); maximumLength = renderer().textLength() - m_start; } else { combinedText->getStringToRender(m_start, string, length); @@ -624,14 +616,14 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, if (hasHyphen()) length = textRun.length(); - unsigned sPos = 0; - unsigned ePos = 0; + int sPos = 0; + int ePos = 0; if (haveSelection && (paintSelectedTextOnly || paintSelectedTextSeparately)) selectionStartEnd(sPos, ePos); if (m_truncation != cNoTruncation) { - sPos = std::min(sPos, m_truncation); - ePos = std::min(ePos, m_truncation); + sPos = std::min(sPos, m_truncation); + ePos = std::min(ePos, m_truncation); length = m_truncation; } @@ -691,27 +683,22 @@ void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, context->concatCTM(rotation(boxRect, Counterclockwise)); } -void InlineTextBox::selectionStartEnd(unsigned& sPos, unsigned& ePos) +void InlineTextBox::selectionStartEnd(int& sPos, int& ePos) { - unsigned startPos, endPos; + int startPos, endPos; if (renderer().selectionState() == RenderObject::SelectionInside) { startPos = 0; endPos = renderer().textLength(); } else { - int originalStartPos, originalEndPos; - renderer().selectionStartEnd(originalStartPos, originalEndPos); - ASSERT(originalStartPos >= 0 && originalEndPos >= 0); - startPos = originalStartPos; - endPos = originalEndPos; + renderer().selectionStartEnd(startPos, endPos); if (renderer().selectionState() == RenderObject::SelectionStart) endPos = renderer().textLength(); else if (renderer().selectionState() == RenderObject::SelectionEnd) startPos = 0; } - - sPos = startPos > m_start ? startPos - m_start : 0; - ePos = endPos > m_start ? endPos - m_start : 0; - ePos = std::min(ePos, m_len); + + sPos = std::max(startPos - m_start, 0); + ePos = std::min(endPos - m_start, (int)m_len); } void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, Color textColor) @@ -721,7 +708,7 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b return; // See if we have a selection to paint at all. - unsigned sPos, ePos; + int sPos, ePos; selectionStartEnd(sPos, ePos); if (sPos >= ePos) return; @@ -740,15 +727,14 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b // If the text is truncated, let the thing being painted in the truncation // draw its own highlight. - unsigned length = m_truncation != cNoTruncation ? m_truncation : m_len; + int length = m_truncation != cNoTruncation ? m_truncation : m_len; String string = renderer().text(); - if (string.length() != length || m_start) { - ASSERT_WITH_SECURITY_IMPLICATION(m_start + length <= string.length()); + if (string.length() != static_cast(length) || m_start) { + ASSERT_WITH_SECURITY_IMPLICATION(static_cast(m_start + length) <= string.length()); string = string.substringSharingImpl(m_start, length); } - ASSERT(renderer().textLength() >= m_start); String hyphenatedStringBuffer; bool respectHyphen = ePos == length && hasHyphen(); TextRun textRun = constructTextRun(style, font, string, renderer().textLength() - m_start, respectHyphen ? &hyphenatedStringBuffer : nullptr); @@ -774,12 +760,11 @@ void InlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint& b #endif } -void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, unsigned startPos, unsigned endPos) +void InlineTextBox::paintCompositionBackground(GraphicsContext* context, const FloatPoint& boxOrigin, const RenderStyle& style, const Font& font, int startPos, int endPos) { - unsigned offset = m_start; - unsigned sPos = startPos > offset ? startPos - offset : 0; - ASSERT(endPos >= offset); - unsigned ePos = std::min(endPos - offset, m_len); + int offset = m_start; + int sPos = std::max(startPos - offset, 0); + int ePos = std::min(endPos - offset, (int)m_len); if (sPos >= ePos) return; @@ -1118,7 +1103,7 @@ void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& b // Determine whether we need to measure text bool markerSpansWholeBox = true; - if (m_start <= marker->startOffset()) + if (m_start <= (int)marker->startOffset()) markerSpansWholeBox = false; if ((end() + 1) != marker->endOffset()) // end points at the last char, not past it markerSpansWholeBox = false; @@ -1127,12 +1112,11 @@ void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& b bool isDictationMarker = marker->type() == DocumentMarker::DictationAlternatives; if (!markerSpansWholeBox || grammar || isDictationMarker) { - unsigned startPosition = marker->startOffset() > m_start ? marker->startOffset() - m_start : 0; - ASSERT(marker->endOffset() >= m_start); - unsigned endPosition = std::min(marker->endOffset() - m_start, m_len); + int startPosition = std::max(marker->startOffset() - m_start, 0); + int endPosition = std::min(marker->endOffset() - m_start, m_len); if (m_truncation != cNoTruncation) - endPosition = std::min(endPosition, m_truncation); + endPosition = std::min(endPosition, m_truncation); // Calculate start & width int deltaY = renderer().style().isFlippedLinesWritingMode() ? selectionBottom() - logicalBottom() : logicalTop() - selectionTop(); @@ -1179,9 +1163,8 @@ void InlineTextBox::paintTextMatchMarker(GraphicsContext* context, const FloatPo { LayoutUnit selectionHeight = this->selectionHeight(); - unsigned sPos = marker->startOffset() > m_start ? marker->startOffset() - m_start : 0; - ASSERT(marker->endOffset() >= m_start); - unsigned ePos = std::min(marker->endOffset() - m_start, m_len); + int sPos = std::max(marker->startOffset() - m_start, (unsigned)0); + int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len); TextRun run = constructTextRun(style, font); // Always compute and store the rect associated with this marker. The computed rect is in absolute coordinates. @@ -1213,9 +1196,8 @@ void InlineTextBox::computeRectForReplacementMarker(DocumentMarker* marker, cons LayoutUnit top = selectionTop(); LayoutUnit h = selectionHeight(); - unsigned sPos = marker->startOffset() > m_start ? marker->startOffset() - m_start : 0; - ASSERT(marker->endOffset() >= m_start); - unsigned ePos = std::min(marker->endOffset() - m_start, m_len); + int sPos = std::max(marker->startOffset() - m_start, (unsigned)0); + int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len); TextRun run = constructTextRun(style, font); // Compute and store the rect associated with this marker. @@ -1322,11 +1304,11 @@ void InlineTextBox::paintCompositionUnderline(GraphicsContext* ctx, const FloatP start = renderer().width(m_start, paintStart - m_start, textPos(), isFirstLine()); } if (paintEnd != underline.endOffset) { // end points at the last char, not past it - paintEnd = std::min(paintEnd, underline.endOffset); + paintEnd = std::min(paintEnd, (unsigned)underline.endOffset); useWholeWidth = false; } if (m_truncation != cNoTruncation) { - paintEnd = std::min(paintEnd, m_start + m_truncation); + paintEnd = std::min(paintEnd, (unsigned)m_start + m_truncation); useWholeWidth = false; } if (!useWholeWidth) { @@ -1387,7 +1369,7 @@ int InlineTextBox::offsetForPosition(float lineOffset, bool includePartialGlyphs return font.offsetForPosition(constructTextRun(lineStyle, font), lineOffset - logicalLeft(), includePartialGlyphs); } -float InlineTextBox::positionForOffset(unsigned offset) const +float InlineTextBox::positionForOffset(int offset) const { ASSERT(offset >= m_start); ASSERT(offset <= m_start + m_len); @@ -1399,8 +1381,8 @@ float InlineTextBox::positionForOffset(unsigned offset) const const RenderStyle& lineStyle = this->lineStyle(); const Font& font = fontToUse(lineStyle, renderer()); - unsigned from = !isLeftToRightDirection() ? offset - m_start : 0; - unsigned to = !isLeftToRightDirection() ? m_len : offset - m_start; + int from = !isLeftToRightDirection() ? offset - m_start : 0; + int to = !isLeftToRightDirection() ? m_len : offset - m_start; // FIXME: Do we need to add rightBearing here? LayoutRect selectionRect = LayoutRect(logicalLeft(), 0, 0, 0); TextRun run = constructTextRun(lineStyle, font); @@ -1418,8 +1400,7 @@ TextRun InlineTextBox::constructTextRun(const RenderStyle& style, const Font& fo if (string.length() != length || startPos) string = string.substringSharingImpl(startPos, length); - - ASSERT(renderer().textLength() >= startPos); + return constructTextRun(style, font, string, renderer().textLength() - startPos, hyphenatedStringBuffer); } diff --git a/Source/WebCore/rendering/InlineTextBox.h b/Source/WebCore/rendering/InlineTextBox.h index d729e4f..e074660 100644 --- a/Source/WebCore/rendering/InlineTextBox.h +++ b/Source/WebCore/rendering/InlineTextBox.h @@ -33,8 +33,8 @@ struct CompositionUnderline; class DocumentMarker; class TextPainter; -const unsigned cNoTruncation = std::numeric_limits::max(); -const unsigned cFullTruncation = std::numeric_limits::max() - 1; +const unsigned short cNoTruncation = USHRT_MAX; +const unsigned short cFullTruncation = USHRT_MAX - 1; class InlineTextBox : public InlineBox { public: @@ -69,7 +69,7 @@ public: void offsetRun(int d) { ASSERT(!isDirty()); m_start += d; } - unsigned truncation() const { return m_truncation; } + unsigned short truncation() const { return m_truncation; } virtual void markDirty(bool dirty = true) override final; @@ -110,9 +110,9 @@ private: public: virtual FloatRect calculateBoundaries() const { return FloatRect(x(), y(), width(), height()); } - virtual LayoutRect localSelectionRect(unsigned startPos, unsigned endPos) const; - bool isSelected(unsigned startPos, unsigned endPos) const; - void selectionStartEnd(unsigned& sPos, unsigned& ePos); + virtual LayoutRect localSelectionRect(int startPos, int endPos) const; + bool isSelected(int startPos, int endPos) const; + void selectionStartEnd(int& sPos, int& ePos); protected: virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom); @@ -152,13 +152,13 @@ private: public: virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const; - virtual float positionForOffset(unsigned offset) const; + virtual float positionForOffset(int offset) const; // Needs to be public, so the static paintTextWithShadows() function can use it. static FloatSize applyShadowToGraphicsContext(GraphicsContext*, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal); protected: - void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, unsigned startPos, unsigned endPos); + void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, int startPos, int endPos); void paintDocumentMarkers(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, bool background); void paintCompositionUnderline(GraphicsContext*, const FloatPoint& boxOrigin, const CompositionUnderline&); @@ -181,12 +181,12 @@ private: InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderObject InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObject - unsigned m_start; - unsigned m_len; + int m_start; + unsigned short m_len; // Where to truncate when text overflow is applied. We use special constants to // denote no truncation (the whole run paints) and full truncation (nothing paints at all). - unsigned m_truncation; + unsigned short m_truncation; }; INLINE_BOX_OBJECT_TYPE_CASTS(InlineTextBox, isInlineTextBox()) diff --git a/Source/WebCore/rendering/RenderCombineText.cpp b/Source/WebCore/rendering/RenderCombineText.cpp index cb36ffd..3f013db 100644 --- a/Source/WebCore/rendering/RenderCombineText.cpp +++ b/Source/WebCore/rendering/RenderCombineText.cpp @@ -72,8 +72,9 @@ void RenderCombineText::adjustTextOrigin(FloatPoint& textOrigin, const FloatRect textOrigin.move(boxRect.height() / 2 - ceilf(m_combinedTextWidth) / 2, style().font().pixelSize()); } -void RenderCombineText::getStringToRender(unsigned start, String& string, unsigned& length) const +void RenderCombineText::getStringToRender(int start, String& string, int& length) const { + ASSERT(start >= 0); if (m_isCombined) { string = originalText(); length = string.length(); @@ -81,7 +82,7 @@ void RenderCombineText::getStringToRender(unsigned start, String& string, unsign } string = text(); - string = string.substringSharingImpl(start, length); + string = string.substringSharingImpl(static_cast(start), length); } void RenderCombineText::combineText() diff --git a/Source/WebCore/rendering/RenderCombineText.h b/Source/WebCore/rendering/RenderCombineText.h index 4cff960..d76066a 100644 --- a/Source/WebCore/rendering/RenderCombineText.h +++ b/Source/WebCore/rendering/RenderCombineText.h @@ -36,7 +36,7 @@ public: void combineText(); void adjustTextOrigin(FloatPoint& textOrigin, const FloatRect& boxRect) const; - void getStringToRender(unsigned, String&, unsigned& length) const; + void getStringToRender(int, String&, int& length) const; bool isCombined() const { return m_isCombined; } float combinedTextWidth(const Font& font) const { return font.size(); } const Font& originalFont() const { return parent()->style().font(); } diff --git a/Source/WebCore/rendering/RenderTextLineBoxes.cpp b/Source/WebCore/rendering/RenderTextLineBoxes.cpp index b817da7..1418750 100644 --- a/Source/WebCore/rendering/RenderTextLineBoxes.cpp +++ b/Source/WebCore/rendering/RenderTextLineBoxes.cpp @@ -464,7 +464,7 @@ void RenderTextLineBoxes::setSelectionState(RenderText& renderer, RenderObject:: static IntRect ellipsisRectForBox(const InlineTextBox& box, unsigned start, unsigned end) { - unsigned truncation = box.truncation(); + unsigned short truncation = box.truncation(); if (truncation == cNoTruncation) return IntRect(); @@ -473,9 +473,8 @@ static IntRect ellipsisRectForBox(const InlineTextBox& box, unsigned start, unsi return IntRect(); IntRect rect; - unsigned ellipsisStartPosition = start > box.start() ? start - box.start() : 0; - ASSERT(end >= box.start()); - unsigned ellipsisEndPosition = std::min(end - box.start(), box.len()); + int ellipsisStartPosition = std::max(start - box.start(), 0); + int ellipsisEndPosition = std::min(end - box.start(), box.len()); // The ellipsis should be considered to be selected if the end of // the selection is past the beginning of the truncation and the diff --git a/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp b/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp index 6fb279e..17d41bd 100644 --- a/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp +++ b/Source/WebCore/rendering/svg/SVGInlineFlowBox.cpp @@ -106,8 +106,8 @@ void SVGInlineFlowBox::computeTextMatchMarkerRectForRenderer(RenderSVGInlineText if (markerStartPosition >= markerEndPosition) continue; - unsigned fragmentStartPosition = 0; - unsigned fragmentEndPosition = 0; + int fragmentStartPosition = 0; + int fragmentEndPosition = 0; const Vector& fragments = textBox->textFragments(); unsigned textFragmentsSize = fragments.size(); diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp index d083fdb..b211196 100644 --- a/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp +++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp @@ -101,7 +101,7 @@ int SVGInlineTextBox::offsetForPositionInFragment(const SVGTextFragment& fragmen return fragment.characterOffset - start() + renderer().scaledFont().offsetForPosition(textRun, position * scalingFactor, includePartialGlyphs); } -float SVGInlineTextBox::positionForOffset(unsigned) const +float SVGInlineTextBox::positionForOffset(int) const { // SVG doesn't use the offset <-> position selection system. ASSERT_NOT_REACHED(); @@ -137,15 +137,11 @@ FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& return snappedSelectionRect; } -LayoutRect SVGInlineTextBox::localSelectionRect(unsigned startPosition, unsigned endPosition) const +LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition) const { - unsigned boxStart = start(); - startPosition = startPosition > boxStart ? startPosition - boxStart : 0; - - if (endPosition < boxStart) - return LayoutRect(); - - endPosition = std::min(endPosition - boxStart, len()); + int boxStart = start(); + startPosition = std::max(startPosition - boxStart, 0); + endPosition = std::min(endPosition - boxStart, static_cast(len())); if (startPosition >= endPosition) return LayoutRect(); @@ -153,8 +149,8 @@ LayoutRect SVGInlineTextBox::localSelectionRect(unsigned startPosition, unsigned AffineTransform fragmentTransform; FloatRect selectionRect; - unsigned fragmentStartPosition = 0; - unsigned fragmentEndPosition = 0; + int fragmentStartPosition = 0; + int fragmentEndPosition = 0; unsigned textFragmentsSize = m_textFragments.size(); for (unsigned i = 0; i < textFragmentsSize; ++i) { @@ -217,11 +213,11 @@ void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo) selectionStyle = &style; } - unsigned startPosition, endPosition; + int startPosition, endPosition; selectionStartEnd(startPosition, endPosition); - unsigned fragmentStartPosition = 0; - unsigned fragmentEndPosition = 0; + int fragmentStartPosition = 0; + int fragmentEndPosition = 0; AffineTransform fragmentTransform; unsigned textFragmentsSize = m_textFragments.size(); for (unsigned i = 0; i < textFragmentsSize; ++i) { @@ -444,24 +440,21 @@ TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFrag return run; } -bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const +bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, int& startPosition, int& endPosition) const { if (startPosition >= endPosition) return false; - - ASSERT(fragment.characterOffset >= start()); - unsigned offset = fragment.characterOffset - start(); - unsigned length = fragment.length; + + int offset = static_cast(fragment.characterOffset) - start(); + int length = static_cast(fragment.length); if (startPosition >= offset + length || endPosition <= offset) return false; if (startPosition < offset) startPosition = 0; - else { - ASSERT(startPosition >= offset); + else startPosition -= offset; - } if (endPosition > offset + length) endPosition = length; @@ -633,8 +626,8 @@ void SVGInlineTextBox::paintText(GraphicsContext* context, RenderStyle* style, R ASSERT(style); ASSERT(selectionStyle); - unsigned startPosition = 0; - unsigned endPosition = 0; + int startPosition = 0; + int endPosition = 0; if (hasSelection) { selectionStartEnd(startPosition, endPosition); hasSelection = mapStartEndPositionsIntoFragmentCoordinates(fragment, startPosition, endPosition); @@ -662,7 +655,7 @@ void SVGInlineTextBox::paintText(GraphicsContext* context, RenderStyle* style, R SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, *style); // Eventually draw text using regular style from the end position of the selection to the end of the current chunk part - if (endPosition < fragment.length && !paintSelectedTextOnly) + if (endPosition < static_cast(fragment.length) && !paintSelectedTextOnly) paintTextWithShadows(context, style, textRun, fragment, endPosition, fragment.length); } diff --git a/Source/WebCore/rendering/svg/SVGInlineTextBox.h b/Source/WebCore/rendering/svg/SVGInlineTextBox.h index 518ea1b..f0894f0 100644 --- a/Source/WebCore/rendering/svg/SVGInlineTextBox.h +++ b/Source/WebCore/rendering/svg/SVGInlineTextBox.h @@ -43,13 +43,13 @@ public: virtual int selectionTop() { return top(); } virtual int selectionHeight() { return static_cast(ceilf(m_logicalHeight)); } virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const; - virtual float positionForOffset(unsigned offset) const; + virtual float positionForOffset(int offset) const; void paintSelectionBackground(PaintInfo&); virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom); - virtual LayoutRect localSelectionRect(unsigned startPosition, unsigned endPosition) const override; + virtual LayoutRect localSelectionRect(int startPosition, int endPosition) const override; - bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, unsigned& startPosition, unsigned& endPosition) const; + bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, int& startPosition, int& endPosition) const; virtual FloatRect calculateBoundaries() const; diff --git a/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp b/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp index 1cb5bc2..e60102d 100644 --- a/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp +++ b/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp @@ -37,13 +37,13 @@ SVGTextMetricsBuilder::SVGTextMetricsBuilder() inline bool SVGTextMetricsBuilder::currentCharacterStartsSurrogatePair() const { - return U16_IS_LEAD(m_run[m_textPosition]) && m_textPosition + 1 < m_run.charactersLength() && U16_IS_TRAIL(m_run[m_textPosition + 1]); + return U16_IS_LEAD(m_run[m_textPosition]) && int(m_textPosition + 1) < m_run.charactersLength() && U16_IS_TRAIL(m_run[m_textPosition + 1]); } bool SVGTextMetricsBuilder::advance() { m_textPosition += m_currentMetrics.length(); - if (m_textPosition >= m_run.charactersLength()) + if (int(m_textPosition) >= m_run.charactersLength()) return false; if (m_isComplexText) diff --git a/Source/WebCore/rendering/svg/SVGTextQuery.cpp b/Source/WebCore/rendering/svg/SVGTextQuery.cpp index 71ddf81..e468416 100644 --- a/Source/WebCore/rendering/svg/SVGTextQuery.cpp +++ b/Source/WebCore/rendering/svg/SVGTextQuery.cpp @@ -133,15 +133,13 @@ bool SVGTextQuery::executeQuery(Data* queryData, ProcessTextFragmentCallback fra return false; } -bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData, const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const +bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData, const SVGTextFragment& fragment, int& startPosition, int& endPosition) const { // Reuse the same logic used for text selection & painting, to map our query start/length into start/endPositions of the current text fragment. - ASSERT(startPosition >= queryData->processedCharacters); - ASSERT(endPosition >= queryData->processedCharacters); startPosition -= queryData->processedCharacters; endPosition -= queryData->processedCharacters; - if (startPosition >= endPosition) + if (startPosition >= endPosition || startPosition < 0 || endPosition < 0) return false; modifyStartEndPositionsRespectingLigatures(queryData, startPosition, endPosition); @@ -152,7 +150,7 @@ bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData, return true; } -void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, unsigned& startPosition, unsigned& endPosition) const +void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, int& startPosition, int& endPosition) const { SVGTextLayoutAttributes* layoutAttributes = queryData->textRenderer->layoutAttributes(); Vector& textMetricsValues = layoutAttributes->textMetricsValues(); @@ -183,21 +181,21 @@ void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, u break; // If the start position maps to a character in the metrics list, we don't need to modify it. - if (startPosition == positionOffset) + if (startPosition == static_cast(positionOffset)) alterStartPosition = false; // If the start position maps to a character in the metrics list, we don't need to modify it. - if (endPosition == positionOffset) + if (endPosition == static_cast(positionOffset)) alterEndPosition = false; // Detect ligatures. if (lastPositionOffset != -1 && lastPositionOffset - positionOffset > 1) { - if (alterStartPosition && startPosition > static_cast(lastPositionOffset) && startPosition < positionOffset) { + if (alterStartPosition && startPosition > lastPositionOffset && startPosition < static_cast(positionOffset)) { startPosition = lastPositionOffset; alterStartPosition = false; } - if (alterEndPosition && endPosition > static_cast(lastPositionOffset) && endPosition < positionOffset) { + if (alterEndPosition && endPosition > lastPositionOffset && endPosition < static_cast(positionOffset)) { endPosition = positionOffset; alterEndPosition = false; } @@ -214,12 +212,12 @@ void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, u return; if (lastPositionOffset != -1 && lastPositionOffset - positionOffset > 1) { - if (alterStartPosition && startPosition > static_cast(lastPositionOffset) && startPosition < positionOffset) { + if (alterStartPosition && startPosition > lastPositionOffset && startPosition < static_cast(positionOffset)) { startPosition = lastPositionOffset; alterStartPosition = false; } - if (alterEndPosition && endPosition > static_cast(lastPositionOffset) && endPosition < positionOffset) { + if (alterEndPosition && endPosition > lastPositionOffset && endPosition < static_cast(positionOffset)) { endPosition = positionOffset; alterEndPosition = false; } @@ -289,8 +287,8 @@ bool SVGTextQuery::subStringLengthCallback(Data* queryData, const SVGTextFragmen { SubStringLengthData* data = static_cast(queryData); - unsigned startPosition = data->startPosition; - unsigned endPosition = startPosition + data->length; + int startPosition = data->startPosition; + int endPosition = startPosition + data->length; if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) return false; @@ -324,8 +322,8 @@ bool SVGTextQuery::startPositionOfCharacterCallback(Data* queryData, const SVGTe { StartPositionOfCharacterData* data = static_cast(queryData); - unsigned startPosition = data->position; - unsigned endPosition = startPosition + 1; + int startPosition = data->position; + int endPosition = startPosition + 1; if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) return false; @@ -373,8 +371,8 @@ bool SVGTextQuery::endPositionOfCharacterCallback(Data* queryData, const SVGText { EndPositionOfCharacterData* data = static_cast(queryData); - unsigned startPosition = data->position; - unsigned endPosition = startPosition + 1; + int startPosition = data->position; + int endPosition = startPosition + 1; if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) return false; @@ -421,8 +419,8 @@ bool SVGTextQuery::rotationOfCharacterCallback(Data* queryData, const SVGTextFra { RotationOfCharacterData* data = static_cast(queryData); - unsigned startPosition = data->position; - unsigned endPosition = startPosition + 1; + int startPosition = data->position; + int endPosition = startPosition + 1; if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) return false; @@ -489,8 +487,8 @@ bool SVGTextQuery::extentOfCharacterCallback(Data* queryData, const SVGTextFragm { ExtentOfCharacterData* data = static_cast(queryData); - unsigned startPosition = data->position; - unsigned endPosition = startPosition + 1; + int startPosition = data->position; + int endPosition = startPosition + 1; if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) return false; @@ -524,8 +522,8 @@ bool SVGTextQuery::characterNumberAtPositionCallback(Data* queryData, const SVGT FloatRect extent; for (unsigned i = 0; i < fragment.length; ++i) { - unsigned startPosition = data->processedCharacters + i; - unsigned endPosition = startPosition + 1; + int startPosition = data->processedCharacters + i; + int endPosition = startPosition + 1; if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) continue; diff --git a/Source/WebCore/rendering/svg/SVGTextQuery.h b/Source/WebCore/rendering/svg/SVGTextQuery.h index 38730a3..721b2df 100644 --- a/Source/WebCore/rendering/svg/SVGTextQuery.h +++ b/Source/WebCore/rendering/svg/SVGTextQuery.h @@ -52,8 +52,8 @@ private: bool executeQuery(Data*, ProcessTextFragmentCallback) const; void collectTextBoxesInFlowBox(InlineFlowBox*); - bool mapStartEndPositionsIntoFragmentCoordinates(Data*, const SVGTextFragment&, unsigned& startPosition, unsigned& endPosition) const; - void modifyStartEndPositionsRespectingLigatures(Data*, unsigned& startPosition, unsigned& endPosition) const; + bool mapStartEndPositionsIntoFragmentCoordinates(Data*, const SVGTextFragment&, int& startPosition, int& endPosition) const; + void modifyStartEndPositionsRespectingLigatures(Data*, int& startPosition, int& endPosition) const; private: bool numberOfCharactersCallback(Data*, const SVGTextFragment&) const; diff --git a/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp b/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp index 2129848..6177386 100644 --- a/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp +++ b/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.cpp @@ -103,7 +103,7 @@ bool SVGTextRunRenderingContext::applySVGKerning(const SimpleFontData* fontData, class SVGGlyphToPathTranslator final : public GlyphToPathTranslator { public: - SVGGlyphToPathTranslator(const TextRun* const, const GlyphBuffer&, const FloatPoint&, const SVGFontData&, SVGFontElement&, unsigned from, unsigned numGlyphs, float scale, bool isVerticalText); + SVGGlyphToPathTranslator(const TextRun* const, const GlyphBuffer&, const FloatPoint&, const SVGFontData&, SVGFontElement&, const int from, const int numGlyphs, float scale, bool isVerticalText); private: virtual bool containsMorePaths() override { @@ -123,15 +123,15 @@ private: FloatPoint m_currentPoint; FloatPoint m_glyphOrigin; SVGGlyph m_svgGlyph; - unsigned m_index; + int m_index; Glyph m_glyph; SVGFontElement& m_fontElement; - const unsigned m_stoppingPoint; + const float m_stoppingPoint; const float m_scale; const bool m_isVerticalText; }; -SVGGlyphToPathTranslator::SVGGlyphToPathTranslator(const TextRun* const textRun, const GlyphBuffer& glyphBuffer, const FloatPoint& point, const SVGFontData& svgFontData, SVGFontElement& fontElement, unsigned from, unsigned numGlyphs, float scale, bool isVerticalText) +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) : m_textRun(textRun) , m_glyphBuffer(glyphBuffer) , m_svgFontData(svgFontData) @@ -287,7 +287,7 @@ void SVGTextRunRenderingContext::drawSVGGlyphs(GraphicsContext* context, const S } } -GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, unsigned currentCharacter, unsigned& advanceLength) +GlyphData SVGTextRunRenderingContext::glyphDataForCharacter(const Font& font, WidthIterator& iterator, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) { const SimpleFontData* primaryFont = font.primaryFont(); ASSERT(primaryFont); diff --git a/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h b/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h index 1dd646b..d0b91f6 100644 --- a/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h +++ b/Source/WebCore/rendering/svg/SVGTextRunRenderingContext.h @@ -42,7 +42,7 @@ public: RenderSVGResource* activePaintingResource() const { return m_activePaintingResource; } void setActivePaintingResource(RenderSVGResource* object) { m_activePaintingResource = object; } - virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, unsigned currentCharacter, unsigned& advanceLength) override; + virtual GlyphData glyphDataForCharacter(const Font&, WidthIterator&, UChar32 character, bool mirror, int currentCharacter, unsigned& advanceLength) override; virtual void drawSVGGlyphs(GraphicsContext*, const SimpleFontData*, const GlyphBuffer&, int from, int to, const FloatPoint&) const override; virtual float floatWidthUsingSVGFont(const Font&, const TextRun&, int& charsConsumed, String& glyphName) const override; virtual bool applySVGKerning(const SimpleFontData*, WidthIterator&, GlyphBuffer*, int from) const override; diff --git a/Source/WebCore/svg/SVGFontData.cpp b/Source/WebCore/svg/SVGFontData.cpp index 825e59f9..80710ce 100644 --- a/Source/WebCore/svg/SVGFontData.cpp +++ b/Source/WebCore/svg/SVGFontData.cpp @@ -130,11 +130,11 @@ float SVGFontData::widthForSVGGlyph(Glyph glyph, float fontSize) const return svgGlyph.horizontalAdvanceX * scaleEmToUnits(fontSize, svgFontFaceElement->unitsPerEm()); } -bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& glyphData, bool mirror, unsigned currentCharacter, unsigned& advanceLength) const +bool SVGFontData::applySVGGlyphSelection(WidthIterator& iterator, GlyphData& glyphData, bool mirror, int currentCharacter, unsigned& advanceLength) const { const TextRun& run = iterator.run(); Vector& arabicForms = iterator.arabicForms(); - ASSERT(run.charactersLength() >= currentCharacter); + ASSERT(int(run.charactersLength()) >= currentCharacter); // Associate text with arabic forms, if needed. String remainingTextInRun; diff --git a/Source/WebCore/svg/SVGFontData.h b/Source/WebCore/svg/SVGFontData.h index 3250a45..72728a1 100644 --- a/Source/WebCore/svg/SVGFontData.h +++ b/Source/WebCore/svg/SVGFontData.h @@ -36,7 +36,7 @@ public: virtual void initializeFontData(SimpleFontData*, float fontSize) override; virtual float widthForSVGGlyph(Glyph, float fontSize) const override; virtual bool fillSVGGlyphPage(GlyphPage*, unsigned offset, unsigned length, UChar* buffer, unsigned bufferLength, const SimpleFontData*) const override; - virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, unsigned currentCharacter, unsigned& advanceLength) const override; + virtual bool applySVGGlyphSelection(WidthIterator&, GlyphData&, bool mirror, int currentCharacter, unsigned& advanceLength) const override; SVGFontFaceElement* svgFontFaceElement() const { return m_svgFontFaceElement; }