summaryrefslogtreecommitdiffstats
path: root/dom/base/Document.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/Document.cpp')
-rw-r--r--dom/base/Document.cpp70
1 files changed, 37 insertions, 33 deletions
diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp
index 8cbf8b8075..68e4100540 100644
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -16423,47 +16423,33 @@ WindowContext* Document::GetWindowContextForPageUseCounters() const {
return wc;
}
-void Document::UpdateIntersectionObservations(TimeStamp aNowTime) {
- if (mIntersectionObservers.IsEmpty()) {
- return;
- }
-
- DOMHighResTimeStamp time = 0;
- if (nsPIDOMWindowInner* win = GetInnerWindow()) {
- if (Performance* perf = win->GetPerformance()) {
- time = perf->TimeStampToDOMHighResForRendering(aNowTime);
+void Document::UpdateIntersections(TimeStamp aNowTime) {
+ if (!mIntersectionObservers.IsEmpty()) {
+ DOMHighResTimeStamp time = 0;
+ if (nsPIDOMWindowInner* win = GetInnerWindow()) {
+ if (Performance* perf = win->GetPerformance()) {
+ time = perf->TimeStampToDOMHighResForRendering(aNowTime);
+ }
}
- }
-
- const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>(
- mIntersectionObservers);
- for (const auto& observer : observers) {
- if (observer) {
+ for (DOMIntersectionObserver* observer : mIntersectionObservers) {
observer->Update(*this, time);
}
+ Dispatch(NewRunnableMethod("Document::NotifyIntersectionObservers", this,
+ &Document::NotifyIntersectionObservers));
}
-}
-
-void Document::ScheduleIntersectionObserverNotification() {
- if (mIntersectionObservers.IsEmpty()) {
- return;
- }
- MOZ_RELEASE_ASSERT(NS_IsMainThread());
- nsCOMPtr<nsIRunnable> notification =
- NewRunnableMethod("Document::NotifyIntersectionObservers", this,
- &Document::NotifyIntersectionObservers);
- Dispatch(notification.forget());
+ EnumerateSubDocuments([aNowTime](Document& aDoc) {
+ aDoc.UpdateIntersections(aNowTime);
+ return CallState::Continue;
+ });
}
void Document::NotifyIntersectionObservers() {
const auto observers = ToTArray<nsTArray<RefPtr<DOMIntersectionObserver>>>(
mIntersectionObservers);
for (const auto& observer : observers) {
- if (observer) {
- // MOZ_KnownLive because the 'observers' array guarantees to keep it
- // alive.
- MOZ_KnownLive(observer)->Notify();
- }
+ // MOZ_KnownLive because the 'observers' array guarantees to keep it
+ // alive.
+ MOZ_KnownLive(observer)->Notify();
}
}
@@ -18647,6 +18633,13 @@ nsICookieJarSettings* Document::CookieJarSettings() {
if (!mCookieJarSettings) {
Document* inProcessParent = GetInProcessParentDocument();
+ auto shouldInheritFrom = [this](Document* aDoc) {
+ return aDoc && (this->NodePrincipal()->Equals(aDoc->NodePrincipal()) ||
+ this->NodePrincipal()->GetIsNullPrincipal());
+ };
+ RefPtr<BrowsingContext> opener =
+ GetBrowsingContext() ? GetBrowsingContext()->GetOpener() : nullptr;
+
if (inProcessParent) {
mCookieJarSettings = net::CookieJarSettings::Create(
inProcessParent->CookieJarSettings()->GetCookieBehavior(),
@@ -18674,6 +18667,18 @@ nsICookieJarSettings* Document::CookieJarSettings() {
->SetTopLevelWindowContextId(
net::CookieJarSettings::Cast(inProcessParent->CookieJarSettings())
->GetTopLevelWindowContextId());
+ } else if (opener && shouldInheritFrom(opener->GetDocument())) {
+ mCookieJarSettings = net::CookieJarSettings::Create(NodePrincipal());
+
+ nsTArray<uint8_t> randomKey;
+ nsresult rv = opener->GetDocument()
+ ->CookieJarSettings()
+ ->GetFingerprintingRandomizationKey(randomKey);
+
+ if (NS_SUCCEEDED(rv)) {
+ net::CookieJarSettings::Cast(mCookieJarSettings)
+ ->SetFingerprintingRandomizationKey(randomKey);
+ }
} else {
mCookieJarSettings = net::CookieJarSettings::Create(NodePrincipal());
@@ -18933,8 +18938,7 @@ void Document::AddPendingFrameStaticClone(nsFrameLoaderOwner* aElement,
}
bool Document::ShouldAvoidNativeTheme() const {
- return StaticPrefs::widget_non_native_theme_enabled() &&
- (!IsInChromeDocShell() || XRE_IsContentProcess());
+ return !IsInChromeDocShell() || XRE_IsContentProcess();
}
bool Document::UseRegularPrincipal() const {