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

Unified Diff: chrome/browser/resources/md_bookmarks/actions.js

Issue 2804503002: MD Bookmarks: Allow 'complex' actions to access the page state directly (Closed)
Patch Set: Self-review Created 3 years, 8 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/md_bookmarks/actions.js
diff --git a/chrome/browser/resources/md_bookmarks/actions.js b/chrome/browser/resources/md_bookmarks/actions.js
index 04c97292f18fae26ff5543e4c3930c732ea49007..a3d73af51e50ca4fc47318f45130efdad9ec574f 100644
--- a/chrome/browser/resources/md_bookmarks/actions.js
+++ b/chrome/browser/resources/md_bookmarks/actions.js
@@ -3,8 +3,8 @@
// found in the LICENSE file.
/**
- * @fileoverview Module for functions which produce action objects. These are
- * listed in one place to document available actions and their parameters.
+ * @fileoverview Module for functions which create actions that do not
+ * rely on Page state.
*/
cr.define('bookmarks.actions', function() {
@@ -58,11 +58,10 @@ cr.define('bookmarks.actions', function() {
* @param {string} id
* @param {string} parentId
* @param {number} index
- * @param {NodeList} nodes
+ * @param {!Set<string>} descendants
* @return {!Action}
*/
- function removeBookmark(id, parentId, index, nodes) {
- var descendants = bookmarks.util.getDescendants(nodes, id);
+ function removeBookmarkSubtree(id, parentId, index, descendants) {
return {
name: 'remove-bookmark',
id: id,
@@ -115,48 +114,26 @@ cr.define('bookmarks.actions', function() {
};
}
- /** @return {!Action} */
- function deselectItems() {
- return {
- name: 'deselect-items',
- };
- }
-
/**
- * @param {string} id
+ * TODO(tsergeant): Make |items| a Set instead of an Array.
+ * @param {!Array<string>} items
+ * @param {string} anchor
* @param {boolean} add
- * @param {boolean} range
- * @param {BookmarksPageState} state
* @return {!Action}
*/
- function selectItem(id, add, range, state) {
- var anchor = state.selection.anchor;
- var toSelect = [];
-
- // TODO(tsergeant): Make it possible to deselect items by ctrl-clicking them
- // again.
- if (range && anchor) {
- var displayedList = bookmarks.util.getDisplayedList(state);
- var selectedIndex = displayedList.indexOf(id);
- assert(selectedIndex != -1);
- var anchorIndex = displayedList.indexOf(anchor);
- if (anchorIndex == -1)
- anchorIndex = selectedIndex;
-
- var startIndex = Math.min(anchorIndex, selectedIndex);
- var endIndex = Math.max(anchorIndex, selectedIndex);
-
- for (var i = startIndex; i <= endIndex; i++)
- toSelect.push(displayedList[i]);
- } else {
- toSelect.push(id);
- }
-
+ function selectItemSet(items, anchor, add) {
return {
name: 'select-items',
+ items: items,
+ anchor: anchor,
add: add,
- anchor: id,
- items: toSelect,
+ };
+ }
+
+ /** @return {!Action} */
+ function deselectItems() {
+ return {
+ name: 'deselect-items',
};
}
@@ -193,9 +170,9 @@ cr.define('bookmarks.actions', function() {
editBookmark: editBookmark,
moveBookmark: moveBookmark,
refreshNodes: refreshNodes,
- removeBookmark: removeBookmark,
+ removeBookmarkSubtree: removeBookmarkSubtree,
selectFolder: selectFolder,
- selectItem: selectItem,
+ selectItemSet: selectItemSet,
setSearchResults: setSearchResults,
setSearchTerm: setSearchTerm,
};

Powered by Google App Engine
This is Rietveld 408576698