Merge m-c to autoland, a=merge

This commit is contained in:
Wes Kocher 2017-04-18 14:40:48 -07:00
commit be39489f68
43 changed files with 23725 additions and 21479 deletions

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,10 @@ public:
virtual bool IsCertainlyAliveForCC() const override;
// EventTarget
using EventTarget::EventListenerAdded;
virtual void EventListenerAdded(nsIAtom* aType) override;
using EventTarget::EventListenerRemoved;
virtual void EventListenerRemoved(nsIAtom* aType) override;
virtual void DisconnectFromOwner() override;

View File

@ -43,7 +43,10 @@ public:
mozilla::DOMEventTargetHelper)
// EventTarget
using EventTarget::EventListenerAdded;
virtual void EventListenerAdded(nsIAtom* aType) override;
using EventTarget::EventListenerRemoved;
virtual void EventListenerRemoved(nsIAtom* aType) override;
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)

View File

@ -456,6 +456,8 @@ public:
virtual void SetHasGamepadEventListener(bool aHasGamepad = true) override;
void NotifyVREventListenerAdded();
bool HasUsedVR() const;
using EventTarget::EventListenerAdded;
virtual void EventListenerAdded(nsIAtom* aType) override;
// nsIInterfaceRequestor

View File

@ -272,11 +272,12 @@ BroadcastChannel::BroadcastChannel(nsPIDOMWindowInner* aWindow,
, mPrincipalInfo(new PrincipalInfo(aPrincipalInfo))
, mOrigin(aOrigin)
, mChannel(aChannel)
, mIsKeptAlive(false)
, mInnerID(0)
, mState(StateActive)
{
// Window can be null in workers
KeepAliveIfHasListenersFor(NS_LITERAL_STRING("message"));
}
BroadcastChannel::~BroadcastChannel()
@ -496,82 +497,7 @@ BroadcastChannel::Shutdown()
mActor = nullptr;
}
// If shutdown() is called we have to release the reference if we still keep
// it.
if (mIsKeptAlive) {
mIsKeptAlive = false;
Release();
}
}
EventHandlerNonNull*
BroadcastChannel::GetOnmessage()
{
if (NS_IsMainThread()) {
return GetEventHandler(nsGkAtoms::onmessage, EmptyString());
}
return GetEventHandler(nullptr, NS_LITERAL_STRING("message"));
}
void
BroadcastChannel::SetOnmessage(EventHandlerNonNull* aCallback)
{
if (NS_IsMainThread()) {
SetEventHandler(nsGkAtoms::onmessage, EmptyString(), aCallback);
} else {
SetEventHandler(nullptr, NS_LITERAL_STRING("message"), aCallback);
}
UpdateMustKeepAlive();
}
void
BroadcastChannel::AddEventListener(const nsAString& aType,
EventListener* aCallback,
const AddEventListenerOptionsOrBoolean& aOptions,
const dom::Nullable<bool>& aWantsUntrusted,
ErrorResult& aRv)
{
DOMEventTargetHelper::AddEventListener(aType, aCallback, aOptions,
aWantsUntrusted, aRv);
if (aRv.Failed()) {
return;
}
UpdateMustKeepAlive();
}
void
BroadcastChannel::RemoveEventListener(const nsAString& aType,
EventListener* aCallback,
const EventListenerOptionsOrBoolean& aOptions,
ErrorResult& aRv)
{
DOMEventTargetHelper::RemoveEventListener(aType, aCallback, aOptions, aRv);
if (aRv.Failed()) {
return;
}
UpdateMustKeepAlive();
}
void
BroadcastChannel::UpdateMustKeepAlive()
{
bool toKeepAlive = HasListenersFor(NS_LITERAL_STRING("message"));
if (toKeepAlive == mIsKeptAlive) {
return;
}
mIsKeptAlive = toKeepAlive;
if (toKeepAlive) {
AddRef();
} else {
Release();
}
IgnoreKeepAliveIfHasListenersFor(NS_LITERAL_STRING("message"));
}
NS_IMETHODIMP

View File

