Bug 1159042 - p3. Refactor mDirtyRoots type into a class - r=dbaron

As mDirtyRoots will be accessed through a more cohesive API, this patch hides
the storage details (nsTArray) -- but provides almost the same API for now.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gerald Squelart 2018-12-11 20:32:14 +00:00
Родитель bcf8270be5
Коммит c2742fa954
2 изменённых файлов: 48 добавлений и 7 удалений

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

@ -567,6 +567,32 @@ class MOZ_STACK_CLASS AutoPointerEventTargetUpdater final {
nsIContent** mTargetContent;
};
void nsIPresShell::DirtyRootsList::AppendElement(nsIFrame* aFrame) {
mList.AppendElement(aFrame);
}
void nsIPresShell::DirtyRootsList::RemoveElement(nsIFrame* aFrame) {
mList.RemoveElement(aFrame);
}
void nsIPresShell::DirtyRootsList::RemoveElements(nsIFrame* aFrame) {
mList.RemoveElementsBy([&](nsIFrame* aRoot) { return aRoot == aFrame; });
}
void nsIPresShell::DirtyRootsList::RemoveElementAt(size_t aIndex) {
return mList.RemoveElementAt(aIndex);
}
void nsIPresShell::DirtyRootsList::Clear() { mList.Clear(); }
bool nsIPresShell::DirtyRootsList::Contains(nsIFrame* aFrame) const {
return mList.Contains(aFrame);
}
bool nsIPresShell::DirtyRootsList::IsEmpty() const { return mList.IsEmpty(); }
size_t nsIPresShell::DirtyRootsList::Length() const { return mList.Length(); }
bool PresShell::sDisableNonTestMouseEvents = false;
mozilla::LazyLogModule PresShell::gLog("PresShell");
@ -2040,12 +2066,7 @@ void PresShell::NotifyDestroyingFrame(nsIFrame* aFrame) {
mFrameConstructor->NotifyDestroyingFrame(aFrame);
for (int32_t idx = mDirtyRoots.Length(); idx;) {
--idx;
if (mDirtyRoots[idx] == aFrame) {
mDirtyRoots.RemoveElementAt(idx);
}
}
mDirtyRoots.RemoveElements(aFrame);
// Remove frame properties
aFrame->DeleteAllProperties();

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

@ -1741,8 +1741,28 @@ class nsIPresShell : public nsStubDocumentObserver {
// A hash table of heap allocated weak frames.
nsTHashtable<nsPtrHashKey<WeakFrame>> mWeakFrames;
class DirtyRootsList {
public:
void AppendElement(nsIFrame* aFrame);
void RemoveElement(nsIFrame* aFrame);
void RemoveElements(nsIFrame* aFrame);
void RemoveElementAt(size_t aIndex);
void Clear();
bool Contains(nsIFrame* aFrame) const;
bool IsEmpty() const;
size_t Length() const;
auto begin() const { return mList.begin(); }
auto begin() { return mList.begin(); }
auto end() const { return mList.end(); }
auto end() { return mList.end(); }
auto& operator[](size_t i) { return mList[i]; }
private:
nsTArray<nsIFrame*> mList;
};
// Reflow roots that need to be reflowed.
nsTArray<nsIFrame*> mDirtyRoots;
DirtyRootsList mDirtyRoots;
#ifdef MOZ_GECKO_PROFILER
// These two fields capture call stacks of any changes that require a restyle