Skip to content

Commit

Permalink
merge mozilla-inbound to mozilla-central. r=merge a=merge
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: LcCWQzgwIBi
  • Loading branch information
Archaeopteryx committed Oct 26, 2017
2 parents b094b9a + 6417bb1 commit 0f82611
Show file tree
Hide file tree
Showing 50 changed files with 315 additions and 209 deletions.
7 changes: 3 additions & 4 deletions caps/nsScriptSecurityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1437,13 +1437,12 @@ nsScriptSecurityManager::InitStatics()
// Currently this nsGenericFactory constructor is used only from FastLoad
// (XPCOM object deserialization) code, when "creating" the system principal
// singleton.
SystemPrincipal *
already_AddRefed<SystemPrincipal>
nsScriptSecurityManager::SystemPrincipalSingletonConstructor()
{
nsIPrincipal *sysprin = nullptr;
if (gScriptSecMan)
NS_ADDREF(sysprin = gScriptSecMan->mSystemPrincipal);
return static_cast<SystemPrincipal*>(sysprin);
return do_AddRef(gScriptSecMan->mSystemPrincipal.get()).downcast<SystemPrincipal>();
return nullptr;
}

struct IsWhitespace {
Expand Down
2 changes: 1 addition & 1 deletion caps/nsScriptSecurityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class nsScriptSecurityManager final : public nsIScriptSecurityManager,
// Invoked exactly once, by XPConnect.
static void InitStatics();

static SystemPrincipal*
static already_AddRefed<SystemPrincipal>
SystemPrincipalSingletonConstructor();

/**
Expand Down
42 changes: 42 additions & 0 deletions dom/base/CustomElementRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,48 @@ CustomElementData::CustomElementData(nsAtom* aType, State aState)
{
}

void
CustomElementData::SetCustomElementDefinition(CustomElementDefinition* aDefinition)
{
MOZ_ASSERT(mState == State::eCustom);
MOZ_ASSERT(!mCustomElementDefinition);
MOZ_ASSERT(aDefinition->mType == mType);

mCustomElementDefinition = aDefinition;
}

CustomElementDefinition*
CustomElementData::GetCustomElementDefinition()
{
MOZ_ASSERT(mCustomElementDefinition ? mState == State::eCustom
: mState != State::eCustom);

return mCustomElementDefinition;
}

void
CustomElementData::Traverse(nsCycleCollectionTraversalCallback& aCb) const
{
for (uint32_t i = 0; i < mReactionQueue.Length(); i++) {
if (mReactionQueue[i]) {
mReactionQueue[i]->Traverse(aCb);
}
}

if (mCustomElementDefinition) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(aCb, "mCustomElementDefinition");
aCb.NoteNativeChild(mCustomElementDefinition,
NS_CYCLE_COLLECTION_PARTICIPANT(CustomElementDefinition));
}
}

void
CustomElementData::Unlink()
{
mReactionQueue.Clear();
mCustomElementDefinition = nullptr;
}

//-----------------------------------------------------
// CustomElementRegistry

Expand Down
23 changes: 8 additions & 15 deletions dom/base/CustomElementRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,16 @@ struct CustomElementData
// e.g., create an element, insert a node.
AutoTArray<UniquePtr<CustomElementReaction>, 3> mReactionQueue;

RefPtr<CustomElementDefinition> mCustomElementDefinition;

void
SetCustomElementDefinition(CustomElementDefinition* aDefinition)
{
MOZ_ASSERT(!mCustomElementDefinition);

mCustomElementDefinition = aDefinition;
}
void SetCustomElementDefinition(CustomElementDefinition* aDefinition);
CustomElementDefinition* GetCustomElementDefinition();

CustomElementDefinition*
GetCustomElementDefinition()
{
return mCustomElementDefinition;
}
void Traverse(nsCycleCollectionTraversalCallback& aCb) const;
void Unlink();

private:
virtual ~CustomElementData() {}

RefPtr<CustomElementDefinition> mCustomElementDefinition;
};

#define ALEADY_CONSTRUCTED_MARKER nullptr
Expand All @@ -169,7 +161,8 @@ struct CustomElementDefinition
mozilla::dom::LifecycleCallbacks* aCallbacks,
uint32_t aDocOrder);

// The type (name) for this custom element.
// The type (name) for this custom element, for <button is="x-foo"> or <x-foo>
// this would be x-foo.
RefPtr<nsAtom> mType;

// The localname to (e.g. <button is=type> -- this would be button).
Expand Down
8 changes: 3 additions & 5 deletions dom/base/DOMRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ class DOMRequestService final : public nsIDOMRequestService
NS_DECL_ISUPPORTS
NS_DECL_NSIDOMREQUESTSERVICE

// Returns an owning reference! No one should call this but the factory.
static DOMRequestService* FactoryCreate()
// No one should call this but the factory.
static already_AddRefed<DOMRequestService> FactoryCreate()
{
DOMRequestService* res = new DOMRequestService;
NS_ADDREF(res);
return res;
return MakeAndAddRef<DOMRequestService>();
}
};

Expand Down
18 changes: 2 additions & 16 deletions dom/base/FragmentOrElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,19 +710,7 @@ FragmentOrElement::nsDOMSlots::Traverse(nsCycleCollectionTraversalCallback &cb)
cb.NoteXPCOMChild(mExtendedSlots->mXBLInsertionPoint.get());

if (mExtendedSlots->mCustomElementData) {
for (uint32_t i = 0;
i < mExtendedSlots->mCustomElementData->mReactionQueue.Length(); i++) {
if (mExtendedSlots->mCustomElementData->mReactionQueue[i]) {
mExtendedSlots->mCustomElementData->mReactionQueue[i]->Traverse(cb);
}
}

if (mExtendedSlots->mCustomElementData->mCustomElementDefinition) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb,
"mExtendedSlots->mCustomElementData->mCustomElementDefinition");
cb.NoteNativeChild(mExtendedSlots->mCustomElementData->mCustomElementDefinition,
NS_CYCLE_COLLECTION_PARTICIPANT(CustomElementDefinition));
}
mExtendedSlots->mCustomElementData->Traverse(cb);
}

NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mExtendedSlots->mFrameLoaderOrOpener");
Expand Down Expand Up @@ -753,9 +741,7 @@ FragmentOrElement::nsDOMSlots::Unlink()
MOZ_ASSERT(!(mExtendedSlots->mXBLBinding));
mExtendedSlots->mXBLInsertionPoint = nullptr;
if (mExtendedSlots->mCustomElementData) {
if (mExtendedSlots->mCustomElementData->mCustomElementDefinition) {
mExtendedSlots->mCustomElementData->mCustomElementDefinition = nullptr;
}
mExtendedSlots->mCustomElementData->Unlink();
mExtendedSlots->mCustomElementData = nullptr;
}
nsCOMPtr<nsIFrameLoader> frameLoader =
Expand Down
9 changes: 3 additions & 6 deletions dom/quota/QuotaManagerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,11 @@ QuotaManagerService::Get()
}

// static
QuotaManagerService*
already_AddRefed<QuotaManagerService>
QuotaManagerService::FactoryCreate()
{
// Returns a raw pointer that carries an owning reference! Lame, but the
// singleton factory macros force this.
QuotaManagerService* quotaManagerService = GetOrCreate();
NS_IF_ADDREF(quotaManagerService);
return quotaManagerService;
RefPtr<QuotaManagerService> quotaManagerService = GetOrCreate();
return quotaManagerService.forget();
}

void
Expand Down
4 changes: 2 additions & 2 deletions dom/quota/QuotaManagerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class QuotaManagerService final
static QuotaManagerService*
Get();

// Returns an owning reference! No one should call this but the factory.
static QuotaManagerService*
// No one should call this but the factory.
static already_AddRefed<QuotaManagerService>
FactoryCreate();

void
Expand Down
17 changes: 7 additions & 10 deletions extensions/cookie/nsPermissionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,12 +926,11 @@ nsPermissionManager::~nsPermissionManager()
}

// static
nsIPermissionManager*
already_AddRefed<nsIPermissionManager>
nsPermissionManager::GetXPCOMSingleton()
{
if (gPermissionManager) {
NS_ADDREF(gPermissionManager);
return gPermissionManager;
return do_AddRef(gPermissionManager);
}

// Create a new singleton nsPermissionManager.
Expand All @@ -940,15 +939,13 @@ nsPermissionManager::GetXPCOMSingleton()
// Release our members, since GC cycles have already been completed and
// would result in serious leaks.
// See bug 209571.
gPermissionManager = new nsPermissionManager();
if (gPermissionManager) {
NS_ADDREF(gPermissionManager);
if (NS_FAILED(gPermissionManager->Init())) {
NS_RELEASE(gPermissionManager);
}
auto permManager = MakeRefPtr<nsPermissionManager>();
if (NS_SUCCEEDED(permManager->Init())) {
gPermissionManager = permManager.get();
return permManager.forget();
}

return gPermissionManager;
return nullptr;;
}

nsresult
Expand Down
2 changes: 1 addition & 1 deletion extensions/cookie/nsPermissionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class nsPermissionManager final : public nsIPermissionManager,
NS_DECL_NSIOBSERVER

nsPermissionManager();
static nsIPermissionManager* GetXPCOMSingleton();
static already_AddRefed<nsIPermissionManager> GetXPCOMSingleton();
nsresult Init();

// enums for AddInternal()
Expand Down
6 changes: 2 additions & 4 deletions js/src/builtin/Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1142,9 +1142,6 @@ EnumerableOwnProperties(JSContext* cx, const JS::CallArgs& args, EnumerableOwnPr
RootedId id(cx);
RootedValue key(cx);
RootedValue value(cx);
RootedNativeObject nobj(cx);
if (obj->is<NativeObject>())
nobj = &obj->as<NativeObject>();
RootedShape shape(cx);
Rooted<PropertyDescriptor> desc(cx);
// Step 4.
Expand All @@ -1161,7 +1158,8 @@ EnumerableOwnProperties(JSContext* cx, const JS::CallArgs& args, EnumerableOwnPr
}

// Step 4.a.i.
if (nobj) {
if (obj->is<NativeObject>()) {
HandleNativeObject nobj = obj.as<NativeObject>();
if (JSID_IS_INT(id) && nobj->containsDenseElement(JSID_TO_INT(id))) {
value = nobj->getDenseOrTypedArrayElement(JSID_TO_INT(id));
} else {
Expand Down
6 changes: 2 additions & 4 deletions js/xpconnect/src/nsXPConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,10 @@ nsXPConnect::InitStatics()
gSelf->mRuntime->InitSingletonScopes();
}

nsXPConnect*
already_AddRefed<nsXPConnect>
nsXPConnect::GetSingleton()
{
nsXPConnect* xpc = nsXPConnect::XPConnect();
NS_IF_ADDREF(xpc);
return xpc;
return do_AddRef(nsXPConnect::XPConnect());
}

// static
Expand Down
5 changes: 1 addition & 4 deletions js/xpconnect/src/xpcprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,7 @@ class nsXPConnect final : public nsIXPConnect
return gSystemPrincipal;
}

// This returns an AddRef'd pointer. It does not do this with an 'out' param
// only because this form is required by the generic module macro:
// NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR
static nsXPConnect* GetSingleton();
static already_AddRefed<nsXPConnect> GetSingleton();

// Called by module code in dll startup
static void InitStatics();
Expand Down
13 changes: 13 additions & 0 deletions layout/base/crashtests/1411138.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Needs to be in quirks mode -->
<html>
<head>
<script>
try { o1 = document.createElement('frameset') } catch(e) { }
try { o2 = document.createElement('body') } catch(e) { }
try { o2.style.overflow = 'auto'; } catch (e) {}
try { document.documentElement.appendChild(o1) } catch(e) { }
try { document.documentElement.appendChild(o2) } catch(e) { }
try { o2.scrollLeft } catch(e) { }
</script>
</head>
</html>
1 change: 1 addition & 0 deletions layout/base/crashtests/crashtests.list
Original file line number Diff line number Diff line change
Expand Up @@ -513,3 +513,4 @@ load 1404789-2.html
load 1406562.html
load 1409088.html
load 1409147.html
load 1411138.html
13 changes: 8 additions & 5 deletions layout/base/nsPresContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIDocument.h"
#include "nsIDocumentInlines.h"
#include "nsIPrintSettings.h"
#include "nsLanguageAtomService.h"
#include "mozilla/LookAndFeel.h"
Expand Down Expand Up @@ -56,6 +57,7 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/dom/Element.h"
#include "nsIMessageManager.h"
#include "mozilla/dom/HTMLBodyElement.h"
#include "mozilla/dom/MediaQueryList.h"
#include "nsSMILAnimationController.h"
#include "mozilla/css/ImageLoader.h"
Expand Down Expand Up @@ -1516,14 +1518,15 @@ GetPropagatedScrollbarStylesForViewport(nsPresContext* aPresContext,
return nullptr;
}

Element* bodyElement = htmlDoc->GetBody();

if (!bodyElement ||
!bodyElement->NodeInfo()->Equals(nsGkAtoms::body)) {
// The body is not a <body> tag, it's a <frameset>.
Element* bodyElement = htmlDoc->GetBodyElement();
if (!bodyElement) {
// No body, nothing to do here.
return nullptr;
}

MOZ_ASSERT(bodyElement->IsHTMLElement(nsGkAtoms::body),
"GetBodyElement returned something bogus");

RefPtr<nsStyleContext> bodyStyle =
styleSet->ResolveStyleFor(bodyElement, rootStyle,
LazyComputeBehavior::Allow);
Expand Down
5 changes: 2 additions & 3 deletions mobile/android/components/build/nsAndroidHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ NS_IMPL_ISUPPORTS(nsAndroidHistory, IHistory, nsIRunnable, nsITimerCallback, nsI
nsAndroidHistory* nsAndroidHistory::sHistory = nullptr;

/*static*/
nsAndroidHistory*
already_AddRefed<nsAndroidHistory>
nsAndroidHistory::GetSingleton()
{
if (!sHistory) {
sHistory = new nsAndroidHistory();
NS_ENSURE_TRUE(sHistory, nullptr);
}

NS_ADDREF(sHistory);
return sHistory;
return do_AddRef(sHistory);
}

nsAndroidHistory::nsAndroidHistory()
Expand Down
2 changes: 1 addition & 1 deletion mobile/android/components/build/nsAndroidHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class nsAndroidHistory final : public mozilla::IHistory,
* Obtains a pointer that has had AddRef called on it. Used by the service
* manager only.
*/
static nsAndroidHistory* GetSingleton();
static already_AddRefed<nsAndroidHistory> GetSingleton();

nsAndroidHistory();

Expand Down
18 changes: 7 additions & 11 deletions modules/libjar/nsJARProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,19 @@ NS_IMPL_ISUPPORTS(nsJARProtocolHandler,
nsIProtocolHandler,
nsISupportsWeakReference)

nsJARProtocolHandler*
already_AddRefed<nsJARProtocolHandler>
nsJARProtocolHandler::GetSingleton()
{
if (!gJarHandler) {
gJarHandler = new nsJARProtocolHandler();
if (!gJarHandler)
return nullptr;

NS_ADDREF(gJarHandler);
nsresult rv = gJarHandler->Init();
if (NS_FAILED(rv)) {
NS_RELEASE(gJarHandler);
auto jar = MakeRefPtr<nsJARProtocolHandler>();
gJarHandler = jar.get();
if (NS_FAILED(jar->Init())) {
gJarHandler = nullptr;
return nullptr;
}
return jar.forget();
}
NS_ADDREF(gJarHandler);
return gJarHandler;
return do_AddRef(gJarHandler);
}

NS_IMETHODIMP
Expand Down
Loading

0 comments on commit 0f82611

Please sign in to comment.