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

Side by Side Diff: LayoutTests/compositing/gestures/resources/link-highlight-helper.js

Issue 322253004: Change compositing/gestures tests to avoid a one pixel difference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 function createSquareCompositedHighlight(node) 1 function createSquareCompositedHighlight(node)
2 { 2 {
3 return _createHighlight(node, "squaredHighlight highlightDiv composited"); 3 return _createHighlight(node, "squaredHighlight highlightDiv composited");
4 } 4 }
5 5
6 function createCompositedHighlight(node) 6 function createCompositedHighlight(node)
7 { 7 {
8 return _createHighlight(node, "highlightDiv composited"); 8 return _createHighlight(node, "highlightDiv composited");
9 } 9 }
10 10
11 function createHighlight(node) 11 function createHighlight(node)
12 { 12 {
13 return _createHighlight(node, "highlightDiv"); 13 return _createHighlight(node, "highlightDiv");
14 } 14 }
15 15
16 function _createHighlight(node, classes) { 16 function _createHighlight(node, classes) {
17 var div = document.createElement('div'); 17 var div = document.createElement('div');
18 div.setAttribute('id', 'highlight'); 18 div.setAttribute('id', 'highlight');
19 div.setAttribute('class', classes); 19 div.setAttribute('class', classes);
20 document.body.appendChild(div); 20 document.body.appendChild(div);
21 21
22 var offset = _getAbsoluteOffset(node);
23 var clientRect = node.getBoundingClientRect(); 22 var clientRect = node.getBoundingClientRect();
24 div.style.top = offset.top + "px"; 23 div.style.top = clientRect.top + "px";
25 div.style.left = offset.left + "px"; 24 div.style.left = clientRect.left + "px";
26 div.style.width = node.offsetWidth + "px"; 25 div.style.width = clientRect.width + "px";
27 div.style.height = node.offsetHeight + "px"; 26 div.style.height = clientRect.height + "px";
28 27
29 return div; 28 return div;
30 } 29 }
31
32 function _getAbsoluteOffset( elem )
33 {
34 var offsetLeft = 0;
35 var offsetTop = 0;
36 do {
37 if ( !isNaN( elem.offsetLeft ) )
38 offsetLeft += elem.offsetLeft - elem.scrollLeft;
39
40 if ( !isNaN( elem.offsetTop ) )
41 offsetTop += elem.offsetTop - elem.scrollTop;
42
43 } while( elem = elem.offsetParent );
44 return { top : offsetTop,
45 left : offsetLeft };
46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698