diff options
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/hud.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/link_hints.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/ui_component.coffee | 18 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 23 |
4 files changed, 17 insertions, 28 deletions
diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index bfad71b7..5a3d9b79 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -96,7 +96,7 @@ class Tween styleElement: null constructor: (@cssSelector, insertionPoint = document.documentElement) -> - @styleElement = document.createElement "style" + @styleElement = DomUtils.createElement "style" unless @styleElement.style # We're in an XML document, so we shouldn't inject any elements. See the comment in UIComponent. diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 8e106b0f..54c10284 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -127,7 +127,7 @@ class LinkHintsMode # Creates a link marker for the given link. # createMarkerFor: (link) -> - marker = document.createElement("div") + marker = DomUtils.createElement "div" marker.className = "vimiumReset internalVimiumHintMarker vimiumHintMarker" marker.clickableItem = link.element diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index e4cfc293..d935079d 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -6,28 +6,16 @@ class UIComponent shadowDOM: null constructor: (iframeUrl, className, @handleMessage) -> - styleSheet = document.createElement "style" - - unless styleSheet.style - # If this is an XML document, nothing we do here works: - # * <style> elements show their contents inline, - # * <iframe> elements don't load any content, - # * document.createElement generates elements that have style == null and ignore CSS. - # If this is the case we don't want to pollute the DOM to no or negative effect. So we bail - # immediately, and disable all externally-called methods. - @postMessage = @activate = @show = @hide = -> - console.log "This vimium feature is disabled because it is incompatible with this page." - return - + styleSheet = DomUtils.createElement "style" styleSheet.type = "text/css" # Default to everything hidden while the stylesheet loads. styleSheet.innerHTML = "@import url(\"#{chrome.runtime.getURL("content_scripts/vimium.css")}\");" - @iframeElement = document.createElement "iframe" + @iframeElement = DomUtils.createElement "iframe" extend @iframeElement, className: className seamless: "seamless" - shadowWrapper = document.createElement "div" + shadowWrapper = DomUtils.createElement "div" # PhantomJS doesn't support createShadowRoot, so guard against its non-existance. @shadowDOM = shadowWrapper.createShadowRoot?() ? shadowWrapper @shadowDOM.appendChild styleSheet diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 9d850419..ddc80464 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -274,23 +274,22 @@ setScrollPosition = ({ scrollX, scrollY }) -> # # Called from the backend in order to change frame focus. # -window.focusThisFrame = do -> +DomUtils.documentReady -> # Create a shadow DOM wrapping the frame so the page's styles don't interfere with ours. - highlightedFrameElement = document.createElement "div" + highlightedFrameElement = DomUtils.createElement "div" # PhantomJS doesn't support createShadowRoot, so guard against its non-existance. _shadowDOM = highlightedFrameElement.createShadowRoot?() ? highlightedFrameElement # Inject stylesheet. - _styleSheet = document.createElement "style" - if _styleSheet.style? - _styleSheet.innerHTML = "@import url(\"#{chrome.runtime.getURL("content_scripts/vimium.css")}\");" - _shadowDOM.appendChild _styleSheet + _styleSheet = DomUtils.createElement "style" + _styleSheet.innerHTML = "@import url(\"#{chrome.runtime.getURL("content_scripts/vimium.css")}\");" + _shadowDOM.appendChild _styleSheet - _frameEl = document.createElement "div" + _frameEl = DomUtils.createElement "div" _frameEl.className = "vimiumReset vimiumHighlightedFrame" _shadowDOM.appendChild _frameEl - (request) -> + window.focusThisFrame = (request) -> if window.innerWidth < 3 or window.innerHeight < 3 # This frame is too small to focus. Cancel and tell the background frame to focus the next one instead. # This affects sites like Google Inbox, which have many tiny iframes. See #1317. @@ -304,6 +303,8 @@ window.focusThisFrame = do -> document.documentElement.appendChild highlightedFrameElement setTimeout (-> highlightedFrameElement.remove()), 200 +window.focusThisFrame = -> + extend window, scrollToBottom: -> Marks.setPreviousPosition() @@ -405,7 +406,7 @@ extend window, Math.min(count, visibleInputs.length) - 1 hints = for tuple in visibleInputs - hint = document.createElement "div" + hint = DomUtils.createElement "div" hint.className = "vimiumReset internalVimiumInputHint vimiumInputHint" # minus 1 for the border @@ -775,7 +776,7 @@ window.enterFindMode = -> window.showHelpDialog = (html, fid) -> return if (isShowingHelpDialog || !document.body || fid != frameId) isShowingHelpDialog = true - container = document.createElement("div") + container = DomUtils.createElement "div" container.id = "vimiumHelpDialogContainer" container.className = "vimiumReset" @@ -861,7 +862,7 @@ CursorHider = # See #1345 and #1348. return unless Utils.haveChromeVersion "39.0.2171.71" - @cursorHideStyle = document.createElement("style") + @cursorHideStyle = DomUtils.createElement "style" @cursorHideStyle.innerHTML = """ body * {pointer-events: none !important; cursor: none !important;} body, html {cursor: none !important;} |
