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

Side by Side Diff: Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 1314543003: Fix ShapeResult::offsetForPosition for RTL scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: TestExpectations in PS3 was uploaded from wrong PC Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « LayoutTests/platform/mac/editing/selection/offset-from-point-complex-scripts-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 449 int ShapeResult::offsetForPosition(Vector<RefPtr<ShapeResult>>& results,
450 const TextRun& run, float targetX) 450 const TextRun& run, float targetX)
451 { 451 {
452 unsigned totalOffset; 452 unsigned totalOffset;
453 if (run.rtl()) { 453 if (run.rtl()) {
454 totalOffset = run.length(); 454 totalOffset = run.length();
455 for (auto& wordResult : results) { 455 for (unsigned i = results.size(); i; --i) {
456 const RefPtr<ShapeResult>& wordResult = results[i - 1];
456 if (!wordResult) 457 if (!wordResult)
457 continue; 458 continue;
458 totalOffset -= wordResult->numCharacters(); 459 totalOffset -= wordResult->numCharacters();
459 if (targetX >= 0 && targetX <= wordResult->width()) { 460 if (targetX >= 0 && targetX <= wordResult->width()) {
460 int offsetForWord = wordResult->offsetForPosition(targetX); 461 int offsetForWord = wordResult->offsetForPosition(targetX);
461 return totalOffset + offsetForWord; 462 return totalOffset + offsetForWord;
462 } 463 }
463 targetX -= wordResult->width(); 464 targetX -= wordResult->width();
464 } 465 }
465 } else { 466 } else {
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 return spacing; 1215 return spacing;
1215 } 1216 }
1216 1217
1217 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere d by !m_expansionOpportunityCount above 1218 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere d by !m_expansionOpportunityCount above
1218 spacing += nextExpansionPerOpportunity(); 1219 spacing += nextExpansionPerOpportunity();
1219 m_isAfterExpansion = true; 1220 m_isAfterExpansion = true;
1220 return spacing; 1221 return spacing;
1221 } 1222 }
1222 1223
1223 } // namespace blink 1224 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/platform/mac/editing/selection/offset-from-point-complex-scripts-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698