Closed Bug 14430 Opened 26 years ago Closed 26 years ago

[blocker] IsEmptyNode misbehaving on <HR> (was: Making italic clobbers <HR>)

Categories

(Core :: DOM: Editor, defect, P1)

All
Mac System 8.5
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: sfraser_bugs, Assigned: mozeditor)

References

Details

Select across the <HR> in the test page, from withing the paragraph before to in the para after, and hit the Italic button. The <HR> disappears.
Depends on: 14473
Whiteboard: can't work on this bug until bug 14473 is fixed
Status: NEW → ASSIGNED
Whiteboard: can't work on this bug until bug 14473 is fixed
Assignee: buster → jfrancis
Severity: normal → blocker
Status: ASSIGNED → NEW
Priority: P3 → P1
Target Milestone: M11
Here's the root cause: nsHTMLEditRules::CleanUpSelection() scans the selection doing garbage collection on empty nodes that result from an edit operation. It uses nsHTMLEditRules::IsEmptyNode() to determine if a node is garbage or content. Unfortunately, IsEmptyNode() returns true on any node that has no children, such as <HR>. I'm guessing this wouldn't work for <OBJECT> or a bunch of other legit tags either. This really needs to get fixed! This should get fixed right away, it'll cause a lot of heartache in a lot of places. Note to Joe: you won't be able to test this particular case without code sitting in my tree, to be checked in today if at all possible. I'll include the (very incomplete) diff in case you want to get to it before I can check in: Index: base/nsHTMLEditor.cpp =================================================================== RCS file: /cvsroot/mozilla/editor/base/nsHTMLEditor.cpp,v retrieving revision 1.155 diff -r1.155 nsHTMLEditor.cpp 5421a5422,5430 > NS_IMETHODIMP nsHTMLEditor::IsLeafThatTakesInlineStyle(const nsString *aTag, > PRBool &aResult) > { > if (!aTag) { return NS_ERROR_NULL_POINTER; } > > aResult = (PRBool)((PR_FALSE==aTag->Equals("br")) && > (PR_FALSE==aTag->Equals("hr")) ); > return NS_OK; > } 5524,5525c5533,5537 < if (tag != "br") // skip <BR>, even though it's a leaf < { // only want to wrap the text node in a new style node if it doesn 't already have that style --- > PRBool processLeaf; > IsLeafThatTakesInlineStyle(&tag, processLeaf); > if (processLeaf) // skip leaf tags that don't take inline style > { > // only want to wrap the node in a new style node if it doesn't al ready have that style Index: base/nsHTMLEditor.h =================================================================== RCS file: /cvsroot/mozilla/editor/base/nsHTMLEditor.h,v retrieving revision 1.71 diff -r1.71 nsHTMLEditor.h 294a295,296 > NS_IMETHOD IsLeafThatTakesInlineStyle(const nsString *aTag, PRBool &aResult) ; >
Summary: Making italic clobbers <HR> → [blocker] IsEmptyNode misbehaving on <HR> (was: Making italic clobbers <HR>)
Whiteboard: need permission to check in my portion of this fix
Status: NEW → ASSIGNED
accepting bug...
Target Milestone: M11 → M12
can slip to M12.
Whiteboard: need permission to check in my portion of this fix
ok, joe, my portion of this is in.
this should be a pretty easy fix. I only want to nuke empty container nodes. I can't remember if our current level of dtd access lets us ask that question, but if it doesn't we can just use a temporary utility function with a hardcoded list of container nodes for now.
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
fixed a while ago; forgot to mark
Status: RESOLVED → VERIFIED
verified in 11/4 build.
You need to log in before you can comment on or make changes to this bug.