Commit 547b0156 authored by Quentin Headen's avatar Quentin Headen
Browse files

Bug 352037 - Add an "Undo add to dictionary" item to spell checker's context menu item; r=ehsan

parent 53fc8685
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -46,6 +46,10 @@
                label="&spellAddToDictionary.label;"
                accesskey="&spellAddToDictionary.accesskey;"
                oncommand="InlineSpellCheckerUI.addToDictionary();"/>
      <menuitem id="spell-undo-add-to-dictionary"
                label="&spellUndoAddToDictionary.label;"
                accesskey="&spellUndoAddToDictionary.accesskey;"
                oncommand="InlineSpellCheckerUI.undoAddToDictionary();" />
      <menuseparator id="spell-suggestions-separator"/>
      <menuitem id="context-openlinkincurrent"
                label="&openLinkCmdInCurrent.label;"
+1 −0
Original line number Diff line number Diff line
@@ -337,6 +337,7 @@ nsContextMenu.prototype = {
            .setAttribute("checked", canSpell && InlineSpellCheckerUI.enabled);

    this.showItem("spell-add-to-dictionary", onMisspelling);
    this.showItem("spell-undo-add-to-dictionary", InlineSpellCheckerUI.canUndo());

    // suggestion list
    this.showItem("spell-suggestions-separator", onMisspelling);
+32 −7
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ Browser context menu tests.
/** Test for Login Manager: multiple login autocomplete. **/

netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm");

const Cc = Components.classes;
const Ci = Components.interfaces;
@@ -514,12 +515,36 @@ function runTest(testNum) {
                               "---",                          null,
                               "spell-add-dictionaries",       true], null,
                         ].concat(inspectItems));

        contextMenu.ownerDocument.getElementById("spell-add-to-dictionary").doCommand(); // Add to dictionary
        closeContextMenu();
        openContextMenuFor(contenteditable); // Invoke context menu for next test.
        openContextMenuFor(textarea, false, true); // Invoke context menu for next test.
        break;
    
    case 15:    
        // Context menu for textarea after a word has been added
        // to the dictionary
        checkContextMenu(["spell-undo-add-to-dictionary", true,
                          "context-undo",        false,
                          "---",                 null,
                          "context-cut",         false,
                          "context-copy",        false,
                          "context-paste",       null, // ignore clipboard state
                          "context-delete",      false,
                          "---",                 null,
                          "context-selectall",   true,
                          "---",                 null,
                          "spell-check-enabled", true,
                          "spell-dictionaries",  true,
                              ["spell-check-dictionary-en-US", true,
                               "---",                          null,
                               "spell-add-dictionaries",       true], null,
                         ].concat(inspectItems));
        contextMenu.ownerDocument.getElementById("spell-undo-add-to-dictionary").doCommand(); // Undo add to dictionary
        closeContextMenu();
        openContextMenuFor(contenteditable);
        break;

    case 16:
        // Context menu for contenteditable
        checkContextMenu(["spell-no-suggestions", false,
                          "spell-add-to-dictionary", true,
@@ -544,7 +569,7 @@ function runTest(testNum) {
        openContextMenuFor(inputspell); // Invoke context menu for next test.
        break;

    case 16:
    case 17:
        // Context menu for spell-check input
        checkContextMenu(["*prodigality",        true, // spelling suggestion
                          "spell-add-to-dictionary", true,
@@ -569,13 +594,13 @@ function runTest(testNum) {
        openContextMenuFor(link); // Invoke context menu for next test.
        break;

    case 17:
    case 18:
        executeCopyCommand("cmd_copyLink", "http://mozilla.com/");
        closeContextMenu();
        openContextMenuFor(pagemenu); // Invoke context menu for next test.
        break;

    case 18:
    case 19:
        // Context menu for element with assigned content context menu
        checkContextMenu(["+Plain item",          {type: "", icon: "", checked: false, disabled: false},
                          "+Disabled item",       {type: "", icon: "", checked: false, disabled: true},
@@ -618,7 +643,7 @@ function runTest(testNum) {
        openContextMenuFor(pagemenu, true); // Invoke context menu for next test.
        break;

    case 19:
    case 20:
        // Context menu for element with assigned content context menu
        // The shift key should bypass content context menu processing
        checkContextMenu(["context-back",         false,
+2 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ interface nsISelection;
interface nsIEditor;
interface nsIEditorSpellCheck;

[scriptable, uuid(f456dda1-965d-470c-8c55-e51b38e45212)]
[scriptable, uuid(df635540-d073-47b8-8678-18776130691d)]

interface nsIInlineSpellChecker : nsISupports
{
@@ -68,6 +68,7 @@ interface nsIInlineSpellChecker : nsISupports
  nsIDOMRange getMisspelledWord(in nsIDOMNode aNode, in long aOffset);
  void replaceWord(in nsIDOMNode aNode, in long aOffset, in AString aNewword);
  void addWordToDictionary(in AString aWord);
  void removeWordFromDictionary(in AString aWord);
  
  void ignoreWord(in AString aWord);
  void ignoreWords([array, size_is(aCount)] in wstring aWordsToIgnore, in unsigned long aCount);
+18 −0
Original line number Diff line number Diff line
@@ -869,6 +869,24 @@ mozInlineSpellChecker::AddWordToDictionary(const nsAString &word)
  return ScheduleSpellCheck(status);
}

//  mozInlineSpellChecker::RemoveWordFromDictionary

NS_IMETHODIMP
mozInlineSpellChecker::RemoveWordFromDictionary(const nsAString &word)
{
  NS_ENSURE_TRUE(mSpellCheck, NS_ERROR_NOT_INITIALIZED);

  nsAutoString wordstr(word);
  nsresult rv = mSpellCheck->RemoveWordFromDictionary(wordstr.get());
  NS_ENSURE_SUCCESS(rv, rv); 
  
  mozInlineSpellStatus status(this);
  nsCOMPtr<nsIRange> range = do_QueryInterface(NULL); // Check everything
  rv = status.InitForRange(range);
  NS_ENSURE_SUCCESS(rv, rv);
  return ScheduleSpellCheck(status);
}

// mozInlineSpellChecker::IgnoreWord

NS_IMETHODIMP
Loading