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

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

Issue 2235683003: Correct description in messages; add 'tel' input type (Closed) Base URL: https://chromium.googlesource.com/chromium/extensions-by-google.git@master
Patch Set: Ignore existing icons/ directory Created 4 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 unified diff | Download patch
« no previous file with comments | « go-back-with-backspace/description.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Determine whether focus is in an editable text field. 1 // Determine whether focus is in an editable text field.
2 function isEditable(path) { 2 function isEditable(path) {
3 var target = path[0]; 3 var target = path[0];
4 4
5 // Elements may be explicitly marked as editable. 5 // Elements may be explicitly marked as editable.
6 if (target.isContentEditable) 6 if (target.isContentEditable)
7 return true; 7 return true;
8 8
9 // Several types of input fields are editable, but not all (e.g., checkboxes). 9 // Several types of input fields are editable, but not all (e.g., checkboxes).
10 var nodeName = target.nodeName; 10 var nodeName = target.nodeName;
11 var nodeType = target.type; 11 var nodeType = target.type;
12 if (nodeName === 'TEXTAREA' || 12 if (nodeName === 'TEXTAREA' ||
13 (nodeName === 'INPUT' && (nodeType === 'text' || 13 (nodeName === 'INPUT' && (nodeType === 'text' ||
14 nodeType === 'email' || 14 nodeType === 'email' ||
15 nodeType === 'number' || 15 nodeType === 'number' ||
16 nodeType === 'password' || 16 nodeType === 'password' ||
17 nodeType === 'search'))) { 17 nodeType === 'search' ||
18 nodeType === 'tel'))) {
18 return true; 19 return true;
19 } 20 }
20 21
21 // Certain CSS styles, on elements or their parents, also indicate editable 22 // Certain CSS styles, on elements or their parents, also indicate editable
22 // fields. 23 // fields.
23 var pathLength = path.length; 24 var pathLength = path.length;
24 for (var i = 0; i < pathLength; ++i) { 25 for (var i = 0; i < pathLength; ++i) {
25 target = path[i]; 26 target = path[i];
26 if (target.nodeType == 1) { // Only Elements have computed styles. 27 if (target.nodeType == 1) { // Only Elements have computed styles.
27 var userModify = getComputedStyle(path[i])['-webkit-user-select']; 28 var userModify = getComputedStyle(path[i])['-webkit-user-select'];
28 if (userModify == 'read-write' || userModify == 'write-only') 29 if (userModify == 'read-write' || userModify == 'write-only')
29 return true; 30 return true;
30 } 31 }
31 } 32 }
32 return false; 33 return false;
33 } 34 }
OLDNEW
« no previous file with comments | « go-back-with-backspace/description.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698