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

Unified Diff: go-back-with-backspace/is_editable.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go-back-with-backspace/content_script.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go-back-with-backspace/is_editable.js
diff --git a/go-back-with-backspace/is_editable.js b/go-back-with-backspace/is_editable.js
index d0e4114ebee40f58b60fb4a8a973e24391118a08..9e26cdcd38ffaaa5020b69a9f12ce40e1fbfc945 100644
--- a/go-back-with-backspace/is_editable.js
+++ b/go-back-with-backspace/is_editable.js
@@ -1,11 +1,13 @@
// Determine whether focus is in an editable text field.
-function isEditable(path) {
- var target = path[0];
-
+function isEditable(target) {
// Elements may be explicitly marked as editable.
if (target.isContentEditable)
return true;
+ // Entire documents may be editable.
+ if (target.ownerDocument.designMode.toLowerCase() === 'on')
+ return true;
+
// Many types of input fields are editable, but not all (e.g., checkboxes).
var nodeName = target.nodeName.toUpperCase();
var nodeType = target.type || '';
@@ -29,14 +31,16 @@ function isEditable(path) {
// Certain CSS styles, on elements or their parents, also indicate editable
// fields.
- var pathLength = path.length;
- for (var i = 0; i < pathLength; ++i) {
- target = path[i];
+ while (target) {
if (target.nodeType == 1) { // Only Elements have computed styles.
- var userModify = getComputedStyle(path[i])['-webkit-user-select'];
- if (userModify == 'read-write' || userModify == 'write-only')
+ var userModify = getComputedStyle(target)['-webkit-user-modify'];
+ if (userModify === 'read-write' ||
+ userModify === 'write-only' ||
+ userModify === 'read-write-plaintext-only') {
return true;
+ }
}
+ target = target.parentNode || null;
}
return false;
}
« no previous file with comments | « go-back-with-backspace/content_script.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698