Changeset 204400 in webkit
- Timestamp:
- Aug 11, 2016 6:22:55 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 52 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r204395 r204400 1 2016-08-11 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Migrate from ints to unsigneds when referring to indices into strings 4 https://bugs.webkit.org/show_bug.cgi?id=160735 5 6 Reviewed by Simon Fraser. 7 8 There are a few cases where we use ints to refer to indices into strings: 9 - A simple historical accident. These were migrated to unsigneds directly. 10 - Where we use -1 as a sentinal value. These were migrated to Optional<unsigned>. 11 12 This patch only modifies rendering code (rather than DOM code). There are a few 13 places in DOM code (such as Position and Node::maxCharacterOffset()) which also 14 erroneously use ints; however, I didn't want this change to be observable from 15 script and I wanted to keep this patch to a reasonable size. 16 17 No new tests because there is no behavior change. 18 19 * editing/FrameSelection.cpp: 20 (WebCore::FrameSelection::updateAppearance): 21 (WebCore::FrameSelection::setCaretVisibility): 22 * platform/DragImage.cpp: 23 (WebCore::createDragImageForRange): 24 * platform/graphics/FontCascade.cpp: 25 (WebCore::FontCascade::glyphBufferForTextRun): 26 (WebCore::FontCascade::drawText): 27 (WebCore::FontCascade::drawEmphasisMarks): 28 (WebCore::FontCascade::adjustSelectionRectForText): 29 (WebCore::computeUnderlineType): 30 (WebCore::FontCascade::getGlyphsAndAdvancesForSimpleText): 31 (WebCore::FontCascade::drawEmphasisMarksForSimpleText): 32 (WebCore::FontCascade::drawGlyphBuffer): 33 (WebCore::offsetToMiddleOfGlyphAtIndex): 34 (WebCore::FontCascade::adjustSelectionRectForSimpleText): 35 * platform/graphics/FontCascade.h: 36 * platform/graphics/GlyphBuffer.h: 37 (WebCore::GlyphBuffer::size): 38 (WebCore::GlyphBuffer::glyphs): 39 (WebCore::GlyphBuffer::advances): 40 (WebCore::GlyphBuffer::fontAt): 41 (WebCore::GlyphBuffer::glyphAt): 42 (WebCore::GlyphBuffer::advanceAt): 43 (WebCore::GlyphBuffer::offsetAt): 44 (WebCore::GlyphBuffer::reverse): 45 (WebCore::GlyphBuffer::offsetInString): 46 (WebCore::GlyphBuffer::shrink): 47 (WebCore::GlyphBuffer::swap): 48 * platform/graphics/GraphicsContext.cpp: 49 (WebCore::GraphicsContext::drawText): 50 (WebCore::GraphicsContext::drawGlyphs): 51 (WebCore::GraphicsContext::drawEmphasisMarks): 52 * platform/graphics/GraphicsContext.h: 53 * platform/graphics/Latin1TextIterator.h: 54 (WebCore::Latin1TextIterator::Latin1TextIterator): 55 (WebCore::Latin1TextIterator::currentCharacter): 56 * platform/graphics/SurrogatePairAwareTextIterator.cpp: 57 (WebCore::SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator): 58 * platform/graphics/SurrogatePairAwareTextIterator.h: 59 (WebCore::SurrogatePairAwareTextIterator::currentCharacter): 60 * platform/graphics/WidthIterator.cpp: 61 (WebCore::WidthIterator::applyFontTransforms): 62 (WebCore::WidthIterator::advanceInternal): 63 (WebCore::WidthIterator::advance): 64 (WebCore::WidthIterator::advanceOneCharacter): 65 * platform/graphics/WidthIterator.h: 66 * platform/graphics/cairo/FontCairo.cpp: 67 (WebCore::drawGlyphsToContext): 68 (WebCore::drawGlyphsShadow): 69 (WebCore::FontCascade::drawGlyphs): 70 * platform/graphics/cairo/FontCairoHarfbuzzNG.cpp: 71 (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText): 72 (WebCore::FontCascade::drawEmphasisMarksForComplexText): 73 (WebCore::FontCascade::adjustSelectionRectForComplexText): 74 * platform/graphics/cocoa/FontCascadeCocoa.mm: 75 (WebCore::fillVectorWithHorizontalGlyphPositions): 76 (WebCore::showLetterpressedGlyphsWithAdvances): 77 (WebCore::showGlyphsWithAdvances): 78 (WebCore::FontCascade::drawGlyphs): 79 (WebCore::FontCascade::dashesForIntersectionsWithRect): 80 (WebCore::FontCascade::adjustSelectionRectForComplexText): 81 (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText): 82 (WebCore::FontCascade::drawEmphasisMarksForComplexText): 83 * platform/graphics/displaylists/DisplayListRecorder.cpp: 84 (WebCore::DisplayList::Recorder::drawGlyphs): 85 * platform/graphics/displaylists/DisplayListRecorder.h: 86 * platform/graphics/harfbuzz/HarfBuzzShaper.cpp: 87 (WebCore::HarfBuzzShaper::selectionRect): 88 * platform/graphics/harfbuzz/HarfBuzzShaper.h: 89 * platform/graphics/mac/ComplexTextController.h: 90 * platform/graphics/win/FontCGWin.cpp: 91 (WebCore::FontCascade::drawGlyphs): 92 * platform/graphics/win/FontWin.cpp: 93 (WebCore::FontCascade::adjustSelectionRectForComplexText): 94 (WebCore::FontCascade::getGlyphsAndAdvancesForComplexText): 95 (WebCore::FontCascade::drawEmphasisMarksForComplexText): 96 * rendering/EllipsisBox.cpp: 97 (WebCore::EllipsisBox::paintSelection): 98 * rendering/InlineTextBox.cpp: 99 (WebCore::InlineTextBox::isSelected): 100 (WebCore::InlineTextBox::selectionState): 101 (WebCore::InlineTextBox::localSelectionRect): 102 (WebCore::InlineTextBox::paint): 103 (WebCore::InlineTextBox::clampedOffset): 104 (WebCore::InlineTextBox::selectionStartEnd): 105 (WebCore::InlineTextBox::paintSelection): 106 (WebCore::InlineTextBox::paintCompositionBackground): 107 (WebCore::InlineTextBox::paintDocumentMarker): 108 (WebCore::InlineTextBox::paintTextMatchMarker): 109 (WebCore::InlineTextBox::positionForOffset): 110 * rendering/InlineTextBox.h: 111 (WebCore::InlineTextBox::offsetRun): 112 (WebCore::InlineTextBox::InlineTextBox): Deleted. 113 * rendering/RenderBlock.cpp: 114 (WebCore::RenderBlock::localCaretRect): 115 * rendering/RenderBlock.h: 116 * rendering/RenderBox.cpp: 117 (WebCore::RenderBox::localCaretRect): 118 * rendering/RenderBox.h: 119 * rendering/RenderInline.cpp: 120 (WebCore::RenderInline::localCaretRect): 121 * rendering/RenderInline.h: 122 * rendering/RenderLineBreak.cpp: 123 (WebCore::RenderLineBreak::localCaretRect): 124 * rendering/RenderLineBreak.h: 125 * rendering/RenderObject.cpp: 126 (WebCore::RenderObject::selectionStartEnd): 127 (WebCore::RenderObject::localCaretRect): 128 * rendering/RenderObject.h: 129 * rendering/RenderReplaced.cpp: 130 (WebCore::RenderReplaced::isSelected): 131 * rendering/RenderText.cpp: 132 (WebCore::RenderText::localCaretRect): 133 (WebCore::RenderText::collectSelectionRectsForLineBoxes): 134 * rendering/RenderText.h: 135 * rendering/RenderTextLineBoxes.cpp: 136 (WebCore::RenderTextLineBoxes::setSelectionState): 137 * rendering/RenderView.cpp: 138 (WebCore::RenderView::subtreeSelectionBounds): 139 (WebCore::RenderView::repaintSubtreeSelection): 140 (WebCore::RenderView::setSelection): 141 (WebCore::RenderView::splitSelectionBetweenSubtrees): 142 (WebCore::RenderView::clearSubtreeSelection): 143 (WebCore::RenderView::applySubtreeSelection): 144 (WebCore::RenderView::getSelection): 145 (WebCore::RenderView::clearSelection): 146 (WebCore::RenderView::RenderView): Deleted. 147 * rendering/RenderView.h: 148 * rendering/SelectionSubtreeRoot.cpp: 149 (WebCore::SelectionSubtreeRoot::adjustForVisibleSelection): 150 (WebCore::SelectionSubtreeRoot::SelectionSubtreeRoot): Deleted. 151 * rendering/SelectionSubtreeRoot.h: 152 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::SelectionSubtreeData): 153 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::selectionStartPos): 154 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::selectionEndPos): 155 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::selectionClear): 156 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::selectionStartEndPositions): 157 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::setSelectionStartPos): 158 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::setSelectionEndPos): 159 (WebCore::SelectionSubtreeRoot::SelectionSubtreeData::clearSelection): 160 (WebCore::SelectionSubtreeRoot::OldSelectionData::OldSelectionData): Deleted. 161 * rendering/TextPainter.cpp: 162 (WebCore::TextPainter::drawTextOrEmphasisMarks): 163 (WebCore::TextPainter::paintTextWithShadows): 164 (WebCore::TextPainter::paintTextAndEmphasisMarksIfNeeded): 165 (WebCore::TextPainter::paintText): 166 * rendering/TextPainter.h: 167 (WebCore::TextPainter::addEmphasis): 168 * rendering/svg/RenderSVGInlineText.cpp: 169 (WebCore::RenderSVGInlineText::localCaretRect): 170 * rendering/svg/RenderSVGInlineText.h: 171 * rendering/svg/SVGInlineTextBox.cpp: 172 (WebCore::SVGInlineTextBox::positionForOffset): 173 (WebCore::SVGInlineTextBox::selectionRectForTextFragment): 174 (WebCore::SVGInlineTextBox::localSelectionRect): 175 (WebCore::SVGInlineTextBox::paintSelectionBackground): 176 (WebCore::SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates): 177 (WebCore::SVGInlineTextBox::paintTextWithShadows): 178 (WebCore::SVGInlineTextBox::paintText): 179 * rendering/svg/SVGInlineTextBox.h: 180 * rendering/svg/SVGTextQuery.cpp: 181 (WebCore::SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates): 182 (WebCore::SVGTextQuery::modifyStartEndPositionsRespectingLigatures): 183 (WebCore::SVGTextQuery::subStringLengthCallback): 184 (WebCore::SVGTextQuery::startPositionOfCharacterCallback): 185 (WebCore::SVGTextQuery::endPositionOfCharacterCallback): 186 (WebCore::SVGTextQuery::rotationOfCharacterCallback): 187 (WebCore::calculateGlyphBoundaries): 188 (WebCore::SVGTextQuery::extentOfCharacterCallback): 189 (WebCore::SVGTextQuery::characterNumberAtPositionCallback): 190 * rendering/svg/SVGTextQuery.h: 191 1 192 2016-08-11 Alex Christensen <achristensen@webkit.org> 2 193 -
trunk/Source/WebCore/editing/FrameSelection.cpp
r202292 r204400 2089 2089 if (startPos.isNotNull() && endPos.isNotNull() && selection.visibleStart() != selection.visibleEnd()) { 2090 2090 RenderObject* startRenderer = startPos.deprecatedNode()->renderer(); 2091 int startOffset = startPos.deprecatedEditingOffset(); 2091 2092 RenderObject* endRenderer = endPos.deprecatedNode()->renderer(); 2092 view->setSelection(startRenderer, startPos.deprecatedEditingOffset(), endRenderer, endPos.deprecatedEditingOffset()); 2093 int endOffset = endPos.deprecatedEditingOffset(); 2094 ASSERT(startOffset >= 0 && endOffset >= 0); 2095 view->setSelection(startRenderer, startOffset, endRenderer, endOffset); 2093 2096 } 2094 2097 } … … 2099 2102 return; 2100 2103 2101 // FIXME: We shouldn't trigger a synchr nouslylayout here.2104 // FIXME: We shouldn't trigger a synchronous layout here. 2102 2105 if (m_frame) 2103 2106 updateSelectionByUpdatingLayoutOrStyle(*m_frame); -
trunk/Source/WebCore/platform/DragImage.cpp
r194496 r204400 142 142 RenderObject* startRenderer; 143 143 RenderObject* endRenderer; 144 intstartOffset;145 intendOffset;144 Optional<unsigned> startOffset; 145 Optional<unsigned> endOffset; 146 146 }; 147 147 … … 175 175 176 176 SnapshotOptions options = SnapshotOptionsPaintSelectionOnly | (forceBlackText ? SnapshotOptionsForceBlackText : SnapshotOptionsNone); 177 view->setSelection(startRenderer, start.deprecatedEditingOffset(), endRenderer, end.deprecatedEditingOffset(), RenderView::RepaintNothing); 177 int startOffset = start.deprecatedEditingOffset(); 178 int endOffset = end.deprecatedEditingOffset(); 179 ASSERT(startOffset >= 0 && endOffset >= 0); 180 view->setSelection(startRenderer, startOffset, endRenderer, endOffset, RenderView::RepaintNothing); 178 181 // We capture using snapshotFrameRect() because we fake up the selection using 179 182 // FrameView but snapshotSelection() uses the selection from the Frame itself. -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r203330 r204400 295 295 } 296 296 297 float FontCascade::glyphBufferForTextRun(CodePath codePathToUse, const TextRun& run, int from, intto, GlyphBuffer& glyphBuffer) const297 float FontCascade::glyphBufferForTextRun(CodePath codePathToUse, const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer) const 298 298 { 299 299 if (codePathToUse != Complex) … … 302 302 } 303 303 304 float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, intto, CustomFontNotReadyAction customFontNotReadyAction) const304 float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, unsigned from, Optional<unsigned> to, CustomFontNotReadyAction customFontNotReadyAction) const 305 305 { 306 306 // Don't draw anything while we are using custom fonts that are in the process of loading, … … 310 310 return 0; 311 311 312 to = (to == -1 ? run.length() : to);312 unsigned destination = to.valueOr(run.length()); 313 313 314 314 CodePath codePathToUse = codePath(run); 315 315 // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050 316 if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || static_cast<unsigned>(to)!= run.length()))316 if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || destination != run.length())) 317 317 codePathToUse = Complex; 318 318 319 319 GlyphBuffer glyphBuffer; 320 float startX = point.x() + glyphBufferForTextRun(codePathToUse, run, from, to, glyphBuffer);320 float startX = point.x() + glyphBufferForTextRun(codePathToUse, run, from, destination, glyphBuffer); 321 321 // We couldn't generate any glyphs for the run. Give up. 322 322 if (glyphBuffer.isEmpty()) … … 328 328 } 329 329 330 void FontCascade::drawEmphasisMarks(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, intto) const330 void FontCascade::drawEmphasisMarks(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, Optional<unsigned> to) const 331 331 { 332 332 if (isLoadingCustomFonts()) 333 333 return; 334 334 335 if (to < 0) 336 to = run.length(); 335 unsigned destination = to.valueOr(run.length()); 337 336 338 337 CodePath codePathToUse = codePath(run); 339 338 // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050 340 if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || static_cast<unsigned>(to)!= run.length()))339 if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || destination != run.length())) 341 340 codePathToUse = Complex; 342 341 343 342 if (codePathToUse != Complex) 344 drawEmphasisMarksForSimpleText(context, run, mark, point, from, to);343 drawEmphasisMarksForSimpleText(context, run, mark, point, from, destination); 345 344 else 346 drawEmphasisMarksForComplexText(context, run, mark, point, from, to);345 drawEmphasisMarksForComplexText(context, run, mark, point, from, destination); 347 346 } 348 347 … … 492 491 } 493 492 494 void FontCascade::adjustSelectionRectForText(const TextRun& run, LayoutRect& selectionRect, int from, intto) const495 { 496 to = (to == -1 ? run.length() : to);493 void FontCascade::adjustSelectionRectForText(const TextRun& run, LayoutRect& selectionRect, unsigned from, Optional<unsigned> to) const 494 { 495 unsigned destination = to.valueOr(run.length()); 497 496 498 497 CodePath codePathToUse = codePath(run); 499 498 // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050 500 if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || static_cast<unsigned>(to)!= run.length()))499 if (codePathToUse != Complex && (enableKerning() || requiresShaping()) && (from || destination != run.length())) 501 500 codePathToUse = Complex; 502 501 503 502 if (codePathToUse != Complex) 504 return adjustSelectionRectForSimpleText(run, selectionRect, from, to);505 506 return adjustSelectionRectForComplexText(run, selectionRect, from, to);503 return adjustSelectionRectForSimpleText(run, selectionRect, from, destination); 504 505 return adjustSelectionRectForComplexText(run, selectionRect, from, destination); 507 506 } 508 507 … … 1124 1123 } 1125 1124 1126 GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, intindex)1125 GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun& textRun, const GlyphBuffer& glyphBuffer, unsigned index) 1127 1126 { 1128 1127 // In general, we want to skip descenders. However, skipping descenders on CJK characters leads to undesirable renderings, … … 1239 1238 } 1240 1239 1241 float FontCascade::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, intto, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const1240 float FontCascade::getGlyphsAndAdvancesForSimpleText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const 1242 1241 { 1243 1242 float initialAdvance; … … 1269 1268 } 1270 1269 1271 void FontCascade::drawEmphasisMarksForSimpleText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, intto) const1270 void FontCascade::drawEmphasisMarksForSimpleText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const 1272 1271 { 1273 1272 GlyphBuffer glyphBuffer; … … 1288 1287 float nextX = startPoint.x() + glyphBuffer.advanceAt(0).width(); 1289 1288 float nextY = startPoint.y() + glyphBuffer.advanceAt(0).height(); 1290 intlastFrom = 0;1291 intnextGlyph = 1;1289 unsigned lastFrom = 0; 1290 unsigned nextGlyph = 1; 1292 1291 while (nextGlyph < glyphBuffer.size()) { 1293 1292 const Font* nextFontData = glyphBuffer.fontAt(nextGlyph); … … 1322 1321 } 1323 1322 1324 inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, size_ti)1323 inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, unsigned i) 1325 1324 { 1326 1325 return offsetToMiddleOfGlyph(glyphBuffer.fontAt(i), glyphBuffer.glyphAt(i)); … … 1345 1344 1346 1345 GlyphBuffer markBuffer; 1347 for ( inti = 0; i + 1 < glyphBuffer.size(); ++i) {1346 for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) { 1348 1347 float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1); 1349 1348 float advance = glyphBuffer.advanceAt(i).width() - middleOfLastGlyph + middleOfNextGlyph; … … 1372 1371 } 1373 1372 1374 void FontCascade::adjustSelectionRectForSimpleText(const TextRun& run, LayoutRect& selectionRect, int from, intto) const1373 void FontCascade::adjustSelectionRectForSimpleText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const 1375 1374 { 1376 1375 GlyphBuffer glyphBuffer; -
trunk/Source/WebCore/platform/graphics/FontCascade.h
r198074 r204400 106 106 virtual ~GlyphToPathTranslator() { } 107 107 }; 108 GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun&, const GlyphBuffer&, intindex);108 GlyphToPathTranslator::GlyphUnderlineType computeUnderlineType(const TextRun&, const GlyphBuffer&, unsigned index); 109 109 110 110 class TextLayoutDeleter { … … 134 134 135 135 enum CustomFontNotReadyAction { DoNotPaintIfFontNotReady, UseFallbackIfFontNotReady }; 136 WEBCORE_EXPORT float drawText(GraphicsContext&, const TextRun&, const FloatPoint&, int from = 0, int to = -1, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const;137 static void drawGlyphs(GraphicsContext&, const Font&, const GlyphBuffer&, int from, intnumGlyphs, const FloatPoint&, FontSmoothingMode);138 void drawEmphasisMarks(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1) const;136 WEBCORE_EXPORT float drawText(GraphicsContext&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = Nullopt, CustomFontNotReadyAction = DoNotPaintIfFontNotReady) const; 137 static void drawGlyphs(GraphicsContext&, const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&, FontSmoothingMode); 138 void drawEmphasisMarks(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = Nullopt) const; 139 139 140 140 DashArray dashesForIntersectionsWithRect(const TextRun&, const FloatPoint& textOrigin, const FloatRect& lineExtents) const; … … 146 146 147 147 int offsetForPosition(const TextRun&, float position, bool includePartialGlyphs) const; 148 void adjustSelectionRectForText(const TextRun&, LayoutRect& selectionRect, int from = 0, int to = -1) const;148 void adjustSelectionRectForText(const TextRun&, LayoutRect& selectionRect, unsigned from = 0, Optional<unsigned> to = Nullopt) const; 149 149 150 150 bool isSmallCaps() const { return m_fontDescription.variantCaps() == FontVariantCaps::Small; } … … 219 219 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; 220 220 221 float glyphBufferForTextRun(CodePath, const TextRun&, int from, intto, GlyphBuffer&) const;221 float glyphBufferForTextRun(CodePath, const TextRun&, unsigned from, unsigned to, GlyphBuffer&) const; 222 222 // Returns the initial in-stream advance. 223 float getGlyphsAndAdvancesForSimpleText(const TextRun&, int from, intto, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;224 void drawEmphasisMarksForSimpleText(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, intto) const;223 float getGlyphsAndAdvancesForSimpleText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; 224 void drawEmphasisMarksForSimpleText(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from, unsigned to) const; 225 225 void drawGlyphBuffer(GraphicsContext&, const GlyphBuffer&, FloatPoint&) const; 226 226 void drawEmphasisMarks(GraphicsContext&, const GlyphBuffer&, const AtomicString&, const FloatPoint&) const; 227 227 float floatWidthForSimpleText(const TextRun&, HashSet<const Font*>* fallbackFonts = 0, GlyphOverflow* = 0) const; 228 228 int offsetForPositionForSimpleText(const TextRun&, float position, bool includePartialGlyphs) const; 229 void adjustSelectionRectForSimpleText(const TextRun&, LayoutRect& selectionRect, int from, intto) const;229 void adjustSelectionRectForSimpleText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const; 230 230 231 231 Optional<GlyphData> getEmphasisMarkGlyphData(const AtomicString&) const; … … 235 235 236 236 // Returns the initial in-stream advance. 237 float getGlyphsAndAdvancesForComplexText(const TextRun&, int from, intto, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const;238 void drawEmphasisMarksForComplexText(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, int from, intto) const;237 float getGlyphsAndAdvancesForComplexText(const TextRun&, unsigned from, unsigned to, GlyphBuffer&, ForTextEmphasisOrNot = NotForTextEmphasis) const; 238 void drawEmphasisMarksForComplexText(GraphicsContext&, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from, unsigned to) const; 239 239 float floatWidthForComplexText(const TextRun&, HashSet<const Font*>* fallbackFonts = 0, GlyphOverflow* = 0) const; 240 240 int offsetForPositionForComplexText(const TextRun&, float position, bool includePartialGlyphs) const; 241 void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, int from, intto) const;241 void adjustSelectionRectForComplexText(const TextRun&, LayoutRect& selectionRect, unsigned from, unsigned to) const; 242 242 243 243 static std::pair<unsigned, bool> expansionOpportunityCountInternal(const LChar*, size_t length, TextDirection, ExpansionBehavior); -
trunk/Source/WebCore/platform/graphics/GlyphBuffer.h
r182236 r204400 78 78 public: 79 79 bool isEmpty() const { return m_font.isEmpty(); } 80 intsize() const { return m_font.size(); }80 unsigned size() const { return m_font.size(); } 81 81 82 82 void clear() … … 92 92 } 93 93 94 GlyphBufferGlyph* glyphs( intfrom) { return m_glyphs.data() + from; }95 GlyphBufferAdvance* advances( intfrom) { return m_advances.data() + from; }96 const GlyphBufferGlyph* glyphs( intfrom) const { return m_glyphs.data() + from; }97 const GlyphBufferAdvance* advances( intfrom) const { return m_advances.data() + from; }98 99 const Font* fontAt( intindex) const { return m_font[index]; }94 GlyphBufferGlyph* glyphs(unsigned from) { return m_glyphs.data() + from; } 95 GlyphBufferAdvance* advances(unsigned from) { return m_advances.data() + from; } 96 const GlyphBufferGlyph* glyphs(unsigned from) const { return m_glyphs.data() + from; } 97 const GlyphBufferAdvance* advances(unsigned from) const { return m_advances.data() + from; } 98 99 const Font* fontAt(unsigned index) const { return m_font[index]; } 100 100 101 101 void setInitialAdvance(GlyphBufferAdvance initialAdvance) { m_initialAdvance = initialAdvance; } … … 105 105 float leadingExpansion() const { return m_leadingExpansion; } 106 106 107 Glyph glyphAt( intindex) const107 Glyph glyphAt(unsigned index) const 108 108 { 109 109 #if USE(CAIRO) … … 114 114 } 115 115 116 GlyphBufferAdvance advanceAt( intindex) const116 GlyphBufferAdvance advanceAt(unsigned index) const 117 117 { 118 118 return m_advances[index]; 119 119 } 120 120 121 FloatSize offsetAt( intindex) const121 FloatSize offsetAt(unsigned index) const 122 122 { 123 123 #if PLATFORM(WIN) … … 181 181 #endif 182 182 183 void reverse( int from, intlength)184 { 185 for ( inti = from, end = from + length - 1; i < end; ++i, --end)183 void reverse(unsigned from, unsigned length) 184 { 185 for (unsigned i = from, end = from + length - 1; i < end; ++i, --end) 186 186 swap(i, end); 187 187 } … … 199 199 } 200 200 201 // FIXME: This converts from an unsigned to an int 202 int offsetInString(int index) const 201 int offsetInString(unsigned index) const 203 202 { 204 203 ASSERT(m_offsetsInString); … … 206 205 } 207 206 208 void shrink( inttruncationPoint)207 void shrink(unsigned truncationPoint) 209 208 { 210 209 m_font.shrink(truncationPoint); … … 219 218 220 219 private: 221 void swap( int index1, intindex2)220 void swap(unsigned index1, unsigned index2) 222 221 { 223 222 const Font* f = m_font[index1]; -
trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp
r201629 r204400 637 637 } 638 638 639 float GraphicsContext::drawText(const FontCascade& font, const TextRun& run, const FloatPoint& point, int from, intto)639 float GraphicsContext::drawText(const FontCascade& font, const TextRun& run, const FloatPoint& point, unsigned from, Optional<unsigned> to) 640 640 { 641 641 if (paintingDisabled()) … … 646 646 } 647 647 648 void GraphicsContext::drawGlyphs(const FontCascade& fontCascade, const Font& font, const GlyphBuffer& buffer, int from, intnumGlyphs, const FloatPoint& point)648 void GraphicsContext::drawGlyphs(const FontCascade& fontCascade, const Font& font, const GlyphBuffer& buffer, unsigned from, unsigned numGlyphs, const FloatPoint& point) 649 649 { 650 650 if (paintingDisabled()) … … 659 659 } 660 660 661 void GraphicsContext::drawEmphasisMarks(const FontCascade& font, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, intto)661 void GraphicsContext::drawEmphasisMarks(const FontCascade& font, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, Optional<unsigned> to) 662 662 { 663 663 if (paintingDisabled()) -
trunk/Source/WebCore/platform/graphics/GraphicsContext.h
r201777 r204400 382 382 TextDrawingModeFlags textDrawingMode() const { return m_state.textDrawingMode; } 383 383 384 float drawText(const FontCascade&, const TextRun&, const FloatPoint&, int from = 0, int to = -1);385 void drawGlyphs(const FontCascade&, const Font&, const GlyphBuffer&, int from, intnumGlyphs, const FloatPoint&);386 void drawEmphasisMarks(const FontCascade&, const TextRun&, const AtomicString& mark, const FloatPoint&, int from = 0, int to = -1);384 float drawText(const FontCascade&, const TextRun&, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = Nullopt); 385 void drawGlyphs(const FontCascade&, const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint&); 386 void drawEmphasisMarks(const FontCascade&, const TextRun&, const AtomicString& mark, const FloatPoint&, unsigned from = 0, Optional<unsigned> to = Nullopt); 387 387 void drawBidiText(const FontCascade&, const TextRun&, const FloatPoint&, FontCascade::CustomFontNotReadyAction = FontCascade::DoNotPaintIfFontNotReady); 388 388 -
trunk/Source/WebCore/platform/graphics/Latin1TextIterator.h
r170947 r204400 29 29 class Latin1TextIterator { 30 30 public: 31 // The passed in LChar pointer starts at 'current Character'. The iterator operates on the range [currentCharacter, lastCharacter].32 // 'endCharacter' denotes the maximum length of the UChar array, which might exceed 'last Character'.33 Latin1TextIterator(const LChar* characters, int currentCharacter, int lastCharacter, int/*endCharacter*/)31 // The passed in LChar pointer starts at 'currentIndex'. The iterator operates on the range [currentIndex, lastIndex]. 32 // 'endCharacter' denotes the maximum length of the UChar array, which might exceed 'lastIndex'. 33 Latin1TextIterator(const LChar* characters, unsigned currentIndex, unsigned lastIndex, unsigned /*endCharacter*/) 34 34 : m_characters(characters) 35 , m_current Character(currentCharacter)36 , m_last Character(lastCharacter)35 , m_currentIndex(currentIndex) 36 , m_lastIndex(lastIndex) 37 37 { 38 38 } … … 40 40 bool consume(UChar32& character, unsigned& clusterLength) 41 41 { 42 if (m_current Character >= m_lastCharacter)42 if (m_currentIndex >= m_lastIndex) 43 43 return false; 44 44 … … 51 51 { 52 52 m_characters += advanceLength; 53 m_current Character+= advanceLength;53 m_currentIndex += advanceLength; 54 54 } 55 55 56 int currentCharacter() const { return m_currentCharacter; }56 unsigned currentIndex() const { return m_currentIndex; } 57 57 const LChar* characters() const { return m_characters; } 58 58 59 59 private: 60 60 const LChar* m_characters; 61 int m_currentCharacter;62 int m_lastCharacter;61 unsigned m_currentIndex; 62 unsigned m_lastIndex; 63 63 }; 64 64 -
trunk/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp
r170947 r204400 28 28 namespace WebCore { 29 29 30 SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, int currentCharacter, int lastCharacter, int endCharacter)30 SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, unsigned currentIndex, unsigned lastIndex, unsigned endIndex) 31 31 : m_characters(characters) 32 , m_current Character(currentCharacter)33 , m_last Character(lastCharacter)34 , m_end Character(endCharacter)32 , m_currentIndex(currentIndex) 33 , m_lastIndex(lastIndex) 34 , m_endIndex(endIndex) 35 35 { 36 36 } … … 58 58 // Do we have a surrogate pair? If so, determine the full Unicode (32 bit) code point before glyph lookup. 59 59 // Make sure we have another character and it's a low surrogate. 60 if (m_current Character + 1 >= m_endCharacter)60 if (m_currentIndex + 1 >= m_endIndex) 61 61 return false; 62 62 … … 75 75 static const uint8_t hiraganaKatakanaVoicingMarksCombiningClass = 8; 76 76 77 if (m_current Character + 1 >= m_endCharacter)77 if (m_currentIndex + 1 >= m_endIndex) 78 78 return 0; 79 79 -
trunk/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h
r170947 r204400 29 29 class SurrogatePairAwareTextIterator { 30 30 public: 31 // The passed in UChar pointer starts at 'current Character'. The iterator operatoes on the range [currentCharacter, lastCharacter].32 // 'end Character' denotes the maximum length of the UChar array, which might exceed 'lastCharacter'.33 SurrogatePairAwareTextIterator(const UChar*, int currentCharacter, int lastCharacter, int endCharacter);31 // The passed in UChar pointer starts at 'currentIndex'. The iterator operatoes on the range [currentIndex, lastIndex]. 32 // 'endIndex' denotes the maximum length of the UChar array, which might exceed 'lastIndex'. 33 SurrogatePairAwareTextIterator(const UChar*, unsigned currentIndex, unsigned lastIndex, unsigned endIndex); 34 34 35 35 inline bool consume(UChar32& character, unsigned& clusterLength) 36 36 { 37 if (m_current Character >= m_lastCharacter)37 if (m_currentIndex >= m_lastIndex) 38 38 return false; 39 39 … … 50 50 { 51 51 m_characters += advanceLength; 52 m_current Character+= advanceLength;52 m_currentIndex += advanceLength; 53 53 } 54 54 55 int currentCharacter() const { return m_currentCharacter; }55 unsigned currentIndex() const { return m_currentIndex; } 56 56 const UChar* characters() const { return m_characters; } 57 57 … … 61 61 62 62 const UChar* m_characters; 63 int m_currentCharacter;64 int m_lastCharacter;65 int m_endCharacter;63 unsigned m_currentIndex; 64 unsigned m_lastIndex; 65 unsigned m_endIndex; 66 66 }; 67 67 -
trunk/Source/WebCore/platform/graphics/WidthIterator.cpp
r198074 r204400 82 82 } 83 83 84 inline auto WidthIterator::shouldApplyFontTransforms(const GlyphBuffer* glyphBuffer, intlastGlyphCount, UChar32 previousCharacter) const -> TransformsType84 inline auto WidthIterator::shouldApplyFontTransforms(const GlyphBuffer* glyphBuffer, unsigned lastGlyphCount, UChar32 previousCharacter) const -> TransformsType 85 85 { 86 86 if (glyphBuffer && glyphBuffer->size() == (lastGlyphCount + 1) && isSoftBankEmoji(previousCharacter)) … … 91 91 } 92 92 93 inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int& lastGlyphCount, const Font* font, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace)93 inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, unsigned& lastGlyphCount, const Font* font, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace) 94 94 { 95 95 ASSERT_UNUSED(previousCharacter, shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter) != WidthIterator::TransformsType::None); … … 98 98 return 0; 99 99 100 intglyphBufferSize = glyphBuffer->size();100 unsigned glyphBufferSize = glyphBuffer->size(); 101 101 if (!force && glyphBufferSize <= lastGlyphCount + 1) { 102 102 lastGlyphCount = glyphBufferSize; … … 106 106 GlyphBufferAdvance* advances = glyphBuffer->advances(0); 107 107 float widthDifference = 0; 108 for ( inti = lastGlyphCount; i < glyphBufferSize; ++i)108 for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i) 109 109 widthDifference -= advances[i].width(); 110 110 111 ASSERT(lastGlyphCount <= glyphBufferSize); 111 112 if (!ltr) 112 113 glyphBuffer->reverse(lastGlyphCount, glyphBufferSize - lastGlyphCount); … … 126 127 charactersTreatedAsSpace.clear(); 127 128 128 for ( inti = lastGlyphCount; i < glyphBufferSize; ++i)129 for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i) 129 130 widthDifference += advances[i].width(); 130 131 … … 182 183 const Font& primaryFont = m_font->primaryFont(); 183 184 const Font* lastFontData = &primaryFont; 184 intlastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0;185 unsigned lastGlyphCount = glyphBuffer ? glyphBuffer->size() : 0; 185 186 186 187 UChar32 character = 0; … … 192 193 while (textIterator.consume(character, clusterLength)) { 193 194 unsigned advanceLength = clusterLength; 194 int currentCharacter = textIterator.current Character();195 int currentCharacter = textIterator.currentIndex(); 195 196 const GlyphData& glyphData = m_font->glyphDataForCharacter(character, rtl); 196 197 Glyph glyph = glyphData.glyph; … … 350 351 } 351 352 352 unsigned consumedCharacters = textIterator.current Character() - m_currentCharacter;353 m_currentCharacter = textIterator.current Character();353 unsigned consumedCharacters = textIterator.currentIndex() - m_currentCharacter; 354 m_currentCharacter = textIterator.currentIndex(); 354 355 m_runWidthSoFar += widthSinceLastRounding; 355 356 m_finalRoundingWidth = lastRoundingWidth; … … 357 358 } 358 359 359 unsigned WidthIterator::advance( intoffset, GlyphBuffer* glyphBuffer)360 { 361 intlength = m_run.length();360 unsigned WidthIterator::advance(unsigned offset, GlyphBuffer* glyphBuffer) 361 { 362 unsigned length = m_run.length(); 362 363 363 364 if (offset > length) 364 365 offset = length; 365 366 366 if (m_currentCharacter >= static_cast<unsigned>(offset))367 if (m_currentCharacter >= offset) 367 368 return 0; 368 369 … … 378 379 bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer) 379 380 { 380 intoldSize = glyphBuffer.size();381 unsigned oldSize = glyphBuffer.size(); 381 382 advance(m_currentCharacter + 1, &glyphBuffer); 382 383 float w = 0; 383 for ( inti = oldSize; i < glyphBuffer.size(); ++i)384 for (unsigned i = oldSize; i < glyphBuffer.size(); ++i) 384 385 w += glyphBuffer.advanceAt(i).width(); 385 386 width = w; -
trunk/Source/WebCore/platform/graphics/WidthIterator.h
r198074 r204400 43 43 WidthIterator(const FontCascade*, const TextRun&, HashSet<const Font*>* fallbackFonts = 0, bool accountForGlyphBounds = false, bool forTextEmphasis = false); 44 44 45 unsigned advance( intto, GlyphBuffer*);45 unsigned advance(unsigned to, GlyphBuffer*); 46 46 bool advanceOneCharacter(float& width, GlyphBuffer&); 47 47 … … 71 71 72 72 enum class TransformsType { None, Forced, NotForced }; 73 TransformsType shouldApplyFontTransforms(const GlyphBuffer*, intlastGlyphCount, UChar32 previousCharacter) const;74 float applyFontTransforms(GlyphBuffer*, bool ltr, int& lastGlyphCount, const Font*, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);73 TransformsType shouldApplyFontTransforms(const GlyphBuffer*, unsigned lastGlyphCount, UChar32 previousCharacter) const; 74 float applyFontTransforms(GlyphBuffer*, bool ltr, unsigned& lastGlyphCount, const Font*, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&); 75 75 76 76 HashSet<const Font*>* m_fallbackFonts { nullptr }; -
trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
r200919 r204400 48 48 namespace WebCore { 49 49 50 static void drawGlyphsToContext(cairo_t* context, const Font& font, GlyphBufferGlyph* glyphs, intnumGlyphs)50 static void drawGlyphsToContext(cairo_t* context, const Font& font, GlyphBufferGlyph* glyphs, unsigned numGlyphs) 51 51 { 52 52 cairo_matrix_t originalTransform; … … 67 67 } 68 68 69 static void drawGlyphsShadow(GraphicsContext& graphicsContext, const FloatPoint& point, const Font& font, GlyphBufferGlyph* glyphs, intnumGlyphs)69 static void drawGlyphsShadow(GraphicsContext& graphicsContext, const FloatPoint& point, const Font& font, GlyphBufferGlyph* glyphs, unsigned numGlyphs) 70 70 { 71 71 ShadowBlur& shadow = graphicsContext.platformContext()->shadowBlur(); … … 99 99 100 100 void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const GlyphBuffer& glyphBuffer, 101 int from, intnumGlyphs, const FloatPoint& point, FontSmoothingMode)101 unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode) 102 102 { 103 103 if (!font.platformData().size()) … … 107 107 108 108 float offset = point.x(); 109 for ( inti = 0; i < numGlyphs; i++) {109 for (unsigned i = 0; i < numGlyphs; i++) { 110 110 glyphs[i].x = offset; 111 111 glyphs[i].y = point.y(); … … 230 230 231 231 private: 232 intm_index;232 unsigned m_index; 233 233 const TextRun& m_textRun; 234 234 const GlyphBuffer& m_glyphBuffer; -
trunk/Source/WebCore/platform/graphics/cairo/FontCairoHarfbuzzNG.cpp
r194132 r204400 41 41 namespace WebCore { 42 42 43 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int, int, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot /* forTextEmphasis */) const43 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned, unsigned, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot /* forTextEmphasis */) const 44 44 { 45 45 HarfBuzzShaper shaper(this, run); … … 53 53 } 54 54 55 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, int /* from */, int/* to */) const55 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& /* context */, const TextRun& /* run */, const AtomicString& /* mark */, const FloatPoint& /* point */, unsigned /* from */, unsigned /* to */) const 56 56 { 57 57 notImplemented(); … … 86 86 } 87 87 88 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, intto) const88 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const 89 89 { 90 90 HarfBuzzShaper shaper(this, run); -
trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
r200919 r204400 71 71 } 72 72 73 static inline void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, size_tcount)73 static inline void fillVectorWithHorizontalGlyphPositions(Vector<CGPoint, 256>& positions, CGContextRef context, const CGSize* advances, unsigned count) 74 74 { 75 75 CGAffineTransform matrix = CGAffineTransformInvert(CGContextGetTextMatrix(context)); 76 76 positions[0] = CGPointZero; 77 for ( size_ti = 1; i < count; ++i) {77 for (unsigned i = 1; i < count; ++i) { 78 78 CGSize advance = CGSizeApplyAffineTransform(advances[i - 1], matrix); 79 79 positions[i].x = positions[i - 1].x + advance.width; … … 92 92 } 93 93 94 static void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const Font& font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_tcount)94 static void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const Font& font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, unsigned count) 95 95 { 96 96 #if ENABLE(LETTERPRESS) … … 159 159 }; 160 160 161 static void showGlyphsWithAdvances(const FloatPoint& point, const Font& font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, size_tcount)161 static void showGlyphsWithAdvances(const FloatPoint& point, const Font& font, CGContextRef context, const CGGlyph* glyphs, const CGSize* advances, unsigned count) 162 162 { 163 163 if (!count) … … 183 183 184 184 CGPoint position = FloatPoint(point.x(), point.y() + font.fontMetrics().floatAscent(IdeographicBaseline) - font.fontMetrics().floatAscent()); 185 for ( size_ti = 0; i < count; ++i) {185 for (unsigned i = 0; i < count; ++i) { 186 186 CGSize translation = CGSizeApplyAffineTransform(translations[i], rotateLeftTransform); 187 187 positions[i] = CGPointApplyAffineTransform(CGPointMake(position.x - translation.width, position.y + translation.height), transform); … … 221 221 } 222 222 223 void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const GlyphBuffer& glyphBuffer, int from, intnumGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode smoothingMode)223 void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode smoothingMode) 224 224 { 225 225 const FontPlatformData& platformData = font.platformData(); … … 435 435 436 436 private: 437 intm_index;437 unsigned m_index; 438 438 const TextRun& m_textRun; 439 439 const GlyphBuffer& m_glyphBuffer; … … 489 489 MacGlyphToPathTranslator translator(run, glyphBuffer, origin); 490 490 DashArray result; 491 for ( intindex = 0; translator.containsMorePaths(); ++index, translator.advance()) {491 for (unsigned index = 0; translator.containsMorePaths(); ++index, translator.advance()) { 492 492 GlyphIterationState info = GlyphIterationState(CGPointMake(0, 0), CGPointMake(0, 0), lineExtents.y(), lineExtents.y() + lineExtents.height(), lineExtents.x() + lineExtents.width(), lineExtents.x()); 493 493 const Font* localFont = glyphBuffer.fontAt(index); … … 528 528 } 529 529 530 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, intto) const530 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const 531 531 { 532 532 ComplexTextController controller(*this, run); … … 543 543 } 544 544 545 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, intto, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const545 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const 546 546 { 547 547 float initialAdvance; … … 566 566 } 567 567 568 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, intto) const568 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const 569 569 { 570 570 GlyphBuffer glyphBuffer; -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.cpp
r198655 r204400 101 101 } 102 102 103 void Recorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, int from, intnumGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode)103 void Recorder::drawGlyphs(const Font& font, const GlyphBuffer& glyphBuffer, unsigned from, unsigned numGlyphs, const FloatPoint& startPoint, FontSmoothingMode smoothingMode) 104 104 { 105 105 DrawingItem& newItem = downcast<DrawingItem>(appendItem(DrawGlyphs::create(font, glyphBuffer.glyphs(from), glyphBuffer.advances(from), numGlyphs, FloatPoint(), toFloatSize(startPoint), smoothingMode))); -
trunk/Source/WebCore/platform/graphics/displaylists/DisplayListRecorder.h
r198655 r204400 81 81 #endif 82 82 83 void drawGlyphs(const Font&, const GlyphBuffer&, int from, intnumGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode);83 void drawGlyphs(const Font&, const GlyphBuffer&, unsigned from, unsigned numGlyphs, const FloatPoint& anchorPoint, FontSmoothingMode); 84 84 85 85 void drawImage(Image&, const FloatRect& destination, const FloatRect& source, const ImagePaintingOptions&); -
trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
r198074 r204400 98 98 } 99 99 100 intHarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition(float targetX)100 unsigned HarfBuzzShaper::HarfBuzzRun::characterIndexForXPosition(float targetX) 101 101 { 102 102 ASSERT(targetX <= m_width); … … 157 157 } 158 158 159 static void normalizeCharacters(const TextRun& run, UChar* destination, intlength)160 { 161 intposition = 0;159 static void normalizeCharacters(const TextRun& run, UChar* destination, unsigned length) 160 { 161 unsigned position = 0; 162 162 bool error = false; 163 163 const UChar* source; … … 171 171 while (position < length) { 172 172 UChar32 character; 173 intnextPosition = position;173 unsigned nextPosition = position; 174 174 U16_NEXT(source, nextPosition, length, character); 175 175 // Don't normalize tabs as they are not treated as spaces for word-end. … … 205 205 } 206 206 207 static void normalizeSpacesAndMirrorChars(const UChar* source, UChar* destination, intlength, HarfBuzzShaper::NormalizeMode normalizeMode)208 { 209 intposition = 0;207 static void normalizeSpacesAndMirrorChars(const UChar* source, UChar* destination, unsigned length, HarfBuzzShaper::NormalizeMode normalizeMode) 208 { 209 unsigned position = 0; 210 210 bool error = false; 211 211 // Iterate characters in source and mirror character if needed. 212 212 while (position < length) { 213 213 UChar32 character; 214 intnextPosition = position;214 unsigned nextPosition = position; 215 215 U16_NEXT(source, nextPosition, length, character); 216 216 // Don't normalize tabs as they are not treated as spaces for word-end … … 418 418 419 419 if (U_GET_GC_MASK(character) & U_GC_M_MASK) { 420 intmarkLength = clusterLength;420 unsigned markLength = clusterLength; 421 421 const UChar* markCharactersEnd = iterator.characters() + clusterLength; 422 422 while (markCharactersEnd < normalizedBufferEnd) { 423 423 UChar32 nextCharacter; 424 intnextCharacterLength = 0;424 unsigned nextCharacterLength = 0; 425 425 U16_NEXT(markCharactersEnd, nextCharacterLength, normalizedBufferEnd - markCharactersEnd, nextCharacter); 426 426 if (!(U_GET_GC_MASK(nextCharacter) & U_GC_M_MASK)) … … 447 447 currentCharacterPosition = iterator.characters(); 448 448 } 449 unsigned numCharactersOfCurrentRun = iterator.current Character() - startIndexOfCurrentRun;449 unsigned numCharactersOfCurrentRun = iterator.currentIndex() - startIndexOfCurrentRun; 450 450 hb_script_t script = hb_icu_script_to_script(currentScript); 451 451 m_harfBuzzRuns.append(std::make_unique<HarfBuzzRun>(currentFontData, startIndexOfCurrentRun, numCharactersOfCurrentRun, m_run.direction(), script)); 452 452 currentFontData = nextFontData; 453 startIndexOfCurrentRun = iterator.current Character();453 startIndexOfCurrentRun = iterator.currentIndex(); 454 454 } while (iterator.consume(character, clusterLength)); 455 455 … … 641 641 } 642 642 643 FloatRect HarfBuzzShaper::selectionRect(const FloatPoint& point, int height, int from, intto)643 FloatRect HarfBuzzShaper::selectionRect(const FloatPoint& point, int height, unsigned from, unsigned to) 644 644 { 645 645 float currentX = 0; … … 654 654 if (m_run.rtl()) 655 655 currentX -= m_harfBuzzRuns[i]->width(); 656 intnumCharacters = m_harfBuzzRuns[i]->numCharacters();657 if (!foundFromX && from >= 0 && from< numCharacters) {656 unsigned numCharacters = m_harfBuzzRuns[i]->numCharacters(); 657 if (!foundFromX && from < numCharacters) { 658 658 fromX = m_harfBuzzRuns[i]->xPositionForOffset(from) + currentX; 659 659 foundFromX = true; 660 } else 660 } else { 661 ASSERT(from >= numCharacters); 661 662 from -= numCharacters; 662 663 if (!foundToX && to >= 0 && to < numCharacters) { 663 } 664 665 if (!foundToX && to < numCharacters) { 664 666 toX = m_harfBuzzRuns[i]->xPositionForOffset(to) + currentX; 665 667 foundToX = true; 666 } else 668 } else { 669 ASSERT(to >= numCharacters); 667 670 to -= numCharacters; 671 } 668 672 669 673 if (foundFromX && foundToX) -
trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.h
r183234 r204400 60 60 float totalWidth() { return m_totalWidth; } 61 61 int offsetForPosition(float targetX); 62 FloatRect selectionRect(const FloatPoint&, int height, int from, intto);62 FloatRect selectionRect(const FloatPoint&, int height, unsigned from, unsigned to); 63 63 64 64 private: … … 71 71 void setWidth(float width) { m_width = width; } 72 72 73 intcharacterIndexForXPosition(float targetX);73 unsigned characterIndexForXPosition(float targetX); 74 74 float xPositionForOffset(unsigned offset); 75 75 … … 89 89 const Font* m_fontData; 90 90 unsigned m_startIndex; 91 size_tm_numCharacters;91 unsigned m_numCharacters; 92 92 unsigned m_numGlyphs; 93 93 TextDirection m_direction; -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h
r199735 r204400 55 55 56 56 // Advance and emit glyphs up to the specified character. 57 void advance(unsigned to, GlyphBuffer* = 0, GlyphIterationStyle = IncludePartialGlyphs, HashSet<const Font*>* fallbackFonts = 0);57 void advance(unsigned to, GlyphBuffer* = nullptr, GlyphIterationStyle = IncludePartialGlyphs, HashSet<const Font*>* fallbackFonts = nullptr); 58 58 59 59 // Compute the character offset for a given x coordinate. -
trunk/Source/WebCore/platform/graphics/win/FontCGWin.cpp
r194966 r204400 129 129 130 130 void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font, const GlyphBuffer& glyphBuffer, 131 int from, intnumGlyphs, const FloatPoint& point, FontSmoothingMode smoothingMode)131 unsigned from, unsigned numGlyphs, const FloatPoint& point, FontSmoothingMode smoothingMode) 132 132 { 133 133 CGContextRef cgContext = graphicsContext.platformContext(); -
trunk/Source/WebCore/platform/graphics/win/FontWin.cpp
r198074 r204400 51 51 } 52 52 53 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, int from, intto) const53 void FontCascade::adjustSelectionRectForComplexText(const TextRun& run, LayoutRect& selectionRect, unsigned from, unsigned to) const 54 54 { 55 55 UniscribeController it(this, run); … … 67 67 } 68 68 69 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, intto, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const69 float FontCascade::getGlyphsAndAdvancesForComplexText(const TextRun& run, unsigned from, unsigned to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const 70 70 { 71 71 if (forTextEmphasis) { … … 92 92 } 93 93 94 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, intto) const94 void FontCascade::drawEmphasisMarksForComplexText(GraphicsContext& context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, unsigned from, unsigned to) const 95 95 { 96 96 GlyphBuffer glyphBuffer; -
trunk/Source/WebCore/rendering/EllipsisBox.cpp
r203681 r204400 137 137 LayoutRect selectionRect = LayoutRect(x() + paintOffset.x(), y() + paintOffset.y() + rootBox.selectionTop(), 0, rootBox.selectionHeight()); 138 138 TextRun run = RenderBlock::constructTextRun(m_str, style, AllowTrailingExpansion); 139 font.adjustSelectionRectForText(run, selectionRect , 0, -1);139 font.adjustSelectionRectForText(run, selectionRect); 140 140 context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), c); 141 141 } -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r204276 r204400 131 131 } 132 132 133 bool InlineTextBox::isSelected(int startPos, int endPos) const 134 { 135 int sPos = std::max(startPos - m_start, 0); 136 int ePos = std::min(endPos - m_start, static_cast<int>(m_len)); 137 return (sPos < ePos); 133 bool InlineTextBox::isSelected(unsigned startPos, unsigned endPos) const 134 { 135 int sPos = clampedOffset(startPos); 136 int ePos = clampedOffset(endPos); 137 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=160786 138 // We should only be checking if sPos >= ePos here, because those are the 139 // indices used to actually generate the selection rect. Allowing us past this guard 140 // on any other condition creates zero-width selection rects. 141 return sPos < ePos || (startPos == endPos && startPos >= start() && startPos <= (start() + len())); 138 142 } 139 143 … … 142 146 RenderObject::SelectionState state = renderer().selectionState(); 143 147 if (state == RenderObject::SelectionStart || state == RenderObject::SelectionEnd || state == RenderObject::SelectionBoth) { 144 intstartPos, endPos;148 unsigned startPos, endPos; 145 149 renderer().selectionStartEnd(startPos, endPos); 146 150 // The position after a hard line break is considered to be past its end. 147 int lastSelectable = start() + len() - (isLineBreak() ? 1 : 0); 151 ASSERT(start() + len() >= (isLineBreak() ? 1 : 0)); 152 unsigned lastSelectable = start() + len() - (isLineBreak() ? 1 : 0); 148 153 149 154 bool start = (state != RenderObject::SelectionEnd && startPos >= m_start && startPos < m_start + m_len); … … 166 171 EllipsisBox* ellipsis = root().ellipsisBox(); 167 172 if (state != RenderObject::SelectionNone) { 168 intselectionStart;169 intselectionEnd;173 unsigned selectionStart; 174 unsigned selectionEnd; 170 175 std::tie(selectionStart, selectionEnd) = selectionStartEnd(); 171 176 // The ellipsis should be considered to be selected if the end of … … 192 197 } 193 198 194 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos) const 195 { 196 int sPos = std::max(startPos - m_start, 0); 197 int ePos = std::min(endPos - m_start, (int)m_len); 198 199 if (sPos > ePos) 199 LayoutRect InlineTextBox::localSelectionRect(unsigned startPos, unsigned endPos) const 200 { 201 unsigned sPos = clampedOffset(startPos); 202 unsigned ePos = clampedOffset(endPos); 203 204 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=160786 205 // We should only be checking if sPos >= ePos here, because those are the 206 // indices used to actually generate the selection rect. Allowing us past this guard 207 // on any other condition creates zero-width selection rects. 208 if (sPos >= ePos && !(startPos == endPos && startPos >= start() && startPos <= (start() + len()))) 200 209 return LayoutRect(); 201 210 … … 213 222 LayoutRect selectionRect = LayoutRect(LayoutPoint(logicalLeft(), selectionTop), LayoutSize(m_logicalWidth, selectionHeight)); 214 223 // Avoid computing the font width when the entire line box is selected as an optimization. 215 if (sPos || ePos != static_cast<int>(m_len))224 if (sPos || ePos != m_len) 216 225 font.adjustSelectionRectForText(textRun, selectionRect, sPos, ePos); 217 226 IntRect snappedSelectionRect = enclosingIntRect(selectionRect); … … 509 518 unsigned length = textRun.length(); 510 519 511 intselectionStart = 0;512 intselectionEnd = 0;520 unsigned selectionStart = 0; 521 unsigned selectionEnd = 0; 513 522 if (haveSelection && (paintSelectedTextOnly || paintSelectedTextSeparately)) 514 523 std::tie(selectionStart, selectionEnd) = selectionStartEnd(); 515 524 516 525 if (m_truncation != cNoTruncation) { 517 selectionStart = std::min <int>(selectionStart, m_truncation);518 selectionEnd = std::min <int>(selectionEnd, m_truncation);526 selectionStart = std::min(selectionStart, static_cast<unsigned>(m_truncation)); 527 selectionEnd = std::min(selectionEnd, static_cast<unsigned>(m_truncation)); 519 528 length = m_truncation; 520 529 } 521 530 522 int emphasisMarkOffset = 0;531 float emphasisMarkOffset = 0; 523 532 bool emphasisMarkAbove; 524 533 bool hasTextEmphasis = emphasisMarkExistsAndIsAbove(lineStyle, emphasisMarkAbove); … … 588 597 } 589 598 590 std::pair<int, int> InlineTextBox::selectionStartEnd() const 599 unsigned InlineTextBox::clampedOffset(unsigned x) const 600 { 601 return std::max(std::min(x, start() + len()), start()) - start(); 602 } 603 604 std::pair<unsigned, unsigned> InlineTextBox::selectionStartEnd() const 591 605 { 592 606 auto selectionState = renderer().selectionState(); … … 594 608 return { 0, m_len }; 595 609 596 intstart;597 intend;610 unsigned start; 611 unsigned end; 598 612 renderer().selectionStartEnd(start, end); 599 613 if (selectionState == RenderObject::SelectionStart) … … 601 615 else if (selectionState == RenderObject::SelectionEnd) 602 616 start = 0; 603 return { std::max(start - m_start, 0), std::min<int>(end - m_start, m_len) };617 return { clampedOffset(start), clampedOffset(end) }; 604 618 } 605 619 … … 611 625 612 626 // See if we have a selection to paint at all. 613 intselectionStart;614 intselectionEnd;627 unsigned selectionStart; 628 unsigned selectionEnd; 615 629 std::tie(selectionStart, selectionEnd) = selectionStartEnd(); 616 630 if (selectionStart >= selectionEnd) … … 635 649 636 650 String hyphenatedString; 637 bool respectHyphen = selectionEnd == static_cast<int>(length)&& hasHyphen();651 bool respectHyphen = selectionEnd == length && hasHyphen(); 638 652 if (respectHyphen) 639 653 hyphenatedString = hyphenatedStringForTextRun(style, length); … … 661 675 } 662 676 663 void InlineTextBox::paintCompositionBackground(GraphicsContext& context, const FloatPoint& boxOrigin, const RenderStyle& style, const FontCascade& font, int startPos, int endPos) 664 { 665 int offset = m_start; 666 int selectionStart = std::max(startPos - offset, 0); 667 int selectionEnd = std::min<int>(endPos - offset, m_len); 677 void InlineTextBox::paintCompositionBackground(GraphicsContext& context, const FloatPoint& boxOrigin, const RenderStyle& style, const FontCascade& font, unsigned startPos, unsigned endPos) 678 { 679 unsigned selectionStart = clampedOffset(startPos); 680 unsigned selectionEnd = clampedOffset(endPos); 668 681 if (selectionStart >= selectionEnd) 669 682 return; … … 757 770 // Determine whether we need to measure text 758 771 bool markerSpansWholeBox = true; 759 if (m_start <= (int)marker.startOffset())772 if (m_start <= marker.startOffset()) 760 773 markerSpansWholeBox = false; 761 774 if ((end() + 1) != marker.endOffset()) // end points at the last char, not past it … … 766 779 bool isDictationMarker = marker.type() == DocumentMarker::DictationAlternatives; 767 780 if (!markerSpansWholeBox || grammar || isDictationMarker) { 768 int startPosition = std::max<int>(marker.startOffset() - m_start, 0);769 int endPosition = std::min<int>(marker.endOffset() - m_start, m_len);781 unsigned startPosition = clampedOffset(marker.startOffset()); 782 unsigned endPosition = clampedOffset(marker.endOffset()); 770 783 771 784 if (m_truncation != cNoTruncation) 772 endPosition = std::min <int>(endPosition, m_truncation);785 endPosition = std::min(endPosition, static_cast<unsigned>(m_truncation)); 773 786 774 787 // Calculate start & width … … 819 832 LayoutRect selectionRect = LayoutRect(boxOrigin.x(), boxOrigin.y() - deltaY, 0, this->selectionHeight()); 820 833 821 int sPos = std::max<int>(marker.startOffset() - m_start, 0);822 int ePos = std::min<int>(marker.endOffset() - m_start, m_len);834 unsigned sPos = clampedOffset(marker.startOffset()); 835 unsigned ePos = clampedOffset(marker.endOffset()); 823 836 TextRun run = constructTextRun(style); 824 837 font.adjustSelectionRectForText(run, selectionRect, sPos, ePos); … … 986 999 } 987 1000 988 float InlineTextBox::positionForOffset( intoffset) const1001 float InlineTextBox::positionForOffset(unsigned offset) const 989 1002 { 990 1003 ASSERT(offset >= m_start); 991 ASSERT(offset <= m_start + m_len);1004 ASSERT(offset <= m_start + len()); 992 1005 993 1006 if (isLineBreak()) … … 996 1009 const RenderStyle& lineStyle = this->lineStyle(); 997 1010 const FontCascade& font = fontToUse(lineStyle, renderer()); 998 int from = !isLeftToRightDirection() ? offset - m_start: 0;999 int to = !isLeftToRightDirection() ? m_len : offset - m_start;1011 unsigned from = !isLeftToRightDirection() ? clampedOffset(offset) : 0; 1012 unsigned to = !isLeftToRightDirection() ? m_len : clampedOffset(offset); 1000 1013 // FIXME: Do we need to add rightBearing here? 1001 1014 LayoutRect selectionRect = LayoutRect(logicalLeft(), 0, 0, 0); -
trunk/Source/WebCore/rendering/InlineTextBox.h
r204276 r204400 43 43 explicit InlineTextBox(RenderText& renderer) 44 44 : InlineBox(renderer) 45 , m_prevTextBox(nullptr)46 , m_nextTextBox(nullptr)47 , m_start(0)48 , m_len(0)49 , m_truncation(cNoTruncation)50 45 { 51 46 setBehavesLikeText(true); … … 70 65 void setLen(unsigned len) { m_len = len; } 71 66 72 void offsetRun(int d) { ASSERT(!isDirty()); m_start += d; }67 void offsetRun(int d) { ASSERT(!isDirty()); ASSERT(d > 0 || m_start >= static_cast<unsigned>(-d)); m_start += d; } 73 68 74 69 unsigned short truncation() const { return m_truncation; } … … 121 116 FloatRect calculateBoundaries() const override { return FloatRect(x(), y(), width(), height()); } 122 117 123 virtual LayoutRect localSelectionRect( int startPos, intendPos) const;124 bool isSelected( int startPos, intendPos) const;125 std::pair< int, int> selectionStartEnd() const;118 virtual LayoutRect localSelectionRect(unsigned startPos, unsigned endPos) const; 119 bool isSelected(unsigned startPos, unsigned endPos) const; 120 std::pair<unsigned, unsigned> selectionStartEnd() const; 126 121 127 122 protected: … … 156 151 public: 157 152 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) const; 158 virtual float positionForOffset( intoffset) const;153 virtual float positionForOffset(unsigned offset) const; 159 154 160 155 protected: 161 void paintCompositionBackground(GraphicsContext&, const FloatPoint& boxOrigin, const RenderStyle&, const FontCascade&, int startPos, intendPos);156 void paintCompositionBackground(GraphicsContext&, const FloatPoint& boxOrigin, const RenderStyle&, const FontCascade&, unsigned startPos, unsigned endPos); 162 157 void paintDocumentMarkers(GraphicsContext&, const FloatPoint& boxOrigin, const RenderStyle&, const FontCascade&, bool background); 163 158 void paintCompositionUnderline(GraphicsContext&, const FloatPoint& boxOrigin, const CompositionUnderline&); 159 unsigned clampedOffset(unsigned) const; 164 160 165 161 private: … … 174 170 void behavesLikeText() const = delete; 175 171 176 InlineTextBox* m_prevTextBox ; // The previous box that also uses our RenderObject177 InlineTextBox* m_nextTextBox ; // The next box that also uses our RenderObject172 InlineTextBox* m_prevTextBox { nullptr }; // The previous box that also uses our RenderObject 173 InlineTextBox* m_nextTextBox { nullptr }; // The next box that also uses our RenderObject 178 174 179 int m_start;180 unsigned short m_len ;175 unsigned m_start { 0 }; 176 unsigned short m_len { 0 }; 181 177 182 178 // Where to truncate when text overflow is applied. We use special constants to 183 179 // denote no truncation (the whole run paints) and full truncation (nothing paints at all). 184 unsigned short m_truncation ;180 unsigned short m_truncation { cNoTruncation }; 185 181 }; 186 182 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r203708 r204400 3490 3490 } 3491 3491 3492 LayoutRect RenderBlock::localCaretRect(InlineBox* inlineBox, intcaretOffset, LayoutUnit* extraWidthToEndOfLine)3492 LayoutRect RenderBlock::localCaretRect(InlineBox* inlineBox, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine) 3493 3493 { 3494 3494 // Do the normal calculation in most cases. -
trunk/Source/WebCore/rendering/RenderBlock.h
r203708 r204400 477 477 void paintContinuationOutlines(PaintInfo&, const LayoutPoint&); 478 478 479 LayoutRect localCaretRect(InlineBox*, intcaretOffset, LayoutUnit* extraWidthToEndOfLine = 0) final;479 LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) final; 480 480 481 481 // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow -
trunk/Source/WebCore/rendering/RenderBox.cpp
r203738 r204400 4384 4384 } 4385 4385 4386 LayoutRect RenderBox::localCaretRect(InlineBox* box, intcaretOffset, LayoutUnit* extraWidthToEndOfLine)4386 LayoutRect RenderBox::localCaretRect(InlineBox* box, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine) 4387 4387 { 4388 4388 // VisiblePositions at offsets inside containers either a) refer to the positions before/after -
trunk/Source/WebCore/rendering/RenderBox.h
r203708 r204400 482 482 bool isUnsplittableForPagination() const; 483 483 484 LayoutRect localCaretRect(InlineBox*, intcaretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr) override;484 LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr) override; 485 485 486 486 virtual LayoutRect overflowClipRect(const LayoutPoint& location, RenderRegion*, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, PaintPhase = PaintPhaseBlockBackground); -
trunk/Source/WebCore/rendering/RenderInline.cpp
r203708 r204400 250 250 } 251 251 252 LayoutRect RenderInline::localCaretRect(InlineBox* inlineBox, int, LayoutUnit* extraWidthToEndOfLine)252 LayoutRect RenderInline::localCaretRect(InlineBox* inlineBox, unsigned, LayoutUnit* extraWidthToEndOfLine) 253 253 { 254 254 if (firstChild()) { -
trunk/Source/WebCore/rendering/RenderInline.h
r201704 r204400 97 97 void updateAlwaysCreateLineBoxes(bool fullLayout); 98 98 99 LayoutRect localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine) final;99 LayoutRect localCaretRect(InlineBox*, unsigned, LayoutUnit* extraWidthToEndOfLine) final; 100 100 101 101 bool hitTestCulledInline(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset); -
trunk/Source/WebCore/rendering/RenderLineBreak.cpp
r200953 r204400 167 167 } 168 168 169 LayoutRect RenderLineBreak::localCaretRect(InlineBox* inlineBox, intcaretOffset, LayoutUnit* extraWidthToEndOfLine)169 LayoutRect RenderLineBreak::localCaretRect(InlineBox* inlineBox, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine) 170 170 { 171 171 ASSERT_UNUSED(caretOffset, !caretOffset); -
trunk/Source/WebCore/rendering/RenderLineBreak.h
r200041 r204400 67 67 int caretMaxOffset() const override; 68 68 bool canBeSelectionLeaf() const override; 69 LayoutRect localCaretRect(InlineBox*, intcaretOffset, LayoutUnit* extraWidthToEndOfLine) override;69 LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine) override; 70 70 void setSelectionState(SelectionState) override; 71 71 -
trunk/Source/WebCore/rendering/RenderObject.cpp
r203091 r204400 1207 1207 } 1208 1208 1209 void RenderObject::selectionStartEnd( int& spos, int& epos) const1209 void RenderObject::selectionStartEnd(unsigned& spos, unsigned& epos) const 1210 1210 { 1211 1211 selectionRoot().selectionData().selectionStartEndPositions(spos, epos); … … 1378 1378 } 1379 1379 1380 LayoutRect RenderObject::localCaretRect(InlineBox*, int, LayoutUnit* extraWidthToEndOfLine)1380 LayoutRect RenderObject::localCaretRect(InlineBox*, unsigned, LayoutUnit* extraWidthToEndOfLine) 1381 1381 { 1382 1382 if (extraWidthToEndOfLine) -
trunk/Source/WebCore/rendering/RenderObject.h
r203973 r204400 750 750 * useful for character range rect computations 751 751 */ 752 virtual LayoutRect localCaretRect(InlineBox*, intcaretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr);752 virtual LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine = nullptr); 753 753 754 754 // When performing a global document tear-down, the renderer of the document is cleared. We use this … … 783 783 784 784 SelectionSubtreeRoot& selectionRoot() const; 785 void selectionStartEnd( int& spos, int& epos) const;785 void selectionStartEnd(unsigned& spos, unsigned& epos) const; 786 786 787 787 void removeFromParent(); -
trunk/Source/WebCore/rendering/RenderReplaced.cpp
r201889 r204400 617 617 return true; 618 618 619 intselectionStart, selectionEnd;619 unsigned selectionStart, selectionEnd; 620 620 selectionStartEnd(selectionStart, selectionEnd); 621 621 if (s == SelectionStart) 622 622 return selectionStart == 0; 623 623 624 intend = element()->hasChildNodes() ? element()->countChildNodes() : 1;624 unsigned end = element()->hasChildNodes() ? element()->countChildNodes() : 1; 625 625 if (s == SelectionEnd) 626 626 return selectionEnd == end; … … 628 628 return selectionStart == 0 && selectionEnd == end; 629 629 630 ASSERT (0);630 ASSERT_NOT_REACHED(); 631 631 return false; 632 632 } -
trunk/Source/WebCore/rendering/RenderText.cpp
r203042 r204400 443 443 } 444 444 445 LayoutRect RenderText::localCaretRect(InlineBox* inlineBox, intcaretOffset, LayoutUnit* extraWidthToEndOfLine)445 LayoutRect RenderText::localCaretRect(InlineBox* inlineBox, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine) 446 446 { 447 447 if (!inlineBox) … … 1373 1373 if (selectionState() == SelectionNone) 1374 1374 return LayoutRect(); 1375 RenderBlock* cb = containingBlock(); 1376 if (!cb) 1375 if (!containingBlock()) 1377 1376 return LayoutRect(); 1378 1377 1379 1378 // Now calculate startPos and endPos for painting selection. 1380 1379 // We include a selection while endPos > 0 1381 intstartPos, endPos;1380 unsigned startPos, endPos; 1382 1381 if (selectionState() == SelectionInside) { 1383 1382 // We are fully selected. -
trunk/Source/WebCore/rendering/RenderText.h
r203038 r204400 120 120 void setSelectionState(SelectionState) final; 121 121 LayoutRect selectionRectForRepaint(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent = true) override; 122 LayoutRect localCaretRect(InlineBox*, intcaretOffset, LayoutUnit* extraWidthToEndOfLine = 0) override;122 LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) override; 123 123 124 124 LayoutRect collectSelectionRectsForLineBoxes(const RenderLayerModelObject* repaintContainer, bool clipToVisibleContent, Vector<LayoutRect>& rects); -
trunk/Source/WebCore/rendering/RenderTextLineBoxes.cpp
r191002 r204400 446 446 } 447 447 448 intstart, end;448 unsigned start, end; 449 449 renderer.selectionStartEnd(start, end); 450 450 if (state == RenderObject::SelectionStart) { -
trunk/Source/WebCore/rendering/RenderView.cpp
r203751 r204400 119 119 : RenderBlockFlow(document, WTFMove(style)) 120 120 , m_frameView(*document.view()) 121 , m_selectionUnsplitStart(nullptr)122 , m_selectionUnsplitEnd(nullptr)123 , m_selectionUnsplitStartPos(-1)124 , m_selectionUnsplitEndPos(-1)125 121 , m_lazyRepaintTimer(*this, &RenderView::lazyRepaintTimerFired) 126 , m_pageLogicalHeight(0)127 , m_pageLogicalHeightChanged(false)128 , m_layoutState(nullptr)129 , m_layoutStateDisableCount(0)130 , m_renderQuoteHead(nullptr)131 , m_renderCounterCount(0)132 , m_selectionWasCaret(false)133 , m_hasSoftwareFilters(false)134 122 #if ENABLE(SERVICE_CONTROLS) 135 123 , m_selectionRectGatherer(*this) … … 773 761 774 762 RenderObject* os = root.selectionData().selectionStart(); 775 RenderObject* stop = rendererAfterPosition(root.selectionData().selectionEnd(), root.selectionData().selectionEndPos()); 763 auto* selectionEnd = root.selectionData().selectionEnd(); 764 RenderObject* stop = nullptr; 765 if (selectionEnd) 766 stop = rendererAfterPosition(selectionEnd, root.selectionData().selectionEndPos().value()); 776 767 SelectionIterator selectionIterator(os); 777 768 while (os && os != stop) { … … 822 813 HashSet<RenderBlock*> processedBlocks; 823 814 824 RenderObject* end = rendererAfterPosition(root.selectionData().selectionEnd(), root.selectionData().selectionEndPos()); 815 auto* selectionEnd = root.selectionData().selectionEnd(); 816 RenderObject* end = nullptr; 817 if (selectionEnd) 818 end = rendererAfterPosition(selectionEnd, root.selectionData().selectionEndPos().value()); 825 819 SelectionIterator selectionIterator(root.selectionData().selectionStart()); 826 820 for (RenderObject* o = selectionIterator.current(); o && o != end; o = selectionIterator.next()) { … … 841 835 } 842 836 843 void RenderView::setSelection(RenderObject* start, int startPos, RenderObject* end, intendPos, SelectionRepaintMode blockRepaintMode)837 void RenderView::setSelection(RenderObject* start, Optional<unsigned> startPos, RenderObject* end, Optional<unsigned> endPos, SelectionRepaintMode blockRepaintMode) 844 838 { 845 839 // Make sure both our start and end objects are defined. … … 878 872 } 879 873 880 void RenderView::splitSelectionBetweenSubtrees(const RenderObject* start, int startPos, const RenderObject* end, intendPos, SelectionRepaintMode blockRepaintMode)874 void RenderView::splitSelectionBetweenSubtrees(const RenderObject* start, Optional<unsigned> startPos, const RenderObject* end, Optional<unsigned> endPos, SelectionRepaintMode blockRepaintMode) 881 875 { 882 876 // Compute the visible selection end points for each of the subtrees. … … 903 897 if (selectionData.selectionClear()) { 904 898 selectionData.setSelectionStart(node->renderer()); 905 selectionData.setSelectionStartPos(node == startNode ? startPos : 0);899 selectionData.setSelectionStartPos(node == startNode ? startPos : Optional<unsigned>(0)); 906 900 } 907 901 … … 909 903 if (node == endNode) 910 904 selectionData.setSelectionEndPos(endPos); 911 else 912 selectionData.setSelectionEndPos(node->offsetInCharacters() ? node->maxCharacterOffset() : node->countChildNodes()); 905 else { 906 unsigned newEndPos = node->offsetInCharacters() ? node->maxCharacterOffset() : node->countChildNodes(); 907 selectionData.setSelectionEndPos(newEndPos); 908 } 913 909 914 910 renderSubtreesMap.set(&root, selectionData); … … 961 957 962 958 RenderObject* os = root.selectionData().selectionStart(); 963 RenderObject* stop = rendererAfterPosition(root.selectionData().selectionEnd(), root.selectionData().selectionEndPos()); 959 auto* selectionEnd = root.selectionData().selectionEnd(); 960 RenderObject* stop = nullptr; 961 if (selectionEnd) 962 stop = rendererAfterPosition(selectionEnd, root.selectionData().selectionEndPos().value()); 964 963 SelectionIterator selectionIterator(os); 965 964 while (os && os != stop) { … … 999 998 1000 999 RenderObject* selectionStart = root.selectionData().selectionStart(); 1001 RenderObject* selectionEnd = rendererAfterPosition(root.selectionData().selectionEnd(), root.selectionData().selectionEndPos()); 1000 auto* selectionDataEnd = root.selectionData().selectionEnd(); 1001 RenderObject* selectionEnd = nullptr; 1002 if (selectionDataEnd) 1003 selectionEnd = rendererAfterPosition(selectionDataEnd, root.selectionData().selectionEndPos().value()); 1002 1004 SelectionIterator selectionIterator(selectionStart); 1003 1005 for (RenderObject* currentRenderer = selectionStart; currentRenderer && currentRenderer != selectionEnd; currentRenderer = selectionIterator.next()) { … … 1090 1092 } 1091 1093 1092 void RenderView::getSelection(RenderObject*& startRenderer, int& startOffset, RenderObject*& endRenderer, int& endOffset) const1094 void RenderView::getSelection(RenderObject*& startRenderer, Optional<unsigned>& startOffset, RenderObject*& endRenderer, Optional<unsigned>& endOffset) const 1093 1095 { 1094 1096 startRenderer = m_selectionUnsplitStart; … … 1101 1103 { 1102 1104 layer()->repaintBlockSelectionGaps(); 1103 setSelection(nullptr, -1, nullptr, -1, RepaintNewMinusOld);1105 setSelection(nullptr, Nullopt, nullptr, Nullopt, RepaintNewMinusOld); 1104 1106 } 1105 1107 -
trunk/Source/WebCore/rendering/RenderView.h
r203751 r204400 86 86 87 87 enum SelectionRepaintMode { RepaintNewXOROld, RepaintNewMinusOld, RepaintNothing }; 88 void setSelection(RenderObject* start, int startPos, RenderObject* end, intendPos, SelectionRepaintMode = RepaintNewXOROld);89 void getSelection(RenderObject*& startRenderer, int& startOffset, RenderObject*& endRenderer, int& endOffset) const;88 void setSelection(RenderObject* start, Optional<unsigned> startPos, RenderObject* endObject, Optional<unsigned> endPos, SelectionRepaintMode = RepaintNewXOROld); 89 void getSelection(RenderObject*& startRenderer, Optional<unsigned>& startOffset, RenderObject*& endRenderer, Optional<unsigned>& endOffset) const; 90 90 void clearSelection(); 91 91 RenderObject* selectionUnsplitStart() const { return m_selectionUnsplitStart; } … … 308 308 bool isScrollableOrRubberbandableBox() const override; 309 309 310 void splitSelectionBetweenSubtrees(const RenderObject* startRenderer, int startPos, const RenderObject* endRenderer, intendPos, SelectionRepaintMode blockRepaintMode);310 void splitSelectionBetweenSubtrees(const RenderObject* startRenderer, Optional<unsigned> startPos, const RenderObject* endRenderer, Optional<unsigned> endPos, SelectionRepaintMode blockRepaintMode); 311 311 void clearSubtreeSelection(const SelectionSubtreeRoot&, SelectionRepaintMode, OldSelectionData&) const; 312 312 void updateSelectionForSubtrees(RenderSubtreesMap&, SelectionRepaintMode); … … 318 318 FrameView& m_frameView; 319 319 320 RenderObject* m_selectionUnsplitStart ;321 RenderObject* m_selectionUnsplitEnd ;322 intm_selectionUnsplitStartPos;323 intm_selectionUnsplitEndPos;320 RenderObject* m_selectionUnsplitStart { nullptr }; 321 RenderObject* m_selectionUnsplitEnd { nullptr }; 322 Optional<unsigned> m_selectionUnsplitStartPos; 323 Optional<unsigned> m_selectionUnsplitEndPos; 324 324 325 325 // Include this RenderView. … … 330 330 // FIXME: Only used by embedded WebViews inside AppKit NSViews. Find a way to remove. 331 331 struct LegacyPrinting { 332 LegacyPrinting() 333 : m_bestTruncatedAt(0) 334 , m_truncatedAt(0) 335 , m_truncatorWidth(0) 336 , m_forcedPageBreak(false) 337 { } 338 339 int m_bestTruncatedAt; 340 int m_truncatedAt; 341 int m_truncatorWidth; 332 int m_bestTruncatedAt { 0 }; 333 int m_truncatedAt { 0 }; 334 int m_truncatorWidth { 0 }; 342 335 IntRect m_printRect; 343 bool m_forcedPageBreak ;336 bool m_forcedPageBreak { false }; 344 337 }; 345 338 LegacyPrinting m_legacyPrinting; … … 355 348 std::unique_ptr<ImageQualityController> m_imageQualityController; 356 349 LayoutUnit m_pageLogicalHeight; 357 bool m_pageLogicalHeightChanged ;350 bool m_pageLogicalHeightChanged { false }; 358 351 std::unique_ptr<LayoutState> m_layoutState; 359 unsigned m_layoutStateDisableCount ;352 unsigned m_layoutStateDisableCount { 0 }; 360 353 std::unique_ptr<RenderLayerCompositor> m_compositor; 361 354 std::unique_ptr<FlowThreadController> m_flowThreadController; 362 355 363 RenderQuote* m_renderQuoteHead ;364 unsigned m_renderCounterCount ;365 366 bool m_selectionWasCaret ;367 bool m_hasSoftwareFilters ;356 RenderQuote* m_renderQuoteHead { nullptr }; 357 unsigned m_renderCounterCount { 0 }; 358 359 bool m_selectionWasCaret { false }; 360 bool m_hasSoftwareFilters { false }; 368 361 bool m_usesFirstLineRules { false }; 369 362 bool m_usesFirstLetterRules { false }; -
trunk/Source/WebCore/rendering/SelectionSubtreeRoot.cpp
r185838 r204400 43 43 } 44 44 45 SelectionSubtreeRoot::SelectionSubtreeRoot(RenderObject* selectionStart, int selectionStartPos, RenderObject* selectionEnd, int selectionEndPos)46 : m_selectionSubtreeData(selectionStart, selectionStartPos, selectionEnd, selectionEndPos)47 {48 }49 50 45 void SelectionSubtreeRoot::adjustForVisibleSelection(Document& document) 51 46 { … … 54 49 55 50 // Create a range based on the cached end points 56 Position startPosition = createLegacyEditingPosition(m_selectionSubtreeData.selectionStart()->node(), m_selectionSubtreeData.selectionStartPos()); 57 Position endPosition = createLegacyEditingPosition(m_selectionSubtreeData.selectionEnd()->node(), m_selectionSubtreeData.selectionEndPos()); 51 auto selectionStart = m_selectionSubtreeData.selectionStartPos().value(); 52 auto selectionEnd = m_selectionSubtreeData.selectionEndPos().value(); 53 Position startPosition = createLegacyEditingPosition(m_selectionSubtreeData.selectionStart()->node(), selectionStart); 54 Position endPosition = createLegacyEditingPosition(m_selectionSubtreeData.selectionEnd()->node(), selectionEnd); 58 55 59 56 RefPtr<Range> range = Range::create(document, startPosition.parentAnchoredEquivalent(), endPosition.parentAnchoredEquivalent()); … … 83 80 return; 84 81 82 auto newStartPos = startPos.deprecatedEditingOffset(); 83 auto newEndPos = endPos.deprecatedEditingOffset(); 84 ASSERT(newStartPos >= 0 && newEndPos >= 0); 85 85 m_selectionSubtreeData.setSelectionStart(startPos.deprecatedNode()->renderer()); 86 m_selectionSubtreeData.setSelectionStartPos( startPos.deprecatedEditingOffset());86 m_selectionSubtreeData.setSelectionStartPos(newStartPos); 87 87 m_selectionSubtreeData.setSelectionEnd(endPos.deprecatedNode()->renderer()); 88 m_selectionSubtreeData.setSelectionEndPos( endPos.deprecatedEditingOffset());88 m_selectionSubtreeData.setSelectionEndPos(newEndPos); 89 89 } 90 90 -
trunk/Source/WebCore/rendering/SelectionSubtreeRoot.h
r175252 r204400 46 46 struct OldSelectionData { 47 47 OldSelectionData() 48 : selectionStartPos(-1)49 , selectionEndPos(-1)50 48 { 51 49 } 52 50 53 intselectionStartPos;54 intselectionEndPos;51 Optional<unsigned> selectionStartPos; 52 Optional<unsigned> selectionEndPos; 55 53 SelectedObjectMap selectedObjects; 56 54 SelectedBlockMap selectedBlocks; … … 59 57 class SelectionSubtreeData { 60 58 public: 61 SelectionSubtreeData() 62 : m_selectionStart(nullptr) 63 , m_selectionStartPos(-1) 64 , m_selectionEnd(nullptr) 65 , m_selectionEndPos(-1) 66 { 67 } 59 SelectionSubtreeData() = default; 68 60 69 SelectionSubtreeData(RenderObject* selectionStart, int selectionStartPos, RenderObject* selectionEnd, intselectionEndPos)61 SelectionSubtreeData(RenderObject* selectionStart, Optional<unsigned> selectionStartPos, RenderObject* selectionEnd, Optional<unsigned> selectionEndPos) 70 62 : m_selectionStart(selectionStart) 71 63 , m_selectionStartPos(selectionStartPos) … … 76 68 77 69 RenderObject* selectionStart() const { return m_selectionStart; } 78 intselectionStartPos() const { return m_selectionStartPos; }70 Optional<unsigned> selectionStartPos() const { return m_selectionStartPos; } 79 71 RenderObject* selectionEnd() const { return m_selectionEnd; } 80 intselectionEndPos() const { return m_selectionEndPos; }72 Optional<unsigned> selectionEndPos() const { return m_selectionEndPos; } 81 73 bool selectionClear() const 82 74 { 83 75 return !m_selectionStart 84 && ( m_selectionStartPos == -1)76 && (!m_selectionStartPos) 85 77 && !m_selectionEnd 86 && ( m_selectionEndPos == -1);78 && (!m_selectionEndPos); 87 79 } 88 80 89 void selectionStartEndPositions( int& startPos, int& endPos) const81 void selectionStartEndPositions(unsigned& startPos, unsigned& endPos) const 90 82 { 91 startPos = m_selectionStartPos ;92 endPos = m_selectionEndPos ;83 startPos = m_selectionStartPos.value(); 84 endPos = m_selectionEndPos.value(); 93 85 } 94 86 void setSelectionStart(RenderObject* selectionStart) { m_selectionStart = selectionStart; } 95 void setSelectionStartPos( int selectionStartPos) { m_selectionStartPos = selectionStartPos;}87 void setSelectionStartPos(Optional<unsigned> selectionStartPos) { m_selectionStartPos = selectionStartPos;} 96 88 void setSelectionEnd(RenderObject* selectionEnd) { m_selectionEnd = selectionEnd; } 97 void setSelectionEndPos( int selectionEndPos) { m_selectionEndPos = selectionEndPos;}89 void setSelectionEndPos(Optional<unsigned> selectionEndPos) { m_selectionEndPos = selectionEndPos;} 98 90 void clearSelection() 99 91 { 100 92 m_selectionStart = nullptr; 101 m_selectionStartPos = -1;93 m_selectionStartPos = Nullopt; 102 94 m_selectionEnd = nullptr; 103 m_selectionEndPos = -1;95 m_selectionEndPos = Nullopt; 104 96 } 105 97 106 98 private: 107 RenderObject* m_selectionStart ;108 intm_selectionStartPos;109 RenderObject* m_selectionEnd ;110 intm_selectionEndPos;99 RenderObject* m_selectionStart { nullptr }; 100 Optional<unsigned> m_selectionStartPos; 101 RenderObject* m_selectionEnd { nullptr }; 102 Optional<unsigned> m_selectionEndPos; 111 103 }; 112 104 … … 115 107 116 108 SelectionSubtreeRoot(); 117 SelectionSubtreeRoot(RenderObject* selectionStart, int selectionStartPos, RenderObject* selectionEnd, int selectionEndPos);118 109 119 110 SelectionSubtreeData& selectionData() { return m_selectionSubtreeData; } -
trunk/Source/WebCore/rendering/TextPainter.cpp
r200807 r204400 85 85 86 86 void TextPainter::drawTextOrEmphasisMarks(const FontCascade& font, const TextRun& textRun, const AtomicString& emphasisMark, 87 int emphasisMarkOffset, const FloatPoint& textOrigin, int startOffset, intendOffset)87 float emphasisMarkOffset, const FloatPoint& textOrigin, unsigned startOffset, unsigned endOffset) 88 88 { 89 89 ASSERT(startOffset < endOffset); … … 91 91 m_context.drawText(font, textRun, textOrigin, startOffset, endOffset); 92 92 else 93 m_context.drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + IntSize(0, emphasisMarkOffset), startOffset, endOffset);93 m_context.drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + FloatSize(0, emphasisMarkOffset), startOffset, endOffset); 94 94 } 95 95 96 96 void TextPainter::paintTextWithShadows(const ShadowData* shadow, const FontCascade& font, const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin, 97 int startOffset, int endOffset, const AtomicString& emphasisMark, int emphasisMarkOffset, bool stroked)97 unsigned startOffset, unsigned endOffset, const AtomicString& emphasisMark, float emphasisMarkOffset, bool stroked) 98 98 { 99 99 if (!shadow) { … … 121 121 } 122 122 123 void TextPainter::paintTextAndEmphasisMarksIfNeeded(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin, int startOffset, intendOffset,123 void TextPainter::paintTextAndEmphasisMarksIfNeeded(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned startOffset, unsigned endOffset, 124 124 const TextPaintStyle& paintStyle, const ShadowData* shadow) 125 125 { … … 146 146 } 147 147 148 void TextPainter::paintText(const TextRun& textRun, int length, const FloatRect& boxRect, const FloatPoint& textOrigin, int selectionStart, intselectionEnd,148 void TextPainter::paintText(const TextRun& textRun, unsigned length, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned selectionStart, unsigned selectionEnd, 149 149 bool paintSelectedTextOnly, bool paintSelectedTextSeparately) 150 150 { -
trunk/Source/WebCore/rendering/TextPainter.h
r202167 r204400 55 55 void setIsHorizontal(bool isHorizontal) { m_textBoxIsHorizontal = isHorizontal; } 56 56 void setFont(const FontCascade& font) { m_font = &font; } 57 void addEmphasis(const AtomicString& emphasisMark, int emphasisMarkOffset, RenderCombineText*);57 void addEmphasis(const AtomicString& emphasisMark, float emphasisMarkOffset, RenderCombineText*); 58 58 void addTextShadow(const ShadowData* textShadow, const ShadowData* selectionShadow); 59 59 60 void paintText(const TextRun&, intlength, const FloatRect& boxRect, const FloatPoint& textOrigin,61 int selectionStart = 0, intselectionEnd = 0, bool paintSelectedTextOnly = false, bool paintSelectedTextSeparately = false);60 void paintText(const TextRun&, unsigned length, const FloatRect& boxRect, const FloatPoint& textOrigin, 61 unsigned selectionStart = 0, unsigned selectionEnd = 0, bool paintSelectedTextOnly = false, bool paintSelectedTextSeparately = false); 62 62 63 63 private: 64 void drawTextOrEmphasisMarks(const FontCascade&, const TextRun&, const AtomicString& emphasisMark, int emphasisMarkOffset,65 const FloatPoint& textOrigin, int startOffset, intendOffset);64 void drawTextOrEmphasisMarks(const FontCascade&, const TextRun&, const AtomicString& emphasisMark, float emphasisMarkOffset, 65 const FloatPoint& textOrigin, unsigned startOffset, unsigned endOffset); 66 66 void paintTextWithShadows(const ShadowData*, const FontCascade&, const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin, 67 int startOffset, int endOffset, const AtomicString& emphasisMark, int emphasisMarkOffset, bool stroked);68 void paintTextAndEmphasisMarksIfNeeded(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin, int startOffset, intendOffset,67 unsigned startOffset, unsigned endOffset, const AtomicString& emphasisMark, float emphasisMarkOffset, bool stroked); 68 void paintTextAndEmphasisMarksIfNeeded(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned startOffset, unsigned endOffset, 69 69 const TextPaintStyle&, const ShadowData*); 70 70 … … 77 77 AtomicString m_emphasisMark; 78 78 RenderCombineText* m_combinedText { nullptr }; 79 int m_emphasisMarkOffset { 0 };79 float m_emphasisMarkOffset { 0 }; 80 80 bool m_textBoxIsHorizontal { true }; 81 81 }; 82 82 83 inline void TextPainter::addEmphasis(const AtomicString& emphasisMark, int emphasisMarkOffset, RenderCombineText* combinedText)83 inline void TextPainter::addEmphasis(const AtomicString& emphasisMark, float emphasisMarkOffset, RenderCombineText* combinedText) 84 84 { 85 85 m_emphasisMark = emphasisMark; -
trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp
r194496 r204400 117 117 } 118 118 119 LayoutRect RenderSVGInlineText::localCaretRect(InlineBox* box, intcaretOffset, LayoutUnit*)119 LayoutRect RenderSVGInlineText::localCaretRect(InlineBox* box, unsigned caretOffset, LayoutUnit*) 120 120 { 121 121 if (!is<InlineTextBox>(box)) … … 123 123 124 124 auto& textBox = downcast<InlineTextBox>(*box); 125 if ( static_cast<unsigned>(caretOffset) < textBox.start() || static_cast<unsigned>(caretOffset)> textBox.start() + textBox.len())125 if (caretOffset < textBox.start() || caretOffset > textBox.start() + textBox.len()) 126 126 return LayoutRect(); 127 127 128 128 // Use the edge of the selection rect to determine the caret rect. 129 if ( static_cast<unsigned>(caretOffset)< textBox.start() + textBox.len()) {129 if (caretOffset < textBox.start() + textBox.len()) { 130 130 LayoutRect rect = textBox.localSelectionRect(caretOffset, caretOffset + 1); 131 131 LayoutUnit x = textBox.isLeftToRightDirection() ? rect.x() : rect.maxX(); -
trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.h
r197563 r204400 61 61 62 62 VisiblePosition positionForPoint(const LayoutPoint&, const RenderRegion*) override; 63 LayoutRect localCaretRect(InlineBox*, intcaretOffset, LayoutUnit* extraWidthToEndOfLine = 0) override;63 LayoutRect localCaretRect(InlineBox*, unsigned caretOffset, LayoutUnit* extraWidthToEndOfLine = 0) override; 64 64 IntRect linesBoundingBox() const override; 65 65 std::unique_ptr<InlineTextBox> createTextBox() override; -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r203910 r204400 101 101 } 102 102 103 float SVGInlineTextBox::positionForOffset( int) const103 float SVGInlineTextBox::positionForOffset(unsigned) const 104 104 { 105 105 // SVG doesn't use the offset <-> position selection system. … … 108 108 } 109 109 110 FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, int startPosition, intendPosition, const RenderStyle* style) const110 FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition, const RenderStyle* style) const 111 111 { 112 112 ASSERT_WITH_SECURITY_IMPLICATION(startPosition < endPosition); … … 135 135 } 136 136 137 LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPosition) const 138 { 139 int boxStart = start(); 140 startPosition = std::max(startPosition - boxStart, 0); 141 endPosition = std::min(endPosition - boxStart, static_cast<int>(len())); 137 LayoutRect SVGInlineTextBox::localSelectionRect(unsigned startPosition, unsigned endPosition) const 138 { 139 startPosition = clampedOffset(startPosition); 140 endPosition = clampedOffset(endPosition); 142 141 if (startPosition >= endPosition) 143 142 return LayoutRect(); … … 147 146 AffineTransform fragmentTransform; 148 147 FloatRect selectionRect; 149 intfragmentStartPosition = 0;150 intfragmentEndPosition = 0;148 unsigned fragmentStartPosition = 0; 149 unsigned fragmentEndPosition = 0; 151 150 152 151 unsigned textFragmentsSize = m_textFragments.size(); … … 204 203 auto& style = parentRenderer.style(); 205 204 206 intstartPosition;207 intendPosition;205 unsigned startPosition; 206 unsigned endPosition; 208 207 std::tie(startPosition, endPosition) = selectionStartEnd(); 209 208 210 intfragmentStartPosition = 0;211 intfragmentEndPosition = 0;209 unsigned fragmentStartPosition = 0; 210 unsigned fragmentEndPosition = 0; 212 211 AffineTransform fragmentTransform; 213 212 unsigned textFragmentsSize = m_textFragments.size(); … … 408 407 } 409 408 410 bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, int& startPosition, int& endPosition) const409 bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const 411 410 { 412 411 if (startPosition >= endPosition) 413 412 return false; 414 413 415 int offset = static_cast<int>(fragment.characterOffset) - start(); 416 int length = static_cast<int>(fragment.length); 414 ASSERT(fragment.characterOffset >= start()); 415 unsigned offset = fragment.characterOffset - start(); 416 unsigned length = fragment.length; 417 417 418 418 if (startPosition >= offset + length || endPosition <= offset) … … 421 421 if (startPosition < offset) 422 422 startPosition = 0; 423 else 423 else { 424 ASSERT(startPosition >= offset); 424 425 startPosition -= offset; 426 } 425 427 426 428 if (endPosition > offset + length) … … 541 543 } 542 544 543 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, int startPosition, intendPosition)545 void SVGInlineTextBox::paintTextWithShadows(GraphicsContext& context, const RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, unsigned startPosition, unsigned endPosition) 544 546 { 545 547 float scalingFactor = renderer().scalingFactor(); … … 591 593 ASSERT(selectionStyle); 592 594 593 intstartPosition = 0;594 intendPosition = 0;595 unsigned startPosition = 0; 596 unsigned endPosition = 0; 595 597 if (hasSelection) { 596 598 std::tie(startPosition, endPosition) = selectionStartEnd(); … … 619 621 620 622 // Eventually draw text using regular style from the end position of the selection to the end of the current chunk part 621 if (endPosition < static_cast<int>(fragment.length)&& !paintSelectedTextOnly)623 if (endPosition < fragment.length && !paintSelectedTextOnly) 622 624 paintTextWithShadows(context, style, textRun, fragment, endPosition, fragment.length); 623 625 } -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.h
r200098 r204400 44 44 int selectionHeight() { return static_cast<int>(ceilf(m_logicalHeight)); } 45 45 int offsetForPosition(float x, bool includePartialGlyphs = true) const override; 46 float positionForOffset( intoffset) const override;46 float positionForOffset(unsigned offset) const override; 47 47 48 48 void paintSelectionBackground(PaintInfo&); 49 49 void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override; 50 LayoutRect localSelectionRect( int startPosition, intendPosition) const override;50 LayoutRect localSelectionRect(unsigned startPosition, unsigned endPosition) const override; 51 51 52 bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, int& startPosition, int& endPosition) const;52 bool mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment&, unsigned& startPosition, unsigned& endPosition) const; 53 53 54 54 FloatRect calculateBoundaries() const override; … … 65 65 66 66 int offsetForPositionInFragment(const SVGTextFragment&, float position, bool includePartialGlyphs) const; 67 FloatRect selectionRectForTextFragment(const SVGTextFragment&, int fragmentStartPosition, intfragmentEndPosition, const RenderStyle*) const;67 FloatRect selectionRectForTextFragment(const SVGTextFragment&, unsigned fragmentStartPosition, unsigned fragmentEndPosition, const RenderStyle*) const; 68 68 69 69 private: … … 80 80 void paintDecoration(GraphicsContext&, TextDecoration, const SVGTextFragment&); 81 81 void paintDecorationWithStyle(GraphicsContext&, TextDecoration, const SVGTextFragment&, RenderBoxModelObject& decorationRenderer); 82 void paintTextWithShadows(GraphicsContext&, const RenderStyle*, TextRun&, const SVGTextFragment&, int startPosition, intendPosition);82 void paintTextWithShadows(GraphicsContext&, const RenderStyle*, TextRun&, const SVGTextFragment&, unsigned startPosition, unsigned endPosition); 83 83 void paintText(GraphicsContext&, const RenderStyle*, const RenderStyle* selectionStyle, const SVGTextFragment&, bool hasSelection, bool paintSelectedTextOnly); 84 84 -
trunk/Source/WebCore/rendering/svg/SVGTextQuery.cpp
r185593 r204400 135 135 } 136 136 137 bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData, const SVGTextFragment& fragment, int& startPosition, int& endPosition) const137 bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData, const SVGTextFragment& fragment, unsigned& startPosition, unsigned& endPosition) const 138 138 { 139 139 // Reuse the same logic used for text selection & painting, to map our query start/length into start/endPositions of the current text fragment. 140 ASSERT(startPosition >= queryData->processedCharacters); 141 ASSERT(endPosition >= queryData->processedCharacters); 140 142 startPosition -= queryData->processedCharacters; 141 143 endPosition -= queryData->processedCharacters; 142 144 143 if (startPosition >= endPosition || startPosition < 0 || endPosition < 0)145 if (startPosition >= endPosition) 144 146 return false; 145 147 … … 152 154 } 153 155 154 void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, int& startPosition, int& endPosition) const156 void SVGTextQuery::modifyStartEndPositionsRespectingLigatures(Data* queryData, unsigned& startPosition, unsigned& endPosition) const 155 157 { 156 158 SVGTextLayoutAttributes* layoutAttributes = queryData->textRenderer->layoutAttributes(); … … 168 170 bool alterEndPosition = true; 169 171 170 int lastPositionOffset = -1;172 Optional<unsigned> lastPositionOffset; 171 173 for (; textMetricsOffset < textMetricsSize && positionOffset < positionSize; ++textMetricsOffset) { 172 174 SVGTextMetrics& metrics = textMetricsValues[textMetricsOffset]; … … 183 185 184 186 // If the start position maps to a character in the metrics list, we don't need to modify it. 185 if (startPosition == static_cast<int>(positionOffset))187 if (startPosition == positionOffset) 186 188 alterStartPosition = false; 187 189 188 190 // If the start position maps to a character in the metrics list, we don't need to modify it. 189 if (endPosition == static_cast<int>(positionOffset))191 if (endPosition == positionOffset) 190 192 alterEndPosition = false; 191 193 192 194 // Detect ligatures. 193 if (lastPositionOffset != -1 && lastPositionOffset- positionOffset > 1) {194 if (alterStartPosition && startPosition > lastPositionOffset && startPosition < static_cast<int>(positionOffset)) {195 startPosition = lastPositionOffset ;195 if (lastPositionOffset && lastPositionOffset.value() - positionOffset > 1) { 196 if (alterStartPosition && startPosition > lastPositionOffset.value() && startPosition < positionOffset) { 197 startPosition = lastPositionOffset.value(); 196 198 alterStartPosition = false; 197 199 } 198 200 199 if (alterEndPosition && endPosition > lastPositionOffset && endPosition < static_cast<int>(positionOffset)) {201 if (alterEndPosition && endPosition > lastPositionOffset.value() && endPosition < positionOffset) { 200 202 endPosition = positionOffset; 201 203 alterEndPosition = false; … … 213 215 return; 214 216 215 if (lastPositionOffset != -1 && lastPositionOffset- positionOffset > 1) {216 if (alterStartPosition && startPosition > lastPositionOffset && startPosition < static_cast<int>(positionOffset))217 startPosition = lastPositionOffset ;218 219 if (alterEndPosition && endPosition > lastPositionOffset && endPosition < static_cast<int>(positionOffset))217 if (lastPositionOffset && lastPositionOffset.value() - positionOffset > 1) { 218 if (alterStartPosition && startPosition > lastPositionOffset.value() && startPosition < positionOffset) 219 startPosition = lastPositionOffset.value(); 220 221 if (alterEndPosition && endPosition > lastPositionOffset.value() && endPosition < positionOffset) 220 222 endPosition = positionOffset; 221 223 } … … 285 287 SubStringLengthData* data = static_cast<SubStringLengthData*>(queryData); 286 288 287 intstartPosition = data->startPosition;288 intendPosition = startPosition + data->length;289 unsigned startPosition = data->startPosition; 290 unsigned endPosition = startPosition + data->length; 289 291 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) 290 292 return false; … … 320 322 StartPositionOfCharacterData* data = static_cast<StartPositionOfCharacterData*>(queryData); 321 323 322 intstartPosition = data->position;323 intendPosition = startPosition + 1;324 unsigned startPosition = data->position; 325 unsigned endPosition = startPosition + 1; 324 326 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) 325 327 return false; … … 369 371 EndPositionOfCharacterData* data = static_cast<EndPositionOfCharacterData*>(queryData); 370 372 371 intstartPosition = data->position;372 intendPosition = startPosition + 1;373 unsigned startPosition = data->position; 374 unsigned endPosition = startPosition + 1; 373 375 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) 374 376 return false; … … 417 419 RotationOfCharacterData* data = static_cast<RotationOfCharacterData*>(queryData); 418 420 419 intstartPosition = data->position;420 intendPosition = startPosition + 1;421 unsigned startPosition = data->position; 422 unsigned endPosition = startPosition + 1; 421 423 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) 422 424 return false; … … 455 457 }; 456 458 457 static inline void calculateGlyphBoundaries(SVGTextQuery::Data* queryData, const SVGTextFragment& fragment, intstartPosition, FloatRect& extent)459 static inline void calculateGlyphBoundaries(SVGTextQuery::Data* queryData, const SVGTextFragment& fragment, unsigned startPosition, FloatRect& extent) 458 460 { 459 461 float scalingFactor = queryData->textRenderer->scalingFactor(); … … 485 487 ExtentOfCharacterData* data = static_cast<ExtentOfCharacterData*>(queryData); 486 488 487 intstartPosition = data->position;488 intendPosition = startPosition + 1;489 unsigned startPosition = data->position; 490 unsigned endPosition = startPosition + 1; 489 491 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) 490 492 return false; … … 520 522 FloatRect extent; 521 523 for (unsigned i = 0; i < fragment.length; ++i) { 522 intstartPosition = data->processedCharacters + i;523 intendPosition = startPosition + 1;524 unsigned startPosition = data->processedCharacters + i; 525 unsigned endPosition = startPosition + 1; 524 526 if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition)) 525 527 continue; -
trunk/Source/WebCore/rendering/svg/SVGTextQuery.h
r170947 r204400 53 53 54 54 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; 57 57 58 58 private:
Note: See TracChangeset
for help on using the changeset viewer.