Bug 41921 - Coalesce text nodes when foster parenting
Summary: Coalesce text nodes when foster parenting
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks: 41123
  Show dependency treegraph
 
Reported: 2010-07-08 17:36 PDT by Adam Barth
Modified: 2010-07-23 22:24 PDT (History)
2 users (show)

See Also:


Attachments
Patch (11.00 KB, patch)
2010-07-08 17:41 PDT, Adam Barth
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2010-07-08 17:36:19 PDT
Coalesce text nodes when foster parenting
Comment 1 Adam Barth 2010-07-08 17:41:46 PDT
Created attachment 60989 [details]
Patch
Comment 2 Eric Seidel (no email) 2010-07-08 19:12:12 PDT
This feels wrong. Why is the if inside attach at site instead of Just having two separate methods?
Comment 3 Adam Barth 2010-07-08 19:18:50 PDT
Yeah, there's something wrong in the layering.  I'm inclined to land this patch and then think the whole class through in another patch once we see the foreign content part.  The class isn't that complicated.
Comment 4 Darin Adler 2010-07-08 23:37:52 PDT
Comment on attachment 60989 [details]
Patch

Drive-by comments:

> +        // FIXME: We need an insertElement which does not send mutation events.

One way to deal with this is to create a function that promises it won't send mutation events, even if it can't yet deliver on that promise. Then you only need the FIXME in one place.

Generally speaking we should probably have parents in the HTML parser be Element* instead of Node*. We should change things around to make that happen because Element has more efficient versions of some of the functions that you can call on Node in a less efficient fashion.

I might get a chance to review this later, although I assume Eric will beat me to it.
Comment 5 Adam Barth 2010-07-08 23:41:58 PDT
> One way to deal with this is to create a function that promises it won't send mutation events, even if it can't yet deliver on that promise. Then you only need the FIXME in one place.

That's a good idea.

> Generally speaking we should probably have parents in the HTML parser be Element* instead of Node*. We should change things around to make that happen because Element has more efficient versions of some of the functions that you can call on Node in a less efficient fashion.

We can work towards that.  We need to use nodes sometimes because we need to attach things to the document occasionally.

> I might get a chance to review this later, although I assume Eric will beat me to it.

You're welcome to review it, but this patch is ugly.  We're learning more about what this class needs to do, and it's internal structure hasn't quite caught up yet.  I'll try to make the class beautiful before we're done.
Comment 6 Eric Seidel (no email) 2010-07-09 02:49:33 PDT
Comment on attachment 60989 [details]
Patch

Sigh.  We need to fix this.  But I agree, it is clearer to land it first and then work from the fixed version towards a saner wholistic design.
Comment 7 Adam Barth 2010-07-09 02:58:11 PDT
Committed r62924: <http://trac.webkit.org/changeset/62924>
Comment 8 Darin Adler 2010-07-09 08:16:46 PDT
(In reply to comment #5)
> > Generally speaking we should probably have parents in the HTML parser be Element* instead of Node*. We should change things around to make that happen because Element has more efficient versions of some of the functions that you can call on Node in a less efficient fashion.
> 
> We can work towards that.  We need to use nodes sometimes because we need to attach things to the document occasionally.

If it  can be a document, then we can still at least use ContainerNode*.
Comment 9 Daniel Bates 2010-07-23 22:24:11 PDT
Comment on attachment 60989 [details]
Patch

Clearing commit-queue flag to get this out of the commit-queue.