Chromium Code Reviews| Index: LayoutTests/svg/text/bidi-getcharnumatpos.html |
| diff --git a/LayoutTests/svg/text/bidi-getcharnumatpos.html b/LayoutTests/svg/text/bidi-getcharnumatpos.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..89bb728aa39d937486f3a04c48271cd98b447972 |
| --- /dev/null |
| +++ b/LayoutTests/svg/text/bidi-getcharnumatpos.html |
| @@ -0,0 +1,40 @@ |
| +<!DOCTYPE html> |
| +<meta charset="UTF-8"> |
| +<title>BiDi getCharNumAtPosition()</title> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<svg width="50px" height="60px" font-family="Arial" font-size="30px"> |
| + <text y="40" direction="ltr">Foo הפוך</text> |
| + <text text-anchor="end" y="70" direction="rtl">Foo הפוך</text> |
|
pdr.
2015/04/16 02:34:58
My Hebrew is a little rusty but shouldn't this be
fs
2015/04/16 14:22:21
I suppose it _should_ be =), but I felt I wanted s
|
| +</svg> |
| +<script> |
| +function getExtents(textElement) { |
| + var glyphBBoxes = []; |
| + for (var i = 0; i < 8; ++i) |
| + glyphBBoxes.push(textElement.getExtentOfChar(i)); |
|
pdr.
2015/04/16 02:34:58
Nit: indentation
fs
2015/04/16 14:22:21
Done.
|
| + return glyphBBoxes; |
| +} |
| + |
| +function getCharNums(textElement, glyphBBoxes) { |
| + var charNums = []; |
| + var point = textElement.ownerSVGElement.createSVGPoint(); |
| + for (var i = 0; i < glyphBBoxes.length; ++i) { |
| + var bbox = glyphBBoxes[i]; |
|
pdr.
2015/04/16 02:34:58
Nit: indentation (here, and below)
fs
2015/04/16 14:22:21
Done.
|
| + point.x = bbox.x + bbox.width / 2; |
| + point.y = bbox.y + bbox.height / 2; |
| + charNums.push(textElement.getCharNumAtPosition(point)); |
| + } |
| + return charNums; |
| +} |
| + |
| +var textElements = document.querySelectorAll("text"); |
| +for (var j = 0; j < textElements.length; ++j) { |
| + var textElement = textElements[j]; |
| + test(function() { |
| + assert_equals(textElement.textContent.length, 8); |
| + var glyphChars = getCharNums(textElement, getExtents(textElement)); |
| + for (var i = 0; i < glyphChars.length; ++i) |
| + assert_equals(glyphChars[i], i); |
| + }, document.title+', direction='+textElement.getAttribute("direction")+'.'); |
| +} |
| +</script> |