Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge r254114 - ComplexTextController::offsetForPosition returns a wr…
…ong offset for a glyph boundary in a RTL text https://bugs.webkit.org/show_bug.cgi?id=205486 Reviewed by Ross Kirsling. Source/WebCore: ComplexTextController::offsetForPosition had the following code: > unsigned hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance); If m_run.ltr() was false and x == 0, hitIndex would become hitGlyphEnd. This is not expected. It expects hitIndex < hitGlyphEnd if hitGlyphStart ≠ hitGlyphEnd. Let hitIndex be hitGlyphStart-1 in the such condition. Above change makes fast/text/ellipsis-text-rtl.html starting to fail because offsetForPosition returns the character offset of the next glyph if the argument 'h' is in a glyph boundary. In RTL text, offsetForPosition should return a character offset of the previous glyph in case of a glyph boundary. Use '<=' instead of '<' for RTL text in order to select previous glyphs for glyph boundaries. Test: fast/dom/Document/CaretRangeFromPoint/rtl.html * platform/graphics/ComplexTextController.cpp: (WebCore::ComplexTextController::offsetForPosition): Compute correct hitGlyphEnd for RTL. LayoutTests: * fast/dom/Document/CaretRangeFromPoint/rtl-expected.txt: Added. * fast/dom/Document/CaretRangeFromPoint/rtl.html: Added. * platform/gtk/TestExpectations: Unmarked imported/blink/editing/selection/offset-from-point-complex-scripts.html.
- Loading branch information
1 parent
c6c0cec
commit d214e17
Showing
6 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
LayoutTests/fast/dom/Document/CaretRangeFromPoint/rtl-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6 5 4 3 2 1 0 |
42 changes: 42 additions & 0 deletions
42
LayoutTests/fast/dom/Document/CaretRangeFromPoint/rtl.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<style> | ||
p { | ||
font-family: "Ahem"; | ||
direction: rtl; | ||
unicode-bidi: bidi-override; | ||
} | ||
</style> | ||
</head> | ||
<div id="container"> | ||
<p>ABCDEF</p> | ||
</div> | ||
<div id=log></div> | ||
<script> | ||
testOffsetFromPoint(container.firstElementChild); | ||
|
||
function testOffsetFromPoint(element) { | ||
var y = element.offsetTop + element.offsetHeight / 2; | ||
var xmin = element.offsetLeft; | ||
var xmax = xmin + element.offsetWidth; | ||
var lastCharacterOffset = null; | ||
var results = []; | ||
for (var x = xmin - 1; x <= xmax + 1; ++x) { | ||
var result = document.caretRangeFromPoint(x, y); | ||
var characterOffset = result ? result.startOffset : null; | ||
if (characterOffset === lastCharacterOffset) | ||
continue; | ||
results.push(characterOffset); | ||
lastCharacterOffset = characterOffset; | ||
} | ||
var div = document.createElement("div"); | ||
div.innerText = results.join(" "); | ||
log.appendChild(div); | ||
} | ||
|
||
if (window.testRunner) { | ||
container.style.display = "none"; | ||
testRunner.dumpAsText(); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters