| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 HashMap<Node*, TouchTargetData> touchTargets; | 122 HashMap<Node*, TouchTargetData> touchTargets; |
| 123 float bestScore = 0; | 123 float bestScore = 0; |
| 124 for (ListHashSet<RefPtr<Node> >::const_iterator it = hitResults.begin(); it
!= hitResults.end(); ++it) { | 124 for (ListHashSet<RefPtr<Node> >::const_iterator it = hitResults.begin(); it
!= hitResults.end(); ++it) { |
| 125 for (Node* node = it->get(); node; node = node->parentNode()) { | 125 for (Node* node = it->get(); node; node = node->parentNode()) { |
| 126 if (blackList.contains(node)) | 126 if (blackList.contains(node)) |
| 127 continue; | 127 continue; |
| 128 if (node->isDocumentNode() || node->hasTagName(HTMLNames::htmlTag) |
| node->hasTagName(HTMLNames::bodyTag)) | 128 if (node->isDocumentNode() || node->hasTagName(HTMLNames::htmlTag) |
| node->hasTagName(HTMLNames::bodyTag)) |
| 129 break; | 129 break; |
| 130 if (node->willRespondToMouseClickEvents()) { | 130 if (node->willRespondToMouseClickEvents()) { |
| 131 TouchTargetData& targetData = touchTargets.add(node, TouchTarget
Data()).iterator->value; | 131 TouchTargetData& targetData = touchTargets.add(node, TouchTarget
Data()).storedValue->value; |
| 132 targetData.windowBoundingBox = boundingBoxForEventNodes(node); | 132 targetData.windowBoundingBox = boundingBoxForEventNodes(node); |
| 133 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin
g, targetData.windowBoundingBox); | 133 targetData.score = scoreTouchTarget(touchPoint, touchPointPaddin
g, targetData.windowBoundingBox); |
| 134 bestScore = max(bestScore, targetData.score); | 134 bestScore = max(bestScore, targetData.score); |
| 135 break; | 135 break; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 for (HashMap<Node*, TouchTargetData>::iterator it = touchTargets.begin(); it
!= touchTargets.end(); ++it) { | 140 for (HashMap<Node*, TouchTargetData>::iterator it = touchTargets.begin(); it
!= touchTargets.end(); ++it) { |
| 141 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. | 141 // Currently the scoring function uses the overlap area with the fat poi
nt as the score. |
| 142 // 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. | 142 // 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. |
| 143 if (it->value.score < bestScore * 0.5) | 143 if (it->value.score < bestScore * 0.5) |
| 144 continue; | 144 continue; |
| 145 goodTargets.append(it->value.windowBoundingBox); | 145 goodTargets.append(it->value.windowBoundingBox); |
| 146 highlightNodes.append(it->key); | 146 highlightNodes.append(it->key); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace WebCore | 150 } // namespace WebCore |
| OLD | NEW |