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

Side by Side Diff: LayoutTests/svg/text/resources/SelectionTestCase.js

Issue 1114093002: Fix mouse position to truncate the coordinate for mouseMoveTo(...) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Draft 2 Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 if (!window.eventSender || !window.testRunner) { 1 if (!window.eventSender || !window.testRunner) {
2 alert('This test needs to be run in DRT, to get results!'); 2 alert('This test needs to be run in DRT, to get results!');
3 } 3 }
4 4
5 var svgRoot = 0; 5 var svgRoot = 0;
6 6
7 // Map 'point' into absolute coordinates, usable for eventSender 7 // Map 'point' into absolute coordinates, usable for eventSender
8 function transformPoint(point, matrix) { 8 function transformPoint(point, matrix) {
9 return point.matrixTransform(matrix); 9 return point.matrixTransform(matrix);
10 } 10 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 startPos = transformPoint(startPos, scaleMatrix); 57 startPos = transformPoint(startPos, scaleMatrix);
58 endPos = transformPoint(endPos, scaleMatrix); 58 endPos = transformPoint(endPos, scaleMatrix);
59 59
60 startExtent = transformRect(startExtent, scaleMatrix); 60 startExtent = transformRect(startExtent, scaleMatrix);
61 endExtent = transformRect(endExtent, scaleMatrix); 61 endExtent = transformRect(endExtent, scaleMatrix);
62 } 62 }
63 63
64 if (window.eventSender) { 64 if (window.eventSender) {
65 // Trigger 'partial glyph selection' code, by adjusting the end x positi on by half glyph width 65 // Trigger 'partial glyph selection' code, by adjusting the end x positi on by half glyph width
66 var xOld = endPos.x; 66 var xOldStart = startPos.x;
67 var xOldEnd = endPos.x;
67 endPos.x -= endExtent.width / 2 - 1; 68 endPos.x -= endExtent.width / 2 - 1;
68 69
70 // Round the points "inwards" to avoid being affected by the truncation
71 // taking place in eventSender.mouseMoveTo(...).
72 startPos.x = Math.ceil(startPos.x);
73
69 var absStartPos = toAbsoluteCoordinates(startPos, element); 74 var absStartPos = toAbsoluteCoordinates(startPos, element);
70 var absEndPos = toAbsoluteCoordinates(endPos, element); 75 var absEndPos = toAbsoluteCoordinates(endPos, element);
71 76
72 // Round the points "inwards" to avoid being affected by the truncation
73 // taking place in eventSender.mouseMoveTo(...).
74 absStartPos.x = Math.ceil(absStartPos.x);
75 absEndPos.x = Math.floor(absEndPos.x);
76
77 // Move to selection origin and hold down mouse 77 // Move to selection origin and hold down mouse
78 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y); 78 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y);
79 eventSender.mouseDown(); 79 eventSender.mouseDown();
80 80
81 // Move again to start selection 81 // Move again to start selection
82 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y); 82 eventSender.mouseMoveTo(absStartPos.x, absStartPos.y);
83 83
84 // Move to end location and release mouse 84 // Move to end location and release mouse
85 eventSender.mouseMoveTo(absEndPos.x, absEndPos.y); 85 eventSender.mouseMoveTo(absEndPos.x, absEndPos.y);
86 eventSender.mouseUp(); 86 eventSender.mouseUp();
87 87
88 endPos.x = xOld; 88 startPos.x = xOldStart;
89 endPos.x = xOldEnd;
89 } 90 }
90 91
91 // Mark start position using a green line 92 // Mark start position using a green line
92 var startLineElement = document.createElementNS("http://www.w3.org/2000/svg" , "svg:line"); 93 var startLineElement = document.createElementNS("http://www.w3.org/2000/svg" , "svg:line");
93 startLineElement.setAttribute("x1", startPos.x); 94 startLineElement.setAttribute("x1", startPos.x);
94 startLineElement.setAttribute("y1", startExtent.y); 95 startLineElement.setAttribute("y1", startExtent.y);
95 startLineElement.setAttribute("x2", startPos.x); 96 startLineElement.setAttribute("x2", startPos.x);
96 startLineElement.setAttribute("y2", startExtent.height + 1); 97 startLineElement.setAttribute("y2", startExtent.height + 1);
97 startLineElement.setAttribute("stroke", "green"); 98 startLineElement.setAttribute("stroke", "green");
98 document.getElementById("container").appendChild(startLineElement); 99 document.getElementById("container").appendChild(startLineElement);
(...skipping 23 matching lines...) Expand all
122 var textElement = document.createElementNS("http://www.w3.org/2000/svg", "svg:text"); 123 var textElement = document.createElementNS("http://www.w3.org/2000/svg", "svg:text");
123 textElement.setAttribute("x", "0"); 124 textElement.setAttribute("x", "0");
124 textElement.setAttribute("y", "35"); 125 textElement.setAttribute("y", "35");
125 textElement.setAttribute("fill", "red"); 126 textElement.setAttribute("fill", "red");
126 textElement.setAttribute("transform", "scale(0.5)"); 127 textElement.setAttribute("transform", "scale(0.5)");
127 textElement.setAttribute("font-size", "8"); 128 textElement.setAttribute("font-size", "8");
128 textElement.textContent = "Expected '" + expectedText + "' to be selecte d, got: '" + actualText + "'"; 129 textElement.textContent = "Expected '" + expectedText + "' to be selecte d, got: '" + actualText + "'";
129 document.getElementById("container").appendChild(textElement); 130 document.getElementById("container").appendChild(textElement);
130 } 131 }
131 } 132 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698