| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 if (!containerNode) | 112 if (!containerNode) |
| 113 continue; | 113 continue; |
| 114 if (!blackList.add(containerNode).isNewEntry) | 114 if (!blackList.add(containerNode).isNewEntry) |
| 115 break; | 115 break; |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 HeapHashMap<Member<Node>, TouchTargetData> touchTargets; | 119 HeapHashMap<Member<Node>, TouchTargetData> touchTargets; |
| 120 float bestScore = 0; | 120 float bestScore = 0; |
| 121 for (const auto& hitResult : hitResults) { | 121 for (const auto& hitResult : hitResults) { |
| 122 for (Node* node = hitResult.get(); node; node = node->parentNode()) { | 122 if (!hitResult) |
| 123 if (blackList.contains(node)) | 123 continue; |
| 124 for (Node& node : NodeTraversal::inclusiveAncestorsOf(*hitResult)) { |
| 125 if (blackList.contains(&node)) |
| 124 continue; | 126 continue; |
| 125 if (node->isDocumentNode() || isHTMLHtmlElement(*node) || isHTMLBody
Element(*node)) | 127 if (node.isDocumentNode() || isHTMLHtmlElement(node) || isHTMLBodyEl
ement(node)) |
| 126 break; | 128 break; |
| 127 if (node->willRespondToMouseClickEvents()) { | 129 if (node.willRespondToMouseClickEvents()) { |
| 128 TouchTargetData& targetData = touchTargets.add(node, TouchTarget
Data()).storedValue->value; | 130 TouchTargetData& targetData = touchTargets.add(&node, TouchTarge
tData()).storedValue->value; |
| 129 targetData.windowBoundingBox = boundingBoxForEventNodes(node); | 131 targetData.windowBoundingBox = boundingBoxForEventNodes(&node); |
| 130 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin
g, targetData.windowBoundingBox); | 132 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin
g, targetData.windowBoundingBox); |
| 131 bestScore = std::max(bestScore, targetData.score); | 133 bestScore = std::max(bestScore, targetData.score); |
| 132 break; | 134 break; |
| 133 } | 135 } |
| 134 } | 136 } |
| 135 } | 137 } |
| 136 | 138 |
| 137 for (const auto& touchTarget : touchTargets) { | 139 for (const auto& touchTarget : touchTargets) { |
| 138 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. | 140 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. |
| 139 // We ignore the candidates that has less than 1/2 overlap (we consider
not really ambiguous enough) than the best candidate to avoid excessive popups. | 141 // We ignore the candidates that has less than 1/2 overlap (we consider
not really ambiguous enough) than the best candidate to avoid excessive popups. |
| 140 if (touchTarget.value.score < bestScore * 0.5) | 142 if (touchTarget.value.score < bestScore * 0.5) |
| 141 continue; | 143 continue; |
| 142 goodTargets.append(touchTarget.value.windowBoundingBox); | 144 goodTargets.append(touchTarget.value.windowBoundingBox); |
| 143 highlightNodes.append(touchTarget.key); | 145 highlightNodes.append(touchTarget.key); |
| 144 } | 146 } |
| 145 } | 147 } |
| 146 | 148 |
| 147 } // namespace blink | 149 } // namespace blink |
| OLD | NEW |