Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1412)

Unified Diff: Source/devtools/front_end/ui/UIUtils.js

Issue 727823002: [DevTools] Ban getSelection, requestAnimationFrame, cancelAnimationFrame global functions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/ui/UIUtils.js
diff --git a/Source/devtools/front_end/ui/UIUtils.js b/Source/devtools/front_end/ui/UIUtils.js
index 62bce6d70212b9851418b62f133749f79630835f..0ccf056e5e5e6d896b33a39cfd5e19e30669a5b6 100644
--- a/Source/devtools/front_end/ui/UIUtils.js
+++ b/Source/devtools/front_end/ui/UIUtils.js
@@ -363,7 +363,7 @@ WebInspector.handleElementValueModifications = function(event, element, finishHa
if (!arrowKeyOrMouseWheelEvent && !pageKeyPressed)
return false;
- var selection = window.getSelection();
+ var selection = element.window().getSelection();
if (!selection.rangeCount)
return false;
@@ -697,6 +697,9 @@ WebInspector._isTextEditingElement = function(element)
return false;
}
+/**
+ * @param {?Node} x
+ */
WebInspector.setCurrentFocusElement = function(x)
{
if (WebInspector._glassPane && x && !WebInspector._glassPane.element.isAncestor(x))
@@ -711,7 +714,7 @@ WebInspector.setCurrentFocusElement = function(x)
// Make a caret selection inside the new element if there isn't a range selection and there isn't already a caret selection inside.
// This is needed (at least) to remove caret from console when focus is moved to some element in the panel.
// The code below should not be applied to text fields and text areas, hence _isTextEditingElement check.
- var selection = window.getSelection();
+ var selection = x.window().getSelection();
if (!WebInspector._isTextEditingElement(WebInspector._currentFocusElement) && selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCaretInside()) {
var selectionRange = WebInspector._currentFocusElement.ownerDocument.createRange();
selectionRange.setStart(WebInspector._currentFocusElement, 0);
@@ -987,6 +990,9 @@ WebInspector.InvokeOnceHandlers.prototype = {
methods.add(method);
},
+ /**
+ * @suppressGlobalPropertiesCheck
+ */
scheduleInvoke: function()
{
if (this._handlers)
@@ -1036,13 +1042,14 @@ WebInspector.invokeOnceAfterBatchUpdate = function(object, method)
}
/**
+ * @param {!Window} window
* @param {!Function} func
* @param {!Array.<{from:number, to:number}>} params
* @param {number} frames
* @param {function()=} animationComplete
* @return {function()}
*/
-WebInspector.animateFunction = function(func, params, frames, animationComplete)
+WebInspector.animateFunction = function(window, func, params, frames, animationComplete)
{
var values = new Array(params.length);
var deltas = new Array(params.length);
@@ -1051,7 +1058,7 @@ WebInspector.animateFunction = function(func, params, frames, animationComplete)
deltas[i] = (params[i].to - params[i].from) / frames;
}
- var raf = requestAnimationFrame(animationStep);
+ var raf = window.requestAnimationFrame(animationStep);
var framesLeft = frames;

Powered by Google App Engine
This is Rietveld 408576698