Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <meta charset="UTF-8"> | |
| 3 <title>BiDi getCharNumAtPosition()</title> | |
| 4 <script src="../../resources/testharness.js"></script> | |
| 5 <script src="../../resources/testharnessreport.js"></script> | |
| 6 <svg width="50px" height="60px" font-family="Arial" font-size="30px"> | |
| 7 <text y="40" direction="ltr">Foo הפוך</text> | |
| 8 <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
| |
| 9 </svg> | |
| 10 <script> | |
| 11 function getExtents(textElement) { | |
| 12 var glyphBBoxes = []; | |
| 13 for (var i = 0; i < 8; ++i) | |
| 14 glyphBBoxes.push(textElement.getExtentOfChar(i)); | |
|
pdr.
2015/04/16 02:34:58
Nit: indentation
fs
2015/04/16 14:22:21
Done.
| |
| 15 return glyphBBoxes; | |
| 16 } | |
| 17 | |
| 18 function getCharNums(textElement, glyphBBoxes) { | |
| 19 var charNums = []; | |
| 20 var point = textElement.ownerSVGElement.createSVGPoint(); | |
| 21 for (var i = 0; i < glyphBBoxes.length; ++i) { | |
| 22 var bbox = glyphBBoxes[i]; | |
|
pdr.
2015/04/16 02:34:58
Nit: indentation (here, and below)
fs
2015/04/16 14:22:21
Done.
| |
| 23 point.x = bbox.x + bbox.width / 2; | |
| 24 point.y = bbox.y + bbox.height / 2; | |
| 25 charNums.push(textElement.getCharNumAtPosition(point)); | |
| 26 } | |
| 27 return charNums; | |
| 28 } | |
| 29 | |
| 30 var textElements = document.querySelectorAll("text"); | |
| 31 for (var j = 0; j < textElements.length; ++j) { | |
| 32 var textElement = textElements[j]; | |
| 33 test(function() { | |
| 34 assert_equals(textElement.textContent.length, 8); | |
| 35 var glyphChars = getCharNums(textElement, getExtents(textElement)); | |
| 36 for (var i = 0; i < glyphChars.length; ++i) | |
| 37 assert_equals(glyphChars[i], i); | |
| 38 }, document.title+', direction='+textElement.getAttribute("direction")+'.'); | |
| 39 } | |
| 40 </script> | |
| OLD | NEW |