| 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 shadowHost(node) |
| 67 { |
| 68 for (; node != null; node = node.parentNode) { |
| 69 if (node.host) |
| 70 return node.host; |
| 71 } |
| 72 return node; |
| 73 } |
| 74 |
| 75 function testTouchPoint(touchpoint, targetNode, allowTextNodes, disallowShadowDO
M) |
| 67 { | 76 { |
| 68 var adjustedNode = internals.touchNodeAdjustedToBestClickableNode(touchpoint
.left, touchpoint.top, touchpoint.width, touchpoint.height, document); | 77 var adjustedNode = internals.touchNodeAdjustedToBestClickableNode(touchpoint
.left, touchpoint.top, touchpoint.width, touchpoint.height, document); |
| 69 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) | 78 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) |
| 70 adjustedNode = adjustedNode.parentNode; | 79 adjustedNode = adjustedNode.parentNode; |
| 80 if (disallowShadowDOM && adjustedNode && adjustedNode.nodeType == 1) { |
| 81 while (shadowHost(adjustedNode)) |
| 82 adjustedNode = shadowHost(adjustedNode); |
| 83 } |
| 71 shouldBeNode(adjustedNode, targetNode); | 84 shouldBeNode(adjustedNode, targetNode); |
| 72 } | 85 } |
| 73 | 86 |
| 74 function testTouchPointContextMenu(touchpoint, targetNode, allowTextNodes) | 87 function testTouchPointContextMenu(touchpoint, targetNode, allowTextNodes) |
| 75 { | 88 { |
| 76 var adjustedNode = internals.touchNodeAdjustedToBestContextMenuNode(touchpoi
nt.left, touchpoint.top, touchpoint.width, touchpoint.height, document); | 89 var adjustedNode = internals.touchNodeAdjustedToBestContextMenuNode(touchpoi
nt.left, touchpoint.top, touchpoint.width, touchpoint.height, document); |
| 77 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) | 90 if (!allowTextNodes && adjustedNode && adjustedNode.nodeType == 3) |
| 78 adjustedNode = adjustedNode.parentNode; | 91 adjustedNode = adjustedNode.parentNode; |
| 79 shouldBeNode(adjustedNode, targetNode); | 92 shouldBeNode(adjustedNode, targetNode); |
| 80 } | 93 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 touchpoint.left += bounds.width / 2; | 161 touchpoint.left += bounds.width / 2; |
| 149 touchpoint.top -= touchOffset; | 162 touchpoint.top -= touchOffset; |
| 150 break; | 163 break; |
| 151 case 'bottom': | 164 case 'bottom': |
| 152 touchpoint.left += bounds.width / 2; | 165 touchpoint.left += bounds.width / 2; |
| 153 touchpoint.top += bounds.height + touchOffset; | 166 touchpoint.top += bounds.height + touchOffset; |
| 154 } | 167 } |
| 155 | 168 |
| 156 return touchpoint; | 169 return touchpoint; |
| 157 } | 170 } |
| OLD | NEW |