[webkit-dev] Why so many text nodes in the DOM? (especially ones with just whitespace)

Gustavo Sverzut Barbieri barbieri at profusion.mobi
Thu Jun 17 14:35:37 PDT 2010

On Thu, Jun 17, 2010 at 6:34 PM, David Hyatt <hyatt at apple.com> wrote:
> On Jun 17, 2010, at 4:24 PM, Matt 'Murph' Finnicum wrote:
> On Thu, Jun 17, 2010 at 4:19 PM, David Hyatt <hyatt at apple.com> wrote:
>> On Jun 17, 2010, at 2:45 PM, Gustavo Sverzut Barbieri wrote:
>> > David, it's bit more than annoying, it's fragmenting memory for no
>> > good. In the long run on systems will small memory it does make a
>> > difference :-/
>> >
>> > I'd like to see some option, maybe compile-time, to strip these
>> > useless whitespaces.
>> >
>> As Alexey points out, this is a compatibility issue though.  People write
>> code assuming the whitespace nodes are there.  If you remove them, you'll
>> see Web site breakage.
>> dave
>> (hyatt at apple.com)
> Do people write code assuming the content of the whitespace nodes? That
> seems very unlikely to me. If not, we could collapse them and be much more
> efficient about things (such as a simple flag in their parent node that
> represents their existence)
> They absolutely do.  Way back in the original KHTML, these nodes were
> omitted from the DOM, and we had compatibility bugs in WebCore caused by the
> absence of those nodes.  One of the earliest bits of work I did on WebCore
> (8 yrs ago) was to add those whitespace nodes back into the DOM.
> The other issue you run into is that at any time someone can change the
> style of an element to have white-space: pre in CSS.  If you don't retain
> information about the white-space, then you'll have a correctness issue when
> the white-space style changes and suddenly requires you to preserve the
> spaces.

Definitely you do have more domain knowledge than I do, so ignore what
I've said :-D

Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
MSN: barbieri at gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

More information about the webkit-dev mailing list