isearch-backspace, isearch-done: docstrings
[conkeror.git] / modules / stylesheet.js
blob518df3f15112887b88a848a5b055b6a33694ce3f
1 /**
2  * (C) Copyright 2004-2007 Shawn Betts
3  * (C) Copyright 2007-2010 John J. Foerch
4  * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
5  *
6  * Use, modification, and distribution are subject to the terms specified in the
7  * COPYING file.
8 **/
10 function register_user_stylesheet (url) {
11     var uri = make_uri(url);
12     var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
13         .getService(Ci.nsIStyleSheetService);
14     sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
17 function unregister_user_stylesheet (url) {
18     var uri = make_uri(url);
19     var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
20         .getService(Ci.nsIStyleSheetService);
21     if (sss.sheetRegistered(uri, sss.USER_SHEET))
22         sss.unregisterSheet(uri, sss.USER_SHEET);
25 function register_agent_stylesheet (url) {
26     var uri = make_uri(url);
27     var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
28         .getService(Ci.nsIStyleSheetService);
29     sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
32 function unregister_agent_stylesheet (url) {
33     var uri = make_uri(url);
34     var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
35         .getService(Ci.nsIStyleSheetService);
36     if (sss.sheetRegistered(uri, sss.AGENT_SHEET))
37         sss.unregisterSheet(uri, sss.AGENT_SHEET);
40 function agent_stylesheet_registered_p (url) {
41     var uri = make_uri(url);
42     var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
43         .getService(Ci.nsIStyleSheetService);
44     return sss.sheetRegistered(uri, sss.AGENT_SHEET);
47 function user_stylesheet_registered_p (url) {
48     var uri = make_uri(url);
49     var sss = Cc["@mozilla.org/content/style-sheet-service;1"]
50         .getService(Ci.nsIStyleSheetService);
51     return sss.sheetRegistered(uri, sss.USER_SHEET);
54 /**
55  * make_css_data_uri takes specifications for a css data uri in its
56  * positional and keyword arguments, and returns a new nsIURI object.
57  *
58  * rules: css rules, not including any @namespace or @-moz-document
59  *        headers.  given as a string or an array of strings.
60  *
61  * $namespace: optional string url for a @namespace header.
62  *
63  * $domains: optional string, or array of strings, for a @-moz-document
64  *           domain(...) header.
65  *
66  * $urls: optional string, or array of strings, for a @-moz-document
67  *        url(...) header.
68  *
69  * $url_prefixes: optional string, or array of strings, for a
70  *                @-moz-document url-prefix(...) header.
71  */
72 define_keywords("$namespace", "$domains", "$urls", "$url_prefixes");
73 function make_css_data_uri (rules) {
74     keywords(arguments);
75     var namespace = arguments.$namespace;
76     var domains = arguments.$domains;
77     var urls = arguments.$urls;
78     var url_prefixes = arguments.$url_prefixes;
79     rules = make_array(rules).join("\n");
80     var restrictions = Array.prototype.concat(
81         make_array(domains).map(function (x) "domain("+x+")"),
82         make_array(urls).map(function (x) "url("+x+")"),
83         make_array(url_prefixes).map(function (x) "url-prefix("+x+")"))
84         .join(",\n");
85     if (restrictions)
86         rules = "@-moz-document "+restrictions+" {\n"+rules+"\n}";
87     if (namespace)
88         rules = "@namespace url("+namespace+");\n"+rules;
89     return make_uri("data:text/css,"+escape(rules));
92 provide("stylesheet");