Bug 1792134 Part 6 - More rename and clean up related to StyleClear. r=emilio

* Rename `mBreakType` to `mFloatClearType` in nsLineBox and nsReflowStatus and
  the methods around it.
* Rename `mBreakType` to `mClear` in nsStyleDisplay.
* Many other method parameters or local variables rename such as from
  `aBreakType` to `aClearType`.

Differential Revision: https://phabricator.services.mozilla.com/D158276
This commit is contained in:
Ting-Yu Lin 2022-09-29 03:40:56 +00:00
parent c62835eef0
commit b798773da4
15 changed files with 122 additions and 134 deletions

View file

@ -158,7 +158,7 @@ void BRFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
}
// Return our reflow status
aStatus.SetInlineLineBreakAfter(aReflowInput.mStyleDisplay->mBreakType);
aStatus.SetInlineLineBreakAfter(aReflowInput.mStyleDisplay->mClear);
ll->SetLineEndsInBR(true);
}

View file

@ -723,9 +723,9 @@ BlockReflowState::PlaceFloatResult BlockReflowState::FlowAndPlaceFloat(
// See if the float should clear any preceding floats...
// XXX We need to mark this float somehow so that it gets reflowed
// when floats are inserted before it.
if (StyleClear::None != floatDisplay->mBreakType) {
if (StyleClear::None != floatDisplay->mClear) {
// XXXldb Does this handle vertical margins correctly?
auto [bCoord, result] = ClearFloats(mBCoord, floatDisplay->mBreakType);
auto [bCoord, result] = ClearFloats(mBCoord, floatDisplay->mClear);
if (result == ClearFloatsResult::FloatsPushedOrSplit) {
PushFloatPastBreak(aFloat);
return PlaceFloatResult::ShouldPlaceInNextContinuation;
@ -1038,7 +1038,7 @@ void BlockReflowState::PlaceBelowCurrentLineFloats(nsLineBox* aLine) {
}
std::tuple<nscoord, BlockReflowState::ClearFloatsResult>
BlockReflowState::ClearFloats(nscoord aBCoord, StyleClear aBreakType,
BlockReflowState::ClearFloats(nscoord aBCoord, StyleClear aClearType,
nsIFrame* aFloatAvoidingBlock) {
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
@ -1053,10 +1053,10 @@ BlockReflowState::ClearFloats(nscoord aBCoord, StyleClear aBreakType,
nscoord newBCoord = aBCoord;
if (aBreakType != StyleClear::None) {
newBCoord = FloatManager()->ClearFloats(newBCoord, aBreakType);
if (aClearType != StyleClear::None) {
newBCoord = FloatManager()->ClearFloats(newBCoord, aClearType);
if (FloatManager()->ClearContinues(aBreakType)) {
if (FloatManager()->ClearContinues(aClearType)) {
return {newBCoord, ClearFloatsResult::FloatsPushedOrSplit};
}
}

View file

@ -156,7 +156,7 @@ class BlockReflowState {
void PlaceBelowCurrentLineFloats(nsLineBox* aLine);
// Returns the first coordinate >= aBCoord that clears the
// floats indicated by aBreakType and has enough inline size between floats
// floats indicated by aClearType and has enough inline size between floats
// (or no floats remaining) to accomodate aFloatAvoidingBlock.
enum class ClearFloatsResult : uint8_t {
BCoordNoChange,
@ -164,7 +164,7 @@ class BlockReflowState {
FloatsPushedOrSplit,
};
std::tuple<nscoord, ClearFloatsResult> ClearFloats(
nscoord aBCoord, StyleClear aBreakType,
nscoord aBCoord, StyleClear aClearType,
nsIFrame* aFloatAvoidingBlock = nullptr);
nsFloatManager* FloatManager() const {

View file

@ -918,13 +918,13 @@ nscoord nsBlockFrame::GetPrefISize(gfxContext* aRenderingContext) {
AutoNoisyIndenter lineindent(gNoisyIntrinsic);
#endif
if (line->IsBlock()) {
StyleClear breakType;
StyleClear clearType;
if (!data.mLineIsEmpty || BlockCanIntersectFloats(line->mFirstChild)) {
breakType = StyleClear::Both;
clearType = StyleClear::Both;
} else {
breakType = line->mFirstChild->StyleDisplay()->mBreakType;
clearType = line->mFirstChild->StyleDisplay()->mClear;
}
data.ForceBreak(breakType);
data.ForceBreak(clearType);
data.mCurrentLine = nsLayoutUtils::IntrinsicForContainer(
aRenderingContext, line->mFirstChild,
IntrinsicISizeType::PrefISize);
@ -2397,7 +2397,7 @@ void nsBlockFrame::PrepareResizeReflow(BlockReflowState& aState) {
// way we are here.
bool isLastLine = line == mLines.back() && !GetNextInFlow();
if (line->IsBlock() || line->HasFloats() ||
(!isLastLine && !line->HasBreakAfter()) ||
(!isLastLine && !line->HasForcedLineBreakAfter()) ||
((isLastLine || !line->IsLineWrapped())) ||
line->ResizeReflowOptimizationDisabled() ||
line->IsImpactedByFloat() || (line->IEnd() > newAvailISize)) {
@ -2414,17 +2414,18 @@ void nsBlockFrame::PrepareResizeReflow(BlockReflowState& aState) {
if (gNoisyReflow && !line->IsDirty()) {
IndentBy(stdout, gNoiseIndent + 1);
printf(
"skipped: line=%p next=%p %s %s%s%s breakTypeBefore/After=%s/%s "
"skipped: line=%p next=%p %s %s%s%s clearTypeBefore/After=%s/%s "
"xmost=%d\n",
static_cast<void*>(line.get()),
static_cast<void*>(
(line.next() != LinesEnd() ? line.next().get() : nullptr)),
line->IsBlock() ? "block" : "inline",
line->HasBreakAfter() ? "has-break-after " : "",
line->HasForcedLineBreakAfter() ? "has-break-after " : "",
line->HasFloats() ? "has-floats " : "",
line->IsImpactedByFloat() ? "impacted " : "",
line->BreakTypeToString(line->GetBreakTypeBefore()),
line->BreakTypeToString(line->GetBreakTypeAfter()), line->IEnd());
line->StyleClearToString(line->FloatClearTypeBefore()),
line->StyleClearToString(line->FloatClearTypeAfter()),
line->IEnd());
}
#endif
}
@ -2522,11 +2523,11 @@ void nsBlockFrame::PropagateFloatDamage(BlockReflowState& aState,
static bool LineHasClear(nsLineBox* aLine) {
return aLine->IsBlock()
? (aLine->HasBreakBefore() ||
? (aLine->HasForcedLineBreakBefore() ||
aLine->mFirstChild->HasAnyStateBits(
NS_BLOCK_HAS_CLEAR_CHILDREN) ||
!nsBlockFrame::BlockCanIntersectFloats(aLine->mFirstChild))
: aLine->HasFloatBreakAfter();
: aLine->HasFloatClearTypeAfter();
}
/**
@ -2624,7 +2625,7 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowState& aState) {
mFloats.FirstChild()->HasAnyStateBits(NS_FRAME_IS_PUSHED_FLOAT);
bool lastLineMovedUp = false;
// We save up information about BR-clearance here
StyleClear inlineFloatBreakType = aState.mTrailingClearFromPIF;
StyleClear inlineFloatClearType = aState.mTrailingClearFromPIF;
LineIterator line = LinesBegin(), line_end = LinesEnd();
@ -2678,17 +2679,18 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowState& aState) {
// We have to reflow the line if it's a block whose clearance
// might have changed, so detect that.
if (!line->IsDirty() && (line->HasBreakBefore() || floatAvoidingBlock)) {
if (!line->IsDirty() &&
(line->HasForcedLineBreakBefore() || floatAvoidingBlock)) {
nscoord curBCoord = aState.mBCoord;
// See where we would be after applying any clearance due to
// BRs.
if (inlineFloatBreakType != StyleClear::None) {
if (inlineFloatClearType != StyleClear::None) {
std::tie(curBCoord, std::ignore) =
aState.ClearFloats(curBCoord, inlineFloatBreakType);
aState.ClearFloats(curBCoord, inlineFloatClearType);
}
auto [newBCoord, result] = aState.ClearFloats(
curBCoord, line->GetBreakTypeBefore(), floatAvoidingBlock);
curBCoord, line->FloatClearTypeBefore(), floatAvoidingBlock);
if (line->HasClearance()) {
// Reflow the line if it might not have clearance anymore.
@ -2709,15 +2711,15 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowState& aState) {
}
// We might have to reflow a line that is after a clearing BR.
if (inlineFloatBreakType != StyleClear::None) {
if (inlineFloatClearType != StyleClear::None) {
std::tie(aState.mBCoord, std::ignore) =
aState.ClearFloats(aState.mBCoord, inlineFloatBreakType);
aState.ClearFloats(aState.mBCoord, inlineFloatClearType);
if (aState.mBCoord != line->BStart() + deltaBCoord) {
// SlideLine is not going to put the line where the clearance
// put it. Reflow the line to be sure.
line->MarkDirty();
}
inlineFloatBreakType = StyleClear::None;
inlineFloatClearType = StyleClear::None;
}
bool previousMarginWasDirty = line->IsPreviousMarginDirty();
@ -3020,11 +3022,11 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowState& aState) {
}
// Record if we need to clear floats before reflowing the next
// line. Note that inlineFloatBreakType will be handled and
// line. Note that inlineFloatClearType will be handled and
// cleared before the next line is processed, so there is no
// need to combine break types here.
if (line->HasFloatBreakAfter()) {
inlineFloatBreakType = line->GetBreakTypeAfter();
if (line->HasFloatClearTypeAfter()) {
inlineFloatClearType = line->FloatClearTypeAfter();
}
if (LineHasClear(line.get())) {
@ -3047,9 +3049,9 @@ void nsBlockFrame::ReflowDirtyLines(BlockReflowState& aState) {
}
// Handle BR-clearance from the last line of the block
if (inlineFloatBreakType != StyleClear::None) {
if (inlineFloatClearType != StyleClear::None) {
std::tie(aState.mBCoord, std::ignore) =
aState.ClearFloats(aState.mBCoord, inlineFloatBreakType);
aState.ClearFloats(aState.mBCoord, inlineFloatClearType);
}
if (needToRecoverState) {
@ -3709,17 +3711,17 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowState& aState,
// Prepare the block reflow engine
nsBlockReflowContext brc(aState.mPresContext, aState.mReflowInput);
StyleClear breakType = frame->StyleDisplay()->mBreakType;
StyleClear clearType = frame->StyleDisplay()->mClear;
if (aState.mTrailingClearFromPIF != StyleClear::None) {
breakType = nsLayoutUtils::CombineClearType(breakType,
clearType = nsLayoutUtils::CombineClearType(clearType,
aState.mTrailingClearFromPIF);
aState.mTrailingClearFromPIF = StyleClear::None;
}
// Clear past floats before the block if the clear style is not none
aLine->ClearForcedLineBreak();
if (breakType != StyleClear::None) {
aLine->SetBreakTypeBefore(breakType);
if (clearType != StyleClear::None) {
aLine->SetForcedLineBreakBefore(clearType);
}
// See if we should apply the block-start margin. If the block frame being
@ -3736,7 +3738,7 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowState& aState,
}
bool treatWithClearance = aLine->HasClearance();
bool mightClearFloats = breakType != StyleClear::None;
bool mightClearFloats = clearType != StyleClear::None;
nsIFrame* floatAvoidingBlock = nullptr;
if (!nsBlockFrame::BlockCanIntersectFloats(frame)) {
mightClearFloats = true;
@ -3751,7 +3753,7 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowState& aState,
aState.mReflowInput.mDiscoveredClearance) {
nscoord curBCoord = aState.mBCoord + aState.mPrevBEndMargin.get();
if (auto [clearBCoord, result] =
aState.ClearFloats(curBCoord, breakType, floatAvoidingBlock);
aState.ClearFloats(curBCoord, clearType, floatAvoidingBlock);
result != ClearFloatsResult::BCoordNoChange) {
Unused << clearBCoord;
@ -3831,7 +3833,7 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowState& aState,
// first pass.
nscoord curBCoord = aState.mBCoord + aState.mPrevBEndMargin.get();
if (auto [clearBCoord, result] =
aState.ClearFloats(curBCoord, breakType, floatAvoidingBlock);
aState.ClearFloats(curBCoord, clearType, floatAvoidingBlock);
result != ClearFloatsResult::BCoordNoChange) {
Unused << clearBCoord;
@ -3862,7 +3864,7 @@ void nsBlockFrame::ReflowBlockFrame(BlockReflowState& aState,
nscoord currentBCoord = aState.mBCoord;
// advance mBCoord to the clear position.
auto [clearBCoord, result] =
aState.ClearFloats(aState.mBCoord, breakType, floatAvoidingBlock);
aState.ClearFloats(aState.mBCoord, clearType, floatAvoidingBlock);
aState.mBCoord = clearBCoord;
clearedFloats = result != ClearFloatsResult::BCoordNoChange;
@ -4785,17 +4787,17 @@ void nsBlockFrame::ReflowInlineFrame(BlockReflowState& aState,
"We should've handled inline break-before in the if-branch!");
// If a float split and its prev-in-flow was followed by a <BR>, then
// combine the <BR>'s break type with the inline's break type (the inline
// will be the very next frame after the split float).
StyleClear breakType = frameReflowStatus.BreakType();
// combine the <BR>'s float clear type with the inline's float clear type
// (the inline will be the very next frame after the split float).
StyleClear clearType = frameReflowStatus.FloatClearType();
if (aState.mTrailingClearFromPIF != StyleClear::None) {
breakType = nsLayoutUtils::CombineClearType(
breakType, aState.mTrailingClearFromPIF);
clearType = nsLayoutUtils::CombineClearType(
clearType, aState.mTrailingClearFromPIF);
aState.mTrailingClearFromPIF = StyleClear::None;
}
// Break-after cases
if (breakType != StyleClear::None || aLineLayout.GetLineEndsInBR()) {
aLine->SetBreakTypeAfter(breakType);
if (clearType != StyleClear::None || aLineLayout.GetLineEndsInBR()) {
aLine->SetForcedLineBreakAfter(clearType);
}
if (frameReflowStatus.IsComplete()) {
// Split line, but after the frame just reflowed
@ -5249,9 +5251,9 @@ bool nsBlockFrame::PlaceLine(BlockReflowState& aState,
// Apply break-after clearing if necessary
// This must stay in sync with |ReflowDirtyLines|.
if (aLine->HasFloatBreakAfter()) {
if (aLine->HasFloatClearTypeAfter()) {
std::tie(aState.mBCoord, std::ignore) =
aState.ClearFloats(aState.mBCoord, aLine->GetBreakTypeAfter());
aState.ClearFloats(aState.mBCoord, aLine->FloatClearTypeAfter());
}
return true;
}
@ -6814,7 +6816,7 @@ StyleClear nsBlockFrame::FindTrailingClear() {
b = static_cast<nsBlockFrame*>(b->GetPrevInFlow())) {
auto endLine = b->LinesRBegin();
if (endLine != b->LinesREnd()) {
return endLine->GetBreakTypeAfter();
return endLine->FloatClearTypeAfter();
}
}
return StyleClear::None;

View file

@ -158,7 +158,7 @@ bool nsBlockReflowContext::ComputeCollapsedBStartMargin(
availSpace);
// Record that we're being optimistic by assuming the kid
// has no clearance
if (kid->StyleDisplay()->mBreakType != StyleClear::None ||
if (kid->StyleDisplay()->mClear != StyleClear::None ||
!nsBlockFrame::BlockCanIntersectFloats(kid)) {
*aMayNeedRetry = true;
}

View file

@ -461,7 +461,7 @@ nsresult nsFloatManager::List(FILE* out) const {
#endif
nscoord nsFloatManager::ClearFloats(nscoord aBCoord,
StyleClear aBreakType) const {
StyleClear aClearType) const {
if (!HasAnyFloats()) {
return aBCoord;
}
@ -469,7 +469,7 @@ nscoord nsFloatManager::ClearFloats(nscoord aBCoord,
nscoord blockEnd = aBCoord + mBlockStart;
const FloatInfo& tail = mFloats[mFloats.Length() - 1];
switch (aBreakType) {
switch (aClearType) {
case StyleClear::Both:
blockEnd = std::max(blockEnd, tail.mLeftBEnd);
blockEnd = std::max(blockEnd, tail.mRightBEnd);
@ -490,11 +490,11 @@ nscoord nsFloatManager::ClearFloats(nscoord aBCoord,
return blockEnd;
}
bool nsFloatManager::ClearContinues(StyleClear aBreakType) const {
bool nsFloatManager::ClearContinues(StyleClear aClearType) const {
return ((mPushedLeftFloatPastBreak || mSplitLeftFloatAcrossBreak) &&
(aBreakType == StyleClear::Both || aBreakType == StyleClear::Left)) ||
(aClearType == StyleClear::Both || aClearType == StyleClear::Left)) ||
((mPushedRightFloatPastBreak || mSplitRightFloatAcrossBreak) &&
(aBreakType == StyleClear::Both || aBreakType == StyleClear::Right));
(aClearType == StyleClear::Both || aClearType == StyleClear::Right));
}
/////////////////////////////////////////////////////////////////////////////

View file

@ -309,19 +309,19 @@ class nsFloatManager {
nscoord LowestFloatBStart() const;
/**
* Return the coordinate of the lowest float matching aBreakType in
* Return the coordinate of the lowest float matching aClearType in
* this float manager. Returns aBCoord if there are no matching
* floats.
*
* Both aBCoord and the result are relative to the current translation.
*/
nscoord ClearFloats(nscoord aBCoord, mozilla::StyleClear aBreakType) const;
nscoord ClearFloats(nscoord aBCoord, mozilla::StyleClear aClearType) const;
/**
* Checks if clear would pass into the floats' BFC's next-in-flow,
* i.e. whether floats affecting this clear have continuations.
*/
bool ClearContinues(mozilla::StyleClear aBreakType) const;
bool ClearContinues(mozilla::StyleClear aClearType) const;
void AssertStateMatches(SavedState* aState) const {
NS_ASSERTION(

View file

@ -5936,15 +5936,10 @@ void nsIFrame::InlineMinISizeData::OptionallyBreak(nscoord aHyphenWidth) {
ForceBreak();
}
void nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType) {
MOZ_ASSERT(aBreakType == StyleClear::None || aBreakType == StyleClear::Both ||
aBreakType == StyleClear::Left ||
aBreakType == StyleClear::Right,
"Must be a physical break type");
void nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aClearType) {
// If this force break is not clearing any float, we can leave all the
// floats to the next force break.
if (mFloats.Length() != 0 && aBreakType != StyleClear::None) {
if (!mFloats.IsEmpty() && aClearType != StyleClear::None) {
// preferred widths accumulated for floats that have already
// been cleared past
nscoord floats_done = 0,
@ -5952,21 +5947,20 @@ void nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType) {
// been cleared past
floats_cur_left = 0, floats_cur_right = 0;
for (uint32_t i = 0, i_end = mFloats.Length(); i != i_end; ++i) {
const FloatInfo& floatInfo = mFloats[i];
for (const FloatInfo& floatInfo : mFloats) {
const nsStyleDisplay* floatDisp = floatInfo.Frame()->StyleDisplay();
StyleClear breakType = floatDisp->mBreakType;
if (breakType == StyleClear::Left || breakType == StyleClear::Right ||
breakType == StyleClear::Both) {
StyleClear clearType = floatDisp->mClear;
if (clearType == StyleClear::Left || clearType == StyleClear::Right ||
clearType == StyleClear::Both) {
nscoord floats_cur =
NSCoordSaturatingAdd(floats_cur_left, floats_cur_right);
if (floats_cur > floats_done) {
floats_done = floats_cur;
}
if (breakType != StyleClear::Right) {
if (clearType != StyleClear::Right) {
floats_cur_left = 0;
}
if (breakType != StyleClear::Left) {
if (clearType != StyleClear::Left) {
floats_cur_right = 0;
}
}
@ -5986,7 +5980,7 @@ void nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType) {
mCurrentLine = NSCoordSaturatingAdd(mCurrentLine, floats_done);
if (aBreakType == StyleClear::Both) {
if (aClearType == StyleClear::Both) {
mFloats.Clear();
} else {
// If the break type does not clear all floats, it means there may
@ -5996,10 +5990,10 @@ void nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType) {
// floats may be cleared directly or indirectly. See below.
nsTArray<FloatInfo> newFloats;
MOZ_ASSERT(
aBreakType == StyleClear::Left || aBreakType == StyleClear::Right,
aClearType == StyleClear::Left || aClearType == StyleClear::Right,
"Other values should have been handled in other branches");
StyleFloat clearFloatType =
aBreakType == StyleClear::Left ? StyleFloat::Left : StyleFloat::Right;
aClearType == StyleClear::Left ? StyleFloat::Left : StyleFloat::Right;
// Iterate the array in reverse so that we can stop when there are
// no longer any floats we need to keep. See below.
for (FloatInfo& floatInfo : Reversed(mFloats)) {
@ -6014,9 +6008,8 @@ void nsIFrame::InlinePrefISizeData::ForceBreak(StyleClear aBreakType) {
// (earlier) floats on that side would be indirectly cleared
// as well. Thus, we should break out of this loop and stop
// considering earlier floats to be kept in mFloats.
StyleClear floatBreakType = floatDisp->mBreakType;
if (floatBreakType != aBreakType &&
floatBreakType != StyleClear::None) {
StyleClear clearType = floatDisp->mClear;
if (clearType != aClearType && clearType != StyleClear::None) {
break;
}
}

View file

@ -202,11 +202,9 @@ enum nsSelectionAmount {
//----------------------------------------------------------------------
// Reflow status returned by the Reflow() methods.
class nsReflowStatus final {
using StyleClear = mozilla::StyleClear;
public:
nsReflowStatus()
: mBreakType(StyleClear::None),
: mFloatClearType(mozilla::StyleClear::None),
mInlineBreak(InlineBreak::None),
mCompletion(Completion::FullyComplete),
mNextInFlowNeedsReflow(false),
@ -214,7 +212,7 @@ class nsReflowStatus final {
// Reset all the member variables.
void Reset() {
mBreakType = StyleClear::None;
mFloatClearType = mozilla::StyleClear::None;
mInlineBreak = InlineBreak::None;
mCompletion = Completion::FullyComplete;
mNextInFlowNeedsReflow = false;
@ -307,7 +305,7 @@ class nsReflowStatus final {
return mInlineBreak == InlineBreak::Before;
}
bool IsInlineBreakAfter() const { return mInlineBreak == InlineBreak::After; }
StyleClear BreakType() const { return mBreakType; }
mozilla::StyleClear FloatClearType() const { return mFloatClearType; }
// Set the inline line-break-before status, and reset other bit flags. Note
// that other frame completion status isn't expected to matter after calling
@ -320,14 +318,15 @@ class nsReflowStatus final {
// column/page where it will hopefully fit.
void SetInlineLineBreakBeforeAndReset() {
Reset();
mBreakType = StyleClear::None;
mFloatClearType = mozilla::StyleClear::None;
mInlineBreak = InlineBreak::Before;
}
// Set the inline line-break-after status. The break type can be changed
// via the optional aBreakType param.
void SetInlineLineBreakAfter(StyleClear aBreakType = StyleClear::None) {
mBreakType = aBreakType;
// Set the inline line-break-after status. The clear type can be changed
// via the optional aClearType param.
void SetInlineLineBreakAfter(
mozilla::StyleClear aClearType = mozilla::StyleClear::None) {
mFloatClearType = aClearType;
mInlineBreak = InlineBreak::After;
}
@ -337,7 +336,7 @@ class nsReflowStatus final {
void SetFirstLetterComplete() { mFirstLetterComplete = true; }
private:
StyleClear mBreakType;
mozilla::StyleClear mFloatClearType;
InlineBreak mInlineBreak;
Completion mCompletion;
bool mNextInFlowNeedsReflow : 1;
@ -2535,14 +2534,12 @@ class nsIFrame : public nsQueryFrame {
};
struct InlinePrefISizeData : public InlineIntrinsicISizeData {
typedef mozilla::StyleClear StyleClear;
InlinePrefISizeData() : mLineIsEmpty(true) {}
/**
* Finish the current line and start a new line.
*
* @param aBreakType controls whether isize of floats are considered
* @param aClearType controls whether isize of floats are considered
* and what floats are kept for the next line:
* * |None| skips handling floats, which means no floats are
* removed, and isizes of floats are not considered either.
@ -2552,10 +2549,8 @@ class nsIFrame : public nsQueryFrame {
* remove floats on the given side, and any floats on the other
* side that are prior to a float on the given side that has a
* 'clear' property that clears them.
* All other values of StyleClear must be converted to the four
* physical values above for this function.
*/
void ForceBreak(StyleClear aBreakType = StyleClear::Both);
void ForceBreak(mozilla::StyleClear aClearType = mozilla::StyleClear::Both);
// The default implementation for nsIFrame::AddInlinePrefISize.
void DefaultAddInlinePrefISize(nscoord aISize);

View file

@ -673,10 +673,10 @@ void nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext,
// Change break-before status into break-after since we have
// already placed at least one child frame. This preserves the
// break-type so that it can be propagated upward.
StyleClear oldBreakType = aStatus.BreakType();
StyleClear oldClearType = aStatus.FloatClearType();
aStatus.Reset();
aStatus.SetIncomplete();
aStatus.SetInlineLineBreakAfter(oldBreakType);
aStatus.SetInlineLineBreakAfter(oldClearType);
PushFrames(aPresContext, aFrame, irs.mPrevFrame, irs);
} else {
// Preserve reflow status when breaking-before our first child

View file

@ -185,8 +185,8 @@ static void ListFloats(FILE* out, const char* aPrefix,
}
}
/* static */ const char* nsLineBox::BreakTypeToString(StyleClear aBreakType) {
switch (aBreakType) {
/* static */ const char* nsLineBox::StyleClearToString(StyleClear aClearType) {
switch (aClearType) {
case StyleClear::None:
return "none";
case StyleClear::Left:
@ -219,8 +219,8 @@ void nsLineBox::List(FILE* out, const char* aPrefix,
IsImpactedByFloat() ? "impacted" : "not-impacted",
IsLineWrapped() ? "wrapped" : "not-wrapped",
HasForcedLineBreak() ? "forced-break" : "no-break",
BreakTypeToString(GetBreakTypeBefore()),
BreakTypeToString(GetBreakTypeAfter()));
StyleClearToString(FloatClearTypeBefore()),
StyleClearToString(FloatClearTypeAfter()));
if (IsBlock() && !GetCarriedOutBEndMargin().IsZero()) {
const nscoord bm = GetCarriedOutBEndMargin().get();

View file

@ -238,44 +238,42 @@ class nsLineBox final : public nsLineLink {
}
}
// mHasForcedLineBreak bit & mBreakType value
// mHasForcedLineBreak bit & mFloatClearType value
// Break information is applied *before* the line if the line is a block,
// or *after* the line if the line is an inline. Confusing, I know, but
// using different names should help.
using StyleClear = mozilla::StyleClear;
// or *after* the line if the line is an inline.
bool HasForcedLineBreak() const { return mFlags.mHasForcedLineBreak; }
void ClearForcedLineBreak() {
mFlags.mHasForcedLineBreak = false;
mFlags.mBreakType = StyleClear::None;
mFlags.mFloatClearType = mozilla::StyleClear::None;
}
bool HasBreakBefore() const { return IsBlock() && HasForcedLineBreak(); }
void SetBreakTypeBefore(StyleClear aBreakType) {
bool HasForcedLineBreakBefore() const {
return IsBlock() && HasForcedLineBreak();
}
void SetForcedLineBreakBefore(mozilla::StyleClear aClearType) {
MOZ_ASSERT(IsBlock(), "Only blocks have break-before");
MOZ_ASSERT(aBreakType == StyleClear::Left ||
aBreakType == StyleClear::Right ||
aBreakType == StyleClear::Both,
MOZ_ASSERT(aClearType != mozilla::StyleClear::None,
"Only StyleClear:Left/Right/Both are allowed before a line");
mFlags.mHasForcedLineBreak = true;
mFlags.mBreakType = aBreakType;
mFlags.mFloatClearType = aClearType;
}
StyleClear GetBreakTypeBefore() const {
return IsBlock() ? BreakType() : StyleClear::None;
mozilla::StyleClear FloatClearTypeBefore() const {
return IsBlock() ? FloatClearType() : mozilla::StyleClear::None;
}
bool HasBreakAfter() const { return IsInline() && HasForcedLineBreak(); }
void SetBreakTypeAfter(StyleClear aBreakType) {
bool HasForcedLineBreakAfter() const {
return IsInline() && HasForcedLineBreak();
}
void SetForcedLineBreakAfter(mozilla::StyleClear aClearType) {
MOZ_ASSERT(IsInline(), "Only inlines have break-after");
mFlags.mHasForcedLineBreak = true;
mFlags.mBreakType = aBreakType;
mFlags.mFloatClearType = aClearType;
}
bool HasFloatBreakAfter() const {
return IsInline() && (StyleClear::Left == BreakType() ||
StyleClear::Right == BreakType() ||
StyleClear::Both == BreakType());
bool HasFloatClearTypeAfter() const {
return IsInline() && FloatClearType() != mozilla::StyleClear::None;
}
StyleClear GetBreakTypeAfter() const {
return IsInline() ? BreakType() : StyleClear::None;
mozilla::StyleClear FloatClearTypeAfter() const {
return IsInline() ? FloatClearType() : mozilla::StyleClear::None;
}
// mCarriedOutBEndMargin value
@ -416,7 +414,7 @@ class nsLineBox final : public nsLineLink {
int32_t* aFrameIndexInLine);
#ifdef DEBUG_FRAME_DUMP
static const char* BreakTypeToString(StyleClear aBreakType);
static const char* StyleClearToString(mozilla::StyleClear aClearType);
void List(FILE* out, int32_t aIndent,
nsIFrame::ListFlags aFlags = nsIFrame::ListFlags()) const;
@ -526,7 +524,9 @@ class nsLineBox final : public nsLineLink {
// mHasForcedLineBreak indicates that this line has either a break-before or
// a break-after.
bool mHasForcedLineBreak : 1;
StyleClear mBreakType;
// mFloatClearType indicates that there's a float clearance before or after
// this line.
mozilla::StyleClear mFloatClearType;
};
struct ExtraData {
@ -572,7 +572,7 @@ class nsLineBox final : public nsLineLink {
FlagBits mFlags;
};
StyleClear BreakType() const { return mFlags.mBreakType; };
mozilla::StyleClear FloatClearType() const { return mFlags.mFloatClearType; };
union {
ExtraData* mData;

View file

@ -2208,7 +2208,7 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument)
mDefaultAppearance(StyleAppearance::None),
mPosition(StylePositionProperty::Static),
mFloat(StyleFloat::None),
mBreakType(StyleClear::None),
mClear(StyleClear::None),
mBreakInside(StyleBreakWithin::Auto),
mBreakBefore(StyleBreakBetween::Auto),
mBreakAfter(StyleBreakBetween::Auto),
@ -2264,7 +2264,7 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
mDefaultAppearance(aSource.mDefaultAppearance),
mPosition(aSource.mPosition),
mFloat(aSource.mFloat),
mBreakType(aSource.mBreakType),
mClear(aSource.mClear),
mBreakInside(aSource.mBreakInside),
mBreakBefore(aSource.mBreakBefore),
mBreakAfter(aSource.mBreakAfter),
@ -2539,8 +2539,7 @@ nsChangeHint nsStyleDisplay::CalcDifference(
//
// FIXME(emilio): We definitely change the frame tree in nsCSSFrameConstructor
// based on break-before / break-after... Shouldn't that reframe?
if (mBreakType != aNewData.mBreakType ||
mBreakInside != aNewData.mBreakInside ||
if (mClear != aNewData.mClear || mBreakInside != aNewData.mBreakInside ||
mBreakBefore != aNewData.mBreakBefore ||
mBreakAfter != aNewData.mBreakAfter ||
mAppearance != aNewData.mAppearance ||

View file

@ -1295,7 +1295,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
mozilla::StylePositionProperty mPosition;
mozilla::StyleFloat mFloat;
mozilla::StyleClear mBreakType;
mozilla::StyleClear mClear;
mozilla::StyleBreakWithin mBreakInside;
mozilla::StyleBreakBetween mBreakBefore;
mozilla::StyleBreakBetween mBreakAfter;

View file

@ -80,7 +80,6 @@ ${helpers.predefined_type(
"computed::Clear::None",
engines="gecko servo-2013",
animation_value_type="discrete",
gecko_ffi_name="mBreakType",
spec="https://drafts.csswg.org/css2/#propdef-clear",
servo_restyle_damage="rebuild_and_reflow",
)}