Bug 439965. Make sure to flush frames on our parent before checking whether editing is on, since editing depends on the presshell. r+sr=peterv

This commit is contained in:
Boris Zbarsky 2008-10-29 13:12:24 -07:00
parent fdca08cb77
commit 21e86516a4
5 changed files with 68 additions and 8 deletions

View File

@ -3794,7 +3794,7 @@ nsHTMLDocument::ExecCommand(const nsAString & commandID,
*_retval = PR_FALSE;
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
// if they are requesting UI from us, let's fail since we have no UI
@ -3869,7 +3869,7 @@ nsHTMLDocument::ExecCommandShowHelp(const nsAString & commandID,
*_retval = PR_FALSE;
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
return NS_ERROR_NOT_IMPLEMENTED;
@ -3884,7 +3884,7 @@ nsHTMLDocument::QueryCommandEnabled(const nsAString & commandID,
*_retval = PR_FALSE;
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
// get command manager and dispatch command to our window if it's acceptable
@ -3913,7 +3913,7 @@ nsHTMLDocument::QueryCommandIndeterm(const nsAString & commandID,
*_retval = PR_FALSE;
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
// get command manager and dispatch command to our window if it's acceptable
@ -3955,7 +3955,7 @@ nsHTMLDocument::QueryCommandState(const nsAString & commandID, PRBool *_retval)
*_retval = PR_FALSE;
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
// get command manager and dispatch command to our window if it's acceptable
@ -4017,7 +4017,7 @@ nsHTMLDocument::QueryCommandSupported(const nsAString & commandID,
*_retval = PR_FALSE;
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
return NS_ERROR_NOT_IMPLEMENTED;
@ -4031,7 +4031,7 @@ nsHTMLDocument::QueryCommandText(const nsAString & commandID,
_retval.SetLength(0);
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
return NS_ERROR_NOT_IMPLEMENTED;
@ -4045,7 +4045,7 @@ nsHTMLDocument::QueryCommandValue(const nsAString & commandID,
_retval.SetLength(0);
// if editing is not on, bail
if (!IsEditingOn())
if (!IsEditingOnAfterFlush())
return NS_ERROR_FAILURE;
// get command manager and dispatch command to our window if it's acceptable
@ -4139,3 +4139,16 @@ nsHTMLDocument::Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const
return CallQueryInterface(clone.get(), aResult);
}
PRBool
nsHTMLDocument::IsEditingOnAfterFlush()
{
nsIDocument* doc = GetParentDocument();
if (doc) {
// Make sure frames are up to date, since that can affect whether
// we're editable.
doc->FlushPendingNotifications(Flush_Frames);
}
return IsEditingOn();
}

View File

@ -262,6 +262,11 @@ protected:
nsresult CreateAndAddWyciwygChannel(void);
nsresult RemoveWyciwygChannel(void);
/**
* Like IsEditingOn(), but will flush as needed first.
*/
PRBool IsEditingOnAfterFlush();
void *GenerateParserKey(void);
virtual PRInt32 GetDefaultNamespaceID() const

View File

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<body>
<script>
function doe(aEl) {
var doc = aEl.contentDocument;
doc.designMode = 'on';
try {
doc.execCommand("insertHTML",false,'some text');
} catch(e) {
document.getElementById('result').innerHTML = e;
}
}
</script>
<iframe onload="doe(this)"></iframe><br>
<pre id="result" style="background-color: red; width: 300px; white-space: -moz-pre-wrap;"></pre>
</body>
</html>

View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<body>
<script>
function doe(aEl) {
aEl.style.display = '';
var doc = aEl.contentDocument;
doc.designMode = 'on';
try {
doc.execCommand("insertHTML",false,'some text');
} catch(e) {
document.getElementById('result').innerHTML = e;
}
}
</script>
<iframe onload="doe(this)" style="display:none"></iframe><br>
<pre id="result" style="background-color: red; width: 300px; white-space: -moz-pre-wrap;"></pre>
</body>
</html>

View File

@ -1,4 +1,5 @@
== bug453105.html bug453105-ref.html
== optiontext.html optiontext-ref.html
== bug456008.xhtml bug456008-ref.html
== bug439965.html bug439965-ref.html
== bug427779.xml bug427779-ref.xml