mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 14:22:27 +01:00
Fix some brokenness
This commit is contained in:
@@ -41,6 +41,7 @@ liberator.Bookmarks = function () //{{{
|
|||||||
const ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
const ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||||
.getService(Components.interfaces.nsIIOService);
|
.getService(Components.interfaces.nsIIOService);
|
||||||
|
|
||||||
|
const storage = liberator.storage;
|
||||||
function Cache(name, store, serial)
|
function Cache(name, store, serial)
|
||||||
{
|
{
|
||||||
const properties = { uri: 0, title: 1, keyword: 2, tags: 3, id: 4 };
|
const properties = { uri: 0, title: 1, keyword: 2, tags: 3, id: 4 };
|
||||||
@@ -140,7 +141,7 @@ liberator.Bookmarks = function () //{{{
|
|||||||
if (rootFolders.indexOf(findRoot(itemId)) >= 0)
|
if (rootFolders.indexOf(findRoot(itemId)) >= 0)
|
||||||
{
|
{
|
||||||
loadBookmark(readBookmark(itemId));
|
loadBookmark(readBookmark(itemId));
|
||||||
liberator.storage.fireEvent(name, "add", itemId);
|
storage.fireEvent(name, "add", itemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -148,7 +149,7 @@ liberator.Bookmarks = function () //{{{
|
|||||||
{
|
{
|
||||||
// liberator.dump("onItemRemoved(" + itemId + ", " + folder + ", " + index + ")\n");
|
// liberator.dump("onItemRemoved(" + itemId + ", " + folder + ", " + index + ")\n");
|
||||||
if (deleteBookmark(itemId))
|
if (deleteBookmark(itemId))
|
||||||
liberator.storage.fireEvent(name, "remove", itemId);
|
storage.fireEvent(name, "remove", itemId);
|
||||||
},
|
},
|
||||||
onItemChanged: function (itemId, property, isAnnotation, value)
|
onItemChanged: function (itemId, property, isAnnotation, value)
|
||||||
{
|
{
|
||||||
@@ -162,7 +163,7 @@ liberator.Bookmarks = function () //{{{
|
|||||||
value = taggingService.getTagsForURI(ioService.newURI(bookmark[properties.uri], null, null), {});
|
value = taggingService.getTagsForURI(ioService.newURI(bookmark[properties.uri], null, null), {});
|
||||||
if (property in properties)
|
if (property in properties)
|
||||||
bookmark[properties[property]] = value;
|
bookmark[properties[property]] = value;
|
||||||
liberator.storage.fireEvent(name, "change", itemId);
|
storage.fireEvent(name, "change", itemId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
QueryInterface: function (iid)
|
QueryInterface: function (iid)
|
||||||
@@ -184,7 +185,7 @@ liberator.Bookmarks = function () //{{{
|
|||||||
}
|
}
|
||||||
var cache = liberator.storage.newObject("bookmark-cache", Cache, false);
|
var cache = liberator.storage.newObject("bookmark-cache", Cache, false);
|
||||||
liberator.storage.addObserver("bookmark-cache", bookmarkObserver);
|
liberator.storage.addObserver("bookmark-cache", bookmarkObserver);
|
||||||
liberator.registerCallback("shutdown", 0, function () {
|
liberator.registerObserver("shutdown", function () {
|
||||||
liberator.storage.removeObserver("bookmark-cache", bookmarkObserver)
|
liberator.storage.removeObserver("bookmark-cache", bookmarkObserver)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ liberator.Buffer = function () //{{{
|
|||||||
const util = liberator.util;
|
const util = liberator.util;
|
||||||
const consoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
const consoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
||||||
.getService(Components.interfaces.nsIConsoleService);
|
.getService(Components.interfaces.nsIConsoleService);
|
||||||
|
const sleep = liberator.sleep;
|
||||||
function Styles(name, store, serial)
|
function Styles(name, store, serial)
|
||||||
{
|
{
|
||||||
const XHTML = "http://www.w3.org/1999/xhtml";
|
const XHTML = "http://www.w3.org/1999/xhtml";
|
||||||
@@ -128,6 +128,8 @@ liberator.Buffer = function () //{{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
let queryinterface = XPCOMUtils.generateQI([Components.interfaces.nsIConsoleListener]);
|
let queryinterface = XPCOMUtils.generateQI([Components.interfaces.nsIConsoleListener]);
|
||||||
|
/* What happens if more than one thread tries to use this? */
|
||||||
|
let testDoc = document.implementation.createDocument(XHTML, "doc", null);
|
||||||
function checkSyntax(css)
|
function checkSyntax(css)
|
||||||
{
|
{
|
||||||
let errors = [];
|
let errors = [];
|
||||||
@@ -148,23 +150,24 @@ liberator.Buffer = function () //{{{
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
consoleService.registerListener(listener);
|
consoleService.registerListener(listener);
|
||||||
let doc = document.implementation.createDocument(XHTML, "doc", null);
|
if (testDoc.documentElement.firstChild)
|
||||||
doc.documentElement.appendChild(util.xmlToDom(
|
testDoc.documentElement.removeChild(testDoc.documentElement.firstChild);
|
||||||
<html><head><link type="text/css" rel="stylesheet" href={cssUri(css)}/></head></html>, doc));
|
testDoc.documentElement.appendChild(util.xmlToDom(
|
||||||
|
<html><head><link type="text/css" rel="stylesheet" href={cssUri(css)}/></head></html>, testDoc));
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Throws NS_ERROR_DOM_INVALID_ACCESS_ERR if not finished loading
|
// Throws NS_ERROR_DOM_INVALID_ACCESS_ERR if not finished loading
|
||||||
doc.styleSheets[0].cssRules.length;
|
testDoc.styleSheets[0].cssRules.length;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
if (e.name != "NS_ERROR_DOM_INVALID_ACCESS_ERR")
|
if (e.name != "NS_ERROR_DOM_INVALID_ACCESS_ERR")
|
||||||
return [e.toString()];
|
return [e.toString()];
|
||||||
liberator.sleep(10);
|
sleep(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1560,15 +1560,15 @@ liberator.Events = function () //{{{
|
|||||||
{
|
{
|
||||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||||
.getService(Components.interfaces.nsIPrefService);
|
.getService(Components.interfaces.nsIPrefService);
|
||||||
this._branch = prefService.getBranch(""); // better way to monitor all changes?
|
this._branch = prefService.getBranch(""); // better way to monitor all changes?
|
||||||
this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||||
this._branch.addObserver("", this, false);
|
this._branch.addObserver("", this, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
unregister: function ()
|
unregister: function ()
|
||||||
{
|
{
|
||||||
if (!this._branch) return;
|
if (this._branch)
|
||||||
this._branch.removeObserver("", this);
|
this._branch.removeObserver("", this);
|
||||||
},
|
},
|
||||||
|
|
||||||
observe: function (aSubject, aTopic, aData)
|
observe: function (aSubject, aTopic, aData)
|
||||||
@@ -1603,7 +1603,10 @@ liberator.Events = function () //{{{
|
|||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
eventManager.prefObserver.register();
|
eventManager.prefObserver.register();
|
||||||
liberator.registerCallback("shutdown", 0, eventManager.destroy);
|
liberator.registerObserver("shutdown", function () {
|
||||||
|
eventManager.destroy();
|
||||||
|
eventManager.prefObserver.unregister();
|
||||||
|
});
|
||||||
|
|
||||||
window.addEventListener("keypress", eventManager.onKeyPress, true);
|
window.addEventListener("keypress", eventManager.onKeyPress, true);
|
||||||
window.addEventListener("keydown", eventManager.onKeyUpOrDown, true);
|
window.addEventListener("keydown", eventManager.onKeyUpOrDown, true);
|
||||||
|
|||||||
@@ -32,7 +32,11 @@ const liberator = (function () //{{{
|
|||||||
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
////////////////////// PRIVATE SECTION /////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
const threadManager = Components.classes["@mozilla.org/thread-manager;1"]
|
||||||
|
.getService(Components.interfaces.nsIThreadManager);
|
||||||
|
|
||||||
var callbacks = [];
|
var callbacks = [];
|
||||||
|
var observers = [];
|
||||||
|
|
||||||
function loadModule(name, func)
|
function loadModule(name, func)
|
||||||
{
|
{
|
||||||
@@ -627,12 +631,26 @@ const liberator = (function () //{{{
|
|||||||
for (let i = 0; i < callbacks.length; i++)
|
for (let i = 0; i < callbacks.length; i++)
|
||||||
{
|
{
|
||||||
var [thistype, thismode, thisfunc] = callbacks[i];
|
var [thistype, thismode, thisfunc] = callbacks[i];
|
||||||
if (mode == liberator.modes.NONE || mode == thismode && type == thistype)
|
if (mode == thismode && type == thistype)
|
||||||
return thisfunc.call(this, data);
|
return thisfunc.call(this, data);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
registerObserver: function (type, callback)
|
||||||
|
{
|
||||||
|
observers.push([type, callback]);
|
||||||
|
},
|
||||||
|
|
||||||
|
triggerObserver: function (type, data)
|
||||||
|
{
|
||||||
|
for (let [,[thistype, callback]] in Iterator(observers))
|
||||||
|
{
|
||||||
|
if (thistype == type)
|
||||||
|
callback(data);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
beep: function ()
|
beep: function ()
|
||||||
{
|
{
|
||||||
if (liberator.options["visualbell"])
|
if (liberator.options["visualbell"])
|
||||||
@@ -1181,7 +1199,7 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
liberator.storage.saveAll();
|
liberator.storage.saveAll();
|
||||||
|
|
||||||
liberator.triggerCallback("shutdown", 0, null);
|
liberator.triggerObserver("shutdown", null);
|
||||||
|
|
||||||
liberator.dump("All liberator modules destroyed\n");
|
liberator.dump("All liberator modules destroyed\n");
|
||||||
|
|
||||||
@@ -1190,8 +1208,6 @@ const liberator = (function () //{{{
|
|||||||
|
|
||||||
sleep: function (ms)
|
sleep: function (ms)
|
||||||
{
|
{
|
||||||
var threadManager = Components.classes["@mozilla.org/thread-manager;1"]
|
|
||||||
.getService(Components.interfaces.nsIThreadManager);
|
|
||||||
var mainThread = threadManager.mainThread;
|
var mainThread = threadManager.mainThread;
|
||||||
|
|
||||||
var then = new Date().getTime(), now = then;
|
var then = new Date().getTime(), now = then;
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ liberator.Options = function () //{{{
|
|||||||
|
|
||||||
liberator.storage.newMap("options", false);
|
liberator.storage.newMap("options", false);
|
||||||
liberator.storage.addObserver("options", optionObserver);
|
liberator.storage.addObserver("options", optionObserver);
|
||||||
liberator.registerCallback("shutdown", 0, function () {
|
liberator.registerObserver("shutdown", function () {
|
||||||
liberator.storage.removeObserver("options", optionObserver)
|
liberator.storage.removeObserver("options", optionObserver)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -252,7 +252,7 @@ liberator.Options = function () //{{{
|
|||||||
if (!/keypress/.test(popupAllowedEvents))
|
if (!/keypress/.test(popupAllowedEvents))
|
||||||
{
|
{
|
||||||
storePreference("dom.popup_allowed_events", popupAllowedEvents + " keypress");
|
storePreference("dom.popup_allowed_events", popupAllowedEvents + " keypress");
|
||||||
liberator.registerCallback("shutdown", 0, function ()
|
liberator.registerObserver("shutdown", function ()
|
||||||
{
|
{
|
||||||
if (loadPreference("dom.popup_allowed_events", "")
|
if (loadPreference("dom.popup_allowed_events", "")
|
||||||
== popupAllowedEvents + " keypress")
|
== popupAllowedEvents + " keypress")
|
||||||
@@ -735,7 +735,7 @@ liberator.Options = function () //{{{
|
|||||||
|
|
||||||
if (filter.length > 0 && filter.lastIndexOf("=") == filter.length - 1)
|
if (filter.length > 0 && filter.lastIndexOf("=") == filter.length - 1)
|
||||||
{
|
{
|
||||||
for (let [,name] in prefArray)
|
for (let [,name] in Iterator(prefArray))
|
||||||
{
|
{
|
||||||
if (name.match("^" + filter.substr(0, filter.length - 1) + "$" ))
|
if (name.match("^" + filter.substr(0, filter.length - 1) + "$" ))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user