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

Unified Diff: Source/core/rendering/svg/SVGTextQuery.cpp

Issue 349573005: Handle multiple fragments in the getCharNumberAtPosition SVGTextQuery (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove redundant line from test. Created 6 years, 6 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 | « LayoutTests/svg/text/getcharnumatposition-multiple-fragments-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/svg/SVGTextQuery.cpp
diff --git a/Source/core/rendering/svg/SVGTextQuery.cpp b/Source/core/rendering/svg/SVGTextQuery.cpp
index f5ead0d43661f2ec0f636f48021b511100a0b748..4d11f06e00efe251cacc66cf0d934d3b660b8768 100644
--- a/Source/core/rendering/svg/SVGTextQuery.cpp
+++ b/Source/core/rendering/svg/SVGTextQuery.cpp
@@ -518,16 +518,19 @@ bool SVGTextQuery::characterNumberAtPositionCallback(Data* queryData, const SVGT
{
CharacterNumberAtPositionData* data = static_cast<CharacterNumberAtPositionData*>(queryData);
+ // Offset of the fragment within the text box.
+ unsigned boxOffset = fragment.characterOffset - queryData->textBox->start();
+
FloatRect extent;
for (unsigned i = 0; i < fragment.length; ++i) {
- int startPosition = data->processedCharacters + i;
+ int startPosition = data->processedCharacters + boxOffset + i;
int endPosition = startPosition + 1;
if (!mapStartEndPositionsIntoFragmentCoordinates(queryData, fragment, startPosition, endPosition))
continue;
calculateGlyphBoundaries(queryData, fragment, startPosition, extent);
if (extent.contains(data->position)) {
- data->processedCharacters += i;
+ data->processedCharacters += boxOffset + i;
return true;
}
}
« no previous file with comments | « LayoutTests/svg/text/getcharnumatposition-multiple-fragments-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698