I'm considering refactoring a good bit of nsHTMLReflowState (ComputeBlockBoxData, InitConstraints) plus things like nsImageFrame::GetDesiredSize that use NS_INTRINSICSIZE (which has to go away on the reflow branch) into the following method on nsIFrame:
/**
* Compute the size that a frame will occupy. Called while
* constructing the nsHTMLReflowState to be used to Reflow the frame,
* in order to fill its mComputedWidth and mComputedHeight member
* variables.
*
* The |height| member of the return value may be
* NS_UNCONSTRAINEDSIZE, but the |width| member must not be.
*
* @param aAvailWidth The available width into which the element is
* being placed (i.e., the width of its containing
* block).
* @param aMargin The sum of the left and right margins of the
* frame, including actual values resulting from
* percentages, but not including actual values
* resulting from 'auto'.
* @param aBorder The sum of the left and right border widths of the
* frame.
* @param aPadding The sum of the left and right margins of the
* frame, including actual values resulting from
* percentages.
* @param aShrinkWrap Whether the frame is in a context where
* non-replaced blocks should shrink-wrap (e.g.,
* it's floating, absolutely positioned, or
* inline-block).
*/
virtual nsSize ComputeSize(nscoord aAvailWidth, nscoord aMargin,
nscoord aBorder, nscoord aPadding,
PRBool aShrinkWrap) = 0;
Does this seem reasonable?
One thing I was considering was whether I should pass the reflow state
as a parameter or not. The advantage of doing so would be fewer
parameters (and perhaps ease of depending on additional things in the
reflow state) and perhaps the performance advantage of not re-retrieving
the style structs. However, I consider ease of adding extra
dependencies to be a significant disadvantage (it makes it harder to
enforce invariants) -- especially dependencies on nsHTMLReflowState,
which I'd like to get significantly smaller.
-David
--
L. David Baron <URL: http://dbaron.org/ >
Technical Lead, Layout & CSS, Mozilla Corporation
pgpOga594sRlT.pgp
Description: PGP signature
_______________________________________________ dev-tech-layout mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-layout

