From 647fd97bef55d2371e87f0cd418ddff62f36800e Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Wed, 24 Oct 2012 15:33:56 -0400 Subject: Use insertCSS() API instead of manually created style element. For some reason addCssToPage seemed to break on Chrome 24. Closes #676. --- background_scripts/main.coffee | 4 ++++ content_scripts/link_hints.coffee | 1 - lib/dom_utils.coffee | 15 --------------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index a3857d61..b56d391c 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -318,6 +318,10 @@ updateScrollPosition = (tab, scrollX, scrollY) -> chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) -> return unless changeInfo.status == "loading" # only do this once per URL change + chrome.tabs.insertCSS tabId, + allFrames: true + code: Settings.get("userDefinedLinkHintCss") + runAt: "document_start" updateOpenTabs(tab) updateActiveState(tabId)) diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 55a78036..5c7f6510 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -60,7 +60,6 @@ LinkHints = @setOpenLinkMode(mode) hintMarkers = @markerMatcher.fillInMarkers(@createMarkerFor(el) for el in @getVisibleClickableElements()) - DomUtils.addCssToPage(settings.get("userDefinedLinkHintCss"), "vimiumLinkHintCss") # Note(philc): Append these markers as top level children instead of as child nodes to the link itself, # because some clickable elements cannot contain children, e.g. submit buttons. This has the caveat # that if you scroll the page and the link has position=fixed, the marker will not stay fixed. diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 501e43a5..a99cb5a6 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -1,19 +1,4 @@ DomUtils = - # - # Adds the given CSS to the page. - # - addCssToPage: (css, id) -> - return if document.getElementById(id) - head = document.getElementsByTagName("head")[0] - if (!head) - head = document.createElement("head") - document.documentElement.appendChild(head) - style = document.createElement("style") - style.id = id - style.type = "text/css" - style.appendChild(document.createTextNode(css)) - head.appendChild(style) - # # Runs :callback if the DOM has loaded, otherwise runs it on load # -- cgit v1.2.3