OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 toX = direction == RTL ? 0 : totalWidth; | 439 toX = direction == RTL ? 0 : totalWidth; |
440 | 440 |
441 // None of our runs is part of the selection, possibly invalid arguments. | 441 // None of our runs is part of the selection, possibly invalid arguments. |
442 if (!foundToX && !foundFromX) | 442 if (!foundToX && !foundFromX) |
443 fromX = toX = 0; | 443 fromX = toX = 0; |
444 if (fromX < toX) | 444 if (fromX < toX) |
445 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); | 445 return FloatRect(point.x() + fromX, point.y(), toX - fromX, height); |
446 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); | 446 return FloatRect(point.x() + toX, point.y(), fromX - toX, height); |
447 } | 447 } |
448 | 448 |
449 int ShapeResult::offsetForPosition(Vector<RefPtr<ShapeResult>>& results, | |
450 const TextRun& run, float targetX) | |
451 { | |
452 RefPtr<ShapeResult> wordResult; | |
brucedawson
2015/08/11 19:01:06
This variable is never used and should be deleted.
| |
453 unsigned totalOffset; | |
454 if (run.rtl()) { | |
455 totalOffset = run.length(); | |
456 for (auto& wordResult : results) { | |
457 if (!wordResult) | |
458 continue; | |
459 totalOffset -= wordResult->numCharacters(); | |
460 if (targetX >= 0 && targetX <= wordResult->width()) { | |
461 int offsetForWord = wordResult->offsetForPosition(targetX); | |
462 return totalOffset + offsetForWord; | |
463 } | |
464 targetX -= wordResult->width(); | |
465 } | |
466 } else { | |
467 totalOffset = 0; | |
468 for (auto& wordResult : results) { | |
469 if (!wordResult) | |
470 continue; | |
471 int offsetForWord = wordResult->offsetForPosition(targetX); | |
472 ASSERT(offsetForWord >= 0); | |
473 totalOffset += offsetForWord; | |
474 if (targetX >= 0 && targetX <= wordResult->width()) | |
475 return totalOffset; | |
476 targetX -= wordResult->width(); | |
477 } | |
478 } | |
479 return totalOffset; | |
480 } | |
481 | |
449 int ShapeResult::offsetForPosition(float targetX) | 482 int ShapeResult::offsetForPosition(float targetX) |
450 { | 483 { |
451 int charactersSoFar = 0; | 484 int charactersSoFar = 0; |
452 float currentX = 0; | 485 float currentX = 0; |
453 | 486 |
454 if (m_direction == RTL) { | 487 if (m_direction == RTL) { |
455 charactersSoFar = m_numCharacters; | 488 charactersSoFar = m_numCharacters; |
456 for (unsigned i = 0; i < m_runs.size(); ++i) { | 489 for (unsigned i = 0; i < m_runs.size(); ++i) { |
457 if (!m_runs[i]) | 490 if (!m_runs[i]) |
458 continue; | 491 continue; |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1157 return spacing; | 1190 return spacing; |
1158 } | 1191 } |
1159 | 1192 |
1160 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere d by !m_expansionOpportunityCount above | 1193 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere d by !m_expansionOpportunityCount above |
1161 spacing += nextExpansionPerOpportunity(); | 1194 spacing += nextExpansionPerOpportunity(); |
1162 m_isAfterExpansion = true; | 1195 m_isAfterExpansion = true; |
1163 return spacing; | 1196 return spacing; |
1164 } | 1197 } |
1165 | 1198 |
1166 } // namespace blink | 1199 } // namespace blink |
OLD | NEW |