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

Unified Diff: chrome/browser/resources/history/history.js

Issue 510213002: history: don't drop focus on the floor when removing a bookmark. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « chrome/browser/resources/history/history.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/history/history.js
diff --git a/chrome/browser/resources/history/history.js b/chrome/browser/resources/history/history.js
index 4a16a5233177632a1667b6d7381d7f02aeb2517f..f71c4992d985dfac0d05218b1ab03232550e3d8a 100644
--- a/chrome/browser/resources/history/history.js
+++ b/chrome/browser/resources/history/history.js
@@ -224,17 +224,22 @@ Visit.prototype.getResultDOM = function(propertyBag) {
entryBox.appendChild(time);
- var bookmarkSection = createElementWithClassName('div', 'bookmark-section');
+ var bookmarkSection = createElementWithClassName(
+ 'button', 'bookmark-section custom-appearance');
if (this.starred_) {
bookmarkSection.title = loadTimeData.getString('removeBookmark');
bookmarkSection.classList.add('starred');
bookmarkSection.addEventListener('click', function f(e) {
recordUmaAction('HistoryPage_BookmarkStarClicked');
- bookmarkSection.classList.remove('starred');
chrome.send('removeBookmark', [self.url_]);
+
+ this.model_.getView().onBeforeUnstarred(this);
+ bookmarkSection.classList.remove('starred');
+ this.model_.getView().onAfterUnstarred(this);
+
bookmarkSection.removeEventListener('click', f);
e.preventDefault();
- });
+ }.bind(this));
}
entryBox.appendChild(bookmarkSection);
@@ -1149,6 +1154,21 @@ HistoryView.prototype.onBeforeRemove = function(visit) {
row.focusIndex(Math.min(pos.col, row.items.length - 1));
};
+/** @param {Visit} visit The visit about to be unstarred. */
+HistoryView.prototype.onBeforeUnstarred = function(visit) {
+ assert(this.currentVisits_.indexOf(visit) >= 0);
+ assert(visit.bookmarkStar == document.activeElement);
+
+ var pos = this.focusGrid_.getPositionForTarget(document.activeElement);
+ var row = this.focusGrid_.rows[pos.row];
+ row.focusIndex(Math.min(pos.col + 1, row.items.length - 1));
+};
+
+/** @param {Visit} visit The visit that was just unstarred. */
+HistoryView.prototype.onAfterUnstarred = function(visit) {
+ this.updateFocusGrid_();
+};
+
/**
* Removes a single entry from the view. Also removes gaps before and after
* entry if necessary.
« no previous file with comments | « chrome/browser/resources/history/history.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698