summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-09-27 15:20:03 -0400
committerKris Maglione <maglione.k@gmail.com>2011-09-27 15:20:03 -0400
commit9c609f24f25e67afa1515a8359222ba4ee15f60f (patch)
tree01fc1a04e64e27048b17027acc102f22d6fe2a96
parent77d8526b433bc5a92853c792de7f0552c1e31aa4 (diff)
downloadpentadactyl-9c609f24f25e67afa1515a8359222ba4ee15f60f.tar.gz
Implement parent groups.
-rw-r--r--common/modules/contexts.jsm20
1 files changed, 18 insertions, 2 deletions
diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm
index 6f8eb7e4..b109cc61 100644
--- a/common/modules/contexts.jsm
+++ b/common/modules/contexts.jsm
@@ -22,8 +22,11 @@ var Group = Class("Group", {
this.filter = filter || this.constructor.defaultFilter;
this.persist = persist || false;
this.hives = [];
+ this.children = [];
},
+ get contexts() this.modules.contexts,
+
set lastDocument(val) { this._lastDocument = val && Cu.getWeakReference(val); },
get lastDocument() this._lastDocument && this._lastDocument.get(),
@@ -36,10 +39,14 @@ var Group = Class("Group", {
this.hives = [];
for (let hive in keys(this.hiveMap))
delete this[hive];
+
+ this.children.splice(0).forEach(this.contexts.closure.removeGroup);
},
destroy: function destroy() {
for (let hive in values(this.hives))
util.trapErrors("destroy", hive);
+
+ this.children.splice(0).forEach(this.contexts.closure.removeGroup);
},
argsExtra: function argsExtra() ({}),
@@ -330,6 +337,7 @@ var Contexts = Module("contexts", {
if (replace) {
util.trapErrors("cleanup", group);
+
if (description)
group.description = description;
if (filter)
@@ -341,7 +349,7 @@ var Contexts = Module("contexts", {
return group;
},
- removeGroup: function removeGroup(name, filter) {
+ removeGroup: function removeGroup(name) {
if (isObject(name)) {
if (this.groupList.indexOf(name) === -1)
return;
@@ -530,8 +538,16 @@ var Contexts = Module("contexts", {
if (args.context) {
args.context.group = group;
- if (args.context.context)
+ if (args.context.context) {
args.context.context.group = group;
+
+ let parent = args.context.context.GROUP;
+ if (parent && parent != group) {
+ group.parent = parent;
+ if (!~parent.children.indexOf(group))
+ parent.children.push(group);
+ }
+ }
}
util.assert(!group.builtin ||