зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1515192 - Replace handcrafted FrameChildListIDs class with EnumSet. r=mats
The following APIs are changed. 1. Contains() needs to become contains(). (EnumSet's methods have lowercase names.) 2. Use list constructor rather than "|" like a plain enum. 3. Use operator+= instead of operator|=. Differential Revision: https://phabricator.services.mozilla.com/D14908 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3fea89ee22
Коммит
6cf6eb81f5
|
@ -5563,11 +5563,11 @@ void PresShell::MarkFramesInSubtreeApproximatelyVisible(
|
|||
bool preserves3DChildren = aFrame->Extend3DContext();
|
||||
|
||||
// We assume all frames in popups are visible, so we skip them here.
|
||||
const nsIFrame::ChildListIDs skip(nsIFrame::kPopupList |
|
||||
nsIFrame::kSelectPopupList);
|
||||
const nsIFrame::ChildListIDs skip = {nsIFrame::kPopupList,
|
||||
nsIFrame::kSelectPopupList};
|
||||
for (nsIFrame::ChildListIterator childLists(aFrame); !childLists.IsDone();
|
||||
childLists.Next()) {
|
||||
if (skip.Contains(childLists.CurrentID())) {
|
||||
if (skip.contains(childLists.CurrentID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -522,11 +522,12 @@ void nsLayoutUtils::UnionChildOverflow(nsIFrame* aFrame,
|
|||
nsOverflowAreas& aOverflowAreas,
|
||||
FrameChildListIDs aSkipChildLists) {
|
||||
// Iterate over all children except pop-ups.
|
||||
FrameChildListIDs skip =
|
||||
aSkipChildLists | nsIFrame::kSelectPopupList | nsIFrame::kPopupList;
|
||||
FrameChildListIDs skip(aSkipChildLists);
|
||||
skip += {nsIFrame::kSelectPopupList, nsIFrame::kPopupList};
|
||||
|
||||
for (nsIFrame::ChildListIterator childLists(aFrame); !childLists.IsDone();
|
||||
childLists.Next()) {
|
||||
if (skip.Contains(childLists.CurrentID())) {
|
||||
if (skip.contains(childLists.CurrentID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -6168,18 +6169,18 @@ static nscoord CalculateBlockContentBEnd(WritingMode aWM,
|
|||
// calculation is intended to affect layout.
|
||||
LogicalSize overflowSize(aWM, aFrame->GetScrollableOverflowRect().Size());
|
||||
if (overflowSize.BSize(aWM) > contentBEnd) {
|
||||
nsIFrame::ChildListIDs skip(nsIFrame::kOverflowList |
|
||||
nsIFrame::kExcessOverflowContainersList |
|
||||
nsIFrame::kOverflowOutOfFlowList);
|
||||
nsIFrame::ChildListIDs skip = {nsIFrame::kOverflowList,
|
||||
nsIFrame::kExcessOverflowContainersList,
|
||||
nsIFrame::kOverflowOutOfFlowList};
|
||||
nsBlockFrame* blockFrame = GetAsBlock(aFrame);
|
||||
if (blockFrame) {
|
||||
contentBEnd =
|
||||
std::max(contentBEnd, CalculateBlockContentBEnd(aWM, blockFrame));
|
||||
skip |= nsIFrame::kPrincipalList;
|
||||
skip += nsIFrame::kPrincipalList;
|
||||
}
|
||||
nsIFrame::ChildListIterator lists(aFrame);
|
||||
for (; !lists.IsDone(); lists.Next()) {
|
||||
if (!skip.Contains(lists.CurrentID())) {
|
||||
if (!skip.contains(lists.CurrentID())) {
|
||||
nsFrameList::Enumerator childFrames(lists.CurrentList());
|
||||
for (; !childFrames.AtEnd(); childFrames.Next()) {
|
||||
nsIFrame* child = childFrames.get();
|
||||
|
|
|
@ -115,10 +115,10 @@ void DetailsFrame::AppendAnonymousContentTo(nsTArray<nsIContent*>& aElements,
|
|||
}
|
||||
|
||||
bool DetailsFrame::HasMainSummaryFrame(nsIFrame* aSummaryFrame) {
|
||||
const ChildListIDs flowLists(kPrincipalList | kOverflowList);
|
||||
const ChildListIDs flowLists = {kPrincipalList, kOverflowList};
|
||||
for (nsIFrame* frag = this; frag; frag = frag->GetNextInFlow()) {
|
||||
for (ChildListIterator lists(frag); !lists.IsDone(); lists.Next()) {
|
||||
if (!flowLists.Contains(lists.CurrentID())) {
|
||||
if (!flowLists.contains(lists.CurrentID())) {
|
||||
continue;
|
||||
}
|
||||
for (nsIFrame* child : lists.CurrentList()) {
|
||||
|
|
|
@ -19,8 +19,8 @@ FrameChildListIterator::FrameChildListIterator(const nsIFrame* aFrame)
|
|||
FrameChildListIDs ids;
|
||||
uint32_t count = mLists.Length();
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
NS_ASSERTION(!ids.Contains(mLists[i].mID), "Duplicate item found!");
|
||||
ids |= mLists[i].mID;
|
||||
NS_ASSERTION(!ids.contains(mLists[i].mID), "Duplicate item found!");
|
||||
ids += mLists[i].mID;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef FrameChildList_h_
|
||||
#define FrameChildList_h_
|
||||
|
||||
#include "mozilla/EnumSet.h"
|
||||
#include "nsFrameList.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
|
@ -21,35 +22,7 @@ namespace layout {
|
|||
extern const char* ChildListName(FrameChildListID aListID);
|
||||
#endif
|
||||
|
||||
class FrameChildListIDs {
|
||||
friend class FrameChildListIterator;
|
||||
|
||||
public:
|
||||
FrameChildListIDs() : mIDs(0) {}
|
||||
FrameChildListIDs(const FrameChildListIDs& aOther) : mIDs(aOther.mIDs) {}
|
||||
MOZ_IMPLICIT FrameChildListIDs(FrameChildListID aListID) : mIDs(aListID) {}
|
||||
|
||||
FrameChildListIDs operator|(FrameChildListIDs aOther) const {
|
||||
return FrameChildListIDs(mIDs | aOther.mIDs);
|
||||
}
|
||||
FrameChildListIDs& operator|=(FrameChildListIDs aOther) {
|
||||
mIDs |= aOther.mIDs;
|
||||
return *this;
|
||||
}
|
||||
bool operator==(FrameChildListIDs aOther) const {
|
||||
return mIDs == aOther.mIDs;
|
||||
}
|
||||
bool operator!=(const FrameChildListIDs& aOther) const {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
bool Contains(FrameChildListIDs aOther) const {
|
||||
return (mIDs & aOther.mIDs) == aOther.mIDs;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit FrameChildListIDs(uint32_t aIDs) : mIDs(aIDs) {}
|
||||
uint32_t mIDs;
|
||||
};
|
||||
using FrameChildListIDs = EnumSet<FrameChildListID>;
|
||||
|
||||
class FrameChildList {
|
||||
public:
|
||||
|
@ -97,19 +70,6 @@ class MOZ_STACK_CLASS FrameChildListIterator
|
|||
AutoTArray<FrameChildList, 4> mLists;
|
||||
};
|
||||
|
||||
inline mozilla::layout::FrameChildListIDs operator|(
|
||||
mozilla::layout::FrameChildListID aLeftOp,
|
||||
mozilla::layout::FrameChildListID aRightOp) {
|
||||
return mozilla::layout::FrameChildListIDs(aLeftOp) |
|
||||
mozilla::layout::FrameChildListIDs(aRightOp);
|
||||
}
|
||||
|
||||
inline mozilla::layout::FrameChildListIDs operator|(
|
||||
mozilla::layout::FrameChildListID aLeftOp,
|
||||
const mozilla::layout::FrameChildListIDs& aRightOp) {
|
||||
return mozilla::layout::FrameChildListIDs(aLeftOp) | aRightOp;
|
||||
}
|
||||
|
||||
} // namespace layout
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
|
@ -415,9 +415,9 @@ void nsBlockFrame::List(FILE* out, const char* aPrefix, uint32_t aFlags) const {
|
|||
// skip the principal list - we printed the lines above
|
||||
// skip the overflow list - we printed the overflow lines above
|
||||
ChildListIterator lists(this);
|
||||
ChildListIDs skip(kPrincipalList | kOverflowList);
|
||||
ChildListIDs skip = {kPrincipalList, kOverflowList};
|
||||
for (; !lists.IsDone(); lists.Next()) {
|
||||
if (skip.Contains(lists.CurrentID())) {
|
||||
if (skip.contains(lists.CurrentID())) {
|
||||
continue;
|
||||
}
|
||||
fprintf_stderr(out, "%s%s %p <\n", pfx.get(),
|
||||
|
@ -1820,7 +1820,7 @@ void nsBlockFrame::UnionChildOverflow(nsOverflowAreas& aOverflowAreas) {
|
|||
// Union with child frames, skipping the principal and float lists
|
||||
// since we already handled those using the line boxes.
|
||||
nsLayoutUtils::UnionChildOverflow(this, aOverflowAreas,
|
||||
kPrincipalList | kFloatList);
|
||||
{kPrincipalList, kFloatList});
|
||||
}
|
||||
|
||||
bool nsBlockFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) {
|
||||
|
|
|
@ -8681,12 +8681,12 @@ static nsRect UnionBorderBoxes(
|
|||
|
||||
// Iterate over all children except pop-up, absolutely-positioned, and
|
||||
// float ones.
|
||||
const nsIFrame::ChildListIDs skip(
|
||||
nsIFrame::kPopupList | nsIFrame::kSelectPopupList |
|
||||
nsIFrame::kAbsoluteList | nsIFrame::kFixedList | nsIFrame::kFloatList);
|
||||
const nsIFrame::ChildListIDs skip = {
|
||||
nsIFrame::kPopupList, nsIFrame::kSelectPopupList, nsIFrame::kAbsoluteList,
|
||||
nsIFrame::kFixedList, nsIFrame::kFloatList};
|
||||
for (nsIFrame::ChildListIterator childLists(aFrame); !childLists.IsDone();
|
||||
childLists.Next()) {
|
||||
if (skip.Contains(childLists.CurrentID())) {
|
||||
if (skip.contains(childLists.CurrentID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,24 +31,24 @@ namespace layout {
|
|||
class FrameChildList;
|
||||
enum FrameChildListID {
|
||||
// The individual concrete child lists.
|
||||
kPrincipalList = 0x1,
|
||||
kPopupList = 0x2,
|
||||
kCaptionList = 0x4,
|
||||
kColGroupList = 0x8,
|
||||
kSelectPopupList = 0x10,
|
||||
kAbsoluteList = 0x20,
|
||||
kFixedList = 0x40,
|
||||
kOverflowList = 0x80,
|
||||
kOverflowContainersList = 0x100,
|
||||
kExcessOverflowContainersList = 0x200,
|
||||
kOverflowOutOfFlowList = 0x400,
|
||||
kFloatList = 0x800,
|
||||
kBulletList = 0x1000,
|
||||
kPushedFloatsList = 0x2000,
|
||||
kBackdropList = 0x4000,
|
||||
kPrincipalList,
|
||||
kPopupList,
|
||||
kCaptionList,
|
||||
kColGroupList,
|
||||
kSelectPopupList,
|
||||
kAbsoluteList,
|
||||
kFixedList,
|
||||
kOverflowList,
|
||||
kOverflowContainersList,
|
||||
kExcessOverflowContainersList,
|
||||
kOverflowOutOfFlowList,
|
||||
kFloatList,
|
||||
kBulletList,
|
||||
kPushedFloatsList,
|
||||
kBackdropList,
|
||||
// A special alias for kPrincipalList that suppress the reflow request that
|
||||
// is normally done when manipulating child lists.
|
||||
kNoReflowPrincipalList = 0x8000
|
||||
kNoReflowPrincipalList,
|
||||
};
|
||||
|
||||
// A helper class for nsIFrame::Destroy[From]. It's defined here because
|
||||
|
|
|
@ -866,10 +866,10 @@ static void GetScrollableOverflowForPerspective(
|
|||
nsIFrame* aScrolledFrame, nsIFrame* aCurrentFrame, const nsRect aScrollPort,
|
||||
nsPoint aOffset, nsRect& aScrolledFrameOverflowArea) {
|
||||
// Iterate over all children except pop-ups.
|
||||
FrameChildListIDs skip = nsIFrame::kSelectPopupList | nsIFrame::kPopupList;
|
||||
FrameChildListIDs skip = {nsIFrame::kSelectPopupList, nsIFrame::kPopupList};
|
||||
for (nsIFrame::ChildListIterator childLists(aCurrentFrame);
|
||||
!childLists.IsDone(); childLists.Next()) {
|
||||
if (skip.Contains(childLists.CurrentID())) {
|
||||
if (skip.contains(childLists.CurrentID())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -6300,12 +6300,12 @@ void nsGridContainerFrame::InsertFrames(ChildListID aListID,
|
|||
void nsGridContainerFrame::RemoveFrame(ChildListID aListID,
|
||||
nsIFrame* aOldFrame) {
|
||||
#ifdef DEBUG
|
||||
ChildListIDs supportedLists =
|
||||
kAbsoluteList | kFixedList | kPrincipalList | kNoReflowPrincipalList;
|
||||
ChildListIDs supportedLists = {kAbsoluteList, kFixedList, kPrincipalList,
|
||||
kNoReflowPrincipalList};
|
||||
// We don't handle the kBackdropList frames in any way, but it only contains
|
||||
// a placeholder for ::backdrop which is OK to not reflow (for now anyway).
|
||||
supportedLists |= kBackdropList;
|
||||
MOZ_ASSERT(supportedLists.Contains(aListID), "unexpected child list");
|
||||
supportedLists += kBackdropList;
|
||||
MOZ_ASSERT(supportedLists.contains(aListID), "unexpected child list");
|
||||
|
||||
// Note that kPrincipalList doesn't mean aOldFrame must be on that list.
|
||||
// It can also be on kOverflowList, in which case it might be a pushed
|
||||
|
@ -6504,12 +6504,12 @@ nsresult nsGridContainerFrame::GetFrameName(nsAString& aResult) const {
|
|||
void nsGridContainerFrame::NoteNewChildren(ChildListID aListID,
|
||||
const nsFrameList& aFrameList) {
|
||||
#ifdef DEBUG
|
||||
ChildListIDs supportedLists =
|
||||
kAbsoluteList | kFixedList | kPrincipalList | kNoReflowPrincipalList;
|
||||
ChildListIDs supportedLists = {kAbsoluteList, kFixedList, kPrincipalList,
|
||||
kNoReflowPrincipalList};
|
||||
// We don't handle the kBackdropList frames in any way, but it only contains
|
||||
// a placeholder for ::backdrop which is OK to not reflow (for now anyway).
|
||||
supportedLists |= kBackdropList;
|
||||
MOZ_ASSERT(supportedLists.Contains(aListID), "unexpected child list");
|
||||
supportedLists += kBackdropList;
|
||||
MOZ_ASSERT(supportedLists.contains(aListID), "unexpected child list");
|
||||
#endif
|
||||
|
||||
nsIPresShell* shell = PresShell();
|
||||
|
@ -6620,28 +6620,28 @@ nsGridContainerFrame::FindLastItemInGridOrder(
|
|||
void nsGridContainerFrame::SetInitialChildList(ChildListID aListID,
|
||||
nsFrameList& aChildList) {
|
||||
#ifdef DEBUG
|
||||
ChildListIDs supportedLists = kAbsoluteList | kFixedList | kPrincipalList;
|
||||
ChildListIDs supportedLists = {kAbsoluteList, kFixedList, kPrincipalList};
|
||||
// We don't handle the kBackdropList frames in any way, but it only contains
|
||||
// a placeholder for ::backdrop which is OK to not reflow (for now anyway).
|
||||
supportedLists |= kBackdropList;
|
||||
MOZ_ASSERT(supportedLists.Contains(aListID), "unexpected child list");
|
||||
supportedLists += kBackdropList;
|
||||
MOZ_ASSERT(supportedLists.contains(aListID), "unexpected child list");
|
||||
#endif
|
||||
|
||||
return nsContainerFrame::SetInitialChildList(aListID, aChildList);
|
||||
}
|
||||
|
||||
void nsGridContainerFrame::SanityCheckGridItemsBeforeReflow() const {
|
||||
ChildListIDs absLists = kAbsoluteList | kFixedList | kOverflowContainersList |
|
||||
kExcessOverflowContainersList;
|
||||
ChildListIDs itemLists = kPrincipalList | kOverflowList;
|
||||
ChildListIDs absLists = {kAbsoluteList, kFixedList, kOverflowContainersList,
|
||||
kExcessOverflowContainersList};
|
||||
ChildListIDs itemLists = {kPrincipalList, kOverflowList};
|
||||
for (const nsIFrame* f = this; f; f = f->GetNextInFlow()) {
|
||||
MOZ_ASSERT(!f->HasAnyStateBits(NS_STATE_GRID_DID_PUSH_ITEMS),
|
||||
"At start of reflow, we should've pulled items back from all "
|
||||
"NIFs and cleared NS_STATE_GRID_DID_PUSH_ITEMS in the process");
|
||||
for (nsIFrame::ChildListIterator childLists(f); !childLists.IsDone();
|
||||
childLists.Next()) {
|
||||
if (!itemLists.Contains(childLists.CurrentID())) {
|
||||
MOZ_ASSERT(absLists.Contains(childLists.CurrentID()) ||
|
||||
if (!itemLists.contains(childLists.CurrentID())) {
|
||||
MOZ_ASSERT(absLists.contains(childLists.CurrentID()) ||
|
||||
childLists.CurrentID() == kBackdropList,
|
||||
"unexpected non-empty child list");
|
||||
continue;
|
||||
|
|
Загрузка…
Ссылка в новой задаче