Chromium Code Reviews
        
  Description*** FOR PROTOTYPE PURPOSES ONLY! NOT INTENDED FOR COMMIT! ***
Non-recursive layout for the RenderBlockFlow class and all of its subclasses
Non-recursive layout for the RenderBlockFlow class and all of its subclasses.  This
is my first attempt at a prototype for how we can incrementally change over the various
render tree classes to use non-recursive layout both for tree traversal and for
multiple passes.
The key to this prototype is found in the RenderObject::nextForLayout method which
introduces a non-recursive algorithm for traversing the render tree in both pre and
post order.  It also takes care of switching between recursive and non-recursive
tree traversal for those nodes that do not yet support non-recursive layout.  I
developed this algorithm by creating a toy model of the render tree and its layout
methods.
A couple of big architectural changes come to light with this prototype:
1) It becomes necessary to split up the current ::layout* methods into pre and post
order methods.  Currently, most nodes do some layout work *before* visiting children
and then some more work *after* visiting children.  This is accomplished with recursion
by recursing into children in the middle of the current ::layout methods and holding
state on the stack.  With non-recursive traversal we have to explicitly visit each node
in pre-order and then in post-order.
NOTE: One potentially good part of this split up into pre/post part is perhaps
a performance gain to be had in the case of multiple passes.  Right now, I believe
multiple passes is unnecessarily executing code paths that are unnecessary and
we might be able to reduce this by splitting up the layout method with more granularity.
2) We need to store all the state that was previously held on the stack frame in
another fashion.  This patch just does the dumb thing and adds that state as member
variables to the RenderObject subclass.  Obviously, this is less than adequate and
we'll need to find a better way to allocate and maintain this state and the lifetime
thereof.  I've left that work until we can talk it over how best to do it.  The first
thought that comes to mind is using the current LayoutState, but we have to be careful
not to make this more complicated than necessary as LayoutState currently holds state
that is more or less used by all the render tree subclasses.
3) One obvious advantage of using non-recursive layout is the fact that we can be explicit
where we put the tree traversal.  Right now, the tree traversal is hidden deep within
the layout methods because of #1.  Although I haven't had time to do it yet, this patch
hopefully makes it clear that this traveral can be moved to the head of the layout method.
I've added various comments in the code where I think it helps to make clear what
is going on.  To be clear, there is plenty more work to be done.  Right now this patch
passes all layout 10,000+ fast tests when using the default recursive method, but
still fails on roughly 500 tests when switched to non-recursive.
Hopefully, this is enough to see where this is headed and to evaluate before going
further.
*** FOR PROTOTYPE PURPOSES ONLY! NOT INTENDED FOR COMMIT! ***
BUG=
   
  Patch Set 1 #
      Total comments: 9
      
     
  
  
 Messages
    Total messages: 5 (0 generated)
     
  
  
       | 
    ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||