Skip to content

Instantly share code, notes, and snippets.

@wlt
Created February 16, 2011 03:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wlt/828794 to your computer and use it in GitHub Desktop.
Save wlt/828794 to your computer and use it in GitHub Desktop.
fix: "set toolbars=menu" behavior didn't conform with Firefox decide what to do.
diff -r 484fafc733a2 common/content/liberator.js
--- a/common/content/liberator.js Mon Feb 14 20:51:50 2011 +0900
+++ b/common/content/liberator.js Wed Feb 16 11:44:13 2011 +0900
@@ -1229,12 +1229,12 @@
if (!elem)
continue;
- elem.collapsed = collapsed;
-
// Firefox4 added this helper function, which does more than
// just collapsing elements (like showing or hiding the menu button when the menu is hidden/shown)
if (window.setToolbarVisibility)
window.setToolbarVisibility(elem, !collapsed);
+ else
+ elem.collapsed = collapsed;
}
return values;
@@ -1244,8 +1244,9 @@
let values = [];
for (let [name, toolbar] in Iterator(toolbars)) {
let elem = document.getElementById(toolbar[0]);
+ let hidingAttribute = elem.getAttribute("type") == "menubar" ? "autohide" : "collapsed";
if (elem)
- values.push(elem.collapsed ? "no" + name : name);
+ values.push(elem.getAttribute(hidingAttribute) == "true" ? "no" + name : name);
}
return this.joinValues(values);
},
@@ -1256,8 +1257,10 @@
for (let [name, toolbar] in Iterator(toolbars)) {
let elem = document.getElementById(toolbar[0][0]);
+ let hidingAttribute = elem.getAttribute("type") == "menubar" ? "autohide" : "collapsed";
if (elem)
- completions.push([elem.collapsed ? name : "no" + name, (elem.collapsed ? "Show " : "Hide ") + toolbar[1]]);
+ completions.push([elem.getAttribute(hidingAttribute) == "true" ? name : "no" + name,
+ (elem.getAttribute(hidingAttribute) == "true" ? "Show " : "Hide ") + toolbar[1]]);
}
context.completions = completions;
context.compare = CompletionContext.Sort.unsorted;
・バグの再現方法
1. :set toolbars=menu
2. メニューバーを右クリックして、「メニューバー」のチェックを外し、メニューバーを非表示にする。
3. :set toolbars=で補完されるmenuの状態が、まだメニューバーが表示されているかのような状態。
・バグの原因
Vimperatorはメニューバー(ツールバー)の表示の状態を属性collapsedでのみ判定しているが、window.setToolbarVisibity()は属性typeが"menubar"の時だけcollapsedではなくautohideをいじるから。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment