| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 return false; | 135 return false; |
| 136 } | 136 } |
| 137 | 137 |
| 138 bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData,
const SVGTextFragment& fragment, int& startPosition, int& endPosition) const | 138 bool SVGTextQuery::mapStartEndPositionsIntoFragmentCoordinates(Data* queryData,
const SVGTextFragment& fragment, int& startPosition, int& endPosition) const |
| 139 { | 139 { |
| 140 // Reuse the same logic used for text selection & painting, to map our query
start/length into start/endPositions of the current text fragment. | 140 // Reuse the same logic used for text selection & painting, to map our query
start/length into start/endPositions of the current text fragment. |
| 141 startPosition -= queryData->processedCharacters; | 141 startPosition -= queryData->processedCharacters; |
| 142 endPosition -= queryData->processedCharacters; | 142 endPosition -= queryData->processedCharacters; |
| 143 | 143 |
| 144 if (startPosition >= endPosition || startPosition < 0 || endPosition < 0) | 144 startPosition = max(0, startPosition); |
| 145 |
| 146 if (startPosition >= endPosition) |
| 145 return false; | 147 return false; |
| 146 | 148 |
| 147 modifyStartEndPositionsRespectingLigatures(queryData, startPosition, endPosi
tion); | 149 modifyStartEndPositionsRespectingLigatures(queryData, startPosition, endPosi
tion); |
| 148 if (!queryData->textBox->mapStartEndPositionsIntoFragmentCoordinates(fragmen
t, startPosition, endPosition)) | 150 if (!queryData->textBox->mapStartEndPositionsIntoFragmentCoordinates(fragmen
t, startPosition, endPosition)) |
| 149 return false; | 151 return false; |
| 150 | 152 |
| 151 ASSERT(startPosition < endPosition); | 153 ASSERT(startPosition < endPosition); |
| 152 return true; | 154 return true; |
| 153 } | 155 } |
| 154 | 156 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 return -1; | 541 return -1; |
| 540 | 542 |
| 541 CharacterNumberAtPositionData data(position); | 543 CharacterNumberAtPositionData data(position); |
| 542 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) | 544 if (!executeQuery(&data, &SVGTextQuery::characterNumberAtPositionCallback)) |
| 543 return -1; | 545 return -1; |
| 544 | 546 |
| 545 return data.processedCharacters; | 547 return data.processedCharacters; |
| 546 } | 548 } |
| 547 | 549 |
| 548 } | 550 } |
| OLD | NEW |