зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1523638
- Part 4: Move NextWindowId logic into nsContentUtils, r=kmag
Differential Revision: https://phabricator.services.mozilla.com/D37651 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
a711231390
Коммит
4d83ce526b
|
@ -309,7 +309,7 @@ static void DecreasePrivateDocShellCount() {
|
|||
|
||||
nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext)
|
||||
: nsDocLoader(),
|
||||
mContentWindowID(NextWindowID()),
|
||||
mContentWindowID(nsContentUtils::GenerateWindowId()),
|
||||
mBrowsingContext(aBrowsingContext),
|
||||
mForcedCharset(nullptr),
|
||||
mParentCharset(nullptr),
|
||||
|
|
|
@ -9850,8 +9850,12 @@ bool nsContentUtils::IsLocalRefURL(const nsString& aString) {
|
|||
return !aString.IsEmpty() && aString[0] == '#';
|
||||
}
|
||||
|
||||
static const uint64_t kIdProcessBits = 32;
|
||||
static const uint64_t kIdBits = 64 - kIdProcessBits;
|
||||
// We use only 53 bits for the ID so that it can be converted to and from a JS
|
||||
// value without loss of precision. The upper bits of the ID hold the process
|
||||
// ID. The lower bits identify the object itself.
|
||||
static constexpr uint64_t kIdTotalBits = 53;
|
||||
static constexpr uint64_t kIdProcessBits = 22;
|
||||
static constexpr uint64_t kIdBits = kIdTotalBits - kIdProcessBits;
|
||||
|
||||
/* static */ uint64_t GenerateProcessSpecificId(uint64_t aId) {
|
||||
uint64_t processId = 0;
|
||||
|
@ -9876,7 +9880,7 @@ static const uint64_t kIdBits = 64 - kIdProcessBits;
|
|||
return (processBits << kIdBits) | bits;
|
||||
}
|
||||
|
||||
// Tab ID is composed in a similar manner of Window ID.
|
||||
// Next process-local Tab ID.
|
||||
static uint64_t gNextTabId = 0;
|
||||
|
||||
/* static */
|
||||
|
@ -9884,7 +9888,7 @@ uint64_t nsContentUtils::GenerateTabId() {
|
|||
return GenerateProcessSpecificId(++gNextTabId);
|
||||
}
|
||||
|
||||
// Browsing context ID is composed in a similar manner of Window ID.
|
||||
// Next process-local Browsing Context ID.
|
||||
static uint64_t gNextBrowsingContextId = 0;
|
||||
|
||||
/* static */
|
||||
|
@ -9892,6 +9896,14 @@ uint64_t nsContentUtils::GenerateBrowsingContextId() {
|
|||
return GenerateProcessSpecificId(++gNextBrowsingContextId);
|
||||
}
|
||||
|
||||
// Next process-local Window ID.
|
||||
static uint64_t gNextWindowId = 0;
|
||||
|
||||
/* static */
|
||||
uint64_t nsContentUtils::GenerateWindowId() {
|
||||
return GenerateProcessSpecificId(++gNextWindowId);
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool nsContentUtils::GetUserIsInteracting() {
|
||||
return UserInteractionObserver::sUserActive;
|
||||
|
|
|
@ -3074,6 +3074,12 @@ class nsContentUtils {
|
|||
*/
|
||||
static uint64_t GenerateBrowsingContextId();
|
||||
|
||||
/**
|
||||
* Generate a window ID which is unique across processes and will never be
|
||||
* recycled.
|
||||
*/
|
||||
static uint64_t GenerateWindowId();
|
||||
|
||||
/**
|
||||
* Determine whether or not the user is currently interacting with the web
|
||||
* browser. This method is safe to call from off of the main thread.
|
||||
|
|
|
@ -7199,13 +7199,6 @@ bool nsPIDOMWindowInner::HasStorageAccessGranted(
|
|||
return mStorageAccessGranted.Contains(aPermissionKey);
|
||||
}
|
||||
|
||||
// XXX: Can we define this in a header instead of here?
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
extern uint64_t NextWindowID();
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
nsPIDOMWindowInner::nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow)
|
||||
: mMutationBits(0),
|
||||
mActivePeerConnections(0),
|
||||
|
@ -7218,8 +7211,7 @@ nsPIDOMWindowInner::nsPIDOMWindowInner(nsPIDOMWindowOuter* aOuterWindow)
|
|||
mMayHavePointerEnterLeaveEventListener(false),
|
||||
mMayHaveTextEventListenerInDefaultGroup(false),
|
||||
mOuterWindow(aOuterWindow),
|
||||
// Make sure no actual window ends up with mWindowID == 0
|
||||
mWindowID(NextWindowID()),
|
||||
mWindowID(nsContentUtils::GenerateWindowId()),
|
||||
mHasNotifiedGlobalCreated(false),
|
||||
mMarkedCCGeneration(0),
|
||||
mHasTriedToCacheTopInnerWindow(false),
|
||||
|
|
|
@ -3213,48 +3213,6 @@ mozilla::ipc::IPCResult ContentChild::RecvSetAudioSessionData(
|
|||
#endif
|
||||
}
|
||||
|
||||
// This code goes here rather than nsGlobalWindow.cpp because nsGlobalWindow.cpp
|
||||
// can't include ContentChild.h since it includes windows.h.
|
||||
|
||||
static uint64_t gNextWindowID = 0;
|
||||
|
||||
// We use only 53 bits for the window ID so that it can be converted to and from
|
||||
// a JS value without loss of precision. The upper bits of the window ID hold
|
||||
// the process ID. The lower bits identify the window.
|
||||
static const uint64_t kWindowIDTotalBits = 53;
|
||||
static const uint64_t kWindowIDProcessBits = 22;
|
||||
static const uint64_t kWindowIDWindowBits =
|
||||
kWindowIDTotalBits - kWindowIDProcessBits;
|
||||
|
||||
// Try to return a window ID that is unique across processes and that will never
|
||||
// be recycled.
|
||||
uint64_t NextWindowID() {
|
||||
uint64_t processID = 0;
|
||||
if (XRE_IsContentProcess()) {
|
||||
ContentChild* cc = ContentChild::GetSingleton();
|
||||
processID = cc->GetID();
|
||||
}
|
||||
|
||||
MOZ_RELEASE_ASSERT(processID < (uint64_t(1) << kWindowIDProcessBits));
|
||||
uint64_t processBits =
|
||||
processID & ((uint64_t(1) << kWindowIDProcessBits) - 1);
|
||||
|
||||
// Make sure no actual window ends up with mWindowID == 0.
|
||||
uint64_t windowID = ++gNextWindowID;
|
||||
|
||||
MOZ_RELEASE_ASSERT(windowID < (uint64_t(1) << kWindowIDWindowBits));
|
||||
uint64_t windowBits = windowID & ((uint64_t(1) << kWindowIDWindowBits) - 1);
|
||||
|
||||
// Make sure that the middleman process doesn't generate WindowIDs which
|
||||
// conflict with the process it's wrapping (which shares a ContentParentID
|
||||
// with it).
|
||||
if (recordreplay::IsMiddleman()) {
|
||||
windowBits |= uint64_t(1) << (kWindowIDWindowBits - 1);
|
||||
}
|
||||
|
||||
return (processBits << kWindowIDWindowBits) | windowBits;
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession(
|
||||
nsTArray<IPCDataTransfer>&& aTransfers, const uint32_t& aAction) {
|
||||
nsCOMPtr<nsIDragService> dragService =
|
||||
|
|
|
@ -834,8 +834,6 @@ class ContentChild final : public PContentChild,
|
|||
DISALLOW_EVIL_CONSTRUCTORS(ContentChild);
|
||||
};
|
||||
|
||||
uint64_t NextWindowID();
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче