Dave Hyatt (an Apple programmer) is writing up some docs on WebCore, Apple's port of KHTML to Mac OS X. In part of his docs (An Overview of WebCore), I notice how he describes how layout and painting is done in WebCore...
This is what he had to say:
"Once the render tree has been built, it must receive a layout. RenderObjects implement a layout method that is used to determine the position and size of the RenderObject boxes on screen. Layout is a recursive function, so calling layout on the root RenderObject results in the entire rendering tree being flowed.
Finally once all of the rendering objects have been placed at the correct positions, they are painted. All RenderObjects implement paint methods. Painting is also recursive. "
The way he describes it makes me really happy, since the layout engine I wrote for work (produces pdf's) works the same way. My RenderObject is called a MElement, and my "paint" method is called "draw". My "layout" method is actually called "layout". Since I mostly designed the thing in the dark with no real knowledge of wtf I was doing, I now feel totally justified in the path I took. Sweet... Took me a couple of rewrites to get to that model, but I've always felt that was the right way to do it.