@ -67,21 +67,7 @@ public:
void Close();
EventHandlerNonNull* GetOnmessage();
void SetOnmessage(EventHandlerNonNull* aCallback);
using nsIDOMEventTarget::AddEventListener;
using nsIDOMEventTarget::RemoveEventListener;
virtual void AddEventListener(const nsAString& aType,
EventListener* aCallback,
const AddEventListenerOptionsOrBoolean& aOptions,
const Nullable<bool>& aWantsUntrusted,
ErrorResult& aRv) override;
virtual void RemoveEventListener(const nsAString& aType,
EventListener* aCallback,
const EventListenerOptionsOrBoolean& aOptions,
ErrorResult& aRv) override;
IMPL_EVENT_HANDLER(message)
void Shutdown();
@ -98,13 +84,6 @@ private:
void PostMessageInternal(JSContext* aCx, JS::Handle<JS::Value> aMessage,
ErrorResult& aRv);
void UpdateMustKeepAlive();
bool IsCertainlyAliveForCC() const override
{
return mIsKeptAlive;
}
void RemoveDocFromBFCache();
RefPtr<BroadcastChannelChild> mActor;
@ -117,8 +96,6 @@ private:
nsCString mOrigin;
nsString mChannel;
bool mIsKeptAlive;
uint64_t mInnerID;
enum {

View File

@ -49,6 +49,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMEventTargetHelper)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK(mListenerManager)
tmp->MaybeDontKeepAlive();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN(DOMEventTargetHelper)
@ -162,6 +163,8 @@ DOMEventTargetHelper::DisconnectFromOwner()
mListenerManager->Disconnect();
mListenerManager = nullptr;
}
MaybeDontKeepAlive();
}
nsPIDOMWindowInner*
@ -384,7 +387,7 @@ DOMEventTargetHelper::WantsUntrusted(bool* aRetVal)
{
nsresult rv = CheckInnerWindowCorrectness();
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocument> doc = GetDocumentIfCurrent();
// We can let listeners on workers to always handle all the events.
*aRetVal = (doc && !nsContentUtils::IsChromeDoc(doc)) || !NS_IsMainThread();
@ -394,15 +397,105 @@ DOMEventTargetHelper::WantsUntrusted(bool* aRetVal)
void
DOMEventTargetHelper::EventListenerAdded(nsIAtom* aType)
{
ErrorResult rv;
IgnoredErrorResult rv;
EventListenerWasAdded(Substring(nsDependentAtomString(aType), 2), rv);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::EventListenerAdded(const nsAString& aType)
{
IgnoredErrorResult rv;
EventListenerWasAdded(aType, rv);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::EventListenerRemoved(nsIAtom* aType)
{
ErrorResult rv;
IgnoredErrorResult rv;
EventListenerWasRemoved(Substring(nsDependentAtomString(aType), 2), rv);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::EventListenerRemoved(const nsAString& aType)
{
IgnoredErrorResult rv;
EventListenerWasRemoved(aType, rv);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::KeepAliveIfHasListenersFor(const nsAString& aType)
{
mKeepingAliveTypes.mStrings.AppendElement(aType);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::KeepAliveIfHasListenersFor(nsIAtom* aType)
{
mKeepingAliveTypes.mAtoms.AppendElement(aType);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::IgnoreKeepAliveIfHasListenersFor(const nsAString& aType)
{
mKeepingAliveTypes.mStrings.RemoveElement(aType);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::IgnoreKeepAliveIfHasListenersFor(nsIAtom* aType)
{
mKeepingAliveTypes.mAtoms.RemoveElement(aType);
MaybeUpdateKeepAlive();
}
void
DOMEventTargetHelper::MaybeUpdateKeepAlive()
{
bool shouldBeKeptAlive = false;
if (!mKeepingAliveTypes.mAtoms.IsEmpty()) {
for (uint32_t i = 0; i < mKeepingAliveTypes.mAtoms.Length(); ++i) {
if (HasListenersFor(mKeepingAliveTypes.mAtoms[i])) {
shouldBeKeptAlive = true;
break;
}
}
}
if (!shouldBeKeptAlive && !mKeepingAliveTypes.mStrings.IsEmpty()) {
for (uint32_t i = 0; i < mKeepingAliveTypes.mStrings.Length(); ++i) {
if (HasListenersFor(mKeepingAliveTypes.mStrings[i])) {
shouldBeKeptAlive = true;
break;
}
}
}
if (shouldBeKeptAlive == mIsKeptAlive) {
return;
}
mIsKeptAlive = shouldBeKeptAlive;
if (mIsKeptAlive) {
AddRef();
} else {
Release();
}
}
void
DOMEventTargetHelper::MaybeDontKeepAlive()
{
if (mIsKeptAlive) {
mIsKeptAlive = false;
Release();
}
}
} // namespace mozilla

View File

@ -37,12 +37,14 @@ public:
: mParentObject(nullptr)
, mOwnerWindow(nullptr)
, mHasOrHasHadOwnerWindow(false)
, mIsKeptAlive(false)
{
}
explicit DOMEventTargetHelper(nsPIDOMWindowInner* aWindow)
: mParentObject(nullptr)
, mOwnerWindow(nullptr)
, mHasOrHasHadOwnerWindow(false)
, mIsKeptAlive(false)
{
BindToOwner(aWindow);
}
@ -50,6 +52,7 @@ public:
: mParentObject(nullptr)
, mOwnerWindow(nullptr)
, mHasOrHasHadOwnerWindow(false)
, mIsKeptAlive(false)
{
BindToOwner(aGlobalObject);
}
@ -57,6 +60,7 @@ public:
: mParentObject(nullptr)
, mOwnerWindow(nullptr)
, mHasOrHasHadOwnerWindow(false)
, mIsKeptAlive(false)
{
BindToOwner(aOther);
}
@ -146,7 +150,7 @@ public:
void BindToOwner(nsIGlobalObject* aOwner);
void BindToOwner(nsPIDOMWindowInner* aOwner);
void BindToOwner(DOMEventTargetHelper* aOther);
virtual void DisconnectFromOwner();
virtual void DisconnectFromOwner();
nsIGlobalObject* GetParentObject() const
{
return GetOwnerGlobal();
@ -159,7 +163,11 @@ public:
bool HasOrHasHadOwner() { return mHasOrHasHadOwnerWindow; }
virtual void EventListenerAdded(nsIAtom* aType) override;
virtual void EventListenerAdded(const nsAString& aType) override;
virtual void EventListenerRemoved(nsIAtom* aType) override;
virtual void EventListenerRemoved(const nsAString& aType) override;
virtual void EventListenerWasAdded(const nsAString& aType,
ErrorResult& aRv,
JSCompartment* aCompartment = nullptr) {}
@ -174,12 +182,15 @@ protected:
nsresult WantsUntrusted(bool* aRetVal);
void MaybeUpdateKeepAlive();
void MaybeDontKeepAlive();
// If this method returns true your object is kept alive until it returns
// false. You can use this method instead using
// NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_BEGIN macro.
virtual bool IsCertainlyAliveForCC() const
{
return false;
return mIsKeptAlive;
}
RefPtr<EventListenerManager> mListenerManager;
@ -187,6 +198,13 @@ protected:
nsresult DispatchTrustedEvent(nsIDOMEvent* aEvent);
virtual void LastRelease() {}
void KeepAliveIfHasListenersFor(const nsAString& aType);
void KeepAliveIfHasListenersFor(nsIAtom* aType);
void IgnoreKeepAliveIfHasListenersFor(const nsAString& aType);
void IgnoreKeepAliveIfHasListenersFor(nsIAtom* aType);
private:
// Inner window or sandbox.
nsWeakPtr mParentObject;
@ -195,6 +213,13 @@ private:
// It is obtained in BindToOwner and reset in DisconnectFromOwner.
nsPIDOMWindowInner* MOZ_NON_OWNING_REF mOwnerWindow;
bool mHasOrHasHadOwnerWindow;
struct {
nsTArray<nsString> mStrings;
nsTArray<nsCOMPtr<nsIAtom>> mAtoms;
} mKeepingAliveTypes;
bool mIsKeptAlive;
};
NS_DEFINE_STATIC_IID_ACCESSOR(DOMEventTargetHelper,

View File

@ -424,8 +424,12 @@ EventListenerManager::AddEventListenerInternal(
ProcessApzAwareEventListenerAdd();
}
if (aTypeAtom && mTarget) {
mTarget->EventListenerAdded(aTypeAtom);
if (mTarget) {
if (aTypeAtom) {
mTarget->EventListenerAdded(aTypeAtom);
} else if (!aTypeString.IsEmpty()) {
mTarget->EventListenerAdded(aTypeString);
}
}
if (mIsMainThreadELM && mTarget) {
@ -611,14 +615,19 @@ EventListenerManager::DisableDevice(EventMessage aEventMessage)
}
void
EventListenerManager::NotifyEventListenerRemoved(nsIAtom* aUserType)
EventListenerManager::NotifyEventListenerRemoved(nsIAtom* aUserType,
const nsAString& aTypeString)
{
// If the following code is changed, other callsites of EventListenerRemoved
// and NotifyAboutMainThreadListenerChange should be changed too.
mNoListenerForEvent = eVoidEvent;
mNoListenerForEventAtom = nullptr;
if (mTarget && aUserType) {
mTarget->EventListenerRemoved(aUserType);
if (mTarget) {
if (aUserType) {
mTarget->EventListenerRemoved(aUserType);
} else if (!aTypeString.IsEmpty()) {
mTarget->EventListenerRemoved(aTypeString);
}
}
if (mIsMainThreadELM && mTarget) {
EventListenerService::NotifyAboutMainThreadListenerChange(mTarget,
@ -653,7 +662,7 @@ EventListenerManager::RemoveEventListenerInternal(
if (listener->mListener == aListenerHolder &&
listener->mFlags.EqualsForRemoval(aFlags)) {
mListeners.RemoveElementAt(i);
NotifyEventListenerRemoved(aUserType);
NotifyEventListenerRemoved(aUserType, aTypeString);
if (!aAllEvents && deviceType) {
DisableDevice(aEventMessage);
}
@ -787,9 +796,14 @@ EventListenerManager::SetEventHandlerInternal(
bool same = jsEventHandler->GetTypedEventHandler() == aTypedHandler;
// Possibly the same listener, but update still the context and scope.
jsEventHandler->SetHandler(aTypedHandler);
if (mTarget && !same && aName) {
mTarget->EventListenerRemoved(aName);
mTarget->EventListenerAdded(aName);
if (mTarget && !same) {
if (aName) {
mTarget->EventListenerRemoved(aName);
mTarget->EventListenerAdded(aName);
} else if (!aTypeString.IsEmpty()) {
mTarget->EventListenerRemoved(aTypeString);
mTarget->EventListenerAdded(aTypeString);
}
}
if (mIsMainThreadELM && mTarget) {
EventListenerService::NotifyAboutMainThreadListenerChange(mTarget, aName);
@ -911,7 +925,7 @@ EventListenerManager::RemoveEventHandler(nsIAtom* aName,
if (listener) {
mListeners.RemoveElementAt(uint32_t(listener - &mListeners.ElementAt(0)));
NotifyEventListenerRemoved(aName);
NotifyEventListenerRemoved(aName, aTypeString);
if (IsDeviceType(eventMessage)) {
DisableDevice(eventMessage);
}
@ -1342,7 +1356,8 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext,
mListeners.RemoveElementsBy([](const Listener& aListener) {
return aListener.mListenerType == Listener::eNoListener;
});
NotifyEventListenerRemoved(aEvent->mSpecifiedEventType);
NotifyEventListenerRemoved(aEvent->mSpecifiedEventType,
aEvent->mSpecifiedEventTypeString);
if (IsDeviceType(aEvent->mMessage)) {
// This is a device-type event, we need to check whether we can
// disable device after removing the once listeners.

View File

@ -605,7 +605,8 @@ protected:
const EventListenerFlags& aFlags,
bool aAllEvents = false);
void RemoveAllListeners();
void NotifyEventListenerRemoved(nsIAtom* aUserType);
void NotifyEventListenerRemoved(nsIAtom* aUserType,
const nsAString& aTypeString);
const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);
nsPIDOMWindowInner* GetInnerWindowForTarget();

View File

@ -70,7 +70,10 @@ public:
// Note, for an event 'foo' aType will be 'onfoo'.
virtual void EventListenerAdded(nsIAtom* aType) {}
virtual void EventListenerAdded(const nsAString& aType) {}
virtual void EventListenerRemoved(nsIAtom* aType) {}
virtual void EventListenerRemoved(const nsAString& aType) {}
// Returns an outer window that corresponds to the inner window this event
// target is associated with. Will return null if the inner window is not the

View File

@ -1089,6 +1089,10 @@ RemoteInputStream::SetStream(nsIInputStream* aStream)
nsresult
RemoteInputStream::BlockAndWaitForStream()
{
if (mStream) {
return NS_OK;
}
if (IsOnOwningThread()) {
if (NS_IsMainThread()) {
NS_WARNING("Blocking the main thread is not supported!");

View File

@ -27,7 +27,10 @@ public:
IMPL_EVENT_HANDLER(audioprocess)
using EventTarget::EventListenerAdded;
void EventListenerAdded(nsIAtom* aType) override;
using EventTarget::EventListenerRemoved;
void EventListenerRemoved(nsIAtom* aType) override;
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;

View File

@ -164,9 +164,7 @@ UsageRequest::GetResult(nsIVariant** aResult)
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(mResult);
NS_ADDREF(*aResult = mResult);
NS_IF_ADDREF(*aResult = mResult);
return NS_OK;
}
@ -261,9 +259,7 @@ Request::GetResult(nsIVariant** aResult)
return NS_ERROR_FAILURE;
}
MOZ_ASSERT(mResult);
NS_ADDREF(*aResult = mResult);
NS_IF_ADDREF(*aResult = mResult);
return NS_OK;
}

View File

@ -134,6 +134,7 @@ function* testSteps()
ok(request.resultCode === NS_ERROR_FAILURE,
"Persist() failed because of the invalid origin");
ok(request.result === null, "The request result is null");
originDir = getRelativeFile(origins[1].path);
exists = originDir.exists();

View File

@ -93,6 +93,7 @@ function* testSteps()
yield undefined;
ok(request.resultCode == NS_ERROR_UNEXPECTED, "Initialization failed");
ok(request.result === null, "The request result is null");
info("Clearing origin");
@ -128,6 +129,7 @@ function* testSteps()
yield undefined;
ok(request.resultCode == NS_ERROR_UNEXPECTED, "Initialization failed");
ok(request.result === null, "The request result is null");
info("Getting usage");
@ -135,6 +137,7 @@ function* testSteps()
yield undefined;
ok(request.resultCode == NS_ERROR_UNEXPECTED, "Get usage failed");
ok(request.result === null, "The request result is null");
file.remove(/* recursive */ false);

View File

@ -654,7 +654,7 @@ CompositorBridgeChild::SharedFrameMetricsData::SharedFrameMetricsData(
, mAPZCId(aAPZCId)
{
mBuffer = new ipc::SharedMemoryBasic;
mBuffer->SetHandle(metrics);
mBuffer->SetHandle(metrics, ipc::SharedMemory::RightsReadOnly);
mBuffer->Map(sizeof(FrameMetrics));
mMutex = new CrossProcessMutex(handle);
MOZ_COUNT_CTOR(SharedFrameMetricsData);
@ -672,7 +672,8 @@ CompositorBridgeChild::SharedFrameMetricsData::~SharedFrameMetricsData()
void
CompositorBridgeChild::SharedFrameMetricsData::CopyFrameMetrics(FrameMetrics* aFrame)
{
FrameMetrics* frame = static_cast<FrameMetrics*>(mBuffer->memory());
const FrameMetrics* frame =
static_cast<const FrameMetrics*>(mBuffer->memory());
MOZ_ASSERT(frame);
mMutex->Lock();
*aFrame = *frame;
@ -682,7 +683,8 @@ CompositorBridgeChild::SharedFrameMetricsData::CopyFrameMetrics(FrameMetrics* aF
FrameMetrics::ViewID
CompositorBridgeChild::SharedFrameMetricsData::GetViewID()
{
FrameMetrics* frame = static_cast<FrameMetrics*>(mBuffer->memory());
const FrameMetrics* frame =
static_cast<const FrameMetrics*>(mBuffer->memory());
MOZ_ASSERT(frame);
// Not locking to read of mScrollId since it should not change after being
// initially set.

View File

@ -76,7 +76,7 @@ CrossProcessMutex::CrossProcessMutex(CrossProcessMutexHandle aHandle)
MOZ_CRASH();
}
if (!mSharedBuffer->SetHandle(aHandle)) {
if (!mSharedBuffer->SetHandle(aHandle, ipc::SharedMemory::RightsReadWrite)) {
MOZ_CRASH();
}

View File

@ -67,7 +67,7 @@ CrossProcessSemaphore::CrossProcessSemaphore(CrossProcessSemaphoreHandle aHandle
MOZ_CRASH();
}
if (!mSharedBuffer->SetHandle(aHandle)) {
if (!mSharedBuffer->SetHandle(aHandle, ipc::SharedMemory::RightsReadWrite)) {
MOZ_CRASH();
}

View File

@ -49,6 +49,11 @@ public:
TYPE_UNKNOWN
};
enum OpenRights {
RightsReadOnly = RightsRead,
RightsReadWrite = RightsRead | RightsWrite,
};
size_t Size() const { return mMappedSize; }
virtual void* memory() const = 0;
@ -124,7 +129,7 @@ public:
virtual bool ShareToProcess(base::ProcessId aProcessId, Handle* aHandle) = 0;
virtual bool IsHandleValid(const Handle& aHandle) const = 0;
virtual bool SetHandle(const Handle& aHandle) = 0;
virtual bool SetHandle(const Handle& aHandle, OpenRights aRights) = 0;
virtual bool ShareHandle(base::ProcessId aProcessId, IPC::Message* aMessage) override
{
@ -141,7 +146,7 @@ public:
Handle handle;
return IPC::ReadParam(aMessage, aIter, &handle) &&
IsHandleValid(handle) &&
SetHandle(handle);
SetHandle(handle, RightsReadWrite);
}
};

View File

@ -37,6 +37,7 @@ LogError(const char* what)
SharedMemoryBasic::SharedMemoryBasic()
: mShmFd(-1)
, mMemory(nullptr)
, mOpenRights(RightsReadWrite)
{ }
SharedMemoryBasic::~SharedMemoryBasic()
@ -46,10 +47,11 @@ SharedMemoryBasic::~SharedMemoryBasic()
}
bool
SharedMemoryBasic::SetHandle(const Handle& aHandle)
SharedMemoryBasic::SetHandle(const Handle& aHandle, OpenRights aRights)
{
MOZ_ASSERT(-1 == mShmFd, "Already Create()d");
mShmFd = aHandle.fd;
mOpenRights = aRights;
return true;
}
@ -81,8 +83,13 @@ SharedMemoryBasic::Map(size_t nBytes)
{
MOZ_ASSERT(nullptr == mMemory, "Already Map()d");
int prot = PROT_READ;
if (mOpenRights == RightsReadWrite) {
prot |= PROT_WRITE;
}
mMemory = mmap(nullptr, nBytes,
PROT_READ | PROT_WRITE,
prot,
MAP_SHARED,
mShmFd,
0);
@ -132,6 +139,7 @@ SharedMemoryBasic::CloseHandle()
if (mShmFd != -1) {
close(mShmFd);
mShmFd = -1;
mOpenRights = RightsReadWrite;
}
}

View File

@ -24,7 +24,7 @@ class SharedMemoryBasic final : public SharedMemoryCommon<base::FileDescriptor>
public:
SharedMemoryBasic();
virtual bool SetHandle(const Handle& aHandle) override;
virtual bool SetHandle(const Handle& aHandle, OpenRights aRights) override;
virtual bool Create(size_t aNbytes) override;
@ -64,6 +64,8 @@ private:
int mShmFd;
// Pointer to mapped region, null if unmapped.
void *mMemory;
// Access rights to map an existing region with.
OpenRights mOpenRights;
};
} // namespace ipc

View File

@ -27,8 +27,8 @@ public:
{
}
virtual bool SetHandle(const Handle& aHandle) override {
return mSharedMemory.SetHandle(aHandle, false);
virtual bool SetHandle(const Handle& aHandle, OpenRights aRights) override {
return mSharedMemory.SetHandle(aHandle, aRights == RightsReadOnly);
}
virtual bool Create(size_t aNbytes) override

View File

@ -40,7 +40,7 @@ public:
SharedMemoryBasic();
virtual bool SetHandle(const Handle& aHandle) override;
virtual bool SetHandle(const Handle& aHandle, OpenRights aRights) override;
virtual bool Create(size_t aNbytes) override;
@ -76,6 +76,8 @@ private:
mach_port_t mPort;
// Pointer to mapped region, null if unmapped.
void *mMemory;
// Access rights to map an existing region with.
OpenRights mOpenRights;
};
} // namespace ipc

View File

@ -499,6 +499,7 @@ SharedMemoryBasic::CleanupForPid(pid_t pid)
SharedMemoryBasic::SharedMemoryBasic()
: mPort(MACH_PORT_NULL)
, mMemory(nullptr)
, mOpenRights(RightsReadWrite)
{
}
@ -509,11 +510,12 @@ SharedMemoryBasic::~SharedMemoryBasic()
}
bool
SharedMemoryBasic::SetHandle(const Handle& aHandle)
SharedMemoryBasic::SetHandle(const Handle& aHandle, OpenRights aRights)
{
MOZ_ASSERT(mPort == MACH_PORT_NULL, "already initialized");
mPort = aHandle;
mOpenRights = aRights;
return true;
}
@ -532,6 +534,8 @@ toVMAddress(void* pointer)
bool
SharedMemoryBasic::Create(size_t size)
{
MOZ_ASSERT(mPort == MACH_PORT_NULL, "already initialized");
mach_vm_address_t address;
kern_return_t kr = mach_vm_allocate(mach_task_self(), &address, round_page(size), VM_FLAGS_ANYWHERE);
@ -574,7 +578,10 @@ SharedMemoryBasic::Map(size_t size)
kern_return_t kr;
mach_vm_address_t address = 0;
vm_prot_t vmProtection = VM_PROT_READ | VM_PROT_WRITE;
vm_prot_t vmProtection = VM_PROT_READ;
if (mOpenRights == RightsReadWrite) {
vmProtection |= VM_PROT_WRITE;
}
kr = mach_vm_map(mach_task_self(), &address, round_page(size), 0, VM_FLAGS_ANYWHERE,
mPort, 0, false, vmProtection, vmProtection, VM_INHERIT_NONE);
@ -665,6 +672,7 @@ SharedMemoryBasic::CloseHandle()
if (mPort != MACH_PORT_NULL) {
mach_port_deallocate(mach_task_self(), mPort);
mPort = MACH_PORT_NULL;
mOpenRights = RightsReadWrite;
}
}

View File

@ -0,0 +1,15 @@
const d = 0;
function f() {
var m = Math;
(function () {
d = m;
})()
}
for (var i = 0; i < 4; i++) {
try {
f();
} catch (e) {
continue;
}
throw "Fail";
}

View File

@ -7542,16 +7542,12 @@ AbortReasonOr<Ok>
IonBuilder::jsop_bindname(PropertyName* name)
{
MDefinition* envChain;
if (analysis().usesEnvironmentChain()) {
envChain = current->environmentChain();
} else {
// We take the slow path when trying to BINDGNAME a name that resolves
// to a 'const' or an uninitialized binding.
MOZ_ASSERT(JSOp(*pc) == JSOP_BINDGNAME);
if (IsGlobalOp(JSOp(*pc)) && !script()->hasNonSyntacticScope())
envChain = constant(ObjectValue(script()->global().lexicalEnvironment()));
}
MBindNameCache* ins = MBindNameCache::New(alloc(), envChain, name, script(), pc);
else
envChain = current->environmentChain();
MBindNameCache* ins = MBindNameCache::New(alloc(), envChain, name, script(), pc);
current->add(ins);
current->push(ins);

View File

@ -24,12 +24,13 @@ MediaQueryList::MediaQueryList(nsIDocument* aDocument,
const nsAString& aMediaQueryList)
: mDocument(aDocument)
, mMatchesValid(false)
, mIsKeptAlive(false)
{
mMediaList =
MediaList::Create(aDocument->GetStyleBackendType(), aMediaQueryList);
PR_INIT_CLIST(this);
KeepAliveIfHasListenersFor(ONCHANGE_STRING);
}
MediaQueryList::~MediaQueryList()
@ -108,12 +109,6 @@ MediaQueryList::AddEventListener(const nsAString& aType,
DOMEventTargetHelper::AddEventListener(aType, aCallback, aOptions,
aWantsUntrusted, aRv);
if (aRv.Failed()) {
return;
}
UpdateMustKeepAlive();
}
void
@ -129,63 +124,6 @@ MediaQueryList::RemoveListener(EventListener* aListener, ErrorResult& aRv)
RemoveEventListener(ONCHANGE_STRING, aListener, options, aRv);
}
void
MediaQueryList::RemoveEventListener(const nsAString& aType,
EventListener* aCallback,
const EventListenerOptionsOrBoolean& aOptions,
ErrorResult& aRv)
{
DOMEventTargetHelper::RemoveEventListener(aType, aCallback, aOptions, aRv);
if (aRv.Failed()) {
return;
}
UpdateMustKeepAlive();
}
EventHandlerNonNull*
MediaQueryList::GetOnchange()
{
if (NS_IsMainThread()) {
return GetEventHandler(nsGkAtoms::onchange, EmptyString());
}
return GetEventHandler(nullptr, ONCHANGE_STRING);
}
void
MediaQueryList::SetOnchange(EventHandlerNonNull* aCallback)
{
if (NS_IsMainThread()) {
SetEventHandler(nsGkAtoms::onchange, EmptyString(), aCallback);
} else {
SetEventHandler(nullptr, ONCHANGE_STRING, aCallback);
}
UpdateMustKeepAlive();
}
void
MediaQueryList::UpdateMustKeepAlive()
{
bool toKeepAlive = HasListeners();
if (toKeepAlive == mIsKeptAlive) {
return;
}
// When we have listeners, the pres context owns a reference to
// this. This is a cyclic reference that can only be broken by
// cycle collection.
mIsKeptAlive = toKeepAlive;
if (toKeepAlive) {
NS_ADDREF_THIS();
} else {
NS_RELEASE_THIS();
}
}
bool
MediaQueryList::HasListeners()
{
@ -197,11 +135,7 @@ MediaQueryList::Disconnect()
{
DisconnectFromOwner();
if (mIsKeptAlive) {
mIsKeptAlive = false;
// See NS_ADDREF_THIS() in AddListener.
NS_RELEASE_THIS();
}
IgnoreKeepAliveIfHasListenersFor(ONCHANGE_STRING);
}
void

View File

@ -53,21 +53,15 @@ public:
void AddListener(EventListener* aListener, ErrorResult& aRv);
void RemoveListener(EventListener* aListener, ErrorResult& aRv);
EventHandlerNonNull* GetOnchange();
void SetOnchange(EventHandlerNonNull* aCallback);
using nsIDOMEventTarget::AddEventListener;
using nsIDOMEventTarget::RemoveEventListener;
virtual void AddEventListener(const nsAString& aType,
EventListener* aCallback,
const AddEventListenerOptionsOrBoolean& aOptions,
const Nullable<bool>& aWantsUntrusted,
ErrorResult& aRv) override;
virtual void RemoveEventListener(const nsAString& aType,
EventListener* aCallback,
const EventListenerOptionsOrBoolean& aOptions,
ErrorResult& aRv) override;
IMPL_EVENT_HANDLER(change)
bool HasListeners();
@ -76,8 +70,6 @@ public:
private:
void RecomputeMatches();
void UpdateMustKeepAlive();
// We only need a pointer to the document to support lazy
// reevaluation following dynamic changes. However, this lazy
// reevaluation is perhaps somewhat important, since some usage
@ -97,7 +89,6 @@ private:
RefPtr<MediaList> mMediaList;
bool mMatches;
bool mMatchesValid;
bool mIsKeptAlive;
};
} // namespace dom

View File

@ -0,0 +1,18 @@
<!doctype html>
<html>
<style>
div::first-line {
--bar: left;
}
span {
animation: var(--bar) 5s infinite alternate;
}
@keyframes left {
from {left: 0;}
to {left: 30px;}
}
</style>
<div>
<span>Crash</span>
</div>
</html>

View File

@ -170,3 +170,4 @@ load 1328535-1.html
load 1331272.html
HTTP load 1333001-1.html
pref(dom.animations-api.core.enabled,true) load 1340344.html
load 1356601-1.html

View File

@ -2573,9 +2573,23 @@ nsRuleNode::WalkRuleTree(const nsStyleStructID aSID,
if (!highestNode)
highestNode = rootNode;
if (!ruleData.mConditions.CacheableWithoutDependencies())
detail = eRulePartialMixed; // Treat as though some data is specified to avoid
// the optimizations and force data computation.
MOZ_ASSERT(!(aSID == eStyleStruct_Variables && startStruct),
"if we start caching Variables structs in the rule tree, then "
"not forcing detail to eRulePartialMixed just below is no "
"longer valid");
if (!ruleData.mConditions.CacheableWithoutDependencies() &&
aSID != eStyleStruct_Variables) {
// Treat as though some data is specified to avoid the optimizations and
// force data computation.
//
// We don't need to do this for Variables structs since we know those are
// never cached in the rule tree, and it avoids wasteful computation of a
// new Variables struct when we have no additional variable declarations,
// which otherwise could happen when there is an AnimValuesStyleRule
// (which calls SetUncacheable for style contexts with pseudo data).
detail = eRulePartialMixed;
}
if (detail == eRuleNone && startStruct) {
// We specified absolutely no rule information, but a parent rule in the tree

View File

@ -256,6 +256,7 @@ LeafName(const char *path)
LibHandle::~LibHandle()
{
free(path);
pthread_mutex_destroy(&mutex);
}
const char *

View File

@ -104,7 +104,10 @@ public:
* of the leaf name.
*/
LibHandle(const char *path)
: directRefCnt(0), path(path ? strdup(path) : nullptr), mappable(nullptr) { }
: directRefCnt(0), path(path ? strdup(path) : nullptr), mappable(nullptr)
{
pthread_mutex_init(&mutex, nullptr);
}
/**
* Destructor.
@ -151,6 +154,7 @@ public:
*/
void AddDirectRef()
{
AutoLock lock(&mutex);
++directRefCnt;
mozilla::external::AtomicRefCounted<LibHandle>::AddRef();
}
@ -161,6 +165,7 @@ public:
*/
bool ReleaseDirectRef()
{
AutoLock lock(&mutex);
bool ret = false;
if (directRefCnt) {
MOZ_ASSERT(directRefCnt <=
@ -236,6 +241,8 @@ private:
/* Mappable object keeping the result of GetMappable() */
mutable RefPtr<Mappable> mappable;
mutable pthread_mutex_t mutex;
};
/**

View File

@ -22,4 +22,4 @@ Writing pinset facebook
Writing pinset spideroak
Writing pinset yahoo
Writing pinset swehackCom
Writing pinset nightx
Writing pinset ncsccs

View File

@ -644,21 +644,22 @@ static const StaticFingerprints kPinset_swehackCom = {
kPinset_swehackCom_Data
};
static const char* const kPinset_nightx_Data[] = {
static const char* const kPinset_ncsccs_Data[] = {
kCOMODO_Certification_AuthorityFingerprint,
kDigiCert_Assured_ID_Root_CAFingerprint,
kVeriSign_Class_3_Public_Primary_Certification_Authority___G5Fingerprint,
kVeriSign_Class_3_Public_Primary_Certification_Authority___G4Fingerprint,
kDigiCert_High_Assurance_EV_Root_CAFingerprint,
kBaltimore_CyberTrust_RootFingerprint,
kLet_s_Encrypt_Authority_X3Fingerprint,
kAddTrust_External_RootFingerprint,
kVeriSign_Universal_Root_Certification_AuthorityFingerprint,
kDigiCert_Global_Root_CAFingerprint,
kLet_s_Encrypt_Authority_X4Fingerprint,
};
static const StaticFingerprints kPinset_nightx = {
sizeof(kPinset_nightx_Data) / sizeof(const char*),
kPinset_nightx_Data
static const StaticFingerprints kPinset_ncsccs = {
sizeof(kPinset_ncsccs_Data) / sizeof(const char*),
kPinset_ncsccs_Data
};
/* Domainlist */
@ -674,7 +675,7 @@ struct TransportSecurityPreload {
/* Sort hostnames for binary search. */
static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
{ "0.me.uk", true, true, false, -1, &kPinset_nightx },
{ "0.me.uk", true, true, false, -1, &kPinset_ncsccs },
{ "2mdn.net", true, false, false, -1, &kPinset_google_root_pems },
{ "accounts.firefox.com", true, false, true, 4, &kPinset_mozilla_services },
{ "accounts.google.com", true, false, false, -1, &kPinset_google_root_pems },
@ -1048,8 +1049,8 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
{ "mx.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
{ "myaccount.google.com", true, false, false, -1, &kPinset_google_root_pems },
{ "myactivity.google.com", true, false, false, -1, &kPinset_google_root_pems },
{ "ncsccs.com", true, true, false, -1, &kPinset_ncsccs },
{ "ni.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
{ "nightx.uk", true, true, false, -1, &kPinset_nightx },
{ "nl.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
{ "no.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
{ "np.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
@ -1101,7 +1102,7 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
{ "test-mode.pinning.example.com", true, true, false, -1, &kPinset_mozilla_test },
{ "testpilot.firefox.com", false, false, true, 9, &kPinset_mozilla_services },
{ "th.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
{ "themathematician.uk", true, true, false, -1, &kPinset_nightx },
{ "themathematician.uk", true, true, false, -1, &kPinset_ncsccs },
{ "torproject.org", false, false, false, -1, &kPinset_tor },
{ "touch.facebook.com", true, false, false, -1, &kPinset_facebook },
{ "tr.search.yahoo.com", false, true, false, -1, &kPinset_yahoo },
@ -1157,4 +1158,4 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
static const int32_t kUnknownId = -1;
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1500562304986000);
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1500994095733000);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -668,6 +668,8 @@ class ScriptMixin(PlatformMixin):
socket.error,
FetchedIncorrectFilesize,
),
sleeptime=30,
attempts=5,
error_message="Can't download from {}".format(url),
error_level=FATAL,
)
@ -1108,7 +1110,8 @@ class ScriptMixin(PlatformMixin):
except retry_exceptions, e:
retry = True
error_message = "%s\nCaught exception: %s" % (error_message, str(e))
self.log('retry: attempt #%d caught exception: %s' % (n, str(e)), level=INFO)
self.log('retry: attempt #%d caught %s exception: %s' %
(n, type(e).__name__, str(e)), level=INFO)
if not retry:
return status

View File

@ -127,7 +127,7 @@ class Proxxy(ScriptMixin, LogMixin):
exit_code=3):
"""
Wrapper around BaseScript.download_file that understands proxies
retry dict is set to 3 attempts, sleeping time 30 seconds.
retry dict is set to 5 attempts, initial sleeping time 30 seconds.
Args:
url (string): url to fetch
@ -156,8 +156,8 @@ class Proxxy(ScriptMixin, LogMixin):
create_parent_dir=create_parent_dir, error_level=ERROR,
exit_code=exit_code,
retry_config=dict(
attempts=3,
sleeptime=30,
attempts=5,
error_level=INFO,
))
if retval:

View File

@ -25,11 +25,6 @@ html|*.numberbox-input {
-moz-box-align: center;
-moz-appearance: spinner-textfield;
margin-right: -1px;
border: 2px solid;
-moz-border-top-colors: ThreeDShadow ThreeDDarkShadow;
-moz-border-right-colors: ThreeDHighlight ThreeDLightShadow;
-moz-border-bottom-colors: ThreeDHighlight ThreeDLightShadow;
-moz-border-left-colors: ThreeDShadow ThreeDDarkShadow;
padding: 3px;
}

View File

@ -22,12 +22,4 @@ html|*.numberbox-input {
.numberbox-input-box {
-moz-appearance: textfield;
margin-right: 4px;
border: 3px solid;
-moz-border-top-colors: transparent #888888 #000000;
-moz-border-right-colors: transparent #FFFFFF #000000;
-moz-border-bottom-colors: transparent #FFFFFF #000000;
-moz-border-left-colors: transparent #888888 #000000;
border-top-right-radius: 2px;
border-bottom-left-radius: 2px;
background-color: -moz-Field;
}

View File

@ -4262,6 +4262,13 @@ nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam,
int16_t aButton, uint16_t aInputSource,
WinPointerInfo* aPointerInfo)
{
enum
{
eUnset,
ePrecise,
eTouch
};
static int sTouchInputActiveState = eUnset;
bool result = false;
UserActivity();
@ -4288,6 +4295,15 @@ nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam,
Telemetry::Accumulate(Telemetry::FX_TOUCH_USED, 1);
}
// Fire an observer when the user initially touches a touch screen. Front end
// uses this to modify UX.
if (sTouchInputActiveState != eTouch) {
sTouchInputActiveState = eTouch;
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
obsServ->NotifyObservers(nullptr, "touch-input-detected", nullptr);
}
if (mTouchWindow) {
// If mTouchWindow is true, then we must have APZ enabled and be
// feeding it raw touch events. In that case we don't need to
@ -4301,6 +4317,14 @@ nsWindow::DispatchMouseEvent(EventMessage aEventMessage, WPARAM wParam,
return result;
}
}
} else {
// Fire an observer when the user initially uses a mouse or pen.
if (sTouchInputActiveState != ePrecise) {
sTouchInputActiveState = ePrecise;
nsCOMPtr<nsIObserverService> obsServ =
mozilla::services::GetObserverService();
obsServ->NotifyObservers(nullptr, "precise-input-detected", nullptr);
}
}
uint32_t pointerId = aPointerInfo ? aPointerInfo->pointerId :