From 11fe107f95dab3a584b7eb4b14a67910d16476be Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 18 Nov 2014 08:52:24 +0000 Subject: Do not handle keystrokes for contentEditable. --- content_scripts/vimium_frontend.coffee | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 118f985e..4df24da4 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -560,7 +560,12 @@ exitInsertMode = (target) -> insertModeLock = null HUD.hide() -isInsertMode = -> insertModeLock != null +isInsertMode = -> + # In addition to checking insertModeLock, we also need to check whether the active element is + # contentEditable because some sites (e.g. inbox.google.com) change the contentEditable attribute on the + # fly; see #1245. + insertModeLock != null or + (document.activeElement and document.activeElement.isContentEditable) # should be called whenever rawQuery is modified. updateFindModeQuery = -> -- cgit v1.2.3 From 512aa9919ac19335ef86048fb41ffa051b60dd3a Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 20 Nov 2014 13:45:01 +0000 Subject: Do not handle keystrokes for contentEditable (refactor). --- content_scripts/vimium_frontend.coffee | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 4df24da4..58224f89 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -529,6 +529,7 @@ isEmbed = (element) -> ["embed", "object"].indexOf(element.nodeName.toLowerCase( # any element which makes it a rich text editor, like the notes on jjot.com. # isEditable = (target) -> + # Note: document.activeElement.isContentEditable is also rechecked in isInsertMode() dynamically. return true if target.isContentEditable nodeName = target.nodeName.toLowerCase() # use a blacklist instead of a whitelist because new form controls are still being implemented for html5 @@ -552,6 +553,7 @@ window.enterInsertMode = (target) -> # when the last editable element that came into focus -- which insertModeLock points to -- has been blurred. # If insert mode is entered manually (via pressing 'i'), then we set insertModeLock to 'undefined', and only # leave insert mode when the user presses . +# Note. This returns the truthiness of target, which is required by isInsertMode. # enterInsertModeWithoutShowingIndicator = (target) -> insertModeLock = target @@ -561,11 +563,13 @@ exitInsertMode = (target) -> HUD.hide() isInsertMode = -> - # In addition to checking insertModeLock, we also need to check whether the active element is - # contentEditable because some sites (e.g. inbox.google.com) change the contentEditable attribute on the - # fly; see #1245. - insertModeLock != null or - (document.activeElement and document.activeElement.isContentEditable) + return true if insertModeLock != null + # Some sites (e.g. inbox.google.com) change the contentEditable attribute on the fly (see #1245); and + # unfortunately, isEditable() is called *before* the change is made. Therefore, we need to re-check whether + # the active element is contentEditable. + document.activeElement and + document.activeElement.isContentEditable and + enterInsertModeWithoutShowingIndicator document.activeElement # should be called whenever rawQuery is modified. updateFindModeQuery = -> -- cgit v1.2.3 From 3f3f256e1abe2a7795ba89ff6b84d4b81fb0a7e2 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 20 Nov 2014 17:15:22 +0000 Subject: Do not handle keystrokes for contentEditable (check find mode). It is not strictly necessary to check find mode here. However, if we don't do so, then we leave a booby trap for future developers. So we do the extra check. This, hopefully, means that we don't suddenly find ourselves dropping into insert mode just because somebody reorders the code elsewhere. --- content_scripts/vimium_frontend.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 58224f89..a98b6254 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -567,8 +567,7 @@ isInsertMode = -> # Some sites (e.g. inbox.google.com) change the contentEditable attribute on the fly (see #1245); and # unfortunately, isEditable() is called *before* the change is made. Therefore, we need to re-check whether # the active element is contentEditable. - document.activeElement and - document.activeElement.isContentEditable and + document.activeElement and document.activeElement.isContentEditable and !findMode and enterInsertModeWithoutShowingIndicator document.activeElement # should be called whenever rawQuery is modified. -- cgit v1.2.3 From fe55f0688664e38b0e299c371a90dfe80ef8d3f7 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 22 Nov 2014 06:51:01 +0000 Subject: Revert 3f3f256e1abe2a7795ba89ff6b84d4b81fb0a7e2. On reflection, 3f3f256e1abe2a7795ba89ff6b84d4b81fb0a7e2 seems like a bad idea. It's unnecessary, and risks unforeseen consequences. --- content_scripts/vimium_frontend.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'content_scripts') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index a98b6254..34fd56d5 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -567,7 +567,7 @@ isInsertMode = -> # Some sites (e.g. inbox.google.com) change the contentEditable attribute on the fly (see #1245); and # unfortunately, isEditable() is called *before* the change is made. Therefore, we need to re-check whether # the active element is contentEditable. - document.activeElement and document.activeElement.isContentEditable and !findMode and + document.activeElement and document.activeElement.isContentEditable and enterInsertModeWithoutShowingIndicator document.activeElement # should be called whenever rawQuery is modified. -- cgit v1.2.3