Bug 786387 - Add comments to document the subtleties of nsFrame::Reflow and better document the main dirty frame bits. r=bz.

This commit is contained in:
Jonathan Watt 2012-08-29 09:01:09 +01:00
Родитель 1d1b72f11d
Коммит f666091a49
2 изменённых файлов: 37 добавлений и 7 удалений

Просмотреть файл

@ -296,6 +296,28 @@ public:
nscoord aWidthInCB);
NS_IMETHOD WillReflow(nsPresContext* aPresContext);
/**
* Calculates the size of this frame after reflowing (calling Reflow on, and
* updating the size and position of) its children, as necessary. The
* calculated size is returned to the caller via the nsHTMLReflowMetrics
* outparam. (The caller is responsible for setting the actual size and
* position of this frame.)
*
* A frame's children must _all_ be reflowed if the frame is dirty (the
* NS_FRAME_IS_DIRTY bit is set on it). Otherwise, individual children
* must be reflowed if they are dirty or have the NS_FRAME_HAS_DIRTY_CHILDREN
* bit set on them. Otherwise, whether children need to be reflowed depends
* on the frame's type (it's up to individual Reflow methods), and on what
* has changed. For example, a change in the width of the frame may require
* all of its children to be reflowed (even those without dirty bits set on
* them), whereas a change in its height might not.
* (nsHTMLReflowState::ShouldReflowAllKids may be helpful in deciding whether
* to reflow all the children, but for some frame types it might result in
* over-reflow.)
*
* Note: if it's only the overflow rect(s) of a frame that need to be
* updated, then UpdateOverflow should be called instead of Reflow.
*/
NS_IMETHOD Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,

Просмотреть файл

@ -170,7 +170,8 @@ typedef uint64_t nsFrameState;
// This bit is available for re-use.
//#define NS_FRAME_SELECTED_CONTENT NS_FRAME_STATE_BIT(9)
// If this bit is set, then the frame is dirty and needs to be reflowed.
// If this bit is set, then the frame and _all_ of its descendant frames need
// to be reflowed.
// This bit is set when the frame is first created.
// This bit is cleared by DidReflow after the required call to Reflow has
// finished.
@ -183,12 +184,19 @@ typedef uint64_t nsFrameState;
// and the like.
#define NS_FRAME_TOO_DEEP_IN_FRAME_TREE NS_FRAME_STATE_BIT(11)
// If this bit is set, either:
// 1. the frame has children that have either NS_FRAME_IS_DIRTY or
// NS_FRAME_HAS_DIRTY_CHILDREN, or
// 2. the frame has had descendants removed.
// It means that Reflow needs to be called, but that Reflow will not
// do as much work as it would if NS_FRAME_IS_DIRTY were set.
// If this bit is set, then either:
// 1. the frame has at least one child that has the NS_FRAME_IS_DIRTY bit or
// NS_FRAME_HAS_DIRTY_CHILDREN bit set, or
// 2. the frame has had at least one child removed since the last reflow, or
// 3. the frame has had a style change that requires the frame to be reflowed
// but does not _necessarily_ require its descendants to be reflowed (e.g.,
// for a 'height', 'width', 'margin', etc. change, it's up to the
// applicable Reflow methods to decide whether the frame's children
// _actually_ need to be reflowed).
// If this bit is set but the NS_FRAME_IS_DIRTY is not set, then Reflow still
// needs to be called on the frame, but Reflow will likely not do as much work
// as it would if NS_FRAME_IS_DIRTY were set. See the comment documenting
// nsFrame::Reflow for more.
// This bit is cleared by DidReflow after the required call to Reflow has
// finished.
// Do not set this bit yourself if you plan to pass the frame to