From 46327e51002ec694c8adb6484174b0acad8be76f Mon Sep 17 00:00:00 2001 From: Anton Khodakivskiy Date: Mon, 22 Jul 2013 14:22:30 +0300 Subject: [PATCH] Resort to Author sheets for CSS injection. Help to avoid dirty '!important' in CSS. --- extension/packages/utils.coffee | 17 +- extension/resources/style.css | 269 ++++++++++++++++---------------- 2 files changed, 144 insertions(+), 142 deletions(-) diff --git a/extension/packages/utils.coffee b/extension/packages/utils.coffee index 55e429e..9eb94a9 100644 --- a/extension/packages/utils.coffee +++ b/extension/packages/utils.coffee @@ -16,7 +16,6 @@ HTMLElement = Ci.nsIDOMHTMLElement Window = Ci.nsIDOMWindow ChromeWindow = Ci.nsIDOMChromeWindow -_sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService) _clip = Cc['@mozilla.org/widget/clipboard;1'].getService(Ci.nsIClipboard) class Bucket @@ -94,13 +93,15 @@ cssUri = do -> # Loads the css identified by the name in the StyleSheetService as User Stylesheet # The stylesheet is then appended to every document, but it can be overwritten by # any user css -loadCss = (name) -> - uri = cssUri(name) - if !_sss.sheetRegistered(uri, _sss.AGENT_SHEET) - _sss.loadAndRegisterSheet(uri, _sss.AGENT_SHEET) - - unload -> - _sss.unregisterSheet(uri, _sss.AGENT_SHEET) +loadCss = do -> + sss = Cc['@mozilla.org/content/style-sheet-service;1'].getService(Ci.nsIStyleSheetService) + return (name) -> + uri = cssUri(name) + if !sss.sheetRegistered(uri, sss.AUTHOR_SHEET) + sss.loadAndRegisterSheet(uri, sss.AUTHOR_SHEET) + + unload -> + sss.unregisterSheet(uri, sss.AUTHOR_SHEET) # Simulate mouse click with full chain of event # Copied from Vimium codebase diff --git a/extension/resources/style.css b/extension/resources/style.css index a7ac863..17931fd 100644 --- a/extension/resources/style.css +++ b/extension/resources/style.css @@ -1,221 +1,222 @@ /* Copied over from vimium project */ .VimFxReset { - background: none !important; - border: none !important; - /*bottom: auto !important;*/ - box-shadow: none !important; - color: WindowText !important; - cursor: auto !important; - display: inline !important; - float: none !important; - font-family: "Helvetica Neue", "Helvetica", "Arial", "Sans" !important; - font-size: inherit !important; - font-style: normal !important; - font-variant: normal !important; - font-weight: normal !important; - height: auto !important; - /*left: auto !important;*/ - letter-spacing: 0 !important; - line-height: 100% !important; - margin: 0 !important; - max-height: none !important; - max-width: none !important; - min-height: 0 !important; - min-width: 0 !important; - opacity: 1 !important; - padding: 0 !important; - position: static !important; - /*right: auto !important;*/ - text-align: left !important; - text-decoration: none !important; - text-indent: 0 !important; - text-shadow: none !important; - text-transform: none !important; - /*top: auto !important;*/ - vertical-align: baseline !important; - white-space: normal !important; - width: auto !important; - z-index: 99999999 !important; - float: none !important; + background: none; + border: none; + /*bottom: auto;*/ + box-shadow: none; + color: WindowText; + cursor: auto; + display: inline; + float: none; + font-family: "Helvetica Neue", "Helvetica", "Arial", "Sans"; + font-size: inherit; + font-style: normal; + font-variant: normal; + font-weight: normal; + height: auto; + /*left: auto;*/ + letter-spacing: 0; + line-height: 100%; + margin: 0; + max-height: none; + max-width: none; + min-height: 0; + min-width: 0; + opacity: 1; + padding: 0; + position: static; + /*right: auto;*/ + text-align: left; + text-decoration: none; + text-indent: 0; + text-shadow: none; + text-transform: none; + /*top: auto;*/ + vertical-align: baseline; + white-space: normal; + width: auto; + z-index: 99999999; + float: none; } /* Find */ input.VimFxNotFound#VimFxFindInput { - color: red !important; + color: red; } input#VimFxFindInput { - position: fixed !important; - bottom: 2px !important; - right: 2px !important; - font-size: 13px !important; - min-width: 200px !important; - background: white !important; - border: solid 1px ThreeDShadow !important; - border-radius: 3px 3px 0 0 !important; - padding: 4px 4px 6px !important; + position: fixed; + bottom: 2px; + right: 2px; + font-size: 13px; + min-width: 200px; + background: white; + border: solid 1px ThreeDShadow; + border-radius: 3px 3px 0 0; + padding: 4px 4px 6px; } /* Markers */ div.VimFxHintMarker { - position: absolute !important; - display: block !important; - white-space: nowrap !important; - overflow: hidden !important; - font-size: 12px !important; - padding: 1px 2px 0 2px !important; - box-shadow: 0 3px 7px 0 rgba(0, 0, 0, 0.3) !important; - background-color: #FFD76E !important; - border: solid 1px #E1BA53 !important; - border-radius: 2px !important; + position: absolute; + display: block; + white-space: nowrap; + overflow: hidden; + font-size: 12px; + padding: 1px 2px 0 2px; + box-shadow: 0 3px 7px 0 rgba(0, 0, 0, 0.3); + background-color: #FFD76E; + border: solid 1px #E1BA53; + border-radius: 2px; } div.VimFxHiddenHintMarker > span { - display: none !important; + display: none; } div.VimFxHintMarker > span { - color: #302505 !important; - font-family: "Helvetica Neue", "Helvetica", "Arial", "Sans" !important; - font-weight: bold !important; - font-size: 12px !important; - text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) !important; + color: #302505; + font-family: "Helvetica Neue", "Helvetica", "Arial", "Sans"; + font-weight: bold; + font-size: 12px; + text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); } div.VimFxHintMarker > span.VimFxCharMatch { - color: #ffa22a !important; + color: #ffa22a; } /* Help Dialog */ div#VimFxHelpDialog { - opacity:0.92 !important; - background-color: Window !important; - position:fixed !important; - border-radius:3px !important; - padding:15px 30px !important; - width:700px !important; - left:50% !important; + opacity:0.92; + background-color: Window; + position:fixed; + border-radius:3px; + padding:15px 30px; + width:700px; + left:50%; /* This needs to be 1/2 width to horizontally center the help dialog */ - margin-left:-380px !important; - top:30px !important; - box-shadow: rgba(1, 2, 1, 0.4) 0px 0px 6px !important; - overflow-y: auto !important; - z-index:99999998 !important; - font-size: 15px !important; - max-height: 80% !important; + margin-left:-380px; + top:30px; + box-shadow: rgba(1, 2, 1, 0.4) 0px 0px 6px; + overflow-y: auto; + z-index:99999998; + font-size: 15px; + max-height: 80%; } div#VimFxHelpDialog .VimFxTitle { - font-size: 30px !important; - line-height: 130% !important; - display: block !important; - float: left !important; + font-size: 30px; + line-height: 130%; + display: block; + float: left; } div#VimFxHelpDialog .VimFxClearFix { - clear: both !important; - float: none !important; - display: block !important; - visibility: hidden !important; - height: 0 !important; + clear: both; + float: none; + display: block; + visibility: hidden; + height: 0; } div#VimFxHelpDialog .VimFxTitleVim { - color: darkgreen !important; + color: darkgreen; } div#VimFxHelpDialog .VimFxTitleFx { - color: darkred !important; + color: darkred; } div#VimFxHelpDialog .VimFxVersion { - float: right !important; - position: absolute !important; - top: 20px !important; - right: 100px !important; - font-size: 12px !important; + float: right; + position: absolute; + top: 20px; + right: 100px; + font-size: 12px; } div#VimFxHelpDialog .VimFxClose { - float: right !important; - font-family: "Helvetica Neue", "Helvetica", "Arial", "Sans" !important; - position: absolute !important; - right: 20px !important; - top: 20px !important; - font-size: 20px !important; - cursor: pointer !important; + float: right; + font-family: "Helvetica Neue", "Helvetica", "Arial", "Sans"; + position: absolute; + right: 20px; + top: 20px; + font-size: 20px; + cursor: pointer; } div#VimFxHelpDialog .VimFxSocial { - float: left !important; + float: left; } div#VimFxHelpDialog .VimFxColumn { - width: 46% !important; - margin: 0 0 0 8% !important; - float: left !important; + width: 46%; + margin: 0 0 0 8%; + float: left; - margin-bottom: 10px !important; + margin-bottom: 10px; } div#VimFxHelpDialog .VimFxColumn:first-child -{ margin: 0 !important;} +{ margin: 0;} div#VimFxHelpDialog .VimFxSectionTitle { - display: block !important; - font-size: 15px !important; - font-weight: bold !important; - line-height: 140% !important; - text-transform: uppercase !important; - margin: 30px 0 10px 0 !important; + display: block; + font-size: 15px; + font-weight: bold; + line-height: 140%; + text-transform: uppercase; + margin: 30px 0 10px 0; } div#VimFxHelpDialog table.VimFxReset { - display: table !important; - table-layout: auto !important; + display: table; + table-layout: auto; } div#VimFxHelpDialog tr.VimFxReset { - display: table-row !important; + display: table-row; } div#VimFxHelpDialog td.VimFxReset { - display: table-cell !important; - padding-top: 2px !important; - padding-bottom: 4px !important; - line-height: 15px !important; + display: table-cell; + padding-top: 2px; + padding-bottom: 4px; + line-height: 15px; } div#VimFxHelpDialog td.VimFxSequence { - min-width:50px !important; - text-align: right !important; - padding-right:5px !important; - font-weight:bold !important; - color:#2f508e !important; + min-width:50px; + text-align: right; + padding-right:5px; + font-weight:bold; + color:#2f508e; } div#VimFxHelpDialog .VimFxSocial { - margin: 30px 0 0 0 !important; - font-size: 12px !important; + margin: 30px 0 0 0; + font-size: 12px; +[Survey] Clipboard Manager - Save, search and sync clipboard history across computers. } div#VimFxHelpDialog .VimFxSocial p { - display: block !important; - line-height: 150% !important; - margin: 0 0 5px 0 !important; + display: block; + line-height: 150%; + margin: 0 0 5px 0; } div#VimFxHelpDialog .VimFxSocial a { - text-decoration: underline !important; - color: darkblue !important; - cursor: pointer !important; + text-decoration: underline; + color: darkblue; + cursor: pointer; } div#VimFxHelpDialog span.VimFxDot { - color: #818181 !important; + color: #818181; } -- 2.39.3