Skip to content

Commit

Permalink
Replaced updateContainer() -- including its insecure call to eval() -…
Browse files Browse the repository at this point in the history
…- with a faked "input" event
  • Loading branch information
1ec5 committed Feb 8, 2009
1 parent 76f1550 commit 691d325
Showing 1 changed file with 7 additions and 41 deletions.
48 changes: 7 additions & 41 deletions content/avim.js
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,7 @@ function AVIM() {
var sp = pos = this.oc.selectionStart;
w = this.unV(w);
if(!this.changed) {
// Insert the non-deadkey.
// w += k;
// var sst = this.oc.scrollTop;
// pos += k.length;
Expand Down Expand Up @@ -1019,6 +1020,9 @@ function AVIM() {
if(this.changed) {
this.changed = false;
e.preventDefault();
var inputEvent = document.createEvent("Events");
inputEvent.initEvent("input", true, true);
el.dispatchEvent(inputEvent);
}
};

Expand All @@ -1042,46 +1046,6 @@ function AVIM() {
return AVIMConfig.exclude.indexOf(id.toLowerCase()) >= 0;
}

/**
* Update specialized XUL textboxes that typically rely on keypress events
* to change state. Examples include autocomplete textboxes and the Find
* Toolbar.
*
* @param e {object} the key press event.
*/
this.updateContainer = function(e) {
var xulTarget = e.target.textbox || e.target;
var xblTarget = e.originalTarget;

// Autocomplete textboxes for Toolkit
if (xulTarget.type == "autocomplete" && xulTarget.controller) {
xulTarget.controller.handleText(true);
}

// Find Toolbar for Toolkit
if (xulTarget._find) xulTarget._find(xblTarget.value);

// Bookmark properties in Firefox -- truly awful kludge
with (xulTarget) eval(xulTarget.getAttribute("oninput") || "");

// Subject bar in Thunderbird
if (window.SetComposeWindowTitle) SetComposeWindowTitle();

// Autocomplete textboxes in Gecko

// Quick way to detect in-browser textboxes -- once autocomplete is used
// for an in-page control (e.g., <input type="search">), do this the
// right way.
if (xulTarget != xblTarget) return;
var popup = document.getElementById("PopupAutoComplete");
if (popup && popup.popupOpen && popup.input) {
// dump("AVIM.updateContainer()\n"); // debug
// popup.input.textValue = xblTarget.value;
// popup.closePopup();
// popup.openAutocompletePopup(popup.input, xblTarget);
}
}

/**
* Handles key presses in the current window. This function is triggered as
* soon as the key goes up. If the key press's target is a XUL element, this
Expand Down Expand Up @@ -1118,13 +1082,15 @@ function AVIM() {
if (this.changed) {
this.changed=false;
e.preventDefault();
var inputEvent = document.createEvent("Events");
inputEvent.initEvent("input", true, true);
el.dispatchEvent(inputEvent);
// A bit of a hack to prevent single-line textboxes from scrolling
// to the beginning of the line.
if (window.goDoCommand && el.type != "textarea") {
goDoCommand("cmd_charPrevious");
goDoCommand("cmd_charNext");
}
this.updateContainer(e);
return false;
}
return true;
Expand Down

0 comments on commit 691d325

Please sign in to comment.