Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* function for finding the absolute bounds of a node (both inline and block) */ | 1 /* function for finding the absolute bounds of a node (both inline and block) */ |
| 2 function findAbsoluteBounds(node) | 2 function findAbsoluteBounds(node) |
| 3 { | 3 { |
| 4 var bounds = node.getBoundingClientRect(); | 4 var bounds = node.getBoundingClientRect(); |
| 5 return { | 5 return { |
| 6 left: bounds.left, | 6 left: bounds.left, |
| 7 top: bounds.top, | 7 top: bounds.top, |
| 8 width: bounds.right - bounds.left, | 8 width: bounds.right - bounds.left, |
| 9 height: bounds.bottom - bounds.top | 9 height: bounds.bottom - bounds.top |
| 10 }; | 10 }; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 function shouldBeWithin(adjustedPoint, targetArea) { | 56 function shouldBeWithin(adjustedPoint, targetArea) { |
| 57 if (adjustedPoint.x >= targetArea.left && adjustedPoint.y >= targetArea.top | 57 if (adjustedPoint.x >= targetArea.left && adjustedPoint.y >= targetArea.top |
| 58 && adjustedPoint.x <= (targetArea.left + targetArea.width) | 58 && adjustedPoint.x <= (targetArea.left + targetArea.width) |
| 59 && adjustedPoint.y <= (targetArea.top + targetArea.height)) { | 59 && adjustedPoint.y <= (targetArea.top + targetArea.height)) { |
| 60 testPassed("adjusted point was within " + boundsToString(targetArea)); | 60 testPassed("adjusted point was within " + boundsToString(targetArea)); |
| 61 } else { | 61 } else { |
| 62 testFailed("adjusted node should be within " + boundsToString(targetArea ) + ". Was " + pointToString(adjustedPoint)); | 62 testFailed("adjusted node should be within " + boundsToString(targetArea ) + ". Was " + pointToString(adjustedPoint)); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 function testTouchPoint(touchpoint, targetNode, allowTextNodes) | 66 function touchNodeAdjustedToBestClickableNode(left, top, width, height, doc, all owShadowDOM) |
| 67 { | 67 { |
| 68 var adjustedNode = internals.touchNodeAdjustedToBestClickableNode(touchpoint .left, touchpoint.top, touchpoint.width, touchpoint.height, document); | 68 var adjustedNode = internals.touchNodeAdjustedToBestClickableNode(left, top, width, height, doc); |
| 69 if (!allowShadowDOM && adjustedNode && adjustedNode.nodeType == 1) { | |
|
Rick Byers
2014/07/07 18:25:44
There's probably only the one test that actually r
Zeeshan Qureshi
2014/07/09 16:10:14
There's a couple of tests that do adjustment on <i
| |
| 70 while (internals.shadowHost(adjustedNode)) { | |
|
Rick Byers
2014/07/07 18:25:44
Rather than add shadowHost to internals, you shoul
Zeeshan Qureshi
2014/07/09 16:10:14
Looks like this is for traversing down the tree.
Rick Byers
2014/07/09 19:46:58
Ah right. Still I think we can avoid adding a new
| |
| 71 adjustedNode = internals.shadowHost(adjustedNode); | |
| 72 } | |
| 73 } | |
| 74 return adjustedNode; | |
| 75 } | |
| 76 | |
| 77 function testTouchPoint(touchpoint, targetNode, allowTextNodes, allowShadowDOM) | |
| 78 { | |
| 79 var adjustedNode = touchNodeAdjustedToBestClickableNode(touchpoint.left, tou chpoint.top, touchpoint.width, touchpoint.height, document, allowShadowDOM); | |
| 69 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) | 80 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) |
| 70 adjustedNode = adjustedNode.parentNode; | 81 adjustedNode = adjustedNode.parentNode; |
| 71 shouldBeNode(adjustedNode, targetNode); | 82 shouldBeNode(adjustedNode, targetNode); |
| 72 } | 83 } |
| 73 | 84 |
| 74 function testTouchPointContextMenu(touchpoint, targetNode, allowTextNodes) | 85 function testTouchPointContextMenu(touchpoint, targetNode, allowTextNodes) |
| 75 { | 86 { |
| 76 var adjustedNode = internals.touchNodeAdjustedToBestContextMenuNode(touchpoi nt.left, touchpoint.top, touchpoint.width, touchpoint.height, document); | 87 var adjustedNode = internals.touchNodeAdjustedToBestContextMenuNode(touchpoi nt.left, touchpoint.top, touchpoint.width, touchpoint.height, document); |
| 77 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) | 88 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) |
| 78 adjustedNode = adjustedNode.parentNode; | 89 adjustedNode = adjustedNode.parentNode; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 touchpoint.left += bounds.width / 2; | 159 touchpoint.left += bounds.width / 2; |
| 149 touchpoint.top -= touchOffset; | 160 touchpoint.top -= touchOffset; |
| 150 break; | 161 break; |
| 151 case 'bottom': | 162 case 'bottom': |
| 152 touchpoint.left += bounds.width / 2; | 163 touchpoint.left += bounds.width / 2; |
| 153 touchpoint.top += bounds.height + touchOffset; | 164 touchpoint.top += bounds.height + touchOffset; |
| 154 } | 165 } |
| 155 | 166 |
| 156 return touchpoint; | 167 return touchpoint; |
| 157 } | 168 } |
| OLD | NEW |