6 different renderer classes have code that does: view()->pushLayoutState(this,...) ... view()->popLayoutState(); or, in some cases: if (some condition) view()->pushLayoutState(this,...) else view()->disableLayoutState(); ... if (some condition which we hope is the same as before) view()->popLayoutState(); else view()->enableLayoutState(); There is only one place where we assert that the push/pops matched, and that's at the outer level. This is crying out for a stack-based class.
Created attachment 24961 [details] Patch
LayoutStateMaintainer could use a better name. LayoutStateStack (but it's not actually the stack)?
Comment on attachment 24961 [details] Patch + RenderView* m_view; + + bool m_push; + bool m_popped; There should be a single space between type and variable name. I like the idea of a stack-based object, but I think it would be better to go all the way and instead of explicit pop (and push) add scope around where you want the state pushed/disabled. I'm interested in Hyatt's opinion as well :-)
Created attachment 24963 [details] Patch with explicit push(), allowing use in RenderTableSection
Created attachment 24964 [details] Patch with scope, rather than explicit pop()
The second patch gets a bit messy; have to move local variables outside the scope. I prefer the explicit pop() version.
Note that second patch is with --ignore-whitespace, to avoid showing all the indentation.
Comment on attachment 24964 [details] Patch with scope, rather than explicit pop() hyatt doesn't like this one.
Comment on attachment 24963 [details] Patch with explicit push(), allowing use in RenderTableSection > +}; > + > + > } // namespace WebCore > > #endif // RenderView_h Extra newline up there. r=me
Committed r38227 M WebCore/rendering/RenderFlexibleBox.cpp M WebCore/rendering/RenderTableRow.cpp M WebCore/rendering/RenderBlock.cpp M WebCore/rendering/RenderTableSection.cpp M WebCore/rendering/RenderContainer.cpp M WebCore/rendering/RenderTable.cpp M WebCore/rendering/RenderView.h M WebCore/ChangeLog r38227 = feaef2ebff2eea5fc2b9d46149a82e020dc88477 (trunk)