Bug 336799 r+sr=bryner Remove spellcheck UI from XUL textboxes

This commit is contained in:
brettw%gmail.com 2006-07-28 17:36:00 +00:00
Родитель beeec7ced8
Коммит 7484cf11af
2 изменённых файлов: 0 добавлений и 119 удалений

Просмотреть файл

@ -90,23 +90,6 @@
<property name="selectionEnd" onset="this.inputField.selectionEnd = val; return val;"
onget="return this.inputField.selectionEnd;"/>
<!-- use this property "spellCheckerUI" instead of "InlineSpellCheckUI",
because this object does the lazy creation and initialization
you need -->
<property name="spellCheckerUI" readonly="true">
<getter><![CDATA[
if (! this.InlineSpellCheckerUI) {
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].
getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://global/content/inlineSpellCheckUI.js", this);
// watch out - that could have failed
if (this.InlineSpellCheckerUI)
this.InlineSpellCheckerUI.init(this.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor);
}
return this.InlineSpellCheckerUI;
]]></getter>
</property>
<method name="setSelectionRange">
<parameter name="aSelectionStart"/>
<parameter name="aSelectionEnd"/>
@ -138,13 +121,6 @@
}
}
#endif
str = this.getAttribute("spellcheck");
if (str == "true") {
// the problem is that we can't initialize the spell checker in the
// constructor because not everything is initialized and the editor
// will fail to create the inline spell checker object.
setTimeout(this._delayedInitSpellCheck, 0, this)
}
]]></constructor>
<destructor>
@ -155,17 +131,6 @@
]]>
</destructor>
<method name="_delayedInitSpellCheck">
<parameter name="me"/>
<body><![CDATA[
// called by the constructor to turn on spell checking
var spellui = me.spellCheckerUI;
if (spellui) {
spellui.enabled = true;
}
]]></body>
</method>
</implementation>
<handlers>
@ -275,27 +240,13 @@
onpopupshowing="if (document.commandDispatcher.focusedElement != this.parentNode.firstChild)
this.parentNode.firstChild.focus();
this.parentNode._doPopupItemEnabling(this);"
onpopuphiding="this.parentNode._doPopupItemDisabling(this);"
oncommand="var cmd = event.originalTarget.getAttribute('cmd'); if(cmd) { this.parentNode.doCommand(cmd); event.stopPropagation(); }">
<xul:menuitem label="&spellNoSuggestions.label;" anonid="spell-no-suggestions" disabled="true"/>
<xul:menuitem label="&spellAddToDictionary.label;" accesskey="&spellAddToDictionary.accesskey;" anonid="spell-add-to-dictionary" oncommand="this.parentNode.parentNode.spellui.addToDictionary();"/>
<xul:menuseparator anonid="spell-suggestions-separator"/>
<xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo"/>
<xul:menuseparator/>
<xul:menuitem label="&cutCmd.label;" accesskey="&cutCmd.accesskey;" cmd="cmd_cut"/>
<xul:menuitem label="&copyCmd.label;" accesskey="&copyCmd.accesskey;" cmd="cmd_copy"/>
<xul:menuitem label="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" cmd="cmd_paste"/>
<xul:menuitem label="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" cmd="cmd_delete"/>
<xul:menuseparator/>
<xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" cmd="cmd_selectAll"/>
<xul:menuseparator anonid="spell-check-separator"/>
<xul:menuitem label="&spellEnable.label;" type="checkbox" accesskey="&spellEnable.accesskey;" anonid="spell-check-enabled" oncommand="this.parentNode.parentNode.spellui.toggleEnabled();"/>
<xul:menu label="&spellDictionaries.label;" accesskey="&spellDictionaries.accesskey;" anonid="spell-dictionaries">
<xul:menupopup anonid="spell-dictionaries-menu"
onpopupshowing="event.stopPropagation();"
onpopuphiding="event.stopPropagation();">
</xul:menupopup>
</xul:menu>
</xul:menupopup>
</content>
@ -316,62 +267,9 @@
children[i].setAttribute("disabled", "true");
}
}
// -- spell checking --
var textboxElt = popupNode;
do {
if (textboxElt.localName == "textbox")
break;
textboxElt = textboxElt.parentNode;
} while (textboxElt);
if (! textboxElt || textboxElt.localName != "textbox") {
// can't find it, give up
this._setNoSpellCheckingAllowed();
return;
}
var spellui = textboxElt.spellCheckerUI;
this.spellui = spellui;
if (! spellui.canSpellCheck)
{
this._setNoSpellCheckingAllowed();
return;
}
spellui.initFromEvent(document.popupRangeParent,
document.popupRangeOffset);
var enabled = spellui.enabled;
document.getAnonymousElementByAttribute(this, "anonid",
"spell-check-enabled").setAttribute("checked", enabled);
var overMisspelling = spellui.overMisspelling;
this._setMenuItemVisibility("spell-add-to-dictionary", overMisspelling);
this._setMenuItemVisibility("spell-suggestions-separator", overMisspelling);
// suggestion list
var suggestionsSeparator = document.getAnonymousElementByAttribute(this,
"anonid", "spell-add-to-dictionary");
var numsug = spellui.addSuggestionsToMenu(popupNode, suggestionsSeparator, 5);
this._setMenuItemVisibility("spell-no-suggestions", overMisspelling && numsug == 0);
// dictionary list
var dictmenu = document.getAnonymousElementByAttribute(this, "anonid",
"spell-dictionaries-menu");
var numdicts = spellui.addDictionaryListToMenu(dictmenu, null);
this._setMenuItemVisibility("spell-dictionaries", enabled && numdicts > 1);
]]>
</body>
</method>
<method name="_doPopupItemDisabling">
<parameter name="popupNode"/>
<body><![CDATA[
if (this.spellui) {
this.spellui.clearSuggestionsFromMenu();
this.spellui.clearDictionaryListFromMenu();
}
]]></body>
</method>
<method name="_setMenuItemVisibility">
<parameter name="anonid"/>
@ -381,16 +279,6 @@
hidden = ! visible;
]]></body>
</method>
<method name="_setNoSpellCheckingAllowed">
<body><![CDATA[
this._setMenuItemVisibility("spell-no-suggestions", false);
this._setMenuItemVisibility("spell-check-enabled", false);
this._setMenuItemVisibility("spell-check-separator", false);
this._setMenuItemVisibility("spell-add-to-dictionary", false);
this._setMenuItemVisibility("spell-suggestions-separator", false);
this._setMenuItemVisibility("spell-dictionaries", false);
]]></body>
</method>
<method name="doCommand">
<parameter name="command"/>

Просмотреть файл

@ -10,10 +10,3 @@
<!ENTITY selectAllCmd.accesskey "a">
<!ENTITY deleteCmd.label "Delete">
<!ENTITY deleteCmd.accesskey "d">
<!ENTITY spellAddToDictionary.label "Add to dictionary">
<!ENTITY spellAddToDictionary.accesskey "t">
<!ENTITY spellEnable.label "Spell check this field">
<!ENTITY spellEnable.accesskey "S">
<!ENTITY spellNoSuggestions.label "(No spelling suggestions)">
<!ENTITY spellDictionaries.label "Languages">
<!ENTITY spellDictionaries.accesskey "l">