| 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 * @fileoverview Support code for the Contextual Search feature. Given a tap | 6 * @fileoverview Support code for the Contextual Search feature. Given a tap |
| 7 * location, locates and highlights the word at that location, and retuns | 7 * location, locates and highlights the word at that location, and retuns |
| 8 * some contextual data about the selection. | 8 * some contextual data about the selection. |
| 9 * | 9 * |
| 10 */ | 10 */ |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 | 779 |
| 780 /** | 780 /** |
| 781 * Checks whether the context in a given point is valid. A context will be | 781 * Checks whether the context in a given point is valid. A context will be |
| 782 * valid when the element at the given point is not interactive or editable. | 782 * valid when the element at the given point is not interactive or editable. |
| 783 * @param {number} x The point's x coordinate. | 783 * @param {number} x The point's x coordinate. |
| 784 * @param {number} y The point's y coordinate. | 784 * @param {number} y The point's y coordinate. |
| 785 * @return {ContextData} Context data from the point, an error set if invalid. | 785 * @return {ContextData} Context data from the point, an error set if invalid. |
| 786 * @private | 786 * @private |
| 787 */ | 787 */ |
| 788 Context.contextFromPoint = function(x, y) { | 788 Context.contextFromPoint = function(x, y) { |
| 789 // Should this use core.js's elementFromPoint_() instead? | 789 // TODO(crbug.com/711350): Evaluate whether this should use context_menu.js's |
| 790 // elementFromPoint_() instead? |
| 790 var contextData = new ContextData(); | 791 var contextData = new ContextData(); |
| 791 var element = document.elementFromPoint(x, y); | 792 var element = document.elementFromPoint(x, y); |
| 792 if (!element) { | 793 if (!element) { |
| 793 contextData.error = "Failed: Couldn't locate an element at " + x + ', ' + y; | 794 contextData.error = "Failed: Couldn't locate an element at " + x + ', ' + y; |
| 794 return contextData; | 795 return contextData; |
| 795 } | 796 } |
| 796 | 797 |
| 797 var d = new Date(); | 798 var d = new Date(); |
| 798 var lastDOM = d.getTime() - Context.lastDOMMutationMillisecond; | 799 var lastDOM = d.getTime() - Context.lastDOMMutationMillisecond; |
| 799 if (lastDOM <= Context.DOMMutationTimeoutMillisecond) { | 800 if (lastDOM <= Context.DOMMutationTimeoutMillisecond) { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1332 var bottom = rects[i].bottom + document.body.scrollTop; | 1333 var bottom = rects[i].bottom + document.body.scrollTop; |
| 1333 var left = rects[i].left + document.body.scrollLeft; | 1334 var left = rects[i].left + document.body.scrollLeft; |
| 1334 var right = rects[i].right + document.body.scrollLeft; | 1335 var right = rects[i].right + document.body.scrollLeft; |
| 1335 rectsArray[i] = '' + top + ' ' + bottom + ' ' + left + ' ' + right; | 1336 rectsArray[i] = '' + top + ' ' + bottom + ' ' + left + ' ' + right; |
| 1336 } | 1337 } |
| 1337 return rectsArray.join(','); | 1338 return rectsArray.join(','); |
| 1338 }; | 1339 }; |
| 1339 | 1340 |
| 1340 /* Anyonymizing block end */ | 1341 /* Anyonymizing block end */ |
| 1341 } | 1342 } |
| OLD | NEW |