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

Side by Side Diff: go-back-with-backspace/content_script.js

Issue 2326083002: Attach to window, add some editable markers, and add a license file. (Closed) Base URL: https://chromium.googlesource.com/chromium/extensions-by-google.git@master
Patch Set: Add TODO with shadow DOM bug Created 4 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 unified diff | Download patch
« no previous file with comments | « go-back-with-backspace/LICENSE ('k') | go-back-with-backspace/is_editable.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Listen for shift-backspace or unmodified backspace and navigate if not in 1 // Listen for shift-backspace or unmodified backspace and navigate if not in
2 // an editable field. 2 // an editable field. We capture the event at the Window to let any handlers
3 document.addEventListener('keydown', function(e) { 3 // or listeners registered on the Document have a chance to handle it first.
4 window.addEventListener('keydown', function(e) {
5 // Listening on the Window means the event has no path (see
6 // http://crbug.com/645527), so we'll have to look at the focused (active)
7 // element. This means it will not work properly with shadow DOM.
8 // TODO: Fix behavior with shadow DOM when the above bug is resolved.
4 if (e.key === 'Backspace' && 9 if (e.key === 'Backspace' &&
10 !e.defaultPrevented &&
5 !e.altKey && 11 !e.altKey &&
6 !e.ctrlKey && 12 !e.ctrlKey &&
7 !e.metaKey && 13 !e.metaKey &&
8 !isEditable(e.path)) { 14 !isEditable(document.activeElement)) {
9 e.shiftKey ? window.history.forward(): window.history.back(); 15 e.shiftKey ? window.history.forward(): window.history.back();
10 e.preventDefault(); 16 e.preventDefault();
11 } 17 }
12 }); 18 });
OLDNEW
« no previous file with comments | « go-back-with-backspace/LICENSE ('k') | go-back-with-backspace/is_editable.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698