Closed
Bug 135922
Opened 23 years ago
Closed 22 years ago
[FIXr]Range.insertNode doesn't split textnodes
Categories
(Core :: DOM: Core & HTML, defect, P1)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla1.4beta
People
(Reporter: peterv, Assigned: bzbarsky)
References
()
Details
(Keywords: dom2)
Attachments
(3 files, 1 obsolete file)
(deleted),
text/html
|
Details | |
(deleted),
text/html
|
Details | |
(deleted),
patch
|
caillon
:
review+
peterv
:
superreview+
asa
:
approval1.4b+
|
Details | Diff | Splinter Review |
The spec says "If the start boundary point of the Range is in a Text node, the
insertNode operation splits the Text node at the boundary point." Mozilla
doesn't handle this correctly, we don't split the text node but instead try to
append the new node to the text node, which of course always fails.
Reporter | ||
Comment 1•23 years ago
|
||
Comment 2•22 years ago
|
||
Unfortunately, the problem is not just that the text node is not split, but that
nsRange::insertNode() is broken in just about every conceivable way.
http://lxr.mozilla.org/seamonkey/source/content/base/src/nsRange.cpp#2059
2073 if( (nsIDOMNode::CDATA_SECTION_NODE == tNodeType) ||
2074 (nsIDOMNode::TEXT_NODE == tNodeType) )
Should be checking type of tStartContainer, not type of node to be inserted.
2081 return tSCParentNode->InsertBefore(aN, tSCParentNode,
getter_AddRefs(tResultNode));
1) Need to splitText if necessary (see SurroundContents for details)
2) Second arg should be tStartContainer, so we don't try to insert before self.
2092 if(tStartOffset == (PRInt32)tChildListLength)
Comparison shouldn't be necessary. tChildList->Item() should return null if
offset greater than tChildListLength, and tStartContainer->InsertBefore reverts
to append if tChildNode is null.
Comment 3•22 years ago
|
||
Here's another test case for range.insertNode()
Assignee | ||
Comment 4•22 years ago
|
||
Assignee | ||
Comment 5•22 years ago
|
||
Attachment #78023 -
Attachment is obsolete: true
Updated•22 years ago
|
Attachment #121596 -
Flags: review?(caillon)
Assignee | ||
Comment 6•22 years ago
|
||
taking
Assignee: kin → bzbarsky
Blocks: 104383
Status: ASSIGNED → NEW
Priority: P3 → P1
Summary: Range.insertNode doesn't split textnodes → [FIX]Range.insertNode doesn't split textnodes
Target Milestone: Future → mozilla1.4beta
Assignee | ||
Updated•22 years ago
|
Attachment #121596 -
Flags: superreview?(peterv)
Comment 7•22 years ago
|
||
Comment on attachment 121596 [details] [diff] [review]
Patch based on Nathan's suggestion
Yay, nsRange!
Attachment #121596 -
Flags: review?(caillon) → review+
Reporter | ||
Updated•22 years ago
|
Attachment #121596 -
Flags: superreview?(peterv) → superreview+
Assignee | ||
Updated•22 years ago
|
Summary: [FIX]Range.insertNode doesn't split textnodes → [FIXr]Range.insertNode doesn't split textnodes
Assignee | ||
Comment 8•22 years ago
|
||
Comment on attachment 121596 [details] [diff] [review]
Patch based on Nathan's suggestion
Requesting 1.4b approval; this is a simple change to bring us in line with the
spec and prevent content disappearing completely when insertNode is used on
ranges.
Attachment #121596 -
Flags: approval1.4b?
Comment 9•22 years ago
|
||
Comment on attachment 121596 [details] [diff] [review]
Patch based on Nathan's suggestion
a=asa (on behalf of drivers) for checkin to 1.4b
Attachment #121596 -
Flags: approval1.4b? → approval1.4b+
Assignee | ||
Comment 10•22 years ago
|
||
Fixed.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Updated•12 years ago
|
Component: DOM: Traversal-Range → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•