Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1195)

Unified Diff: Source/core/layout/svg/line/SVGInlineTextBox.cpp

Issue 1049673002: Simplify range mapping computation in SVGTextQuery/SVGInlineTextBox (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/svg/SVGTextQuery.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/core/layout/svg/SVGTextQuery.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698