зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1272409 - Part 4: Integrate ResizeObserver with Document and reflow. r=dholbert,smaug
Depends on D27617 Differential Revision: https://phabricator.services.mozilla.com/D27618 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b2dd73fd98
Коммит
6e5ad8de80
|
@ -76,6 +76,8 @@
|
|||
#include "mozilla/dom/Navigator.h"
|
||||
#include "mozilla/dom/Performance.h"
|
||||
#include "mozilla/dom/TreeOrderedArrayInlines.h"
|
||||
#include "mozilla/dom/ResizeObserver.h"
|
||||
#include "mozilla/dom/ResizeObserverController.h"
|
||||
#include "mozilla/dom/ServiceWorkerContainer.h"
|
||||
#include "mozilla/dom/ScriptLoader.h"
|
||||
#include "mozilla/dom/ShadowIncludingTreeIterator.h"
|
||||
|
@ -1739,6 +1741,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(Document)
|
|||
cb.NoteXPCOMChild(mql);
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp->mResizeObserverController) {
|
||||
tmp->mResizeObserverController->Traverse(cb);
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(Document)
|
||||
|
@ -1850,6 +1856,10 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Document)
|
|||
}
|
||||
|
||||
tmp->mInUnlinkOrDeletion = false;
|
||||
|
||||
if (tmp->mResizeObserverController) {
|
||||
tmp->mResizeObserverController->Unlink();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
nsresult Document::Init() {
|
||||
|
@ -12443,6 +12453,22 @@ FlashClassification Document::DocumentFlashClassification() {
|
|||
return mFlashClassification;
|
||||
}
|
||||
|
||||
void Document::AddResizeObserver(ResizeObserver* aResizeObserver) {
|
||||
if (!mResizeObserverController) {
|
||||
mResizeObserverController = MakeUnique<ResizeObserverController>(this);
|
||||
}
|
||||
|
||||
mResizeObserverController->AddResizeObserver(aResizeObserver);
|
||||
}
|
||||
|
||||
void Document::ScheduleResizeObserversNotification() const {
|
||||
if (!mResizeObserverController) {
|
||||
return;
|
||||
}
|
||||
|
||||
mResizeObserverController->ScheduleNotification();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes |mIsThirdPartyForFlashClassifier| if necessary and returns its
|
||||
* value. The value returned represents whether this document should be
|
||||
|
|
|
@ -243,6 +243,8 @@ namespace dom {
|
|||
|
||||
class Document;
|
||||
class DOMStyleSheetSetList;
|
||||
class ResizeObserver;
|
||||
class ResizeObserverController;
|
||||
|
||||
// Document states
|
||||
|
||||
|
@ -3535,6 +3537,10 @@ class Document : public nsINode,
|
|||
// toolkit/components/url-classifier/flash-block-lists.rst
|
||||
FlashClassification DocumentFlashClassification();
|
||||
|
||||
// ResizeObserver usage.
|
||||
void AddResizeObserver(ResizeObserver* aResizeObserver);
|
||||
void ScheduleResizeObserversNotification() const;
|
||||
|
||||
/**
|
||||
* Localization
|
||||
*
|
||||
|
@ -4024,6 +4030,8 @@ class Document : public nsINode,
|
|||
|
||||
RefPtr<FeaturePolicy> mFeaturePolicy;
|
||||
|
||||
UniquePtr<ResizeObserverController> mResizeObserverController;
|
||||
|
||||
// True if BIDI is enabled.
|
||||
bool mBidiEnabled : 1;
|
||||
// True if we may need to recompute the language prefs for this document.
|
||||
|
|
|
@ -80,7 +80,7 @@ already_AddRefed<ResizeObserver> ResizeObserver::Constructor(
|
|||
}
|
||||
|
||||
RefPtr<ResizeObserver> observer = new ResizeObserver(window.forget(), aCb);
|
||||
// TODO: Add the new ResizeObserver to document here in the later patch.
|
||||
document->AddResizeObserver(observer);
|
||||
|
||||
return observer.forget();
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ void ResizeObserver::Observe(Element& aTarget, ErrorResult& aRv) {
|
|||
// Per the spec, we need to trigger notification in event loop that
|
||||
// contains ResizeObserver observe call even when resize/reflow does
|
||||
// not happen.
|
||||
// TODO: Implement the notification scheduling in the later patch.
|
||||
aTarget.OwnerDoc()->ScheduleResizeObserversNotification();
|
||||
}
|
||||
|
||||
void ResizeObserver::Unobserve(Element& aTarget, ErrorResult& aRv) {
|
||||
|
|
|
@ -8987,6 +8987,10 @@ void PresShell::DidDoReflow(bool aInterruptible) {
|
|||
docShell->NotifyReflowObservers(aInterruptible, mLastReflowStart, now);
|
||||
}
|
||||
|
||||
if (!mPresContext->HasPendingInterrupt()) {
|
||||
mDocument->ScheduleResizeObserversNotification();
|
||||
}
|
||||
|
||||
if (sSynthMouseMove) {
|
||||
SynthesizeMouseMove(false);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче