Commit 7e4346c9 authored by dbeam's avatar dbeam Committed by Commit bot

history: don't drop focus on the floor when removing a bookmark.

R=dmazzoni@chromium.org
BUG=408405
TEST=keyboard navigate to bookmark star, press space: bookmark deletes and focus still exists.

Review URL: https://codereview.chromium.org/510213002

Cr-Commit-Position: refs/heads/master@{#293212}
parent 90147459
......@@ -494,6 +494,7 @@ html .expand .site-domain-arrow {
-webkit-margin-start: 8px;
background:
url(../../../../ui/webui/resources/images/star_small.png) no-repeat;
border: none;
display: inline-block;
height: 11px;
min-width: 15px;
......
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment