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

Unified Diff: LayoutTests/svg/text/textquery-collapsed-whitespace.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
Index: LayoutTests/svg/text/textquery-collapsed-whitespace.html
diff --git a/LayoutTests/svg/text/textquery-collapsed-whitespace.html b/LayoutTests/svg/text/textquery-collapsed-whitespace.html
new file mode 100644
index 0000000000000000000000000000000000000000..5c890d968e76159c5e0ad5687423bc45e6df6043
--- /dev/null
+++ b/LayoutTests/svg/text/textquery-collapsed-whitespace.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<title>Text queries on elements with collapsed whitespace</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<svg>
+ <text transform="translate(0 20)">A B C</text>
+ <text transform="translate(0 40)">A <tspan>B</tspan> C</text>
+ <text transform="translate(0 60)"> A B C </text>
+ <text transform="translate(0 80)"> A <tspan> B C </tspan> </text>
+ <text transform="translate(0 100)"> <tspan> A B </tspan> C </text>
+ <text transform="translate(0 120)"> A <tspan> B </tspan> C </text>
+</svg>
+<script>
+setup(function() {
+ window.textElements = document.getElementsByTagName('text');
+ var referenceElement = textElements[0];
+ window.reference = [];
+ for (var i = 0; i < 5; ++i)
+ reference.push(referenceElement.getExtentOfChar(i));
+});
+
+test(function() {
+ for (var j = 1; j < textElements.length; ++j) {
+ var element = textElements[j];
+ assert_equals(element.getNumberOfChars(), 5, 'collapsed length');
+
+ for (var i = 0; i < 5; ++i) {
+ var extents = element.getExtentOfChar(i);
+ for (var attr of ['x', 'y', 'width', 'height'])
+ assert_equals(extents[attr], reference[i][attr], 'same extents as reference (' + attr + ')');
+ }
+
+ var queryPoint = element.ownerSVGElement.createSVGPoint();
+ for (var i = 0; i < 5; ++i) {
+ queryPoint.x = reference[i].x + reference[i].width / 2;
+ queryPoint.y = reference[i].y + reference[i].height / 2;
+ assert_equals(element.getCharNumAtPosition(queryPoint), i, 'at same position as reference');
+ }
+ }
+});
+</script>
« no previous file with comments | « LayoutTests/svg/text/bidi-text-query.svg ('k') | LayoutTests/svg/text/textquery-collapsed-whitespace-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698