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

Unified Diff: third_party/WebKit/LayoutTests/fast/events/offsetX-offsetY-svg.html

Issue 2124283002: Use the outermost SVG as base when computing offsetX/Y for SVG elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | third_party/WebKit/Source/core/events/MouseRelatedEvent.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/events/offsetX-offsetY-svg.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/offsetX-offsetY-svg.html b/third_party/WebKit/LayoutTests/fast/events/offsetX-offsetY-svg.html
new file mode 100644
index 0000000000000000000000000000000000000000..586ed898e70c942528bf65dde1085b4906e21e20
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/offsetX-offsetY-svg.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<title>MouseEvent.offsetX/offsetY for an SVG element is always relative to the outermost &lt;svg> CSS layout box</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<style>
+svg {
+ border: 10px solid blue;
+ border-width: 20px 40px 30px 10px;
+}
+</style>
+<svg width="400" height="400" viewBox="0 0 400000 400000">
+ <rect x="40000" y="60000" width="80000" height="80000" fill="blue"/>
+ <rect x="160000" y="180000" width="80000" height="80000" fill="blue" stroke="lightblue" stroke-width="10000"/>
+</svg>
+<script>
+function check_offset(test, element, clientX, clientY, expectedOffsetX, expectedOffsetY) {
+ element.onclick = test.step_func(function(event) {
+ assert_equals(event.offsetX, expectedOffsetX, 'offsetX');
+ assert_equals(event.offsetY, expectedOffsetY, 'offsetY');
+ });
+ var mouseEvent = new MouseEvent('click', { clientX: clientX, clientY: clientY });
+ element.dispatchEvent(mouseEvent);
+}
+
+test(function(t) {
+ var rects = document.querySelectorAll('rect');
+ var svgBoundingRect = document.querySelector('svg').getBoundingClientRect();
+ var offsetBase = { x: svgBoundingRect.left + 10, y: svgBoundingRect.top + 20 };
+ check_offset(t, rects[0], offsetBase.x + 80, offsetBase.y + 100, 80, 100);
+ check_offset(t, rects[1], offsetBase.x + 200, offsetBase.y + 220, 200, 220);
+});
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/events/MouseRelatedEvent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698