Open Bug 653948 Opened 14 years ago Updated 3 years ago

Remove ContentInserted/ContentAppended duality

Categories

(Core :: DOM: Core & HTML, defect)

defect

Tracking

()

People

(Reporter: sicking, Unassigned)

References

Details

Can we kill the current ContentInserted/ContentAppended duality that we have? And instead have a single notification but which supports a range. Something like: ContentInserted(nsIDocument *aDocument, nsIContent* aContainer, nsIContent* aStartChild, nsIContent* aEndChild, PRInt32 aIndexInContainer) (where aIndexInContainer should eventually go away). aEndChild is the first node that is *not* newly inserted. Code that want to optimize for append operations can just check if aEndChild is false. The advantage here is two-fold. First of all all listeners would only have to handle a single notification. Second, we can likely optimize things like range-insertions in the middle of a node. The latter can happen with insertAdjecentHTML (which is likely to become more common once it becomes cross-browser) and XBL. I saw that the layout code has been moving in this direction, though I'm not sure if it takes advantage of range insertions in the middle of a node yet.
OS: Mac OS X → All
Hardware: x86 → All
See Also: → 651120
(In reply to comment #0) > I saw that the layout code has been moving in this direction, though I'm not > sure if it takes advantage of range insertions in the middle of a node yet. Layout will already convert multiple ContentInserted calls that are adjacent into a range insertion and perform it all in one batch (lazily).
Mounir said he'd take a stab at this.
Assignee: nobody → mounir.lamouri
In general, I'm fine with this. That said, there's one case where ContentAppended is faster: it knows that aContainer is non-null. Unfortunately, for insertion as document kids we'd need to pass a null aContainer to the new method (or make aContainer an nsINode and add some AsContent() in places). In the frame constructor, I wonder why ContentAppended doesn't just call ContentRangeInserted now... Timothy, was there a reason for that other than just not wanting to rejigger the code too much? Whoever works on this, I'd really appreciate a patch queue, esp if you want me to review the frame constructor changes. ;)
There were some non-trivial differences in how appends and inserts were handled.
I guess we should sort those out, then...
Component: DOM → DOM: Core & HTML

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: mounir → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.