Skip to content

Commit

Permalink
Backed out 9 changesets (bug 1523638) for browser_contextmenu.js fail…
Browse files Browse the repository at this point in the history
…ures CLOSED TREE

Backed out changeset 0a584a07b696 (bug 1523638)
Backed out changeset 8c5af2289900 (bug 1523638)
Backed out changeset 40ed1bd64b09 (bug 1523638)
Backed out changeset 9a99a0391979 (bug 1523638)
Backed out changeset 07fb4748b91a (bug 1523638)
Backed out changeset 49047c3ebae9 (bug 1523638)
Backed out changeset d606d072126c (bug 1523638)
Backed out changeset 76dc1937fc77 (bug 1523638)
Backed out changeset c784c14b5d5d (bug 1523638)
  • Loading branch information
bogdant-old committed Jul 16, 2019
1 parent d05771c commit 8b082b9
Show file tree
Hide file tree
Showing 44 changed files with 289 additions and 479 deletions.
60 changes: 11 additions & 49 deletions docshell/base/nsDocShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,9 @@ static void DecreasePrivateDocShellCount() {
}
}

nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
uint64_t aContentWindowID)
nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext)
: nsDocLoader(),
mContentWindowID(aContentWindowID),
mContentWindowID(NextWindowID()),
mBrowsingContext(aBrowsingContext),
mForcedCharset(nullptr),
mParentCharset(nullptr),
Expand Down Expand Up @@ -396,11 +395,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,

nsContentUtils::GenerateUUIDInPlace(mHistoryID);

// If no outer window ID was provided, generate a new one.
if (aContentWindowID == 0) {
mContentWindowID = nsContentUtils::GenerateWindowId();
}

