diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index 358aa26cc45..8b632f425c5 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -4249,6 +4249,7 @@ function nsContextMenu( xulMenu ) { this.isContentSelected = false; this.inDirList = false; this.shouldDisplay = true; + this.isDesignMode = false; // Initialize new menu. this.initMenu( xulMenu ); @@ -4437,7 +4438,7 @@ nsContextMenu.prototype = { this.showItem( "context-paste", this.onTextInput ); this.showItem( "context-delete", this.onTextInput ); this.showItem( "context-sep-paste", this.onTextInput ); - this.showItem( "context-selectall", !( this.onLink || this.onImage ) ); + this.showItem( "context-selectall", !( this.onLink || this.onImage ) || this.isDesignMode ); this.showItem( "context-sep-selectall", this.isContentSelected ); // XXX dr @@ -4524,14 +4525,14 @@ nsContextMenu.prototype = { this.onTextInput = this.isTargetATextBox(this.target); // allow spellchecking UI on all writable text boxes except passwords if (this.onTextInput && ! this.target.readOnly && this.target.type != "password") { - InlineSpellCheckerUI.init(this.target); + InlineSpellCheckerUI.init(this.target.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor); InlineSpellCheckerUI.initFromEvent(rangeParent, rangeOffset); } this.onKeywordField = this.isTargetAKeywordField(this.target); } else if ( this.target instanceof HTMLTextAreaElement ) { this.onTextInput = true; if (! this.target.readOnly) { - InlineSpellCheckerUI.init(this.target); + InlineSpellCheckerUI.init(this.target.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor); InlineSpellCheckerUI.initFromEvent(rangeParent, rangeOffset); } } else if ( this.target instanceof HTMLHtmlElement ) { @@ -4669,6 +4670,30 @@ nsContextMenu.prototype = { this.inFrame = true; } + // if the document is editable, show context menu like in text inputs + var win = this.target.ownerDocument.defaultView; + if (win) { + var editingSession = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIWebNavigation) + .QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIEditingSession); + if (editingSession.windowIsEditable(win)) { + this.onTextInput = true; + this.onKeywordField = false; + this.onImage = false; + this.onLoadedImage = false; + this.onMetaDataItem = false; + this.onMathML = false; + this.inFrame = false; + this.hasBGImage = false; + this.isDesignMode = true; + InlineSpellCheckerUI.init(editingSession.getEditorForWindow(win)); + var canSpell = InlineSpellCheckerUI.canSpellCheck; + InlineSpellCheckerUI.initFromEvent(rangeParent, rangeOffset); + this.showItem("spell-check-enabled", canSpell); + this.showItem("spell-separator", canSpell); + } + } }, // Returns the computed style attribute for the given element. getComputedStyle: function( elem, prop ) { diff --git a/mozilla/toolkit/content/inlineSpellCheckUI.js b/mozilla/toolkit/content/inlineSpellCheckUI.js index d48f43790ca..b4fe8159481 100644 --- a/mozilla/toolkit/content/inlineSpellCheckUI.js +++ b/mozilla/toolkit/content/inlineSpellCheckUI.js @@ -48,11 +48,11 @@ var InlineSpellCheckerUI = { mLanguageBundle: null, // language names mRegionBundle: null, // region names - // Call this function to initialize for a given edit element - init: function(inputElt) + // Call this function to initialize for a given editor + init: function(aEditor) { this.uninit(); - this.mEditor = inputElt.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor; + this.mEditor = aEditor; try { this.mInlineSpellChecker = this.mEditor.getInlineSpellChecker(true); // note: this might have been NULL if there is no chance we can spellcheck diff --git a/mozilla/toolkit/content/widgets/textbox.xml b/mozilla/toolkit/content/widgets/textbox.xml index 3e810e424f4..2ad392d1e91 100644 --- a/mozilla/toolkit/content/widgets/textbox.xml +++ b/mozilla/toolkit/content/widgets/textbox.xml @@ -102,7 +102,7 @@ loader.loadSubScript("chrome://global/content/inlineSpellCheckUI.js", this); // watch out - that could have failed if (this.InlineSpellCheckerUI) - this.InlineSpellCheckerUI.init(this.inputField); + this.InlineSpellCheckerUI.init(this.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor); } return this.InlineSpellCheckerUI; ]]>