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

Unified Diff: chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js

Issue 543863002: Typecheck chrome://bookmarks using Closure Compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@true_master
Patch Set: remove runner.jar from CL Created 6 years, 3 months 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: chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
diff --git a/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js b/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
index a678d379e4116695cf56fe9ce3f6fd3896c1a7aa..25c83297bc3e04bdb5a20d35eaada5ca3ca81db2 100644
--- a/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
+++ b/chrome/browser/resources/bookmark_manager/js/bmm/bookmark_list.js
@@ -5,14 +5,27 @@
// TODO(arv): Now that this is driven by a data model, implement a data model
// that handles the loading and the events from the bookmark backend.
+/**
+ * @typedef {{childIds: Array.<string>}}
+ *
+ * @see chrome/common/extensions/api/bookmarks.json
+ */
+var ReorderInfo;
+
+/**
+ * @typedef {{parentId: string, index: number, oldParentId: string,
+ * oldIndex: number}}
+ *
+ * @see chrome/common/extensions/api/bookmarks.json
+ */
+var MoveInfo;
+
cr.define('bmm', function() {
var List = cr.ui.List;
var ListItem = cr.ui.ListItem;
var ArrayDataModel = cr.ui.ArrayDataModel;
var ContextMenuButton = cr.ui.ContextMenuButton;
- var list;
-
/**
* Basic array data model for use with bookmarks.
* @param {!Array.<!BookmarkTreeNode>} items The bookmark items.
@@ -57,7 +70,7 @@ cr.define('bmm', function() {
* Creates a new bookmark list.
* @param {Object=} opt_propertyBag Optional properties.
* @constructor
- * @extends {HTMLButtonElement}
+ * @extends {cr.ui.List}
*/
var BookmarkList = cr.ui.define('list');
@@ -79,6 +92,10 @@ cr.define('bmm', function() {
bmm.list = this;
Dan Beam 2014/09/25 04:27:18 wait, this is already set?
Vitaly Pavlenko 2014/09/25 15:37:15 Ok, I reset this assignment.
},
+ /**
+ * @param {!BookmarkTreeNode} bookmarkNode
+ * @override
+ */
createItem: function(bookmarkNode) {
return new BookmarkListItem(bookmarkNode);
},
@@ -198,9 +215,10 @@ cr.define('bmm', function() {
* Handles mousedown events so that we can prevent the auto scroll as
* necessary.
* @private
- * @param {!MouseEvent} e The mousedown event object.
+ * @param {!Event} e The mousedown event object.
*/
handleMouseDown_: function(e) {
+ e = /** @type {!MouseEvent} */(e);
if (e.button == 1) {
// WebKit no longer fires click events for middle clicks so we manually
// listen to mouse up to dispatch a click event.
@@ -220,9 +238,10 @@ cr.define('bmm', function() {
* WebKit no longer dispatches click events for middle clicks so we need
* to emulate it.
* @private
- * @param {!MouseEvent} e The mouse up event object.
+ * @param {!Event} e The mouse up event object.
*/
handleMiddleMouseUp_: function(e) {
+ e = /** @type {!MouseEvent} */(e);
this.removeEventListener('mouseup', this.handleMiddleMouseUp_);
if (e.button == 1) {
var el = e.target;
@@ -250,6 +269,10 @@ cr.define('bmm', function() {
}
},
+ /**
+ * @param {string} id
+ * @param {ReorderInfo} reorderInfo
+ */
handleChildrenReordered: function(id, reorderInfo) {
if (this.parentId == id) {
// We create a new data model with updated items in the right order.
@@ -274,6 +297,10 @@ cr.define('bmm', function() {
this.dataModel.splice(bookmarkNode.index, 0, bookmarkNode);
},
+ /**
+ * @param {string} id
+ * @param {MoveInfo} moveInfo
+ */
handleMoved: function(id, moveInfo) {
if (moveInfo.parentId == this.parentId ||
moveInfo.oldParentId == this.parentId) {
@@ -344,7 +371,6 @@ cr.define('bmm', function() {
/**
* The ID of the bookmark folder we are displaying.
- * @type {string}
*/
cr.defineProperty(BookmarkList, 'parentId', cr.PropertyKind.JS,
function() {
@@ -353,9 +379,10 @@ cr.define('bmm', function() {
/**
* The contextMenu property.
- * @type {cr.ui.Menu}
*/
cr.ui.contextMenuHandler.addContextMenuProperty(BookmarkList);
+ /** @type {cr.ui.Menu} */
+ BookmarkList.prototype.contextMenu;
/**
* Creates a new bookmark list item.
@@ -507,14 +534,14 @@ cr.define('bmm', function() {
this.setAttribute('editing', '');
this.draggable = false;
- labelInput = doc.createElement('input');
+ labelInput = /** @type {HTMLElement} */(doc.createElement('input'));
labelInput.placeholder =
loadTimeData.getString('name_input_placeholder');
replaceAllChildren(labelEl, labelInput);
labelInput.value = title;
if (!isFolder) {
- urlInput = doc.createElement('input');
+ urlInput = /** @type {HTMLElement} */(doc.createElement('input'));
urlInput.type = 'url';
urlInput.required = true;
urlInput.placeholder =
@@ -522,13 +549,13 @@ cr.define('bmm', function() {
// We also need a name for the input for the CSS to work.
urlInput.name = '-url-input-' + cr.createUid();
- replaceAllChildren(urlEl, urlInput);
+ replaceAllChildren(assert(urlEl), urlInput);
urlInput.value = url;
}
- function stopPropagation(e) {
+ var stopPropagation = function(e) {
e.stopPropagation();
- }
+ };
var eventsToStop =
['mousedown', 'mouseup', 'contextmenu', 'dblclick', 'paste'];
@@ -601,6 +628,6 @@ cr.define('bmm', function() {
return {
BookmarkList: BookmarkList,
- list: list
+ list: $('list'),
Dan Beam 2014/09/24 21:38:58 either: get list() { return $('list'); }, or
Vitaly Pavlenko 2014/09/24 22:18:23 Done.
};
});

Powered by Google App Engine
This is Rietveld 408576698