| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 /** | 6 /** |
| 7 * @fileoverview Helper functions. | 7 * @fileoverview Helper functions. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 goog.provide('cvox.SearchUtil'); | 10 goog.provide('cvox.SearchUtil'); |
| 11 | 11 |
| 12 /** Utility functions. */ | 12 /** Utility functions. */ |
| 13 cvox.SearchUtil = function() { | 13 cvox.SearchUtil = function() {}; |
| 14 }; | |
| 15 | 14 |
| 16 /** | 15 /** |
| 17 * Extracts the first URL from an element. | 16 * Extracts the first URL from an element. |
| 18 * @param {Node} node DOM element to extract from. | 17 * @param {Node} node DOM element to extract from. |
| 19 * @return {?string} URL. | 18 * @return {?string} URL. |
| 20 */ | 19 */ |
| 21 cvox.SearchUtil.extractURL = function(node) { | 20 cvox.SearchUtil.extractURL = function(node) { |
| 22 if (node) { | 21 if (node) { |
| 23 if (node.tagName === 'A') { | 22 if (node.tagName === 'A') { |
| 24 return node.href; | 23 return node.href; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 if (!keepGoing) { | 148 if (!keepGoing) { |
| 150 // The onclick method ran successfully and returned false, meaning the | 149 // The onclick method ran successfully and returned false, meaning the |
| 151 // event should not bubble up, so we will return here. | 150 // event should not bubble up, so we will return here. |
| 152 return; | 151 return; |
| 153 } | 152 } |
| 154 } | 153 } |
| 155 | 154 |
| 156 // Send a mousedown (or simply a double click if requested). | 155 // Send a mousedown (or simply a double click if requested). |
| 157 var evt = document.createEvent('MouseEvents'); | 156 var evt = document.createEvent('MouseEvents'); |
| 158 var evtType = opt_double ? 'dblclick' : 'mousedown'; | 157 var evtType = opt_double ? 'dblclick' : 'mousedown'; |
| 159 evt.initMouseEvent(evtType, true, true, document.defaultView, | 158 evt.initMouseEvent( |
| 160 1, 0, 0, 0, 0, false, false, shiftKey, false, 0, null); | 159 evtType, true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, |
| 160 shiftKey, false, 0, null); |
| 161 // Mark any events we generate so we don't try to process our own events. | 161 // Mark any events we generate so we don't try to process our own events. |
| 162 evt.fromCvox = true; | 162 evt.fromCvox = true; |
| 163 try { | 163 try { |
| 164 targetNode.dispatchEvent(evt); | 164 targetNode.dispatchEvent(evt); |
| 165 } catch (e) {} | 165 } catch (e) { |
| 166 //Send a mouse up | 166 } |
| 167 // Send a mouse up |
| 167 evt = document.createEvent('MouseEvents'); | 168 evt = document.createEvent('MouseEvents'); |
| 168 evt.initMouseEvent('mouseup', true, true, document.defaultView, | 169 evt.initMouseEvent( |
| 169 1, 0, 0, 0, 0, false, false, shiftKey, false, 0, null); | 170 'mouseup', true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, |
| 171 shiftKey, false, 0, null); |
| 170 // Mark any events we generate so we don't try to process our own events. | 172 // Mark any events we generate so we don't try to process our own events. |
| 171 evt.fromCvox = true; | 173 evt.fromCvox = true; |
| 172 try { | 174 try { |
| 173 targetNode.dispatchEvent(evt); | 175 targetNode.dispatchEvent(evt); |
| 174 } catch (e) {} | 176 } catch (e) { |
| 175 //Send a click | 177 } |
| 178 // Send a click |
| 176 evt = document.createEvent('MouseEvents'); | 179 evt = document.createEvent('MouseEvents'); |
| 177 evt.initMouseEvent('click', true, true, document.defaultView, | 180 evt.initMouseEvent( |
| 178 1, 0, 0, 0, 0, false, false, shiftKey, false, 0, null); | 181 'click', true, true, document.defaultView, 1, 0, 0, 0, 0, false, false, |
| 182 shiftKey, false, 0, null); |
| 179 // Mark any events we generate so we don't try to process our own events. | 183 // Mark any events we generate so we don't try to process our own events. |
| 180 evt.fromCvox = true; | 184 evt.fromCvox = true; |
| 181 try { | 185 try { |
| 182 targetNode.dispatchEvent(evt); | 186 targetNode.dispatchEvent(evt); |
| 183 } catch (e) {} | 187 } catch (e) { |
| 188 } |
| 184 }; | 189 }; |
| OLD | NEW |