diff options
author | Moonchild <moonchild@palemoon.org> | 2019-07-11 14:57:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-11 14:57:46 +0000 |
commit | 69970c911be3c9189006c61fea7c059bf4f7e005 (patch) | |
tree | 897c26912343bbc34a3820bc2e3a9a2030ab4781 /layout/generic | |
parent | 04a7c6bb4e4048369e0a635dc02e9d83bbd59f87 (diff) | |
parent | 570cad82795beeb1eb7011c09be295afa11373ce (diff) | |
download | UXP-69970c911be3c9189006c61fea7c059bf4f7e005.tar UXP-69970c911be3c9189006c61fea7c059bf4f7e005.tar.gz UXP-69970c911be3c9189006c61fea7c059bf4f7e005.tar.lz UXP-69970c911be3c9189006c61fea7c059bf4f7e005.tar.xz UXP-69970c911be3c9189006c61fea7c059bf4f7e005.zip |
Merge pull request #1171 from win7-7/FrameProperties-iterate-once-pr
Iterate the frame property list once to collect which child list properties we have
Diffstat (limited to 'layout/generic')
-rw-r--r-- | layout/generic/nsContainerFrame.cpp | 89 |
1 files changed, 53 insertions, 36 deletions
diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 2933ac4cf..abf687c9b 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -219,24 +219,49 @@ nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot) // Destroy frames on the principal child list. mFrames.DestroyFramesFrom(aDestructRoot); + + if (MOZ_UNLIKELY(!mProperties.IsEmpty())) { + using T = mozilla::FrameProperties::UntypedDescriptor; + bool hasO = false, hasOC = false, hasEOC = false, hasBackdrop = false; + mProperties.ForEach([&] (const T& aProp, void*) { + if (aProp == OverflowProperty()) { + hasO = true; + } else if (aProp == OverflowContainersProperty()) { + hasOC = true; + } else if (aProp == ExcessOverflowContainersProperty()) { + hasEOC = true; + } else if (aProp == BackdropProperty()) { + hasBackdrop = true; + } + return true; + }); + // Destroy frames on the auxiliary frame lists and delete the lists. nsPresContext* pc = PresContext(); nsIPresShell* shell = pc->PresShell(); - SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); + if (hasO) { + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); + } - MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers) || - !(GetProperty(nsContainerFrame::OverflowContainersProperty()) || - GetProperty(nsContainerFrame::ExcessOverflowContainersProperty())), - "this type of frame should't have overflow containers"); - SafelyDestroyFrameListProp(aDestructRoot, shell, - OverflowContainersProperty()); - SafelyDestroyFrameListProp(aDestructRoot, shell, - ExcessOverflowContainersProperty()); + MOZ_ASSERT(IsFrameOfType(eCanContainOverflowContainers) || + !(hasOC || hasEOC), + "this type of frame shouldn't have overflow containers"); + if (hasOC) { + SafelyDestroyFrameListProp(aDestructRoot, shell, + OverflowContainersProperty()); + } + if (hasEOC) { + SafelyDestroyFrameListProp(aDestructRoot, shell, + ExcessOverflowContainersProperty()); + } MOZ_ASSERT(!GetProperty(BackdropProperty()) || StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE, "only top layer frame may have backdrop"); - SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); + if (hasBackdrop) { + SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); + } +} nsSplittableFrame::DestroyFrom(aDestructRoot); } @@ -274,36 +299,28 @@ nsContainerFrame::GetChildList(ChildListID aListID) const } } -static void -AppendIfNonempty(const nsIFrame* aFrame, - nsContainerFrame::FrameListPropertyDescriptor aProperty, - nsTArray<nsIFrame::ChildList>* aLists, - nsIFrame::ChildListID aListID) -{ - if (nsFrameList* list = aFrame->GetProperty(aProperty)) { - list->AppendIfNonempty(aLists, aListID); - } -} - void nsContainerFrame::GetChildLists(nsTArray<ChildList>* aLists) const { mFrames.AppendIfNonempty(aLists, kPrincipalList); - ::AppendIfNonempty(this, OverflowProperty(), - aLists, kOverflowList); - if (IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) { - ::AppendIfNonempty(this, OverflowContainersProperty(), - aLists, kOverflowContainersList); - ::AppendIfNonempty(this, ExcessOverflowContainersProperty(), - aLists, kExcessOverflowContainersList); - } - // Bypass BackdropProperty hashtable lookup for any in-flow frames - // since frames in the top layer (only which can have backdrop) are - // definitely out-of-flow. - if (GetStateBits() & NS_FRAME_OUT_OF_FLOW) { - ::AppendIfNonempty(this, BackdropProperty(), - aLists, kBackdropList); - } + using T = mozilla::FrameProperties::UntypedDescriptor; + mProperties.ForEach([this, aLists] (const T& aProp, void* aValue) { + typedef const nsFrameList* L; + if (aProp == OverflowProperty()) { + L(aValue)->AppendIfNonempty(aLists, kOverflowList); + } else if (aProp == OverflowContainersProperty()) { + MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers), + "found unexpected OverflowContainersProperty"); + L(aValue)->AppendIfNonempty(aLists, kOverflowContainersList); + } else if (aProp == ExcessOverflowContainersProperty()) { + MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers), + "found unexpected ExcessOverflowContainersProperty"); + L(aValue)->AppendIfNonempty(aLists, kExcessOverflowContainersList); + } else if (aProp == BackdropProperty()) { + L(aValue)->AppendIfNonempty(aLists, kBackdropList); + } + return true; + }); nsSplittableFrame::GetChildLists(aLists); } |