On 09/15/2011 12:23 PM, fantasai wrote:
I'm working on a patch that requires adding data to nsReflowStatus,
but trying to understand how all the bits fit together makes my
head spin, particularly the NS_INLINE_BREAK parts...
Are there non-historical reasons why we're using macros instead of a
bitfield? Can I change things to make it more understandable? What are
the constraints on changing nsReflowStatus (other than "don't change
existing behavior")? Are there files other than nsIFrame.h that define
nsReflowStatus bits?
Here's kindof what I was thinking to change it to. This would involve
touching lots of files... alternatively I could just rearrange the
NS_INLINE_BREAK macros to make that part easier to understand. Thoughts?
http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsIFrame.h#340
struct nsReflowStatus {
/* Completion */
enum {
eComplete = 0,
eOverflowIncomplete = 1,
eIncomplete = 3, // allows bitwise merging
} mCompletion:2;
PRBool mReflowNextInFlow:1;
PRBool mTruncated:1;
PRBool IsComplete() { return mCompletion != eIncomplete; }
PRBool IsFullyComplete() { return mCompletion == eComplete; }
PRBool OverflowIsIncomplete() { return mCompletion == eOverflowIncomplete; }
PRBool IsTruncated() { return mTruncated; }
void SetIncomplete() { mCompletion = eIncomplete; }
void SetOverflowIncomplete() { mCompletion = eOverflowIncomplete; }
void MergeCompletionFrom(nsReflowStatus aStatus)
{
mCompletion |= aStatus.mCompletion;
mReflowNextInFlow |= aStatus.mReflowNextInFlow;
mTruncated |= aStatus.mTruncated;
}
/* Break/Clear Extension */
// Type of break requested. See nsStyleConsts.h NS_STYLE_PAGE_BREAk_*
PRUint mBreak:8;
// Type of clear requested. See nsStyleConsts.h NS_STYLE_CLEAR_*
// Note: Line breaks are currently handled as clears.
PRUint mClear:8;
// When a clear is requested, this bit when set indicates that the
// clear should occur after the frame just reflowed; when the bit is
// not set the break should occur before the frame just reflowed.
PRBool mClearIsAfter:1;
// Set when a break was induced by completion of a first-letter
PRBool mFirstLetterComplete:1
PRBool HasLineBreak() { return !!mClear; }
PRBool HasLineBreakBefore() { return !!mClear && !mClearIsAfter; }
PRBool HasLineBreakAfter() { return !!mClear && mClearIsAfter; }
void SetLineBreakBefore() {
mClear = NS_STYLE_CLEAR_LINE;
mClearIsBefore = PR_TRUE;
}
void SetLineBreakAfter() {
mClear = NS_STYLE_CLEAR_LINE;
mClearIsBefore = PR_FALSE;
}
}
~fantasai
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout