diff options
author | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 23:47:06 +0000 |
---|---|---|
committer | arv@chromium.org <arv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 23:47:06 +0000 |
commit | 3ed462685a542d3a9625d8fa24a5755a283530ae (patch) | |
tree | 72b60d41d6294059527a5120df595eb7c73f48ab /chrome/browser/resources/shared | |
parent | baa88b42ff4fe68d8bd096b2c4c28a4ebdac6910 (diff) | |
download | chromium_src-3ed462685a542d3a9625d8fa24a5755a283530ae.zip chromium_src-3ed462685a542d3a9625d8fa24a5755a283530ae.tar.gz chromium_src-3ed462685a542d3a9625d8fa24a5755a283530ae.tar.bz2 |
DOMUI etc. Use the built in bind method of Function now that V8 supports it.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/3308030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59303 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/shared')
-rw-r--r-- | chrome/browser/resources/shared/js/cr.js | 32 | ||||
-rw-r--r-- | chrome/browser/resources/shared/js/cr/ui/command.js | 4 | ||||
-rw-r--r-- | chrome/browser/resources/shared/js/cr/ui/list.js | 10 | ||||
-rw-r--r-- | chrome/browser/resources/shared/js/cr/ui/splitter.js | 6 | ||||
-rw-r--r-- | chrome/browser/resources/shared/js/cr/ui/tree.js | 4 |
5 files changed, 12 insertions, 44 deletions
diff --git a/chrome/browser/resources/shared/js/cr.js b/chrome/browser/resources/shared/js/cr.js index 77bc40d..25ba498 100644 --- a/chrome/browser/resources/shared/js/cr.js +++ b/chrome/browser/resources/shared/js/cr.js @@ -248,37 +248,6 @@ const cr = (function() { } /** - * Partially applies this function to a particular 'this object' and zero or - * more arguments. The result is a new function with some arguments of the - * first function pre-filled and the value of |this| 'pre-specified'. - * - * Remaining arguments specified at call-time are appended to the pre- - * specified ones. - * - * Usage: - * <pre>var barMethBound = bind(myFunction, myObj, 'arg1', 'arg2'); - * barMethBound('arg3', 'arg4');</pre> - * - * @param {Function} fn A function to partially apply. - * @param {Object|undefined} selfObj Specifies the object which |this| should - * point to when the function is run. If the value is null or undefined, - * it will default to the global object. - * @param {...*} var_args Additional arguments that are partially - * applied to the function. - * - * @return {!Function} A partially-applied form of the function bind() was - * invoked as a method of. - */ - function bind(fn, selfObj, var_args) { - var boundArgs = Array.prototype.slice.call(arguments, 2); - return function() { - var args = Array.prototype.slice.call(arguments); - args.unshift.apply(args, boundArgs); - return fn.apply(selfObj, args); - } - } - - /** * Dispatches a simple event on an event target. * @param {!EventTarget} target The event target to dispatch the event on. * @param {string} type The type of the event. @@ -355,7 +324,6 @@ const cr = (function() { PropertyKind: PropertyKind, createUid: createUid, getUid: getUid, - bind: bind, dispatchSimpleEvent: dispatchSimpleEvent, dispatchPropertyChange: dispatchPropertyChange, diff --git a/chrome/browser/resources/shared/js/cr/ui/command.js b/chrome/browser/resources/shared/js/cr/ui/command.js index 4f4610d..1011398 100644 --- a/chrome/browser/resources/shared/js/cr/ui/command.js +++ b/chrome/browser/resources/shared/js/cr/ui/command.js @@ -194,10 +194,10 @@ cr.define('cr.ui', function() { * @constructor */ function CommandManager(doc) { - doc.addEventListener('focus', cr.bind(this.handleFocus_, this), true); + doc.addEventListener('focus', this.handleFocus_.bind(this), true); // Make sure we add the listener to the bubbling phase so that elements can // prevent the command. - doc.addEventListener('keydown', cr.bind(this.handleKeyDown_, this), false); + doc.addEventListener('keydown', this.handleKeyDown_.bind(this), false); } /** diff --git a/chrome/browser/resources/shared/js/cr/ui/list.js b/chrome/browser/resources/shared/js/cr/ui/list.js index 234d8db..1ac2f9c 100644 --- a/chrome/browser/resources/shared/js/cr/ui/list.js +++ b/chrome/browser/resources/shared/js/cr/ui/list.js @@ -92,9 +92,9 @@ cr.define('cr.ui', function() { if (this.dataModel_ != dataModel) { if (!this.boundHandleDataModelSplice_) { this.boundHandleDataModelSplice_ = - cr.bind(this.handleDataModelSplice_, this); + this.handleDataModelSplice_.bind(this); this.boundHandleDataModelChange_ = - cr.bind(this.handleDataModelChange_, this); + this.handleDataModelChange_.bind(this); } if (this.dataModel_) { @@ -139,8 +139,8 @@ cr.define('cr.ui', function() { return; if (!this.boundHandleOnChange_) { - this.boundHandleOnChange_ = cr.bind(this.handleOnChange_, this); - this.boundHandleLeadChange_ = cr.bind(this.handleLeadChange_, this); + this.boundHandleOnChange_ = this.handleOnChange_.bind(this); + this.boundHandleLeadChange_ = this.handleLeadChange_.bind(this); } if (oldSm) { @@ -242,7 +242,7 @@ cr.define('cr.ui', function() { this.addEventListener('mousedown', this.handleMouseDownUp_); this.addEventListener('mouseup', this.handleMouseDownUp_); this.addEventListener('keydown', this.handleKeyDown); - this.addEventListener('scroll', cr.bind(this.redraw, this)); + this.addEventListener('scroll', this.redraw.bind(this)); // Make list focusable if (!this.hasAttribute('tabindex')) diff --git a/chrome/browser/resources/shared/js/cr/ui/splitter.js b/chrome/browser/resources/shared/js/cr/ui/splitter.js index 4f9510e..3ede5ea 100644 --- a/chrome/browser/resources/shared/js/cr/ui/splitter.js +++ b/chrome/browser/resources/shared/js/cr/ui/splitter.js @@ -67,7 +67,7 @@ cr.define('cr.ui', function() { * Initializes the element. */ decorate: function() { - this.addEventListener('mousedown', cr.bind(this.handleMouseDown_, this), + this.addEventListener('mousedown', this.handleMouseDown_.bind(this), true); }, @@ -77,8 +77,8 @@ cr.define('cr.ui', function() { */ startDrag: function(e) { if (!this.boundHandleMouseMove_) { - this.boundHandleMouseMove_ = cr.bind(this.handleMouseMove_, this); - this.boundHandleMouseUp_ = cr.bind(this.handleMouseUp_, this); + this.boundHandleMouseMove_ = this.handleMouseMove_.bind(this); + this.boundHandleMouseUp_ = this.handleMouseUp_.bind(this); } var doc = this.ownerDocument; diff --git a/chrome/browser/resources/shared/js/cr/ui/tree.js b/chrome/browser/resources/shared/js/cr/ui/tree.js index 1fa3352..598bfab 100644 --- a/chrome/browser/resources/shared/js/cr/ui/tree.js +++ b/chrome/browser/resources/shared/js/cr/ui/tree.js @@ -555,9 +555,9 @@ cr.define('cr.ui', function() { labelEl.appendChild(input); input.addEventListener('keydown', handleKeydown); - input.addEventListener('blur', cr.bind(function() { + input.addEventListener('blur', (function() { this.editing = false; - }, this)); + }).bind(this)); // Make sure that double clicks do not expand and collapse the tree // item. |