Closed
Bug 16082
Opened 27 years ago
Closed 27 years ago
assert typing character after br
Categories
(Core :: DOM: Editor, defect, P3)
Tracking
()
VERIFIED
FIXED
M14
People
(Reporter: buster, Assigned: mozeditor)
References
(
URL
)
Details
open the editor on an empty document (open any doc, control-a, del should do it)
type 'a'
type Enter twice
use the mouse to position the caret on the first blank line (the second line in
the document)
type 'b'
assert.
The problem seems to be in nsHTMLEditRules::WillInsertText().
We get into this code with selNode holding a text node, which isn't a legal
parent of a div. selNode is originally the body, then gets set to a text node
in a call to mEditor->GetStartNodeAndOffset(); after having changed the
selection in the block that calls GetNextHTMLNode().
// if we are directly in a body or (non-moz) div, create a moz-div.
// Also creat one if we detected a prior moz br (see above).
res = mEditor->GetStartNodeAndOffset(aSelection, &selNode, &selOffset);
if (NS_FAILED(res)) return res;
if (needMozDiv || IsBody(selNode) || IsNormalDiv(selNode))
{
// wrap things up in a moz-div
nsCOMPtr<nsIDOMNode> mozDiv;
res = CreateMozDiv(selNode, selOffset, &mozDiv); <-- ouch!
The assert is actually in nsEditor::Do(), which simply checks the result of all
operations.
somewhere, should we be calling nsEditor::CanContainTag() to catch things like
this?
I'm against calling nsEditor::CanContainTag() in
nsEditor::CreateTxnForCreateElement because it should be possible to for an
editor to create illegal intermediate states in the DOM tree, as allowed by the
DOM.
I think this same argument applies to nsEditor::CreateNode().
Perhaps what we should do is pass in an optional argument to CreateNode() so
the caller can tell us whether to verify or not. We would call
nsEditor::CanContainTag() by default, but let the user pass in
aValidate=PR_FALSE. Something like:
NS_IMETHODIMP nsEditor::CreateNode(const nsString& aTag,
nsIDOMNode * aParent,
PRInt32 aPosition,
nsIDOMNode ** aNewNode,
PRBool aValidate=PR_TRUE)
{
// normal precondition checks, currently missing!
if (aValidate && PR_FALSE==CanContainNode(aParent, aTag))
return NS_ERROR_SOME_ERROR;
// else do normal processing
| Assignee | ||
Updated•27 years ago
|
Status: NEW → ASSIGNED
| Assignee | ||
Comment 2•27 years ago
|
||
buster's original comments make me think he is misunderstanding the code - the
text node is being wrapped in a div, not vica versa. i already know that there
are warts in the mozdiv rules, especially when typing next to <br>s. I'll look
into this.
| Assignee | ||
Comment 3•27 years ago
|
||
accepting/m11
Updated•27 years ago
|
Target Milestone: M11 → M14
| Assignee | ||
Updated•27 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 27 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 4•27 years ago
|
||
fixed
You need to log in
before you can comment on or make changes to this bug.
Description
•