Bug 1444580: Devirtualize the IntersectionObserver bits. r=smaug

MozReview-Commit-ID: 65WtMQPu7f4
This commit is contained in:
Emilio Cobos Álvarez 2018-03-10 05:45:59 +01:00
Родитель 842e5cdf17
Коммит ee333aaf7e
3 изменённых файлов: 27 добавлений и 42 удалений

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

@ -12358,21 +12358,7 @@ nsDocument::ReportUseCounters(UseCounterReportKind aKind)
}
void
nsDocument::AddIntersectionObserver(DOMIntersectionObserver* aObserver)
{
MOZ_ASSERT(!mIntersectionObservers.Contains(aObserver),
"Intersection observer already in the list");
mIntersectionObservers.PutEntry(aObserver);
}
void
nsDocument::RemoveIntersectionObserver(DOMIntersectionObserver* aObserver)
{
mIntersectionObservers.RemoveEntry(aObserver);
}
void
nsDocument::UpdateIntersectionObservations()
nsIDocument::UpdateIntersectionObservations()
{
if (mIntersectionObservers.IsEmpty()) {
return;
@ -12388,7 +12374,7 @@ nsDocument::UpdateIntersectionObservations()
nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers.Count());
for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
DOMIntersectionObserver* observer = iter.Get()->GetKey();
observers.AppendElement(observer);
observers.AppendElement(observer);
}
for (const auto& observer : observers) {
if (observer) {
@ -12398,7 +12384,7 @@ nsDocument::UpdateIntersectionObservations()
}
void
nsDocument::ScheduleIntersectionObserverNotification()
nsIDocument::ScheduleIntersectionObserverNotification()
{
if (mIntersectionObservers.IsEmpty()) {
return;
@ -12412,7 +12398,7 @@ nsDocument::ScheduleIntersectionObserverNotification()
}
void
nsDocument::NotifyIntersectionObservers()
nsIDocument::NotifyIntersectionObservers()
{
nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers.Count());
for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {

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

@ -477,18 +477,6 @@ public:
void ReportUseCounters(UseCounterReportKind aKind = UseCounterReportKind::eDefault);
virtual void AddIntersectionObserver(
mozilla::dom::DOMIntersectionObserver* aObserver) override;
virtual void RemoveIntersectionObserver(
mozilla::dom::DOMIntersectionObserver* aObserver) override;
virtual void UpdateIntersectionObservations() override;
virtual void ScheduleIntersectionObserverNotification() override;
virtual void NotifyIntersectionObservers() override;
virtual bool HasIntersectionObservers() const override
{
return !mIntersectionObservers.IsEmpty();
}
virtual void NotifyLayerManagerRecreated() override;
bool IsSynthesized();
@ -850,10 +838,6 @@ protected:
// Array of owning references to all children
nsAttrAndChildArray mChildren;
// Array of intersection observers
nsTHashtable<nsPtrHashKey<mozilla::dom::DOMIntersectionObserver>>
mIntersectionObservers;
// Tracker for animations that are waiting to start.
// nullptr until GetOrCreatePendingAnimationTracker is called.
RefPtr<mozilla::PendingAnimationTracker> mPendingAnimationTracker;

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

@ -3188,15 +3188,26 @@ public:
mozilla::dom::DocGroup* GetDocGroup() const;
virtual void AddIntersectionObserver(
mozilla::dom::DOMIntersectionObserver* aObserver) = 0;
virtual void RemoveIntersectionObserver(
mozilla::dom::DOMIntersectionObserver* aObserver) = 0;
void AddIntersectionObserver(mozilla::dom::DOMIntersectionObserver* aObserver)
{
MOZ_ASSERT(!mIntersectionObservers.Contains(aObserver),
"Intersection observer already in the list");
mIntersectionObservers.PutEntry(aObserver);
}
virtual void UpdateIntersectionObservations() = 0;
virtual void ScheduleIntersectionObserverNotification() = 0;
virtual void NotifyIntersectionObservers() = 0;
virtual bool HasIntersectionObservers() const = 0;
void RemoveIntersectionObserver(mozilla::dom::DOMIntersectionObserver* aObserver)
{
mIntersectionObservers.RemoveEntry(aObserver);
}
bool HasIntersectionObservers() const
{
return !mIntersectionObservers.IsEmpty();
}
void UpdateIntersectionObservations();
void ScheduleIntersectionObserverNotification();
void NotifyIntersectionObservers();
// Dispatch a runnable related to the document.
virtual nsresult Dispatch(mozilla::TaskCategory aCategory,
@ -3989,6 +4000,10 @@ protected:
// is a weak reference to avoid leaks due to circular references.
nsWeakPtr mScopeObject;
// Array of intersection observers
nsTHashtable<nsPtrHashKey<mozilla::dom::DOMIntersectionObserver>>
mIntersectionObservers;
nsTArray<RefPtr<mozilla::StyleSheet>> mOnDemandBuiltInUASheets;
nsTArray<RefPtr<mozilla::StyleSheet>> mAdditionalSheets[AdditionalSheetTypeCount];