aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/ui_component.coffee
AgeCommit message (Collapse)Author
2016-04-28Fix UI-component initialization issues.Stephen Blott
This fixes some UI component initialization issues. It's a long story... The problem. - Go to this page: http://www.thejournal.ie/seanad-election-results-2016-2737768-Apr2016/ - Click one of the links from the "Most Popular" box on the right. - Navigate back (`H`) and, as the original page is loading, activate the Vomnibar. In 1.54 this renders Vimium unusable. In `master` this renders the Vomnibar unsable, but the rest of Vimium usable. It seems the source of the issue is that we're initializing UI components too soon. We need to wait until the `readyState` is "complete". With this PR: - The Vomnibar is initialised when the `readyState` is "complete" (in the top frame only, and only if Vimium is enabled). Requests arriving prior to then are silently discarded. - The HUD is also initialized only when the `readyState` is "complete"; however, requests arriving before then are queued. So, if the user immediately enters insert mode, then the "Insert mode" indicator will eventually be displayed. - The help dialog silently discards requests until the `readyState` is "complete. I'm posting this as a PR because: 1. It needs some visibility. 2. With this, if the `readyState` *never* reaches "complete", then the Vomnibar would be unusable. And that's pretty serious.
2016-04-21Help dialog; remove ability to blur the dialog.Stephen Blott
Previously, you could blur the help dialog on the options page (to read and type command names). With the reinstated help-dialog styling (whereby the help-dialog iframe extends across the entire window), this doesn't make sense. So it's removed.
2016-04-18Cache content_scripts/vimium.css in chrome.storage.local.Stephen Blott
Previously, we had two different approaches. This seems like a simpler approach. We simply cache the Vimium CSS in chrome.storage.local (in the background page) and fetch it from there (in UI components). There is also a minor change in the we no longer cache the CSS in memory. This seems to be the right thing to do. Caching the CSS in memory consumes a small amount of memory. However, it can only speed up the fastest loads. It cannot speed up the first load -- which is likely the one that matters most. So caching the CSS in memory seems to make little sense.
2016-04-18Revert "Cache content_scripts/vimium.css in chrome.storage.local."Stephen Blott
This reverts commit 0a49cc45732175c65651b5f054c677d6c42a28c0.
2016-04-18Cache content_scripts/vimium.css in chrome.storage.local.Stephen Blott
Previously, we had two different approaches. This seems like a simpler approach. We simply cache the Vimium CSS in chrome.storage.local (in the background page) and fetch it from there (in UI components). There is also a minor change in the we no longer cache the CSS in memory. This seems to be the right thing to do. Caching the CSS in memory consumes a small amount of memory. However, it can only speed up the fastest loads. It cannot speed up the first load -- which is likely the one that matters most. So caching the CSS in memory seems to make little sense.
2016-04-18Wait for documentReady() when whoeing ui components.Stephen Blott
Previously, requests (like opening the Vomnibar) would be silently discarded if they arrive before the document is ready. Here, we queue them instead.
2016-04-18Require documentReady for all UI components.Stephen Blott
This replaces c01d7eea8675f9a7d84999777e8de72244d687b6. All UI components require the document to be ready. So, here the constructor waits for DomUtils.documentReady(). The diff looks big, but mainly it's a result of changes in indentation in the constructor and in hide(). Also, hide() now uses @postMessage() to post a null message. This forces hide to use @iframePort.use(), which ensures that hide()s cannot overtake activate()s. This continues #2100.
2016-04-17More code review of UI-component focus handling.Stephen Blott
2016-04-16Minor code review.Stephen Blott
2016-04-16Self code review re. ui-component focus handling.Stephen Blott
2016-04-16We cannot wait for nextTick() here...Stephen Blott
It interferes with the HUD's timing.
2016-04-16Rework UI component focus handling.Stephen Blott
The code to handle the focus for UI components has been tweaked and adapted over time, and has become quite complicated (and brittle). This reworks it from scratch, and co-locates similar code which does related things. Fixes #2099.
2016-04-14Rework UI component init sequence.Stephen Blott
In testing global link hints, it seems that UI components can be opened before they're actually ready, and Vimium hangs with a broken UI component displayed. This issue seems to be in 1.54 too. It's not clear what's causing this -- and it's hard to reproduce systematically. However, it only seems to happen on navigation. Therefore, it seems likely that there is an issue with the initialization sequence. Here, we wait for: - the DOM content to be ready, and - the port to be provided before registering the UI component as ready.
2016-04-09A UI component isn't ready until it's ready.Stephen Blott
1. Do not initialize UI components until the DOm is ready. 2. Do not register UI components as ready (specifically the HUD) until the full initialization sequence is complete. This goes some way towards fixing the issue described in this comment: https://github.com/philc/vimium/issues/2081#issuecomment-205758102 It relates to link-hints mode hanging when launched during a navigation. This problem exists in 1.54, but emerged during testing of global link hints. "Some way toeards fixing..." because it is still possible to trigger issues.
2016-03-27Finally fix help-dialog focus issue.Stephen Blott
In the previous commits, I omitted to actually check that the help dialog wasn't closing on the options page. I should be good now.
2016-03-27Handle focus events for UI components.Stephen Blott
The help-dialog UI component was ignoring requests to "hide" when other frames are focused (because previously it covered the whole screen, and no other frame could get the focus). With f0911e52f0e71c6d2539bdc74a09ff2dbd5ab125, the help dialog no longer covers the whole screen, so it must listen for and react to "frameFocused" events. However, the help dialog should not "hide" when the frame that is focused is itself! This required a little extra plumbing. That plumbing is helpful, though, because it allows individual UI components to decide what to do when another frame receives the focus (as opposed to the previious version, which simply unilaterally sent a "hide" message).
2016-03-06Fix focus issue with UI components.Stephen Blott
Problem: - `?`, `o`, `Esc`, `Esc` leaves the focus in the (invisible) help dialog frame, rendering Vimium broken. Since we do @iframeElement.focus() when we activate a UI component, here we do @iframeElement.blur() when hiding such elements. Fixes #2038.
2016-02-28Remove some legacy (and unused) code.Stephen Blott
2015-09-21Add a comment explaining the choice of XMLHttpRequest for UIComponentmrmr1993
2015-09-19Tidy up #1833.Stephen Blott
2015-09-18Load UIComponent stylesheet via XMLHttpRequest, use background as neededmrmr1993
2015-09-13Don't show UIComponent <iframe>s while vimium.css loadsmrmr1993
This fixes #1817, where our stylesheet isn't loaded correctly due to a Chromium issue and the Vomnibar/HUD <iframe>s are always visible on the new tab page.
2015-08-28clean codegdh1995
2015-08-26Use createElementNS for XML documents and remove XML specific codepathsmrmr1993
This implements @gdh1995's idea from #1796.
2015-05-29Also disable all externally-used functions for XML.Stephen Blott
2015-05-29Disable UIComponent for XML documentsmrmr1993
If the page is an XML document, nothing we do works: * <style> elements show their contents inline, * <iframe> elements don't load any content, * document.createElement generates elements that - have Element.style == null, and - ignore CSS. This commit stops us from injecting anything into the DOM from UIComponent, fixing #1640.
2015-05-26Refactor to avoid potential race condition (cont).Stephen Blott
2015-05-26Refactor to avoid potential race condition.Stephen Blott
I haven't seen this happen, but... It could be possible for the iframe's contents to load before this callback is called (on nextTick), in which case the "load" callback wouldn't be called. So we delay setting the iframe's source until nextTick has elapsed.
2015-05-26Add comment noting why we need AsyncDataFetcher.Stephen Blott
2015-05-25Fix UI Component race condition on start up.Stephen Blott
Approach: Re-use the existing AsynDataFetcher class to "fetch" and use the iframe message port. Messages are queued until the iframe's contents have loaded and the message port is open. Fixes #1679.
2015-05-18Fix vomnibar stuck open.Stephen Blott
See #1671. The problem was that we were making the vomnibar visible in the frontend, even if the vomnibar initialisation was not yet complete, and the iframe port was not yet available. (Also, @activate() is never being called without options, so we can drop that test.) Fixes #1671.
2015-05-13Move the HUD to an iframe, managed by UIComponentmrmr1993
2015-05-11Use css @import rather than XMLHttpRequest for shadow DOM external stylemrmr1993
2015-05-01Rename UIComponent class to match the one used in the stylesheetmrmr1993
2015-04-28Load stylesheet via XHR to fix styles in UIComponent Shadow DOMmrmr1993
Shadow DOM doesn't support <link>s, so we have to load the stylesheet manually and inject it into a <style> element.
2015-04-28Load the Vomnibar (and all UIComponents) in a shadow DOMmrmr1993
This insulates them from page CSS, so we don't have to compete to style elements correctly.
2015-04-28Fix vomnibar start-up messages.Stephen Blott
2015-04-26Disable frame flash after Vomnibar closes.Stephen Blott
The UX around this is not quite right yet. It's better to disable it for now.
2015-04-26Remove (overlooked) debugging code.Stephen Blott
2015-04-23Activate vomnibar in window.top; no flicker and tidy up.Stephen Blott
1. Rework event handling to eliminate frame flicker (a la #1485). 2. Tidy up logic. Which should make this more robust.
2015-03-17Activate vomnibar in window.top; more clean up.Stephen Blott
Clean up, and fixes following code review from @mrmr1993.
2015-03-17Activate vomnibar in window.top; fix race condition on close.Stephen Blott
2015-03-17Activate vomnibar in window.top; more clean up.Stephen Blott
2015-03-17Activate vomnibar in window.top; hide on focus, fixed.Stephen Blott
2015-03-17Activate vomnibar in window.top; hide on focus.Stephen Blott
2015-03-17Activate vomnibar in window.top; simplify messaging.Stephen Blott
2015-03-17Activate vomnibar in window.top; refocus original frame.Stephen Blott
2015-03-16Activate vomnibar in window.top.Stephen Blott
This changes vomnibar commands to activate not in the current frame, but in window.top. Consequently, the vomnibar always appears in the same position, and we don't get odd looking vomnibars in small frames. Apart from the better UX, this seems to be the right thing to do. Vomnibar commands apply to tabs (not frames). Currently incomplete: - On exit, the focus is not returned to the frame which originally had the focus. (It's returned to window.top). - The vomnibar can lose the focus and not hide itself for various frame/click combinations.
2015-03-06Correctly remove event listeners.Stephen Blott
Fix oversight from #1517.
2015-03-05Hide vomnibar if host frame regains focus.Stephen Blott
Fixes #1506. This takes the opposite approach to #1511. Instead of hiding the vomnibar when it blurs, we hide it when it's host frame is focused.