Bug 1611733 - Bug 1611633 - convert ns style position defines to enum class. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D61958

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Thomas Dolezal 2020-02-07 12:35:30 +00:00
Родитель 1627f07981
Коммит 062c15357a
17 изменённых файлов: 64 добавлений и 57 удалений

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

@ -2272,7 +2272,7 @@ void EventStateManager::DoScrollZoom(nsIFrame* aTargetFrame,
static nsIFrame* GetParentFrameToScroll(nsIFrame* aFrame) {
if (!aFrame) return nullptr;
if (aFrame->StyleDisplay()->mPosition == NS_STYLE_POSITION_FIXED &&
if (aFrame->StyleDisplay()->mPosition == StylePositionProperty::Fixed &&
nsLayoutUtils::IsReallyFixedPos(aFrame))
return aFrame->PresContext()->GetPresShell()->GetRootScrollFrame();

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

@ -174,7 +174,7 @@ void AccessibleCaret::EnsureApzAware() {
bool AccessibleCaret::IsInPositionFixedSubtree() const {
for (nsIFrame* f = mImaginaryCaretReferenceFrame.GetFrame(); f;
f = f->GetParent()) {
if (f->StyleDisplay()->mPosition == NS_STYLE_POSITION_FIXED &&
if (f->StyleDisplay()->mPosition == StylePositionProperty::Fixed &&
nsLayoutUtils::IsReallyFixedPos(f)) {
return true;
}

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

@ -681,7 +681,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
const nsStyleDisplay* display = aFrame->StyleDisplay();
// Changes to the offsets of a non-positioned element can safely be ignored.
if (display->mPosition == NS_STYLE_POSITION_STATIC) {
if (display->mPosition == StylePositionProperty::Static) {
return true;
}
@ -721,7 +721,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
return false;
}
// Move the frame
if (display->mPosition == NS_STYLE_POSITION_STICKY) {
if (display->mPosition == StylePositionProperty::Sticky) {
// Update sticky positioning for an entire element at once, starting with
// the first continuation or ib-split sibling.
// It's rare that the frame we already have isn't already the first
@ -739,7 +739,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
ssc->PositionContinuations(firstContinuation);
}
} else {
MOZ_ASSERT(NS_STYLE_POSITION_RELATIVE == display->mPosition,
MOZ_ASSERT(StylePositionProperty::Relative == display->mPosition,
"Unexpected type of positioning");
for (nsIFrame* cont = aFrame; cont;
cont = nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
@ -936,7 +936,7 @@ static bool ContainingBlockChangeAffectsDescendants(
const bool isContainingBlock =
aIsFixedPosContainingBlock ||
(aIsAbsPosContainingBlock &&
display->mPosition == NS_STYLE_POSITION_ABSOLUTE);
display->mPosition == StylePositionProperty::Absolute);
// NOTE(emilio): aPossiblyChangingContainingBlock is guaranteed to be
// a first continuation, see the assertion in the caller.
nsIFrame* parent = outOfFlow->GetParent()->FirstContinuation();

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

@ -968,21 +968,21 @@ nsContainerFrame* nsFrameConstructorState::GetGeometricParent(
"-moz-top-layer should be either none or top");
MOZ_ASSERT(aStyleDisplay.IsAbsolutelyPositionedStyle(),
"Top layer items should always be absolutely positioned");
if (aStyleDisplay.mPosition == NS_STYLE_POSITION_FIXED) {
if (aStyleDisplay.mPosition == StylePositionProperty::Fixed) {
MOZ_ASSERT(mTopLayerFixedList.containingBlock, "No root frame?");
return mTopLayerFixedList.containingBlock;
}
MOZ_ASSERT(aStyleDisplay.mPosition == NS_STYLE_POSITION_ABSOLUTE);
MOZ_ASSERT(aStyleDisplay.mPosition == StylePositionProperty::Absolute);
MOZ_ASSERT(mTopLayerAbsoluteList.containingBlock);
return mTopLayerAbsoluteList.containingBlock;
}
if (aStyleDisplay.mPosition == NS_STYLE_POSITION_ABSOLUTE &&
if (aStyleDisplay.mPosition == StylePositionProperty::Absolute &&
mAbsoluteList.containingBlock) {
return mAbsoluteList.containingBlock;
}
if (aStyleDisplay.mPosition == NS_STYLE_POSITION_FIXED &&
if (aStyleDisplay.mPosition == StylePositionProperty::Fixed &&
GetFixedList().containingBlock) {
return GetFixedList().containingBlock;
}
@ -1045,18 +1045,18 @@ AbsoluteFrameList* nsFrameConstructorState::GetOutOfFlowFrameList(
const nsStyleDisplay* disp = aNewFrame->StyleDisplay();
if (disp->mTopLayer != StyleTopLayer::None) {
*aPlaceholderType = PLACEHOLDER_FOR_TOPLAYER;
if (disp->mPosition == NS_STYLE_POSITION_FIXED) {
if (disp->mPosition == StylePositionProperty::Fixed) {
*aPlaceholderType |= PLACEHOLDER_FOR_FIXEDPOS;
return &mTopLayerFixedList;
}
*aPlaceholderType |= PLACEHOLDER_FOR_ABSPOS;
return &mTopLayerAbsoluteList;
}
if (disp->mPosition == NS_STYLE_POSITION_ABSOLUTE) {
if (disp->mPosition == StylePositionProperty::Absolute) {
*aPlaceholderType = PLACEHOLDER_FOR_ABSPOS;
return &mAbsoluteList;
}
if (disp->mPosition == NS_STYLE_POSITION_FIXED) {
if (disp->mPosition == StylePositionProperty::Fixed) {
*aPlaceholderType = PLACEHOLDER_FOR_FIXEDPOS;
return &GetFixedList();
}

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

@ -2018,7 +2018,7 @@ bool nsLayoutUtils::IsFixedPosFrameInDisplayPort(const nsIFrame* aFrame) {
// their pages!
nsIFrame* parent = aFrame->GetParent();
if (!parent || parent->GetParent() ||
aFrame->StyleDisplay()->mPosition != NS_STYLE_POSITION_FIXED) {
aFrame->StyleDisplay()->mPosition != StylePositionProperty::Fixed) {
return false;
}
return ViewportHasDisplayPort(aFrame->PresContext());
@ -2076,7 +2076,7 @@ nsIScrollableFrame* nsLayoutUtils::GetNearestScrollableFrame(nsIFrame* aFrame,
}
}
if ((aFlags & SCROLLABLE_FIXEDPOS_FINDS_ROOT) &&
f->StyleDisplay()->mPosition == NS_STYLE_POSITION_FIXED &&
f->StyleDisplay()->mPosition == StylePositionProperty::Fixed &&
nsLayoutUtils::IsReallyFixedPos(f)) {
return f->PresShell()->GetRootScrollFrameAsScrollable();
}
@ -7467,7 +7467,7 @@ nsDeviceContext* nsLayoutUtils::GetDeviceContextForScreenInfo(
/* static */
bool nsLayoutUtils::IsReallyFixedPos(const nsIFrame* aFrame) {
MOZ_ASSERT(aFrame->StyleDisplay()->mPosition == NS_STYLE_POSITION_FIXED,
MOZ_ASSERT(aFrame->StyleDisplay()->mPosition == StylePositionProperty::Fixed,
"IsReallyFixedPos called on non-'position:fixed' frame");
return MayBeReallyFixedPos(aFrame);
}

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

@ -2082,7 +2082,7 @@ class nsLayoutUtils {
/**
* Some frames with 'position: fixed' (nsStyleDisplay::mPosition ==
* NS_STYLE_POSITION_FIXED) are not really fixed positioned, since
* StylePositionProperty::Fixed) are not really fixed positioned, since
* they're inside an element with -moz-transform. This function says
* whether such an element is a real fixed-pos element.
*/
@ -2090,7 +2090,7 @@ class nsLayoutUtils {
/**
* This function says whether `aFrame` would really be a fixed positioned
* frame if the frame was created with NS_STYLE_POSITION_FIXED.
* frame if the frame was created with StylePositionProperty::Fixed.
*
* It is effectively the same as IsReallyFixedPos, but without asserting the
* position value. Use it only when you know what you're doing, like when

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

@ -1073,9 +1073,9 @@ void ReflowInput::ApplyRelativePositioning(nsIFrame* aFrame,
}
const nsStyleDisplay* display = aFrame->StyleDisplay();
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
if (StylePositionProperty::Relative == display->mPosition) {
*aPosition += nsPoint(aComputedOffsets.left, aComputedOffsets.top);
} else if (NS_STYLE_POSITION_STICKY == display->mPosition &&
} else if (StylePositionProperty::Sticky == display->mPosition &&
!aFrame->GetNextContinuation() && !aFrame->GetPrevContinuation() &&
!(aFrame->GetStateBits() & NS_FRAME_PART_OF_IBSPLIT)) {
// Sticky positioning for elements with multiple frames needs to be
@ -2311,7 +2311,7 @@ void ReflowInput::InitConstraints(
// until the scroll container knows its size, so we compute offsets
// from StickyScrollContainer::UpdatePositions.)
if (mStyleDisplay->IsRelativelyPositioned(mFrame) &&
NS_STYLE_POSITION_RELATIVE == mStyleDisplay->mPosition) {
StylePositionProperty::Relative == mStyleDisplay->mPosition) {
ComputeRelativeOffsets(cbwm, mFrame, cbSize.ConvertTo(cbwm, wm),
ComputedPhysicalOffsets());
} else {

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

@ -4995,7 +4995,8 @@ void nsFlexContainerFrame::MoveFlexItemToFinalPosition(
// If item is relpos, look up its offsets (cached from prev reflow)
LogicalMargin logicalOffsets(outerWM);
if (NS_STYLE_POSITION_RELATIVE == aItem.Frame()->StyleDisplay()->mPosition) {
if (StylePositionProperty::Relative ==
aItem.Frame()->StyleDisplay()->mPosition) {
nsMargin* cachedOffsets =
aItem.Frame()->GetProperty(nsIFrame::ComputedOffsetProperty());
MOZ_ASSERT(cachedOffsets,

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

@ -789,7 +789,7 @@ void nsFrame::DestroyFrom(nsIFrame* aDestructRoot,
SVGObserverUtils::InvalidateDirectRenderingObservers(this);
if (StyleDisplay()->mPosition == NS_STYLE_POSITION_STICKY) {
if (StyleDisplay()->mPosition == StylePositionProperty::Sticky) {
StickyScrollContainer* ssc =
StickyScrollContainer::GetStickyScrollContainerForFrame(this);
if (ssc) {
@ -1268,11 +1268,11 @@ void nsFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
RemoveProperty(NormalPositionProperty());
}
handleStickyChange = disp->mPosition == NS_STYLE_POSITION_STICKY ||
oldDisp->mPosition == NS_STYLE_POSITION_STICKY;
handleStickyChange = disp->mPosition == StylePositionProperty::Sticky ||
oldDisp->mPosition == StylePositionProperty::Sticky;
}
} else { // !aOldComputedStyle
handleStickyChange = disp->mPosition == NS_STYLE_POSITION_STICKY;
handleStickyChange = disp->mPosition == StylePositionProperty::Sticky;
}
if (handleStickyChange && !HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) &&
@ -1284,7 +1284,7 @@ void nsFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
// StickyScrollContainer will remove them later.
if (auto* ssc =
StickyScrollContainer::GetStickyScrollContainerForFrame(this)) {
if (disp->mPosition == NS_STYLE_POSITION_STICKY) {
if (disp->mPosition == StylePositionProperty::Sticky) {
ssc->AddFrame(this);
} else {
ssc->RemoveFrame(this);
@ -3255,13 +3255,13 @@ void nsIFrame::BuildDisplayListForStackingContext(
}
bool useStickyPosition =
disp->mPosition == NS_STYLE_POSITION_STICKY &&
disp->mPosition == StylePositionProperty::Sticky &&
IsScrollFrameActive(
aBuilder,
nsLayoutUtils::GetNearestScrollableFrame(
GetParent(), nsLayoutUtils::SCROLLABLE_SAME_DOC |
nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN));
bool useFixedPosition = disp->mPosition == NS_STYLE_POSITION_FIXED &&
bool useFixedPosition = disp->mPosition == StylePositionProperty::Fixed &&
(nsLayoutUtils::IsFixedPosFrameInDisplayPort(this) ||
BuilderHasScrolledClip(aBuilder));

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

@ -5000,7 +5000,7 @@ void ContainerState::ProcessDisplayItems(nsDisplayList* aList) {
if (itemType == DisplayItemType::TYPE_FIXED_POSITION) {
newLayerEntry->mIsFixedToRootScrollFrame =
item->Frame()->StyleDisplay()->mPosition ==
NS_STYLE_POSITION_FIXED &&
StylePositionProperty::Fixed &&
nsLayoutUtils::IsReallyFixedPos(item->Frame());
}

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

@ -2064,7 +2064,8 @@ const nsIFrame* nsDisplayListBuilder::FindReferenceFrameFor(
// Sticky frames are active if their nearest scrollable frame is also active.
static bool IsStickyFrameActive(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsIFrame* aParent) {
MOZ_ASSERT(aFrame->StyleDisplay()->mPosition == NS_STYLE_POSITION_STICKY);
MOZ_ASSERT(aFrame->StyleDisplay()->mPosition ==
static_cast<uint8_t>(StylePositionProperty::Sticky));
// Find the nearest scrollframe.
nsIScrollableFrame* sf = nsLayoutUtils::GetNearestScrollableFrame(
@ -2101,7 +2102,7 @@ nsDisplayListBuilder::AGRState nsDisplayListBuilder::IsAnimatedGeometryRoot(
return AGR_YES;
}
if (aFrame->StyleDisplay()->mPosition == NS_STYLE_POSITION_STICKY &&
if (aFrame->StyleDisplay()->mPosition == StylePositionProperty::Sticky &&
IsStickyFrameActive(this, aFrame, parent)) {
aIsAsync = true;
return AGR_YES;
@ -7960,7 +7961,8 @@ void nsDisplayTransform::SetReferenceFrameToAncestor(
// determine if we are inside a fixed pos subtree. If we use the outer AGR
// from outside the fixed pos subtree FLB can't tell that we are fixed pos.
mAnimatedGeometryRoot = mAnimatedGeometryRootForChildren;
} else if (mFrame->StyleDisplay()->mPosition == NS_STYLE_POSITION_STICKY &&
} else if (mFrame->StyleDisplay()->mPosition ==
StylePositionProperty::Sticky &&
IsStickyFrameActive(aBuilder, mFrame, nullptr)) {
// Similar to the IsFixedPosFrameInDisplayPort case we are our own AGR.
// We are inside the sticky position, so our AGR is the sticky positioned

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

@ -123,6 +123,7 @@ rusty-enums = [
"mozilla::StyleUserSelect",
"mozilla::StyleImageLayerRepeat",
"mozilla::StyleImageLayerAttachment",
"mozilla::StylePositionProperty",
"mozilla::StyleBoxDecorationBreak",
"mozilla::StyleBorderStyle",
"mozilla::StyleRuleInclusion",

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

@ -939,7 +939,7 @@ bool nsComputedDOMStyle::NeedsToFlushLayout(nsCSSPropertyID aPropID) const {
case eCSSProperty_bottom:
case eCSSProperty_left:
// Doing better than this is actually hard.
return style->StyleDisplay()->mPosition != NS_STYLE_POSITION_STATIC;
return style->StyleDisplay()->mPosition != StylePositionProperty::Static;
case eCSSProperty_padding_top:
case eCSSProperty_padding_right:
case eCSSProperty_padding_bottom:
@ -1983,25 +1983,25 @@ already_AddRefed<CSSValue> nsComputedDOMStyle::GetOffsetWidthFor(
mozilla::Side aSide) {
const nsStyleDisplay* display = StyleDisplay();
uint8_t position = display->mPosition;
mozilla::StylePositionProperty position = display->mPosition;
if (!mOuterFrame) {
// GetNonStaticPositionOffset or GetAbsoluteOffset don't handle elements
// without frames in any sensible way. GetStaticOffset, however, is perfect
// for that case.
position = NS_STYLE_POSITION_STATIC;
position = StylePositionProperty::Static;
}
switch (position) {
case NS_STYLE_POSITION_STATIC:
case StylePositionProperty::Static:
return GetStaticOffset(aSide);
case NS_STYLE_POSITION_STICKY:
case StylePositionProperty::Sticky:
return GetNonStaticPositionOffset(
aSide, false, &nsComputedDOMStyle::GetScrollFrameContentWidth,
&nsComputedDOMStyle::GetScrollFrameContentHeight);
case NS_STYLE_POSITION_ABSOLUTE:
case NS_STYLE_POSITION_FIXED:
case StylePositionProperty::Absolute:
case StylePositionProperty::Fixed:
return GetAbsoluteOffset(aSide);
case NS_STYLE_POSITION_RELATIVE:
case StylePositionProperty::Relative:
return GetNonStaticPositionOffset(
aSide, true, &nsComputedDOMStyle::GetCBContentWidth,
&nsComputedDOMStyle::GetCBContentHeight);

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

@ -432,11 +432,13 @@ enum class StyleGridTrackBreadth : uint8_t {
#define NS_MATHML_DISPLAYSTYLE_BLOCK 1
// See nsStyleDisplay.mPosition
#define NS_STYLE_POSITION_STATIC 0
#define NS_STYLE_POSITION_RELATIVE 1
#define NS_STYLE_POSITION_ABSOLUTE 2
#define NS_STYLE_POSITION_FIXED 3
#define NS_STYLE_POSITION_STICKY 4
enum class StylePositionProperty : uint8_t {
Static,
Relative,
Absolute,
Fixed,
Sticky,
};
// See nsStyleEffects.mClip, mClipFlags
#define NS_STYLE_CLIP_AUTO 0x00
@ -623,8 +625,8 @@ enum class StyleTableLayout : uint8_t {
};
enum class StyleEmptyCells : uint8_t {
Hide,
Show,
Hide,
Show,
};
// Constants for the caption-side property. Note that despite having "physical"

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

@ -2673,7 +2673,7 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument)
mOriginalDisplay(StyleDisplay::Inline),
mContain(StyleContain::NONE),
mAppearance(StyleAppearance::None),
mPosition(NS_STYLE_POSITION_STATIC),
mPosition(StylePositionProperty::Static),
mFloat(StyleFloat::None),
mBreakType(StyleClear::None),
mBreakInside(StyleBreakWithin::Auto),

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

@ -1504,7 +1504,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
// mDisplay
mozilla::StyleContain mContain;
mozilla::StyleAppearance mAppearance;
uint8_t mPosition; // NS_STYLE_POSITION_*
mozilla::StylePositionProperty mPosition;
mozilla::StyleFloat mFloat;
mozilla::StyleClear mBreakType;
@ -1691,20 +1691,20 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
bool IsFloatingStyle() const { return mozilla::StyleFloat::None != mFloat; }
bool IsAbsolutelyPositionedStyle() const {
return NS_STYLE_POSITION_ABSOLUTE == mPosition ||
NS_STYLE_POSITION_FIXED == mPosition;
return mozilla::StylePositionProperty::Absolute == mPosition ||
mozilla::StylePositionProperty::Fixed == mPosition;
}
bool IsRelativelyPositionedStyle() const {
return NS_STYLE_POSITION_RELATIVE == mPosition ||
NS_STYLE_POSITION_STICKY == mPosition;
return mozilla::StylePositionProperty::Relative == mPosition ||
mozilla::StylePositionProperty::Sticky == mPosition;
}
bool IsStickyPositionedStyle() const {
return NS_STYLE_POSITION_STICKY == mPosition;
return mozilla::StylePositionProperty::Sticky == mPosition;
}
bool IsPositionForcingStackingContext() const {
return NS_STYLE_POSITION_STICKY == mPosition ||
NS_STYLE_POSITION_FIXED == mPosition;
return mozilla::StylePositionProperty::Sticky == mPosition ||
mozilla::StylePositionProperty::Fixed == mPosition;
}
static bool IsRubyDisplayType(mozilla::StyleDisplay aDisplay) {

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

@ -47,6 +47,7 @@ ${helpers.single_keyword(
values="static absolute relative fixed ${'sticky' if engine in ['gecko', 'servo-2013'] else ''}"
engines="gecko servo-2013 servo-2020"
animation_value_type="discrete"
gecko_enum_prefix="StylePositionProperty"
flags="CREATES_STACKING_CONTEXT ABSPOS_CB"
spec="https://drafts.csswg.org/css-position/#position-property"
servo_restyle_damage="rebuild_and_reflow"