Closed Bug 216317 Opened 21 years ago Closed 20 years ago

usecss as parameter for execCommand results in an exception

Categories

(Core :: DOM: Editor, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: smacvicar, Assigned: Brade)

References

()

Details

(Whiteboard: midas)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5a) Gecko/20030728 Mozilla Firebird/0.6.1

When usecss is called an execption is generated. This only happens when a
certain order is used but the result is that css can't be disabled without some
side effects.

Reproducible: Always

Steps to Reproduce:
1. Visit URL above
2. Run any if the functions
Actual Results:  
In all cases the use of the useCSS feature fails to run or uses CSS for formatting.

Expected Results:  
Use the proper tags instead of css for formatting
Severity: blocker → major
Some debugging has identified the source of the execption as line 250 of
mozilla/editor/composer/src/nsComposerDocumentCommands.cpp within
nsSetDocumentStateCommand::DoCommandParams

which reads
248   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
249   if (!editor) 
250     return NS_ERROR_INVALID_ARG;

Lack of knowledge about the mozilla core prevents me from providing any further
debug information.
-->brade

btw, the useCSS command at this location appears to work correctly from 1.4 branch:
   http://www.mozilla.org/editor/midasdemo/

I'm guessing that the useCSS command is being called too early before the editor
has been created; perhaps a 1 or 2-second timer would work around the timing issue?
Assignee: mozeditor → brade
Whiteboard: midas
What you explained appears valid, the iframe isn't finished loading.

changing
htmlbox.write("<html><head></head><body>" +
document.getElementById("textbox").value + "</body></html>");

to

htmlbox.write("<html><head></head><body onload=\"document.execCommand('useCSS',
false, false);\">" + document.getElementById("textbox").value + "</body></html>");

meaning that usecss shouldn't be called until after the iframe has loaded, this
prevents the exception from appearing but css is still used in formatting.

There doesn't seem to be a way to turn css off when images are involved in the
document you are editing and css has to be off before the user attempts to edit
the document.

Actually on further review it looks like the onload event isn't called.
Ok there appears to be a documentation issue as well.

useCSS you'd expect true as the aoptional arguement would force the use of CSS.
incorrect apparently true turns off CSS and false turns it on?

Turning this to true appears to fix our problem but some documentation could
possibly be made regarding it?
Scott--can you try this with a newer build?  Is it still a problem?  useCSS set
to true should give css output.  useCSS set to false should give standard html
output (such as <b> for bold).

If it is a problem, could you attach a testcase (for comment 4)?

I know at one point there was a problem where you could get into the state where
the editor was toggling backwards.  I believe that was fixed (but perhaps not).
For me it seems to work now?
Yeah it was broken in the 1.6a release which was Gecko/20031030 but appears to
be fixed in 1.6 final.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.