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

Unified Diff: LayoutTests/svg/dom/SVGSVGElement-intersection-enclosure.html

Issue 185333004: [SVG] Refactor getIntersectionList() and getEnclosureList() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Copyright notice update. Created 6 years, 10 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 | « no previous file | LayoutTests/svg/dom/SVGSVGElement-intersection-enclosure-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/svg/dom/SVGSVGElement-intersection-enclosure.html
diff --git a/LayoutTests/svg/dom/SVGSVGElement-intersection-enclosure.html b/LayoutTests/svg/dom/SVGSVGElement-intersection-enclosure.html
new file mode 100644
index 0000000000000000000000000000000000000000..74e4cc1427ec3b2134151bfa8684f5f628e25c11
--- /dev/null
+++ b/LayoutTests/svg/dom/SVGSVGElement-intersection-enclosure.html
@@ -0,0 +1,94 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <script src="../../resources/js-test.js"></script>
+</head>
+
+<body onload="run_test()">
+ <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200">
+ <g id="container" transform="translate(50, 50)">
+ <g id="subcontainer">
+ </g>
+ </g>
+ </svg>
+ <p id="description"></p>
+ <div id="console"></div>
+
+ <script>
+ jsTestIsAsync = true;
+ var svg = document.getElementById('svg');
+ var container = document.getElementById('container');
+ var subcontainer = document.getElementById('subcontainer');
+
+ for (var i = 0; i < 10; i++) {
+ for (var j = 0; j < 10; j++) {
+ var r = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
+ r.setAttribute('x', i * 10 + 1);
+ r.setAttribute('y', j * 10 + 1);
+ r.setAttribute('width', 8);
+ r.setAttribute('height', 8);
+ r.setAttribute('fill', 'green');
+ if (j < 5)
+ container.appendChild(r);
+ else
+ subcontainer.appendChild(r);
+ }
+ }
+
+ var rect = svg.createSVGRect();
+ var reference_element;
+
+ function check_enclosure_and_intersection(ref_id, e1, i1, e2, i2) {
+ reference_element = ref_id ? document.getElementById(ref_id) : null;
+
+ debug('');
+ rect.x = rect.y = 50;
+ rect.width = rect.height = 100;
+ debug('rect: [' + rect.x + ' ' + rect.y + ' '
+ + (rect.x + rect.width) + ' ' + (rect.y + rect.height) + ']');
+ debug('referenceElement: ' + ref_id);
+ shouldBe('svg.getEnclosureList(rect, reference_element).length', e1 + '');
+ shouldBe('svg.getIntersectionList(rect, reference_element).length',i1 + '');
+
+ debug('');
+ rect.x = rect.y = 55;
+ rect.width = rect.height = 90;
+ debug('rect: [' + rect.x + ' ' + rect.y + ' '
+ + (rect.x + rect.width) + ' ' + (rect.y + rect.height) + ']');
+ debug('referenceElement: ' + ref_id);
+ shouldBe('svg.getEnclosureList(rect, reference_element).length', e2 + '');
+ shouldBe('svg.getIntersectionList(rect, reference_element).length', i2 + '');
+ }
+
+ function run_test() {
+ description("Verify SVGSVGElement's getIntersectionList() " +
+ "and getEnclosureList() behavior.");
+
+ check_enclosure_and_intersection(null, 100, 100, 64, 100);
+ check_enclosure_and_intersection('container', 100, 100, 64, 100);
+ check_enclosure_and_intersection('subcontainer', 50, 50, 32, 50);
+
+ debug('');
+ debug('Zooming should not affect the results.');
+ if (window.eventSender) {
+ eventSender.zoomPageIn();
+ eventSender.zoomPageIn();
+ eventSender.zoomPageIn();
+ }
+ check_enclosure_and_intersection(null, 100, 100, 64, 100);
+ check_enclosure_and_intersection('container', 100, 100, 64, 100);
+ check_enclosure_and_intersection('subcontainer', 50, 50, 32, 50);
+
+ debug('');
+ debug('But a viewbox transform should.');
+ svg.setAttribute('viewBox', '0 0 150 150');
+ check_enclosure_and_intersection(null, 36, 49, 25, 36);
+ check_enclosure_and_intersection('container', 36, 49, 25, 36);
+ check_enclosure_and_intersection('subcontainer', 6, 14, 0, 6);
+
+ debug('');
+ finishJSTest();
+ }
+ </script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/svg/dom/SVGSVGElement-intersection-enclosure-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698