mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-20 00:15:45 +01:00
New prototype ItemList implementation. Faster completion scrolling.
This commit is contained in:
@@ -868,6 +868,7 @@ Class.Memoize = function Memoize(getter, wait)
|
||||
let done = false;
|
||||
|
||||
if (wait)
|
||||
// Crazy, yeah, I know. -- Kris
|
||||
this.get = function replace() {
|
||||
let obj = this.instance || this;
|
||||
Object.defineProperty(obj, key, {
|
||||
@@ -892,7 +893,7 @@ Class.Memoize = function Memoize(getter, wait)
|
||||
return this[key];
|
||||
};
|
||||
else
|
||||
this.get = function replace() {
|
||||
this.get = function g_Memoize() {
|
||||
let obj = this.instance || this;
|
||||
try {
|
||||
Class.replaceProperty(obj, key, null);
|
||||
@@ -903,7 +904,7 @@ Class.Memoize = function Memoize(getter, wait)
|
||||
}
|
||||
};
|
||||
|
||||
this.set = function replace(val) Class.replaceProperty(this.instance || this, val);
|
||||
this.set = function s_Memoize(val) Class.replaceProperty(this.instance || this, key, val);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1227,6 +1228,8 @@ var StructBase = Class("StructBase", Array, {
|
||||
this[i] = arguments[i];
|
||||
},
|
||||
|
||||
get toStringParams() this,
|
||||
|
||||
clone: function struct_clone() this.constructor.apply(null, this.slice()),
|
||||
|
||||
closure: Class.Property(Object.getOwnPropertyDescriptor(Class.prototype, "closure")),
|
||||
|
||||
@@ -289,7 +289,7 @@ var Buffer = Module("Buffer", {
|
||||
* @param {Node} elem The element to focus.
|
||||
*/
|
||||
focusElement: function focusElement(elem) {
|
||||
let { dactyl } = this.modules;
|
||||
let { Editor, dactyl } = this.modules;
|
||||
|
||||
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
||||
overlay.setData(elem, "focus-allowed", true);
|
||||
|
||||
@@ -633,25 +633,33 @@ var CompletionContext = Class("CompletionContext", {
|
||||
return iter.map(util.range(start, end, step), function (i) items[i]);
|
||||
},
|
||||
|
||||
getRow: function getRow(idx) this.cache.rows && this.cache.rows[idx],
|
||||
|
||||
getRows: function getRows(start, end, doc) {
|
||||
let self = this;
|
||||
let items = this.items;
|
||||
let cache = this.cache.rows;
|
||||
let step = start > end ? -1 : 1;
|
||||
|
||||
start = Math.max(0, start || 0);
|
||||
end = Math.min(items.length, end != null ? end : items.length);
|
||||
for (let i in util.range(start, end, step))
|
||||
try {
|
||||
yield [i, cache[i] = cache[i] || util.xmlToDom(self.createRow(items[i]), doc)];
|
||||
}
|
||||
catch (e) {
|
||||
util.reportError(e);
|
||||
yield [i, cache[i] = cache[i] || util.xmlToDom(
|
||||
<div highlight="CompItem" style="white-space: nowrap">
|
||||
<li highlight="CompResult">{items[i].text} </li>
|
||||
<li highlight="CompDesc ErrorMsg">{e} </li>
|
||||
</div>, doc)];
|
||||
}
|
||||
|
||||
for (let i in util.range(start, end, step)) {
|
||||
if (!cache[i])
|
||||
try {
|
||||
cache[i] = util.xmlToDom(self.createRow(items[i]), doc);
|
||||
}
|
||||
catch (e) {
|
||||
util.reportError(e);
|
||||
cache[i] = util.xmlToDom(
|
||||
<div highlight="CompItem" style="white-space: nowrap">
|
||||
<li highlight="CompResult">{items[i].text} </li>
|
||||
<li highlight="CompDesc ErrorMsg">{e} </li>
|
||||
</div>, doc);
|
||||
}
|
||||
|
||||
yield [i, cache[i]];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -94,7 +94,7 @@ var Contexts = Module("contexts", {
|
||||
|
||||
cleanup: function () {
|
||||
for each (let module in this.pluginModules)
|
||||
util.trapErrors("cleanup", module);
|
||||
util.trapErrors("unload", module);
|
||||
|
||||
this.pluginModules = {};
|
||||
},
|
||||
|
||||
@@ -36,10 +36,13 @@ function BooleanAttribute(attr) ({
|
||||
* change in the near future.
|
||||
*/
|
||||
var DOM = Class("DOM", {
|
||||
init: function init(val, context) {
|
||||
init: function init(val, context, nodes) {
|
||||
let self;
|
||||
let length = 0;
|
||||
|
||||
if (nodes)
|
||||
this.nodes = nodes;
|
||||
|
||||
if (context instanceof Ci.nsIDOMDocument)
|
||||
this.document = context;
|
||||
|
||||
@@ -48,7 +51,7 @@ var DOM = Class("DOM", {
|
||||
|
||||
if (val == null)
|
||||
;
|
||||
else if (typeof val == "xml")
|
||||
else if (typeof val == "xml" && context instanceof Ci.nsIDOMDocument)
|
||||
this[length++] = DOM.fromXML(val, context, this.nodes);
|
||||
else if (val instanceof Ci.nsIDOMNode || val instanceof Ci.nsIDOMWindow)
|
||||
this[length++] = val;
|
||||
@@ -58,6 +61,8 @@ var DOM = Class("DOM", {
|
||||
else if ("__iterator__" in val || isinstance(val, ["Iterator", "Generator"]))
|
||||
for (let elem in val)
|
||||
this[length++] = elem;
|
||||
else
|
||||
this[length++] = val;
|
||||
|
||||
this.length = length;
|
||||
return self || this;
|
||||
@@ -130,19 +135,22 @@ var DOM = Class("DOM", {
|
||||
}, self || this);
|
||||
|
||||
let dom = this;
|
||||
function munge(val) {
|
||||
function munge(val, container, idx) {
|
||||
if (val instanceof Ci.nsIDOMRange)
|
||||
return val.extractContents();
|
||||
if (val instanceof Ci.nsIDOMNode)
|
||||
return val;
|
||||
|
||||
if (typeof val == "xml")
|
||||
if (typeof val == "xml") {
|
||||
val = dom.constructor(val, dom.document);
|
||||
if (container)
|
||||
container[idx] = val[0];
|
||||
}
|
||||
|
||||
if (isObject(val) && "length" in val) {
|
||||
let frag = dom.document.createDocumentFragment();
|
||||
for (let i = 0; i < val.length; i++)
|
||||
frag.appendChild(munge(val[i]));
|
||||
frag.appendChild(munge(val[i], val, i));
|
||||
return frag;
|
||||
}
|
||||
return val;
|
||||
|
||||
@@ -28,7 +28,7 @@ var FailedAssertion = Class("FailedAssertion", ErrorBase, {
|
||||
noTrace: true
|
||||
});
|
||||
|
||||
var Point = Struct("x", "y");
|
||||
var Point = Struct("Point", "x", "y");
|
||||
|
||||
var wrapCallback = function wrapCallback(fn, isEvent) {
|
||||
if (!fn.wrapper)
|
||||
|
||||
Reference in New Issue
Block a user