eric at webkit.org
Thu Sep 9 10:24:33 PDT 2010
On Thu, Sep 9, 2010 at 9:45 AM, David Hyatt <hyatt at apple.com> wrote:
> On Sep 9, 2010, at 2:00 AM, Eric Seidel wrote:
>> Instead, we could change all elements to mark themselves (and their
>> parents) as needing style recalc during insertedIntoDocument(),
>> effectively "attaching/lazyAttaching".
> lazyAttach is poorly implemented right now, since it is relying on style recalculation to trigger the attachment when it should have used a new timer. Right now because it is latching onto the style recalc timer and tree it is wasting time doing recalc styles on all of the ancestors of any elements that need attaching. That's just bad.
I'm not sure a new timer is right. I don't think we need/want a timer
at all. Probably just a flag on document which says "something needs
an attach, do a full tree walk". Which we check during style resolve
and do a tree walk. We don't want to attach any more eagerly than
necessary. We have to be attached to resolve style, but not before.
I'm not sure how that's necessarily better than being part of the
style recalc. But I don't feel like an expert enough here to know.
> This means the normal attach() process performs better (and is presumably still used by the parser).
attach() is used in many places, but not all. lazyAttach() is used by
the Adoption Agency Algorithm in the parser as well as ContainerNode's
insertBefore, appendChild and replaceChild.
> We should fix lazyAttach to use its own timer and tree walk independent of recalcStyle that just calls attach() instead on children that need it.
Please explain more. I'm not sure how that is better than marking
parents as "childNeedsStyleRecalc" which is what we do now. As far as
I know that doesn't cause the parents to recalc. In order to attach
we need a style calculation. I agree, it's possible to end up walking
the rendering tree too often if we're checking if it needs style
recalc after inserting every element anyway.
My understanding is that lazyAttach was written to make Acid3 faster
by avoiding the malloc associated with attach()/createRenderer() in
the cases where elements never end up rendered. It also helps with
the Adoption Agency Algorithm as elements get inserted and then moved
again and don't necessarily end up rendered in their original
More information about the webkit-dev