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.
Simon Lydell [Fri, 20 May 2016 18:55:16 +0000 (20:55 +0200)]
Improve hints on Twitter
- Removes a useless hint that covered the hint for showing more tweets.
Thanks to @XrXr for reporting and suggesting a fix. Supersedes and
closes #732.
- Adds a hint for each tweet, allowing to open it in the
popup/modal/lightbox thingy.
Simon Lydell [Fri, 20 May 2016 15:35:35 +0000 (17:35 +0200)]
Improve focusType detection
Inputs focused and blurred inside the Evernote Web Clipper extension's
popup (which is an `<iframe>` injected into the browser UI) were
previously not detected (making it difficult to type into them without
triggering VimFx commands). That was because we have to check if events
really are UI events or not in order to support non-multi-process
Firefox (which expose web page content events to UI code), and
Evernote's elements seem to be indistinguishable from web page content.
This commit simply removes the check for where the event comes from when
looking for focusType changes. Luckily, it doesn't matter if we happen
to handle web page content events in the UI.
To avoid excessive 'focusTypeChange' events (a single focus or blur
might trigger 'focusTypeChange' twice now: Once in the UI code, and once
in the frame script), this commit also makes sure that setting the
focusType to the same value as before is a no-op.
Simon Lydell [Sun, 8 May 2016 18:56:54 +0000 (20:56 +0200)]
Speed up and refactor Hints mode
This makes most hints show up on screen up to twice as fast as before.
The rest of the hints show up at the same speed as before. Hints
generation has been optimized for the common case, by looking for
markable elements in two passes (if needed and possible). First, we look
for common and fast-to-find elements (such as links); then we look for
everything else. Addresses #409.
Code has been pulled out of marker.coffee, modes.coffee and
hints.coffee, and put into the new marker-container.coffee. hints.coffee
was then renamed to markable-elements.coffee (because all it does now is
finding markable elements).
The concept of tagging elements as "semantic" has been removed. The idea
was to give "unsemantic" elements worse hints (so they wouldn't trump
links, for example). Now, such elements are usually found in the second
pass instead, which gives about the same effect.
`<c-enter>` in Hints mode no longer replaces all hints with new ones for
_all_ elements on screen. Instead, it replaces the hints with hints for
all _unmarked_ elements on screen. Pressing `<c-enter>` again toggles
back to the original hints.
There is a breaking API change for `vimfx.setHintMatcher(hintMatcher)`.
`hintMatcher` no longer receives and returns an object (of the shape
`{type, semantic}`), but instead simply receives and returns the `type`
of the element.
Simon Lydell [Sat, 14 May 2016 10:58:19 +0000 (12:58 +0200)]
Pin the coffee-script version
The very latest commits of coffee-script break coffeelint. This pins the
coffee-script dependency to a commit that both compiles VimFx and runs
coffeelint as intended.
Simon Lydell [Fri, 13 May 2016 06:05:03 +0000 (08:05 +0200)]
Fix frame scripts being loaded more than once sometimes
1. Open several tabs.
2. Set Firefox to remember your tabs between sessions.
3. Restart Firefox. All but the current tab will now be in a "pending"
(unloaded) state.
4. Update/re-install VimFx.
5. Visit one of the pending tabs.
Now, the frame script will be loaded _twice_ in that tab, which for
example causes `f` to produce double-clicks. This is especially
noticeable during development, when you update/re-install VimFx all the
time.
The reason is that Firefox does not seem to load frame scripts in
pending tabs immediately. Instead, the URI to the frame script we asked
to load is remembered and then loaded when you actually visit the
pending tab in question. If you update VimFx before doing so, yet one
frame script URI will be pushed to that stack, causing _two_ instances
of it to be loaded when visiting the tab. Both of those will be from the
new VimFx version; the URIs are the same, and the file at that URI has
now been updated.
This commit attempts to solve this problem by generating a
`bootstrap-frame-$BUILD_TIME.js` file (which simply runs
`bootstrap.coffee`) and loading that as a frame script. This means that
old saved frame script URIs will point to non-existing files and thus
be harmless.
Simon Lydell [Sun, 8 May 2016 07:34:48 +0000 (09:34 +0200)]
Fix smooth scrolling speed in newer Firefox versions
The following pseudo-code used to work:
setFirefoxSpringConstant()
startScrollingSmoothly()
resetFirefoxSpringConstant()
// Some time later: Smooth scrolling finishes.
However, in some newer Firefox version that's changed.
`resetFirefoxSpringConstant` now has to be called when the smooth
scrolling is done, it seems. Unfortunately there appears to be no way of
knowing when that's the case. Instead, this commit introduces a timeout
before the spring constant pref is reset. The timeout can be customized
via the `scroll.reset_timeout` pref if needed. Special care was taken so
that, for example, holding `j` to scroll would only reset the pref
_once_ (after the last scroll command) and to the correct value.