User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; nb-NO; rv:1.9) Gecko/2008051202 Firefox/3.0 Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; nb-NO; rv:1.9) Gecko/2008051202 Firefox/3.0 I'm updating my extension for Firefox 3, and I have a XUL editor, where xulEditor.contentDocument.queryCommandState('bold') now fails and gives the following error: Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLDocument.queryCommandState]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" Worked fine in Firefox 2. Can't seem to get around this. Any ideas? Reproducible: Always Steps to Reproduce: 1. Set up a XUL editor field in chrome. 2. Try to query the commandstate within the editing document using xulEditor.contentDocument.queryCommandState('bold')
I can confirm that this worked in 1.9b2pre, but does not work in latest 1.9pre
Per-Kristian - a narrowed regress range would be helpful. See if you can find the Firefox nightly that started throwing exceptions.
Thank you for the confirmation mfinkle, I'll see if I can find it.
mfinkle found out that <browser> doesn't have these problems, so a temporary workaround is to user browser instead of editor. Then in order to get <editor> stuff: var myBrowser = document.getElementById('myBrowser'); var editingSession = myBrowser.webNavigation.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIEditingSession); myBrowser.contentDocument.designMode = 'on'; var editor = editingSession.getEditorForWindow(myBrowser.contentWindow); var commandManager = myBrowser.webNavigation.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsICommandManager); var htmlEditor = editor.QueryInterface(Components.interfaces.nsIHTMLEditor); Works for now, until this bug is fixed.
For some reason the mEditingState is set to eOff when checked here: http://mxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp#4450 I'm not sure why yet.
Maybe this was caused by Bug 428844, which was checked in on 2008-04-17? That changed how we tore down the editor. The old editor is tore down before the new one is setup, maybe that's failing...
mEditingState is eOff because SetDesignMode considers setting designMode='on' to be redundant for a document that is already editable, see http://bonsai.mozilla.org/cvsblame.cgi?file=/mozilla/content/html/document/src/nsHTMLDocument.cpp&rev=3.785&mark=4139-4140#4121 Fixing this will probably require quite a bit of changes. What does using an editor element with designMode="on" give that a simple editor element or a browser element with designMode="on" doesn't? Unless there's an important advantage I don't think this is a high priority bug.
It has property commandManager, and methods getHTMLEditor and getEditor for instance. But the critical point is that the editor element simply doesn't work for what it is designed for, to edit stuff. So all extensions and such using a <editor> will not work, and break stuff when it comes down to executing commands like bold, italic, link, etc. I can't see how that can not be critical?
Executing commands like cmd_bold, ... with the commandManager is broken?
Created attachment 322786 [details] Testcase using commandManager Using the commandManager works fine for me?
Using commandManager like that works here too. But not contentDocument.execCommand (and similar calls) as it did before 2004-04-18. Quote from http://developer.mozilla.org/en/docs/XUL:editor <blockquote> Once editable, the document can have special formatting and other HTML pieces added to it using the document.execCommand method: var editor = document.getElementById("myEditor"); // toggle bold for the current selection editor.contentDocument.execCommand("bold", false, null); </blockquote> I suppse it's not only my code that will suffer from this bug.
I have a similar problem in FF3 when trying to use execCommand on an iframe editor see https://bugzilla.mozilla.org/show_bug.cgi?id=457332. This bug did not exist in FF1 or 2 and works in other browsers.
Same error with Fx 3.1 on linux. But I have fixed the problem by adding contenteditable="true" in a HTML element of the content document.
6 years ago
Created attachment 546023 [details] [diff] [review] Patch (v1) For <xul:editor>, the HTML document's mEditingState ended up being eOff, which effectively disables the execCommand API. This patch is a simple fix for that.
Comment on attachment 546023 [details] [diff] [review] Patch (v1) Review of attachment 546023 [details] [diff] [review]: -----------------------------------------------------------------
Try run for fe3b8f619f5c is complete. Detailed breakdown of the results available here: http://tbpl.mozilla.org/?tree=Try&rev=fe3b8f619f5c Results: success: 148 warnings: 13 failure: 2 Total buildrequests: 163
This bug fix is noted here: https://developer.mozilla.org/en/Firefox_8_for_developers#XUL