summaryrefslogtreecommitdiffstats
path: root/dom/base
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/DOMIntersectionObserver.cpp114
-rw-r--r--dom/base/DOMIntersectionObserver.h13
-rw-r--r--dom/base/Element.cpp9
-rw-r--r--dom/base/Element.h3
-rw-r--r--dom/base/FragmentOrElement.cpp6
-rw-r--r--dom/base/FragmentOrElement.h3
-rw-r--r--dom/base/Location.cpp31
-rw-r--r--dom/base/Navigator.cpp78
-rw-r--r--dom/base/Navigator.h7
-rw-r--r--dom/base/nsCCUncollectableMarker.cpp40
-rw-r--r--dom/base/nsDocument.cpp23
-rw-r--r--dom/base/nsDocument.h5
-rw-r--r--dom/base/nsFrameLoader.cpp3
-rw-r--r--dom/base/nsGlobalWindow.cpp66
-rw-r--r--dom/base/nsGlobalWindow.h22
-rw-r--r--dom/base/nsScriptLoader.cpp12
16 files changed, 171 insertions, 264 deletions
diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp
index e39abf1a6..e7b3cd0da 100644
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -43,16 +43,18 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMIntersectionObserver)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
+ tmp->Disconnect();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mQueuedEntries)
- tmp->Disconnect();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMIntersectionObserver)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueuedEntries)
@@ -153,30 +155,29 @@ DOMIntersectionObserver::Observe(Element& aTarget)
return;
}
aTarget.RegisterIntersectionObserver(this);
- mObservationTargets.PutEntry(&aTarget);
+ mObservationTargets.AppendElement(&aTarget);
Connect();
}
void
DOMIntersectionObserver::Unobserve(Element& aTarget)
{
- if (UnlinkTarget(aTarget)) {
- aTarget.UnregisterIntersectionObserver(this);
+ if (mObservationTargets.Length() == 1) {
+ Disconnect();
+ return;
}
+
+ mObservationTargets.RemoveElement(&aTarget);
+ aTarget.UnregisterIntersectionObserver(this);
}
-bool
+void
DOMIntersectionObserver::UnlinkTarget(Element& aTarget)
{
- if (!mObservationTargets.Contains(&aTarget)) {
- return false;
- }
- if (mObservationTargets.Count() == 1) {
- Disconnect();
- return false;
- }
- mObservationTargets.RemoveEntry(&aTarget);
- return true;
+ mObservationTargets.RemoveElement(&aTarget);
+ if (mObservationTargets.Length() == 0) {
+ Disconnect();
+ }
}
void
@@ -185,10 +186,11 @@ DOMIntersectionObserver::Connect()
if (mConnected) {
return;
}
+
mConnected = true;
-
- nsIDocument* document = mOwner->GetExtantDoc();
- document->AddIntersectionObserver(this);
+ if(mDocument) {
+ mDocument->AddIntersectionObserver(this);
+ }
}
void
@@ -197,18 +199,17 @@ DOMIntersectionObserver::Disconnect()
if (!mConnected) {
return;
}
- for (auto iter = mObservationTargets.Iter(); !iter.Done(); iter.Next()) {
- Element* target = iter.Get()->GetKey();
+
+ mConnected = false;
+
+ for (size_t i = 0; i < mObservationTargets.Length(); ++i) {
+ Element* target = mObservationTargets.ElementAt(i);
target->UnregisterIntersectionObserver(this);
}
mObservationTargets.Clear();
- if (mOwner) {
- nsIDocument* document = mOwner->GetExtantDoc();
- if (document) {
- document->RemoveIntersectionObserver(this);
- }
+ if (mDocument) {
+ mDocument->RemoveIntersectionObserver(this);
}
- mConnected = false;
}
void
@@ -269,17 +270,21 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
root = mRoot;
rootFrame = root->GetPrimaryFrame();
if (rootFrame) {
+ nsRect rootRectRelativeToRootFrame;
if (rootFrame->GetType() == nsGkAtoms::scrollFrame) {
+ // rootRectRelativeToRootFrame should be the content rect of rootFrame, not including the scrollbars.
nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame);
- rootRect = nsLayoutUtils::TransformFrameRectToAncestor(
- rootFrame,
- rootFrame->GetContentRectRelativeToSelf(),
- scrollFrame->GetScrolledFrame());
+ rootRectRelativeToRootFrame = scrollFrame->GetScrollPortRect();
} else {
- rootRect = nsLayoutUtils::GetAllInFlowRectsUnion(rootFrame,
- nsLayoutUtils::GetContainingBlockForClientRect(rootFrame),
- nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
+ // rootRectRelativeToRootFrame should be the border rect of rootFrame.
+ rootRectRelativeToRootFrame = rootFrame->GetRectRelativeToSelf();
}
+ nsIFrame* containingBlock =
+ nsLayoutUtils::GetContainingBlockForClientRect(rootFrame);
+ rootRect =
+ nsLayoutUtils::TransformFrameRectToAncestor(rootFrame,
+ rootRectRelativeToRootFrame,
+ containingBlock);
}
} else {
nsCOMPtr<nsIPresShell> presShell = aDocument->GetShell();
@@ -314,11 +319,12 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
rootMargin.Side(side) = nsLayoutUtils::ComputeCBDependentValue(basis, coord);
}
- for (auto iter = mObservationTargets.Iter(); !iter.Done(); iter.Next()) {
- Element* target = iter.Get()->GetKey();
+ for (size_t i = 0; i < mObservationTargets.Length(); ++i) {
+ Element* target = mObservationTargets.ElementAt(i);
nsIFrame* targetFrame = target->GetPrimaryFrame();
nsRect targetRect;
Maybe<nsRect> intersectionRect;
+ bool isSameDoc = root && root->GetComposedDoc() == target->GetComposedDoc();
if (rootFrame && targetFrame) {
// If mRoot is set we are testing intersection with a container element
@@ -327,7 +333,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
// Skip further processing of this target if it is not in the same
// Document as the intersection root, e.g. if root is an element of
// the main document and target an element from an embedded iframe.
- if (target->GetComposedDoc() != root->GetComposedDoc()) {
+ if (!isSameDoc) {
continue;
}
// Skip further processing of this target if is not a descendant of the
@@ -344,7 +350,7 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
nsLayoutUtils::GetContainingBlockForClientRect(targetFrame),
nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS
);
- intersectionRect = Some(targetFrame->GetVisualOverflowRect());
+ intersectionRect = Some(targetFrame->GetRectRelativeToSelf());
nsIFrame* containerFrame = nsLayoutUtils::GetCrossDocParentFrame(targetFrame);
while (containerFrame && containerFrame != rootFrame) {
@@ -399,29 +405,37 @@ DOMIntersectionObserver::Update(nsIDocument* aDocument, DOMHighResTimeStamp time
intersectionRectRelativeToRoot,
rootIntersectionRect
);
- if (intersectionRect.isSome()) {
- intersectionRect = Some(nsLayoutUtils::TransformFrameRectToAncestor(
- nsLayoutUtils::GetContainingBlockForClientRect(rootFrame),
- intersectionRect.value(),
- targetFrame->PresContext()->PresShell()->GetRootScrollFrame()
- ));
+ if (intersectionRect.isSome() && !isSameDoc) {
+ nsRect rect = intersectionRect.value();
+ nsPresContext* presContext = targetFrame->PresContext();
+ nsLayoutUtils::TransformRect(rootFrame,
+ presContext->PresShell()->GetRootScrollFrame(), rect);
+ intersectionRect = Some(rect);
}
}
- double targetArea = targetRect.width * targetRect.height;
- double intersectionArea = !intersectionRect ?
- 0 : intersectionRect->width * intersectionRect->height;
- double intersectionRatio = targetArea > 0.0 ? intersectionArea / targetArea : 0.0;
+ int64_t targetArea =
+ (int64_t) targetRect.Width() * (int64_t) targetRect.Height();
+ int64_t intersectionArea = !intersectionRect ? 0 :
+ (int64_t) intersectionRect->Width() *
+ (int64_t) intersectionRect->Height();
+
+ double intersectionRatio;
+ if (targetArea > 0.0) {
+ intersectionRatio = (double) intersectionArea / (double) targetArea;
+ } else {
+ intersectionRatio = intersectionRect.isSome() ? 1.0 : 0.0;
+ }
- size_t threshold = -1;
+ int32_t threshold = -1;
if (intersectionRatio > 0.0) {
if (intersectionRatio >= 1.0) {
intersectionRatio = 1.0;
- threshold = mThresholds.Length();
+ threshold = (int32_t)mThresholds.Length();
} else {
for (size_t k = 0; k < mThresholds.Length(); ++k) {
if (mThresholds[k] <= intersectionRatio) {
- threshold = k + 1;
+ threshold = (int32_t)k + 1;
} else {
break;
}
@@ -480,7 +494,7 @@ DOMIntersectionObserver::Notify()
}
mozilla::dom::Sequence<mozilla::OwningNonNull<DOMIntersectionObserverEntry>> entries;
if (entries.SetCapacity(mQueuedEntries.Length(), mozilla::fallible)) {
- for (uint32_t i = 0; i < mQueuedEntries.Length(); ++i) {
+ for (size_t i = 0; i < mQueuedEntries.Length(); ++i) {
RefPtr<DOMIntersectionObserverEntry> next = mQueuedEntries[i];
*entries.AppendElement(mozilla::fallible) = next;
}
diff --git a/dom/base/DOMIntersectionObserver.h b/dom/base/DOMIntersectionObserver.h
index 8144fc5c5..9c8ebf5b1 100644
--- a/dom/base/DOMIntersectionObserver.h
+++ b/dom/base/DOMIntersectionObserver.h
@@ -106,7 +106,10 @@ class DOMIntersectionObserver final : public nsISupports,
public:
DOMIntersectionObserver(already_AddRefed<nsPIDOMWindowInner>&& aOwner,
mozilla::dom::IntersectionCallback& aCb)
- : mOwner(aOwner), mCallback(&aCb), mConnected(false)
+ : mOwner(aOwner)
+ , mDocument(mOwner->GetExtantDoc())
+ , mCallback(&aCb)
+ , mConnected(false)
{
}
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -142,7 +145,7 @@ public:
void Observe(Element& aTarget);
void Unobserve(Element& aTarget);
- bool UnlinkTarget(Element& aTarget);
+ void UnlinkTarget(Element& aTarget);
void Disconnect();
void TakeRecords(nsTArray<RefPtr<DOMIntersectionObserverEntry>>& aRetVal);
@@ -164,11 +167,15 @@ protected:
double aIntersectionRatio);
nsCOMPtr<nsPIDOMWindowInner> mOwner;
+ RefPtr<nsIDocument> mDocument;
RefPtr<mozilla::dom::IntersectionCallback> mCallback;
RefPtr<Element> mRoot;
nsCSSRect mRootMargin;
nsTArray<double> mThresholds;
- nsTHashtable<nsPtrHashKey<Element>> mObservationTargets;
+
+ // Holds raw pointers which are explicitly cleared by UnlinkTarget().
+ nsTArray<Element*> mObservationTargets;
+
nsTArray<RefPtr<DOMIntersectionObserverEntry>> mQueuedEntries;
bool mConnected;
};
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp
index 79b36a314..67759fdb2 100644
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -145,7 +145,6 @@
#include "mozilla/dom/KeyframeEffectBinding.h"
#include "mozilla/dom/WindowBinding.h"
#include "mozilla/dom/ElementBinding.h"
-#include "mozilla/dom/VRDisplay.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Preferences.h"
#include "nsComputedDOMStyle.h"
@@ -3948,7 +3947,7 @@ Element::ClearDataset()
slots->mDataset = nullptr;
}
-nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>*
+nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>*
Element::RegisteredIntersectionObservers()
{
nsDOMSlots* slots = DOMSlots();
@@ -3963,7 +3962,7 @@ enum nsPreviousIntersectionThreshold {
void
Element::RegisterIntersectionObserver(DOMIntersectionObserver* aObserver)
{
- nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* observers =
+ nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* observers =
RegisteredIntersectionObservers();
if (observers->Contains(aObserver)) {
return;
@@ -3980,7 +3979,7 @@ Element::RegisterIntersectionObserver(DOMIntersectionObserver* aObserver)
void
Element::UnregisterIntersectionObserver(DOMIntersectionObserver* aObserver)
{
- nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* observers =
+ nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* observers =
RegisteredIntersectionObservers();
observers->Remove(aObserver);
}
@@ -3988,7 +3987,7 @@ Element::UnregisterIntersectionObserver(DOMIntersectionObserver* aObserver)
bool
Element::UpdateIntersectionObservation(DOMIntersectionObserver* aObserver, int32_t aThreshold)
{
- nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* observers =
+ nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>* observers =
RegisteredIntersectionObservers();
if (!observers->Contains(aObserver)) {
return false;
diff --git a/dom/base/Element.h b/dom/base/Element.h
index c269ab14a..ef57a6466 100644
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -1382,7 +1382,8 @@ protected:
nsDOMTokenList* GetTokenList(nsIAtom* aAtom,
const DOMTokenListSupportedTokenArray aSupportedTokens = nullptr);
- nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t>* RegisteredIntersectionObservers();
+ nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>*
+ RegisteredIntersectionObservers();
private:
/**
diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
index fde983e7c..13ba19c8c 100644
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -585,6 +585,12 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb,
mCustomElementData->mCallbackQueue[i]->Traverse(cb);
}
}
+
+ for (auto iter = mRegisteredIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
+ DOMIntersectionObserver* observer = iter.Key();
+ NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mSlots->mRegisteredIntersectionObservers[i]");
+ cb.NoteXPCOMChild(observer);
+ }
}
void
diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h
index 7c74e9cd4..f0cc29f22 100644
--- a/dom/base/FragmentOrElement.h
+++ b/dom/base/FragmentOrElement.h
@@ -354,7 +354,8 @@ public:
/**
* Registered Intersection Observers on the element.
*/
- nsDataHashtable<nsPtrHashKey<DOMIntersectionObserver>, int32_t> mRegisteredIntersectionObservers;
+ nsDataHashtable<nsRefPtrHashKey<DOMIntersectionObserver>, int32_t>
+ mRegisteredIntersectionObservers;
};
protected:
diff --git a/dom/base/Location.cpp b/dom/base/Location.cpp
index 7b3722f09..e312cffe0 100644
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -33,6 +33,7 @@
#include "nsCycleCollectionParticipant.h"
#include "nsNullPrincipal.h"
#include "ScriptSettings.h"
+#include "mozilla/Unused.h"
#include "mozilla/dom/LocationBinding.h"
namespace mozilla {
@@ -716,9 +717,15 @@ Location::SetProtocol(const nsAString& aProtocol)
return rv;
}
- rv = uri->SetScheme(NS_ConvertUTF16toUTF8(aProtocol));
+ nsAString::const_iterator start, end;
+ aProtocol.BeginReading(start);
+ aProtocol.EndReading(end);
+ nsAString::const_iterator iter(start);
+ Unused << FindCharInReadable(':', iter, end);
+
+ rv = uri->SetScheme(NS_ConvertUTF16toUTF8(Substring(start, iter)));
if (NS_WARN_IF(NS_FAILED(rv))) {
- return rv;
+ return NS_ERROR_DOM_SYNTAX_ERR;
}
nsAutoCString newSpec;
rv = uri->GetSpec(newSpec);
@@ -728,8 +735,28 @@ Location::SetProtocol(const nsAString& aProtocol)
// We may want a new URI class for the new URI, so recreate it:
rv = NS_NewURI(getter_AddRefs(uri), newSpec);
if (NS_FAILED(rv)) {
+ if (rv == NS_ERROR_MALFORMED_URI) {
+ rv = NS_ERROR_DOM_SYNTAX_ERR;
+ }
return rv;
}
+
+ bool isHttp;
+ rv = uri->SchemeIs("http", &isHttp);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
+
+ bool isHttps;
+ rv = uri->SchemeIs("https", &isHttps);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
+ return rv;
+ }
+
+ if (!isHttp && !isHttps) {
+ // No-op, per spec.
+ return NS_OK;
+ }
return SetURI(uri);
}
diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp
index 1bc4f82f4..286cd0e79 100644
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -44,7 +44,6 @@
#include "mozilla/dom/ServiceWorkerContainer.h"
#include "mozilla/dom/StorageManager.h"
#include "mozilla/dom/TCPSocket.h"
-#include "mozilla/dom/VRDisplay.h"
#include "mozilla/dom/workers/RuntimeService.h"
#include "mozilla/Hal.h"
#include "nsISiteSpecificUserAgent.h"
@@ -1471,83 +1470,6 @@ Navigator::RequestGamepadServiceTest()
}
#endif
-already_AddRefed<Promise>
-Navigator::GetVRDisplays(ErrorResult& aRv)
-{
- if (!mWindow || !mWindow->GetDocShell()) {
- aRv.Throw(NS_ERROR_UNEXPECTED);
- return nullptr;
- }
-
- nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
- win->NotifyVREventListenerAdded();
-
- nsCOMPtr<nsIGlobalObject> go = do_QueryInterface(mWindow);
- RefPtr<Promise> p = Promise::Create(go, aRv);
- if (aRv.Failed()) {
- return nullptr;
- }
-
- // We pass mWindow's id to RefreshVRDisplays, so NotifyVRDisplaysUpdated will
- // be called asynchronously, resolving the promises in mVRGetDisplaysPromises.
- if (!VRDisplay::RefreshVRDisplays(win->WindowID())) {
- p->MaybeReject(NS_ERROR_FAILURE);
- return p.forget();
- }
-
- mVRGetDisplaysPromises.AppendElement(p);
- return p.forget();
-}
-
-void
-Navigator::GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const
-{
- /**
- * Get only the active VR displays.
- * Callers do not wish to VRDisplay::RefreshVRDisplays, as the enumeration may
- * activate hardware that is not yet intended to be used.
- */
- if (!mWindow || !mWindow->GetDocShell()) {
- return;
- }
- nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
- win->NotifyVREventListenerAdded();
- nsTArray<RefPtr<VRDisplay>> displays;
- if (win->UpdateVRDisplays(displays)) {
- for (auto display : displays) {
- if (display->IsPresenting()) {
- aDisplays.AppendElement(display);
- }
- }
- }
-}
-
-void
-Navigator::NotifyVRDisplaysUpdated()
-{
- // Synchronize the VR devices and resolve the promises in
- // mVRGetDisplaysPromises
- nsGlobalWindow* win = nsGlobalWindow::Cast(mWindow);
-
- nsTArray<RefPtr<VRDisplay>> vrDisplays;
- if (win->UpdateVRDisplays(vrDisplays)) {
- for (auto p : mVRGetDisplaysPromises) {
- p->MaybeResolve(vrDisplays);
- }
- } else {
- for (auto p : mVRGetDisplaysPromises) {
- p->MaybeReject(NS_ERROR_FAILURE);
- }
- }
- mVRGetDisplaysPromises.Clear();
-}
-
-void
-Navigator::NotifyActiveVRDisplaysChanged()
-{
- NavigatorBinding::ClearCachedActiveVRDisplaysValue(this);
-}
-
//*****************************************************************************
// Navigator::nsIMozNavigatorNetwork
//*****************************************************************************
diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h
index d47a80bc1..91b7fc15c 100644
--- a/dom/base/Navigator.h
+++ b/dom/base/Navigator.h
@@ -76,7 +76,6 @@ class Connection;
class PowerManager;
class Presentation;
class LegacyMozTCPSocket;
-class VRDisplay;
class StorageManager;
namespace time {
@@ -204,8 +203,6 @@ public:
void GetGamepads(nsTArray<RefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
GamepadServiceTest* RequestGamepadServiceTest();
#endif // MOZ_GAMEPAD
- already_AddRefed<Promise> GetVRDisplays(ErrorResult& aRv);
- void GetActiveVRDisplays(nsTArray<RefPtr<VRDisplay>>& aDisplays) const;
#ifdef MOZ_TIME_MANAGER
time::TimeManager* GetMozTime(ErrorResult& aRv);
#endif // MOZ_TIME_MANAGER
@@ -269,10 +266,6 @@ private:
RefPtr<MediaKeySystemAccessManager> mMediaKeySystemAccessManager;
#endif
-public:
- void NotifyVRDisplaysUpdated();
- void NotifyActiveVRDisplaysChanged();
-
private:
virtual ~Navigator();
diff --git a/dom/base/nsCCUncollectableMarker.cpp b/dom/base/nsCCUncollectableMarker.cpp
index 861cda521..db4d0d351 100644
--- a/dom/base/nsCCUncollectableMarker.cpp
+++ b/dom/base/nsCCUncollectableMarker.cpp
@@ -188,23 +188,20 @@ MarkMessageManagers()
}
void
-MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS,
- bool aPrepareForCC)
+MarkDocument(nsIDocument* aDoc, bool aCleanupJS, bool aPrepareForCC)
{
- if (!aViewer) {
+ if (!aDoc) {
return;
}
- nsIDocument *doc = aViewer->GetDocument();
- if (doc &&
- doc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) {
- doc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
+ if (aDoc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) {
+ aDoc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
if (aCleanupJS) {
- EventListenerManager* elm = doc->GetExistingListenerManager();
+ EventListenerManager* elm = aDoc->GetExistingListenerManager();
if (elm) {
elm->MarkForCC();
}
- nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow());
+ nsCOMPtr<EventTarget> win = do_QueryInterface(aDoc->GetInnerWindow());
if (win) {
elm = win->GetExistingListenerManager();
if (elm) {
@@ -215,18 +212,27 @@ MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS,
} else if (aPrepareForCC) {
// Unfortunately we need to still mark user data just before running CC so
// that it has the right generation.
- doc->PropertyTable(DOM_USER_DATA)->
+ aDoc->PropertyTable(DOM_USER_DATA)->
EnumerateAll(MarkUserData, &nsCCUncollectableMarker::sGeneration);
}
}
- if (doc) {
- if (nsPIDOMWindowInner* inner = doc->GetInnerWindow()) {
- inner->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
- }
- if (nsPIDOMWindowOuter* outer = doc->GetWindow()) {
- outer->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
- }
+ if (nsPIDOMWindowInner* inner = aDoc->GetInnerWindow()) {
+ inner->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
+ }
+ if (nsPIDOMWindowOuter* outer = aDoc->GetWindow()) {
+ outer->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
+ }
+}
+
+void
+MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS,
+ bool aPrepareForCC)
+{
+ if (!aViewer) {
+ return;
}
+
+ MarkDocument(aViewer->GetDocument(), aCleanupJS, aPrepareForCC);
}
void MarkDocShell(nsIDocShellTreeItem* aNode, bool aCleanupJS,
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index ac9601caf..e779c060c 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1736,8 +1736,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOnDemandBuiltInUASheets)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPreloadingImages)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIntersectionObservers)
-
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSubImportLinks)
for (uint32_t i = 0; i < tmp->mFrameRequestCallbacks.Length(); ++i) {
@@ -12375,15 +12373,15 @@ nsDocument::ReportUseCounters()
void
nsDocument::AddIntersectionObserver(DOMIntersectionObserver* aObserver)
{
- NS_ASSERTION(mIntersectionObservers.IndexOf(aObserver) == nsTArray<int>::NoIndex,
- "Intersection observer already in the list");
- mIntersectionObservers.AppendElement(aObserver);
+ MOZ_ASSERT(!mIntersectionObservers.Contains(aObserver),
+ "Intersection observer already in the list");
+ mIntersectionObservers.PutEntry(aObserver);
}
void
nsDocument::RemoveIntersectionObserver(DOMIntersectionObserver* aObserver)
{
- mIntersectionObservers.RemoveElement(aObserver);
+ mIntersectionObservers.RemoveEntry(aObserver);
}
void
@@ -12396,7 +12394,8 @@ nsDocument::UpdateIntersectionObservations()
time = perf->Now();
}
}
- for (const auto& observer : mIntersectionObservers) {
+ for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
+ DOMIntersectionObserver* observer = iter.Get()->GetKey();
observer->Update(this, time);
}
}
@@ -12404,6 +12403,10 @@ nsDocument::UpdateIntersectionObservations()
void
nsDocument::ScheduleIntersectionObserverNotification()
{
+ if (mIntersectionObservers.IsEmpty()) {
+ return;
+ }
+
nsCOMPtr<nsIRunnable> notification = NewRunnableMethod(this,
&nsDocument::NotifyIntersectionObservers);
NS_DispatchToCurrentThread(notification);
@@ -12412,7 +12415,11 @@ nsDocument::ScheduleIntersectionObserverNotification()
void
nsDocument::NotifyIntersectionObservers()
{
- nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers);
+ nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers.Count());
+ for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
+ DOMIntersectionObserver* observer = iter.Get()->GetKey();
+ observers.AppendElement(observer);
+ }
for (const auto& observer : observers) {
observer->Notify();
}
diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
index 3725b3c18..d2f97a33e 100644
--- a/dom/base/nsDocument.h
+++ b/dom/base/nsDocument.h
@@ -1341,8 +1341,9 @@ protected:
// Array of observers
nsTObserverArray<nsIDocumentObserver*> mObservers;
- // Array of intersection observers
- nsTArray<RefPtr<mozilla::dom::DOMIntersectionObserver>> mIntersectionObservers;
+ // Hashtable of intersection observers
+ nsTHashtable<nsPtrHashKey<mozilla::dom::DOMIntersectionObserver>>
+ mIntersectionObservers;
// Tracker for animations that are waiting to start.
// nullptr until GetOrCreatePendingAnimationTracker is called.
diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp
index 23067becd..2804f2d4c 100644
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -588,6 +588,9 @@ nsFrameLoader::ReallyStartLoadingInternal()
flags = nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
}
+
+ // Notify that this load resulted from attribute changes.
+ loadInfo->SetIsFromProcessingFrameAttributes(true);
// Kick off the load...
bool tmpState = mNeedsAsyncDestroy;
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index 86160c77c..677e1a0ea 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -202,9 +202,6 @@
#include "mozilla/dom/GamepadManager.h"
#endif
-#include "mozilla/dom/VRDisplay.h"
-#include "mozilla/dom/VREventObserver.h"
-
#include "nsRefreshDriver.h"
#include "Layers.h"
@@ -1532,7 +1529,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
mShowFocusRingForContent(false),
mFocusByKeyOccurred(false),
mHasGamepad(false),
- mHasVREvents(false),
#ifdef MOZ_GAMEPAD
mHasSeenGamepadInput(false),
#endif
@@ -1967,12 +1963,9 @@ nsGlobalWindow::CleanUp()
if (IsInnerWindow()) {
DisableGamepadUpdates();
mHasGamepad = false;
- DisableVRUpdates();
- mHasVREvents = false;
DisableIdleCallbackRequests();
} else {
MOZ_ASSERT(!mHasGamepad);
- MOZ_ASSERT(!mHasVREvents);
}
if (mCleanMessageManager) {
@@ -2118,9 +2111,6 @@ nsGlobalWindow::FreeInnerObjects(bool aForDocumentOpen)
mHasGamepad = false;
mGamepads.Clear();
#endif
- DisableVRUpdates();
- mHasVREvents = false;
- mVRDisplays.Clear();
}
//*****************************************************************************
@@ -2275,7 +2265,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow)
#endif
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheStorage)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRDisplays)
// Traverse stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler)
@@ -2352,7 +2341,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow)
#endif
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheStorage)
- NS_IMPL_CYCLE_COLLECTION_UNLINK(mVRDisplays)
// Unlink stuff from nsPIDOMWindow
NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler)
@@ -10508,24 +10496,6 @@ nsGlobalWindow::DisableGamepadUpdates()
}
void
-nsGlobalWindow::EnableVRUpdates()
-{
- MOZ_ASSERT(IsInnerWindow());
-
- if (mHasVREvents && !mVREventObserver) {
- mVREventObserver = new VREventObserver(this);
- }
-}
-
-void
-nsGlobalWindow::DisableVRUpdates()
-{
- MOZ_ASSERT(IsInnerWindow());
-
- mVREventObserver = nullptr;
-}
-
-void
nsGlobalWindow::SetChromeEventHandler(EventTarget* aChromeEventHandler)
{
MOZ_ASSERT(IsOuterWindow());
@@ -12210,7 +12180,6 @@ nsGlobalWindow::Suspend()
ac->RemoveWindowListener(mEnabledSensors[i], this);
}
DisableGamepadUpdates();
- DisableVRUpdates();
mozilla::dom::workers::SuspendWorkersForWindow(AsInner());
@@ -12274,7 +12243,6 @@ nsGlobalWindow::Resume()
ac->AddWindowListener(mEnabledSensors[i], this);
}
EnableGamepadUpdates();
- EnableVRUpdates();
// Resume all of the AudioContexts for this window
for (uint32_t i = 0; i < mAudioContexts.Length(); ++i) {
@@ -14030,19 +13998,6 @@ nsGlobalWindow::SetHasGamepadEventListener(bool aHasGamepad/* = true*/)
void
nsGlobalWindow::EventListenerAdded(nsIAtom* aType)
{
- if (aType == nsGkAtoms::onvrdisplayconnect ||
- aType == nsGkAtoms::onvrdisplaydisconnect ||
- aType == nsGkAtoms::onvrdisplaypresentchange) {
- NotifyVREventListenerAdded();
- }
-}
-
-void
-nsGlobalWindow::NotifyVREventListenerAdded()
-{
- MOZ_ASSERT(IsInnerWindow());
- mHasVREvents = true;
- EnableVRUpdates();
}
void
@@ -14187,27 +14142,6 @@ nsGlobalWindow::SyncGamepadState()
}
#endif // MOZ_GAMEPAD
-bool
-nsGlobalWindow::UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDevices)
-{
- FORWARD_TO_INNER(UpdateVRDisplays, (aDevices), false);
-
- VRDisplay::UpdateVRDisplays(mVRDisplays, AsInner());
- aDevices = mVRDisplays;
- return true;
-}
-
-void
-nsGlobalWindow::NotifyActiveVRDisplaysChanged()
-{
- MOZ_ASSERT(IsInnerWindow());
-
- if (mNavigator) {
- mNavigator->NotifyActiveVRDisplaysChanged();
- }
-}
-
-
// nsGlobalChromeWindow implementation
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalChromeWindow)
diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h
index 80bf33b80..1cb825a77 100644
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -135,8 +135,6 @@ class SpeechSynthesis;
class TabGroup;
class Timeout;
class U2F;
-class VRDisplay;
-class VREventObserver;
class WakeLock;
#if defined(MOZ_WIDGET_ANDROID)
class WindowOrientationObserver;
@@ -745,18 +743,6 @@ public:
void EnableGamepadUpdates();
void DisableGamepadUpdates();
- // Inner windows only.
- // Enable/disable updates for VR
- void EnableVRUpdates();
- void DisableVRUpdates();
-
- // Update the VR displays for this window
- bool UpdateVRDisplays(nsTArray<RefPtr<mozilla::dom::VRDisplay>>& aDisplays);
-
- // Inner windows only.
- // Called to inform that the set of active VR displays has changed.
- void NotifyActiveVRDisplaysChanged();
-
#define EVENT(name_, id_, type_, struct_) \
mozilla::dom::EventHandlerNonNull* GetOn##name_() \
{ \
@@ -1832,9 +1818,6 @@ protected:
// Indicates whether this window wants gamepad input events
bool mHasGamepad : 1;
- // Inner windows only.
- // Indicates whether this window wants VR events
- bool mHasVREvents : 1;
#ifdef MOZ_GAMEPAD
nsCheapSet<nsUint32HashKey> mGamepadIndexSet;
nsRefPtrHashtable<nsUint32HashKey, mozilla::dom::Gamepad> mGamepads;
@@ -1989,11 +1972,6 @@ protected:
// This is the CC generation the last time we called CanSkip.
uint32_t mCanSkipCCGeneration;
- // The VR Displays for this window
- nsTArray<RefPtr<mozilla::dom::VRDisplay>> mVRDisplays;
-
- nsAutoPtr<mozilla::dom::VREventObserver> mVREventObserver;
-
friend class nsDOMScriptableHelper;
friend class nsDOMWindowUtils;
friend class mozilla::dom::PostMessageEvent;
diff --git a/dom/base/nsScriptLoader.cpp b/dom/base/nsScriptLoader.cpp
index a6d20e363..0eb5bbf31 100644
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -81,11 +81,19 @@ ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback,
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsScriptLoadRequest)
NS_INTERFACE_MAP_END
-NS_IMPL_CYCLE_COLLECTION_0(nsScriptLoadRequest)
-
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsScriptLoadRequest)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsScriptLoadRequest)
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsScriptLoadRequest)
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsScriptLoadRequest)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mElement)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsScriptLoadRequest)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElement)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+
nsScriptLoadRequest::~nsScriptLoadRequest()
{
js_free(mScriptTextBuf);