if (gDocShellCount++ == 0) {
NS_ASSERTION(sURIFixup == nullptr,
"Huh, sURIFixup not null in first nsDocShell ctor!");
Expand Down Expand Up @@ -467,11 +461,11 @@ nsDocShell::~nsDocShell() {

/* static */
already_AddRefed<nsDocShell> nsDocShell::Create(
BrowsingContext* aBrowsingContext, uint64_t aContentWindowID) {
BrowsingContext* aBrowsingContext) {
MOZ_ASSERT(aBrowsingContext, "DocShell without a BrowsingContext!");

nsresult rv;
RefPtr<nsDocShell> ds = new nsDocShell(aBrowsingContext, aContentWindowID);
RefPtr<nsDocShell> ds = new nsDocShell(aBrowsingContext);

// Initialize the underlying nsDocLoader.
rv = ds->nsDocLoader::Init();
Expand Down Expand Up @@ -525,7 +519,6 @@ already_AddRefed<nsDocShell> nsDocShell::Create(

// Make |ds| the primary DocShell for the given context.
aBrowsingContext->SetDocShell(ds);

return ds.forget();
}

Expand Down Expand Up @@ -6373,12 +6366,12 @@ nsresult nsDocShell::RefreshURIFromQueue() {
}

nsresult nsDocShell::Embed(nsIContentViewer* aContentViewer,
WindowGlobalChild* aWindowActor) {
const char* aCommand, nsISupports* aExtraInfo) {
// Save the LayoutHistoryState of the previous document, before
// setting up new document
PersistLayoutHistoryState();

nsresult rv = SetupNewViewer(aContentViewer, aWindowActor);
nsresult rv = SetupNewViewer(aContentViewer);
NS_ENSURE_SUCCESS(rv, rv);

// XXX What if SetupNewViewer fails?
Expand Down Expand Up @@ -7014,7 +7007,6 @@ nsresult nsDocShell::EnsureContentViewer() {
nsCOMPtr<nsIURI> baseURI;
nsIPrincipal* principal = GetInheritedPrincipal(false);
nsIPrincipal* storagePrincipal = GetInheritedPrincipal(false, true);

nsCOMPtr<nsIDocShellTreeItem> parentItem;
GetSameTypeParent(getter_AddRefs(parentItem));
if (parentItem) {
Expand Down Expand Up @@ -7056,14 +7048,11 @@ nsresult nsDocShell::EnsureContentViewer() {
nsresult nsDocShell::CreateAboutBlankContentViewer(
nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
nsIContentSecurityPolicy* aCSP, nsIURI* aBaseURI,
bool aTryToSaveOldPresentation, bool aCheckPermitUnload,
WindowGlobalChild* aActor) {
bool aTryToSaveOldPresentation, bool aCheckPermitUnload) {
RefPtr<Document> blankDoc;
nsCOMPtr<nsIContentViewer> viewer;
nsresult rv = NS_ERROR_FAILURE;

MOZ_ASSERT_IF(aActor, aActor->DocumentPrincipal() == aPrincipal);

/* mCreatingDocument should never be true at this point. However, it's
a theoretical possibility. We want to know about it and make it stop,
and this sounds like a job for an assertion. */
Expand Down Expand Up @@ -7192,7 +7181,7 @@ nsresult nsDocShell::CreateAboutBlankContentViewer(
// hook 'em up
if (viewer) {
viewer->SetContainer(this);
rv = Embed(viewer, aActor);
rv = Embed(viewer, "", 0);
NS_ENSURE_SUCCESS(rv, rv);

SetCurrentURI(blankDoc->GetDocumentURI(), nullptr, true, 0);
Expand Down Expand Up @@ -7222,32 +7211,6 @@ nsDocShell::CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
nullptr);
}

nsresult nsDocShell::CreateContentViewerForActor(
WindowGlobalChild* aWindowActor) {
MOZ_ASSERT(aWindowActor);

// FIXME: WindowGlobalChild should provide the StoragePrincipal.
nsresult rv = CreateAboutBlankContentViewer(
aWindowActor->DocumentPrincipal(), aWindowActor->DocumentPrincipal(),
/* aCsp */ nullptr,
/* aBaseURI */ nullptr,
/* aTryToSaveOldPresentation */ true,
/* aCheckPermitUnload */ true, aWindowActor);
if (NS_SUCCEEDED(rv)) {
RefPtr<Document> doc(GetDocument());
MOZ_ASSERT(
doc,
"Should have a document if CreateAboutBlankContentViewer succeeded");
MOZ_ASSERT(doc->GetOwnerGlobal() == aWindowActor->WindowGlobal(),
"New document should be in the same global as our actor");

// FIXME: We may want to support non-initial documents here.
doc->SetIsInitialDocument(true);
}

return rv;
}

bool nsDocShell::CanSavePresentation(uint32_t aLoadType,
nsIRequest* aNewRequest,
Document* aNewDocument) {
Expand Down Expand Up @@ -8375,7 +8338,7 @@ nsresult nsDocShell::CreateContentViewer(const nsACString& aContentType,
}
}

NS_ENSURE_SUCCESS(Embed(viewer), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(Embed(viewer, "", nullptr), NS_ERROR_FAILURE);

if (TreatAsBackgroundLoad()) {
nsCOMPtr<nsIRunnable> triggerParentCheckDocShell =
Expand Down Expand Up @@ -8448,8 +8411,7 @@ nsresult nsDocShell::NewContentViewerObj(const nsACString& aContentType,
return NS_OK;
}

nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,
WindowGlobalChild* aWindowActor) {
nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer) {
MOZ_ASSERT(!mIsBeingDestroyed);

//
Expand Down Expand Up @@ -8573,7 +8535,7 @@ nsresult nsDocShell::SetupNewViewer(nsIContentViewer* aNewViewer,

mContentViewer->SetNavigationTiming(mTiming);

if (NS_FAILED(mContentViewer->Init(widget, bounds, aWindowActor))) {
if (NS_FAILED(mContentViewer->Init(widget, bounds))) {
mContentViewer = nullptr;
NS_WARNING("ContentViewer Initialization failed");
return NS_ERROR_FAILURE;
Expand Down
30 changes: 11 additions & 19 deletions docshell/base/nsDocShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,7 @@ class nsDocShell final : public nsDocLoader,

// Create a new nsDocShell object, initializing it.
static already_AddRefed<nsDocShell> Create(
mozilla::dom::BrowsingContext* aBrowsingContext,
uint64_t aContentWindowID = 0);
mozilla::dom::BrowsingContext* aBrowsingContext);

NS_IMETHOD Stop() override {
// Need this here because otherwise nsIWebNavigation::Stop
Expand Down Expand Up @@ -474,11 +473,6 @@ class nsDocShell final : public nsDocLoader,
mSkipBrowsingContextDetachOnDestroy = true;
}

// Create a content viewer within this nsDocShell for the given
// `WindowGlobalChild` actor.
nsresult CreateContentViewerForActor(
mozilla::dom::WindowGlobalChild* aWindowActor);

private: // member functions
friend class nsDSURIContentListener;
friend class FramingChecker;
Expand All @@ -503,8 +497,7 @@ class nsDocShell final : public nsDocLoader,
friend void mozilla::TimelineConsumers::PopMarkers(
nsDocShell*, JSContext*, nsTArray<dom::ProfileTimelineMarker>&);

nsDocShell(mozilla::dom::BrowsingContext* aBrowsingContext,
uint64_t aContentWindowID);
explicit nsDocShell(mozilla::dom::BrowsingContext* aBrowsingContext);

// Security checks to prevent frameset spoofing. See comments at
// implementation sites.
Expand Down Expand Up @@ -558,11 +551,12 @@ class nsDocShell final : public nsDocLoader,
// aPrincipal can be passed in if the caller wants. If null is
// passed in, the about:blank principal will end up being used.
// aCSP, if any, will be used for the new about:blank load.
nsresult CreateAboutBlankContentViewer(
nsIPrincipal* aPrincipal, nsIPrincipal* aStoragePrincipal,
nsIContentSecurityPolicy* aCSP, nsIURI* aBaseURI,
bool aTryToSaveOldPresentation = true, bool aCheckPermitUnload = true,
mozilla::dom::WindowGlobalChild* aActor = nullptr);
nsresult CreateAboutBlankContentViewer(nsIPrincipal* aPrincipal,
nsIPrincipal* aStoragePrincipal,
nsIContentSecurityPolicy* aCSP,
nsIURI* aBaseURI,
bool aTryToSaveOldPresentation = true,
bool aCheckPermitUnload = true);

nsresult CreateContentViewer(const nsACString& aContentType,
nsIRequest* aRequest,
Expand All @@ -573,9 +567,7 @@ class nsDocShell final : public nsDocLoader,
nsIStreamListener** aContentHandler,
nsIContentViewer** aViewer);

nsresult SetupNewViewer(
nsIContentViewer* aNewViewer,
mozilla::dom::WindowGlobalChild* aWindowActor = nullptr);
nsresult SetupNewViewer(nsIContentViewer* aNewViewer);

//
// Session History
Expand Down Expand Up @@ -988,8 +980,8 @@ class nsDocShell final : public nsDocLoader,
nsresult EnsureFind();
nsresult EnsureCommandHandler();
nsresult RefreshURIFromQueue();
nsresult Embed(nsIContentViewer* aContentViewer,
mozilla::dom::WindowGlobalChild* aWindowActor = nullptr);
nsresult Embed(nsIContentViewer* aContentViewer, const char* aCommand,
nsISupports* aExtraInfo);
nsPresContext* GetEldestPresContext();
nsresult CheckLoadingPermissions();
nsresult PersistLayoutHistoryState();
Expand Down
9 changes: 2 additions & 7 deletions docshell/base/nsIContentViewer.idl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ class nsDOMNavigationTiming;
namespace mozilla {
class Encoding;
class PresShell;
namespace dom {
class WindowGlobalChild;
} // namespace dom
} // namespace mozilla
}
%}

[ptr] native nsIWidgetPtr(nsIWidget);
Expand All @@ -35,14 +32,12 @@ class WindowGlobalChild;
[ref] native nsIContentViewerTArray(nsTArray<nsCOMPtr<nsIContentViewer> >);
[ptr] native Encoding(const mozilla::Encoding);
[ptr] native PresShellPtr(mozilla::PresShell);
[ptr] native WindowGlobalChildPtr(mozilla::dom::WindowGlobalChild);

[scriptable, builtinclass, uuid(2da17016-7851-4a45-a7a8-00b360e01595)]
interface nsIContentViewer : nsISupports
{
[noscript] void init(in nsIWidgetPtr aParentWidget,
[const] in nsIntRectRef aBounds,
in WindowGlobalChildPtr aWindowActor);
[const] in nsIntRectRef aBounds);

attribute nsIDocShell container;

Expand Down
7 changes: 4 additions & 3 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ nsresult ExternalResourceMap::AddExternalResource(nsIURI* aURI,
// Make sure that hiding our viewer will tear down its presentation.
aViewer->SetSticky(false);

rv = aViewer->Init(nullptr, nsIntRect(0, 0, 0, 0), nullptr);
rv = aViewer->Init(nullptr, nsIntRect(0, 0, 0, 0));
if (NS_SUCCEEDED(rv)) {
rv = aViewer->Open(nullptr, nullptr);
}
Expand Down Expand Up @@ -3375,8 +3375,9 @@ void Document::SetDocumentURI(nsIURI* aURI) {

// Tell our WindowGlobalParent that the document's URI has been changed.
nsPIDOMWindowInner* inner = GetInnerWindow();
if (inner && inner->GetWindowGlobalChild()) {
inner->GetWindowGlobalChild()->SetDocumentURI(mDocumentURI);
WindowGlobalChild* wgc = inner ? inner->GetWindowGlobalChild() : nullptr;
if (wgc) {
Unused << wgc->SendUpdateDocumentURI(mDocumentURI);
}
}

Expand Down
20 changes: 4 additions & 16 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9850,12 +9850,8 @@ bool nsContentUtils::IsLocalRefURL(const nsString& aString) {
return !aString.IsEmpty() && aString[0] == '#';
}

// 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 const uint64_t kIdProcessBits = 32;
static const uint64_t kIdBits = 64 - kIdProcessBits;

/* static */ uint64_t GenerateProcessSpecificId(uint64_t aId) {
uint64_t processId = 0;
Expand All @@ -9880,30 +9876,22 @@ static constexpr uint64_t kIdBits = kIdTotalBits - kIdProcessBits;
return (processBits << kIdBits) | bits;
}

// Next process-local Tab ID.
// Tab ID is composed in a similar manner of Window ID.
static uint64_t gNextTabId = 0;

/* static */
uint64_t nsContentUtils::GenerateTabId() {
return GenerateProcessSpecificId(++gNextTabId);
}

// Next process-local Browsing Context ID.
// Browsing context ID is composed in a similar manner of Window ID.
static uint64_t gNextBrowsingContextId = 0;

/* static */
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;
Expand Down
6 changes: 0 additions & 6 deletions dom/base/nsContentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3074,12 +3074,6 @@ 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.
Expand Down
Loading

0 comments on commit 8b082b9

Please sign in to comment.