Simon Lydell [Fri, 9 Sep 2016 18:46:28 +0000 (20:46 +0200)]
Add `gB` for quickly editing the blacklist
This also improves the description of the blacklist option, mentioning
that the patterns must match the _entire_ URL, since many people seem to
overlook this fact.
Simon Lydell [Mon, 29 Aug 2016 20:11:41 +0000 (22:11 +0200)]
Fix missing hint markers when re-entering Hints mode quickly
1. Enter Hints mode.
2. Press `<escape>` to exit it.
3. Press `f` to re-enter Hints mode within `hints_timeout` milliseconds.
This used to result in re-entering Hints mode as expected, but with no
hint markers on screen because of a timeout from the last Hints mode
session that removed the hints container. Removing the hints container
is done by ID for robustness, so it doesn't help that the hints
container actually is a new DOM element at that time.
This commit fixes the above problem, and makes the logic more robust.
In `onLeave` for Hints mode, it makes sense to always try to remove the
Hints container, so that it may not be accidentally be left on screen.
However, it does not make sense to do so after a timeout, which was
previously the case. Now, it is done _immediately_ instead.
The only case where he timeout is wanted, is when a hint marker just has
been matched. This commit also adds a check in that timeout callback that
Hints mode hasn't been re-entered before removing the hints container.
Simon Lydell [Sat, 27 Aug 2016 21:26:06 +0000 (23:26 +0200)]
Fix initial visibility of second-pass hint markers
1. Go to a site where there is a noticeable delay between the two passes
for the `f` command, such as on reddit.com.
2. Press a prefix hint char there before the second pass has completed.
When the second pass completes, the hint markers for that pass will be
shown, even though they cannot start with the prefix hint char you
pressed. This commit makes sure that the hint markers for the second
pass start out hidden if needed.
That commit switched to using `prefs.get` directly in
events-frame.coffee instead of using `messageManager.get`. That avoids
synchronous messages, which is a good thing.
However, I forgot that when doing so, `vimfx.addOptionOverrides` won't
take effect.
This commit partly reverts to getting options via synchronous messages
again. In the very frequent 'keydown' event direct `prefs.get` is still
used for the unlikely-to-be-overridden `focus_previous_key` and
`focus_next_key` prefs, while synchronous messaging is used in the less
frequent 'focus' event, which enables the use case of overriding
`prevent_autofocus` on select pages.
Simon Lydell [Sat, 20 Aug 2016 08:40:48 +0000 (10:40 +0200)]
Change `` ` `` into `'`
This is both for the `` ` `` shortcut (go to mark) and the `` ` `` mark
(last position). Both `` ` `` and `'` are used in Vim. `'` is a better
default, because it is easier to type -- both on an en-US QWERTY
keyboard and, more importantly, on some international layouts, such as
the sv-SE layout.
Simon Lydell [Wed, 10 Aug 2016 10:08:32 +0000 (12:08 +0200)]
Make it possible to create custom hint commands
My first idea was to use `vim.enterMode('hints', ...)`. However, that's
too complicated to be useful for any user.
Actually, I found that `vim.enterMode(...)` is too complicated for most
(all?) modes, so I decided to make it private (removing it from the
public API) while at it. (I also made the arguments of
`vim.enterMode`/`mode.onEnter` more consistent with each other.)
I also considered exposing the entire "API" that the `f` commands use
internally. However, that's more complicated than the average user
needs, and would increase the API surface _a lot._
Instead, the `f` commands now take a `callbackOverride` argument. This
lets you choose the `f` command that matches the elements you're looking
for and the override what happens when a hint marker is matched.
Simon Lydell [Sat, 6 Aug 2016 14:26:57 +0000 (16:26 +0200)]
Fix unmousable bottom-right corner of the page scrollbars
VimFx's statuspanel (for notifications) had `pointer-events: auto;`
instead of `pointer-events: none;`, which statuspanels have by default.
The reason was to allow clicking the statuspanel to hide it.
This made it impossible to interact with the bottom-right corner of the
page scrollbars. The invisible statuspanel captured any clicks there.
This commit hides notifications when clicking _anything_ instead, and
removes `pointer-events: auto;`.
The convention on most modern sites seem to be to make a trailing slash
optional. But especially on older servers, no trailing slash means "view
file", while a trailing slash means "view directory". Removing the
trailing slash in such cases most likely results in a 404, while
preserving it gives a useful result.
Simon Lydell [Fri, 8 Jul 2016 06:00:18 +0000 (08:00 +0200)]
Make it possible to escape from stuck "auto insert mode"
With this commit, `<escape>` resets `vim.focusType` to 'none', in case
we somehow have gotten stuck with 'editable'.
The button now also runs the `esc` command, making it a true escape
hatch: Clicking it not only lets you escape from other modes back to
Normal mode, but also blurs stuff and makes sure that `vim.focusType` is
'none'.
Simon Lydell [Thu, 30 Jun 2016 05:56:12 +0000 (07:56 +0200)]
Simplify detection of markable `<label>`s
Apparently, such elements have a `.control` property that returns their
associated form control. No need to manually look for the 'for'
attribute or nested form control elements.
Simon Lydell [Wed, 22 Jun 2016 06:02:36 +0000 (08:02 +0200)]
Teach the `zF` command to find and activate dropmarkers
For example, the bookmarks button has a "star" button on the left, which
acts like a normal button, and another button on the right, which
actually is a `<dropmarker>` and opens a `<menupopup>`. Previously,
VimFx didn't find the `<dropmarker>` (because it hasn't got
`.tabIndex > `-1). Now it does. Note that simulating a click on a
`<dropmarker>` triggers its parent button's action. Instead, the
`<menupopup>` must be found and triggered manually.
Another example of such a button is Greasemonkey’s button. Actually,
this "button with dropmarker" concept seems pretty common among add-ons.
This commit also removes the unnecessary double hint for the bookmarks
button, but filtering out `<toolbarbutton>`s which are direct children
of another `<toolbarbutton>`.
Simon Lydell [Sat, 18 Jun 2016 10:59:01 +0000 (12:59 +0200)]
Only rotate _visible_ hint markers
Previously, if you pressed `<space>` in Hints mode to rotate overlapping
markers, after already having entered a few hint chars, it would
sometimes look as if nothing happens. This was because _all_ markers
where being rotated, even hidden ones. This commit only rotates _visible_
markers.
Alan Wu [Sun, 12 Jun 2016 08:27:17 +0000 (04:27 -0400)]
Fix `zF` double clicking on browser elements (#757)
`nsIDOMWindowUtils.dispatchDOMEventViaPresShell()` dispatches
a 'command' event automatically after a 'click' event on XUL pages.
This was causing `zF` to effectively double click on browser elements,
since VimFx also simulates a 'command' event.
Elements which suffers from this double click include but are not
limited to, the new tab button, question mark circles in the preferences
page and buttons created by the add-on sdk.
Alan Wu [Mon, 6 Jun 2016 10:23:05 +0000 (06:23 -0400)]
Dispatch trusted mouse events to content page (#751)
Some DOM APIs need to be called from the handler of a trusted event to
work. `requestFullscreen()` and `document.execCommand('copy')` are
examples of such API.
Before this patch, VimFx dispatched mouse events using
`element.dispatchEvent()` which had the event handlers for the events
running in untrusted context. This behavior prevented hint mode from
full-screening on Youtube and copying clone addresses on Github.
This patch uses XPCOM to dispatch mouse events as trusted events to the
content page.
See also:
https://www.w3.org/TR/uievents/#trusted-events - info from the spec
https://clipboardjs.com/ - before this patch, copying doesn't work
Simon Lydell [Sun, 5 Jun 2016 17:25:50 +0000 (19:25 +0200)]
Improve Marks mode UX
- Return to Normal mode if a mark key hasn't been pressed within
`options.timeout` milliseconds.
- Let `<escape>` return to Normal mode instead of creating or going to a
mark named `<escape>`. Previously, if the user pressed `<escape>` as
an attempt to exit Marks mode after accidentally pressing `m`, that
would indeed exit Marks mode, but it would also set the `<escape>`
mark. That meant that after that point, the user couldn't exit Marks
mode using `<escape>` after having pressed `` ` `` without the side
effect of scrolling to the `<escape>` mark.
- Marks mode has been hidden from the help dialog, in order not to
clutter it with unnecessary information. While at it, Find mode was
removed from the help dialog as well, for the same reason. Both modes
are still available in VimFx's settings page in the Add-ons Manager,
though.
Simon Lydell [Sun, 5 Jun 2016 17:01:02 +0000 (19:01 +0200)]
Make the `?` command and the button _toggle_ help
I've noticed people (including myself, sometimes) unconsciously
expecting both the `?` command and the button to _close_ the Keyboard
Shortcuts dialog if it is already open.
I don't think there's any need complicating the description of the `?`
command and the tooltip of the button to reflect this.
Simon Lydell [Thu, 2 Jun 2016 15:15:39 +0000 (17:15 +0200)]
Drastically speed up `find_from_top_of_viewport`
- Don't recurse into children of elements when looking for visible text
nodes; we'll get to them anyway since we iterate over every element of
the page.
- Don't bother checking text nodes that we already know are whitespace
only.
Simon Lydell [Sun, 29 May 2016 09:29:34 +0000 (11:29 +0200)]
Improve nonCoveredPoint checks
- Skip trying to the right of a covering element if that's further to
the right than the element's rect.
- If the covering element is a parent to the element we're checking,
don't try looking to the right of the parent. It is _very_ unlikely
that we'll find the element we're checking there. Instead, try the
most likely point to be non-covered: The center of the element. This
needs to be done because of pseudo-elements of the parent element
which might cover the link partly, likely at the edges. Fixes #742.
Simon Lydell [Sun, 29 May 2016 07:39:47 +0000 (09:39 +0200)]
Include possibly covered elements for complementary hints
There might be false positives when checking if an element is covered or
not. This commit includes covered elements when switching to
complementary hints (`<c-enter>` in Hints mode), so that you can target
for example links which are only partly covered.
Simon Lydell [Fri, 27 May 2016 17:39:15 +0000 (19:39 +0200)]
Improve the Find next/previous commands
- Finding is asynchronous. This commit makes sure to wait until the
finding is done before sending notifications (such as "Phrase not
found"). This makes the notifications more reliable.
- Prevent the find bar from re-opening if there are no matches.
Fixes #739.
Simon Lydell [Fri, 27 May 2016 07:29:46 +0000 (09:29 +0200)]
Fix focus handling
When blurring a UI element, we handle that blur after a timeout. If
the UI element was blurred due to focusing a frame element, the focus
events for that frame element occurs _before_ handling the UI blur. That
caused the focusType to be set according to the UI blur, and not
according to the frame focus. This meant that if you had the location
bar focused and clicked inside a text input in a web page, VimFx would
enter and then immediately exit "auto insert mode". This commit fixes
this issue by asking the frame script for the focusType if a 'focus' or
'blur' event is caught in the UI and the active element is the current
`<browser>` (instead of treating `<browser>` as focusType 'none').
Also, since commit fee33fa8, 'focusTypeChange' events are only sent when
_changing_ the focusType of a `vim`, _not_ when trying to set the
focusType to the same value as before. While that's good, it caused a
problem when switching tabs. When switching tabs, 'blur' events occur in
the old tab and (re-)'focus' events occur in the new tab, but no
focusType of any `vim` is necessarily changed. However, one tab might be
in "auto insert mode" while the other isn't, so the button would still
need to be updated. Therefore, this commit sends a 'focusTypeChange'
event when switching tabs.