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

Unified Diff: LayoutTests/svg/text/bidi-getcharnumatpos.html

Issue 1083073002: Add a "logical query mode" to SVGTextQuery (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Older URL. Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/svg/text/bidi-getcharnumatpos-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..671c1d1c74b9a500ba29adf2ed70df9efbfe7688
--- /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>
+</svg>
+<script>
+function getExtents(textElement) {
+ var glyphBBoxes = [];
+ for (var i = 0; i < 8; ++i)
+ glyphBBoxes.push(textElement.getExtentOfChar(i));
+ 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];
+ 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, 10);
+ 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>
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/svg/text/bidi-getcharnumatpos-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698