Chromium Code Reviews| Index: Source/core/layout/svg/line/SVGInlineTextBox.cpp |
| diff --git a/Source/core/layout/svg/line/SVGInlineTextBox.cpp b/Source/core/layout/svg/line/SVGInlineTextBox.cpp |
| index 654844c83a0ec105d46af77158d964fbde6a2d87..de9186e8268fe36ea6a9e0b48a1498e5028c6155 100644 |
| --- a/Source/core/layout/svg/line/SVGInlineTextBox.cpp |
| +++ b/Source/core/layout/svg/line/SVGInlineTextBox.cpp |
| @@ -202,29 +202,17 @@ TextRun SVGInlineTextBox::constructTextRun(const ComputedStyle& style, const SVG |
| bool SVGInlineTextBox::mapStartEndPositionsIntoFragmentCoordinates(const SVGTextFragment& fragment, int& startPosition, int& endPosition) const |
| { |
| - if (startPosition >= endPosition) |
| - return false; |
| - |
| - int offset = static_cast<int>(fragment.characterOffset) - start(); |
| - int length = static_cast<int>(fragment.length); |
| + int fragmentOffsetInBox = static_cast<int>(fragment.characterOffset) - start(); |
| - if (startPosition >= offset + length || endPosition <= offset) |
| - return false; |
| + // Compute positions relative to the fragment. |
|
Erik Dahlström (inactive)
2015/04/01 14:04:20
This used to leave startPosition and endPosition u
fs
2015/04/01 14:16:24
The common pattern in callers are:
int startPos =
|
| + startPosition -= fragmentOffsetInBox; |
| + endPosition -= fragmentOffsetInBox; |
| - if (startPosition < offset) |
| - startPosition = 0; |
| - else |
| - startPosition -= offset; |
| + // Intersect with the fragment range. |
| + startPosition = std::max(startPosition, 0); |
| + endPosition = std::min(endPosition, static_cast<int>(fragment.length)); |
| - if (endPosition > offset + length) { |
| - endPosition = length; |
| - } else { |
| - ASSERT(endPosition >= offset); |
| - endPosition -= offset; |
| - } |
| - |
| - ASSERT(startPosition < endPosition); |
| - return true; |
| + return startPosition < endPosition; |
| } |
| void SVGInlineTextBox::paintDocumentMarker(GraphicsContext*, const FloatPointWillBeLayoutPoint&, DocumentMarker*, const ComputedStyle&, const Font&, bool) |