From 9928f8e67c6bdffcb7a2d3d3dac55e26cc0adb0c Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Fri, 27 Sep 2013 21:48:42 +1200 Subject: [PATCH 01/72] Bug 907463. Dealloc shmem on ActorDestroy. r=nical --- gfx/layers/client/CanvasClient.cpp | 24 +++++++++++++ gfx/layers/client/CanvasClient.h | 7 ++++ gfx/layers/client/CompositableClient.cpp | 10 +++++- gfx/layers/client/CompositableClient.h | 8 +++++ gfx/layers/client/ContentClient.cpp | 35 ++++++++++++++++++ gfx/layers/client/ContentClient.h | 8 +++++ gfx/layers/client/ImageClient.cpp | 27 ++++++++++++++ gfx/layers/client/ImageClient.h | 8 +++++ gfx/layers/client/TextureClient.cpp | 9 +++++ gfx/layers/client/TextureClient.h | 11 ++++++ gfx/layers/client/TiledContentClient.h | 14 ++++++++ gfx/layers/composite/CompositableHost.cpp | 9 ++++- gfx/layers/composite/CompositableHost.h | 13 +++++-- gfx/layers/composite/ContentHost.cpp | 43 +++++++++++++++++++++-- gfx/layers/composite/ContentHost.h | 4 +++ gfx/layers/composite/ImageHost.h | 14 ++++++++ gfx/layers/composite/TextureHost.cpp | 16 +++++++++ gfx/layers/composite/TextureHost.h | 8 +++++ gfx/layers/composite/TiledContentHost.h | 16 +++++++++ gfx/layers/ipc/ISurfaceAllocator.cpp | 7 ++++ gfx/layers/ipc/ISurfaceAllocator.h | 4 +++ 21 files changed, 288 insertions(+), 7 deletions(-) diff --git a/gfx/layers/client/CanvasClient.cpp b/gfx/layers/client/CanvasClient.cpp index f228b5d13c13..38585e3c54e7 100644 --- a/gfx/layers/client/CanvasClient.cpp +++ b/gfx/layers/client/CanvasClient.cpp @@ -105,6 +105,14 @@ CanvasClient2D::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFla mTextureInfo.mTextureFlags | aFlags); } +void +CanvasClient2D::OnActorDestroy() +{ + if (mBuffer) { + mBuffer->OnActorDestroy(); + } +} + void DeprecatedCanvasClient2D::Updated() { @@ -156,6 +164,14 @@ DeprecatedCanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer) mDeprecatedTextureClient->Unlock(); } +void +DeprecatedCanvasClient2D::OnActorDestroy() +{ + if (mDeprecatedTextureClient) { + mDeprecatedTextureClient->OnActorDestroy(); + } +} + void DeprecatedCanvasClientSurfaceStream::Updated() { @@ -224,5 +240,13 @@ DeprecatedCanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLaye aLayer->Painted(); } +void +DeprecatedCanvasClientSurfaceStream::OnActorDestroy() +{ + if (mDeprecatedTextureClient) { + mDeprecatedTextureClient->OnActorDestroy(); + } +} + } } diff --git a/gfx/layers/client/CanvasClient.h b/gfx/layers/client/CanvasClient.h index 5fb75dc6457c..195ce3b562ff 100644 --- a/gfx/layers/client/CanvasClient.h +++ b/gfx/layers/client/CanvasClient.h @@ -91,9 +91,12 @@ public: mBuffer = nullptr; } + virtual void OnActorDestroy() MOZ_OVERRIDE; + private: RefPtr mBuffer; }; + class DeprecatedCanvasClient2D : public CanvasClient { public: @@ -114,6 +117,8 @@ public: mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor); } + virtual void OnActorDestroy() MOZ_OVERRIDE; + private: RefPtr mDeprecatedTextureClient; }; @@ -140,6 +145,8 @@ public: mDeprecatedTextureClient->SetDescriptorFromReply(aDescriptor); } + virtual void OnActorDestroy() MOZ_OVERRIDE; + private: RefPtr mDeprecatedTextureClient; }; diff --git a/gfx/layers/client/CompositableClient.cpp b/gfx/layers/client/CompositableClient.cpp index d580a3a2b680..fe029106fe07 100644 --- a/gfx/layers/client/CompositableClient.cpp +++ b/gfx/layers/client/CompositableClient.cpp @@ -35,7 +35,6 @@ CompositableClient::~CompositableClient() Destroy(); FlushTexturesToRemoveCallbacks(); - MOZ_ASSERT(mTexturesToRemove.Length() == 0, "would leak textures pending for deletion"); } @@ -87,6 +86,7 @@ CompositableClient::Destroy() if (!mCompositableChild) { return; } + mCompositableChild->SetClient(nullptr); mCompositableChild->Destroy(); mCompositableChild = nullptr; } @@ -257,5 +257,13 @@ CompositableClient::OnTransaction() mTexturesToRemove.Clear(); } + +void +CompositableChild::ActorDestroy(ActorDestroyReason why) +{ + if (mCompositableClient && why == AbnormalShutdown) { + mCompositableClient->OnActorDestroy(); + } +} } // namespace layers } // namespace mozilla diff --git a/gfx/layers/client/CompositableClient.h b/gfx/layers/client/CompositableClient.h index 7f6fbde1763f..6078bd6feb87 100644 --- a/gfx/layers/client/CompositableClient.h +++ b/gfx/layers/client/CompositableClient.h @@ -161,6 +161,12 @@ public: * Only call this if you know what you are doing. */ void FlushTexturesToRemoveCallbacks(); + + /** + * Our IPDL actor is being destroyed, get rid of any shmem resources now. + */ + virtual void OnActorDestroy() = 0; + protected: struct TextureIDAndFlags { TextureIDAndFlags(uint64_t aID, TextureFlags aFlags) @@ -207,6 +213,8 @@ public: return mCompositableClient; } + virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; + void SetAsyncID(uint64_t aID) { mID = aID; } uint64_t GetAsyncID() const { diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index ad23e2fcac63..dbca52395590 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -327,6 +327,21 @@ ContentClientRemoteBuffer::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) } } + +void +ContentClientRemoteBuffer::OnActorDestroy() +{ + if (mDeprecatedTextureClient) { + mDeprecatedTextureClient->OnActorDestroy(); + } + if (mDeprecatedTextureClientOnWhite) { + mDeprecatedTextureClientOnWhite->OnActorDestroy(); + } + for (size_t i = 0; i < mOldTextures.Length(); ++i) { + mOldTextures[i]->OnActorDestroy(); + } +} + ContentClientDoubleBuffered::~ContentClientDoubleBuffered() { if (mDeprecatedTextureClient) { @@ -427,6 +442,26 @@ ContentClientDoubleBuffered::SwapBuffers(const nsIntRegion& aFrontUpdatedRegion) ContentClientRemoteBuffer::SwapBuffers(aFrontUpdatedRegion); } +void +ContentClientDoubleBuffered::OnActorDestroy() +{ + if (mDeprecatedTextureClient) { + mDeprecatedTextureClient->OnActorDestroy(); + } + if (mDeprecatedTextureClientOnWhite) { + mDeprecatedTextureClientOnWhite->OnActorDestroy(); + } + for (size_t i = 0; i < mOldTextures.Length(); ++i) { + mOldTextures[i]->OnActorDestroy(); + } + if (mFrontClient) { + mFrontClient->OnActorDestroy(); + } + if (mFrontClientOnWhite) { + mFrontClientOnWhite->OnActorDestroy(); + } +} + struct AutoDeprecatedTextureClient { AutoDeprecatedTextureClient() : mTexture(nullptr) diff --git a/gfx/layers/client/ContentClient.h b/gfx/layers/client/ContentClient.h index 619f370247bd..2826b3a2e445 100644 --- a/gfx/layers/client/ContentClient.h +++ b/gfx/layers/client/ContentClient.h @@ -163,6 +163,8 @@ public: MOZ_CRASH("Should not be called on non-remote ContentClient"); } + virtual void OnActorDestroy() MOZ_OVERRIDE {} + private: BasicLayerManager* mManager; }; @@ -247,6 +249,8 @@ public: return mTextureInfo; } + virtual void OnActorDestroy() MOZ_OVERRIDE; + protected: virtual nsIntRegion GetUpdatedRegion(const nsIntRegion& aRegionToDraw, const nsIntRegion& aVisibleRegion, @@ -310,6 +314,8 @@ protected: virtual void DestroyFrontBuffer() MOZ_OVERRIDE; virtual void LockFrontBuffer() MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE; + private: void UpdateDestinationFrom(const RotatedBuffer& aSource, const nsIntRegion& aUpdateRegion); @@ -395,6 +401,8 @@ public: } } + virtual void OnActorDestroy() MOZ_OVERRIDE {} + private: enum BufferType{ diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index 8fdbc4e018a5..1e20cef23d37 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -280,6 +280,25 @@ ImageClientBuffered::UpdateImage(ImageContainer* aContainer, return ImageClientSingle::UpdateImage(aContainer, aContentFlags); } +void +ImageClientSingle::OnActorDestroy() +{ + if (mFrontBuffer) { + mFrontBuffer->OnActorDestroy(); + } +} + +void +ImageClientBuffered::OnActorDestroy() +{ + if (mFrontBuffer) { + mFrontBuffer->OnActorDestroy(); + } + if (mBackBuffer) { + mBackBuffer->OnActorDestroy(); + } +} + bool ImageClientSingle::AddTextureClient(TextureClient* aTexture) { @@ -465,6 +484,14 @@ ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd, { } +void +DeprecatedImageClientSingle::OnActorDestroy() +{ + if (mDeprecatedTextureClient) { + mDeprecatedTextureClient->OnActorDestroy(); + } +} + bool ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags) { diff --git a/gfx/layers/client/ImageClient.h b/gfx/layers/client/ImageClient.h index 127d08e7c313..940696ec222f 100644 --- a/gfx/layers/client/ImageClient.h +++ b/gfx/layers/client/ImageClient.h @@ -102,6 +102,8 @@ public: virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE; + protected: RefPtr mFrontBuffer; // Some layers may want to enforce some flags to all their textures @@ -125,6 +127,8 @@ public: virtual void FlushAllImages(bool aExceptFront) MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE; + protected: RefPtr mBackBuffer; }; @@ -169,6 +173,8 @@ public: virtual already_AddRefed CreateImage(const uint32_t *aFormats, uint32_t aNumFormats) MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE; + private: RefPtr mDeprecatedTextureClient; TextureInfo mTextureInfo; @@ -210,6 +216,8 @@ public: return nullptr; } + virtual void OnActorDestroy() MOZ_OVERRIDE {} + protected: uint64_t mAsyncContainerID; ShadowableLayer* mLayer; diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 932bb10ca697..f4d67e0c21a7 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -390,6 +390,15 @@ DeprecatedTextureClient::~DeprecatedTextureClient() MOZ_ASSERT(mDescriptor.type() == SurfaceDescriptor::T__None, "Need to release surface!"); } +void +DeprecatedTextureClient::OnActorDestroy() +{ + if (ISurfaceAllocator::IsShmem(&mDescriptor)) { + mDescriptor = SurfaceDescriptor(); + } +} + + DeprecatedTextureClientShmem::DeprecatedTextureClientShmem(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo) : DeprecatedTextureClient(aForwarder, aTextureInfo) diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index 8811d5024f2c..55fad537f8d7 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -216,6 +216,10 @@ public: */ void MarkInvalid() { mValid = false; } + // If a texture client holds a reference to shmem, it should override this + // method to forget about the shmem _without_ releasing it. + virtual void OnActorDestroy() {} + protected: void AddFlags(TextureFlags aFlags) { @@ -316,6 +320,11 @@ public: ipc::Shmem& GetShmem() { return mShmem; } + virtual void OnActorDestroy() MOZ_OVERRIDE + { + mShmem = ipc::Shmem(); + } + protected: ipc::Shmem mShmem; ISurfaceAllocator* mAllocator; @@ -492,6 +501,8 @@ public: virtual gfxContentType GetContentType() = 0; + void OnActorDestroy(); + protected: DeprecatedTextureClient(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo); diff --git a/gfx/layers/client/TiledContentClient.h b/gfx/layers/client/TiledContentClient.h index dc5d3875b06d..f10a7eefbdf6 100644 --- a/gfx/layers/client/TiledContentClient.h +++ b/gfx/layers/client/TiledContentClient.h @@ -201,6 +201,14 @@ public: static BasicTiledLayerBuffer OpenDescriptor(ISurfaceAllocator* aAllocator, const SurfaceDescriptorTiles& aDescriptor); + void OnActorDestroy() + { + for (size_t i = 0; i < mRetainedTiles.Length(); i++) { + if (mRetainedTiles[i].IsPlaceholderTile()) continue; + mRetainedTiles[i].mDeprecatedTextureClient->OnActorDestroy(); + } + } + protected: BasicTiledLayerTile ValidateTile(BasicTiledLayerTile aTile, const nsIntPoint& aTileRect, @@ -290,6 +298,12 @@ public: }; void LockCopyAndWrite(TiledBufferType aType); + virtual void OnActorDestroy() MOZ_OVERRIDE + { + mTiledBuffer.OnActorDestroy(); + mLowPrecisionTiledBuffer.OnActorDestroy(); + } + private: BasicTiledLayerBuffer mTiledBuffer; BasicTiledLayerBuffer mLowPrecisionTiledBuffer; diff --git a/gfx/layers/composite/CompositableHost.cpp b/gfx/layers/composite/CompositableHost.cpp index 71112e000923..89b811924800 100644 --- a/gfx/layers/composite/CompositableHost.cpp +++ b/gfx/layers/composite/CompositableHost.cpp @@ -237,7 +237,14 @@ void CompositableParent::ActorDestroy(ActorDestroyReason why) { if (mHost) { - mHost->Detach(); + // XXX: sadness warning. We should be able to do this whenever we get ActorDestroy, + // not just for abnormal shutdowns (which is the only case we _need_ to - so that + // we don't double release our shmems). But, for some reason, that causes a + // crash, we don't know why. (Bug 925773). + if (why == AbnormalShutdown) { + mHost->OnActorDestroy(); + } + mHost->Detach(nullptr, CompositableHost::FORCE_DETACH); } } diff --git a/gfx/layers/composite/CompositableHost.h b/gfx/layers/composite/CompositableHost.h index 91d1f07e5309..ef0525112ab5 100644 --- a/gfx/layers/composite/CompositableHost.h +++ b/gfx/layers/composite/CompositableHost.h @@ -107,6 +107,12 @@ public: mBackendData = aBackendData; } + /** + * Our IPDL actor is being destroyed, get rid of any shmem resources now and + * don't worry about compositing anymore. + */ + virtual void OnActorDestroy() = 0; + // If base class overrides, it should still call the parent implementation virtual void SetCompositor(Compositor* aCompositor); @@ -237,6 +243,7 @@ public: static const AttachFlags NO_FLAGS = 0; static const AttachFlags ALLOW_REATTACH = 1; static const AttachFlags KEEP_ATTACHED = 2; + static const AttachFlags FORCE_DETACH = 2; virtual void Attach(Layer* aLayer, Compositor* aCompositor, @@ -257,10 +264,12 @@ public: // attached to that layer. If we are part of a normal layer, then we will be // detached in any case. if aLayer is null, then we will only detach if we are // not async. - void Detach(Layer* aLayer = nullptr) + // Only force detach if the IPDL tree is being shutdown. + void Detach(Layer* aLayer = nullptr, AttachFlags aFlags = NO_FLAGS) { if (!mKeepAttached || - aLayer == mLayer) { + aLayer == mLayer || + aFlags & FORCE_DETACH) { SetLayer(nullptr); SetCompositor(nullptr); mAttached = false; diff --git a/gfx/layers/composite/ContentHost.cpp b/gfx/layers/composite/ContentHost.cpp index fadf78b1b360..9ce57feb4a1e 100644 --- a/gfx/layers/composite/ContentHost.cpp +++ b/gfx/layers/composite/ContentHost.cpp @@ -52,6 +52,23 @@ ContentHostBase::DestroyFrontHost() mDeprecatedTextureHostOnWhite = nullptr; } +void +ContentHostBase::OnActorDestroy() +{ + if (mDeprecatedTextureHost) { + mDeprecatedTextureHost->OnActorDestroy(); + } + if (mDeprecatedTextureHostOnWhite) { + mDeprecatedTextureHostOnWhite->OnActorDestroy(); + } + if (mNewFrontHost) { + mNewFrontHost->OnActorDestroy(); + } + if (mNewFrontHostOnWhite) { + mNewFrontHostOnWhite->OnActorDestroy(); + } +} + void ContentHostBase::Composite(EffectChain& aEffectChain, float aOpacity, @@ -409,19 +426,16 @@ ContentHostDoubleBuffered::DestroyTextures() "We won't be able to destroy our SurfaceDescriptor"); mNewFrontHost = nullptr; } - if (mNewFrontHostOnWhite) { MOZ_ASSERT(mNewFrontHostOnWhite->GetDeAllocator(), "We won't be able to destroy our SurfaceDescriptor"); mNewFrontHostOnWhite = nullptr; } - if (mBackHost) { MOZ_ASSERT(mBackHost->GetDeAllocator(), "We won't be able to destroy our SurfaceDescriptor"); mBackHost = nullptr; } - if (mBackHostOnWhite) { MOZ_ASSERT(mBackHostOnWhite->GetDeAllocator(), "We won't be able to destroy our SurfaceDescriptor"); @@ -431,6 +445,29 @@ ContentHostDoubleBuffered::DestroyTextures() // don't touch mDeprecatedTextureHost, we might need it for compositing } +void +ContentHostDoubleBuffered::OnActorDestroy() +{ + if (mDeprecatedTextureHost) { + mDeprecatedTextureHost->OnActorDestroy(); + } + if (mDeprecatedTextureHostOnWhite) { + mDeprecatedTextureHostOnWhite->OnActorDestroy(); + } + if (mNewFrontHost) { + mNewFrontHost->OnActorDestroy(); + } + if (mNewFrontHostOnWhite) { + mNewFrontHostOnWhite->OnActorDestroy(); + } + if (mBackHost) { + mBackHost->OnActorDestroy(); + } + if (mBackHostOnWhite) { + mBackHostOnWhite->OnActorDestroy(); + } +} + void ContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData, const nsIntRegion& aUpdated, diff --git a/gfx/layers/composite/ContentHost.h b/gfx/layers/composite/ContentHost.h index f5095090dd1f..4b23505f6df7 100644 --- a/gfx/layers/composite/ContentHost.h +++ b/gfx/layers/composite/ContentHost.h @@ -127,6 +127,8 @@ public: // destroy our front buffer so that we can continue to composite. virtual void DestroyTextures() = 0; + virtual void OnActorDestroy() MOZ_OVERRIDE; + protected: virtual nsIntPoint GetOriginOffset() { @@ -177,6 +179,8 @@ public: const TextureInfo& aTextureInfo) MOZ_OVERRIDE; virtual void DestroyTextures() MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE; + #ifdef MOZ_DUMP_PAINTING virtual void Dump(FILE* aFile=nullptr, const char* aPrefix="", diff --git a/gfx/layers/composite/ImageHost.h b/gfx/layers/composite/ImageHost.h index 0310e29c2a61..19e07ca8befb 100644 --- a/gfx/layers/composite/ImageHost.h +++ b/gfx/layers/composite/ImageHost.h @@ -68,6 +68,13 @@ public: virtual LayerRenderState GetRenderState() MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE + { + if (mFrontBuffer) { + mFrontBuffer->OnActorDestroy(); + } + } + virtual void PrintInfo(nsACString& aTo, const char* aPrefix); #ifdef MOZ_DUMP_PAINTING @@ -128,6 +135,13 @@ public: virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE + { + if (mDeprecatedTextureHost) { + mDeprecatedTextureHost->OnActorDestroy(); + } + } + virtual void PrintInfo(nsACString& aTo, const char* aPrefix); #ifdef MOZ_DUMP_PAINTING diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 1d57bcae8820..347891e2296c 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -242,6 +242,15 @@ DeprecatedTextureHost::SwapTextures(const SurfaceDescriptor& aImage, SetBuffer(mBuffer, mDeAllocator); } +void +DeprecatedTextureHost::OnActorDestroy() +{ + if (ISurfaceAllocator::IsShmem(mBuffer)) { + *mBuffer = SurfaceDescriptor(); + mBuffer = nullptr; + } +} + void DeprecatedTextureHost::PrintInfo(nsACString& aTo, const char* aPrefix) { @@ -506,6 +515,13 @@ ShmemTextureHost::DeallocateSharedData() } } +void +ShmemTextureHost::OnActorDestroy() +{ + delete mShmem; + mShmem = nullptr; +} + uint8_t* ShmemTextureHost::GetBuffer() { return mShmem ? mShmem->get() : nullptr; diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index 8fa69f0e05cc..2e6a365bac9c 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -384,6 +384,10 @@ public: virtual void SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData); + // If a texture host holds a reference to shmem, it should override this method + // to forget about the shmem _without_ releasing it. + virtual void OnActorDestroy() {} + virtual const char *Name() { return "TextureHost"; } virtual void PrintInfo(nsACString& aTo, const char* aPrefix); @@ -480,6 +484,8 @@ public: virtual const char *Name() MOZ_OVERRIDE { return "ShmemTextureHost"; } + virtual void OnActorDestroy() MOZ_OVERRIDE; + protected: mozilla::ipc::Shmem* mShmem; ISurfaceAllocator* mDeallocator; @@ -710,6 +716,8 @@ public: // see bug 865908 about fixing this. virtual void ForgetBuffer() {} + void OnActorDestroy(); + protected: /** * Should be implemented by the backend-specific DeprecatedTextureHost classes diff --git a/gfx/layers/composite/TiledContentHost.h b/gfx/layers/composite/TiledContentHost.h index 06d0edb15cf1..3f7572013a7f 100644 --- a/gfx/layers/composite/TiledContentHost.h +++ b/gfx/layers/composite/TiledContentHost.h @@ -119,6 +119,16 @@ public: mCompositor = aCompositor; } + void OnActorDestroy() + { + Iterator end = TilesEnd(); + for (Iterator it = TilesBegin(); it != end; ++it) { + if (it->mDeprecatedTextureHost) { + it->mDeprecatedTextureHost->OnActorDestroy(); + } + } + } + protected: TiledTexture ValidateTile(TiledTexture aTile, const nsIntPoint& aTileRect, @@ -239,6 +249,12 @@ public: Compositor* aCompositor, AttachFlags aFlags = NO_FLAGS) MOZ_OVERRIDE; + virtual void OnActorDestroy() MOZ_OVERRIDE + { + mVideoMemoryTiledBuffer.OnActorDestroy(); + mLowPrecisionVideoMemoryTiledBuffer.OnActorDestroy(); + } + #ifdef MOZ_DUMP_PAINTING virtual void Dump(FILE* aFile=nullptr, const char* aPrefix="", diff --git a/gfx/layers/ipc/ISurfaceAllocator.cpp b/gfx/layers/ipc/ISurfaceAllocator.cpp index e465d7e0a6c3..c34d1d388093 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.cpp +++ b/gfx/layers/ipc/ISurfaceAllocator.cpp @@ -112,6 +112,13 @@ ISurfaceAllocator::AllocSurfaceDescriptorWithCaps(const gfxIntSize& aSize, return true; } +/* static */ bool +ISurfaceAllocator::IsShmem(SurfaceDescriptor* aSurface) +{ + return aSurface && (aSurface->type() == SurfaceDescriptor::TShmem || + aSurface->type() == SurfaceDescriptor::TYCbCrImage || + aSurface->type() == SurfaceDescriptor::TRGBImage); +} void ISurfaceAllocator::DestroySharedSurface(SurfaceDescriptor* aSurface) diff --git a/gfx/layers/ipc/ISurfaceAllocator.h b/gfx/layers/ipc/ISurfaceAllocator.h index fbcdc125e359..62d4bf8ea50b 100644 --- a/gfx/layers/ipc/ISurfaceAllocator.h +++ b/gfx/layers/ipc/ISurfaceAllocator.h @@ -123,6 +123,10 @@ ISurfaceAllocator() {} { return nullptr; } + + // Returns true if aSurface wraps a Shmem. + static bool IsShmem(SurfaceDescriptor* aSurface); + protected: // this method is needed for a temporary fix, will be removed after // DeprecatedTextureClient/Host rework. From 7ccb385d1f1cde80ee7c43fb4763aa53b66cfdf9 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 1 Nov 2013 15:39:24 -0400 Subject: [PATCH 02/72] Bug 933193 part 1. Factor out the id selector fast-path from querySelector(All) so we can reuse it a bit more broadly. r=smaug --- content/base/src/nsINode.cpp | 83 ++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 7cf4f1852873..35556c407fc7 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -2319,6 +2319,59 @@ AddScopeElements(TreeMatchContext& aMatchContext, } } +namespace { +struct SelectorMatchInfo { + nsCSSSelectorList* const mSelectorList; + TreeMatchContext& mMatchContext; +}; +} + +// Given an id, find elements with that id under aRoot that match aMatchInfo if +// any is provided. If no SelectorMatchInfo is provided, just find the ones +// with the given id. aRoot must be in the document. +template +inline static void +FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot, + SelectorMatchInfo* aMatchInfo, + T& aList) +{ + MOZ_ASSERT(aRoot->IsInDoc(), + "Don't call me if the root is not in the document"); + MOZ_ASSERT(aRoot->IsElement() || aRoot->IsNodeOfType(nsINode::eDOCUMENT), + "The optimization below to check ContentIsDescendantOf only for " + "elements depends on aRoot being either an element or a " + "document if it's in the document. Note that document fragments " + "can't be IsInDoc(), so should never show up here."); + + const nsSmallVoidArray* elements = aRoot->OwnerDoc()->GetAllElementsForId(aId); + + if (!elements) { + // Nothing to do; we're done + return; + } + + // XXXbz: Should we fall back to the tree walk if aRoot is not the + // document and |elements| is long, for some value of "long"? + for (int32_t i = 0; i < elements->Count(); ++i) { + Element *element = static_cast(elements->ElementAt(i)); + if (!aRoot->IsElement() || + (element != aRoot && + nsContentUtils::ContentIsDescendantOf(element, aRoot))) { + // We have an element with the right id and it's a strict descendant + // of aRoot. Make sure it really matches the selector. + if (!aMatchInfo || + nsCSSRuleProcessor::SelectorListMatches(element, + aMatchInfo->mMatchContext, + aMatchInfo->mSelectorList)) { + aList.AppendElement(element); + if (onlyFirstMatch) { + return; + } + } + } + } +} + // Actually find elements matching aSelectorList (which must not be // null) and which are descendants of aRoot and put them in aList. If // onlyFirstMatch, then stop once the first one is found. @@ -2326,7 +2379,6 @@ template MOZ_ALWAYS_INLINE static nsresult FindMatchingElements(nsINode* aRoot, const nsAString& aSelector, T &aList) { - nsIDocument* doc = aRoot->OwnerDoc(); nsIDocument::SelectorCache& cache = doc->GetSelectorCache(); nsCSSSelectorList* selectorList = nullptr; @@ -2380,32 +2432,9 @@ FindMatchingElements(nsINode* aRoot, const nsAString& aSelector, T &aList) !selectorList->mNext && selectorList->mSelectors->mIDList) { nsIAtom* id = selectorList->mSelectors->mIDList->mAtom; - const nsSmallVoidArray* elements = - doc->GetAllElementsForId(nsDependentAtomString(id)); - - // XXXbz: Should we fall back to the tree walk if aRoot is not the - // document and |elements| is long, for some value of "long"? - if (elements) { - for (int32_t i = 0; i < elements->Count(); ++i) { - Element *element = static_cast(elements->ElementAt(i)); - if (!aRoot->IsElement() || - (element != aRoot && - nsContentUtils::ContentIsDescendantOf(element, aRoot))) { - // We have an element with the right id and it's a strict descendant - // of aRoot. Make sure it really matches the selector. - if (nsCSSRuleProcessor::SelectorListMatches(element, matchingContext, - selectorList)) { - aList.AppendElement(element); - if (onlyFirstMatch) { - return NS_OK; - } - } - } - } - } - - // No elements with this id, or none of them are our descendants, - // or none of them match. We're done here. + SelectorMatchInfo info = { selectorList, matchingContext }; + FindMatchingElementsWithId(nsDependentAtomString(id), + aRoot, &info, aList); return NS_OK; } From 02ebdf4ae8f9ec26eba8384b5ec4c094d1aa4c2c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 1 Nov 2013 15:39:24 -0400 Subject: [PATCH 03/72] Bug 933193 part 2. Implement nsINode::GetElementById and make SVGSVGElement use it. r=smaug --- content/base/public/nsINode.h | 6 ++++++ content/base/src/nsINode.cpp | 23 +++++++++++++++++++++++ content/svg/content/src/SVGSVGElement.cpp | 12 ------------ content/svg/content/src/SVGSVGElement.h | 2 +- dom/webidl/SVGSVGElement.webidl | 1 - 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h index 7f19d4f8f5c8..a7007bda966f 100644 --- a/content/base/public/nsINode.h +++ b/content/base/public/nsINode.h @@ -1078,6 +1078,12 @@ public: nsresult QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn); nsresult QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn); +protected: + // nsIDocument overrides this with its own (faster) version. This + // should really only be called for elements and document fragments. + mozilla::dom::Element* GetElementById(const nsAString& aId); + +public: /** * Associate an object aData to aKey on this node. If aData is null any * previously registered object and UserDataHandler associated to aKey on diff --git a/content/base/src/nsINode.cpp b/content/base/src/nsINode.cpp index 35556c407fc7..0586b02146e4 100644 --- a/content/base/src/nsINode.cpp +++ b/content/base/src/nsINode.cpp @@ -2521,6 +2521,29 @@ nsINode::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn) return rv.ErrorCode(); } +Element* +nsINode::GetElementById(const nsAString& aId) +{ + MOZ_ASSERT(IsElement() || IsNodeOfType(eDOCUMENT_FRAGMENT), + "Bogus this object for GetElementById call"); + if (IsInDoc()) { + ElementHolder holder; + FindMatchingElementsWithId(aId, this, nullptr, holder); + return holder.mElement; + } + + for (nsIContent* kid = GetFirstChild(); kid; kid = kid->GetNextNode(this)) { + if (!kid->IsElement()) { + continue; + } + nsIAtom* id = kid->AsElement()->GetID(); + if (id && id->Equals(aId)) { + return kid->AsElement(); + } + } + return nullptr; +} + JSObject* nsINode::WrapObject(JSContext *aCx, JS::Handle aScope) { diff --git a/content/svg/content/src/SVGSVGElement.cpp b/content/svg/content/src/SVGSVGElement.cpp index bbcfd19ee65a..58bc0388d04c 100644 --- a/content/svg/content/src/SVGSVGElement.cpp +++ b/content/svg/content/src/SVGSVGElement.cpp @@ -435,18 +435,6 @@ SVGSVGElement::CreateSVGTransformFromMatrix(SVGMatrix& matrix) return transform.forget(); } -Element* -SVGSVGElement::GetElementById(const nsAString& elementId, ErrorResult& rv) -{ - nsAutoString selector(NS_LITERAL_STRING("#")); - nsStyleUtil::AppendEscapedCSSIdent(PromiseFlatString(elementId), selector); - nsIContent* element = QuerySelector(selector, rv); - if (!rv.Failed() && element) { - return element->AsElement(); - } - return nullptr; -} - //---------------------------------------------------------------------- already_AddRefed diff --git a/content/svg/content/src/SVGSVGElement.h b/content/svg/content/src/SVGSVGElement.h index fa03d26fc821..6e02d22971e8 100644 --- a/content/svg/content/src/SVGSVGElement.h +++ b/content/svg/content/src/SVGSVGElement.h @@ -246,7 +246,7 @@ public: already_AddRefed CreateSVGRect(); already_AddRefed CreateSVGTransform(); already_AddRefed CreateSVGTransformFromMatrix(SVGMatrix& matrix); - Element* GetElementById(const nsAString& elementId, ErrorResult& rv); + using nsINode::GetElementById; // This does what we want already_AddRefed ViewBox(); already_AddRefed PreserveAspectRatio(); uint16_t ZoomAndPan(); diff --git a/dom/webidl/SVGSVGElement.webidl b/dom/webidl/SVGSVGElement.webidl index 7e52d3c13537..583f3eeb0a8d 100644 --- a/dom/webidl/SVGSVGElement.webidl +++ b/dom/webidl/SVGSVGElement.webidl @@ -59,7 +59,6 @@ interface SVGSVGElement : SVGGraphicsElement { SVGTransform createSVGTransform(); [NewObject] SVGTransform createSVGTransformFromMatrix(SVGMatrix matrix); - [Throws] Element? getElementById(DOMString elementId); }; From 40c1486150890d4a4743811d738149529ea82534 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 1 Nov 2013 15:39:25 -0400 Subject: [PATCH 04/72] Bug 933193 part 3. Add getElementById to DocumentFragment. r=smaug --- content/base/src/DocumentFragment.h | 2 + content/base/test/mochitest.ini | 1 + content/base/test/test_getElementById.html | 58 ++++++++++++++++++++++ dom/webidl/DocumentFragment.webidl | 8 +-- 4 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 content/base/test/test_getElementById.html diff --git a/content/base/src/DocumentFragment.h b/content/base/src/DocumentFragment.h index c1ca920f9a29..3485afbd7782 100644 --- a/content/base/src/DocumentFragment.h +++ b/content/base/src/DocumentFragment.h @@ -40,6 +40,8 @@ public: using FragmentOrElement::GetFirstChild; using nsINode::QuerySelector; using nsINode::QuerySelectorAll; + // Make sure bindings can see our superclass' protected GetElementById method. + using nsINode::GetElementById; // nsISupports NS_DECL_ISUPPORTS_INHERITED diff --git a/content/base/test/mochitest.ini b/content/base/test/mochitest.ini index 223d2b02c815..442012a07393 100644 --- a/content/base/test/mochitest.ini +++ b/content/base/test/mochitest.ini @@ -532,6 +532,7 @@ support-files = [test_elementTraversal.html] [test_fileapi.html] [test_fileapi_slice.html] +[test_getElementById.html] [test_html_colors_quirks.html] [test_html_colors_standards.html] [test_html_in_xhr.html] diff --git a/content/base/test/test_getElementById.html b/content/base/test/test_getElementById.html new file mode 100644 index 000000000000..b0c2b01dbfc6 --- /dev/null +++ b/content/base/test/test_getElementById.html @@ -0,0 +1,58 @@ + + + + + + Test for Bug 933193 + + + + +Mozilla Bug 933193 +

+ +
+
+ + + diff --git a/dom/webidl/DocumentFragment.webidl b/dom/webidl/DocumentFragment.webidl index 45efb2968610..0f814666fb64 100644 --- a/dom/webidl/DocumentFragment.webidl +++ b/dom/webidl/DocumentFragment.webidl @@ -13,13 +13,7 @@ [Constructor] interface DocumentFragment : Node { - // NEW - /* - FIXME: not implemented yet - - void prepend((Node or DOMString)... nodes); - void append((Node or DOMString)... nodes); - */ + Element? getElementById(DOMString elementId); }; // http://www.w3.org/TR/2012/WD-selectors-api-20120628/#interface-definitions From 1c2bc77c17d305decb68d3d080e373146bd35587 Mon Sep 17 00:00:00 2001 From: Christian Holler Date: Thu, 14 Nov 2013 01:44:41 +0100 Subject: [PATCH 05/72] Bug 934641 - Switch ASan tests to using the low-memory config instead of the mid-memory config, to work around intermittent OOM failures, r=philor --- build/automation.py.in | 13 +++---------- build/automationutils.py | 13 +++---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/build/automation.py.in b/build/automation.py.in index 08763895331e..61625e59c3ff 100644 --- a/build/automation.py.in +++ b/build/automation.py.in @@ -521,19 +521,12 @@ class Automation(object): try: totalMemory = int(os.popen("free").readlines()[1].split()[1]) - # Only 2 GB RAM or less available? Use custom ASan options to reduce + # Only 4 GB RAM or less available? Use custom ASan options to reduce # the amount of resources required to do the tests. Standard options # will otherwise lead to OOM conditions on the current test slaves. - # - # If we have more than 2 GB or RAM but still less than 4 GB, we need - # another set of options to prevent OOM in some memory-intensive - # tests. - if totalMemory <= 1024 * 1024 * 2: + if totalMemory <= 1024 * 1024 * 4: self.log.info("INFO | automation.py | ASan running in low-memory configuration") - env["ASAN_OPTIONS"] = "quarantine_size=50331648:redzone=64" - elif totalMemory <= 1024 * 1024 * 4: - self.log.info("INFO | automation.py | ASan running in mid-memory configuration") - env["ASAN_OPTIONS"] = "quarantine_size=100663296:redzone=64" + env["ASAN_OPTIONS"] = "quarantine_size=50331648" else: self.log.info("INFO | automation.py | ASan running in default memory configuration") except OSError,err: diff --git a/build/automationutils.py b/build/automationutils.py index 43e04a829972..7cf803889bc6 100644 --- a/build/automationutils.py +++ b/build/automationutils.py @@ -457,20 +457,13 @@ def environment(xrePath, env=None, crashreporter=True): totalMemory = systemMemory() - # Only 2 GB RAM or less available? Use custom ASan options to reduce + # Only 4 GB RAM or less available? Use custom ASan options to reduce # the amount of resources required to do the tests. Standard options # will otherwise lead to OOM conditions on the current test slaves. - # - # If we have more than 2 GB or RAM but still less than 4 GB, we need - # another set of options to prevent OOM in some memory-intensive - # tests. message = "INFO | runtests.py | ASan running in %s configuration" - if totalMemory <= 1024 * 1024 * 2: + if totalMemory <= 1024 * 1024 * 4: message = message % 'low-memory' - env["ASAN_OPTIONS"] = "quarantine_size=50331648:redzone=64" - elif totalMemory <= 1024 * 1024 * 4: - message = message % 'mid-memory' - env["ASAN_OPTIONS"] = "quarantine_size=80530636:redzone=64" + env["ASAN_OPTIONS"] = "quarantine_size=50331648" else: message = message % 'default memory' except OSError,err: From bae6b8b955af166f620b0d00e0ec2d88b87b3bcb Mon Sep 17 00:00:00 2001 From: Matthew Gregan Date: Mon, 18 Nov 2013 17:22:47 +1300 Subject: [PATCH 06/72] Bug 939662 - Remove "using namespace mozilla::dom;" from MediaDecoder.h and fix fallout. r=cpearce --HG-- extra : rebase_source : 922db8de8e9103e3001c26f23ed7402efa8237f5 --- content/media/MediaDecoder.cpp | 8 +++--- content/media/MediaDecoder.h | 25 ++++++++----------- content/media/MediaDecoderStateMachine.cpp | 6 ++--- content/media/MediaDecoderStateMachine.h | 2 +- content/media/MediaResource.cpp | 18 ++++++------- content/media/RtspMediaResource.cpp | 6 ++--- content/media/gstreamer/GStreamerReader.cpp | 2 +- content/media/mediasource/MediaSource.h | 1 - .../media/mediasource/MediaSourceDecoder.cpp | 8 +++--- .../media/mediasource/MediaSourceDecoder.h | 8 +++--- content/media/mediasource/SubBufferDecoder.h | 2 +- content/media/ogg/OggReader.cpp | 2 +- 12 files changed, 41 insertions(+), 47 deletions(-) diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index fad35fa7ad45..30d4c670aeb5 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -570,7 +570,7 @@ nsresult MediaDecoder::Play() * (and can be -1 if aValue is before aRanges.Start(0)). */ static bool -IsInRanges(TimeRanges& aRanges, double aValue, int32_t& aIntervalIndex) +IsInRanges(dom::TimeRanges& aRanges, double aValue, int32_t& aIntervalIndex) { uint32_t length; aRanges.GetLength(&length); @@ -598,7 +598,7 @@ nsresult MediaDecoder::Seek(double aTime) NS_ABORT_IF_FALSE(aTime >= 0.0, "Cannot seek to a negative value."); - TimeRanges seekable; + dom::TimeRanges seekable; nsresult res; uint32_t length = 0; res = GetSeekable(&seekable); @@ -1326,7 +1326,7 @@ bool MediaDecoder::IsMediaSeekable() return mMediaSeekable; } -nsresult MediaDecoder::GetSeekable(TimeRanges* aSeekable) +nsresult MediaDecoder::GetSeekable(dom::TimeRanges* aSeekable) { double initialTime = 0.0; @@ -1492,7 +1492,7 @@ void MediaDecoder::Invalidate() // Constructs the time ranges representing what segments of the media // are buffered and playable. -nsresult MediaDecoder::GetBuffered(TimeRanges* aBuffered) { +nsresult MediaDecoder::GetBuffered(dom::TimeRanges* aBuffered) { if (mDecoderStateMachine) { return mDecoderStateMachine->GetBuffered(aBuffered); } diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index 0fcbf44fd8d1..27a66180f142 100644 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -201,8 +201,6 @@ class TimeRanges; } } -using namespace mozilla::dom; - namespace mozilla { namespace layers { class Image; @@ -232,8 +230,6 @@ class MediaDecoder : public nsIObserver, public AbstractMediaDecoder { public: - typedef mozilla::layers::Image Image; - NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIOBSERVER @@ -371,7 +367,7 @@ public: MediaDecoder* mDecoder; // The last video image sent to the stream. Useful if we need to replicate // the image. - nsRefPtr mLastVideoImage; + nsRefPtr mLastVideoImage; gfxIntSize mLastVideoImageDisplaySize; // This is set to true when the stream is initialized (audio and // video tracks added). @@ -523,7 +519,7 @@ public: virtual bool IsTransportSeekable(); // Return the time ranges that can be seeked into. - virtual nsresult GetSeekable(TimeRanges* aSeekable); + virtual nsresult GetSeekable(dom::TimeRanges* aSeekable); // Set the end time of the media resource. When playback reaches // this point the media pauses. aTime is in seconds. @@ -559,7 +555,7 @@ public: virtual void MoveLoadsToBackground(); // Returns a weak reference to the media decoder owner. - mozilla::MediaDecoderOwner* GetMediaOwner() const; + MediaDecoderOwner* GetMediaOwner() const; // Returns the current size of the framebuffer used in // MozAudioAvailable events. @@ -584,7 +580,7 @@ public: // Constructs the time ranges representing what segments of the media // are buffered and playable. - virtual nsresult GetBuffered(TimeRanges* aBuffered); + virtual nsresult GetBuffered(dom::TimeRanges* aBuffered); // Returns the size, in bytes, of the heap memory used by the currently // queued decoded video and audio data. @@ -595,7 +591,7 @@ public: { return mVideoFrameContainer; } - mozilla::layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; + layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; // Sets the length of the framebuffer used in MozAudioAvailable events. // The new size must be between 512 and 16384. @@ -661,8 +657,8 @@ public: // held. void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; - void SetAudioChannelType(AudioChannelType aType) { mAudioChannelType = aType; } - AudioChannelType GetAudioChannelType() { return mAudioChannelType; } + void SetAudioChannelType(dom::AudioChannelType aType) { mAudioChannelType = aType; } + dom::AudioChannelType GetAudioChannelType() { return mAudioChannelType; } // Send a new set of metadata to the state machine, to be dispatched to the // main thread to be presented when the |currentTime| of the media is greater @@ -927,6 +923,7 @@ public: GetFrameStatistics().NotifyDecodedFrames(aParsed, aDecoded); } +protected: /****** * The following members should be accessed with the decoder lock held. ******/ @@ -1025,7 +1022,7 @@ private: // The |RestrictedAccessMonitor| member object. RestrictedAccessMonitor mReentrantMonitor; -public: +protected: // Data about MediaStreams that are being fed by this decoder. nsTArray mOutputStreams; // The SourceMediaStream we are using to feed the mOutputStreams. This stream @@ -1087,8 +1084,6 @@ public: // PlaybackEnded when mDecodedStream->mStream finishes. bool mTriggerPlaybackEndedWhenSourceStreamFinishes; -protected: - // Start timer to update download progress information. nsresult StartProgress(); @@ -1148,7 +1143,7 @@ protected: // Be assigned from media element during the initialization and pass to // AudioStream Class. - AudioChannelType mAudioChannelType; + dom::AudioChannelType mAudioChannelType; }; } // namespace mozilla diff --git a/content/media/MediaDecoderStateMachine.cpp b/content/media/MediaDecoderStateMachine.cpp index 72297f9ffa51..a056ceb874cb 100644 --- a/content/media/MediaDecoderStateMachine.cpp +++ b/content/media/MediaDecoderStateMachine.cpp @@ -1605,7 +1605,7 @@ void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer, // faster than played, mEndTime won't reflect the end of playable data // since we haven't played the frame at the end of buffered data. So update // mEndTime here as new data is downloaded to prevent such a lag. - TimeRanges buffered; + dom::TimeRanges buffered; if (mDecoder->IsInfinite() && NS_SUCCEEDED(mDecoder->GetBuffered(&buffered))) { @@ -1851,7 +1851,7 @@ int64_t MediaDecoderStateMachine::GetUndecodedData() const AssertCurrentThreadInMonitor(); NS_ASSERTION(mState > DECODER_STATE_DECODING_METADATA, "Must have loaded metadata for GetBuffered() to work"); - TimeRanges buffered; + dom::TimeRanges buffered; nsresult res = mDecoder->GetBuffered(&buffered); NS_ENSURE_SUCCESS(res, 0); @@ -2713,7 +2713,7 @@ void MediaDecoderStateMachine::StartBuffering() stats.mDownloadRate/1024, stats.mDownloadRateReliable ? "" : " (unreliable)")); } -nsresult MediaDecoderStateMachine::GetBuffered(TimeRanges* aBuffered) { +nsresult MediaDecoderStateMachine::GetBuffered(dom::TimeRanges* aBuffered) { MediaResource* resource = mDecoder->GetResource(); NS_ENSURE_TRUE(resource, NS_ERROR_FAILURE); resource->Pin(); diff --git a/content/media/MediaDecoderStateMachine.h b/content/media/MediaDecoderStateMachine.h index 7e5aad6b01a6..8897ef6e8b38 100644 --- a/content/media/MediaDecoderStateMachine.h +++ b/content/media/MediaDecoderStateMachine.h @@ -255,7 +255,7 @@ public: return mState == DECODER_STATE_SEEKING; } - nsresult GetBuffered(TimeRanges* aBuffered); + nsresult GetBuffered(dom::TimeRanges* aBuffered); void SetPlaybackRate(double aPlaybackRate); void SetPreservesPitch(bool aPreservesPitch); diff --git a/content/media/MediaResource.cpp b/content/media/MediaResource.cpp index 555058282dc1..f5806b659e73 100644 --- a/content/media/MediaResource.cpp +++ b/content/media/MediaResource.cpp @@ -147,7 +147,7 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest) MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); nsresult status; nsresult rv = aRequest->GetStatus(&status); @@ -583,7 +583,7 @@ nsresult ChannelMediaResource::OpenChannel(nsIStreamListener** aStreamListener) // an authorizing Access-Control header. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); if (element->ShouldCheckAllowOrigin()) { nsRefPtr crossSiteListener = @@ -642,7 +642,7 @@ void ChannelMediaResource::SetupChannelHeaders() if (!owner) { return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { return; } @@ -805,7 +805,7 @@ void ChannelMediaResource::Suspend(bool aCloseImmediately) // Shutting down; do nothing. return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -840,7 +840,7 @@ void ChannelMediaResource::Resume() // Shutting down; do nothing. return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -889,7 +889,7 @@ ChannelMediaResource::RecreateChannel() // The decoder is being shut down, so don't bother opening a new channel return NS_OK; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so don't bother opening a new channel return NS_OK; @@ -1309,7 +1309,7 @@ nsresult FileMediaResource::Open(nsIStreamListener** aStreamListener) // web server. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); rv = nsContentUtils::GetSecurityManager()-> @@ -1374,7 +1374,7 @@ already_AddRefed FileMediaResource::CloneData(MediaDecoder* aDeco // The decoder is being shut down, so we can't clone return nullptr; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so we can't clone return nullptr; @@ -1533,7 +1533,7 @@ void BaseMediaResource::MoveLoadsToBackground() { NS_WARNING("Null owner in MediaResource::MoveLoadsToBackground()"); return; } - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { NS_WARNING("Null element in MediaResource::MoveLoadsToBackground()"); return; diff --git a/content/media/RtspMediaResource.cpp b/content/media/RtspMediaResource.cpp index a9d4074e94cf..20f78594e002 100644 --- a/content/media/RtspMediaResource.cpp +++ b/content/media/RtspMediaResource.cpp @@ -504,7 +504,7 @@ RtspMediaResource::OnConnected(uint8_t aTrackIdx, MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); element->FinishDecoderSetup(mDecoder, this); @@ -535,7 +535,7 @@ void RtspMediaResource::Suspend(bool aCloseImmediately) MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE_VOID(owner); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE_VOID(element); mMediaStreamController->Suspend(); @@ -548,7 +548,7 @@ void RtspMediaResource::Resume() MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE_VOID(owner); - HTMLMediaElement* element = owner->GetMediaElement(); + dom::HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE_VOID(element); if (mChannel) { diff --git a/content/media/gstreamer/GStreamerReader.cpp b/content/media/gstreamer/GStreamerReader.cpp index 4cb1b80092fc..c35d2e3149b4 100644 --- a/content/media/gstreamer/GStreamerReader.cpp +++ b/content/media/gstreamer/GStreamerReader.cpp @@ -654,7 +654,7 @@ nsresult GStreamerReader::Seek(int64_t aTarget, return DecodeToTarget(aTarget); } -nsresult GStreamerReader::GetBuffered(TimeRanges* aBuffered, +nsresult GStreamerReader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) { if (!mInfo.HasValidMedia()) { diff --git a/content/media/mediasource/MediaSource.h b/content/media/mediasource/MediaSource.h index 0e920fef121b..295e82b8e3ec 100644 --- a/content/media/mediasource/MediaSource.h +++ b/content/media/mediasource/MediaSource.h @@ -35,7 +35,6 @@ namespace dom { class GlobalObject; class SourceBuffer; class SourceBufferList; -class TimeRanges; template class Optional; #define MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID \ diff --git a/content/media/mediasource/MediaSourceDecoder.cpp b/content/media/mediasource/MediaSourceDecoder.cpp index 13895b9a95cb..beeb3f3624ad 100644 --- a/content/media/mediasource/MediaSourceDecoder.cpp +++ b/content/media/mediasource/MediaSourceDecoder.cpp @@ -120,7 +120,7 @@ private: } }; -MediaSourceDecoder::MediaSourceDecoder(HTMLMediaElement* aElement) +MediaSourceDecoder::MediaSourceDecoder(dom::HTMLMediaElement* aElement) : mMediaSource(nullptr) , mVideoReader(nullptr), mAudioReader(nullptr) @@ -148,13 +148,13 @@ MediaSourceDecoder::Load(nsIStreamListener**, MediaDecoder*) } nsresult -MediaSourceDecoder::GetSeekable(TimeRanges* aSeekable) +MediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable) { double duration = mMediaSource->Duration(); if (IsNaN(duration)) { // Return empty range. } else if (duration > 0 && mozilla::IsInfinite(duration)) { - nsRefPtr bufferedRanges = new TimeRanges(); + nsRefPtr bufferedRanges = new dom::TimeRanges(); GetBuffered(bufferedRanges); aSeekable->Add(0, bufferedRanges->GetFinalEndTime()); } else { @@ -164,7 +164,7 @@ MediaSourceDecoder::GetSeekable(TimeRanges* aSeekable) } void -MediaSourceDecoder::AttachMediaSource(MediaSource* aMediaSource) +MediaSourceDecoder::AttachMediaSource(dom::MediaSource* aMediaSource) { MOZ_ASSERT(!mMediaSource && !mDecoderStateMachine); mMediaSource = aMediaSource; diff --git a/content/media/mediasource/MediaSourceDecoder.h b/content/media/mediasource/MediaSourceDecoder.h index e85f61640600..747876a6ba4f 100644 --- a/content/media/mediasource/MediaSourceDecoder.h +++ b/content/media/mediasource/MediaSourceDecoder.h @@ -36,14 +36,14 @@ class MediaSource; class MediaSourceDecoder : public MediaDecoder { public: - MediaSourceDecoder(HTMLMediaElement* aElement); + MediaSourceDecoder(dom::HTMLMediaElement* aElement); virtual MediaDecoder* Clone() MOZ_OVERRIDE; virtual MediaDecoderStateMachine* CreateStateMachine() MOZ_OVERRIDE; virtual nsresult Load(nsIStreamListener**, MediaDecoder*) MOZ_OVERRIDE; - virtual nsresult GetSeekable(TimeRanges* aSeekable) MOZ_OVERRIDE; + virtual nsresult GetSeekable(dom::TimeRanges* aSeekable) MOZ_OVERRIDE; - void AttachMediaSource(MediaSource* aMediaSource); + void AttachMediaSource(dom::MediaSource* aMediaSource); void DetachMediaSource(); SubBufferDecoder* CreateSubDecoder(const nsACString& aType); @@ -80,7 +80,7 @@ public: } private: - MediaSource* mMediaSource; + dom::MediaSource* mMediaSource; nsTArray > mDecoders; nsTArray mReaders; // Readers owned by Decoders. diff --git a/content/media/mediasource/SubBufferDecoder.h b/content/media/mediasource/SubBufferDecoder.h index cb11a4440765..2444474e3d99 100644 --- a/content/media/mediasource/SubBufferDecoder.h +++ b/content/media/mediasource/SubBufferDecoder.h @@ -48,7 +48,7 @@ public: mParentDecoder->NotifyDataArrived(aBuffer, aLength, aOffset); } - nsresult GetBuffered(TimeRanges* aBuffered) + nsresult GetBuffered(dom::TimeRanges* aBuffered) { // XXX: Need mStartTime (from StateMachine) instead of passing 0. return mReader->GetBuffered(aBuffered, 0); diff --git a/content/media/ogg/OggReader.cpp b/content/media/ogg/OggReader.cpp index eb670c96a81a..941cc04204cb 100644 --- a/content/media/ogg/OggReader.cpp +++ b/content/media/ogg/OggReader.cpp @@ -1772,7 +1772,7 @@ nsresult OggReader::SeekBisection(int64_t aTarget, return NS_OK; } -nsresult OggReader::GetBuffered(TimeRanges* aBuffered, int64_t aStartTime) +nsresult OggReader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) { { mozilla::ReentrantMonitorAutoEnter mon(mMonitor); From 7f90ed61c6acca1ea1166d642b992696583d7558 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Tue, 19 Nov 2013 10:43:15 +1300 Subject: [PATCH 07/72] Bug 919215 - Start the AudioStream on creation when in low-latency mode, and let it underrun. r=roc The BufferedAudioStream buffers the data it gets through the Write() calls and what is consumed by the callback. This means that if the audio producer starts Write()ing data right after Start()ing the stream, data will accumulate in this buffer and won't be consumed. Eventually, the buffer will be of a certain size before it begins to be consumed by the callback, and this means an umcompressible latency (because the data will be written at more or less the same rate as it is produced). This patch start the BufferedAudioStream right away when it is created, dropping the silent AudioSegment until it finds real data (and padding with silence is then done at the beginning). The stream will underrun, but the callback will synthetize silence, avoiding overbuffering in the BufferedAudioStream. This ensures minimal latency cause by the buffering. Note that the clock will still advance, so this will not change the behavior of content that has leading silence. --- content/media/AudioSegment.cpp | 57 ++++++++++++++++++++-------------- content/media/AudioStream.cpp | 46 ++++++++++++++++++++++++++- content/media/AudioStream.h | 2 ++ 3 files changed, 80 insertions(+), 25 deletions(-) diff --git a/content/media/AudioSegment.cpp b/content/media/AudioSegment.cpp index fe825516d1a6..0ca700754550 100644 --- a/content/media/AudioSegment.cpp +++ b/content/media/AudioSegment.cpp @@ -126,36 +126,45 @@ AudioSegment::WriteTo(uint64_t aID, AudioStream* aOutput) NS_ERROR("Buffer overflow"); return; } + uint32_t duration = uint32_t(durationTicks); - buf.SetLength(outputChannels*duration); - if (c.mBuffer) { - channelData.SetLength(c.mChannelData.Length()); - for (uint32_t i = 0; i < channelData.Length(); ++i) { - channelData[i] = - AddAudioSampleOffset(c.mChannelData[i], c.mBufferFormat, int32_t(offset)); - } - if (channelData.Length() < outputChannels) { - // Up-mix. Note that this might actually make channelData have more - // than outputChannels temporarily. - AudioChannelsUpMix(&channelData, outputChannels, gZeroChannel); - } + // If we have written data in the past, or we have real (non-silent) data + // to write, we can proceed. Otherwise, it means we just started the + // AudioStream, and we don't have real data to write to it (just silence). + // To avoid overbuffering in the AudioStream, we simply drop the silence, + // here. The stream will underrun and output silence anyways. + if (c.mBuffer || aOutput->GetWritten()) { + buf.SetLength(outputChannels*duration); + if (c.mBuffer) { + channelData.SetLength(c.mChannelData.Length()); + for (uint32_t i = 0; i < channelData.Length(); ++i) { + channelData[i] = + AddAudioSampleOffset(c.mChannelData[i], c.mBufferFormat, int32_t(offset)); + } - if (channelData.Length() > outputChannels) { - // Down-mix. - DownmixAndInterleave(channelData, c.mBufferFormat, duration, - c.mVolume, outputChannels, buf.Elements()); + if (channelData.Length() < outputChannels) { + // Up-mix. Note that this might actually make channelData have more + // than outputChannels temporarily. + AudioChannelsUpMix(&channelData, outputChannels, gZeroChannel); + } + + if (channelData.Length() > outputChannels) { + // Down-mix. + DownmixAndInterleave(channelData, c.mBufferFormat, duration, + c.mVolume, outputChannels, buf.Elements()); + } else { + InterleaveAndConvertBuffer(channelData.Elements(), c.mBufferFormat, + duration, c.mVolume, + outputChannels, + buf.Elements()); + } } else { - InterleaveAndConvertBuffer(channelData.Elements(), c.mBufferFormat, - duration, c.mVolume, - outputChannels, - buf.Elements()); + // Assumes that a bit pattern of zeroes == 0.0f + memset(buf.Elements(), 0, buf.Length()*sizeof(AudioDataValue)); } - } else { - // Assumes that a bit pattern of zeroes == 0.0f - memset(buf.Elements(), 0, buf.Length()*sizeof(AudioDataValue)); + aOutput->Write(buf.Elements(), int32_t(duration), &(c.mTimeStamp)); } - aOutput->Write(buf.Elements(), int32_t(duration), &(c.mTimeStamp)); if(!c.mTimeStamp.IsNull()) { TimeStamp now = TimeStamp::Now(); // would be more efficient to c.mTimeStamp to ms on create time then pass here diff --git a/content/media/AudioStream.cpp b/content/media/AudioStream.cpp index 263a932233d1..913307198bed 100644 --- a/content/media/AudioStream.cpp +++ b/content/media/AudioStream.cpp @@ -144,6 +144,7 @@ AudioStream::AudioStream() mChannels(0), mWritten(0), mAudioClock(MOZ_THIS_IN_INITIALIZER_LIST()), + mLatencyRequest(HighLatency), mReadPoint(0) {} @@ -364,6 +365,7 @@ private: // aTime is the time in ms the samples were inserted into MediaStreamGraph long GetUnprocessed(void* aBuffer, long aFrames, int64_t &aTime); long GetTimeStretched(void* aBuffer, long aFrames, int64_t &aTime); + long GetUnprocessedWithSilencePadding(void* aBuffer, long aFrames, int64_t &aTime); // Shared implementation of underflow adjusted position calculation. // Caller must own the monitor. @@ -577,6 +579,7 @@ BufferedAudioStream::Init(int32_t aNumChannels, int32_t aRate, ("%s channels: %d, rate: %d", __FUNCTION__, aNumChannels, aRate)); mInRate = mOutRate = aRate; mChannels = aNumChannels; + mLatencyRequest = aLatencyRequest; mDumpFile = OpenDumpFile(this); @@ -634,6 +637,13 @@ BufferedAudioStream::Init(int32_t aNumChannels, int32_t aRate, NS_ABORT_IF_FALSE(bufferLimit % mBytesPerFrame == 0, "Must buffer complete frames"); mBuffer.SetCapacity(bufferLimit); + // Start the stream right away when low latency has been requested. This means + // that the DataCallback will feed silence to cubeb, until the first frames + // are writtent to this BufferedAudioStream. + if (mLatencyRequest == AudioStream::LowLatency) { + Start(); + } + return NS_OK; } @@ -912,6 +922,32 @@ BufferedAudioStream::GetUnprocessed(void* aBuffer, long aFrames, int64_t &aTimeM return BytesToFrames(available) + flushedFrames; } +// Get unprocessed samples, and pad the beginning of the buffer with silence if +// there is not enough data. +long +BufferedAudioStream::GetUnprocessedWithSilencePadding(void* aBuffer, long aFrames, int64_t& aTimeMs) +{ + uint32_t toPopBytes = FramesToBytes(aFrames); + uint32_t available = std::min(toPopBytes, mBuffer.Length()); + uint32_t silenceOffset = toPopBytes - available; + + uint8_t* wpos = reinterpret_cast(aBuffer); + + memset(wpos, 0, silenceOffset); + wpos += silenceOffset; + + void* input[2]; + uint32_t input_size[2]; + mBuffer.PopElements(available, &input[0], &input_size[0], &input[1], &input_size[1]); + memcpy(wpos, input[0], input_size[0]); + wpos += input_size[0]; + memcpy(wpos, input[1], input_size[1]); + + GetBufferInsertTime(aTimeMs); + + return aFrames; +} + long BufferedAudioStream::GetTimeStretched(void* aBuffer, long aFrames, int64_t &aTimeMs) { @@ -965,8 +1001,16 @@ BufferedAudioStream::DataCallback(void* aBuffer, long aFrames) int64_t insertTime; if (available) { + // When we are playing a low latency stream, and it is the first time we are + // getting data from the buffer, we prefer to add the silence for an + // underrun at the beginning of the buffer, so the first buffer is not cut + // in half by the silence inserted to compensate for the underrun. if (mInRate == mOutRate) { - servicedFrames = GetUnprocessed(output, aFrames, insertTime); + if (mLatencyRequest == AudioStream::LowLatency && !mWritten) { + servicedFrames = GetUnprocessedWithSilencePadding(output, aFrames, insertTime); + } else { + servicedFrames = GetUnprocessed(output, aFrames, insertTime); + } } else { servicedFrames = GetTimeStretched(output, aFrames, insertTime); } diff --git a/content/media/AudioStream.h b/content/media/AudioStream.h index 059ce02c9e01..ecd7f5e64bec 100644 --- a/content/media/AudioStream.h +++ b/content/media/AudioStream.h @@ -207,6 +207,8 @@ protected: // copy of Latency logger's starting time for offset calculations TimeStamp mStartTime; + // Whether we are playing a low latency stream, or a normal stream. + LatencyRequest mLatencyRequest; // Where in the current mInserts[0] block cubeb has read to int64_t mReadPoint; // Keep track of each inserted block of samples and the time it was inserted From 1c72ffaa67f1016af89054bb05e5e678382ccef9 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Tue, 19 Nov 2013 13:30:25 +0900 Subject: [PATCH 08/72] Bug 913264 - add none value to font-variant-ligatures. r=dbaron --- gfx/src/nsFont.cpp | 17 +++++++++++++++-- gfx/src/nsFont.h | 2 +- gfx/thebes/gfxFontConstants.h | 2 ++ .../font-features/font-variant-features.js | 3 +++ layout/style/nsCSSParser.cpp | 16 ++++++++++++++-- layout/style/nsCSSProps.cpp | 1 + layout/style/nsCSSValue.cpp | 2 +- layout/style/nsComputedDOMStyle.cpp | 2 +- layout/style/test/property_database.js | 5 +++-- 9 files changed, 41 insertions(+), 9 deletions(-) diff --git a/gfx/src/nsFont.cpp b/gfx/src/nsFont.cpp index 1b2ae7b58b5b..fe6d3f7a6a1f 100644 --- a/gfx/src/nsFont.cpp +++ b/gfx/src/nsFont.cpp @@ -260,6 +260,7 @@ static_assert(NS_ARRAY_LENGTH(eastAsianDefaults) == // NS_FONT_VARIANT_LIGATURES_xxx values const gfxFontFeature ligDefaults[] = { + { TRUETYPE_TAG('l','i','g','a'), 0 }, // none value means all off { TRUETYPE_TAG('l','i','g','a'), 1 }, { TRUETYPE_TAG('l','i','g','a'), 0 }, { TRUETYPE_TAG('d','l','i','g'), 1 }, @@ -386,19 +387,31 @@ void nsFont::AddFontFeaturesToStyle(gfxFontStyle *aStyle) const // -- ligatures if (variantLigatures) { AddFontFeaturesBitmask(variantLigatures, - NS_FONT_VARIANT_LIGATURES_COMMON, + NS_FONT_VARIANT_LIGATURES_NONE, NS_FONT_VARIANT_LIGATURES_NO_CONTEXTUAL, ligDefaults, aStyle->featureSettings); - // special case common ligs, which also enable/disable clig if (variantLigatures & NS_FONT_VARIANT_LIGATURES_COMMON) { + // liga already enabled, need to enable clig also setting.mTag = TRUETYPE_TAG('c','l','i','g'); setting.mValue = 1; aStyle->featureSettings.AppendElement(setting); } else if (variantLigatures & NS_FONT_VARIANT_LIGATURES_NO_COMMON) { + // liga already disabled, need to disable clig also setting.mTag = TRUETYPE_TAG('c','l','i','g'); setting.mValue = 0; aStyle->featureSettings.AppendElement(setting); + } else if (variantLigatures & NS_FONT_VARIANT_LIGATURES_NONE) { + // liga already disabled, need to disable dlig, hlig, calt, clig + setting.mValue = 0; + setting.mTag = TRUETYPE_TAG('d','l','i','g'); + aStyle->featureSettings.AppendElement(setting); + setting.mTag = TRUETYPE_TAG('h','l','i','g'); + aStyle->featureSettings.AppendElement(setting); + setting.mTag = TRUETYPE_TAG('c','a','l','t'); + aStyle->featureSettings.AppendElement(setting); + setting.mTag = TRUETYPE_TAG('c','l','i','g'); + aStyle->featureSettings.AppendElement(setting); } } diff --git a/gfx/src/nsFont.h b/gfx/src/nsFont.h index 6e885ac30be8..4fe897f1730b 100644 --- a/gfx/src/nsFont.h +++ b/gfx/src/nsFont.h @@ -56,10 +56,10 @@ struct NS_GFX nsFont { // Variant subproperties // (currently -moz- versions, will replace variant above eventually) uint8_t variantCaps; - uint8_t variantLigatures; uint8_t variantNumeric; uint8_t variantPosition; + uint16_t variantLigatures; uint16_t variantEastAsian; // Some font-variant-alternates property values require diff --git a/gfx/thebes/gfxFontConstants.h b/gfx/thebes/gfxFontConstants.h index 94a443a29db3..39defb687b3c 100644 --- a/gfx/thebes/gfxFontConstants.h +++ b/gfx/thebes/gfxFontConstants.h @@ -119,6 +119,7 @@ enum { NS_FONT_VARIANT_EAST_ASIAN_PROP_WIDTH ) enum { + eFeatureLigatures_none, eFeatureLigatures_common, eFeatureLigatures_no_common, eFeatureLigatures_discretionary, @@ -131,6 +132,7 @@ enum { eFeatureLigatures_numFeatures }; +#define NS_FONT_VARIANT_LIGATURES_NONE (1 << eFeatureLigatures_none) #define NS_FONT_VARIANT_LIGATURES_COMMON (1 << eFeatureLigatures_common) #define NS_FONT_VARIANT_LIGATURES_NO_COMMON (1 << eFeatureLigatures_no_common) #define NS_FONT_VARIANT_LIGATURES_DISCRETIONARY (1 << eFeatureLigatures_discretionary) diff --git a/layout/reftests/font-features/font-variant-features.js b/layout/reftests/font-features/font-variant-features.js index 53167cd2931b..21800d0c96e8 100644 --- a/layout/reftests/font-features/font-variant-features.js +++ b/layout/reftests/font-features/font-variant-features.js @@ -53,6 +53,7 @@ var gPropertyData = [ // font-variant-ligatures // valid values + { prop: "font-variant-ligatures", value: "none", features: {"liga": 0, "dlig": 0, "clig": 0, "calt": 0, "hlig": 0} }, { prop: "font-variant-ligatures", value: "normal", features: {"liga": 1, "dlig": 0} }, { prop: "font-variant-ligatures", value: "common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0, "calt": 1} }, { prop: "font-variant-ligatures", value: "no-common-ligatures", features: {"liga": 0, "clig": 0, "dlig": 0, "hlig": 0, "calt": 1} }, @@ -68,6 +69,8 @@ var gPropertyData = [ { prop: "font-variant-ligatures", value: "common-ligatures no-discretionary-ligatures historical-ligatures no-contextual", features: {"clig": 1, "dlig": 0, "hlig": 1, "liga": 1, "calt": 0} }, // invalid values + { prop: "font-variant-ligatures", value: "common-ligatures none", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, + { prop: "font-variant-ligatures", value: "none common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, { prop: "font-variant-ligatures", value: "common-ligatures normal", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, { prop: "font-variant-ligatures", value: "common-ligatures no-common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, { prop: "font-variant-ligatures", value: "common-ligatures common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 1ad1b34f4e78..6ee5359d85c9 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -8989,8 +8989,20 @@ CSSParserImpl::ParseFontVariantLigatures(nsCSSValue& aValue) MASK_END_VALUE, "incorrectly terminated array"); - return ParseBitmaskValues(aValue, nsCSSProps::kFontVariantLigaturesKTable, - maskLigatures); + bool parsed = + ParseBitmaskValues(aValue, nsCSSProps::kFontVariantLigaturesKTable, + maskLigatures); + + // if none value included, no other values are possible + if (parsed && eCSSUnit_Enumerated == aValue.GetUnit()) { + int32_t val = aValue.GetIntValue(); + if ((val & NS_FONT_VARIANT_LIGATURES_NONE) && + (val & ~int32_t(NS_FONT_VARIANT_LIGATURES_NONE))) { + parsed = false; + } + } + + return parsed; } static const int32_t maskNumeric[] = { diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 0d2bd43d609e..f951f6708082 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -1144,6 +1144,7 @@ const int32_t nsCSSProps::kFontVariantEastAsianKTable[] = { }; const int32_t nsCSSProps::kFontVariantLigaturesKTable[] = { + eCSSKeyword_none, NS_FONT_VARIANT_LIGATURES_NONE, eCSSKeyword_common_ligatures, NS_FONT_VARIANT_LIGATURES_COMMON, eCSSKeyword_no_common_ligatures, NS_FONT_VARIANT_LIGATURES_NO_COMMON, eCSSKeyword_discretionary_ligatures, NS_FONT_VARIANT_LIGATURES_DISCRETIONARY, diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 237874c9be8d..114028e8ab47 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -909,7 +909,7 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult) const case eCSSProperty_font_variant_ligatures: nsStyleUtil::AppendBitmaskCSSValue(aProperty, intValue, - NS_FONT_VARIANT_LIGATURES_COMMON, + NS_FONT_VARIANT_LIGATURES_NONE, NS_FONT_VARIANT_LIGATURES_NO_CONTEXTUAL, aResult); break; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index 8363951e0011..8ccf84b82c17 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -1612,7 +1612,7 @@ nsComputedDOMStyle::DoGetFontVariantLigatures() nsAutoString valueStr; nsStyleUtil::AppendBitmaskCSSValue(eCSSProperty_font_variant_ligatures, - intValue, NS_FONT_VARIANT_LIGATURES_COMMON, + intValue, NS_FONT_VARIANT_LIGATURES_NONE, NS_FONT_VARIANT_LIGATURES_NO_CONTEXTUAL, valueStr); val->SetString(valueStr); } diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index e971dc7f2d54..91d8e897ebb3 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -4313,14 +4313,15 @@ if (SpecialPowers.getBoolPref("layout.css.font-features.enabled")) { inherited: true, type: CSS_TYPE_LONGHAND, initial_values: [ "normal" ], - other_values: [ "common-ligatures", "no-common-ligatures", "discretionary-ligatures", "no-discretionary-ligatures", + other_values: [ "none", "common-ligatures", "no-common-ligatures", "discretionary-ligatures", "no-discretionary-ligatures", "historical-ligatures", "no-historical-ligatures", "contextual", "no-contextual", "common-ligatures no-discretionary-ligatures", "contextual no-discretionary-ligatures", "historical-ligatures no-common-ligatures", "no-historical-ligatures discretionary-ligatures", "common-ligatures no-discretionary-ligatures historical-ligatures no-contextual" ], invalid_values: [ "common-ligatures normal", "common-ligatures no-common-ligatures", "common-ligatures common-ligatures", "no-historical-ligatures historical-ligatures", "no-discretionary-ligatures discretionary-ligatures", - "no-contextual contextual", "common-ligatures no-discretionary-ligatures no-common-ligatures" ] + "no-contextual contextual", "common-ligatures no-discretionary-ligatures no-common-ligatures", + "common-ligatures none", "no-discretionary-ligatures none", "none common-ligatures" ] }, "font-variant-numeric": { domProp: "fontVariantNumeric", From e1e381eed718f0babfaf76ccd4dabea82c1190a3 Mon Sep 17 00:00:00 2001 From: John Daggett Date: Tue, 19 Nov 2013 13:30:25 +0900 Subject: [PATCH 09/72] Bug 913264 - add reftest for none value of font-variant-ligatures. r=jfkthame --- .../font-features-ligatures-none.html | 20 +++++++++++++++++++ layout/reftests/font-features/reftest.list | 1 + 2 files changed, 21 insertions(+) create mode 100644 layout/reftests/font-features/font-features-ligatures-none.html diff --git a/layout/reftests/font-features/font-features-ligatures-none.html b/layout/reftests/font-features/font-features-ligatures-none.html new file mode 100644 index 000000000000..418c8c9e2e38 --- /dev/null +++ b/layout/reftests/font-features/font-features-ligatures-none.html @@ -0,0 +1,20 @@ + + + + + +fastest firefox + + diff --git a/layout/reftests/font-features/reftest.list b/layout/reftests/font-features/reftest.list index 7eebffa70f35..073d910f7b61 100644 --- a/layout/reftests/font-features/reftest.list +++ b/layout/reftests/font-features/reftest.list @@ -28,6 +28,7 @@ HTTP(..) == font-features-turkish.html font-features-noliga.html HTTP(..) == font-features-hlig-2.html font-features-hlig.html HTTP(..) == font-features-hlig-4.html font-features-hlig.html HTTP(..) != font-features-hlig-5.html font-features-hlig.html +pref(layout.css.font-features.enabled,true) HTTP(..) == font-features-ligatures-none.html font-features-noliga.html # check that feature in style rule overrides @font-face skip-if(B2G) HTTP(..) == font-features-hlig-3.html font-features-noliga.html # bug 773482 From c5eff3cccc92094785a9ad510204cd5518fa6631 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Mon, 18 Nov 2013 23:34:00 -0500 Subject: [PATCH 10/72] Bug 457296 - Allow nsIPermissionManager to accept mailto URLs. r=jdm. --- extensions/cookie/nsPermissionManager.cpp | 14 +++++++ .../test/unit/test_permmanager_mailto.js | 38 +++++++++++++++++++ extensions/cookie/test/unit/xpcshell.ini | 1 + 3 files changed, 53 insertions(+) create mode 100644 extensions/cookie/test/unit/test_permmanager_mailto.js diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index 461dc516a4e1..826786c6d40f 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -132,6 +132,20 @@ GetHostForPrincipal(nsIPrincipal* aPrincipal, nsACString& aHost) return NS_OK; } + // For the mailto scheme, we use the path of the URI. We have to chop off the + // query part if one exists, so we eliminate everything after a ?. + bool isMailTo = false; + if (NS_SUCCEEDED(uri->SchemeIs("mailto", &isMailTo)) && isMailTo) { + rv = uri->GetPath(aHost); + NS_ENSURE_SUCCESS(rv, rv); + + int32_t spart = aHost.FindChar('?', 0); + if (spart >= 0) { + aHost.Cut(spart, aHost.Length() - spart); + } + return NS_OK; + } + // Some entries like "file://" uses the origin. rv = aPrincipal->GetOrigin(getter_Copies(aHost)); if (NS_SUCCEEDED(rv) && !aHost.IsEmpty()) { diff --git a/extensions/cookie/test/unit/test_permmanager_mailto.js b/extensions/cookie/test/unit/test_permmanager_mailto.js new file mode 100644 index 000000000000..d7d1e80fd75f --- /dev/null +++ b/extensions/cookie/test/unit/test_permmanager_mailto.js @@ -0,0 +1,38 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function run_test() { + // initialize the permission manager service + const kTestAddr = "test@example.org"; + const kType = "test-mailto"; + const kCapability = 1; + + // make a mailto: URI with parameters + let uri = Services.io.newURI("mailto:" + kTestAddr + "?subject=test", null, + null); + + // add a permission entry for that URI + Services.permissions.add(uri, kType, kCapability); + do_check_true(permission_exists(kTestAddr, kType, kCapability)); + + Services.permissions.removeAll(); + + uri = Services.io.newURI("mailto:" + kTestAddr, null, null); + Services.permissions.add(uri, kType, kCapability); + do_check_true(permission_exists(kTestAddr, kType, kCapability)); + + Services.permissions.removeAll(); +} + +function permission_exists(aHost, aType, aCapability) { + let e = Services.permissions.enumerator; + while (e.hasMoreElements()) { + let perm = e.getNext().QueryInterface(Ci.nsIPermission); + if (perm.host == aHost && + perm.type == aType && + perm.capability == aCapability) { + return true; + } + } + return false; +} diff --git a/extensions/cookie/test/unit/xpcshell.ini b/extensions/cookie/test/unit/xpcshell.ini index 58f91c19099e..dcf310490946 100644 --- a/extensions/cookie/test/unit/xpcshell.ini +++ b/extensions/cookie/test/unit/xpcshell.ini @@ -27,6 +27,7 @@ skip-if = debug == true [test_permmanager_idn.js] [test_permmanager_subdomains.js] [test_permmanager_local_files.js] +[test_permmanager_mailto.js] [test_permmanager_cleardata.js] [test_schema_2_migration.js] [test_schema_3_migration.js] From 046f7d967b796abfe6718bcc784a7f6e8c0cd18b Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Mon, 18 Nov 2013 20:38:52 -0800 Subject: [PATCH 11/72] Bug 936143 - Part 1: Add Debugger.Script.lineCount test where the script's source notes end in newline notes. (r=jimb) --- .../jit-test/tests/debug/Script-startLine.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/js/src/jit-test/tests/debug/Script-startLine.js b/js/src/jit-test/tests/debug/Script-startLine.js index 9801230f6e9b..4d3c49950102 100644 --- a/js/src/jit-test/tests/debug/Script-startLine.js +++ b/js/src/jit-test/tests/debug/Script-startLine.js @@ -8,9 +8,11 @@ dbg.onDebuggerStatement = function (frame) { assertEq(typeof frame.script.url, 'string'); }; -function test(f) { +function test(f, manualCount) { start = count = g.first = g.last = undefined; f(); + if (manualCount) + g.last = g.first + manualCount - 1; assertEq(start, g.first); assertEq(count, g.last + 1 - g.first); print(start, count); @@ -41,3 +43,19 @@ g.eval("function f2() {\n" + "}\n"); test(g.f2); test(g.f2); + +// Having a last = Error().lineNumber forces a setline srcnote, so test a +// function that ends with newline srcnotes. +g.eval("/* Any copyright is dedicated to the Public Domain.\n" + + " http://creativecommons.org/publicdomain/zero/1.0/ */\n" + + "\n" + + "function secondCall() { first = Error().lineNumber;\n" + + " debugger;\n" + + " // Comment\n" + + " eval(\"42;\");\n" + + " function foo() {}\n" + + " if (true) {\n" + + " foo();\n" + // <- this is +6 and must be within the extent + " }\n" + + "}"); +test(g.secondCall, 7); From 0439fbbd0ec8e37c7a1c106239faee4ab350081f Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 18 Nov 2013 20:39:57 -0800 Subject: [PATCH 12/72] Bug 936143 - Part 2: Simplify and fix js_GetScriptLineExtent. (r=shu) --- js/src/jsscript.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index f1c41aafdabb..c83216d75330 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -2247,29 +2247,19 @@ JS_FRIEND_API(unsigned) js_GetScriptLineExtent(JSScript *script) { unsigned lineno = script->lineno; - unsigned maxLineNo = 0; - bool counting = true; + unsigned maxLineNo = lineno; for (jssrcnote *sn = script->notes(); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) { SrcNoteType type = (SrcNoteType) SN_TYPE(sn); - if (type == SRC_SETLINE) { - if (maxLineNo < lineno) - maxLineNo = lineno; + if (type == SRC_SETLINE) lineno = (unsigned) js_GetSrcNoteOffset(sn, 0); - counting = true; - if (maxLineNo < lineno) - maxLineNo = lineno; - else - counting = false; - } else if (type == SRC_NEWLINE) { - if (counting) - lineno++; - } + else if (type == SRC_NEWLINE) + lineno++; + + if (maxLineNo < lineno) + maxLineNo = lineno; } - if (maxLineNo > lineno) - lineno = maxLineNo; - - return 1 + lineno - script->lineno; + return 1 + maxLineNo - script->lineno; } void From 462cd597b54e586696301023af05ccf64bdef65a Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Mon, 18 Nov 2013 23:43:09 -0500 Subject: [PATCH 13/72] Bug 939680 - Implement nsINetworkLinkService.linkType on Android r=blassey --- mobile/android/base/GeckoAppShell.java | 72 +++++++++++++++++++ .../android/nsAndroidNetworkLinkService.cpp | 10 ++- widget/android/GeneratedJNIWrappers.cpp | 28 ++++++++ widget/android/GeneratedJNIWrappers.h | 2 + 4 files changed, 110 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index cebe06dc7a83..7601d4fa466e 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -66,6 +66,7 @@ import android.os.MessageQueue; import android.os.SystemClock; import android.os.Vibrator; import android.provider.Settings; +import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Base64; import android.util.DisplayMetrics; @@ -133,6 +134,18 @@ public class GeckoAppShell static public final int WPL_STATE_IS_DOCUMENT = 0x00020000; static public final int WPL_STATE_IS_NETWORK = 0x00040000; + /* Keep in sync with constants found here: + http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsINetworkLinkService.idl + */ + static public final int LINK_TYPE_UNKNOWN = 0; + static public final int LINK_TYPE_ETHERNET = 1; + static public final int LINK_TYPE_USB = 2; + static public final int LINK_TYPE_WIFI = 3; + static public final int LINK_TYPE_WIMAX = 4; + static public final int LINK_TYPE_2G = 5; + static public final int LINK_TYPE_3G = 6; + static public final int LINK_TYPE_4G = 7; + public static final String SHORTCUT_TYPE_WEBAPP = "webapp"; public static final String SHORTCUT_TYPE_BOOKMARK = "bookmark"; @@ -1532,6 +1545,65 @@ public class GeckoAppShell return true; } + @GeneratableAndroidBridgeTarget + public static int networkLinkType() { + ConnectivityManager cm = (ConnectivityManager) + getContext().getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo info = cm.getActiveNetworkInfo(); + if (info == null) { + return LINK_TYPE_UNKNOWN; + } + + switch (info.getType()) { + case ConnectivityManager.TYPE_ETHERNET: + return LINK_TYPE_ETHERNET; + case ConnectivityManager.TYPE_WIFI: + return LINK_TYPE_WIFI; + case ConnectivityManager.TYPE_WIMAX: + return LINK_TYPE_WIMAX; + case ConnectivityManager.TYPE_MOBILE: + break; // We will handle sub-types after the switch. + default: + Log.w(LOGTAG, "Ignoring the current network type."); + return LINK_TYPE_UNKNOWN; + } + + TelephonyManager tm = (TelephonyManager) + getContext().getSystemService(Context.TELEPHONY_SERVICE); + if (tm == null) { + Log.e(LOGTAG, "Telephony service does not exist"); + return LINK_TYPE_UNKNOWN; + } + + switch (tm.getNetworkType()) { + case TelephonyManager.NETWORK_TYPE_IDEN: + case TelephonyManager.NETWORK_TYPE_CDMA: + case TelephonyManager.NETWORK_TYPE_GPRS: + return LINK_TYPE_2G; + case TelephonyManager.NETWORK_TYPE_1xRTT: + case TelephonyManager.NETWORK_TYPE_EDGE: + return LINK_TYPE_2G; // 2.5G + case TelephonyManager.NETWORK_TYPE_UMTS: + case TelephonyManager.NETWORK_TYPE_EVDO_0: + return LINK_TYPE_3G; + case TelephonyManager.NETWORK_TYPE_HSPA: + case TelephonyManager.NETWORK_TYPE_HSDPA: + case TelephonyManager.NETWORK_TYPE_HSUPA: + case TelephonyManager.NETWORK_TYPE_EVDO_A: + case TelephonyManager.NETWORK_TYPE_EVDO_B: + case TelephonyManager.NETWORK_TYPE_EHRPD: + return LINK_TYPE_3G; // 3.5G + case TelephonyManager.NETWORK_TYPE_HSPAP: + return LINK_TYPE_3G; // 3.75G + case TelephonyManager.NETWORK_TYPE_LTE: + return LINK_TYPE_4G; // 3.9G + case TelephonyManager.NETWORK_TYPE_UNKNOWN: + default: + Log.w(LOGTAG, "Connected to an unknown mobile network!"); + return LINK_TYPE_UNKNOWN; + } + } + @GeneratableAndroidBridgeTarget public static void setSelectedLocale(String localeCode) { /* Bug 713464: This method is still called from Gecko side. diff --git a/netwerk/system/android/nsAndroidNetworkLinkService.cpp b/netwerk/system/android/nsAndroidNetworkLinkService.cpp index f8d64660e05a..01ed147847c0 100644 --- a/netwerk/system/android/nsAndroidNetworkLinkService.cpp +++ b/netwerk/system/android/nsAndroidNetworkLinkService.cpp @@ -49,7 +49,13 @@ nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType) { NS_ENSURE_ARG_POINTER(aLinkType); - // XXX This function has not yet been implemented for this platform - *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; + if (!mozilla::AndroidBridge::Bridge()) { + // Fail soft here and assume a connection exists + NS_WARNING("GetLinkType is not supported without a bridge connection"); + *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; + return NS_OK; + } + + *aLinkType = mozilla::AndroidBridge::Bridge()->NetworkLinkType(); return NS_OK; } diff --git a/widget/android/GeneratedJNIWrappers.cpp b/widget/android/GeneratedJNIWrappers.cpp index 1b9b2f13586a..27d1ca4d4fba 100644 --- a/widget/android/GeneratedJNIWrappers.cpp +++ b/widget/android/GeneratedJNIWrappers.cpp @@ -66,6 +66,7 @@ void AndroidBridge::InitStubs(JNIEnv *jEnv) { jLockScreenOrientation = getStaticMethod("lockScreenOrientation", "(I)V"); jMarkURIVisited = getStaticMethod("markUriVisited", "(Ljava/lang/String;)V"); jMoveTaskToBack = getStaticMethod("moveTaskToBack", "()V"); + jNetworkLinkType = getStaticMethod("networkLinkType", "()I"); jNotifyDefaultPrevented = getStaticMethod("notifyDefaultPrevented", "(Z)V"); jNotifyIME = getStaticMethod("notifyIME", "(I)V"); jNotifyIMEChange = getStaticMethod("notifyIMEChange", "(Ljava/lang/String;III)V"); @@ -1451,6 +1452,33 @@ void AndroidBridge::MoveTaskToBack() { env->PopLocalFrame(NULL); } +int32_t AndroidBridge::NetworkLinkType() { + JNIEnv *env = GetJNIEnv(); + if (!env) { + ALOG_BRIDGE("Aborted: No env - %s", __PRETTY_FUNCTION__); + return 0; + } + + if (env->PushLocalFrame(0) != 0) { + ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__); + env->ExceptionDescribe(); + env->ExceptionClear(); + return 0; + } + + int32_t temp = env->CallStaticIntMethod(mGeckoAppShellClass, jNetworkLinkType); + + if (env->ExceptionCheck()) { + ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__); + env->ExceptionDescribe(); + env->ExceptionClear(); + env->PopLocalFrame(NULL); + return 0; + } + env->PopLocalFrame(NULL); + return temp; +} + void AndroidBridge::NotifyDefaultPrevented(bool a0) { JNIEnv *env = GetJNIEnv(); if (!env) { diff --git a/widget/android/GeneratedJNIWrappers.h b/widget/android/GeneratedJNIWrappers.h index c71585242243..c755afbe9234 100644 --- a/widget/android/GeneratedJNIWrappers.h +++ b/widget/android/GeneratedJNIWrappers.h @@ -50,6 +50,7 @@ jmethodID jKillAnyZombies; jmethodID jLockScreenOrientation; jmethodID jMarkURIVisited; jmethodID jMoveTaskToBack; +jmethodID jNetworkLinkType; jmethodID jNotifyDefaultPrevented; jmethodID jNotifyIME; jmethodID jNotifyIMEChange; @@ -160,6 +161,7 @@ void KillAnyZombies(); void LockScreenOrientation(int32_t a0); void MarkURIVisited(const nsAString& a0); void MoveTaskToBack(); +int32_t NetworkLinkType(); void NotifyDefaultPrevented(bool a0); static void NotifyIME(int32_t a0); static void NotifyIMEChange(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3); From dc139405e14fad16628043d305804226366d17d4 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 19 Nov 2013 13:45:31 +0900 Subject: [PATCH 14/72] Bug 938437 - Replace nsStaticXULComponents.cpp with smart use of sections. r=bsmedberg,irc-r=decoder --- toolkit/library/Makefile.in | 51 +--- .../StaticXULComponentsEnd.cpp | 4 + .../library/StaticXULComponentsEnd/moz.build | 11 + toolkit/library/StaticXULComponentsStart.cpp | 4 + toolkit/library/moz.build | 2 +- toolkit/library/nsStaticXULComponents.cpp | 267 ------------------ toolkit/toolkit.mozbuild | 1 + xpcom/components/Module.h | 17 +- xpcom/components/nsComponentManager.cpp | 20 +- 9 files changed, 51 insertions(+), 326 deletions(-) create mode 100644 toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp create mode 100644 toolkit/library/StaticXULComponentsEnd/moz.build create mode 100644 toolkit/library/StaticXULComponentsStart.cpp delete mode 100644 toolkit/library/nsStaticXULComponents.cpp diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 02c7eefa553e..9de89a088ae0 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -69,49 +69,6 @@ endif endif # component libraries -ifdef MOZ_JSDEBUGGER -DEFINES += -DMOZ_JSDEBUGGER -endif - -ifdef MOZ_PREF_EXTENSIONS -DEFINES += -DMOZ_PREF_EXTENSIONS -endif - -ifdef MOZ_AUTH_EXTENSION -DEFINES += -DMOZ_AUTH_EXTENSION -endif - -ifdef MOZ_PERMISSIONS -DEFINES += -DMOZ_PERMISSIONS -endif - -ifdef MOZ_UNIVERSALCHARDET -DEFINES += -DMOZ_UNIVERSALCHARDET -endif - -ifeq (,$(filter android gonk qt os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT))) -ifdef MOZ_XUL -DEFINES += -DMOZ_FILEVIEW -endif -endif - -# Platform-specific icon channel stuff - supported mostly-everywhere -ifneq (,$(filter windows os2 mac cocoa gtk2 gtk3 qt android,$(MOZ_WIDGET_TOOLKIT))) -DEFINES += -DICON_DECODER -endif - -ifdef MOZ_SPELLCHECK -DEFINES += -DMOZ_SPELLCHECK -endif - -ifdef MOZ_ZIPWRITER -DEFINES += -DMOZ_ZIPWRITER -endif - -ifdef MOZ_GIO_COMPONENT -DEFINES += -DMOZ_GIO_COMPONENT -endif - ifdef MOZ_APP_COMPONENT_LIBS COMPONENT_LIBS += $(MOZ_APP_COMPONENT_LIBS) endif @@ -400,12 +357,6 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),windows) OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32) endif -ifdef MOZ_DEBUG -ifdef ENABLE_TESTS -DEFINES += -DENABLE_LAYOUTDEBUG -endif -endif - ifeq (WINNT_1,$(OS_TARGET)_$(MOZ_PROFILE_USE)) # Wrap linker to measure peak virtual memory usage. LD := $(PYTHON) $(topsrcdir)/build/link.py $(CURDIR)/linker-vsize $(LD) @@ -444,3 +395,5 @@ endif $(FINAL_TARGET)/dependentlibs.list: dependentlibs.py $(SHARED_LIBRARY) $(wildcard $(if $(wildcard $(FINAL_TARGET)/dependentlibs.list),$(addprefix $(FINAL_TARGET)/,$(shell cat $(FINAL_TARGET)/dependentlibs.list)))) $(PYTHON) $< $(SHARED_LIBRARY) -L $(FINAL_TARGET) $(if $(TOOLCHAIN_PREFIX),$(addprefix -p ,$(TOOLCHAIN_PREFIX))) > $@ + +EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,StaticXULComponentsEnd,$(CURDIR)/StaticXULComponentsEnd) diff --git a/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp b/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp new file mode 100644 index 000000000000..015f8865df4b --- /dev/null +++ b/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp @@ -0,0 +1,4 @@ +#include "mozilla/Module.h" +#include "mozilla/NullPtr.h" + +NSMODULE_DEFN(end_kPStaticModules) = nullptr; diff --git a/toolkit/library/StaticXULComponentsEnd/moz.build b/toolkit/library/StaticXULComponentsEnd/moz.build new file mode 100644 index 000000000000..493bb7721e0e --- /dev/null +++ b/toolkit/library/StaticXULComponentsEnd/moz.build @@ -0,0 +1,11 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SOURCES += [ + 'StaticXULComponentsEnd.cpp', +] + +LIBRARY_NAME = 'StaticXULComponentsEnd' + +LIBXUL_LIBRARY = True diff --git a/toolkit/library/StaticXULComponentsStart.cpp b/toolkit/library/StaticXULComponentsStart.cpp new file mode 100644 index 000000000000..dc24b589459e --- /dev/null +++ b/toolkit/library/StaticXULComponentsStart.cpp @@ -0,0 +1,4 @@ +#include "mozilla/Module.h" +#include "mozilla/NullPtr.h" + +NSMODULE_DEFN(start_kPStaticModules) = nullptr; diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index b20253bfd391..435ef159f6b3 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_METRO'] and CONFIG['OS_ARCH'] == 'WINNT': LIBRARY_NAME = 'xul' SOURCES += [ - 'nsStaticXULComponents.cpp', + 'StaticXULComponentsStart.cpp', ] if CONFIG['OS_ARCH'] == 'WINNT': diff --git a/toolkit/library/nsStaticXULComponents.cpp b/toolkit/library/nsStaticXULComponents.cpp deleted file mode 100644 index ddc0699ec365..000000000000 --- a/toolkit/library/nsStaticXULComponents.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/Module.h" -#include "nsXPCOM.h" -#include "nsMemory.h" - -#ifdef MOZ_AUTH_EXTENSION -#define AUTH_MODULE MODULE(nsAuthModule) -#else -#define AUTH_MODULE -#endif - -#ifdef MOZ_PERMISSIONS -#define PERMISSIONS_MODULES \ - MODULE(nsCookieModule) \ - MODULE(nsPermissionsModule) -#else -#define PERMISSIONS_MODULES -#endif - -#ifdef MOZ_UNIVERSALCHARDET -#define UNIVERSALCHARDET_MODULE MODULE(nsUniversalCharDetModule) -#else -#define UNIVERSALCHARDET_MODULE -#endif - -#ifdef XP_WIN -# define WIDGET_MODULES MODULE(nsWidgetModule) -#elif defined(XP_MACOSX) -# define WIDGET_MODULES MODULE(nsWidgetMacModule) -#elif defined(XP_OS2) -# define WIDGET_MODULES MODULE(nsWidgetOS2Module) -#elif defined(MOZ_WIDGET_GTK) -# define WIDGET_MODULES MODULE(nsWidgetGtk2Module) -#elif defined(MOZ_WIDGET_QT) -# define WIDGET_MODULES MODULE(nsWidgetQtModule) -#elif defined(MOZ_WIDGET_ANDROID) -# define WIDGET_MODULES MODULE(nsWidgetAndroidModule) -#elif defined(MOZ_WIDGET_GONK) -# define WIDGET_MODULES MODULE(nsWidgetGonkModule) -#else -# error Unknown widget module. -#endif - -#ifdef ICON_DECODER -#define ICON_MODULE MODULE(nsIconDecoderModule) -#else -#define ICON_MODULE -#endif - -#ifdef MOZ_ENABLE_XREMOTE -#define XREMOTE_MODULES MODULE(RemoteServiceModule) -#else -#define XREMOTE_MODULES -#endif - -#ifdef MOZ_PREF_EXTENSIONS -#define SYSTEMPREF_MODULES MODULE(nsAutoConfigModule) -#else -#define SYSTEMPREF_MODULES -#endif - -#ifdef ENABLE_LAYOUTDEBUG -#define LAYOUT_DEBUG_MODULE MODULE(nsLayoutDebugModule) -#else -#define LAYOUT_DEBUG_MODULE -#endif - -#ifdef MOZ_JSDEBUGGER -#define JSDEBUGGER_MODULES \ - MODULE(JavaScript_Debugger) -#else -#define JSDEBUGGER_MODULES -#endif - -#if defined(MOZ_FILEVIEW) && defined(MOZ_XUL) -#define FILEVIEW_MODULE MODULE(nsFileViewModule) -#else -#define FILEVIEW_MODULE -#endif - -#ifdef MOZ_ZIPWRITER -#define ZIPWRITER_MODULE MODULE(ZipWriterModule) -#else -#define ZIPWRITER_MODULE -#endif - -#ifdef MOZ_PLACES -#define PLACES_MODULES \ - MODULE(nsPlacesModule) -#else -#define PLACES_MODULES -#endif - -#ifdef MOZ_XUL -#define XULENABLED_MODULES \ - MODULE(tkAutoCompleteModule) \ - MODULE(satchel) \ - MODULE(PKI) -#else -#define XULENABLED_MODULES -#endif - -#ifdef MOZ_SPELLCHECK -#define SPELLCHECK_MODULE MODULE(mozSpellCheckerModule) -#else -#define SPELLCHECK_MODULE -#endif - -#ifdef MOZ_XUL -#ifdef MOZ_WIDGET_GTK -#define UNIXPROXY_MODULE MODULE(nsUnixProxyModule) -#endif -#if defined(MOZ_WIDGET_QT) -#define UNIXPROXY_MODULE MODULE(nsUnixProxyModule) -#endif -#endif -#ifndef UNIXPROXY_MODULE -#define UNIXPROXY_MODULE -#endif - -#if defined(XP_MACOSX) -#define OSXPROXY_MODULE MODULE(nsOSXProxyModule) -#else -#define OSXPROXY_MODULE -#endif - -#if defined(XP_WIN) -#define WINDOWSPROXY_MODULE MODULE(nsWindowsProxyModule) -#else -#define WINDOWSPROXY_MODULE -#endif - -#if defined(MOZ_WIDGET_ANDROID) -#define ANDROIDPROXY_MODULE MODULE(nsAndroidProxyModule) -#else -#define ANDROIDPROXY_MODULE -#endif - -#if defined(BUILD_CTYPES) -#define JSCTYPES_MODULE MODULE(jsctypes) -#else -#define JSCTYPES_MODULE -#endif - -#ifndef MOZ_APP_COMPONENT_MODULES -#if defined(MOZ_APP_COMPONENT_INCLUDE) -#include MOZ_APP_COMPONENT_INCLUDE -#define MOZ_APP_COMPONENT_MODULES APP_COMPONENT_MODULES -#else -#define MOZ_APP_COMPONENT_MODULES -#endif -#endif - -#if defined(MOZ_ENABLE_PROFILER_SPS) -#define PROFILER_MODULE MODULE(nsProfilerModule) -#else -#define PROFILER_MODULE -#endif - -#if defined(MOZ_WEBRTC) -#define PEERCONNECTION_MODULE MODULE(peerconnection) -#else -#define PEERCONNECTION_MODULE -#endif - -#if defined(MOZ_GIO_COMPONENT) -#define GIO_MODULE MODULE(nsGIOModule) -#else -#define GIO_MODULE -#endif - -#if defined(MOZ_SYNTH_PICO) -#define SYNTH_PICO_MODULE MODULE(synthpico) -#else -#define SYNTH_PICO_MODULE -#endif - -#define XUL_MODULES \ - MODULE(nsUConvModule) \ - MODULE(nsI18nModule) \ - MODULE(nsChardetModule) \ - UNIVERSALCHARDET_MODULE \ - MODULE(necko) \ - PERMISSIONS_MODULES \ - AUTH_MODULE \ - MODULE(nsJarModule) \ - ZIPWRITER_MODULE \ - MODULE(StartupCacheModule) \ - MODULE(nsPrefModule) \ - MODULE(nsRDFModule) \ - MODULE(nsWindowDataSourceModule) \ - MODULE(nsParserModule) \ - MODULE(nsImageLib2Module) \ - MODULE(nsMediaSnifferModule) \ - MODULE(nsGfxModule) \ - PROFILER_MODULE \ - WIDGET_MODULES \ - ICON_MODULE \ - MODULE(nsPluginModule) \ - MODULE(nsLayoutModule) \ - MODULE(docshell_provider) \ - MODULE(embedcomponents) \ - MODULE(Browser_Embedding_Module) \ - MODULE(appshell) \ - MODULE(nsTransactionManagerModule) \ - MODULE(nsComposerModule) \ - MODULE(application) \ - MODULE(Apprunner) \ - MODULE(CommandLineModule) \ - FILEVIEW_MODULE \ - MODULE(mozStorageModule) \ - PLACES_MODULES \ - XULENABLED_MODULES \ - MODULE(nsToolkitCompsModule) \ - XREMOTE_MODULES \ - JSDEBUGGER_MODULES \ - MODULE(BOOT) \ - MODULE(NSS) \ - SYSTEMPREF_MODULES \ - SPELLCHECK_MODULE \ - LAYOUT_DEBUG_MODULE \ - UNIXPROXY_MODULE \ - OSXPROXY_MODULE \ - WINDOWSPROXY_MODULE \ - ANDROIDPROXY_MODULE \ - JSCTYPES_MODULE \ - MODULE(jsreflect) \ - MODULE(jsperf) \ - MODULE(identity) \ - MODULE(nsServicesCryptoModule) \ - MOZ_APP_COMPONENT_MODULES \ - MODULE(nsTelemetryModule) \ - MODULE(jsinspector) \ - MODULE(jsdebugger) \ - PEERCONNECTION_MODULE \ - GIO_MODULE \ - SYNTH_PICO_MODULE \ - MODULE(DiskSpaceWatcherModule) \ - /* end of list */ - -#define MODULE(_name) \ - NSMODULE_DECL(_name); - -XUL_MODULES - -#ifdef MOZ_WIDGET_GONK -MODULE(WifiProxyServiceModule) -#endif - -#undef MODULE - -#define MODULE(_name) \ - &NSMODULE_NAME(_name), - -extern const mozilla::Module *const *const kPStaticModules[] = { - XUL_MODULES -#ifdef MOZ_WIDGET_GONK -MODULE(WifiProxyServiceModule) -#endif - nullptr -}; - -#undef MODULE diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index 1bfbee8e53a9..bb4215a6a811 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -161,6 +161,7 @@ if CONFIG['MOZ_GIO_COMPONENT']: add_tier_dir('platform', app_libxul_dirs) add_tier_dir('platform', app_libxul_static_dirs, static=True) +add_tier_dir('platform', 'toolkit/library/StaticXULComponentsEnd') add_tier_dir('platform', 'toolkit/library') if CONFIG['MOZ_REPLACE_MALLOC']: diff --git a/xpcom/components/Module.h b/xpcom/components/Module.h index 27449291b13e..c6fa5f600ab6 100644 --- a/xpcom/components/Module.h +++ b/xpcom/components/Module.h @@ -105,8 +105,21 @@ struct Module #if defined(MOZILLA_INTERNAL_API) # define NSMODULE_NAME(_name) _name##_NSModule -# define NSMODULE_DECL(_name) extern mozilla::Module const *const NSMODULE_NAME(_name) -# define NSMODULE_DEFN(_name) NSMODULE_DECL(_name) +# if defined(_MSC_VER) +# pragma section(".kPStaticModules", read) +# pragma comment(linker, "/merge:.kPStaticModules=.rdata") +# define NSMODULE_SECTION __declspec(allocate(".kPStaticModules")) +# elif defined(__GNUC__) +# if defined(__ELF__) +# define NSMODULE_SECTION __attribute__((section(".kPStaticModules"), visibility("protected"))) +# elif defined(__MACH__) +# define NSMODULE_SECTION __attribute__((section("__DATA, .kPStaticModules"), visibility("default"))) +# endif +# endif +# if !defined(NSMODULE_SECTION) +# error Do not know how to define sections. +# endif +# define NSMODULE_DEFN(_name) extern NSMODULE_SECTION mozilla::Module const *const NSMODULE_NAME(_name) #else # define NSMODULE_NAME(_name) NSModule # define NSMODULE_DEFN(_name) extern "C" NS_EXPORT mozilla::Module const *const NSModule diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index b8b908be994d..f81f59a0d1da 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -79,10 +79,6 @@ using namespace mozilla; PRLogModuleInfo* nsComponentManagerLog = nullptr; -// defined in nsStaticXULComponents.cpp to contain all the components in -// libxul. -extern mozilla::Module const *const *const kPStaticModules[]; - #if 0 || defined (DEBUG_timeless) #define SHOW_DENIED_ON_SHUTDOWN #define SHOW_CI_ON_EXISTING_SERVICE @@ -322,6 +318,15 @@ nsComponentManagerImpl::nsComponentManagerImpl() nsTArray* nsComponentManagerImpl::sStaticModules; +NSMODULE_DEFN(start_kPStaticModules); +NSMODULE_DEFN(end_kPStaticModules); + +/* The content between start_kPStaticModules and end_kPStaticModules is gathered + * by the linker from various objects containing symbols in a specific section. + * ASAN considers (rightfully) the use of this content as a global buffer + * overflow. But this is a deliberate and well-considered choice, with no proper + * way to make ASAN happy. */ +MOZ_ASAN_BLACKLIST /* static */ void nsComponentManagerImpl::InitializeStaticModules() { @@ -329,9 +334,10 @@ nsComponentManagerImpl::InitializeStaticModules() return; sStaticModules = new nsTArray; - for (const mozilla::Module *const *const *staticModules = kPStaticModules; - *staticModules; ++staticModules) - sStaticModules->AppendElement(**staticModules); + for (const mozilla::Module *const *staticModules = &NSMODULE_NAME(start_kPStaticModules) + 1; + staticModules < &NSMODULE_NAME(end_kPStaticModules); ++staticModules) + if (*staticModules) // ASAN adds padding + sStaticModules->AppendElement(*staticModules); } nsTArray* From 24dbdc00cd18edede81db7dd5ccd27e81de7d877 Mon Sep 17 00:00:00 2001 From: Mark Finkle Date: Mon, 18 Nov 2013 23:52:01 -0500 Subject: [PATCH 15/72] Backout 86253e0141c8 to avoid cross-branch merge isses from fx-team and bug 913985 --- mobile/android/base/GeckoAppShell.java | 72 ------------------- .../android/nsAndroidNetworkLinkService.cpp | 10 +-- widget/android/GeneratedJNIWrappers.cpp | 28 -------- widget/android/GeneratedJNIWrappers.h | 2 - 4 files changed, 2 insertions(+), 110 deletions(-) diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 7601d4fa466e..cebe06dc7a83 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -66,7 +66,6 @@ import android.os.MessageQueue; import android.os.SystemClock; import android.os.Vibrator; import android.provider.Settings; -import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Base64; import android.util.DisplayMetrics; @@ -134,18 +133,6 @@ public class GeckoAppShell static public final int WPL_STATE_IS_DOCUMENT = 0x00020000; static public final int WPL_STATE_IS_NETWORK = 0x00040000; - /* Keep in sync with constants found here: - http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsINetworkLinkService.idl - */ - static public final int LINK_TYPE_UNKNOWN = 0; - static public final int LINK_TYPE_ETHERNET = 1; - static public final int LINK_TYPE_USB = 2; - static public final int LINK_TYPE_WIFI = 3; - static public final int LINK_TYPE_WIMAX = 4; - static public final int LINK_TYPE_2G = 5; - static public final int LINK_TYPE_3G = 6; - static public final int LINK_TYPE_4G = 7; - public static final String SHORTCUT_TYPE_WEBAPP = "webapp"; public static final String SHORTCUT_TYPE_BOOKMARK = "bookmark"; @@ -1545,65 +1532,6 @@ public class GeckoAppShell return true; } - @GeneratableAndroidBridgeTarget - public static int networkLinkType() { - ConnectivityManager cm = (ConnectivityManager) - getContext().getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo info = cm.getActiveNetworkInfo(); - if (info == null) { - return LINK_TYPE_UNKNOWN; - } - - switch (info.getType()) { - case ConnectivityManager.TYPE_ETHERNET: - return LINK_TYPE_ETHERNET; - case ConnectivityManager.TYPE_WIFI: - return LINK_TYPE_WIFI; - case ConnectivityManager.TYPE_WIMAX: - return LINK_TYPE_WIMAX; - case ConnectivityManager.TYPE_MOBILE: - break; // We will handle sub-types after the switch. - default: - Log.w(LOGTAG, "Ignoring the current network type."); - return LINK_TYPE_UNKNOWN; - } - - TelephonyManager tm = (TelephonyManager) - getContext().getSystemService(Context.TELEPHONY_SERVICE); - if (tm == null) { - Log.e(LOGTAG, "Telephony service does not exist"); - return LINK_TYPE_UNKNOWN; - } - - switch (tm.getNetworkType()) { - case TelephonyManager.NETWORK_TYPE_IDEN: - case TelephonyManager.NETWORK_TYPE_CDMA: - case TelephonyManager.NETWORK_TYPE_GPRS: - return LINK_TYPE_2G; - case TelephonyManager.NETWORK_TYPE_1xRTT: - case TelephonyManager.NETWORK_TYPE_EDGE: - return LINK_TYPE_2G; // 2.5G - case TelephonyManager.NETWORK_TYPE_UMTS: - case TelephonyManager.NETWORK_TYPE_EVDO_0: - return LINK_TYPE_3G; - case TelephonyManager.NETWORK_TYPE_HSPA: - case TelephonyManager.NETWORK_TYPE_HSDPA: - case TelephonyManager.NETWORK_TYPE_HSUPA: - case TelephonyManager.NETWORK_TYPE_EVDO_A: - case TelephonyManager.NETWORK_TYPE_EVDO_B: - case TelephonyManager.NETWORK_TYPE_EHRPD: - return LINK_TYPE_3G; // 3.5G - case TelephonyManager.NETWORK_TYPE_HSPAP: - return LINK_TYPE_3G; // 3.75G - case TelephonyManager.NETWORK_TYPE_LTE: - return LINK_TYPE_4G; // 3.9G - case TelephonyManager.NETWORK_TYPE_UNKNOWN: - default: - Log.w(LOGTAG, "Connected to an unknown mobile network!"); - return LINK_TYPE_UNKNOWN; - } - } - @GeneratableAndroidBridgeTarget public static void setSelectedLocale(String localeCode) { /* Bug 713464: This method is still called from Gecko side. diff --git a/netwerk/system/android/nsAndroidNetworkLinkService.cpp b/netwerk/system/android/nsAndroidNetworkLinkService.cpp index 01ed147847c0..f8d64660e05a 100644 --- a/netwerk/system/android/nsAndroidNetworkLinkService.cpp +++ b/netwerk/system/android/nsAndroidNetworkLinkService.cpp @@ -49,13 +49,7 @@ nsAndroidNetworkLinkService::GetLinkType(uint32_t *aLinkType) { NS_ENSURE_ARG_POINTER(aLinkType); - if (!mozilla::AndroidBridge::Bridge()) { - // Fail soft here and assume a connection exists - NS_WARNING("GetLinkType is not supported without a bridge connection"); - *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; - return NS_OK; - } - - *aLinkType = mozilla::AndroidBridge::Bridge()->NetworkLinkType(); + // XXX This function has not yet been implemented for this platform + *aLinkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; return NS_OK; } diff --git a/widget/android/GeneratedJNIWrappers.cpp b/widget/android/GeneratedJNIWrappers.cpp index 27d1ca4d4fba..1b9b2f13586a 100644 --- a/widget/android/GeneratedJNIWrappers.cpp +++ b/widget/android/GeneratedJNIWrappers.cpp @@ -66,7 +66,6 @@ void AndroidBridge::InitStubs(JNIEnv *jEnv) { jLockScreenOrientation = getStaticMethod("lockScreenOrientation", "(I)V"); jMarkURIVisited = getStaticMethod("markUriVisited", "(Ljava/lang/String;)V"); jMoveTaskToBack = getStaticMethod("moveTaskToBack", "()V"); - jNetworkLinkType = getStaticMethod("networkLinkType", "()I"); jNotifyDefaultPrevented = getStaticMethod("notifyDefaultPrevented", "(Z)V"); jNotifyIME = getStaticMethod("notifyIME", "(I)V"); jNotifyIMEChange = getStaticMethod("notifyIMEChange", "(Ljava/lang/String;III)V"); @@ -1452,33 +1451,6 @@ void AndroidBridge::MoveTaskToBack() { env->PopLocalFrame(NULL); } -int32_t AndroidBridge::NetworkLinkType() { - JNIEnv *env = GetJNIEnv(); - if (!env) { - ALOG_BRIDGE("Aborted: No env - %s", __PRETTY_FUNCTION__); - return 0; - } - - if (env->PushLocalFrame(0) != 0) { - ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__); - env->ExceptionDescribe(); - env->ExceptionClear(); - return 0; - } - - int32_t temp = env->CallStaticIntMethod(mGeckoAppShellClass, jNetworkLinkType); - - if (env->ExceptionCheck()) { - ALOG_BRIDGE("Exceptional exit of: %s", __PRETTY_FUNCTION__); - env->ExceptionDescribe(); - env->ExceptionClear(); - env->PopLocalFrame(NULL); - return 0; - } - env->PopLocalFrame(NULL); - return temp; -} - void AndroidBridge::NotifyDefaultPrevented(bool a0) { JNIEnv *env = GetJNIEnv(); if (!env) { diff --git a/widget/android/GeneratedJNIWrappers.h b/widget/android/GeneratedJNIWrappers.h index c755afbe9234..c71585242243 100644 --- a/widget/android/GeneratedJNIWrappers.h +++ b/widget/android/GeneratedJNIWrappers.h @@ -50,7 +50,6 @@ jmethodID jKillAnyZombies; jmethodID jLockScreenOrientation; jmethodID jMarkURIVisited; jmethodID jMoveTaskToBack; -jmethodID jNetworkLinkType; jmethodID jNotifyDefaultPrevented; jmethodID jNotifyIME; jmethodID jNotifyIMEChange; @@ -161,7 +160,6 @@ void KillAnyZombies(); void LockScreenOrientation(int32_t a0); void MarkURIVisited(const nsAString& a0); void MoveTaskToBack(); -int32_t NetworkLinkType(); void NotifyDefaultPrevented(bool a0); static void NotifyIME(int32_t a0); static void NotifyIMEChange(const nsAString& a0, int32_t a1, int32_t a2, int32_t a3); From b35daa7ae47a93aea5b8fb2ae02572b46b41307d Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 18 Nov 2013 20:22:41 -0500 Subject: [PATCH 16/72] Bug 936566 - Print mask layers in layers dump. r=nrc --HG-- extra : rebase_source : cb960d4f8880f9c3fd39fafc8a4c8a21f6a19596 --- gfx/layers/Layers.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 709750bcd968..3309f34bb4c8 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1262,6 +1262,12 @@ Layer::LogSelf(const char* aPrefix) nsAutoCString str; PrintInfo(str, aPrefix); MOZ_LAYERS_LOG(("%s", str.get())); + + if (mMaskLayer) { + nsAutoCString pfx(aPrefix); + pfx += " \\ MaskLayer "; + mMaskLayer->LogSelf(pfx.get()); + } } nsACString& @@ -1306,6 +1312,9 @@ Layer::PrintInfo(nsACString& aTo, const char* aPrefix) mStickyPositionData->mInner.x, mStickyPositionData->mInner.y, mStickyPositionData->mInner.width, mStickyPositionData->mInner.height); } + if (mMaskLayer) { + aTo.AppendPrintf(" [mMaskLayer=%p]", mMaskLayer); + } return aTo; } From fbc92cc0f486f137ab156dc24bea055de19b621e Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Mon, 18 Nov 2013 16:45:14 -0500 Subject: [PATCH 17/72] Bug 939950 - Build gfx/2d in unified mode. r=bjacob,ehsan,bas --HG-- extra : rebase_source : 4776cc15a2de124149624b8297ae0c4953621eae --- gfx/2d/DrawTargetCG.h | 6 ++++++ gfx/2d/PathCG.h | 1 - gfx/2d/RecordedEvent.cpp | 2 +- gfx/2d/RecordedEvent.h | 26 +++++++++++++------------- gfx/2d/moz.build | 10 ++++++---- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/gfx/2d/DrawTargetCG.h b/gfx/2d/DrawTargetCG.h index 12c08fb19295..4bfde0def1e6 100644 --- a/gfx/2d/DrawTargetCG.h +++ b/gfx/2d/DrawTargetCG.h @@ -3,6 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef mozilla_gfx_DrawTargetCG_h +#define mozilla_gfx_DrawTargetCG_h + #include #include "2D.h" @@ -176,3 +179,6 @@ private: } } + +#endif + diff --git a/gfx/2d/PathCG.h b/gfx/2d/PathCG.h index 9665c15c0821..b1cd6b96dd90 100644 --- a/gfx/2d/PathCG.h +++ b/gfx/2d/PathCG.h @@ -95,7 +95,6 @@ private: friend class DrawTargetCG; CGMutablePathRef mPath; - bool mEndedActive; Point mEndPoint; FillRule mFillRule; }; diff --git a/gfx/2d/RecordedEvent.cpp b/gfx/2d/RecordedEvent.cpp index 1facad518425..282d98103c94 100644 --- a/gfx/2d/RecordedEvent.cpp +++ b/gfx/2d/RecordedEvent.cpp @@ -277,7 +277,7 @@ RecordedDrawingEvent::RecordToStream(ostream &aStream) const } ReferencePtr -RecordedDrawingEvent::GetObject() const +RecordedDrawingEvent::GetObjectRef() const { return mDT; } diff --git a/gfx/2d/RecordedEvent.h b/gfx/2d/RecordedEvent.h index 9c363d870c47..a5cee9863c72 100644 --- a/gfx/2d/RecordedEvent.h +++ b/gfx/2d/RecordedEvent.h @@ -178,7 +178,7 @@ public: virtual std::string GetName() const = 0; - virtual ReferencePtr GetObject() const = 0; + virtual ReferencePtr GetObjectRef() const = 0; virtual ReferencePtr GetDestinedDT() { return nullptr; } @@ -211,7 +211,7 @@ protected: RecordedDrawingEvent(EventType aType, std::istream &aStream); virtual void RecordToStream(std::ostream &aStream) const; - virtual ReferencePtr GetObject() const; + virtual ReferencePtr GetObjectRef() const; ReferencePtr mDT; }; @@ -228,7 +228,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "DrawTarget Creation"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } ReferencePtr mRefPtr; BackendType mBackendType; @@ -253,7 +253,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "DrawTarget Destruction"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } ReferencePtr mRefPtr; @@ -646,7 +646,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "Path Creation"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; @@ -670,7 +670,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "Path Destruction"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; @@ -696,7 +696,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "SourceSurface Creation"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; @@ -723,7 +723,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "SourceSurface Destruction"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; @@ -749,7 +749,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "GradientStops Creation"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; @@ -775,7 +775,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "GradientStops Destruction"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; @@ -797,7 +797,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "Snapshot"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; @@ -828,7 +828,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "ScaledFont Creation"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } void SetFontData(const uint8_t *aData, uint32_t aSize, uint32_t aIndex, Float aGlyphSize); @@ -857,7 +857,7 @@ public: virtual void OutputSimpleEventInfo(std::stringstream &aStringStream) const; virtual std::string GetName() const { return "ScaledFont Destruction"; } - virtual ReferencePtr GetObject() const { return mRefPtr; } + virtual ReferencePtr GetObjectRef() const { return mRefPtr; } private: friend class RecordedEvent; diff --git a/gfx/2d/moz.build b/gfx/2d/moz.build index daaf3ac40c13..0983f55f2fef 100644 --- a/gfx/2d/moz.build +++ b/gfx/2d/moz.build @@ -36,7 +36,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': 'MacIOSurface.h', 'QuartzSupport.h', ] - SOURCES += [ + UNIFIED_SOURCES += [ 'DrawTargetCG.cpp', 'PathCG.cpp', 'ScaledFontMac.cpp', @@ -62,13 +62,15 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': ] if CONFIG['MOZ_ENABLE_SKIA']: - SOURCES += [ + UNIFIED_SOURCES += [ 'convolver.cpp', 'DrawTargetSkia.cpp', - 'image_operations.cpp', 'PathSkia.cpp', 'SourceSurfaceSkia.cpp', ] + SOURCES += [ + 'image_operations.cpp', # Uses _USE_MATH_DEFINES + ] # Are we targeting x86 or x64? If so, build SSE2 files. if CONFIG['INTEL_ARCHITECTURE']: @@ -79,7 +81,7 @@ if CONFIG['INTEL_ARCHITECTURE']: 'ImageScalingSSE2.cpp', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'Blur.cpp', 'DrawEventRecorder.cpp', 'DrawTargetCairo.cpp', From 0471905a267245523ed56212ed0f8768f9a1ca3d Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Mon, 18 Nov 2013 13:01:54 -0500 Subject: [PATCH 18/72] Bug 845874. Switch to Y-X banded regions. r=roc Previously our region code was just a simple y,x sorted list of non-intersecting rectangles. This can cause us to have simple regions represented in a complex unoptimizable way. Switching to pixman regions gives us a canonical region implementation. There are some cases when this can cause performance regressions. For example, with the old region code we end up with this region: http://people.mozilla.org/~jmuizelaar/region-pre.html which is represented like this: http://people.mozilla.org/~jmuizelaar/region-post.html with the new code. We call SimplifyOutward(4) on this. With old regions we can't simplify it so we end up taking the bounds and get 1 rect. With the new regions we have only 3 rects to start and so we do nothing. The difference between 3 rects and 1 rect cause D2D to do a PushLayer() instead of a ClipRect() and that seems to be the causes for the regression. --HG-- extra : rebase_source : 65e0d29d67b51a3780448eaecfde33dbcb6b99b1 --- gfx/cairo/cairo/src/cairo-rename.h | 128 +- gfx/cairo/cairo/src/moz.build | 1 + gfx/cairo/cairo/src/pixman-rename.h | 128 ++ gfx/cairo/libpixman/src/pixman-compiler.h | 14 +- gfx/cairo/libpixman/src/pixman.h | 5 +- gfx/src/nsRegion.cpp | 1635 +++------------------ gfx/src/nsRegion.h | 351 +++-- gfx/tests/gtest/TestRegion.cpp | 47 + layout/media/symbols.def.in | 24 + uriloader/exthandler/Makefile.in | 2 +- 10 files changed, 581 insertions(+), 1754 deletions(-) create mode 100644 gfx/cairo/cairo/src/pixman-rename.h diff --git a/gfx/cairo/cairo/src/cairo-rename.h b/gfx/cairo/cairo/src/cairo-rename.h index c44577f5062a..d29d42cb0297 100644 --- a/gfx/cairo/cairo/src/cairo-rename.h +++ b/gfx/cairo/cairo/src/cairo-rename.h @@ -362,130 +362,4 @@ #define cairo_xlib_surface_get_xrender_format _moz_cairo_xlib_surface_get_xrender_format #define cairo_xlib_surface_set_drawable _moz_cairo_xlib_surface_set_drawable #define cairo_xlib_surface_set_size _moz_cairo_xlib_surface_set_size -#ifdef MOZ_TREE_PIXMAN -#define pixman_region_set_static_pointers _moz_pixman_region_set_static_pointers -#define pixman_region_init _moz_pixman_region_init -#define pixman_region_init_rect _moz_pixman_region_init_rect -#define pixman_region_init_rects _moz_pixman_region_init_rects -#define pixman_region_init_with_extents _moz_pixman_region_init_with_extents -#define pixman_region_fini _moz_pixman_region_fini -#define pixman_region_translate _moz_pixman_region_translate -#define pixman_region_copy _moz_pixman_region_copy -#define pixman_region_intersect _moz_pixman_region_intersect -#define pixman_region_union _moz_pixman_region_union -#define pixman_region_union_rect _moz_pixman_region_union_rect -#define pixman_region_subtract _moz_pixman_region_subtract -#define pixman_region_inverse _moz_pixman_region_inverse -#define pixman_region_contains_point _moz_pixman_region_contains_point -#define pixman_region_contains_rectangle _moz_pixman_region_contains_rectangle -#define pixman_region_not_empty _moz_pixman_region_not_empty -#define pixman_region_extents _moz_pixman_region_extents -#define pixman_region_n_rects _moz_pixman_region_n_rects -#define pixman_region_rectangles _moz_pixman_region_rectangles -#define pixman_region_equal _moz_pixman_region_equal -#define pixman_region_selfcheck _moz_pixman_region_selfcheck -#define pixman_region_reset _moz_pixman_region_reset -#define pixman_region32_init _moz_pixman_region32_init -#define pixman_region32_init_rect _moz_pixman_region32_init_rect -#define pixman_region32_init_rects _moz_pixman_region32_init_rects -#define pixman_region32_init_with_extents _moz_pixman_region32_init_with_extents -#define pixman_region32_fini _moz_pixman_region32_fini -#define pixman_region32_translate _moz_pixman_region32_translate -#define pixman_region32_copy _moz_pixman_region32_copy -#define pixman_region32_intersect _moz_pixman_region32_intersect -#define pixman_region32_union _moz_pixman_region32_union -#define pixman_region32_union_rect _moz_pixman_region32_union_rect -#define pixman_region32_subtract _moz_pixman_region32_subtract -#define pixman_region32_inverse _moz_pixman_region32_inverse -#define pixman_region32_contains_point _moz_pixman_region32_contains_point -#define pixman_region32_contains_rectangle _moz_pixman_region32_contains_rectangle -#define pixman_region32_not_empty _moz_pixman_region32_not_empty -#define pixman_region32_extents _moz_pixman_region32_extents -#define pixman_region32_n_rects _moz_pixman_region32_n_rects -#define pixman_region32_rectangles _moz_pixman_region32_rectangles -#define pixman_region32_equal _moz_pixman_region32_equal -#define pixman_region32_selfcheck _moz_pixman_region32_selfcheck -#define pixman_region32_reset _moz_pixman_region32_reset -#define pixman_blt _moz_pixman_blt -#define pixman_fill _moz_pixman_fill -#define pixman_transform_point_3d _moz_pixman_transform_point_3d -#define pixman_version _moz_pixman_version -#define pixman_version_string _moz_pixman_version_string -#define pixman_format_supported_destination _moz_pixman_format_supported_destination -#define pixman_format_supported_source _moz_pixman_format_supported_source -#define pixman_image_create_solid_fill _moz_pixman_image_create_solid_fill -#define pixman_image_create_linear_gradient _moz_pixman_image_create_linear_gradient -#define pixman_image_create_radial_gradient _moz_pixman_image_create_radial_gradient -#define pixman_image_create_conical_gradient _moz_pixman_image_create_conical_gradient -#define pixman_image_create_bits _moz_pixman_image_create_bits -#define pixman_image_ref _moz_pixman_image_ref -#define pixman_image_unref _moz_pixman_image_unref -#define pixman_image_set_clip_region _moz_pixman_image_set_clip_region -#define pixman_image_set_clip_region32 _moz_pixman_image_set_clip_region32 -#define pixman_image_set_has_client_clip _moz_pixman_image_set_has_client_clip -#define pixman_image_set_transform _moz_pixman_image_set_transform -#define pixman_image_set_repeat _moz_pixman_image_set_repeat -#define pixman_image_set_filter _moz_pixman_image_set_filter -#define pixman_image_set_source_clipping _moz_pixman_image_set_source_clipping -#define pixman_image_set_alpha_map _moz_pixman_image_set_alpha_map -#define pixman_image_set_component_alpha _moz_pixman_image_set_component_alpha -#define pixman_image_set_accessors _moz_pixman_image_set_accessors -#define pixman_image_set_indexed _moz_pixman_image_set_indexed -#define pixman_image_get_data _moz_pixman_image_get_data -#define pixman_image_get_width _moz_pixman_image_get_width -#define pixman_image_get_height _moz_pixman_image_get_height -#define pixman_image_get_stride _moz_pixman_image_get_stride -#define pixman_image_get_depth _moz_pixman_image_get_depth -#define pixman_image_fill_rectangles _moz_pixman_image_fill_rectangles -#define pixman_compute_composite_region _moz_pixman_compute_composite_region -#define pixman_image_composite _moz_pixman_image_composite -#define pixman_sample_ceil_y _moz_pixman_sample_ceil_y -#define pixman_sample_floor_y _moz_pixman_sample_floor_y -#define pixman_edge_step _moz_pixman_edge_step -#define pixman_edge_init _moz_pixman_edge_init -#define pixman_line_fixed_edge_init _moz_pixman_line_fixed_edge_init -#define pixman_rasterize_edges _moz_pixman_rasterize_edges -#define pixman_add_traps _moz_pixman_add_traps -#define pixman_add_trapezoids _moz_pixman_add_trapezoids -#define pixman_rasterize_trapezoid _moz_pixman_rasterize_trapezoid -#define pixman_disable_out_of_bounds_workaround _moz_pixman_disable_out_of_bounds_workaround -#define pixman_f_transform_bounds _moz_pixman_f_transform_bounds -#define pixman_f_transform_from_pixman_transform _moz_pixman_f_transform_from_pixman_transform -#define pixman_f_transform_init_identity _moz_pixman_f_transform_init_identity -#define pixman_f_transform_init_rotate _moz_pixman_f_transform_init_rotate -#define pixman_f_transform_init_scale _moz_pixman_f_transform_init_scale -#define pixman_f_transform_init_translate _moz_pixman_f_transform_init_translate -#define pixman_f_transform_invert _moz_pixman_f_transform_invert -#define pixman_f_transform_multiply _moz_pixman_f_transform_multiply -#define pixman_f_transform_point _moz_pixman_f_transform_point -#define pixman_f_transform_point_3d _moz_pixman_f_transform_point_3d -#define pixman_f_transform_rotate _moz_pixman_f_transform_rotate -#define pixman_f_transform_scale _moz_pixman_f_transform_scale -#define pixman_f_transform_translate _moz_pixman_f_transform_translate -#define pixman_image_composite32 _moz_pixman_image_composite32 -#define pixman_image_fill_boxes _moz_pixman_image_fill_boxes -#define pixman_image_get_component_alpha _moz_pixman_image_get_component_alpha -#define pixman_image_get_destroy_data _moz_pixman_image_get_destroy_data -#define pixman_image_get_format _moz_pixman_image_get_format -#define pixman_image_set_destroy_function _moz_pixman_image_set_destroy_function -#define pixman_region_init_from_image _moz_pixman_region_init_from_image -#define pixman_region_intersect_rect _moz_pixman_region_intersect_rect -#define pixman_region32_init_from_image _moz_pixman_region32_init_from_image -#define pixman_region32_intersect_rect _moz_pixman_region32_intersect_rect -#define pixman_transform_bounds _moz_pixman_transform_bounds -#define pixman_transform_from_pixman_f_transform _moz_pixman_transform_from_pixman_f_transform -#define pixman_transform_init_identity _moz_pixman_transform_init_identity -#define pixman_transform_init_rotate _moz_pixman_transform_init_rotate -#define pixman_transform_init_scale _moz_pixman_transform_init_scale -#define pixman_transform_init_translate _moz_pixman_transform_init_translate -#define pixman_transform_invert _moz_pixman_transform_invert -#define pixman_transform_is_identity _moz_pixman_transform_is_identity -#define pixman_transform_is_int_translate _moz_pixman_transform_is_int_translate -#define pixman_transform_is_inverse _moz_pixman_transform_is_inverse -#define pixman_transform_is_scale _moz_pixman_transform_is_scale -#define pixman_transform_multiply _moz_pixman_transform_multiply -#define pixman_transform_point _moz_pixman_transform_point -#define pixman_transform_rotate _moz_pixman_transform_rotate -#define pixman_transform_scale _moz_pixman_transform_scale -#define pixman_transform_translate _moz_pixman_transform_translate -#endif +#include "pixman-rename.h" diff --git a/gfx/cairo/cairo/src/moz.build b/gfx/cairo/cairo/src/moz.build index 4269f07e5d37..e00735176c0b 100644 --- a/gfx/cairo/cairo/src/moz.build +++ b/gfx/cairo/cairo/src/moz.build @@ -13,6 +13,7 @@ EXPORTS.cairo += [ 'cairo-tee.h', 'cairo-version.h', 'cairo.h', + 'pixman-rename.h', ] if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('cocoa', 'uikit'): diff --git a/gfx/cairo/cairo/src/pixman-rename.h b/gfx/cairo/cairo/src/pixman-rename.h new file mode 100644 index 000000000000..5d896e8e3950 --- /dev/null +++ b/gfx/cairo/cairo/src/pixman-rename.h @@ -0,0 +1,128 @@ +#ifdef MOZ_TREE_PIXMAN +#define pixman_region_set_static_pointers _moz_pixman_region_set_static_pointers +#define pixman_region_init _moz_pixman_region_init +#define pixman_region_init_rect _moz_pixman_region_init_rect +#define pixman_region_init_rects _moz_pixman_region_init_rects +#define pixman_region_init_with_extents _moz_pixman_region_init_with_extents +#define pixman_region_fini _moz_pixman_region_fini +#define pixman_region_translate _moz_pixman_region_translate +#define pixman_region_copy _moz_pixman_region_copy +#define pixman_region_intersect _moz_pixman_region_intersect +#define pixman_region_union _moz_pixman_region_union +#define pixman_region_union_rect _moz_pixman_region_union_rect +#define pixman_region_subtract _moz_pixman_region_subtract +#define pixman_region_inverse _moz_pixman_region_inverse +#define pixman_region_contains_point _moz_pixman_region_contains_point +#define pixman_region_contains_rectangle _moz_pixman_region_contains_rectangle +#define pixman_region_not_empty _moz_pixman_region_not_empty +#define pixman_region_extents _moz_pixman_region_extents +#define pixman_region_n_rects _moz_pixman_region_n_rects +#define pixman_region_rectangles _moz_pixman_region_rectangles +#define pixman_region_equal _moz_pixman_region_equal +#define pixman_region_selfcheck _moz_pixman_region_selfcheck +#define pixman_region_reset _moz_pixman_region_reset +#define pixman_region32_init _moz_pixman_region32_init +#define pixman_region32_init_rect _moz_pixman_region32_init_rect +#define pixman_region32_init_rects _moz_pixman_region32_init_rects +#define pixman_region32_init_with_extents _moz_pixman_region32_init_with_extents +#define pixman_region32_init_from_image _moz_pixman_region32_init_from_image +#define pixman_region32_fini _moz_pixman_region32_fini +#define pixman_region32_translate _moz_pixman_region32_translate +#define pixman_region32_copy _moz_pixman_region32_copy +#define pixman_region32_intersect _moz_pixman_region32_intersect +#define pixman_region32_intersect_rect _moz_pixman_region32_intersect_rect +#define pixman_region32_union _moz_pixman_region32_union +#define pixman_region32_union_rect _moz_pixman_region32_union_rect +#define pixman_region32_subtract _moz_pixman_region32_subtract +#define pixman_region32_inverse _moz_pixman_region32_inverse +#define pixman_region32_contains_point _moz_pixman_region32_contains_point +#define pixman_region32_contains_rectangle _moz_pixman_region32_contains_rectangle +#define pixman_region32_not_empty _moz_pixman_region32_not_empty +#define pixman_region32_extents _moz_pixman_region32_extents +#define pixman_region32_n_rects _moz_pixman_region32_n_rects +#define pixman_region32_rectangles _moz_pixman_region32_rectangles +#define pixman_region32_equal _moz_pixman_region32_equal +#define pixman_region32_selfcheck _moz_pixman_region32_selfcheck +#define pixman_region32_reset _moz_pixman_region32_reset +#define pixman_region32_clear _moz_pixman_region32_clear +#define pixman_blt _moz_pixman_blt +#define pixman_fill _moz_pixman_fill +#define pixman_transform_point_3d _moz_pixman_transform_point_3d +#define pixman_version _moz_pixman_version +#define pixman_version_string _moz_pixman_version_string +#define pixman_format_supported_destination _moz_pixman_format_supported_destination +#define pixman_format_supported_source _moz_pixman_format_supported_source +#define pixman_image_create_solid_fill _moz_pixman_image_create_solid_fill +#define pixman_image_create_linear_gradient _moz_pixman_image_create_linear_gradient +#define pixman_image_create_radial_gradient _moz_pixman_image_create_radial_gradient +#define pixman_image_create_conical_gradient _moz_pixman_image_create_conical_gradient +#define pixman_image_create_bits _moz_pixman_image_create_bits +#define pixman_image_ref _moz_pixman_image_ref +#define pixman_image_unref _moz_pixman_image_unref +#define pixman_image_set_clip_region _moz_pixman_image_set_clip_region +#define pixman_image_set_clip_region32 _moz_pixman_image_set_clip_region32 +#define pixman_image_set_has_client_clip _moz_pixman_image_set_has_client_clip +#define pixman_image_set_transform _moz_pixman_image_set_transform +#define pixman_image_set_repeat _moz_pixman_image_set_repeat +#define pixman_image_set_filter _moz_pixman_image_set_filter +#define pixman_image_set_source_clipping _moz_pixman_image_set_source_clipping +#define pixman_image_set_alpha_map _moz_pixman_image_set_alpha_map +#define pixman_image_set_component_alpha _moz_pixman_image_set_component_alpha +#define pixman_image_set_accessors _moz_pixman_image_set_accessors +#define pixman_image_set_indexed _moz_pixman_image_set_indexed +#define pixman_image_get_data _moz_pixman_image_get_data +#define pixman_image_get_width _moz_pixman_image_get_width +#define pixman_image_get_height _moz_pixman_image_get_height +#define pixman_image_get_stride _moz_pixman_image_get_stride +#define pixman_image_get_depth _moz_pixman_image_get_depth +#define pixman_image_fill_rectangles _moz_pixman_image_fill_rectangles +#define pixman_compute_composite_region _moz_pixman_compute_composite_region +#define pixman_image_composite _moz_pixman_image_composite +#define pixman_sample_ceil_y _moz_pixman_sample_ceil_y +#define pixman_sample_floor_y _moz_pixman_sample_floor_y +#define pixman_edge_step _moz_pixman_edge_step +#define pixman_edge_init _moz_pixman_edge_init +#define pixman_line_fixed_edge_init _moz_pixman_line_fixed_edge_init +#define pixman_rasterize_edges _moz_pixman_rasterize_edges +#define pixman_add_traps _moz_pixman_add_traps +#define pixman_add_trapezoids _moz_pixman_add_trapezoids +#define pixman_rasterize_trapezoid _moz_pixman_rasterize_trapezoid +#define pixman_disable_out_of_bounds_workaround _moz_pixman_disable_out_of_bounds_workaround +#define pixman_f_transform_bounds _moz_pixman_f_transform_bounds +#define pixman_f_transform_from_pixman_transform _moz_pixman_f_transform_from_pixman_transform +#define pixman_f_transform_init_identity _moz_pixman_f_transform_init_identity +#define pixman_f_transform_init_rotate _moz_pixman_f_transform_init_rotate +#define pixman_f_transform_init_scale _moz_pixman_f_transform_init_scale +#define pixman_f_transform_init_translate _moz_pixman_f_transform_init_translate +#define pixman_f_transform_invert _moz_pixman_f_transform_invert +#define pixman_f_transform_multiply _moz_pixman_f_transform_multiply +#define pixman_f_transform_point _moz_pixman_f_transform_point +#define pixman_f_transform_point_3d _moz_pixman_f_transform_point_3d +#define pixman_f_transform_rotate _moz_pixman_f_transform_rotate +#define pixman_f_transform_scale _moz_pixman_f_transform_scale +#define pixman_f_transform_translate _moz_pixman_f_transform_translate +#define pixman_image_composite32 _moz_pixman_image_composite32 +#define pixman_image_fill_boxes _moz_pixman_image_fill_boxes +#define pixman_image_get_component_alpha _moz_pixman_image_get_component_alpha +#define pixman_image_get_destroy_data _moz_pixman_image_get_destroy_data +#define pixman_image_get_format _moz_pixman_image_get_format +#define pixman_image_set_destroy_function _moz_pixman_image_set_destroy_function +#define pixman_region_init_from_image _moz_pixman_region_init_from_image +#define pixman_region_intersect_rect _moz_pixman_region_intersect_rect +#define pixman_transform_bounds _moz_pixman_transform_bounds +#define pixman_transform_from_pixman_f_transform _moz_pixman_transform_from_pixman_f_transform +#define pixman_transform_init_identity _moz_pixman_transform_init_identity +#define pixman_transform_init_rotate _moz_pixman_transform_init_rotate +#define pixman_transform_init_scale _moz_pixman_transform_init_scale +#define pixman_transform_init_translate _moz_pixman_transform_init_translate +#define pixman_transform_invert _moz_pixman_transform_invert +#define pixman_transform_is_identity _moz_pixman_transform_is_identity +#define pixman_transform_is_int_translate _moz_pixman_transform_is_int_translate +#define pixman_transform_is_inverse _moz_pixman_transform_is_inverse +#define pixman_transform_is_scale _moz_pixman_transform_is_scale +#define pixman_transform_multiply _moz_pixman_transform_multiply +#define pixman_transform_point _moz_pixman_transform_point +#define pixman_transform_rotate _moz_pixman_transform_rotate +#define pixman_transform_scale _moz_pixman_transform_scale +#define pixman_transform_translate _moz_pixman_transform_translate +#endif diff --git a/gfx/cairo/libpixman/src/pixman-compiler.h b/gfx/cairo/libpixman/src/pixman-compiler.h index 31e359fbcd2b..fb674c5f0855 100644 --- a/gfx/cairo/libpixman/src/pixman-compiler.h +++ b/gfx/cairo/libpixman/src/pixman-compiler.h @@ -85,7 +85,19 @@ /* In libxul builds we don't ever want to export pixman symbols */ #if 1 -# define PIXMAN_EXPORT cairo_public +#include "prcpucfg.h" + +#ifdef HAVE_VISIBILITY_HIDDEN_ATTRIBUTE +#define CVISIBILITY_HIDDEN __attribute__((visibility("hidden"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550) +#define CVISIBILITY_HIDDEN __hidden +#else +#define CVISIBILITY_HIDDEN +#endif + +/* In libxul builds we don't ever want to export cairo symbols */ +#define PIXMAN_EXPORT extern CVISIBILITY_HIDDEN + #else /* GCC visibility */ diff --git a/gfx/cairo/libpixman/src/pixman.h b/gfx/cairo/libpixman/src/pixman.h index ceec9684da85..1cbf62e21f39 100644 --- a/gfx/cairo/libpixman/src/pixman.h +++ b/gfx/cairo/libpixman/src/pixman.h @@ -69,7 +69,10 @@ SOFTWARE. #ifndef PIXMAN_H__ #define PIXMAN_H__ -#include "cairo-platform.h" +#ifdef MOZILLA_VERSION +#include "cairo/pixman-rename.h" +#endif + #include diff --git a/gfx/src/nsRegion.cpp b/gfx/src/nsRegion.cpp index c984de9e9088..648e39dd52ed 100644 --- a/gfx/src/nsRegion.cpp +++ b/gfx/src/nsRegion.cpp @@ -2,1011 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + #include "nsRegion.h" -#include // for max, min -#include "mozilla/Assertions.h" // for MOZ_ASSERT_HELPER2, etc -#include "mozilla/ThreadLocal.h" // for ThreadLocal -#include "mozilla/mozalloc.h" // for operator delete, etc -#include "nsDebug.h" // for NS_ASSERTION, NS_ERROR -#include "nsISupports.h" // for NS_ASSERT_OWNINGTHREAD, etc -#include "nsPrintfCString.h" // for nsPrintfCString -#include "nsTArray.h" // for nsTArray, nsTArray_Impl, etc +#include "nsPrintfCString.h" +#include "nsTArray.h" -/* - * The SENTINEL values below guaranties that a < or > - * comparison with it will be false for all values of the - * underlying nscoord type. E.g. this is always false: - * aCoord > NS_COORD_GREATER_SENTINEL - * Setting the mRectListHead dummy rectangle to these values - * allows us to loop without checking for the list end. - */ -#ifdef NS_COORD_IS_FLOAT -#define NS_COORD_LESS_SENTINEL nscoord_MIN -#define NS_COORD_GREATER_SENTINEL nscoord_MAX -#else -#define NS_COORD_LESS_SENTINEL INT32_MIN -#define NS_COORD_GREATER_SENTINEL INT32_MAX -#endif -// Fast inline analogues of nsRect methods for nsRegion::nsRectFast. -// Check for emptiness is not required - it is guaranteed by caller. - -inline bool nsRegion::nsRectFast::Contains (const nsRect& aRect) const -{ - return (bool) ((aRect.x >= x) && (aRect.y >= y) && - (aRect.XMost () <= XMost ()) && (aRect.YMost () <= YMost ())); -} - -inline bool nsRegion::nsRectFast::Intersects (const nsRect& aRect) const -{ - return (bool) ((x < aRect.XMost ()) && (y < aRect.YMost ()) && - (aRect.x < XMost ()) && (aRect.y < YMost ())); -} - -inline bool nsRegion::nsRectFast::IntersectRect (const nsRect& aRect1, const nsRect& aRect2) -{ - const nscoord xmost = std::min (aRect1.XMost (), aRect2.XMost ()); - x = std::max (aRect1.x, aRect2.x); - width = xmost - x; - if (width <= 0) return false; - - const nscoord ymost = std::min (aRect1.YMost (), aRect2.YMost ()); - y = std::max (aRect1.y, aRect2.y); - height = ymost - y; - if (height <= 0) return false; - - return true; -} - -inline void nsRegion::nsRectFast::UnionRect (const nsRect& aRect1, const nsRect& aRect2) -{ - const nscoord xmost = std::max (aRect1.XMost (), aRect2.XMost ()); - const nscoord ymost = std::max (aRect1.YMost (), aRect2.YMost ()); - x = std::min(aRect1.x, aRect2.x); - y = std::min(aRect1.y, aRect2.y); - width = xmost - x; - height = ymost - y; -} - - - -// Custom memory allocator for nsRegion::RgnRect structures. -// Entries are allocated from global memory pool. -// Memory pool can grow in size, but it can't shrink. - -#define INIT_MEM_CHUNK_ENTRIES 100 -#define INCR_MEM_CHUNK_ENTRIES 100 - -class RgnRectMemoryAllocator -{ - nsRegion::RgnRect* mFreeListHead; - uint32_t mFreeEntries; - void* mChunkListHead; -#if defined (DEBUG) - NS_DECL_OWNINGTHREAD - - void InitLock () { NS_ASSERT_OWNINGTHREAD (RgnRectMemoryAllocator); } - void DestroyLock () { NS_ASSERT_OWNINGTHREAD (RgnRectMemoryAllocator); } - void Lock () { NS_ASSERT_OWNINGTHREAD (RgnRectMemoryAllocator); } - void Unlock () { NS_ASSERT_OWNINGTHREAD (RgnRectMemoryAllocator); } -#else - void InitLock () { } - void DestroyLock () { } - void Lock () { } - void Unlock () { } -#endif - - void* AllocChunk (uint32_t aEntries, void* aNextChunk, nsRegion::RgnRect* aTailDest) - { - uint8_t* pBuf = new uint8_t [aEntries * sizeof (nsRegion::RgnRect) + sizeof (void*)]; - *reinterpret_cast(pBuf) = aNextChunk; - nsRegion::RgnRect* pRect = reinterpret_cast(pBuf + sizeof (void*)); - - for (uint32_t cnt = 0 ; cnt < aEntries - 1 ; cnt++) - pRect [cnt].next = &pRect [cnt + 1]; - - pRect [aEntries - 1].next = aTailDest; - - return pBuf; - } - - void FreeChunk (void* aChunk) { delete [] (uint8_t *) aChunk; } - void* NextChunk (void* aThisChunk) const { return *static_cast(aThisChunk); } - - nsRegion::RgnRect* ChunkHead (void* aThisChunk) const - { return reinterpret_cast(static_cast(aThisChunk) + sizeof (void*)); } - -public: - RgnRectMemoryAllocator (uint32_t aNumOfEntries); - ~RgnRectMemoryAllocator (); - - nsRegion::RgnRect* Alloc (); - void Free (nsRegion::RgnRect* aRect); -}; - - -RgnRectMemoryAllocator::RgnRectMemoryAllocator (uint32_t aNumOfEntries) -{ - InitLock (); - mChunkListHead = AllocChunk (aNumOfEntries, nullptr, nullptr); - mFreeEntries = aNumOfEntries; - mFreeListHead = ChunkHead (mChunkListHead); -} - -RgnRectMemoryAllocator::~RgnRectMemoryAllocator () -{ - while (mChunkListHead) - { - void* tmp = mChunkListHead; - mChunkListHead = NextChunk (mChunkListHead); - FreeChunk (tmp); - } - -#if 0 - /* - * As a static object this class outlives any library which would implement - * locking. So we intentionally leak the 'lock'. - * - * Currently RgnRectMemoryAllocator is only used from the primary thread, - * so we aren't using a lock which means that there is no lock to leak. - * If we ever switch to multiple GUI threads (e.g. one per window), - * we'd probably use one allocator per window-thread to avoid the - * locking overhead and just require consumers not to pass regions - * across threads/windows, which would be a reasonable restriction - * because they wouldn't be useful outside their window. - */ - DestroyLock (); -#endif -} - -nsRegion::RgnRect* RgnRectMemoryAllocator::Alloc () -{ - Lock (); - - if (mFreeEntries == 0) - { - mChunkListHead = AllocChunk (INCR_MEM_CHUNK_ENTRIES, mChunkListHead, mFreeListHead); - mFreeEntries = INCR_MEM_CHUNK_ENTRIES; - mFreeListHead = ChunkHead (mChunkListHead); - } - - nsRegion::RgnRect* tmp = mFreeListHead; - mFreeListHead = mFreeListHead->next; - mFreeEntries--; - Unlock (); - - return tmp; -} - -void RgnRectMemoryAllocator::Free (nsRegion::RgnRect* aRect) -{ - Lock (); - mFreeEntries++; - aRect->next = mFreeListHead; - mFreeListHead = aRect; - Unlock (); -} - - -// Global pool for nsRegion::RgnRect allocation -mozilla::ThreadLocal gRectPoolTlsIndex; - -void RgnRectMemoryAllocatorDTOR(void *priv) -{ - RgnRectMemoryAllocator* allocator = gRectPoolTlsIndex.get(); - delete allocator; -} - -nsresult nsRegion::InitStatic() -{ - if (gRectPoolTlsIndex.initialized()) { - // It's ok to call InitStatic if we called ShutdownStatic first - MOZ_ASSERT(gRectPoolTlsIndex.get() == nullptr); - return NS_OK; - } - - return gRectPoolTlsIndex.init() ? NS_OK : NS_ERROR_FAILURE; -} - -void nsRegion::ShutdownStatic() -{ - RgnRectMemoryAllocator* allocator = gRectPoolTlsIndex.get(); - if (!allocator) - return; - - delete allocator; - - gRectPoolTlsIndex.set(nullptr); -} - -void* nsRegion::RgnRect::operator new (size_t) CPP_THROW_NEW -{ - RgnRectMemoryAllocator* allocator = gRectPoolTlsIndex.get(); - if (!allocator) { - allocator = new RgnRectMemoryAllocator(INIT_MEM_CHUNK_ENTRIES); - gRectPoolTlsIndex.set(allocator); - } - return allocator->Alloc (); -} - -void nsRegion::RgnRect::operator delete (void* aRect, size_t) -{ - RgnRectMemoryAllocator* allocator = gRectPoolTlsIndex.get(); - if (!allocator) { - NS_ERROR("Invalid nsRegion::RgnRect delete"); - return; - } - allocator->Free (static_cast(aRect)); -} - - - -void nsRegion::Init() -{ - mRectListHead.prev = mRectListHead.next = &mRectListHead; - mCurRect = &mRectListHead; - mRectCount = 0; - mBoundRect.SetRect (0, 0, 0, 0); -} - -inline void nsRegion::InsertBefore (RgnRect* aNewRect, RgnRect* aRelativeRect) -{ - aNewRect->prev = aRelativeRect->prev; - aNewRect->next = aRelativeRect; - aRelativeRect->prev->next = aNewRect; - aRelativeRect->prev = aNewRect; - mCurRect = aNewRect; - mRectCount++; -} - -inline void nsRegion::InsertAfter (RgnRect* aNewRect, RgnRect* aRelativeRect) -{ - aNewRect->prev = aRelativeRect; - aNewRect->next = aRelativeRect->next; - aRelativeRect->next->prev = aNewRect; - aRelativeRect->next = aNewRect; - mCurRect = aNewRect; - mRectCount++; -} - - -// Adjust the number of rectangles in region. -// Content of rectangles should be changed by caller. - -void nsRegion::SetToElements (uint32_t aCount) -{ - if (mRectCount < aCount) // Add missing rectangles - { - uint32_t InsertCount = aCount - mRectCount; - mRectCount = aCount; - RgnRect* pPrev = &mRectListHead; - RgnRect* pNext = mRectListHead.next; - - while (InsertCount--) - { - mCurRect = new RgnRect; - mCurRect->prev = pPrev; - pPrev->next = mCurRect; - pPrev = mCurRect; - } - - pPrev->next = pNext; - pNext->prev = pPrev; - } else - if (mRectCount > aCount) // Remove unnecessary rectangles - { - uint32_t RemoveCount = mRectCount - aCount; - mRectCount = aCount; - mCurRect = mRectListHead.next; - - while (RemoveCount--) - { - RgnRect* tmp = mCurRect; - mCurRect = mCurRect->next; - delete tmp; - } - - mRectListHead.next = mCurRect; - mCurRect->prev = &mRectListHead; - } -} - - -// Save the entire chain of linked elements in 'prev' field of the RgnRect structure. -// After that forward-only iterations using 'next' field could still be used. -// Some elements from forward-only chain could be temporarily removed to optimize inner loops. -// The original double linked state could be restored by call to RestoreLinkChain (). -// Both functions despite size can be inline because they are called only from one function. - -inline void nsRegion::SaveLinkChain () -{ - RgnRect* pRect = &mRectListHead; - - do - { - pRect->prev = pRect->next; - pRect = pRect->next; - } while (pRect != &mRectListHead); -} - - -inline void nsRegion::RestoreLinkChain () -{ - RgnRect* pPrev = &mRectListHead; - RgnRect* pRect = mRectListHead.next = mRectListHead.prev; - - while (pRect != &mRectListHead) - { - pRect->next = pRect->prev; - pRect->prev = pPrev; - pPrev = pRect; - pRect = pRect->next; - } - - mRectListHead.prev = pPrev; -} - - -// Insert node in right place of sorted list -// If necessary then bounding rectangle could be updated and rectangle combined -// with neighbour rectangles. This is usually done in Optimize () - -void nsRegion::InsertInPlace (RgnRect* aRect, bool aOptimizeOnFly) -{ - if (mRectCount == 0) - InsertAfter (aRect, &mRectListHead); - else - { - if (aRect->y > mCurRect->y) - { - mRectListHead.y = NS_COORD_GREATER_SENTINEL; - while (aRect->y > mCurRect->next->y) - mCurRect = mCurRect->next; - - mRectListHead.x = NS_COORD_GREATER_SENTINEL; - while (aRect->y == mCurRect->next->y && aRect->x > mCurRect->next->x) - mCurRect = mCurRect->next; - - InsertAfter (aRect, mCurRect); - } else - if (aRect->y < mCurRect->y) - { - mRectListHead.y = NS_COORD_LESS_SENTINEL; - while (aRect->y < mCurRect->prev->y) - mCurRect = mCurRect->prev; - - mRectListHead.x = NS_COORD_LESS_SENTINEL; - while (aRect->y == mCurRect->prev->y && aRect->x < mCurRect->prev->x) - mCurRect = mCurRect->prev; - - InsertBefore (aRect, mCurRect); - } else - { - if (aRect->x > mCurRect->x) - { - mRectListHead.x = NS_COORD_GREATER_SENTINEL; - while (aRect->y == mCurRect->next->y && aRect->x > mCurRect->next->x) - mCurRect = mCurRect->next; - - InsertAfter (aRect, mCurRect); - } else - { - mRectListHead.x = NS_COORD_LESS_SENTINEL; - while (aRect->y == mCurRect->prev->y && aRect->x < mCurRect->prev->x) - mCurRect = mCurRect->prev; - - InsertBefore (aRect, mCurRect); - } - } - } - - - if (aOptimizeOnFly) - { - if (mRectCount == 1) - mBoundRect = *mCurRect; - else - { - mBoundRect.UnionRect (mBoundRect, *mCurRect); - - // Check if we can go left or up before starting to combine rectangles - if ((mCurRect->y == mCurRect->prev->y && mCurRect->height == mCurRect->prev->height && - mCurRect->x == mCurRect->prev->XMost ()) || - (mCurRect->x == mCurRect->prev->x && mCurRect->width == mCurRect->prev->width && - mCurRect->y == mCurRect->prev->YMost ()) ) - mCurRect = mCurRect->prev; - - // Try to combine with rectangle on right side - while (mCurRect->y == mCurRect->next->y && mCurRect->height == mCurRect->next->height && - mCurRect->XMost () == mCurRect->next->x) - { - mCurRect->width += mCurRect->next->width; - delete Remove (mCurRect->next); - } - - // Try to combine with rectangle under this one - while (mCurRect->x == mCurRect->next->x && mCurRect->width == mCurRect->next->width && - mCurRect->YMost () == mCurRect->next->y) - { - mCurRect->height += mCurRect->next->height; - delete Remove (mCurRect->next); - } - } - } -} - - -nsRegion::RgnRect* nsRegion::Remove (RgnRect* aRect) -{ - aRect->prev->next = aRect->next; - aRect->next->prev = aRect->prev; - mRectCount--; - - if (mCurRect == aRect) - mCurRect = (aRect->next != &mRectListHead) ? aRect->next : aRect->prev; - - return aRect; -} - - -// Try to reduce the number of rectangles in complex region by combining with -// surrounding ones on right and bottom sides of each rectangle in list. -// Update bounding rectangle - -void nsRegion::Optimize () -{ - if (mRectCount == 0) - mBoundRect.SetRect (0, 0, 0, 0); - else - { - RgnRect* pRect = mRectListHead.next; - int32_t xmost = mRectListHead.prev->XMost (); - int32_t ymost = mRectListHead.prev->YMost (); - mBoundRect.x = mRectListHead.next->x; - mBoundRect.y = mRectListHead.next->y; - - while (pRect != &mRectListHead) - { - // Try to combine with rectangle on right side - while (pRect->y == pRect->next->y && pRect->height == pRect->next->height && - pRect->XMost () == pRect->next->x) - { - pRect->width += pRect->next->width; - delete Remove (pRect->next); - } - - // Try to combine with rectangle under this one - while (pRect->x == pRect->next->x && pRect->width == pRect->next->width && - pRect->YMost () == pRect->next->y) - { - pRect->height += pRect->next->height; - delete Remove (pRect->next); - } - - // Determine bound rectangle. Use fact that rectangles are sorted. - if (pRect->x < mBoundRect.x) mBoundRect.x = pRect->x; - if (pRect->XMost () > xmost) xmost = pRect->XMost (); - if (pRect->YMost () > ymost) ymost = pRect->YMost (); - - pRect = pRect->next; - } - - mBoundRect.width = xmost - mBoundRect.x; - mBoundRect.height = ymost - mBoundRect.y; - } -} - - -// Move rectangles starting from 'aStartRect' till end of the list to the destionation region. -// Important for temporary objects - instead of copying rectangles with Merge () and then -// emptying region in destructor they could be moved to destination region in one step. - -void nsRegion::MoveInto (nsRegion& aDestRegion, const RgnRect* aStartRect) -{ - RgnRect* pRect = const_cast(aStartRect); - RgnRect* pPrev = pRect->prev; - - while (pRect != &mRectListHead) - { - RgnRect* next = pRect->next; - aDestRegion.InsertInPlace (pRect); - - mRectCount--; - pRect = next; - } - - pPrev->next = &mRectListHead; - mRectListHead.prev = pPrev; - mCurRect = mRectListHead.next; -} - - -// Merge two non-overlapping regions into one. -// Automatically optimize region by calling Optimize () - -void nsRegion::Merge (const nsRegion& aRgn1, const nsRegion& aRgn2) -{ - if (aRgn1.mRectCount == 0) // Region empty. Result is equal to other region - Copy (aRgn2); - else - if (aRgn2.mRectCount == 0) // Region empty. Result is equal to other region - Copy (aRgn1); - if (aRgn1.mRectCount == 1) // Region is single rectangle. Optimize on fly - { - RgnRect* TmpRect = new RgnRect (*aRgn1.mRectListHead.next); - Copy (aRgn2); - InsertInPlace (TmpRect, true); - } else - if (aRgn2.mRectCount == 1) // Region is single rectangle. Optimize on fly - { - RgnRect* TmpRect = new RgnRect (*aRgn2.mRectListHead.next); - Copy (aRgn1); - InsertInPlace (TmpRect, true); - } else - { - const nsRegion* pCopyRegion, *pInsertRegion; - - // Determine which region contains more rectangles. Copy the larger one - if (aRgn1.mRectCount >= aRgn2.mRectCount) - { - pCopyRegion = &aRgn1; - pInsertRegion = &aRgn2; - } else - { - pCopyRegion = &aRgn2; - pInsertRegion = &aRgn1; - } - - if (pInsertRegion == this) // Do merge in-place - pInsertRegion = pCopyRegion; - else - Copy (*pCopyRegion); - - const RgnRect* pSrcRect = pInsertRegion->mRectListHead.next; - - while (pSrcRect != &pInsertRegion->mRectListHead) - { - InsertInPlace (new RgnRect (*pSrcRect)); - - pSrcRect = pSrcRect->next; - } - - Optimize (); - } -} - - -nsRegion& nsRegion::Copy (const nsRegion& aRegion) -{ - if (&aRegion == this) - return *this; - - if (aRegion.mRectCount == 0) - SetEmpty (); - else - { - SetToElements (aRegion.mRectCount); - - const RgnRect* pSrc = aRegion.mRectListHead.next; - RgnRect* pDest = mRectListHead.next; - - while (pSrc != &aRegion.mRectListHead) - { - *pDest = *pSrc; - - pSrc = pSrc->next; - pDest = pDest->next; - } - - mCurRect = mRectListHead.next; - mBoundRect = aRegion.mBoundRect; - } - - return *this; -} - - -nsRegion& nsRegion::Copy (const nsRect& aRect) -{ - if (aRect.IsEmpty ()) - SetEmpty (); - else - { - SetToElements (1); - *mRectListHead.next = static_cast(aRect); - mBoundRect = static_cast(aRect); - } - - return *this; -} - - -nsRegion& nsRegion::And (const nsRegion& aRgn1, const nsRegion& aRgn2) -{ - if (&aRgn1 == &aRgn2) // And with self - Copy (aRgn1); - else - if (aRgn1.mRectCount == 0 || aRgn2.mRectCount == 0) // If either region is empty then result is empty - SetEmpty (); - else - { - nsRectFast TmpRect; - - if (aRgn1.mRectCount == 1 && aRgn2.mRectCount == 1) // Intersect rectangle with rectangle - { - TmpRect.IntersectRect (*aRgn1.mRectListHead.next, *aRgn2.mRectListHead.next); - Copy (TmpRect); - } else - { - if (!aRgn1.mBoundRect.Intersects (aRgn2.mBoundRect)) // Regions do not intersect - SetEmpty (); - else - { - // Region is simple rectangle and it fully overlays other region - if (aRgn1.mRectCount == 1 && aRgn1.mBoundRect.Contains (aRgn2.mBoundRect)) - Copy (aRgn2); - else - // Region is simple rectangle and it fully overlays other region - if (aRgn2.mRectCount == 1 && aRgn2.mBoundRect.Contains (aRgn1.mBoundRect)) - Copy (aRgn1); - else - { - nsRegion TmpRegion; - nsRegion* pSrcRgn1 = const_cast(&aRgn1); - nsRegion* pSrcRgn2 = const_cast(&aRgn2); - - if (&aRgn1 == this) // Copy region if it is both source and result - { - TmpRegion.Copy (aRgn1); - pSrcRgn1 = &TmpRegion; - } - - if (&aRgn2 == this) // Copy region if it is both source and result - { - TmpRegion.Copy (aRgn2); - pSrcRgn2 = &TmpRegion; - } - - // For outer loop prefer region for which at least one rectangle is below other's bound rectangle - if (pSrcRgn2->mRectListHead.prev->y >= pSrcRgn1->mBoundRect.YMost ()) - { - nsRegion* Tmp = pSrcRgn1; - pSrcRgn1 = pSrcRgn2; - pSrcRgn2 = Tmp; - } - - - SetToElements (0); - pSrcRgn2->SaveLinkChain (); - - pSrcRgn1->mRectListHead.y = NS_COORD_GREATER_SENTINEL; - pSrcRgn2->mRectListHead.y = NS_COORD_GREATER_SENTINEL; - - for (RgnRect* pSrcRect1 = pSrcRgn1->mRectListHead.next ; - pSrcRect1->y < pSrcRgn2->mBoundRect.YMost () ; pSrcRect1 = pSrcRect1->next) - { - if (pSrcRect1->Intersects (pSrcRgn2->mBoundRect)) // Rectangle intersects region. Process each rectangle - { - RgnRect* pPrev2 = &pSrcRgn2->mRectListHead; - - for (RgnRect* pSrcRect2 = pSrcRgn2->mRectListHead.next ; - pSrcRect2->y < pSrcRect1->YMost () ; pSrcRect2 = pSrcRect2->next) - { - if (pSrcRect2->YMost () <= pSrcRect1->y) // Rect2's bottom is above the top of Rect1. - { // No successive rectangles in Rgn1 can intersect it. - pPrev2->next = pSrcRect2->next; // Remove Rect2 from Rgn2's checklist - continue; - } - - if (pSrcRect1->Contains (*pSrcRect2)) // Rect1 fully overlays Rect2. - { // No any other rectangle in Rgn1 can intersect it. - pPrev2->next = pSrcRect2->next; // Remove Rect2 from Rgn2's checklist - InsertInPlace (new RgnRect (*pSrcRect2)); - continue; - } - - - if (TmpRect.IntersectRect (*pSrcRect1, *pSrcRect2)) - InsertInPlace (new RgnRect (TmpRect)); - - pPrev2 = pSrcRect2; - } - } - } - - pSrcRgn2->RestoreLinkChain (); - Optimize (); - } - } - } - } - - return *this; -} - - -nsRegion& nsRegion::And (const nsRegion& aRegion, const nsRect& aRect) -{ - // If either region or rectangle is empty then result is empty - if (aRegion.mRectCount == 0 || aRect.IsEmpty ()) - SetEmpty (); - else // Intersect region with rectangle - { - const nsRectFast& aRectFast = static_cast(aRect); - nsRectFast TmpRect; - - if (aRegion.mRectCount == 1) // Intersect rectangle with rectangle - { - TmpRect.IntersectRect (*aRegion.mRectListHead.next, aRectFast); - Copy (TmpRect); - } else // Intersect complex region with rectangle - { - if (!aRectFast.Intersects (aRegion.mBoundRect)) // Rectangle does not intersect region - SetEmpty (); - else - { - if (aRectFast.Contains (aRegion.mBoundRect)) // Rectangle fully overlays region - Copy (aRegion); - else - { - nsRegion TmpRegion; - nsRegion* pSrcRegion = const_cast(&aRegion); - - if (&aRegion == this) // Copy region if it is both source and result - { - TmpRegion.Copy (aRegion); - pSrcRegion = &TmpRegion; - } - - SetToElements (0); - pSrcRegion->mRectListHead.y = NS_COORD_GREATER_SENTINEL; - - for (const RgnRect* pSrcRect = pSrcRegion->mRectListHead.next ; - pSrcRect->y < aRectFast.YMost () ; pSrcRect = pSrcRect->next) - { - if (TmpRect.IntersectRect (*pSrcRect, aRectFast)) - InsertInPlace (new RgnRect (TmpRect)); - } - - Optimize (); - } - } - } - } - - return *this; -} - - -nsRegion& nsRegion::Or (const nsRegion& aRgn1, const nsRegion& aRgn2) -{ - if (&aRgn1 == &aRgn2) // Or with self - Copy (aRgn1); - else - if (aRgn1.mRectCount == 0) // Region empty. Result is equal to other region - Copy (aRgn2); - else - if (aRgn2.mRectCount == 0) // Region empty. Result is equal to other region - Copy (aRgn1); - else - { - if (!aRgn1.mBoundRect.Intersects (aRgn2.mBoundRect)) // Regions do not intersect - Merge (aRgn1, aRgn2); - else - { - // Region is simple rectangle and it fully overlays other region - if (aRgn1.mRectCount == 1 && aRgn1.mBoundRect.Contains (aRgn2.mBoundRect)) - Copy (aRgn1); - else - // Region is simple rectangle and it fully overlays other region - if (aRgn2.mRectCount == 1 && aRgn2.mBoundRect.Contains (aRgn1.mBoundRect)) - Copy (aRgn2); - else - { - nsRegion TmpRegion; - aRgn1.SubRegion (aRgn2, TmpRegion); // Get only parts of region which not overlap the other region - Copy (aRgn2); - TmpRegion.MoveInto (*this); - Optimize (); - } - } - } - - return *this; -} - - -nsRegion& nsRegion::Or (const nsRegion& aRegion, const nsRect& aRect) -{ - if (aRegion.mRectCount == 0) // Region empty. Result is equal to rectangle - Copy (aRect); - else - if (aRect.IsEmpty ()) // Rectangle is empty. Result is equal to region - Copy (aRegion); - else - { - const nsRectFast& aRectFast = static_cast(aRect); - - if (!aRectFast.Intersects (aRegion.mBoundRect)) // Rectangle does not intersect region - { - Copy (aRegion); - InsertInPlace (new RgnRect (aRectFast), true); - } else - { - // Region is simple rectangle and it fully overlays rectangle - if (aRegion.mRectCount == 1 && aRegion.mBoundRect.Contains (aRectFast)) - Copy (aRegion); - else - if (aRectFast.Contains (aRegion.mBoundRect)) // Rectangle fully overlays region - Copy (aRectFast); - else - { - aRegion.SubRect (aRectFast, *this); // Exclude from region parts that overlap the rectangle - InsertInPlace (new RgnRect (aRectFast)); - Optimize (); - } - } - } - - return *this; -} - - -nsRegion& nsRegion::Xor (const nsRegion& aRgn1, const nsRegion& aRgn2) -{ - if (&aRgn1 == &aRgn2) // Xor with self - SetEmpty (); - else - if (aRgn1.mRectCount == 0) // Region empty. Result is equal to other region - Copy (aRgn2); - else - if (aRgn2.mRectCount == 0) // Region empty. Result is equal to other region - Copy (aRgn1); - else - { - if (!aRgn1.mBoundRect.Intersects (aRgn2.mBoundRect)) // Regions do not intersect - Merge (aRgn1, aRgn2); - else - { - // Region is simple rectangle and it fully overlays other region - if (aRgn1.mRectCount == 1 && aRgn1.mBoundRect.Contains (aRgn2.mBoundRect)) - { - aRgn1.SubRegion (aRgn2, *this); - Optimize (); - } else - // Region is simple rectangle and it fully overlays other region - if (aRgn2.mRectCount == 1 && aRgn2.mBoundRect.Contains (aRgn1.mBoundRect)) - { - aRgn2.SubRegion (aRgn1, *this); - Optimize (); - } else - { - nsRegion TmpRegion; - aRgn1.SubRegion (aRgn2, TmpRegion); - aRgn2.SubRegion (aRgn1, *this); - TmpRegion.MoveInto (*this); - Optimize (); - } - } - } - - return *this; -} - - -nsRegion& nsRegion::Xor (const nsRegion& aRegion, const nsRect& aRect) -{ - if (aRegion.mRectCount == 0) // Region empty. Result is equal to rectangle - Copy (aRect); - else - if (aRect.IsEmpty ()) // Rectangle is empty. Result is equal to region - Copy (aRegion); - else - { - const nsRectFast& aRectFast = static_cast(aRect); - - if (!aRectFast.Intersects (aRegion.mBoundRect)) // Rectangle does not intersect region - { - Copy (aRegion); - InsertInPlace (new RgnRect (aRectFast), true); - } else - { - // Region is simple rectangle and it fully overlays rectangle - if (aRegion.mRectCount == 1 && aRegion.mBoundRect.Contains (aRectFast)) - { - aRegion.SubRect (aRectFast, *this); - Optimize (); - } else - if (aRectFast.Contains (aRegion.mBoundRect)) // Rectangle fully overlays region - { - nsRegion TmpRegion; - TmpRegion.Copy (aRectFast); - TmpRegion.SubRegion (aRegion, *this); - Optimize (); - } else - { - nsRegion TmpRegion; - TmpRegion.Copy (aRectFast); - TmpRegion.SubRegion (aRegion, TmpRegion); - aRegion.SubRect (aRectFast, *this); - TmpRegion.MoveInto (*this); - Optimize (); - } - } - } - - return *this; -} - - -nsRegion& nsRegion::Sub (const nsRegion& aRgn1, const nsRegion& aRgn2) -{ - if (&aRgn1 == &aRgn2) // Sub from self - SetEmpty (); - else - if (aRgn1.mRectCount == 0) // If source is empty then result is empty, too - SetEmpty (); - else - if (aRgn2.mRectCount == 0) // Nothing to subtract - Copy (aRgn1); - else - { - if (!aRgn1.mBoundRect.Intersects (aRgn2.mBoundRect)) // Regions do not intersect - Copy (aRgn1); - else - { - aRgn1.SubRegion (aRgn2, *this); - Optimize (); - } - } - - return *this; -} - - -nsRegion& nsRegion::Sub (const nsRegion& aRegion, const nsRect& aRect) -{ - if (aRegion.mRectCount == 0) // If source is empty then result is empty, too - SetEmpty (); - else - if (aRect.IsEmpty ()) // Nothing to subtract - Copy (aRegion); - else - { - const nsRectFast& aRectFast = static_cast(aRect); - - if (!aRectFast.Intersects (aRegion.mBoundRect)) // Rectangle does not intersect region - Copy (aRegion); - else - { - if (aRectFast.Contains (aRegion.mBoundRect)) // Rectangle fully overlays region - SetEmpty (); - else - { - aRegion.SubRect (aRectFast, *this); - Optimize (); - } - } - } - - return *this; -} - -bool nsRegion::Contains (const nsRect& aRect) const -{ - if (aRect.IsEmpty()) - return true; - if (IsEmpty()) - return false; - if (!IsComplex()) - return mBoundRect.Contains (aRect); - - nsRegion tmpRgn; - tmpRgn.Sub(aRect, *this); - return tmpRgn.IsEmpty(); -} - -bool nsRegion::Contains (const nsRegion& aRgn) const +bool nsRegion::Contains(const nsRegion& aRgn) const { // XXX this could be made faster nsRegionRectIterator iter(aRgn); @@ -1018,266 +20,75 @@ bool nsRegion::Contains (const nsRegion& aRgn) const return true; } -bool nsRegion::Intersects (const nsRect& aRect) const +bool nsRegion::Intersects(const nsRect& aRect) const { - if (aRect.IsEmpty() || IsEmpty()) - return false; - - const RgnRect* r = mRectListHead.next; - while (r != &mRectListHead) - { - if (r->Intersects(aRect)) + // XXX this could be made faster + nsRegionRectIterator iter(*this); + while (const nsRect* r = iter.Next()) { + if (r->Intersects(aRect)) { return true; - r = r->next; + } } return false; } -// Subtract region from current region. -// Both regions are non-empty and they intersect each other. -// Result could be empty region if aRgn2 is rectangle that fully overlays aRgn1. -// Optimize () is not called on exit (bound rectangle is not updated). - -void nsRegion::SubRegion (const nsRegion& aRegion, nsRegion& aResult) const +void nsRegion::SimplifyOutward (uint32_t aMaxRects) { - if (aRegion.mRectCount == 1) // Subtract simple rectangle + MOZ_ASSERT(aMaxRects >= 1, "Invalid max rect count"); + + if (GetNumRects() <= aMaxRects) + return; + + pixman_box32_t *boxes; + int n; + boxes = pixman_region32_rectangles(&mImpl, &n); + + // Try combining rects in horizontal bands into a single rect + int dest = 0; + for (int src = 1; src < n; src++) { - if (aRegion.mBoundRect.Contains (mBoundRect)) - aResult.SetEmpty (); - else - SubRect (*aRegion.mRectListHead.next, aResult); - } else - { - nsRegion TmpRegion, CompletedRegion; - const nsRegion* pSubRgn = &aRegion; - - if (&aResult == &aRegion) // Copy region if it is both source and result - { - TmpRegion.Copy (aRegion); - pSubRgn = &TmpRegion; + // The goal here is to try to keep groups of rectangles that are vertically + // discontiguous as separate rectangles in the final region. This is + // simple and fast to implement and page contents tend to vary more + // vertically than horizontally (which is why our rectangles are stored + // sorted by y-coordinate, too). + // + // Note: if boxes share y1 because of the canonical representation they + // will share y2 + while ((src < (n)) && boxes[dest].y1 == boxes[src].y1) { + // merge box[i] and box[i+1] + boxes[dest].x2 = boxes[src].x2; + src++; } - - const RgnRect* pSubRect = pSubRgn->mRectListHead.next; - - SubRect (*pSubRect, aResult, CompletedRegion); - pSubRect = pSubRect->next; - - while (pSubRect != &pSubRgn->mRectListHead) - { - aResult.SubRect (*pSubRect, aResult, CompletedRegion); - pSubRect = pSubRect->next; + if (src < n) { + dest++; + boxes[dest] = boxes[src]; } + } - CompletedRegion.MoveInto (aResult); + uint32_t reducedCount = dest+1; + // pixman has a special representation for + // regions of 1 rectangle. So just use the + // bounds in that case + if (reducedCount > 1 && reducedCount <= aMaxRects) { + // reach into pixman and lower the number + // of rects stored in data. + mImpl.data->numRects = reducedCount; + } else { + *this = GetBounds(); } } - -// Subtract rectangle from current region. -// Both region and rectangle are non-empty and they intersect each other. -// Result could be empty region if aRect fully overlays aRegion. -// Could be called repeatedly with 'this' as input and result - bound rectangle is not known. -// Optimize () is not called on exit (bound rectangle is not updated). -// -// aCompleted is filled with rectangles which are already checked and could be safely -// removed from further examination in case aRect rectangles come from ordered list. -// aCompleted is not automatically emptied. aCompleted and aResult could be the same region. - -void nsRegion::SubRect (const nsRectFast& aRect, nsRegion& aResult, nsRegion& aCompleted) const +void nsRegion::SimplifyInward (uint32_t aMaxRects) { - nsRegion TmpRegion; - const nsRegion* pSrcRegion = this; + NS_ASSERTION(aMaxRects >= 1, "Invalid max rect count"); - if (&aResult == this) // Copy region if it is both source and result - { - TmpRegion.Copy (*this); - pSrcRegion = &TmpRegion; - } + if (GetNumRects() <= aMaxRects) + return; - aResult.SetToElements (0); - - const_cast(pSrcRegion)->mRectListHead.y = NS_COORD_GREATER_SENTINEL; - const RgnRect* pSrcRect = pSrcRegion->mRectListHead.next; - - for ( ; pSrcRect->y < aRect.YMost () ; pSrcRect = pSrcRect->next) - { - nsRectFast TmpRect; - - // If bottom of current rectangle is above the top of aRect then this rectangle - // could be moved to aCompleted region. Successive aRect rectangles from ordered - // list do not have to check this rectangle again. - if (pSrcRect->YMost () <= aRect.y) - { - aCompleted.InsertInPlace (new RgnRect (*pSrcRect)); - continue; - } - - if (!TmpRect.IntersectRect (*pSrcRect, aRect)) - aResult.InsertInPlace (new RgnRect (*pSrcRect)); - else - { - // Rectangle A. Subtract from this rectangle B - const nscoord ax = pSrcRect->x; - const nscoord axm = pSrcRect->XMost (); - const nscoord aw = pSrcRect->width; - const nscoord ay = pSrcRect->y; - const nscoord aym = pSrcRect->YMost (); - const nscoord ah = pSrcRect->height; - // Rectangle B. Subtract this from rectangle A - const nscoord bx = aRect.x; - const nscoord bxm = aRect.XMost (); - const nscoord by = aRect.y; - const nscoord bym = aRect.YMost (); - // Rectangle I. Area where rectangles A and B intersect - const nscoord ix = TmpRect.x; - const nscoord ixm = TmpRect.XMost (); - const nscoord iy = TmpRect.y; - const nscoord iym = TmpRect.YMost (); - const nscoord ih = TmpRect.height; - - // There are 16 combinations how rectangles could intersect - - if (bx <= ax && by <= ay) - { - if (bxm < axm && bym < aym) // 1. - { - aResult.InsertInPlace (new RgnRect (ixm, ay, axm - ixm, ih)); - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - } else - if (bxm >= axm && bym < aym) // 2. - { - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - } else - if (bxm < axm && bym >= aym) // 3. - { - aResult.InsertInPlace (new RgnRect (ixm, ay, axm - ixm, ah)); - } else - if (pSrcRect->IsEqualInterior(aRect)) // 4. subset - { // Current rectangle is equal to aRect - pSrcRect = pSrcRect->next; // don't add this one to the result, it's removed - break; // No any other rectangle in region can intersect it - } - } else - if (bx > ax && by <= ay) - { - if (bxm < axm && bym < aym) // 5. - { - aResult.InsertInPlace (new RgnRect (ax, ay, ix - ax, ih)); - aResult.InsertInPlace (new RgnRect (ixm, ay, axm - ixm, ih)); - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - } else - if (bxm >= axm && bym < aym) // 6. - { - aResult.InsertInPlace (new RgnRect (ax, ay, ix - ax, ih)); - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - } else - if (bxm < axm && bym >= aym) // 7. - { - aResult.InsertInPlace (new RgnRect (ax, ay, ix - ax, ah)); - aResult.InsertInPlace (new RgnRect (ixm, ay, axm - ixm, ah)); - } else - if (bxm >= axm && bym >= aym) // 8. - { - aResult.InsertInPlace (new RgnRect (ax, ay, ix - ax, ah)); - } - } else - if (bx <= ax && by > ay) - { - if (bxm < axm && bym < aym) // 9. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - aResult.InsertInPlace (new RgnRect (ixm, iy, axm - ixm, ih)); - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - } else - if (bxm >= axm && bym < aym) // 10. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - } else - if (bxm < axm && bym >= aym) // 11. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - aResult.InsertInPlace (new RgnRect (ixm, iy, axm - ixm, ih)); - } else - if (bxm >= axm && bym >= aym) // 12. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - } - } else - if (bx > ax && by > ay) - { - if (bxm < axm && bym < aym) // 13. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - aResult.InsertInPlace (new RgnRect (ax, iy, ix - ax, ih)); - aResult.InsertInPlace (new RgnRect (ixm, iy, axm - ixm, ih)); - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - - // Current rectangle fully overlays aRect. No any other rectangle can intersect it. - pSrcRect = pSrcRect->next; // don't add this one to the result, it's removed - break; - } else - if (bxm >= axm && bym < aym) // 14. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - aResult.InsertInPlace (new RgnRect (ax, iy, ix - ax, ih)); - aResult.InsertInPlace (new RgnRect (ax, iym, aw, aym - iym)); - } else - if (bxm < axm && bym >= aym) // 15. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - aResult.InsertInPlace (new RgnRect (ax, iy, ix - ax, ih)); - aResult.InsertInPlace (new RgnRect (ixm, iy, axm - ixm, ih)); - } else - if (bxm >= axm && bym >= aym) // 16. - { - aResult.InsertInPlace (new RgnRect (ax, ay, aw, iy - ay)); - aResult.InsertInPlace (new RgnRect (ax, iy, ix - ax, ih)); - } - } - } - } - - // Just copy remaining rectangles in region which are below aRect and can't intersect it. - // If rectangles are in temporary region then they could be moved. - if (pSrcRegion == &TmpRegion) - TmpRegion.MoveInto (aResult, pSrcRect); - else - { - while (pSrcRect != &pSrcRegion->mRectListHead) - { - aResult.InsertInPlace (new RgnRect (*pSrcRect)); - pSrcRect = pSrcRect->next; - } - } + SetEmpty(); } - -bool nsRegion::IsEqual (const nsRegion& aRegion) const -{ - if (mRectCount == 0) - return (aRegion.mRectCount == 0) ? true : false; - - if (aRegion.mRectCount == 0) - return (mRectCount == 0) ? true : false; - - if (mRectCount == 1 && aRegion.mRectCount == 1) // Both regions are simple rectangles - return (mRectListHead.next->IsEqualInterior(*aRegion.mRectListHead.next)); - else // At least one is complex region. - { - if (!mBoundRect.IsEqualInterior(aRegion.mBoundRect)) // If regions are equal then bounding rectangles should match - return false; - else - { - nsRegion TmpRegion; - TmpRegion.Xor (*this, aRegion); // Get difference between two regions - - return (TmpRegion.mRectCount == 0); - } - } -} - - uint64_t nsRegion::Area () const { uint64_t area = 0; @@ -1289,52 +100,41 @@ uint64_t nsRegion::Area () const return area; } - -void nsRegion::MoveBy (nsPoint aPt) -{ - if (aPt.x || aPt.y) - { - RgnRect* pRect = mRectListHead.next; - - while (pRect != &mRectListHead) - { - pRect->MoveBy (aPt.x, aPt.y); - pRect = pRect->next; - } - - mBoundRect.MoveBy (aPt.x, aPt.y); - } -} - nsRegion& nsRegion::ScaleRoundOut (float aXScale, float aYScale) { - nsRegion region; - nsRegionRectIterator iter(*this); - for (;;) { - const nsRect* r = iter.Next(); - if (!r) - break; - nsRect rect = *r; + int n; + pixman_box32_t *boxes = pixman_region32_rectangles(&mImpl, &n); + for (int i=0; iConvertAppUnitsRoundOut(aFromAPP, aToAPP); - region.Or(region, rect); + + nsRegion region = *this; + int n; + pixman_box32_t *boxes = pixman_region32_rectangles(®ion.mImpl, &n); + for (int i=0; iConvertAppUnitsRoundIn(aFromAPP, aToAPP); - region.Or(region, rect); + + nsRegion region = *this; + int n; + pixman_box32_t *boxes = pixman_region32_rectangles(®ion.mImpl, &n); + for (int i=0; iToOutsidePixels(aAppUnitsPerPixel); + deviceRect = rect.ToOutsidePixels(aAppUnitsPerPixel); else - deviceRect = currentRect->ToNearestPixels(aAppUnitsPerPixel); - result.Or(result, deviceRect); + deviceRect = rect.ToNearestPixels(aAppUnitsPerPixel); + + boxes[i] = RectToBox(deviceRect); } - return result; + + nsIntRegion intRegion; + pixman_region32_fini(&intRegion.mImpl.mImpl); + // This will union all of the rectangles and runs in about O(n lg(n)) + pixman_region32_init_rects(&intRegion.mImpl.mImpl, boxes, n); + + return intRegion; } nsIntRegion nsRegion::ToOutsidePixels (nscoord aAppUnitsPerPixel) const @@ -1446,49 +264,57 @@ nsIntRegion nsRegion::ScaleToInsidePixels (float aScaleX, float aScaleY, * for the first rect. */ - nsIntRegion result; - RgnRect* pRect = mRectListHead.next; - RgnRect* first = pRect; + // make a copy of this region so that we can mutate it in place + nsRegion region = *this; + int n; + pixman_box32_t *boxes = pixman_region32_rectangles(®ion.mImpl, &n); - nsIntRect firstDeviceRect; - if (pRect != &mRectListHead) { - firstDeviceRect = - pRect->ScaleToInsidePixels(aScaleX, aScaleY, aAppUnitsPerPixel); - pRect = pRect->next; - } + nsIntRegion intRegion; + if (n) { + nsRect first = BoxToRect(boxes[0]); + nsIntRect firstDeviceRect = + first.ScaleToInsidePixels(aScaleX, aScaleY, aAppUnitsPerPixel); - while (pRect != &mRectListHead) - { - nsIntRect deviceRect = - pRect->ScaleToInsidePixels(aScaleX, aScaleY, aAppUnitsPerPixel); + for (int i=1; iy <= first->YMost()) { - if (pRect->XMost() == first->x && pRect->YMost() <= first->YMost()) { - // pRect is touching on the left edge of the first rect and contained within - // the length of its left edge - deviceRect.SetRightEdge(firstDeviceRect.x); - } else if (pRect->x == first->XMost() && pRect->YMost() <= first->YMost()) { - // pRect is touching on the right edge of the first rect and contained within - // the length of its right edge - deviceRect.SetLeftEdge(firstDeviceRect.XMost()); - } else if (pRect->y == first->YMost()) { - // The bottom of the first rect is on the same line as the top of pRect, but - // they aren't necessarily contained. - if (pRect->x <= first->x && pRect->XMost() >= first->XMost()) { - // The top of pRect contains the bottom of the first rect - firstDeviceRect.SetBottomEdge(deviceRect.y); - } else if (pRect->x >= first->x && pRect->XMost() <= first->XMost()) { - // The bottom of the first contains the top of pRect - deviceRect.SetTopEdge(firstDeviceRect.YMost()); - } + if (rect.y <= first.YMost()) { + if (rect.XMost() == first.x && rect.YMost() <= first.YMost()) { + // rect is touching on the left edge of the first rect and contained within + // the length of its left edge + deviceRect.SetRightEdge(firstDeviceRect.x); + } else if (rect.x == first.XMost() && rect.YMost() <= first.YMost()) { + // rect is touching on the right edge of the first rect and contained within + // the length of its right edge + deviceRect.SetLeftEdge(firstDeviceRect.XMost()); + } else if (rect.y == first.YMost()) { + // The bottom of the first rect is on the same line as the top of rect, but + // they aren't necessarily contained. + if (rect.x <= first.x && rect.XMost() >= first.XMost()) { + // The top of rect contains the bottom of the first rect + firstDeviceRect.SetBottomEdge(deviceRect.y); + } else if (rect.x >= first.x && rect.XMost() <= first.XMost()) { + // The bottom of the first contains the top of rect + deviceRect.SetTopEdge(firstDeviceRect.YMost()); + } + } } - } - pRect = pRect->next; - result.Or(result, deviceRect); - } - result.Or(result, firstDeviceRect); - return result; + boxes[i] = RectToBox(deviceRect); + } + + boxes[0] = RectToBox(firstDeviceRect); + + pixman_region32_fini(&intRegion.mImpl.mImpl); + // This will union all of the rectangles and runs in about O(n lg(n)) + pixman_region32_init_rects(&intRegion.mImpl.mImpl, boxes, n); + } + return intRegion; + } // A cell's "value" is a pair consisting of @@ -1687,8 +513,8 @@ namespace { nsRect nsRegion::GetLargestRectangle (const nsRect& aContainingRect) const { nsRect bestRect; - if (mRectCount <= 1) { - bestRect = mBoundRect; + if (GetNumRects() <= 1) { + bestRect = GetBounds(); return bestRect; } @@ -1794,111 +620,26 @@ nsRect nsRegion::GetLargestRectangle (const nsRect& aContainingRect) const { return bestRect; } -void nsRegion::SimplifyOutward (uint32_t aMaxRects) -{ - NS_ASSERTION(aMaxRects >= 1, "Invalid max rect count"); - - if (mRectCount <= aMaxRects) - return; - - // Try combining rects in horizontal bands into a single rect - RgnRect* pRect = mRectListHead.next; - while (pRect != &mRectListHead) - { - // Combine with the following rectangle if they have the same YMost - // or if they overlap vertically. This ensures that all overlapping - // rectangles are merged, preserving the invariant that rectangles - // don't overlap. - // The goal here is to try to keep groups of rectangles that are vertically - // discontiguous as separate rectangles in the final region. This is - // simple and fast to implement and page contents tend to vary more - // vertically than horizontally (which is why our rectangles are stored - // sorted by y-coordinate, too). - while (pRect->next != &mRectListHead && - pRect->YMost () >= pRect->next->y) - { - pRect->UnionRect(*pRect, *pRect->next); - delete Remove (pRect->next); - } - - pRect = pRect->next; - } - - if (mRectCount <= aMaxRects) - return; - - *this = GetBounds(); -} - -void nsRegion::SimplifyInward (uint32_t aMaxRects) -{ - NS_ASSERTION(aMaxRects >= 1, "Invalid max rect count"); - - if (mRectCount <= aMaxRects) - return; - - SetEmpty(); -} - -void nsRegion::SimpleSubtract (const nsRect& aRect) -{ - if (aRect.IsEmpty()) - return; - - // protect against aRect being one of our own rectangles - nsRect param = aRect; - RgnRect* r = mRectListHead.next; - while (r != &mRectListHead) - { - RgnRect* next = r->next; - if (param.Contains(*r)) { - delete Remove(r); - } - r = next; - } - - Optimize(); -} - -void nsRegion::SimpleSubtract (const nsRegion& aRegion) -{ - if (aRegion.IsEmpty()) - return; - - if (&aRegion == this) { - SetEmpty(); - return; - } - - const RgnRect* r = aRegion.mRectListHead.next; - while (r != &aRegion.mRectListHead) - { - SimpleSubtract(*r); - r = r->next; - } - - Optimize(); -} - nsCString -nsRegion::ToString() const -{ - nsCString result; - result.AppendLiteral("["); - const RgnRect* r = mRectListHead.next; - while (r != &mRectListHead) - { - if (r != mRectListHead.next) { - result.AppendLiteral("; "); - } - result.Append(nsPrintfCString("%d,%d,%d,%d", r->x, r->y, r->XMost(), r->YMost())); - r = r->next; - } - result.AppendLiteral("]"); +nsRegion::ToString() const { + nsCString result; + result.AppendLiteral("["); - return result; + int n; + pixman_box32_t *boxes = pixman_region32_rectangles(const_cast(&mImpl), &n); + for (int i=0; i 1; } - bool IsEqual (const nsRegion& aRegion) const; - uint32_t GetNumRects () const { return mRectCount; } - const nsRect& GetBounds () const { return mBoundRect; } + bool IsEmpty () const { return !pixman_region32_not_empty(Impl()); } + bool IsComplex () const { return GetNumRects() > 1; } + bool IsEqual (const nsRegion& aRegion) const + { + return pixman_region32_equal(Impl(), aRegion.Impl()); + } + uint32_t GetNumRects () const { return pixman_region32_n_rects(Impl()); } + const nsRect GetBounds () const { return BoxToRect(mImpl.extents); } uint64_t Area () const; // Converts this region from aFromAPP, an appunits per pixel ratio, to // aToAPP. This applies nsRect::ConvertAppUnitsRoundOut/In to each rect of @@ -189,95 +213,91 @@ public: * original region. */ void SimplifyInward (uint32_t aMaxRects); - /** - * Efficiently try to remove a rectangle from this region. The actual - * area removed could be some sub-area contained by the rectangle - * (even possibly nothing at all). - * - * We remove all rectangles that are contained by aRect. - */ - void SimpleSubtract (const nsRect& aRect); - /** - * Efficiently try to remove a region from this region. The actual - * area removed could be some sub-area contained by aRegion - * (even possibly nothing at all). - * - * We remove all rectangles of this region that are contained by - * a rectangle of aRegion. - */ - void SimpleSubtract (const nsRegion& aRegion); nsCString ToString() const; - - /** - * Initialize any static data associated with nsRegion. - */ - static nsresult InitStatic(); - - /** - * Deinitialize static data. - */ - static void ShutdownStatic(); - private: - uint32_t mRectCount; - RgnRect* mCurRect; - RgnRect mRectListHead; - nsRectFast mBoundRect; + pixman_region32_t mImpl; - void Init (); - nsRegion& Copy (const nsRegion& aRegion); - nsRegion& Copy (const nsRect& aRect); - void InsertBefore (RgnRect* aNewRect, RgnRect* aRelativeRect); - void InsertAfter (RgnRect* aNewRect, RgnRect* aRelativeRect); - void SetToElements (uint32_t aCount); - RgnRect* Remove (RgnRect* aRect); - void InsertInPlace (RgnRect* aRect, bool aOptimizeOnFly = false); - inline void SaveLinkChain (); - inline void RestoreLinkChain (); - void Optimize (); - void SubRegion (const nsRegion& aRegion, nsRegion& aResult) const; - void SubRect (const nsRectFast& aRect, nsRegion& aResult, nsRegion& aCompleted) const; - void SubRect (const nsRectFast& aRect, nsRegion& aResult) const - { SubRect (aRect, aResult, aResult); } - void Merge (const nsRegion& aRgn1, const nsRegion& aRgn2); - void MoveInto (nsRegion& aDestRegion, const RgnRect* aStartRect); - void MoveInto (nsRegion& aDestRegion) - { MoveInto (aDestRegion, mRectListHead.next); } nsIntRegion ToPixels(nscoord aAppUnitsPerPixel, bool aOutsidePixels) const; + + nsRegion& Copy (const nsRegion& aRegion) + { + pixman_region32_copy(&mImpl, aRegion.Impl()); + return *this; + } + + nsRegion& Copy (const nsRect& aRect) + { + pixman_box32_t box = RectToBox(aRect); + pixman_region32_reset(&mImpl, &box); + return *this; + } + + static inline pixman_box32_t RectToBox(const nsRect &aRect) + { + pixman_box32_t box = { aRect.x, aRect.y, aRect.XMost(), aRect.YMost() }; + return box; + } + + static inline pixman_box32_t RectToBox(const nsIntRect &aRect) + { + pixman_box32_t box = { aRect.x, aRect.y, aRect.XMost(), aRect.YMost() }; + return box; + } + + + static inline nsRect BoxToRect(const pixman_box32_t &aBox) + { + return nsRect(aBox.x1, aBox.y1, + aBox.x2 - aBox.x1, + aBox.y2 - aBox.y1); + } + + pixman_region32_t* Impl() const + { + return const_cast(&mImpl); + } + }; - -// Allow read-only access to region rectangles by iterating the list - class NS_GFX nsRegionRectIterator { const nsRegion* mRegion; - const nsRegion::RgnRect* mCurPtr; + int i; + int n; + nsRect rect; + pixman_box32_t *boxes; public: nsRegionRectIterator (const nsRegion& aRegion) { mRegion = &aRegion; - mCurPtr = &aRegion.mRectListHead; + i = 0; + boxes = pixman_region32_rectangles(aRegion.Impl(), &n); } const nsRect* Next () { - mCurPtr = mCurPtr->next; - return (mCurPtr != &mRegion->mRectListHead) ? mCurPtr : nullptr; + if (i == n) + return nullptr; + rect = nsRegion::BoxToRect(boxes[i]); + i++; + return ▭ } const nsRect* Prev () { - mCurPtr = mCurPtr->prev; - return (mCurPtr != &mRegion->mRectListHead) ? mCurPtr : nullptr; + if (i == -1) + return nullptr; + rect = nsRegion::BoxToRect(boxes[i]); + i--; + return ▭ } void Reset () { - mCurPtr = &mRegion->mRectListHead; + i = 0; } }; @@ -287,6 +307,7 @@ public: class NS_GFX nsIntRegion { friend class nsIntRegionRectIterator; + friend class nsRegion; public: nsIntRegion () {} @@ -449,29 +470,6 @@ public: { mImpl.SimplifyInward (aMaxRects); } - /** - * Efficiently try to remove a rectangle from this region. The actual - * area removed could be some sub-area contained by the rectangle - * (even possibly nothing at all). - * - * We remove all rectangles that are contained by aRect. - */ - void SimpleSubtract (const nsIntRect& aRect) - { - mImpl.SimpleSubtract (ToRect (aRect)); - } - /** - * Efficiently try to remove a region from this region. The actual - * area removed could be some sub-area contained by aRegion - * (even possibly nothing at all). - * - * We remove all rectangles of this region that are contained by - * a rectangle of aRegion. - */ - void SimpleSubtract (const nsIntRegion& aRegion) - { - mImpl.SimpleSubtract (aRegion.mImpl); - } nsCString ToString() const { return mImpl.ToString(); } @@ -519,5 +517,4 @@ public: mImpl.Reset (); } }; - #endif diff --git a/gfx/tests/gtest/TestRegion.cpp b/gfx/tests/gtest/TestRegion.cpp index a73998372e0a..2cef29898a1e 100644 --- a/gfx/tests/gtest/TestRegion.cpp +++ b/gfx/tests/gtest/TestRegion.cpp @@ -124,3 +124,50 @@ TEST(Gfx, RegionTestContainsSpecifiedOverflowingRect) { TestLargestRegion::TestContainsSpecifiedOverflowingRect(); } +TEST(Gfx, RegionScaleToInside) { + { // no rectangles + nsRegion r; + + nsIntRegion scaled = r.ScaleToInsidePixels(1, 1, 60); + nsIntRegion result; + + EXPECT_TRUE(result.IsEqual(scaled)) << + "scaled result incorrect"; + } + + { // one rectangle + nsRegion r(nsRect(0,44760,19096,264)); + + nsIntRegion scaled = r.ScaleToInsidePixels(1, 1, 60); + nsIntRegion result(nsIntRect(0,746,318,4)); + + EXPECT_TRUE(result.IsEqual(scaled)) << + "scaled result incorrect"; + } + + + { // the first rectangle gets adjusted + nsRegion r(nsRect(0,44760,19096,264)); + r.Or(r, nsRect(0,45024,19360,1056)); + + nsIntRegion scaled = r.ScaleToInsidePixels(1, 1, 60); + nsIntRegion result(nsIntRect(0,746,318,5)); + result.Or(result, nsIntRect(0,751,322,17)); + + EXPECT_TRUE(result.IsEqual(scaled)) << + "scaled result incorrect"; + } + + { // the second rectangle gets adjusted + nsRegion r(nsRect(0,44760,19360,264)); + r.Or(r, nsRect(0,45024,19096,1056)); + + nsIntRegion scaled = r.ScaleToInsidePixels(1, 1, 60); + nsIntRegion result(nsIntRect(0,746,322,4)); + result.Or(result, nsIntRect(0,750,318,18)); + + EXPECT_TRUE(result.IsEqual(scaled)) << + "scaled result incorrect"; + } + +} diff --git a/layout/media/symbols.def.in b/layout/media/symbols.def.in index ef83ae69b50c..a72b003f995a 100644 --- a/layout/media/symbols.def.in +++ b/layout/media/symbols.def.in @@ -486,6 +486,30 @@ _moz_pixman_image_set_transform _moz_pixman_image_unref _moz_pixman_transform_from_pixman_f_transform _moz_pixman_transform_invert +_moz_pixman_region32_reset +_moz_pixman_region32_init +_moz_pixman_region32_init_rect +_moz_pixman_region32_init_rects +_moz_pixman_region32_init_with_extents +_moz_pixman_region32_fini +_moz_pixman_region32_translate +_moz_pixman_region32_copy +_moz_pixman_region32_intersect +_moz_pixman_region32_intersect_rect +_moz_pixman_region32_union +_moz_pixman_region32_union_rect +_moz_pixman_region32_subtract +_moz_pixman_region32_inverse +_moz_pixman_region32_contains_point +_moz_pixman_region32_contains_rectangle +_moz_pixman_region32_not_empty +_moz_pixman_region32_extents +_moz_pixman_region32_n_rects +_moz_pixman_region32_rectangles +_moz_pixman_region32_equal +_moz_pixman_region32_selfcheck +_moz_pixman_region32_reset +_moz_pixman_region32_clear #endif cairo_d2d_create_device cairo_d2d_create_device_from_d3d10device diff --git a/uriloader/exthandler/Makefile.in b/uriloader/exthandler/Makefile.in index b6fd02236cfb..f9f25b75af53 100644 --- a/uriloader/exthandler/Makefile.in +++ b/uriloader/exthandler/Makefile.in @@ -42,7 +42,7 @@ LOCAL_INCLUDES += -I$(srcdir)/win endif ifdef MOZ_ENABLE_DBUS -LOCAL_INCLUDES += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS) +OS_INCLUDES += $(TK_CFLAGS) $(MOZ_DBUS_CFLAGS) endif include $(topsrcdir)/config/rules.mk From d43b81a00e13f3639f1766fba758e8ee00843302 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 15 Nov 2013 05:11:10 -0800 Subject: [PATCH 19/72] Bug 819801 - In DMD builds, check that SQLite's reporting of its total memory consumption are correct. r=asuth. (NPOTB because it's DMD-only changes.) --- storage/src/mozStorageService.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/storage/src/mozStorageService.cpp b/storage/src/mozStorageService.cpp index 9712f5b134d1..3495955b73fc 100644 --- a/storage/src/mozStorageService.cpp +++ b/storage/src/mozStorageService.cpp @@ -60,6 +60,10 @@ namespace storage { //////////////////////////////////////////////////////////////////////////////// //// Memory Reporting +#ifdef MOZ_DMD +static mozilla::Atomic gSqliteMemoryUsed; +#endif + static int64_t StorageSQLiteDistinguishedAmount() { @@ -138,6 +142,13 @@ public: SQLITE_DBSTATUS_SCHEMA_USED, &totalConnSize); NS_ENSURE_SUCCESS(rv, rv); } + +#ifdef MOZ_DMD + if (::sqlite3_memory_used() != int64_t(gSqliteMemoryUsed)) { + NS_WARNING("memory consumption reported by SQLite doesn't match " + "our measurements"); + } +#endif } int64_t other = ::sqlite3_memory_used() - totalConnSize; @@ -387,7 +398,10 @@ namespace { // In other words, we are marking all sqlite heap blocks as reported even // though we're not reporting them ourselves. Instead we're trusting that // sqlite is fully and correctly accounting for all of its heap blocks via its -// own memory accounting. +// own memory accounting. Well, we don't have to trust it entirely, because +// it's easy to keep track (while doing this DMD-specific marking) of exactly +// how much memory SQLite is using. And we can compare that against what +// SQLite reports it is using. NS_MEMORY_REPORTER_MALLOC_SIZEOF_ON_ALLOC_FUN(SqliteMallocSizeOfOnAlloc) NS_MEMORY_REPORTER_MALLOC_SIZEOF_ON_FREE_FUN(SqliteMallocSizeOfOnFree) @@ -398,7 +412,7 @@ static void *sqliteMemMalloc(int n) { void* p = ::moz_malloc(n); #ifdef MOZ_DMD - SqliteMallocSizeOfOnAlloc(p); + gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p); #endif return p; } @@ -406,7 +420,7 @@ static void *sqliteMemMalloc(int n) static void sqliteMemFree(void *p) { #ifdef MOZ_DMD - SqliteMallocSizeOfOnFree(p); + gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p); #endif ::moz_free(p); } @@ -414,13 +428,13 @@ static void sqliteMemFree(void *p) static void *sqliteMemRealloc(void *p, int n) { #ifdef MOZ_DMD - SqliteMallocSizeOfOnFree(p); + gSqliteMemoryUsed -= SqliteMallocSizeOfOnFree(p); void *pnew = ::moz_realloc(p, n); if (pnew) { - SqliteMallocSizeOfOnAlloc(pnew); + gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(pnew); } else { // realloc failed; undo the SqliteMallocSizeOfOnFree from above - SqliteMallocSizeOfOnAlloc(p); + gSqliteMemoryUsed += SqliteMallocSizeOfOnAlloc(p); } return pnew; #else From dd9c0aa76f1f5897e9e3ecf81870d976534c4f06 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 18 Nov 2013 21:34:23 -0800 Subject: [PATCH 20/72] Back out 4d8015a52178 (bug 936566) for build bustage --- gfx/layers/Layers.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/gfx/layers/Layers.cpp b/gfx/layers/Layers.cpp index 3309f34bb4c8..709750bcd968 100644 --- a/gfx/layers/Layers.cpp +++ b/gfx/layers/Layers.cpp @@ -1262,12 +1262,6 @@ Layer::LogSelf(const char* aPrefix) nsAutoCString str; PrintInfo(str, aPrefix); MOZ_LAYERS_LOG(("%s", str.get())); - - if (mMaskLayer) { - nsAutoCString pfx(aPrefix); - pfx += " \\ MaskLayer "; - mMaskLayer->LogSelf(pfx.get()); - } } nsACString& @@ -1312,9 +1306,6 @@ Layer::PrintInfo(nsACString& aTo, const char* aPrefix) mStickyPositionData->mInner.x, mStickyPositionData->mInner.y, mStickyPositionData->mInner.width, mStickyPositionData->mInner.height); } - if (mMaskLayer) { - aTo.AppendPrintf(" [mMaskLayer=%p]", mMaskLayer); - } return aTo; } From 9958c63251780ea650a4b1c531f134e7baae20cb Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Mon, 18 Nov 2013 21:34:48 -0800 Subject: [PATCH 21/72] Back out 4fd2bf2ec8db (bug 939662) for Windows build bustage CLOSED TREE --- content/media/MediaDecoder.cpp | 8 +++--- content/media/MediaDecoder.h | 25 +++++++++++-------- content/media/MediaDecoderStateMachine.cpp | 6 ++--- content/media/MediaDecoderStateMachine.h | 2 +- content/media/MediaResource.cpp | 18 ++++++------- content/media/RtspMediaResource.cpp | 6 ++--- content/media/gstreamer/GStreamerReader.cpp | 2 +- content/media/mediasource/MediaSource.h | 1 + .../media/mediasource/MediaSourceDecoder.cpp | 8 +++--- .../media/mediasource/MediaSourceDecoder.h | 8 +++--- content/media/mediasource/SubBufferDecoder.h | 2 +- content/media/ogg/OggReader.cpp | 2 +- 12 files changed, 47 insertions(+), 41 deletions(-) diff --git a/content/media/MediaDecoder.cpp b/content/media/MediaDecoder.cpp index 30d4c670aeb5..fad35fa7ad45 100644 --- a/content/media/MediaDecoder.cpp +++ b/content/media/MediaDecoder.cpp @@ -570,7 +570,7 @@ nsresult MediaDecoder::Play() * (and can be -1 if aValue is before aRanges.Start(0)). */ static bool -IsInRanges(dom::TimeRanges& aRanges, double aValue, int32_t& aIntervalIndex) +IsInRanges(TimeRanges& aRanges, double aValue, int32_t& aIntervalIndex) { uint32_t length; aRanges.GetLength(&length); @@ -598,7 +598,7 @@ nsresult MediaDecoder::Seek(double aTime) NS_ABORT_IF_FALSE(aTime >= 0.0, "Cannot seek to a negative value."); - dom::TimeRanges seekable; + TimeRanges seekable; nsresult res; uint32_t length = 0; res = GetSeekable(&seekable); @@ -1326,7 +1326,7 @@ bool MediaDecoder::IsMediaSeekable() return mMediaSeekable; } -nsresult MediaDecoder::GetSeekable(dom::TimeRanges* aSeekable) +nsresult MediaDecoder::GetSeekable(TimeRanges* aSeekable) { double initialTime = 0.0; @@ -1492,7 +1492,7 @@ void MediaDecoder::Invalidate() // Constructs the time ranges representing what segments of the media // are buffered and playable. -nsresult MediaDecoder::GetBuffered(dom::TimeRanges* aBuffered) { +nsresult MediaDecoder::GetBuffered(TimeRanges* aBuffered) { if (mDecoderStateMachine) { return mDecoderStateMachine->GetBuffered(aBuffered); } diff --git a/content/media/MediaDecoder.h b/content/media/MediaDecoder.h index 27a66180f142..0fcbf44fd8d1 100644 --- a/content/media/MediaDecoder.h +++ b/content/media/MediaDecoder.h @@ -201,6 +201,8 @@ class TimeRanges; } } +using namespace mozilla::dom; + namespace mozilla { namespace layers { class Image; @@ -230,6 +232,8 @@ class MediaDecoder : public nsIObserver, public AbstractMediaDecoder { public: + typedef mozilla::layers::Image Image; + NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIOBSERVER @@ -367,7 +371,7 @@ public: MediaDecoder* mDecoder; // The last video image sent to the stream. Useful if we need to replicate // the image. - nsRefPtr mLastVideoImage; + nsRefPtr mLastVideoImage; gfxIntSize mLastVideoImageDisplaySize; // This is set to true when the stream is initialized (audio and // video tracks added). @@ -519,7 +523,7 @@ public: virtual bool IsTransportSeekable(); // Return the time ranges that can be seeked into. - virtual nsresult GetSeekable(dom::TimeRanges* aSeekable); + virtual nsresult GetSeekable(TimeRanges* aSeekable); // Set the end time of the media resource. When playback reaches // this point the media pauses. aTime is in seconds. @@ -555,7 +559,7 @@ public: virtual void MoveLoadsToBackground(); // Returns a weak reference to the media decoder owner. - MediaDecoderOwner* GetMediaOwner() const; + mozilla::MediaDecoderOwner* GetMediaOwner() const; // Returns the current size of the framebuffer used in // MozAudioAvailable events. @@ -580,7 +584,7 @@ public: // Constructs the time ranges representing what segments of the media // are buffered and playable. - virtual nsresult GetBuffered(dom::TimeRanges* aBuffered); + virtual nsresult GetBuffered(TimeRanges* aBuffered); // Returns the size, in bytes, of the heap memory used by the currently // queued decoded video and audio data. @@ -591,7 +595,7 @@ public: { return mVideoFrameContainer; } - layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; + mozilla::layers::ImageContainer* GetImageContainer() MOZ_OVERRIDE; // Sets the length of the framebuffer used in MozAudioAvailable events. // The new size must be between 512 and 16384. @@ -657,8 +661,8 @@ public: // held. void UpdatePlaybackPosition(int64_t aTime) MOZ_FINAL MOZ_OVERRIDE; - void SetAudioChannelType(dom::AudioChannelType aType) { mAudioChannelType = aType; } - dom::AudioChannelType GetAudioChannelType() { return mAudioChannelType; } + void SetAudioChannelType(AudioChannelType aType) { mAudioChannelType = aType; } + AudioChannelType GetAudioChannelType() { return mAudioChannelType; } // Send a new set of metadata to the state machine, to be dispatched to the // main thread to be presented when the |currentTime| of the media is greater @@ -923,7 +927,6 @@ public: GetFrameStatistics().NotifyDecodedFrames(aParsed, aDecoded); } -protected: /****** * The following members should be accessed with the decoder lock held. ******/ @@ -1022,7 +1025,7 @@ private: // The |RestrictedAccessMonitor| member object. RestrictedAccessMonitor mReentrantMonitor; -protected: +public: // Data about MediaStreams that are being fed by this decoder. nsTArray mOutputStreams; // The SourceMediaStream we are using to feed the mOutputStreams. This stream @@ -1084,6 +1087,8 @@ protected: // PlaybackEnded when mDecodedStream->mStream finishes. bool mTriggerPlaybackEndedWhenSourceStreamFinishes; +protected: + // Start timer to update download progress information. nsresult StartProgress(); @@ -1143,7 +1148,7 @@ protected: // Be assigned from media element during the initialization and pass to // AudioStream Class. - dom::AudioChannelType mAudioChannelType; + AudioChannelType mAudioChannelType; }; } // namespace mozilla diff --git a/content/media/MediaDecoderStateMachine.cpp b/content/media/MediaDecoderStateMachine.cpp index a056ceb874cb..72297f9ffa51 100644 --- a/content/media/MediaDecoderStateMachine.cpp +++ b/content/media/MediaDecoderStateMachine.cpp @@ -1605,7 +1605,7 @@ void MediaDecoderStateMachine::NotifyDataArrived(const char* aBuffer, // faster than played, mEndTime won't reflect the end of playable data // since we haven't played the frame at the end of buffered data. So update // mEndTime here as new data is downloaded to prevent such a lag. - dom::TimeRanges buffered; + TimeRanges buffered; if (mDecoder->IsInfinite() && NS_SUCCEEDED(mDecoder->GetBuffered(&buffered))) { @@ -1851,7 +1851,7 @@ int64_t MediaDecoderStateMachine::GetUndecodedData() const AssertCurrentThreadInMonitor(); NS_ASSERTION(mState > DECODER_STATE_DECODING_METADATA, "Must have loaded metadata for GetBuffered() to work"); - dom::TimeRanges buffered; + TimeRanges buffered; nsresult res = mDecoder->GetBuffered(&buffered); NS_ENSURE_SUCCESS(res, 0); @@ -2713,7 +2713,7 @@ void MediaDecoderStateMachine::StartBuffering() stats.mDownloadRate/1024, stats.mDownloadRateReliable ? "" : " (unreliable)")); } -nsresult MediaDecoderStateMachine::GetBuffered(dom::TimeRanges* aBuffered) { +nsresult MediaDecoderStateMachine::GetBuffered(TimeRanges* aBuffered) { MediaResource* resource = mDecoder->GetResource(); NS_ENSURE_TRUE(resource, NS_ERROR_FAILURE); resource->Pin(); diff --git a/content/media/MediaDecoderStateMachine.h b/content/media/MediaDecoderStateMachine.h index 8897ef6e8b38..7e5aad6b01a6 100644 --- a/content/media/MediaDecoderStateMachine.h +++ b/content/media/MediaDecoderStateMachine.h @@ -255,7 +255,7 @@ public: return mState == DECODER_STATE_SEEKING; } - nsresult GetBuffered(dom::TimeRanges* aBuffered); + nsresult GetBuffered(TimeRanges* aBuffered); void SetPlaybackRate(double aPlaybackRate); void SetPreservesPitch(bool aPreservesPitch); diff --git a/content/media/MediaResource.cpp b/content/media/MediaResource.cpp index f5806b659e73..555058282dc1 100644 --- a/content/media/MediaResource.cpp +++ b/content/media/MediaResource.cpp @@ -147,7 +147,7 @@ ChannelMediaResource::OnStartRequest(nsIRequest* aRequest) MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); nsresult status; nsresult rv = aRequest->GetStatus(&status); @@ -583,7 +583,7 @@ nsresult ChannelMediaResource::OpenChannel(nsIStreamListener** aStreamListener) // an authorizing Access-Control header. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); if (element->ShouldCheckAllowOrigin()) { nsRefPtr crossSiteListener = @@ -642,7 +642,7 @@ void ChannelMediaResource::SetupChannelHeaders() if (!owner) { return; } - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { return; } @@ -805,7 +805,7 @@ void ChannelMediaResource::Suspend(bool aCloseImmediately) // Shutting down; do nothing. return; } - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -840,7 +840,7 @@ void ChannelMediaResource::Resume() // Shutting down; do nothing. return; } - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // Shutting down; do nothing. return; @@ -889,7 +889,7 @@ ChannelMediaResource::RecreateChannel() // The decoder is being shut down, so don't bother opening a new channel return NS_OK; } - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so don't bother opening a new channel return NS_OK; @@ -1309,7 +1309,7 @@ nsresult FileMediaResource::Open(nsIStreamListener** aStreamListener) // web server. MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); rv = nsContentUtils::GetSecurityManager()-> @@ -1374,7 +1374,7 @@ already_AddRefed FileMediaResource::CloneData(MediaDecoder* aDeco // The decoder is being shut down, so we can't clone return nullptr; } - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { // The decoder is being shut down, so we can't clone return nullptr; @@ -1533,7 +1533,7 @@ void BaseMediaResource::MoveLoadsToBackground() { NS_WARNING("Null owner in MediaResource::MoveLoadsToBackground()"); return; } - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); if (!element) { NS_WARNING("Null element in MediaResource::MoveLoadsToBackground()"); return; diff --git a/content/media/RtspMediaResource.cpp b/content/media/RtspMediaResource.cpp index 20f78594e002..a9d4074e94cf 100644 --- a/content/media/RtspMediaResource.cpp +++ b/content/media/RtspMediaResource.cpp @@ -504,7 +504,7 @@ RtspMediaResource::OnConnected(uint8_t aTrackIdx, MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE(owner, NS_ERROR_FAILURE); - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE(element, NS_ERROR_FAILURE); element->FinishDecoderSetup(mDecoder, this); @@ -535,7 +535,7 @@ void RtspMediaResource::Suspend(bool aCloseImmediately) MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE_VOID(owner); - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE_VOID(element); mMediaStreamController->Suspend(); @@ -548,7 +548,7 @@ void RtspMediaResource::Resume() MediaDecoderOwner* owner = mDecoder->GetMediaOwner(); NS_ENSURE_TRUE_VOID(owner); - dom::HTMLMediaElement* element = owner->GetMediaElement(); + HTMLMediaElement* element = owner->GetMediaElement(); NS_ENSURE_TRUE_VOID(element); if (mChannel) { diff --git a/content/media/gstreamer/GStreamerReader.cpp b/content/media/gstreamer/GStreamerReader.cpp index c35d2e3149b4..4cb1b80092fc 100644 --- a/content/media/gstreamer/GStreamerReader.cpp +++ b/content/media/gstreamer/GStreamerReader.cpp @@ -654,7 +654,7 @@ nsresult GStreamerReader::Seek(int64_t aTarget, return DecodeToTarget(aTarget); } -nsresult GStreamerReader::GetBuffered(dom::TimeRanges* aBuffered, +nsresult GStreamerReader::GetBuffered(TimeRanges* aBuffered, int64_t aStartTime) { if (!mInfo.HasValidMedia()) { diff --git a/content/media/mediasource/MediaSource.h b/content/media/mediasource/MediaSource.h index 295e82b8e3ec..0e920fef121b 100644 --- a/content/media/mediasource/MediaSource.h +++ b/content/media/mediasource/MediaSource.h @@ -35,6 +35,7 @@ namespace dom { class GlobalObject; class SourceBuffer; class SourceBufferList; +class TimeRanges; template class Optional; #define MOZILLA_DOM_MEDIASOURCE_IMPLEMENTATION_IID \ diff --git a/content/media/mediasource/MediaSourceDecoder.cpp b/content/media/mediasource/MediaSourceDecoder.cpp index beeb3f3624ad..13895b9a95cb 100644 --- a/content/media/mediasource/MediaSourceDecoder.cpp +++ b/content/media/mediasource/MediaSourceDecoder.cpp @@ -120,7 +120,7 @@ private: } }; -MediaSourceDecoder::MediaSourceDecoder(dom::HTMLMediaElement* aElement) +MediaSourceDecoder::MediaSourceDecoder(HTMLMediaElement* aElement) : mMediaSource(nullptr) , mVideoReader(nullptr), mAudioReader(nullptr) @@ -148,13 +148,13 @@ MediaSourceDecoder::Load(nsIStreamListener**, MediaDecoder*) } nsresult -MediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable) +MediaSourceDecoder::GetSeekable(TimeRanges* aSeekable) { double duration = mMediaSource->Duration(); if (IsNaN(duration)) { // Return empty range. } else if (duration > 0 && mozilla::IsInfinite(duration)) { - nsRefPtr bufferedRanges = new dom::TimeRanges(); + nsRefPtr bufferedRanges = new TimeRanges(); GetBuffered(bufferedRanges); aSeekable->Add(0, bufferedRanges->GetFinalEndTime()); } else { @@ -164,7 +164,7 @@ MediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable) } void -MediaSourceDecoder::AttachMediaSource(dom::MediaSource* aMediaSource) +MediaSourceDecoder::AttachMediaSource(MediaSource* aMediaSource) { MOZ_ASSERT(!mMediaSource && !mDecoderStateMachine); mMediaSource = aMediaSource; diff --git a/content/media/mediasource/MediaSourceDecoder.h b/content/media/mediasource/MediaSourceDecoder.h index 747876a6ba4f..e85f61640600 100644 --- a/content/media/mediasource/MediaSourceDecoder.h +++ b/content/media/mediasource/MediaSourceDecoder.h @@ -36,14 +36,14 @@ class MediaSource; class MediaSourceDecoder : public MediaDecoder { public: - MediaSourceDecoder(dom::HTMLMediaElement* aElement); + MediaSourceDecoder(HTMLMediaElement* aElement); virtual MediaDecoder* Clone() MOZ_OVERRIDE; virtual MediaDecoderStateMachine* CreateStateMachine() MOZ_OVERRIDE; virtual nsresult Load(nsIStreamListener**, MediaDecoder*) MOZ_OVERRIDE; - virtual nsresult GetSeekable(dom::TimeRanges* aSeekable) MOZ_OVERRIDE; + virtual nsresult GetSeekable(TimeRanges* aSeekable) MOZ_OVERRIDE; - void AttachMediaSource(dom::MediaSource* aMediaSource); + void AttachMediaSource(MediaSource* aMediaSource); void DetachMediaSource(); SubBufferDecoder* CreateSubDecoder(const nsACString& aType); @@ -80,7 +80,7 @@ public: } private: - dom::MediaSource* mMediaSource; + MediaSource* mMediaSource; nsTArray > mDecoders; nsTArray mReaders; // Readers owned by Decoders. diff --git a/content/media/mediasource/SubBufferDecoder.h b/content/media/mediasource/SubBufferDecoder.h index 2444474e3d99..cb11a4440765 100644 --- a/content/media/mediasource/SubBufferDecoder.h +++ b/content/media/mediasource/SubBufferDecoder.h @@ -48,7 +48,7 @@ public: mParentDecoder->NotifyDataArrived(aBuffer, aLength, aOffset); } - nsresult GetBuffered(dom::TimeRanges* aBuffered) + nsresult GetBuffered(TimeRanges* aBuffered) { // XXX: Need mStartTime (from StateMachine) instead of passing 0. return mReader->GetBuffered(aBuffered, 0); diff --git a/content/media/ogg/OggReader.cpp b/content/media/ogg/OggReader.cpp index 941cc04204cb..eb670c96a81a 100644 --- a/content/media/ogg/OggReader.cpp +++ b/content/media/ogg/OggReader.cpp @@ -1772,7 +1772,7 @@ nsresult OggReader::SeekBisection(int64_t aTarget, return NS_OK; } -nsresult OggReader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) +nsresult OggReader::GetBuffered(TimeRanges* aBuffered, int64_t aStartTime) { { mozilla::ReentrantMonitorAutoEnter mon(mMonitor); From 492d0e235cb44e4981f6a95acab564e0a5178624 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Tue, 19 Nov 2013 14:05:41 +0800 Subject: [PATCH 22/72] Bug 936327. r=bent --- dom/bindings/BindingUtils.h | 3 ++ dom/workers/WorkerPrivate.cpp | 5 +++ dom/workers/WorkerScope.cpp | 2 + dom/workers/test/mochitest.ini | 2 + dom/workers/test/test_timeoutTracing.html | 47 +++++++++++++++++++++++ dom/workers/test/timeoutTracing_worker.js | 13 +++++++ 6 files changed, 72 insertions(+) create mode 100644 dom/workers/test/test_timeoutTracing.html create mode 100644 dom/workers/test/timeoutTracing_worker.js diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index dcbb3f8b5945..e3cff87c0628 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -20,6 +20,7 @@ #include "mozilla/dom/RootedDictionary.h" #include "mozilla/dom/workers/Workers.h" #include "mozilla/ErrorResult.h" +#include "mozilla/HoldDropJSObjects.h" #include "mozilla/Likely.h" #include "mozilla/Util.h" #include "nsCycleCollector.h" @@ -2323,6 +2324,8 @@ CreateGlobal(JSContext* aCx, T* aObject, nsWrapperCache* aCache, return nullptr; } + mozilla::HoldJSObjects(aObject); + return global; } diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 9a4d2297d6bf..33f945724630 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -4240,6 +4240,11 @@ WorkerPrivate::TraceTimeouts(const TraceCallbacks& aCallbacks, for (uint32_t index = 0; index < mTimeouts.Length(); index++) { TimeoutInfo* info = mTimeouts[index]; + + if (info->mTimeoutCallable.isUndefined()) { + continue; + } + aCallbacks.Trace(&info->mTimeoutCallable, "mTimeoutCallable", aClosure); for (uint32_t index2 = 0; index2 < info->mExtraArgVals.Length(); index2++) { aCallbacks.Trace(&info->mExtraArgVals[index2], "mExtraArgVals[i]", aClosure); diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index ecc5e7459cd1..9a7f9f2d5c2a 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -41,6 +41,8 @@ WorkerGlobalScope::WorkerGlobalScope(WorkerPrivate* aWorkerPrivate) WorkerGlobalScope::~WorkerGlobalScope() { + // Matches the HoldJSObjects in CreateGlobal. + mozilla::DropJSObjects(this); } NS_IMPL_CYCLE_COLLECTION_CLASS(WorkerGlobalScope) diff --git a/dom/workers/test/mochitest.ini b/dom/workers/test/mochitest.ini index ce42a9cb05d8..4c60ab35ba48 100644 --- a/dom/workers/test/mochitest.ini +++ b/dom/workers/test/mochitest.ini @@ -45,6 +45,7 @@ support-files = threadErrors_worker4.js threadTimeouts_worker.js throwingOnerror_worker.js + timeoutTracing_worker.js transferable_worker.js urlApi_worker.js url_worker.js @@ -96,6 +97,7 @@ support-files = [test_threadErrors.html] [test_threadTimeouts.html] [test_throwingOnerror.html] +[test_timeoutTracing.html] [test_transferable.html] [test_url.html] [test_urlApi.html] diff --git a/dom/workers/test/test_timeoutTracing.html b/dom/workers/test/test_timeoutTracing.html new file mode 100644 index 000000000000..b995f487908e --- /dev/null +++ b/dom/workers/test/test_timeoutTracing.html @@ -0,0 +1,47 @@ + + + + + + Test for DOM Worker Threads + + + + +
+
+
+ + + diff --git a/dom/workers/test/timeoutTracing_worker.js b/dom/workers/test/timeoutTracing_worker.js new file mode 100644 index 000000000000..d62cc50c5429 --- /dev/null +++ b/dom/workers/test/timeoutTracing_worker.js @@ -0,0 +1,13 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +onmessage = function(event) { + throw "No messages should reach me!"; +} + +setInterval(function() { postMessage("Still alive!"); }, 20); +setInterval(";", 20); + +postMessage("Begin!"); From facf7517b4bfd6ee473bc7de5c399f56dcbef48f Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Tue, 19 Nov 2013 14:05:42 +0800 Subject: [PATCH 23/72] Bug 940071: Free the proto and iface cache for generated globals. r=bz --- dom/bindings/BindingUtils.cpp | 7 +++++++ dom/bindings/BindingUtils.h | 13 +++++++++++++ dom/bindings/Codegen.py | 2 ++ 3 files changed, 22 insertions(+) diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index 2ae924b04438..ece2aaed67d7 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -2167,6 +2167,13 @@ TraceGlobal(JSTracer* aTrc, JSObject* aObj) mozilla::dom::TraceProtoAndIfaceCache(aTrc, aObj); } +void +FinalizeGlobal(JSFreeOp* aFreeOp, JSObject* aObj) +{ + MOZ_ASSERT(js::GetObjectClass(aObj)->flags & JSCLASS_DOM_GLOBAL); + mozilla::dom::DestroyProtoAndIfaceCache(aObj); +} + bool ResolveGlobal(JSContext* aCx, JS::Handle aObj, JS::MutableHandle aId, unsigned aFlags, diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index e3cff87c0628..711c16a08f86 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -290,6 +290,11 @@ AllocateProtoAndIfaceCache(JSObject* obj) js::SetReservedSlot(obj, DOM_PROTOTYPE_SLOT, JS::PrivateValue(protoAndIfaceArray)); + +#ifdef NS_BUILD_REFCNT_LOGGING + NS_LogCtor((void*)protoAndIfaceArray, "ProtoAndIfaceArray", + sizeof(JS::Heap) * kProtoAndIfaceCacheCount); +#endif } inline void @@ -314,6 +319,11 @@ DestroyProtoAndIfaceCache(JSObject* obj) JS::Heap* protoAndIfaceArray = GetProtoAndIfaceArray(obj); +#ifdef NS_BUILD_REFCNT_LOGGING + NS_LogDtor((void*)protoAndIfaceArray, "ProtoAndIfaceArray", + sizeof(JS::Heap) * kProtoAndIfaceCacheCount); +#endif + delete [] protoAndIfaceArray; } @@ -2274,6 +2284,9 @@ ThreadsafeCheckIsChrome(JSContext* aCx, JSObject* aObj); void TraceGlobal(JSTracer* aTrc, JSObject* aObj); +void +FinalizeGlobal(JSFreeOp* aFop, JSObject* aObj); + bool ResolveGlobal(JSContext* aCx, JS::Handle aObj, JS::MutableHandle aId, unsigned aFlags, diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index ea16c4b52cac..5e0fad48abee 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1084,6 +1084,8 @@ def finalizeHook(descriptor, hookName, context): finalize += "ClearWrapper(self, self);\n" if descriptor.interface.getExtendedAttribute('OverrideBuiltins'): finalize += "self->mExpandoAndGeneration.expando = JS::UndefinedValue();\n" + if descriptor.interface.getExtendedAttribute("Global"): + finalize += "mozilla::dom::FinalizeGlobal(fop, obj);\n" if descriptor.nativeOwnership == 'worker': finalize += "self->Release();" else: From eed95ac5c2da407c72037759b172c47efbd8b101 Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Sat, 16 Nov 2013 23:33:56 -0800 Subject: [PATCH 24/72] Bug 939578 - Build netwerk/streamconv in unified mode. r=mcmanus --- netwerk/streamconv/converters/ParseFTPList.h | 6 ++++- netwerk/streamconv/converters/moz.build | 6 ++--- .../streamconv/converters/nsBinHexDecoder.cpp | 13 ++++------- netwerk/streamconv/test/Converters.cpp | 17 ++++++++------ netwerk/streamconv/test/Converters.h | 23 ++++++++++++------- netwerk/streamconv/test/TestStreamConv.cpp | 8 ------- netwerk/streamconv/test/moz.build | 2 +- 7 files changed, 38 insertions(+), 37 deletions(-) diff --git a/netwerk/streamconv/converters/ParseFTPList.h b/netwerk/streamconv/converters/ParseFTPList.h index 85a83d4b19f2..f4a632a87bd3 100644 --- a/netwerk/streamconv/converters/ParseFTPList.h +++ b/netwerk/streamconv/converters/ParseFTPList.h @@ -3,6 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef ParseRTPList_h___ +#define ParseRTPList_h___ + #include #include #include "prtime.h" @@ -94,7 +97,8 @@ struct list_result /* (converting all-upcase names may be desirable) */ }; -int ParseFTPList(const char *line, +int ParseFTPList(const char *line, struct list_state *state, struct list_result *result ); +#endif /* !ParseRTPList_h___ */ diff --git a/netwerk/streamconv/converters/moz.build b/netwerk/streamconv/converters/moz.build index c944c480f79b..52647b430ed8 100644 --- a/netwerk/streamconv/converters/moz.build +++ b/netwerk/streamconv/converters/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ +UNIFIED_SOURCES += [ 'mozTXTToHTMLConv.cpp', 'nsDirIndex.cpp', 'nsDirIndexParser.cpp', @@ -16,13 +16,13 @@ SOURCES += [ ] if 'ftp' in CONFIG['NECKO_PROTOCOLS']: - SOURCES += [ + UNIFIED_SOURCES += [ 'nsFTPDirListingConv.cpp', 'ParseFTPList.cpp', ] if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'cocoa': - SOURCES += [ + UNIFIED_SOURCES += [ 'nsBinHexDecoder.cpp', ] diff --git a/netwerk/streamconv/converters/nsBinHexDecoder.cpp b/netwerk/streamconv/converters/nsBinHexDecoder.cpp index 0930688c3a83..e59df2bacd79 100644 --- a/netwerk/streamconv/converters/nsBinHexDecoder.cpp +++ b/netwerk/streamconv/converters/nsBinHexDecoder.cpp @@ -20,11 +20,6 @@ #include "nsMimeTypes.h" #include - -// sadly I couldn't find char defintions for CR LF elsehwere in the code (they are defined as strings in nsCRT.h) -#define CR '\015' -#define LF '\012' - nsBinHexDecoder::nsBinHexDecoder() : mState(0), mCRC(0), mFileCRC(0), mOctetin(26), mDonePos(3), mInCRC(0), mCount(0), mMarker(0), mPosInbuff(0), @@ -62,7 +57,7 @@ NS_INTERFACE_MAP_END // The binhex 4.0 decoder table.... -static signed char binhex_decode[256] = +static const signed char binhex_decode[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -321,7 +316,7 @@ nsresult nsBinHexDecoder::ProcessNextChunk(nsIRequest * aRequest, nsISupports * while (mPosInDataBuffer < numBytesInBuffer) { c = mDataBuffer[mPosInDataBuffer++]; - while (c == CR || c == LF) + while (c == nsCRT::CR || c == nsCRT::LF) { if (mPosInDataBuffer >= numBytesInBuffer) break; @@ -430,10 +425,10 @@ int16_t nsBinHexDecoder::GetNextChar(uint32_t numBytesInBuffer) while (mPosInDataBuffer < numBytesInBuffer) { c = mDataBuffer[mPosInDataBuffer++]; - if (c != LF && c != CR) + if (c != nsCRT::LF && c != nsCRT::CR) break; } - return (c == LF || c == CR) ? 0 : (int) c; + return (c == nsCRT::LF || c == nsCRT::CR) ? 0 : (int) c; } ////////////////////////////////////////////////////// diff --git a/netwerk/streamconv/test/Converters.cpp b/netwerk/streamconv/test/Converters.cpp index 550282fc7b43..8a4dfb588fc4 100644 --- a/netwerk/streamconv/test/Converters.cpp +++ b/netwerk/streamconv/test/Converters.cpp @@ -4,12 +4,21 @@ #include "nsComponentManagerUtils.h" #include -#include ////////////////////////////////////////////////// // TestConverter ////////////////////////////////////////////////// +#define NS_TESTCONVERTER_CID \ +{ /* B8A067B0-4450-11d3-A16E-0050041CAF44 */ \ + 0xb8a067b0, \ + 0x4450, \ + 0x11d3, \ + {0xa1, 0x6e, 0x00, 0x50, 0x04, 0x1c, 0xaf, 0x44} \ +} + +NS_DEFINE_CID(kTestConverterCID, NS_TESTCONVERTER_CID); + NS_IMPL_ISUPPORTS3(TestConverter, nsIStreamConverter, nsIStreamListener, @@ -79,12 +88,6 @@ TestConverter::AsyncConvertData(const char *aFromType, return NS_OK; } -static inline uint32_t -saturated(uint64_t aValue) -{ - return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX); -} - // nsIStreamListener method /* This method handles asyncronous conversion of data. */ NS_IMETHODIMP diff --git a/netwerk/streamconv/test/Converters.h b/netwerk/streamconv/test/Converters.h index 68edfe87c3ee..d15ec935b116 100644 --- a/netwerk/streamconv/test/Converters.h +++ b/netwerk/streamconv/test/Converters.h @@ -1,8 +1,13 @@ +#ifndef Converters_h___ +#define Converters_h___ + #include "nsIStreamConverter.h" #include "nsIFactory.h" #include "nsCOMPtr.h" #include "nsStringAPI.h" +#include + /* This file defines stream converter components, and their accompanying factory class. * These converters implement the nsIStreamConverter interface and support both * asynchronous and synchronous stream conversion. @@ -10,14 +15,8 @@ /////////////////////////////////////////////// // TestConverter -#define NS_TESTCONVERTER_CID \ -{ /* B8A067B0-4450-11d3-A16E-0050041CAF44 */ \ - 0xb8a067b0, \ - 0x4450, \ - 0x11d3, \ - {0xa1, 0x6e, 0x00, 0x50, 0x04, 0x1c, 0xaf, 0x44} \ -} -static NS_DEFINE_CID(kTestConverterCID, NS_TESTCONVERTER_CID); + +extern const nsCID kTestConverterCID; class TestConverter : public nsIStreamConverter { public: @@ -43,3 +42,11 @@ public: }; nsresult CreateTestConverter(nsISupports* aOuter, REFNSIID aIID, void** aResult); + +static inline uint32_t +saturated(uint64_t aValue) +{ + return (uint32_t) std::min(aValue, (uint64_t) UINT32_MAX); +} + +#endif /* !Converters_h___ */ diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index 58e1cb1c5fec..797fdd15a37d 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -19,8 +19,6 @@ #include "nsIRequest.h" #include "nsNetCID.h" -#include - #define ASYNC_TEST // undefine this if you want to test sycnronous conversion. ///////////////////////////////// @@ -99,12 +97,6 @@ NS_IMPL_ISUPPORTS2(EndListener, // EndListener END //////////////////////////////////////////////////////////////////////// -static uint32_t -saturated(uint64_t aValue) -{ - return (uint32_t)std::min(aValue, (uint64_t)UINT32_MAX); -} - nsresult SendData(const char * aData, nsIStreamListener* aListener, nsIRequest* request) { nsresult rv; diff --git a/netwerk/streamconv/test/moz.build b/netwerk/streamconv/test/moz.build index 4b783f89a344..988026eb8c3c 100644 --- a/netwerk/streamconv/test/moz.build +++ b/netwerk/streamconv/test/moz.build @@ -6,7 +6,7 @@ PROGRAM = 'TestStreamConv' -SOURCES += [ +UNIFIED_SOURCES += [ 'Converters.cpp', 'TestStreamConv.cpp', ] From dee1a12c2803668055b5a33549e3d5435fa1cf17 Mon Sep 17 00:00:00 2001 From: Joshua Cranmer Date: Tue, 19 Nov 2013 00:12:25 -0600 Subject: [PATCH 25/72] Bug 940202 - Make FINAL_LIBRARY work with comm-central, r=glandium --HG-- extra : rebase_source : fc8bc5cf6e69be02eeefa7dd98eb5273998831db --- .../mozbuild/mozbuild/backend/recursivemake.py | 14 +++++++++++--- python/mozbuild/mozbuild/frontend/data.py | 4 ++-- python/mozbuild/mozbuild/frontend/emitter.py | 18 +++++++++--------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 68a56821a53b..53243c598f8c 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -1069,9 +1069,17 @@ class RecursiveMakeBackend(CommonBackend): def _process_library_definition(self, libdef, backend_file): backend_file.write('LIBRARY_NAME = %s\n' % libdef.basename) - for reldir, basename in libdef.static_libraries: - backend_file.write('SHARED_LIBRARY_LIBS += $(DEPTH)/%s/$(LIB_PREFIX)%s.$(LIB_SUFFIX)\n' - % (reldir, basename)) + thisobjdir = libdef.objdir + topobjdir = libdef.topobjdir + for objdir, basename in libdef.static_libraries: + # If this is an external objdir (i.e., comm-central), use the other + # directory instead of $(DEPTH). + if objdir.startswith(topobjdir + '/'): + relpath = '$(DEPTH)/%s' % mozpath.relpath(objdir, topobjdir) + else: + relpath = os.path.relpath(objdir, thisobjdir) + backend_file.write('SHARED_LIBRARY_LIBS += %s/$(LIB_PREFIX)%s.$(LIB_SUFFIX)\n' + % (relpath, basename)) def _write_manifests(self, dest, manifests): man_dir = os.path.join(self.environment.topobjdir, '_build_manifests', diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 9649b656ed6b..384035506936 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -345,8 +345,8 @@ class LibraryDefinition(SandboxDerived): self.refcount = 0 self.static_libraries = [] - def link_static_lib(self, reldir, basename): - self.static_libraries.append((reldir, basename)) + def link_static_lib(self, objdir, basename): + self.static_libraries.append((objdir, basename)) class TestManifest(SandboxDerived): diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 67dd0ee3ad64..697f52a32233 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -87,7 +87,7 @@ class TreeMetadataEmitter(LoggingMixin): for out in output: if isinstance(out, MozbuildSandbox): # Keep all sandboxes around, we will need them later. - sandboxes[out['RELATIVEDIR']] = out + sandboxes[out['OBJDIR']] = out for o in self.emit_from_sandbox(out): yield o @@ -101,22 +101,22 @@ class TreeMetadataEmitter(LoggingMixin): else: raise Exception('Unhandled output type: %s' % out) - for reldir, libname, final_lib in self._final_libs: + for objdir, libname, final_lib in self._final_libs: if final_lib not in self._libs: raise Exception('FINAL_LIBRARY in %s (%s) does not match any ' - 'LIBRARY_NAME' % (reldir, final_lib)) + 'LIBRARY_NAME' % (objdir, final_lib)) libs = self._libs[final_lib] if len(libs) > 1: raise Exception('FINAL_LIBRARY in %s (%s) matches a ' 'LIBRARY_NAME defined in multiple places (%s)' % - (reldir, final_lib, ', '.join(libs.keys()))) - libs.values()[0].link_static_lib(reldir, libname) - self._libs[libname][reldir].refcount += 1 + (objdir, final_lib, ', '.join(libs.keys()))) + libs.values()[0].link_static_lib(objdir, libname) + self._libs[libname][objdir].refcount += 1 # The refcount can't go above 1 right now. It might in the future, # but that will have to be specifically handled. At which point the # refcount might have to be a list of referencees, for better error # reporting. - assert self._libs[libname][reldir].refcount <= 1 + assert self._libs[libname][objdir].refcount <= 1 def recurse_libs(path, name): for p, n in self._libs[name][path].static_libraries: @@ -310,13 +310,13 @@ class TreeMetadataEmitter(LoggingMixin): # If no LIBRARY_NAME is given, create one. libname = sandbox['RELATIVEDIR'].replace('/', '_') if libname: - self._libs.setdefault(libname, {})[sandbox['RELATIVEDIR']] = \ + self._libs.setdefault(libname, {})[sandbox['OBJDIR']] = \ LibraryDefinition(sandbox, libname) if final_lib: if sandbox.get('FORCE_STATIC_LIB'): raise SandboxValidationError('FINAL_LIBRARY implies FORCE_STATIC_LIB') - self._final_libs.append((sandbox['RELATIVEDIR'], libname, final_lib)) + self._final_libs.append((sandbox['OBJDIR'], libname, final_lib)) passthru.variables['FORCE_STATIC_LIB'] = True # While there are multiple test manifests, the behavior is very similar From 8e4efc89339d5b5b4768c803ccab8cffb0bf40d3 Mon Sep 17 00:00:00 2001 From: Joshua Cranmer Date: Tue, 19 Nov 2013 00:16:34 -0600 Subject: [PATCH 26/72] Bug 940202 followup, due to missing a review comment. --- python/mozbuild/mozbuild/backend/recursivemake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 53243c598f8c..b2ef747f75cc 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -1077,7 +1077,7 @@ class RecursiveMakeBackend(CommonBackend): if objdir.startswith(topobjdir + '/'): relpath = '$(DEPTH)/%s' % mozpath.relpath(objdir, topobjdir) else: - relpath = os.path.relpath(objdir, thisobjdir) + relpath = mozpath.relpath(objdir, thisobjdir) backend_file.write('SHARED_LIBRARY_LIBS += %s/$(LIB_PREFIX)%s.$(LIB_SUFFIX)\n' % (relpath, basename)) From 7c888f92378e3fa43f27efcba60b15eeae9f94fa Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 14 Nov 2013 18:43:11 -0800 Subject: [PATCH 27/72] Bug 921224 (part 1) - Don't use ballast in MarkStack. r=wmccloskey. --HG-- extra : rebase_source : f847b35b7d5879816f1cde112c1f3cbf0fe58414 --- js/src/gc/Marking.cpp | 2 +- js/src/jsapi.cpp | 2 +- js/src/jsgc.cpp | 2 +- js/src/jsgc.h | 164 ++++++++++++++++++++---------------------- 4 files changed, 81 insertions(+), 89 deletions(-) diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index f27a31d7f8c0..7dd91670c52c 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -1270,7 +1270,7 @@ struct SlotArrayLayout void GCMarker::saveValueRanges() { - for (uintptr_t *p = stack.tos; p > stack.stack; ) { + for (uintptr_t *p = stack.tos_; p > stack.stack_; ) { uintptr_t tag = *--p & StackTagMask; if (tag == ValueArrayTag) { *p &= ~StackTagMask; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index fb3d972b3395..0a5778b8665c 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2094,7 +2094,7 @@ JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key) case JSGC_SLICE_TIME_BUDGET: return uint32_t(rt->gcSliceBudget > 0 ? rt->gcSliceBudget / PRMJ_USEC_PER_MSEC : 0); case JSGC_MARK_STACK_LIMIT: - return rt->gcMarker.sizeLimit(); + return rt->gcMarker.maxCapacity(); case JSGC_HIGH_FREQUENCY_TIME_LIMIT: return rt->gcHighFrequencyTimeThreshold; case JSGC_HIGH_FREQUENCY_LOW_LIMIT: diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index 77cfef71c0f3..c304ea21e499 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1937,7 +1937,7 @@ void js::SetMarkStackLimit(JSRuntime *rt, size_t limit) { JS_ASSERT(!rt->isHeapBusy()); - rt->gcMarker.setSizeLimit(limit); + rt->gcMarker.setMaxCapacity(limit); } void diff --git a/js/src/jsgc.h b/js/src/jsgc.h index cab82f0e2f66..eb3f24bdd0df 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -910,138 +910,130 @@ typedef HashSet GCChunkSet; template struct MarkStack { - T *stack; - T *tos; - T *limit; + T *stack_; + T *tos_; + T *end_; - T *ballast; - T *ballastLimit; + // The capacity we start with and reset() to. + size_t baseCapacity_; + size_t maxCapacity_; - size_t sizeLimit; - - MarkStack(size_t sizeLimit) - : stack(nullptr), - tos(nullptr), - limit(nullptr), - ballast(nullptr), - ballastLimit(nullptr), - sizeLimit(sizeLimit) { } + MarkStack(size_t maxCapacity) + : stack_(nullptr), + tos_(nullptr), + end_(nullptr), + baseCapacity_(0), + maxCapacity_(maxCapacity) + {} ~MarkStack() { - if (stack != ballast) - js_free(stack); - js_free(ballast); + js_free(stack_); } - bool init(size_t ballastcap) { - JS_ASSERT(!stack); + size_t capacity() { return end_ - stack_; } - if (ballastcap == 0) - return true; + ptrdiff_t position() const { return tos_ - stack_; } - ballast = js_pod_malloc(ballastcap); - if (!ballast) + void setStack(T *stack, size_t tosIndex, size_t capacity) { + stack_ = stack; + tos_ = stack + tosIndex; + end_ = stack + capacity; + } + + bool init(size_t baseCapacity) { + baseCapacity_ = baseCapacity; + if (baseCapacity_ > maxCapacity_) + baseCapacity_ = maxCapacity_; + + JS_ASSERT(!stack_); + T *newStack = js_pod_malloc(baseCapacity_); + if (!newStack) return false; - ballastLimit = ballast + ballastcap; - initFromBallast(); + + setStack(newStack, 0, baseCapacity_); return true; } - void initFromBallast() { - stack = ballast; - limit = ballastLimit; - if (size_t(limit - stack) > sizeLimit) - limit = stack + sizeLimit; - tos = stack; - } - - void setSizeLimit(size_t size) { + void setMaxCapacity(size_t maxCapacity) { JS_ASSERT(isEmpty()); + maxCapacity_ = maxCapacity; + if (baseCapacity_ > maxCapacity_) + baseCapacity_ = maxCapacity_; - sizeLimit = size; reset(); } bool push(T item) { - if (tos == limit) { + if (tos_ == end_) { if (!enlarge()) return false; } - JS_ASSERT(tos < limit); - *tos++ = item; + JS_ASSERT(tos_ < end_); + *tos_++ = item; return true; } bool push(T item1, T item2, T item3) { - T *nextTos = tos + 3; - if (nextTos > limit) { + T *nextTos = tos_ + 3; + if (nextTos > end_) { if (!enlarge()) return false; - nextTos = tos + 3; + nextTos = tos_ + 3; } - JS_ASSERT(nextTos <= limit); - tos[0] = item1; - tos[1] = item2; - tos[2] = item3; - tos = nextTos; + JS_ASSERT(nextTos <= end_); + tos_[0] = item1; + tos_[1] = item2; + tos_[2] = item3; + tos_ = nextTos; return true; } bool isEmpty() const { - return tos == stack; + return tos_ == stack_; } T pop() { JS_ASSERT(!isEmpty()); - return *--tos; - } - - ptrdiff_t position() const { - return tos - stack; + return *--tos_; } void reset() { - if (stack != ballast) - js_free(stack); - initFromBallast(); - JS_ASSERT(stack == ballast); + if (capacity() == baseCapacity_) { + // No size change; keep the current stack. + setStack(stack_, 0, baseCapacity_); + return; + } + + T *newStack = (T *)js_realloc(stack_, sizeof(T) * baseCapacity_); + if (!newStack) { + // If the realloc fails, just keep using the existing stack; it's + // not ideal but better than failing. + newStack = stack_; + baseCapacity_ = capacity(); + } + setStack(newStack, 0, baseCapacity_); } bool enlarge() { - size_t tosIndex = tos - stack; - size_t cap = limit - stack; - if (cap == sizeLimit) + if (capacity() == maxCapacity_) return false; - size_t newcap = cap * 2; - if (newcap == 0) - newcap = 32; - if (newcap > sizeLimit) - newcap = sizeLimit; - T *newStack; - if (stack == ballast) { - newStack = js_pod_malloc(newcap); - if (!newStack) - return false; - for (T *src = stack, *dst = newStack; src < tos; ) - *dst++ = *src++; - } else { - newStack = (T *)js_realloc(stack, sizeof(T) * newcap); - if (!newStack) - return false; - } - stack = newStack; - tos = stack + tosIndex; - limit = newStack + newcap; + size_t newCapacity = capacity() * 2; + if (newCapacity > maxCapacity_) + newCapacity = maxCapacity_; + + size_t tosIndex = position(); + + T *newStack = (T *)js_realloc(stack_, sizeof(T) * newCapacity); + if (!newStack) + return false; + + setStack(newStack, tosIndex, newCapacity); return true; } size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - size_t n = 0; - if (stack != ballast) - n += mallocSizeOf(stack); - n += mallocSizeOf(ballast); - return n; + return mallocSizeOf(stack_); } }; @@ -1129,8 +1121,8 @@ struct GCMarker : public JSTracer { explicit GCMarker(JSRuntime *rt); bool init(); - void setSizeLimit(size_t size) { stack.setSizeLimit(size); } - size_t sizeLimit() const { return stack.sizeLimit; } + void setMaxCapacity(size_t maxCap) { stack.setMaxCapacity(maxCap); } + size_t maxCapacity() const { return stack.maxCapacity_; } void start(); void stop(); From 776635e01b1e7c5a4dd732d6b3791f989354a661 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 14 Nov 2013 18:43:13 -0800 Subject: [PATCH 28/72] Bug 921224 (part 2) - Use a smaller mark stack when incremental GC is disabled. r=wmccloskey. --HG-- extra : rebase_source : 86fdb1f981db31751f07a1e2c367caa31637cc5a --- js/src/builtin/TestingFunctions.cpp | 4 +-- js/src/gc/Marking.cpp | 2 +- js/src/jit-test/tests/basic/bug656261.js | 2 +- js/src/jsapi.cpp | 10 +++---- js/src/jsfriendapi.cpp | 2 +- js/src/jsgc.cpp | 8 +++--- js/src/jsgc.h | 34 ++++++++++++++++++++---- js/src/jsobj.cpp | 2 +- js/src/vm/Runtime.cpp | 5 ++-- js/src/vm/Runtime.h | 11 +++++++- 10 files changed, 57 insertions(+), 23 deletions(-) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 8f4472474a40..9f2c11509833 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -363,8 +363,8 @@ InternalConst(JSContext *cx, unsigned argc, jsval *vp) if (!flat) return false; - if (JS_FlatStringEqualsAscii(flat, "MARK_STACK_LENGTH")) { - vp[0] = UINT_TO_JSVAL(js::MARK_STACK_LENGTH); + if (JS_FlatStringEqualsAscii(flat, "INCREMENTAL_MARK_STACK_BASE_CAPACITY")) { + vp[0] = UINT_TO_JSVAL(js::INCREMENTAL_MARK_STACK_BASE_CAPACITY); } else { JS_ReportError(cx, "unknown const name"); return false; diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 7dd91670c52c..93f0dbd8d0fb 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -1474,7 +1474,7 @@ GCMarker::processMarkStackTop(SliceBudget &budget) /* Call the trace hook if necessary. */ const Class *clasp = type->clasp; if (clasp->trace) { - JS_ASSERT_IF(runtime->gcMode == JSGC_MODE_INCREMENTAL && + JS_ASSERT_IF(runtime->gcMode() == JSGC_MODE_INCREMENTAL && runtime->gcIncrementalEnabled, clasp->flags & JSCLASS_IMPLEMENTS_BARRIERS); clasp->trace(this, obj); diff --git a/js/src/jit-test/tests/basic/bug656261.js b/js/src/jit-test/tests/basic/bug656261.js index e62ab334a450..7a3b61d21308 100644 --- a/js/src/jit-test/tests/basic/bug656261.js +++ b/js/src/jit-test/tests/basic/bug656261.js @@ -5,7 +5,7 @@ function build_getter(i) { function test() { - var N = internalConst("MARK_STACK_LENGTH") + 2; + var N = internalConst("INCREMENTAL_MARK_STACK_BASE_CAPACITY") + 2; var o = {}; var descriptor = { enumerable: true}; for (var i = 0; i != N; ++i) { diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 0a5778b8665c..082453ed643c 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -2067,10 +2067,10 @@ JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32_t value) break; default: JS_ASSERT(key == JSGC_MODE); - rt->gcMode = JSGCMode(value); - JS_ASSERT(rt->gcMode == JSGC_MODE_GLOBAL || - rt->gcMode == JSGC_MODE_COMPARTMENT || - rt->gcMode == JSGC_MODE_INCREMENTAL); + rt->setGCMode(JSGCMode(value)); + JS_ASSERT(rt->gcMode() == JSGC_MODE_GLOBAL || + rt->gcMode() == JSGC_MODE_COMPARTMENT || + rt->gcMode() == JSGC_MODE_INCREMENTAL); return; } } @@ -2086,7 +2086,7 @@ JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key) case JSGC_BYTES: return uint32_t(rt->gcBytes); case JSGC_MODE: - return uint32_t(rt->gcMode); + return uint32_t(rt->gcMode()); case JSGC_UNUSED_CHUNKS: return uint32_t(rt->gcChunkPool.getEmptyCount()); case JSGC_TOTAL_CHUNKS: diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index 4f780cfb93a1..e431cad6d610 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -901,7 +901,7 @@ JS::NotifyDidPaint(JSRuntime *rt) JS_FRIEND_API(bool) JS::IsIncrementalGCEnabled(JSRuntime *rt) { - return rt->gcIncrementalEnabled && rt->gcMode == JSGC_MODE_INCREMENTAL; + return rt->gcIncrementalEnabled && rt->gcMode() == JSGC_MODE_INCREMENTAL; } JS_FRIEND_API(bool) diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index c304ea21e499..fffdd8040f7c 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -1676,9 +1676,9 @@ GCMarker::GCMarker(JSRuntime *rt) } bool -GCMarker::init() +GCMarker::init(JSGCMode gcMode) { - return stack.init(MARK_STACK_LENGTH); + return stack.init(gcMode); } void @@ -4550,7 +4550,7 @@ BudgetIncrementalGC(JSRuntime *rt, int64_t *budget) return; } - if (rt->gcMode != JSGC_MODE_INCREMENTAL) { + if (rt->gcMode() != JSGC_MODE_INCREMENTAL) { ResetIncrementalGC(rt, "GC mode change"); *budget = SliceBudget::Unlimited; rt->gcStats.nonincremental("GC mode"); @@ -4741,7 +4741,7 @@ Collect(JSRuntime *rt, bool incremental, int64_t budget, int compartmentCount = 0; int collectedCount = 0; for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) { - if (rt->gcMode == JSGC_MODE_GLOBAL) + if (rt->gcMode() == JSGC_MODE_GLOBAL) zone->scheduleGC(); /* This is a heuristic to avoid resets. */ diff --git a/js/src/jsgc.h b/js/src/jsgc.h index eb3f24bdd0df..25b8ded12f7a 100644 --- a/js/src/jsgc.h +++ b/js/src/jsgc.h @@ -908,6 +908,9 @@ struct GCChunkHasher { typedef HashSet GCChunkSet; +static const size_t NON_INCREMENTAL_MARK_STACK_BASE_CAPACITY = 4096; +static const size_t INCREMENTAL_MARK_STACK_BASE_CAPACITY = 32768; + template struct MarkStack { T *stack_; @@ -940,10 +943,25 @@ struct MarkStack { end_ = stack + capacity; } - bool init(size_t baseCapacity) { - baseCapacity_ = baseCapacity; + void setBaseCapacity(JSGCMode mode) { + switch (mode) { + case JSGC_MODE_GLOBAL: + case JSGC_MODE_COMPARTMENT: + baseCapacity_ = NON_INCREMENTAL_MARK_STACK_BASE_CAPACITY; + break; + case JSGC_MODE_INCREMENTAL: + baseCapacity_ = INCREMENTAL_MARK_STACK_BASE_CAPACITY; + break; + default: + MOZ_ASSUME_UNREACHABLE("bad gc mode"); + } + if (baseCapacity_ > maxCapacity_) baseCapacity_ = maxCapacity_; + } + + bool init(JSGCMode gcMode) { + setBaseCapacity(gcMode); JS_ASSERT(!stack_); T *newStack = js_pod_malloc(baseCapacity_); @@ -1032,6 +1050,12 @@ struct MarkStack { return true; } + void setGCMode(JSGCMode gcMode) { + // The mark stack won't be resized until the next call to reset(), but + // that will happen at the end of the next GC. + setBaseCapacity(gcMode); + } + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { return mallocSizeOf(stack_); } @@ -1077,8 +1101,6 @@ struct SliceBudget { } }; -static const size_t MARK_STACK_LENGTH = 32768; - struct GrayRoot { void *thing; JSGCTraceKind kind; @@ -1119,7 +1141,7 @@ struct GCMarker : public JSTracer { public: explicit GCMarker(JSRuntime *rt); - bool init(); + bool init(JSGCMode gcMode); void setMaxCapacity(size_t maxCap) { stack.setMaxCapacity(maxCap); } size_t maxCapacity() const { return stack.maxCapacity_; } @@ -1198,6 +1220,8 @@ struct GCMarker : public JSTracer { static void GrayCallback(JSTracer *trc, void **thing, JSGCTraceKind kind); + void setGCMode(JSGCMode mode) { stack.setGCMode(mode); } + size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const; MarkStack stack; diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 575165b16197..6ee71302c171 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -1301,7 +1301,7 @@ NewObject(ExclusiveContext *cx, const Class *clasp, types::TypeObject *type_, JS rt->gcIncrementalEnabled = false; #ifdef DEBUG - if (rt->gcMode == JSGC_MODE_INCREMENTAL) { + if (rt->gcMode() == JSGC_MODE_INCREMENTAL) { fprintf(stderr, "The class %s has a trace hook but does not declare the\n" "JSCLASS_IMPLEMENTS_BARRIERS flag. Please ensure that it correctly\n" diff --git a/js/src/vm/Runtime.cpp b/js/src/vm/Runtime.cpp index a5e275e85993..b36a52519d4c 100644 --- a/js/src/vm/Runtime.cpp +++ b/js/src/vm/Runtime.cpp @@ -168,7 +168,6 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads) gcNextFullGCTime(0), gcLastGCTime(0), gcJitReleaseTime(0), - gcMode(JSGC_MODE_GLOBAL), gcAllocationThreshold(30 * 1024 * 1024), gcHighFrequencyGC(false), gcHighFrequencyTimeThreshold(1000), @@ -294,6 +293,8 @@ JSRuntime::JSRuntime(JSUseHelperThreads useHelperThreads) { liveRuntimesCount++; + setGCMode(JSGC_MODE_GLOBAL); + /* Initialize infallibly first, so we can goto bad and JS_DestroyRuntime. */ JS_INIT_CLIST(&onNewGlobalObjectWatchers); @@ -355,7 +356,7 @@ JSRuntime::init(uint32_t maxbytes) if (!js_InitGC(this, maxbytes)) return false; - if (!gcMarker.init()) + if (!gcMarker.init(gcMode())) return false; const char *size = getenv("JSGC_MARK_STACK_LIMIT"); diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index a704818100ef..77e7cb06623e 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -1015,7 +1015,16 @@ struct JSRuntime : public JS::shadow::Runtime, int64_t gcNextFullGCTime; int64_t gcLastGCTime; int64_t gcJitReleaseTime; - JSGCMode gcMode; + private: + JSGCMode gcMode_; + + public: + JSGCMode gcMode() const { return gcMode_; } + void setGCMode(JSGCMode mode) { + gcMode_ = mode; + gcMarker.setGCMode(mode); + } + size_t gcAllocationThreshold; bool gcHighFrequencyGC; uint64_t gcHighFrequencyTimeThreshold; From 8b5ebd61c401801c8950dc3931f9524c7945fc3b Mon Sep 17 00:00:00 2001 From: Makoto Kato Date: Tue, 19 Nov 2013 15:47:03 +0900 Subject: [PATCH 29/72] Bug 915217 - incorrect anaylzing mov [r64+disp], imm32. r=ehsan --- toolkit/xre/nsWindowsDllInterceptor.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/toolkit/xre/nsWindowsDllInterceptor.h b/toolkit/xre/nsWindowsDllInterceptor.h index a3af20274bd8..86b90e9d0d74 100644 --- a/toolkit/xre/nsWindowsDllInterceptor.h +++ b/toolkit/xre/nsWindowsDllInterceptor.h @@ -481,8 +481,10 @@ protected: } } else if (origBytes[nBytes] == 0xc7) { // MOV r/m64, imm32 - if ((origBytes[nBytes + 1] & 0xf8) == 0x40) { - nBytes += 6; + if (origBytes[nBytes + 1] == 0x44) { + // MOV [r64+disp8], imm32 + // ModR/W + SIB + disp8 + imm32 + nBytes += 8; } else { return; } From bbd61a2941c3b2da2e9eed95e28ea9d07279bf46 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 19 Nov 2013 16:06:30 +0900 Subject: [PATCH 30/72] Bug 940202 - One more followup to properly use $(DEPTH) on windows. rs=jcranmer --- python/mozbuild/mozbuild/backend/recursivemake.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index b2ef747f75cc..3ed3746ef748 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -1070,7 +1070,7 @@ class RecursiveMakeBackend(CommonBackend): def _process_library_definition(self, libdef, backend_file): backend_file.write('LIBRARY_NAME = %s\n' % libdef.basename) thisobjdir = libdef.objdir - topobjdir = libdef.topobjdir + topobjdir = libdef.topobjdir.replace(os.sep, '/') for objdir, basename in libdef.static_libraries: # If this is an external objdir (i.e., comm-central), use the other # directory instead of $(DEPTH). From 30a8cf94edd6667543803e21b32fd2dc3ca69f2e Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 18 Nov 2013 23:13:05 -0800 Subject: [PATCH 31/72] Bug 936754 - Fire dblclick event for double-taps in Metro.r=jimm --- widget/windows/winrt/MetroInput.cpp | 16 +++++++++------- widget/windows/winrt/MetroInput.h | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/widget/windows/winrt/MetroInput.cpp b/widget/windows/winrt/MetroInput.cpp index 622c1ad30cf4..888d00c8d65d 100644 --- a/widget/windows/winrt/MetroInput.cpp +++ b/widget/windows/winrt/MetroInput.cpp @@ -896,6 +896,9 @@ MetroInput::OnTapped(UI::Input::IGestureRecognizer* aSender, Devices::Input::PointerDeviceType deviceType; aArgs->get_PointerDeviceType(&deviceType); + unsigned int tapCount; + aArgs->get_TapCount(&tapCount); + // For mouse and pen input, we send mousedown/mouseup/mousemove // events as soon as we detect the input event. For touch input, a set of // mousedown/mouseup events will be sent only once a tap has been detected. @@ -905,7 +908,7 @@ MetroInput::OnTapped(UI::Input::IGestureRecognizer* aSender, Foundation::Point position; aArgs->get_Position(&position); - HandleSingleTap(position); + HandleTap(position, tapCount); return S_OK; } @@ -932,7 +935,7 @@ MetroInput::OnRightTapped(UI::Input::IGestureRecognizer* aSender, } void -MetroInput::HandleSingleTap(const Foundation::Point& aPoint) +MetroInput::HandleTap(const Foundation::Point& aPoint, unsigned int aTapCount) { #ifdef DEBUG_INPUT LogFunction(); @@ -946,7 +949,7 @@ MetroInput::HandleSingleTap(const Foundation::Point& aPoint) new WidgetMouseEvent(true, NS_MOUSE_MOVE, mWidget.Get(), WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); mouseEvent->refPoint = refPoint; - mouseEvent->clickCount = 1; + mouseEvent->clickCount = aTapCount; mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; DispatchAsyncEventIgnoreStatus(mouseEvent); @@ -955,7 +958,7 @@ MetroInput::HandleSingleTap(const Foundation::Point& aPoint) new WidgetMouseEvent(true, NS_MOUSE_BUTTON_DOWN, mWidget.Get(), WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); mouseEvent->refPoint = refPoint; - mouseEvent->clickCount = 1; + mouseEvent->clickCount = aTapCount; mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; mouseEvent->button = WidgetMouseEvent::buttonType::eLeftButton; DispatchAsyncEventIgnoreStatus(mouseEvent); @@ -964,7 +967,7 @@ MetroInput::HandleSingleTap(const Foundation::Point& aPoint) new WidgetMouseEvent(true, NS_MOUSE_BUTTON_UP, mWidget.Get(), WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); mouseEvent->refPoint = refPoint; - mouseEvent->clickCount = 1; + mouseEvent->clickCount = aTapCount; mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; mouseEvent->button = WidgetMouseEvent::buttonType::eLeftButton; DispatchAsyncEventIgnoreStatus(mouseEvent); @@ -980,11 +983,10 @@ MetroInput::HandleSingleTap(const Foundation::Point& aPoint) new WidgetMouseEvent(true, NS_MOUSE_MOVE, mWidget.Get(), WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal); mouseEvent->refPoint = LayoutDeviceIntPoint(point.x, point.y); - mouseEvent->clickCount = 1; + mouseEvent->clickCount = aTapCount; mouseEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH; DispatchAsyncEventIgnoreStatus(mouseEvent); } - } void diff --git a/widget/windows/winrt/MetroInput.h b/widget/windows/winrt/MetroInput.h index 137fe957fafb..57801743ea6c 100644 --- a/widget/windows/winrt/MetroInput.h +++ b/widget/windows/winrt/MetroInput.h @@ -142,7 +142,7 @@ public: HRESULT OnRightTapped(IGestureRecognizer* aSender, IRightTappedEventArgs* aArgs); - void HandleSingleTap(const Point& aPoint); + void HandleTap(const Point& aPoint, unsigned int aTapCount); void HandleLongTap(const Point& aPoint); private: From 659e5ac14635323e006ce5d4e62b0ba5b3b8272f Mon Sep 17 00:00:00 2001 From: Allison Naaktgeboren Date: Mon, 18 Nov 2013 23:13:05 -0800 Subject: [PATCH 32/72] Bug 895581 Double tap should zoom content instead of selecting text.r=mbrubeck --- .../base/content/contenthandlers/Content.js | 80 +++++++++++++++++++ browser/metro/base/content/input.js | 15 ---- widget/windows/winrt/MetroWidget.cpp | 21 ++++- 3 files changed, 100 insertions(+), 16 deletions(-) diff --git a/browser/metro/base/content/contenthandlers/Content.js b/browser/metro/base/content/contenthandlers/Content.js index 39fa20c9350d..27c85e861d22 100644 --- a/browser/metro/base/content/contenthandlers/Content.js +++ b/browser/metro/base/content/contenthandlers/Content.js @@ -114,6 +114,7 @@ function getOverflowContentBoundingRect(aElement) { */ let Content = { _debugEvents: false, + _isZoomedIn: false, get formAssistant() { delete this.formAssistant; @@ -133,6 +134,7 @@ let Content = { addEventListener("touchstart", this, false); addEventListener("click", this, true); + addEventListener("dblclick", this, true); addEventListener("keydown", this); addEventListener("keyup", this); @@ -180,6 +182,15 @@ let Content = { this.formAssistant.open(aEvent.target, aEvent); break; + case "dblclick": + // XXX Once gesture listners are used(Bug 933236), apzc will notify us + if (aEvent.mozInputSource == Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH) { + let selection = content.getSelection(); + selection.removeAllRanges(); + this._onZoomToTappedContent(aEvent.target); + } + break; + case "click": // Workaround for bug 925457: we sometimes don't recognize the // correct tap target or are unable to identify if it's editable. @@ -363,6 +374,75 @@ let Content = { } }, + _onZoomToTappedContent: function (aElement) { + if (!aElement || this._isZoomedIn) { + this._zoomOut(); + return; + } + + while (aElement && !this._shouldZoomToElement(aElement)) { + aElement = aElement.parentNode; + } + + if (!aElement) { + this._zoomOut(); + } else { + this._zoomToElement(aElement); + } + }, + + /****************************************************** + * Zoom utilities + */ + _zoomOut: function() { + let rect = getBoundingContentRect(content.document.documentElement); + + let utils = Util.getWindowUtils(content); + let viewId = utils.getViewId(content.document.documentElement); + let presShellId = {}; + utils.getPresShellId(presShellId); + let zoomData = [rect.x, + rect.y, + rect.width, + rect.height, + presShellId.value, + viewId].join(","); + Services.obs.notifyObservers(null, "Metro:ZoomToRect", zoomData); + this._isZoomedIn = false; + }, + + _zoomToElement: function(aElement) { + let rect = getBoundingContentRect(aElement); + let utils = Util.getWindowUtils(content); + let viewId = utils.getViewId(content.document.documentElement); + let presShellId = {}; + utils.getPresShellId(presShellId); + let zoomData = [rect.x, + rect.y, + rect.width, + rect.height, + presShellId.value, + viewId].join(","); + Services.obs.notifyObservers(null, "Metro:ZoomToRect", zoomData); + this._isZoomedIn = true; + }, + + _shouldZoomToElement: function(aElement) { + let win = aElement.ownerDocument.defaultView; + if (win.getComputedStyle(aElement, null).display == "inline") { + return false; + } + else if (aElement instanceof Ci.nsIDOMHTMLLIElement) { + return false; + } + else if (aElement instanceof Ci.nsIDOMHTMLQuoteElement) { + return false; + } + else { + return true; + } + }, + /****************************************************** * General utilities diff --git a/browser/metro/base/content/input.js b/browser/metro/base/content/input.js index 0a7eff652f15..9f4b20f83f5d 100644 --- a/browser/metro/base/content/input.js +++ b/browser/metro/base/content/input.js @@ -93,7 +93,6 @@ var TouchModule = { // capture phase events window.addEventListener("CancelTouchSequence", this, true); - window.addEventListener("dblclick", this, true); window.addEventListener("keydown", this, true); window.addEventListener("MozMouseHittest", this, true); @@ -144,20 +143,6 @@ var TouchModule = { case "touchend": this._onTouchEnd(aEvent); break; - case "dblclick": - // XXX This will get picked up somewhere below us for "double tap to zoom" - // once we get omtc and the apzc. Currently though dblclick is delivered to - // content and triggers selection of text, so fire up the SelectionHelperUI - // once selection is present. - if (!InputSourceHelper.isPrecise && - !SelectionHelperUI.isActive && - !FindHelperUI.isActive) { - setTimeout(function () { - SelectionHelperUI.attachEditSession(Browser.selectedTab.browser, - aEvent.clientX, aEvent.clientY); - }, 50); - } - break; case "keydown": this._handleKeyDown(aEvent); break; diff --git a/widget/windows/winrt/MetroWidget.cpp b/widget/windows/winrt/MetroWidget.cpp index b6df3ac6444c..8beec087bfe8 100644 --- a/widget/windows/winrt/MetroWidget.cpp +++ b/widget/windows/winrt/MetroWidget.cpp @@ -278,6 +278,7 @@ MetroWidget::Destroy() nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); if (NS_SUCCEEDED(rv)) { observerService->RemoveObserver(this, "apzc-scroll-offset-changed"); + observerService->RemoveObserver(this, "Metro:ZoomToRect"); } } @@ -966,6 +967,7 @@ CompositorParent* MetroWidget::NewCompositorParent(int aSurfaceWidth, int aSurfa nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1", &rv); if (NS_SUCCEEDED(rv)) { observerService->AddObserver(this, "apzc-scroll-offset-changed", false); + observerService->AddObserver(this, "Metro:ZoomToRect", false); } } @@ -1561,5 +1563,22 @@ MetroWidget::Observe(nsISupports *subject, const char *topic, const PRUnichar *d mController->UpdateScrollOffset(ScrollableLayerGuid(mRootLayerTreeId, presShellId, scrollId), scrollOffset); } - return NS_OK; + else if (!strcmp(topic, "Metro:ZoomToRect")) { + CSSRect rect = CSSRect(); + uint64_t viewId = 0; + int32_t presShellId = 0; + + int reScan = swscanf(data, L"%f,%f,%f,%f,%d,%llu", + &rect.x, &rect.y, &rect.width, &rect.height, + &presShellId, &viewId); + if(reScan != 6) { + NS_WARNING("Malformed Metro:ZoomToRect message"); + } + + ScrollableLayerGuid guid = ScrollableLayerGuid(mRootLayerTreeId, presShellId, viewId); + APZController::sAPZC->ZoomToRect(guid, rect); + } + else { + return NS_OK; + } } From 14ea59908d5c5522b8f5f6f350f7f64c8fe62550 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Tue, 19 Nov 2013 16:12:55 +0900 Subject: [PATCH 33/72] Bug 938526 - Ignore import libraries when dealing with --extract in expandlibs_exec.py. r=khuey --- config/expandlibs_exec.py | 10 ++++++++-- js/src/config/expandlibs_exec.py | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/config/expandlibs_exec.py b/config/expandlibs_exec.py index d8d9ea9d937a..f6ac5a033c21 100644 --- a/config/expandlibs_exec.py +++ b/config/expandlibs_exec.py @@ -84,8 +84,14 @@ class ExpandArgsMore(ExpandArgs): self.tmp.append(tmp) if conf.AR == 'lib': out = subprocess.check_output([conf.AR, '-NOLOGO', '-LIST', arg]) - for l in out.splitlines(): - subprocess.call([conf.AR, '-NOLOGO', '-EXTRACT:%s' % l, os.path.abspath(arg)], cwd=tmp) + files = out.splitlines() + # If lib -list returns a list full of dlls, it's an + # import lib. + if all(isDynamicLib(f) for f in files): + newlist += [arg] + continue + for f in files: + subprocess.call([conf.AR, '-NOLOGO', '-EXTRACT:%s' % f, os.path.abspath(arg)], cwd=tmp) else: subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp) objs = [] diff --git a/js/src/config/expandlibs_exec.py b/js/src/config/expandlibs_exec.py index d8d9ea9d937a..f6ac5a033c21 100644 --- a/js/src/config/expandlibs_exec.py +++ b/js/src/config/expandlibs_exec.py @@ -84,8 +84,14 @@ class ExpandArgsMore(ExpandArgs): self.tmp.append(tmp) if conf.AR == 'lib': out = subprocess.check_output([conf.AR, '-NOLOGO', '-LIST', arg]) - for l in out.splitlines(): - subprocess.call([conf.AR, '-NOLOGO', '-EXTRACT:%s' % l, os.path.abspath(arg)], cwd=tmp) + files = out.splitlines() + # If lib -list returns a list full of dlls, it's an + # import lib. + if all(isDynamicLib(f) for f in files): + newlist += [arg] + continue + for f in files: + subprocess.call([conf.AR, '-NOLOGO', '-EXTRACT:%s' % f, os.path.abspath(arg)], cwd=tmp) else: subprocess.call(ar_extract + [os.path.abspath(arg)], cwd=tmp) objs = [] From 5eebe35433c51131bb7c2c2860d0727805d5dbfd Mon Sep 17 00:00:00 2001 From: Jan Varga Date: Tue, 19 Nov 2013 08:36:12 +0100 Subject: [PATCH 34/72] Bug 921478 - Remove BackstagePass IDB constructor resolve hook and use Cu.importGlobalProperties. r=bholley,bent --HG-- rename : dom/indexedDB/test/test_globalObjects.xul => dom/indexedDB/test/test_globalObjects_chrome.xul rename : dom/indexedDB/test/test_globalObjects.html => dom/indexedDB/test/test_globalObjects_content.html rename : dom/indexedDB/test/unit/test_globalObjects.js => dom/indexedDB/test/unit/test_globalObjects_xpc.js --- dom/base/IndexedDBHelper.jsm | 1 + dom/contacts/fallback/ContactDB.jsm | 1 + dom/contacts/tests/test_contacts_upgrade.html | 1 + dom/indexedDB/IndexedDatabaseManager.cpp | 183 +++--------------- dom/indexedDB/IndexedDatabaseManager.h | 12 +- dom/indexedDB/test/chrome.ini | 3 +- dom/indexedDB/test/chromeHelpers.js | 12 +- dom/indexedDB/test/mochitest.ini | 2 +- .../test/test_globalObjects_chrome.xul | 43 ++++ ...s.html => test_globalObjects_content.html} | 0 ...jects.xul => test_globalObjects_other.xul} | 20 +- dom/indexedDB/test/unit/GlobalObjectsChild.js | 2 + .../test/unit/GlobalObjectsComponent.js | 5 +- .../test/unit/GlobalObjectsModule.jsm | 2 + dom/indexedDB/test/unit/head.js | 18 +- dom/indexedDB/test/unit/mochitest.ini | 3 +- ...Objects.js => test_globalObjects_other.js} | 21 +- .../test/unit/test_globalObjects_xpc.js | 26 +++ dom/indexedDB/test/unit/xpcshell.ini | 5 +- .../src/gonk/MobileMessageDatabaseService.js | 1 + dom/network/src/NetworkStatsDB.jsm | 1 + dom/push/src/PushService.jsm | 1 + js/xpconnect/src/Sandbox.cpp | 3 +- js/xpconnect/src/XPCRuntimeService.cpp | 10 - js/xpconnect/src/nsXPConnect.cpp | 7 - 25 files changed, 152 insertions(+), 231 deletions(-) create mode 100644 dom/indexedDB/test/test_globalObjects_chrome.xul rename dom/indexedDB/test/{test_globalObjects.html => test_globalObjects_content.html} (100%) rename dom/indexedDB/test/{test_globalObjects.xul => test_globalObjects_other.xul} (82%) rename dom/indexedDB/test/unit/{test_globalObjects.js => test_globalObjects_other.js} (81%) create mode 100644 dom/indexedDB/test/unit/test_globalObjects_xpc.js diff --git a/dom/base/IndexedDBHelper.jsm b/dom/base/IndexedDBHelper.jsm index 818921ff50af..1a4302996cfc 100644 --- a/dom/base/IndexedDBHelper.jsm +++ b/dom/base/IndexedDBHelper.jsm @@ -20,6 +20,7 @@ this.EXPORTED_SYMBOLS = ["IndexedDBHelper"]; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +Cu.importGlobalProperties(["indexedDB"]); this.IndexedDBHelper = function IndexedDBHelper() {} diff --git a/dom/contacts/fallback/ContactDB.jsm b/dom/contacts/fallback/ContactDB.jsm index c0db32c36fe4..52ec9f3118c0 100644 --- a/dom/contacts/fallback/ContactDB.jsm +++ b/dom/contacts/fallback/ContactDB.jsm @@ -18,6 +18,7 @@ const Ci = Components.interfaces; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); Cu.import("resource://gre/modules/PhoneNumberUtils.jsm"); +Cu.importGlobalProperties(["indexedDB"]); const DB_NAME = "contacts"; const DB_VERSION = 18; diff --git a/dom/contacts/tests/test_contacts_upgrade.html b/dom/contacts/tests/test_contacts_upgrade.html index b4438292aaa2..b271fe655199 100644 --- a/dom/contacts/tests/test_contacts_upgrade.html +++ b/dom/contacts/tests/test_contacts_upgrade.html @@ -148,6 +148,7 @@ function makeFailure(reason) { const {Cc, Ci, Cu} = SpecialPowers; Cu.import("resource://gre/modules/ContactDB.jsm", window); +Cu.importGlobalProperties(["indexedDB"]); let cdb = new ContactDB(); cdb.init(); diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index 67fb0b19cbc2..aefb62cccf4d 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -111,35 +111,6 @@ mozilla::StaticRefPtr gInstance; mozilla::Atomic gInitialized(0); mozilla::Atomic gClosed(0); -// See ResolveConstructors below. -struct ConstructorInfo { - const char* const name; - JS::Handle (* const resolve)(JSContext*, JS::Handle, - bool); - jsid id; -}; - -ConstructorInfo gConstructorInfo[] = { - -#define BINDING_ENTRY(_name) \ - { #_name, _name##Binding::GetConstructorObject, JSID_VOID }, - - BINDING_ENTRY(IDBCursor) - BINDING_ENTRY(IDBCursorWithValue) - BINDING_ENTRY(IDBDatabase) - BINDING_ENTRY(IDBFactory) - BINDING_ENTRY(IDBFileHandle) - BINDING_ENTRY(IDBIndex) - BINDING_ENTRY(IDBKeyRange) - BINDING_ENTRY(IDBObjectStore) - BINDING_ENTRY(IDBOpenDBRequest) - BINDING_ENTRY(IDBRequest) - BINDING_ENTRY(IDBTransaction) - BINDING_ENTRY(IDBVersionChangeEvent) - -#undef BINDING_ENTRY -}; - class AsyncDeleteFileRunnable MOZ_FINAL : public nsIRunnable { public: @@ -207,53 +178,6 @@ struct MOZ_STACK_CLASS InvalidateInfo const nsACString& pattern; }; -bool -GetIndexedDB(JSContext* aCx, JS::Handle aGlobal, - JS::MutableHandle aResult) -{ - MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); - MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, - "Not a global object!"); - - nsRefPtr factory; - if (NS_FAILED(IDBFactory::Create(aCx, aGlobal, nullptr, - getter_AddRefs(factory)))) { - return false; - } - - MOZ_ASSERT(factory, "This should never fail for chrome!"); - - return !!WrapNewBindingObject(aCx, aGlobal, factory, aResult); -} - -bool -IndexedDBLazyGetter(JSContext* aCx, JS::Handle aGlobal, - JS::Handle aId, JS::MutableHandle aVp) -{ - MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); - MOZ_ASSERT(JSID_IS_STRING(aId), "Bad id!"); - MOZ_ASSERT(JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(aId), IDB_STR), - "Bad id!"); - - JS::Rooted global(aCx, CheckedUnwrap(aGlobal, - /* stopAtOuter = */ false)); - NS_ENSURE_TRUE(global, false); - NS_ENSURE_TRUE(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL, false); - - JS::Rooted indexedDB(aCx); - if (!GetIndexedDB(aCx, global, &indexedDB)) { - return false; - } - - if (!JS_DefinePropertyById(aCx, global, aId, indexedDB, nullptr, nullptr, - JSPROP_ENUMERATE)) { - return false; - } - - aVp.set(indexedDB); - return true; -} - } // anonymous namespace IndexedDatabaseManager::IndexedDatabaseManager() @@ -482,32 +406,39 @@ IndexedDatabaseManager::TabContextMayAccessOrigin(const TabContext& aContext, // static bool -IndexedDatabaseManager::DefineConstructors(JSContext* aCx, - JS::Handle aGlobal) -{ - MOZ_ASSERT(NS_IsMainThread()); - - for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { - if (!gConstructorInfo[i].resolve(aCx, aGlobal, true)) { - return false; - } - } - - return true; -} - -// static -bool -IndexedDatabaseManager::DefineIndexedDBGetter(JSContext* aCx, - JS::Handle aGlobal) +IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx, + JS::Handle aGlobal) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, "Passed object is not a global object!"); + if (!IDBCursorBinding::GetConstructorObject(aCx, aGlobal) || + !IDBCursorWithValueBinding::GetConstructorObject(aCx, aGlobal) || + !IDBDatabaseBinding::GetConstructorObject(aCx, aGlobal) || + !IDBFactoryBinding::GetConstructorObject(aCx, aGlobal) || + !IDBFileHandleBinding::GetConstructorObject(aCx, aGlobal) || + !IDBIndexBinding::GetConstructorObject(aCx, aGlobal) || + !IDBKeyRangeBinding::GetConstructorObject(aCx, aGlobal) || + !IDBObjectStoreBinding::GetConstructorObject(aCx, aGlobal) || + !IDBOpenDBRequestBinding::GetConstructorObject(aCx, aGlobal) || + !IDBRequestBinding::GetConstructorObject(aCx, aGlobal) || + !IDBTransactionBinding::GetConstructorObject(aCx, aGlobal) || + !IDBVersionChangeEventBinding::GetConstructorObject(aCx, aGlobal)) { + return false; + } + + nsRefPtr factory; + if (NS_FAILED(IDBFactory::Create(aCx, aGlobal, nullptr, + getter_AddRefs(factory)))) { + return false; + } + + MOZ_ASSERT(factory, "This should never fail for chrome!"); + JS::Rooted indexedDB(aCx); - if (!GetIndexedDB(aCx, aGlobal, &indexedDB)) { + if (!WrapNewBindingObject(aCx, aGlobal, factory, &indexedDB)) { return false; } @@ -515,20 +446,6 @@ IndexedDatabaseManager::DefineIndexedDBGetter(JSContext* aCx, JSPROP_ENUMERATE); } -// static -bool -IndexedDatabaseManager::DefineIndexedDBLazyGetter(JSContext* aCx, - JS::Handle aGlobal) -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); - MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, - "Passed object is not a global object!"); - - return JS_DefineProperty(aCx, aGlobal, IDB_STR, JSVAL_VOID, - IndexedDBLazyGetter, nullptr, 0); -} - // static bool IndexedDatabaseManager::IsClosed() @@ -749,7 +666,7 @@ IndexedDatabaseManager::InitWindowless(const jsval& aGlobal, JSContext* aCx) return NS_ERROR_FAILURE; } - if (!DefineConstructors(aCx, global) || !DefineIndexedDBGetter(aCx, global)) { + if (!DefineIndexedDB(aCx, global)) { return NS_ERROR_FAILURE; } @@ -1001,49 +918,3 @@ GetFileReferencesHelper::Run() return NS_OK; } - -BEGIN_INDEXEDDB_NAMESPACE - -bool -ResolveConstructors(JSContext* aCx, JS::Handle aObj, - JS::Handle aId, JS::MutableHandle aObjp) -{ - MOZ_ASSERT(NS_IsMainThread()); - - // The first time this function is called we need to intern all the strings we - // care about. - if (JSID_IS_VOID(gConstructorInfo[0].id)) { - for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { - JS::Rooted str(aCx, - JS_InternString(aCx, gConstructorInfo[i].name)); - if (!str) { - NS_WARNING("Failed to intern string!"); - while (i) { - gConstructorInfo[--i].id = JSID_VOID; - } - return false; - } - gConstructorInfo[i].id = INTERNED_STRING_TO_JSID(aCx, str); - } - } - - // Now resolve. - for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { - if (gConstructorInfo[i].id == aId) { - JS::Rooted constructor(aCx, - gConstructorInfo[i].resolve(aCx, aObj, true)); - if (!constructor) { - return false; - } - - aObjp.set(aObj); - return true; - } - } - - // Not resolved. - aObjp.set(nullptr); - return true; -} - -END_INDEXEDDB_NAMESPACE diff --git a/dom/indexedDB/IndexedDatabaseManager.h b/dom/indexedDB/IndexedDatabaseManager.h index e81236fbc7bb..c3ec871fa07d 100644 --- a/dom/indexedDB/IndexedDatabaseManager.h +++ b/dom/indexedDB/IndexedDatabaseManager.h @@ -140,13 +140,7 @@ public: const nsACString& aOrigin); static bool - DefineConstructors(JSContext* aCx, JS::Handle aGlobal); - - static bool - DefineIndexedDBGetter(JSContext* aCx, JS::Handle aGlobal); - - static bool - DefineIndexedDBLazyGetter(JSContext* aCx, JS::Handle aGlobal); + DefineIndexedDB(JSContext* aCx, JS::Handle aGlobal); private: IndexedDatabaseManager(); @@ -176,10 +170,6 @@ private: static mozilla::Atomic sLowDiskSpaceMode; }; -bool -ResolveConstructors(JSContext* aCx, JS::Handle aObj, - JS::Handle aId, JS::MutableHandle aObjp); - END_INDEXEDDB_NAMESPACE #endif /* mozilla_dom_indexeddb_indexeddatabasemanager_h__ */ diff --git a/dom/indexedDB/test/chrome.ini b/dom/indexedDB/test/chrome.ini index 636a72c429dd..a809b45b5d1f 100644 --- a/dom/indexedDB/test/chrome.ini +++ b/dom/indexedDB/test/chrome.ini @@ -1,4 +1,5 @@ [DEFAULT] support-files = chromeHelpers.js -[test_globalObjects.xul] +[test_globalObjects_chrome.xul] +[test_globalObjects_other.xul] diff --git a/dom/indexedDB/test/chromeHelpers.js b/dom/indexedDB/test/chromeHelpers.js index 1233661060bb..cb86f2747ec6 100644 --- a/dom/indexedDB/test/chromeHelpers.js +++ b/dom/indexedDB/test/chromeHelpers.js @@ -7,11 +7,15 @@ const { 'classes': Cc, 'interfaces': Ci, 'utils': Cu } = Components; let testGenerator = testSteps(); -function runTest() -{ - SimpleTest.waitForExplicitFinish(); +if (!window.runTest) { + window.runTest = function() + { + Cu.importGlobalProperties(["indexedDB"]); - testGenerator.next(); + SimpleTest.waitForExplicitFinish(); + + testGenerator.next(); + } } function finishTest() diff --git a/dom/indexedDB/test/mochitest.ini b/dom/indexedDB/test/mochitest.ini index 54783fece01c..4f9e4b9eae3c 100644 --- a/dom/indexedDB/test/mochitest.ini +++ b/dom/indexedDB/test/mochitest.ini @@ -58,7 +58,7 @@ support-files = [test_filehandle_store_snapshot.html] [test_getAll.html] [test_get_filehandle.html] -[test_globalObjects.html] +[test_globalObjects_content.html] [test_global_data.html] [test_index_empty_keyPath.html] [test_index_getAll.html] diff --git a/dom/indexedDB/test/test_globalObjects_chrome.xul b/dom/indexedDB/test/test_globalObjects_chrome.xul new file mode 100644 index 000000000000..47e967d9692e --- /dev/null +++ b/dom/indexedDB/test/test_globalObjects_chrome.xul @@ -0,0 +1,43 @@ + + + + + + + + + + + Mozilla Bug 832883 + + diff --git a/dom/indexedDB/test/test_globalObjects.html b/dom/indexedDB/test/test_globalObjects_content.html similarity index 100% rename from dom/indexedDB/test/test_globalObjects.html rename to dom/indexedDB/test/test_globalObjects_content.html diff --git a/dom/indexedDB/test/test_globalObjects.xul b/dom/indexedDB/test/test_globalObjects_other.xul similarity index 82% rename from dom/indexedDB/test/test_globalObjects.xul rename to dom/indexedDB/test/test_globalObjects_other.xul index c3d2520a2c70..cfab5deace9d 100644 --- a/dom/indexedDB/test/test_globalObjects.xul +++ b/dom/indexedDB/test/test_globalObjects_other.xul @@ -14,20 +14,6 @@ diff --git a/dom/indexedDB/test/unit/GlobalObjectsChild.js b/dom/indexedDB/test/unit/GlobalObjectsChild.js index 586d27f7b4f4..5351ff2f1a9a 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsChild.js +++ b/dom/indexedDB/test/unit/GlobalObjectsChild.js @@ -18,6 +18,8 @@ function finishTest() function run_test() { const name = "Splendid Test"; + Cu.importGlobalProperties(["indexedDB"]); + do_test_pending(); let keyRange = IDBKeyRange.only(42); diff --git a/dom/indexedDB/test/unit/GlobalObjectsComponent.js b/dom/indexedDB/test/unit/GlobalObjectsComponent.js index 01c3e23dafc8..44bc1afe9b69 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsComponent.js +++ b/dom/indexedDB/test/unit/GlobalObjectsComponent.js @@ -3,7 +3,10 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); +const Cu = Components.utils; + +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.importGlobalProperties(["indexedDB"]); function GlobalObjectsComponent() { this.wrappedJSObject = this; diff --git a/dom/indexedDB/test/unit/GlobalObjectsModule.jsm b/dom/indexedDB/test/unit/GlobalObjectsModule.jsm index cb085b6f3355..fe214f722e72 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsModule.jsm +++ b/dom/indexedDB/test/unit/GlobalObjectsModule.jsm @@ -3,6 +3,8 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ +Components.utils.importGlobalProperties(["indexedDB"]); + this.EXPORTED_SYMBOLS = [ "GlobalObjectsModule" ]; diff --git a/dom/indexedDB/test/unit/head.js b/dom/indexedDB/test/unit/head.js index b3757ec25bb3..1ec20b3463e0 100644 --- a/dom/indexedDB/test/unit/head.js +++ b/dom/indexedDB/test/unit/head.js @@ -38,15 +38,19 @@ function run_test() { runTest(); }; -function runTest() -{ - // XPCShell does not get a profile by default. - do_get_profile(); +if (!this.runTest) { + this.runTest = function() + { + // XPCShell does not get a profile by default. + do_get_profile(); - enableExperimental(); + enableExperimental(); - do_test_pending(); - testGenerator.next(); + Cu.importGlobalProperties(["indexedDB"]); + + do_test_pending(); + testGenerator.next(); + } } function finishTest() diff --git a/dom/indexedDB/test/unit/mochitest.ini b/dom/indexedDB/test/unit/mochitest.ini index e2823e9587f4..e0fcdf40d12a 100644 --- a/dom/indexedDB/test/unit/mochitest.ini +++ b/dom/indexedDB/test/unit/mochitest.ini @@ -18,8 +18,9 @@ [test_deleteDatabase_interactions.js] [test_event_source.js] [test_getAll.js] -[test_globalObjects.js] [test_globalObjects_ipc.js] +[test_globalObjects_other.js] +[test_globalObjects_xpc.js] [test_global_data.js] [test_index_empty_keyPath.js] [test_index_getAll.js] diff --git a/dom/indexedDB/test/unit/test_globalObjects.js b/dom/indexedDB/test/unit/test_globalObjects_other.js similarity index 81% rename from dom/indexedDB/test/unit/test_globalObjects.js rename to dom/indexedDB/test/unit/test_globalObjects_other.js index 40ae45fcd0f1..a1338459c83b 100644 --- a/dom/indexedDB/test/unit/test_globalObjects.js +++ b/dom/indexedDB/test/unit/test_globalObjects_other.js @@ -7,8 +7,6 @@ var testGenerator = testSteps(); function testSteps() { - const name = "Splendid Test"; - let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); @@ -18,18 +16,6 @@ function testSteps() return uri.spec; } - // Test for IDBKeyRange and indexedDB availability in xpcshell. - let keyRange = IDBKeyRange.only(42); - ok(keyRange, "Got keyRange"); - - let request = indexedDB.open(name, 1); - request.onerror = errorHandler; - request.onsuccess = grabEventAndContinueHandler; - let event = yield undefined; - - let db = event.target.result; - ok(db, "Got database"); - // Test for IDBKeyRange and indexedDB availability in JS modules. Cu.import(getSpec("GlobalObjectsModule.jsm")); let test = new GlobalObjectsModule(); @@ -65,3 +51,10 @@ function testSteps() finishTest(); yield undefined; } + +this.runTest = function() { + do_get_profile(); + + do_test_pending(); + testGenerator.next(); +} diff --git a/dom/indexedDB/test/unit/test_globalObjects_xpc.js b/dom/indexedDB/test/unit/test_globalObjects_xpc.js new file mode 100644 index 000000000000..57611d046900 --- /dev/null +++ b/dom/indexedDB/test/unit/test_globalObjects_xpc.js @@ -0,0 +1,26 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +var testGenerator = testSteps(); + +function testSteps() +{ + const name = "Splendid Test"; + + // Test for IDBKeyRange and indexedDB availability in xpcshell. + let keyRange = IDBKeyRange.only(42); + ok(keyRange, "Got keyRange"); + + let request = indexedDB.open(name, 1); + request.onerror = errorHandler; + request.onsuccess = grabEventAndContinueHandler; + let event = yield undefined; + + let db = event.target.result; + ok(db, "Got database"); + + finishTest(); + yield undefined; +} diff --git a/dom/indexedDB/test/unit/xpcshell.ini b/dom/indexedDB/test/unit/xpcshell.ini index fdfedcedb64e..d3e19e5e52cf 100644 --- a/dom/indexedDB/test/unit/xpcshell.ini +++ b/dom/indexedDB/test/unit/xpcshell.ini @@ -28,10 +28,11 @@ support-files = [test_deleteDatabase_interactions.js] [test_event_source.js] [test_getAll.js] -[test_globalObjects.js] [test_globalObjects_ipc.js] # FIXME/bug 575918: out-of-process xpcshell is broken on OS X -skip-if = os == "mac" || os == "android" +#skip-if = os == "mac" || os == "android" +[test_globalObjects_other.js] +[test_globalObjects_xpc.js] [test_global_data.js] [test_index_empty_keyPath.js] [test_index_getAll.js] diff --git a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js index e17a37c63f27..918a8d1f853a 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js @@ -9,6 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/PhoneNumberUtils.jsm"); +Cu.importGlobalProperties(["indexedDB"]); const RIL_MOBILEMESSAGEDATABASESERVICE_CONTRACTID = "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"; diff --git a/dom/network/src/NetworkStatsDB.jsm b/dom/network/src/NetworkStatsDB.jsm index 3d22ef9ca139..c8e64347cbf1 100644 --- a/dom/network/src/NetworkStatsDB.jsm +++ b/dom/network/src/NetworkStatsDB.jsm @@ -13,6 +13,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); +Cu.importGlobalProperties(["indexedDB"]); const DB_NAME = "net_stats"; const DB_VERSION = 3; diff --git a/dom/push/src/PushService.jsm b/dom/push/src/PushService.jsm index 92295580a36c..ae22aabf6fb1 100644 --- a/dom/push/src/PushService.jsm +++ b/dom/push/src/PushService.jsm @@ -23,6 +23,7 @@ Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); Cu.import("resource://gre/modules/Timer.jsm"); Cu.import("resource://gre/modules/Preferences.jsm"); Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js"); +Cu.importGlobalProperties(["indexedDB"]); XPCOMUtils.defineLazyModuleGetter(this, "AlarmService", "resource://gre/modules/AlarmService.jsm"); diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index fbe0c506b67a..aaeacde6ea70 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -948,8 +948,7 @@ bool xpc::GlobalProperties::Define(JSContext *cx, JS::HandleObject obj) { if (indexedDB && AccessCheck::isChrome(obj) && - (!IndexedDatabaseManager::DefineConstructors(cx, obj) || - !IndexedDatabaseManager::DefineIndexedDBGetter(cx, obj))) + !IndexedDatabaseManager::DefineIndexedDB(cx, obj)) return false; if (XMLHttpRequest && diff --git a/js/xpconnect/src/XPCRuntimeService.cpp b/js/xpconnect/src/XPCRuntimeService.cpp index 188a15c98aad..5499df49cac7 100644 --- a/js/xpconnect/src/XPCRuntimeService.cpp +++ b/js/xpconnect/src/XPCRuntimeService.cpp @@ -10,11 +10,9 @@ #include "nsDOMClassInfo.h" #include "nsIPrincipal.h" -#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h" #include "mozilla/dom/workers/Workers.h" using mozilla::dom::workers::ResolveWorkerClasses; -namespace indexedDB = mozilla::dom::indexedDB; NS_INTERFACE_MAP_BEGIN(BackstagePass) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) @@ -75,14 +73,6 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper, return NS_OK; } - *_retval = indexedDB::ResolveConstructors(cx, obj, id, &objp); - NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE); - - if (objp) { - *objpArg = objp; - return NS_OK; - } - return NS_OK; } diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index ba6235a08c0b..f730f7e2fea0 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -515,7 +515,6 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL); // Init WebIDL binding constructors wanted on all XPConnect globals. - // Additional bindings may be created lazily, see BackstagePass::NewResolve. // // XXX Please do not add any additional classes here without the approval of // the XPConnect module owner. @@ -525,12 +524,6 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, return UnexpectedFailure(NS_ERROR_FAILURE); } - if (nsContentUtils::IsSystemPrincipal(aPrincipal) && - !IndexedDatabaseManager::DefineIndexedDBLazyGetter(aJSContext, - global)) { - return UnexpectedFailure(NS_ERROR_FAILURE); - } - wrappedGlobal.forget(_retval); return NS_OK; } From 3b4e8ca478d76fcb2d0709f62ae81dc9277193bc Mon Sep 17 00:00:00 2001 From: Vendelin Ruzicka Date: Tue, 19 Nov 2013 08:36:33 +0100 Subject: [PATCH 35/72] Bug 921478 - Part 2: Convert test_contacts_upgrade.html to real chrome mochitest. r=bent --HG-- rename : dom/contacts/tests/test_contacts_upgrade.html => dom/contacts/tests/test_contacts_upgrade.xul --- dom/contacts/tests/chrome.ini | 2 +- dom/contacts/tests/test_contacts_upgrade.html | 279 ------------------ dom/contacts/tests/test_contacts_upgrade.xul | 279 ++++++++++++++++++ dom/datastore/DataStore.jsm | 1 + dom/datastore/DataStoreDB.jsm | 1 + dom/indexedDB/IndexedDatabaseManager.cpp | 3 +- dom/indexedDB/test/unit/xpcshell.ini | 2 +- 7 files changed, 285 insertions(+), 282 deletions(-) delete mode 100644 dom/contacts/tests/test_contacts_upgrade.html create mode 100644 dom/contacts/tests/test_contacts_upgrade.xul diff --git a/dom/contacts/tests/chrome.ini b/dom/contacts/tests/chrome.ini index 3ed06c21260d..073b9ace36b1 100644 --- a/dom/contacts/tests/chrome.ini +++ b/dom/contacts/tests/chrome.ini @@ -1,3 +1,3 @@ [DEFAULT] -[test_contacts_upgrade.html] +[test_contacts_upgrade.xul] diff --git a/dom/contacts/tests/test_contacts_upgrade.html b/dom/contacts/tests/test_contacts_upgrade.html deleted file mode 100644 index b271fe655199..000000000000 --- a/dom/contacts/tests/test_contacts_upgrade.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - Test for Bug 889239 - - - - - - -Mozilla Bug 889239 -

- -
-
-
- - diff --git a/dom/contacts/tests/test_contacts_upgrade.xul b/dom/contacts/tests/test_contacts_upgrade.xul new file mode 100644 index 000000000000..c9b90d111e4d --- /dev/null +++ b/dom/contacts/tests/test_contacts_upgrade.xul @@ -0,0 +1,279 @@ + + + + + + + + + + Mozilla Bug 889239 + + diff --git a/dom/datastore/DataStore.jsm b/dom/datastore/DataStore.jsm index f6b3ad6b6d0f..afe1a2645f1d 100644 --- a/dom/datastore/DataStore.jsm +++ b/dom/datastore/DataStore.jsm @@ -28,6 +28,7 @@ Cu.import("resource://gre/modules/DataStoreDB.jsm"); Cu.import("resource://gre/modules/ObjectWrapper.jsm"); Cu.import('resource://gre/modules/Services.jsm'); Cu.import('resource://gre/modules/XPCOMUtils.jsm'); +Cu.importGlobalProperties(["indexedDB"]); XPCOMUtils.defineLazyServiceGetter(this, "cpmm", "@mozilla.org/childprocessmessagemanager;1", diff --git a/dom/datastore/DataStoreDB.jsm b/dom/datastore/DataStoreDB.jsm index 75c3fdb8af17..bf5383550754 100644 --- a/dom/datastore/DataStoreDB.jsm +++ b/dom/datastore/DataStoreDB.jsm @@ -19,6 +19,7 @@ const DATASTOREDB_REVISION_INDEX = 'revisionIndex'; Cu.import('resource://gre/modules/IndexedDBHelper.jsm'); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); +Cu.importGlobalProperties(["indexedDB"]); XPCOMUtils.defineLazyServiceGetter(this, "uuidgen", "@mozilla.org/uuid-generator;1", diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index aefb62cccf4d..90cf85144086 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -425,7 +425,8 @@ IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx, !IDBOpenDBRequestBinding::GetConstructorObject(aCx, aGlobal) || !IDBRequestBinding::GetConstructorObject(aCx, aGlobal) || !IDBTransactionBinding::GetConstructorObject(aCx, aGlobal) || - !IDBVersionChangeEventBinding::GetConstructorObject(aCx, aGlobal)) { + !IDBVersionChangeEventBinding::GetConstructorObject(aCx, aGlobal)) + { return false; } diff --git a/dom/indexedDB/test/unit/xpcshell.ini b/dom/indexedDB/test/unit/xpcshell.ini index d3e19e5e52cf..7f9a8a54b12f 100644 --- a/dom/indexedDB/test/unit/xpcshell.ini +++ b/dom/indexedDB/test/unit/xpcshell.ini @@ -30,7 +30,7 @@ support-files = [test_getAll.js] [test_globalObjects_ipc.js] # FIXME/bug 575918: out-of-process xpcshell is broken on OS X -#skip-if = os == "mac" || os == "android" +skip-if = os == "mac" || os == "android" [test_globalObjects_other.js] [test_globalObjects_xpc.js] [test_global_data.js] From 292c9a43208fd9b2e15ceb99d2bcf3c4fc0b6da7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Nov 2013 22:24:12 -0800 Subject: [PATCH 36/72] Bug 939385 (part 1) - Rename largestContiguousVMBlock as vsizeMaxContiguous. r=froydnj. --HG-- extra : rebase_source : 3c364af0442eeabd5951370792f1a467eaa86994 --- .../mochitest/tests/SimpleTest/TestRunner.js | 2 +- xpcom/base/nsIMemoryReporter.idl | 10 +++---- xpcom/base/nsMemoryReporterManager.cpp | 26 +++++++++---------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest/TestRunner.js index 28254f437752..b6f14d0a1a21 100644 --- a/testing/mochitest/tests/SimpleTest/TestRunner.js +++ b/testing/mochitest/tests/SimpleTest/TestRunner.js @@ -405,8 +405,8 @@ var MEM_STAT_UNSUPPORTED = 1; var MEM_STAT_SUPPORTED = 2; TestRunner._hasMemoryStatistics = {} TestRunner._hasMemoryStatistics.vsize = MEM_STAT_UNKNOWN; +TestRunner._hasMemoryStatistics.vsizeMaxContiguous = MEM_STAT_UNKNOWN; TestRunner._hasMemoryStatistics.heapAllocated = MEM_STAT_UNKNOWN; -TestRunner._hasMemoryStatistics.largestContiguousVMBlock = MEM_STAT_UNKNOWN; /** * This stub is called by SimpleTest when a test is finished. diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index 66e7ade7ac8f..59330f1b5655 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -263,6 +263,9 @@ interface nsIMemoryReporterManager : nsISupports * |vsize| (UNITS_BYTES) The virtual size, i.e. the amount of address space * taken up. * + * |vsizeMaxContiguous| (UNITS_BYTES) The size of the largest contiguous + * block of virtual memory. + * * |resident| (UNITS_BYTES) The resident size (a.k.a. RSS or physical memory * used). * @@ -300,13 +303,10 @@ interface nsIMemoryReporterManager : nsISupports * * |pageFaultsHard| (UNITS_COUNT_CUMULATIVE) The number of hard (a.k.a. * major) page faults that have occurred since the process started. - * - * |largestContiguousVMBlock| (UNITS_BYTES) The size of the largest - * contiguous block of virtual memory. Only available on Windows; on all - * other platforms, reading this value returns 0. */ readonly attribute int64_t explicit; readonly attribute int64_t vsize; + readonly attribute int64_t vsizeMaxContiguous; readonly attribute int64_t resident; readonly attribute int64_t residentFast; @@ -329,8 +329,6 @@ interface nsIMemoryReporterManager : nsISupports readonly attribute int64_t pageFaultsHard; - readonly attribute int64_t largestContiguousVMBlock; - /* * This attribute indicates if moz_malloc_usable_size() works. */ diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index dfa41367055c..2f3c7b19d99a 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -371,8 +371,8 @@ static nsresult GetResidentFast(int64_t* aN) return GetResident(aN); } -#define HAVE_LARGEST_CONTIGUOUS_BLOCK_REPORTERS 1 -static nsresult LargestContiguousVMBlock(int64_t* aN) +#define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1 +static nsresult GetVsizeMaxContiguous(int64_t* aN) { SIZE_T biggestRegion = 0; MEMORY_BASIC_INFORMATION vmemInfo = {0}; @@ -1285,6 +1285,17 @@ nsMemoryReporterManager::GetVsize(int64_t* aVsize) #endif } +NS_IMETHODIMP +nsMemoryReporterManager::GetVsizeMaxContiguous(int64_t* aAmount) +{ +#ifdef HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER + return ::GetVsizeMaxContiguous(aAmount); +#else + *aAmount = 0; + return NS_ERROR_NOT_AVAILABLE; +#endif +} + NS_IMETHODIMP nsMemoryReporterManager::GetResident(int64_t* aAmount) { @@ -1411,17 +1422,6 @@ nsMemoryReporterManager::GetPageFaultsHard(int64_t* aAmount) #endif } -NS_IMETHODIMP -nsMemoryReporterManager::GetLargestContiguousVMBlock(int64_t* aAmount) -{ -#ifdef HAVE_LARGEST_CONTIGUOUS_BLOCK_REPORTERS - return LargestContiguousVMBlock(aAmount); -#else - *aAmount = 0; - return NS_ERROR_NOT_AVAILABLE; -#endif -} - NS_IMETHODIMP nsMemoryReporterManager::GetHasMozMallocUsableSize(bool* aHas) { From 8545d775850e886c5264b41ae2898cdb41f7a411 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Nov 2013 22:24:18 -0800 Subject: [PATCH 37/72] Bug 939385 (part 2) - Expose vsizeMaxContiguous to telemetry. r=froydnj. --HG-- extra : rebase_source : addf1db7cfe59fced1a8e8331034a28a2d801712 --- toolkit/components/telemetry/Histograms.json | 8 ++++++++ toolkit/components/telemetry/TelemetryPing.js | 1 + 2 files changed, 9 insertions(+) diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 0d89d6761170..2649439359af 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -255,6 +255,14 @@ "extended_statistics_ok": true, "description": "Virtual memory size (KB)" }, + "MEMORY_VSIZE_MAX_CONTIGUOUS": { + "kind": "exponential", + "low": "32 * 1024", + "high": "16 * 1024 * 1024", + "n_buckets": 100, + "extended_statistics_ok": true, + "description": "Maximum-sized block of contiguous virtual memory (KB)" + }, "MEMORY_JS_COMPARTMENTS_SYSTEM": { "kind": "exponential", "high": "1000", diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index f206ef760a13..c2eca6adb067 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -452,6 +452,7 @@ TelemetryPing.prototype = { let p = (id, n) => h(id, Ci.nsIMemoryReporter.UNITS_PERCENTAGE, n); b("MEMORY_VSIZE", "vsize"); + b("MEMORY_VSIZE_MAX_CONTIGUOUS", "vsizeMaxContiguous"); b("MEMORY_RESIDENT", "residentFast"); b("MEMORY_HEAP_ALLOCATED", "heapAllocated"); p("MEMORY_HEAP_COMMITTED_UNUSED_RATIO", "heapOverheadRatio"); From 1f1f9e46d482e7c497ed01b54842e1cf27809b45 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Nov 2013 22:37:38 -0800 Subject: [PATCH 38/72] Bug 939385 (part 3) - Expose vsizeMaxContiguous to about:memory. r=froydnj. --HG-- extra : rebase_source : 77331283b56ddf28a137a0165ef9926d6e0f0f42 --- .../aboutmemory/tests/test_aboutmemory5.xul | 3 ++- xpcom/base/nsMemoryReporterManager.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul index 50a464310cce..9aa61e290a66 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul @@ -104,7 +104,8 @@ // If we have more than 1000 chars, we've probably successfully // copy+pasted. if (actual.length > 1000) { - let vsizes = actual.match(/vsize/g); + // Note: Match "vsize" but not "vsize-max-contiguous". + let vsizes = actual.match(/vsize[^-]/g); let endOfBrowsers = actual.match(/End of Browser/g); if (vsizes.length == 4 && endOfBrowsers.length == 3) { diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 2f3c7b19d99a..c18a6bc87e6b 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -399,6 +399,20 @@ static nsresult GetVsizeMaxContiguous(int64_t* aN) return NS_OK; } +class VsizeMaxContiguousReporter MOZ_FINAL : public MemoryUniReporter +{ +public: + VsizeMaxContiguousReporter() + : MemoryUniReporter("vsize-max-contiguous", KIND_OTHER, UNITS_BYTES, +"Size of the maximum contiguous block of available virtual memory.") + {} + + NS_IMETHOD GetAmount(int64_t* aAmount) + { + return GetVsizeMaxContiguous(aAmount); + } +}; + #define HAVE_PRIVATE_REPORTER class PrivateReporter MOZ_FINAL : public MemoryUniReporter { @@ -776,6 +790,10 @@ nsMemoryReporterManager::Init() RegisterReporter(new ResidentReporter); #endif +#ifdef HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER + RegisterReporter(new VsizeMaxContiguousReporter); +#endif + #ifdef HAVE_RESIDENT_UNIQUE_REPORTER RegisterReporter(new ResidentUniqueReporter); #endif From 90b108526bb9963dd4cba6af1445986f54698885 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 18 Nov 2013 22:37:39 -0800 Subject: [PATCH 39/72] Bug 939385 (part 4) - Rename some distinguished amount functions. r=froydnj. --HG-- extra : rebase_source : 7aa40beaaf9f025f361d0a570a2f35d582a151c5 --- xpcom/base/nsMemoryReporterManager.cpp | 82 ++++++++++++++++---------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index c18a6bc87e6b..3b470b9ae162 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -59,19 +59,22 @@ static nsresult GetProcSelfStatmField(int aField, int64_t* aN) } #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult GetVsize(int64_t* aN) +static nsresult +VsizeDistinguishedAmount(int64_t* aN) { return GetProcSelfStatmField(0, aN); } -static nsresult GetResident(int64_t* aN) +static nsresult +ResidentDistinguishedAmount(int64_t* aN) { return GetProcSelfStatmField(1, aN); } -static nsresult GetResidentFast(int64_t* aN) +static nsresult +ResidentFastDistinguishedAmount(int64_t* aN) { - return GetResident(aN); + return ResidentDistinguishedAmount(aN); } #define HAVE_RESIDENT_UNIQUE_REPORTER @@ -172,7 +175,8 @@ static nsresult GetKinfoProcSelf(KINFO_PROC* aProc) } #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult GetVsize(int64_t* aN) +static nsresult +VsizeDistinguishedAmount(int64_t* aN) { KINFO_PROC proc; nsresult rv = GetKinfoProcSelf(&proc); @@ -182,7 +186,8 @@ static nsresult GetVsize(int64_t* aN) return rv; } -static nsresult GetResident(int64_t* aN) +static nsresult +ResidentDistinguishedAmount(int64_t* aN) { KINFO_PROC proc; nsresult rv = GetKinfoProcSelf(&proc); @@ -192,9 +197,10 @@ static nsresult GetResident(int64_t* aN) return rv; } -static nsresult GetResidentFast(int64_t* aN) +static nsresult +ResidentFastDistinguishedAmount(int64_t* aN) { - return GetResident(aN); + return ResidentDistinguishedAmount(aN); } #elif defined(SOLARIS) @@ -245,7 +251,8 @@ static void XMappingIter(int64_t& vsize, int64_t& resident) } #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult GetVsize(int64_t* aN) +static nsresult +VsizeDistinguishedAmount(int64_t* aN) { int64_t vsize, resident; XMappingIter(vsize, resident); @@ -256,7 +263,8 @@ static nsresult GetVsize(int64_t* aN) return NS_OK; } -static nsresult GetResident(int64_t* aN) +static nsresult +ResidentDistinguishedAmount(int64_t* aN) { int64_t vsize, resident; XMappingIter(vsize, resident); @@ -267,9 +275,10 @@ static nsresult GetResident(int64_t* aN) return NS_OK; } -static nsresult GetResidentFast(int64_t* aN) +static nsresult +ResidentFastDistinguishedAmount(int64_t* aN) { - return GetResident(aN); + return ResidentDistinguishedAmount(aN); } #elif defined(XP_MACOSX) @@ -289,7 +298,8 @@ static bool GetTaskBasicInfo(struct task_basic_info* aTi) // absurdly high, eg. 2GB+ even at start-up. But both 'top' and 'ps' report // it, so we might as well too. #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult GetVsize(int64_t* aN) +static nsresult +VsizeDistinguishedAmount(int64_t* aN) { task_basic_info ti; if (!GetTaskBasicInfo(&ti)) @@ -306,7 +316,7 @@ static nsresult GetVsize(int64_t* aN) // // Purging these pages can take a long time for some users (see bug 789975), // so we provide the option to get the RSS without purging first. -static nsresult GetResident(int64_t* aN, bool aDoPurge) +static nsresult ResidentDistinguishedAmountHelper(int64_t* aN, bool aDoPurge) { #ifdef HAVE_JEMALLOC_STATS if (aDoPurge) { @@ -323,14 +333,16 @@ static nsresult GetResident(int64_t* aN, bool aDoPurge) return NS_OK; } -static nsresult GetResidentFast(int64_t* aN) +static nsresult +ResidentFastDistinguishedAmount(int64_t* aN) { - return GetResident(aN, /* doPurge = */ false); + return ResidentDistinguishedAmountHelper(aN, /* doPurge = */ false); } -static nsresult GetResident(int64_t* aN) +static nsresult +ResidentDistinguishedAmount(int64_t* aN) { - return GetResident(aN, /* doPurge = */ true); + return ResidentDistinguishedAmountHelper(aN, /* doPurge = */ true); } #elif defined(XP_WIN) @@ -340,7 +352,8 @@ static nsresult GetResident(int64_t* aN) #include #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult GetVsize(int64_t* aN) +static nsresult +VsizeDistinguishedAmount(int64_t* aN) { MEMORYSTATUSEX s; s.dwLength = sizeof(s); @@ -353,7 +366,8 @@ static nsresult GetVsize(int64_t* aN) return NS_OK; } -static nsresult GetResident(int64_t* aN) +static nsresult +ResidentDistinguishedAmount(int64_t* aN) { PROCESS_MEMORY_COUNTERS pmc; pmc.cb = sizeof(PROCESS_MEMORY_COUNTERS); @@ -366,13 +380,15 @@ static nsresult GetResident(int64_t* aN) return NS_OK; } -static nsresult GetResidentFast(int64_t* aN) +static nsresult +ResidentFastDistinguishedAmount(int64_t* aN) { - return GetResident(aN); + return ResidentDistinguishedAmount(aN); } #define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1 -static nsresult GetVsizeMaxContiguous(int64_t* aN) +static nsresult +VsizeMaxContiguousDistinguishedAmount(int64_t* aN) { SIZE_T biggestRegion = 0; MEMORY_BASIC_INFORMATION vmemInfo = {0}; @@ -409,7 +425,7 @@ public: NS_IMETHOD GetAmount(int64_t* aAmount) { - return GetVsizeMaxContiguous(aAmount); + return VsizeMaxContiguousDistinguishedAmount(aAmount); } }; @@ -457,7 +473,10 @@ public: "resources used by the process.") {} - NS_IMETHOD GetAmount(int64_t* aAmount) { return GetVsize(aAmount); } + NS_IMETHOD GetAmount(int64_t* aAmount) + { + return VsizeDistinguishedAmount(aAmount); + } }; class ResidentReporter MOZ_FINAL : public MemoryUniReporter @@ -473,7 +492,10 @@ public: "time.") {} - NS_IMETHOD GetAmount(int64_t* aAmount) { return GetResident(aAmount); } + NS_IMETHOD GetAmount(int64_t* aAmount) + { + return ResidentDistinguishedAmount(aAmount); + } }; #endif // HAVE_VSIZE_AND_RESIDENT_REPORTERS @@ -1296,7 +1318,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetVsize(int64_t* aVsize) { #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS - return ::GetVsize(aVsize); + return VsizeDistinguishedAmount(aVsize); #else *aResident = 0; return NS_ERROR_NOT_AVAILABLE; @@ -1307,7 +1329,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetVsizeMaxContiguous(int64_t* aAmount) { #ifdef HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER - return ::GetVsizeMaxContiguous(aAmount); + return VsizeMaxContiguousDistinguishedAmount(aAmount); #else *aAmount = 0; return NS_ERROR_NOT_AVAILABLE; @@ -1318,7 +1340,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetResident(int64_t* aAmount) { #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS - return ::GetResident(aAmount); + return ResidentDistinguishedAmount(aAmount); #else *aAmount = 0; return NS_ERROR_NOT_AVAILABLE; @@ -1329,7 +1351,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetResidentFast(int64_t* aAmount) { #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS - return ::GetResidentFast(aAmount); + return ResidentFastDistinguishedAmount(aAmount); #else *aAmount = 0; return NS_ERROR_NOT_AVAILABLE; From d8cbe657a01becd82aa5dbd5376b9ee9ffc5a1c7 Mon Sep 17 00:00:00 2001 From: Tim Abraldes Date: Tue, 19 Nov 2013 01:55:07 -0800 Subject: [PATCH 40/72] bug 895581. Remove a mochitest-metro test that assumes double-tap should select; double-tap now causes a zoom instead. r=orange --- .../tests/mochitest/browser_selection_basic.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/browser/metro/base/tests/mochitest/browser_selection_basic.js b/browser/metro/base/tests/mochitest/browser_selection_basic.js index e2085e1944f2..90c3f5eaf513 100644 --- a/browser/metro/base/tests/mochitest/browser_selection_basic.js +++ b/browser/metro/base/tests/mochitest/browser_selection_basic.js @@ -62,21 +62,6 @@ gTests.push({ }, }); -gTests.push({ - desc: "double-tap to select", - setUp: setUpAndTearDown, - tearDown: setUpAndTearDown, - run: function test() { - sendDoubleTap(gWindow, 30, 20); - - yield waitForCondition(function () { - return SelectionHelperUI.isSelectionUIVisible; - }, kCommonWaitMs, kCommonPollMs); - - is(getTrimmedSelection(gWindow).toString(), "There", "selection test"); - }, -}); - gTests.push({ desc: "appbar interactions", setUp: setUpAndTearDown, From c66b5e35cec4e40ccd427fa828ac9404decab202 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 11:41:29 +0100 Subject: [PATCH 41/72] Backed out changeset e07cab8a2732 (bug 921478) for perma-orange on Mochitest-1 on B2G Linux Opt on a CLOSED TREE --HG-- rename : dom/contacts/tests/test_contacts_upgrade.xul => dom/contacts/tests/test_contacts_upgrade.html --- dom/contacts/tests/chrome.ini | 2 +- dom/contacts/tests/test_contacts_upgrade.html | 279 ++++++++++++++++++ dom/contacts/tests/test_contacts_upgrade.xul | 279 ------------------ dom/datastore/DataStore.jsm | 1 - dom/datastore/DataStoreDB.jsm | 1 - dom/indexedDB/IndexedDatabaseManager.cpp | 3 +- dom/indexedDB/test/unit/xpcshell.ini | 2 +- 7 files changed, 282 insertions(+), 285 deletions(-) create mode 100644 dom/contacts/tests/test_contacts_upgrade.html delete mode 100644 dom/contacts/tests/test_contacts_upgrade.xul diff --git a/dom/contacts/tests/chrome.ini b/dom/contacts/tests/chrome.ini index 073b9ace36b1..3ed06c21260d 100644 --- a/dom/contacts/tests/chrome.ini +++ b/dom/contacts/tests/chrome.ini @@ -1,3 +1,3 @@ [DEFAULT] -[test_contacts_upgrade.xul] +[test_contacts_upgrade.html] diff --git a/dom/contacts/tests/test_contacts_upgrade.html b/dom/contacts/tests/test_contacts_upgrade.html new file mode 100644 index 000000000000..b271fe655199 --- /dev/null +++ b/dom/contacts/tests/test_contacts_upgrade.html @@ -0,0 +1,279 @@ + + + + + Test for Bug 889239 + + + + + + +Mozilla Bug 889239 +

+ +
+
+
+ + diff --git a/dom/contacts/tests/test_contacts_upgrade.xul b/dom/contacts/tests/test_contacts_upgrade.xul deleted file mode 100644 index c9b90d111e4d..000000000000 --- a/dom/contacts/tests/test_contacts_upgrade.xul +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - - - - - Mozilla Bug 889239 - - diff --git a/dom/datastore/DataStore.jsm b/dom/datastore/DataStore.jsm index afe1a2645f1d..f6b3ad6b6d0f 100644 --- a/dom/datastore/DataStore.jsm +++ b/dom/datastore/DataStore.jsm @@ -28,7 +28,6 @@ Cu.import("resource://gre/modules/DataStoreDB.jsm"); Cu.import("resource://gre/modules/ObjectWrapper.jsm"); Cu.import('resource://gre/modules/Services.jsm'); Cu.import('resource://gre/modules/XPCOMUtils.jsm'); -Cu.importGlobalProperties(["indexedDB"]); XPCOMUtils.defineLazyServiceGetter(this, "cpmm", "@mozilla.org/childprocessmessagemanager;1", diff --git a/dom/datastore/DataStoreDB.jsm b/dom/datastore/DataStoreDB.jsm index bf5383550754..75c3fdb8af17 100644 --- a/dom/datastore/DataStoreDB.jsm +++ b/dom/datastore/DataStoreDB.jsm @@ -19,7 +19,6 @@ const DATASTOREDB_REVISION_INDEX = 'revisionIndex'; Cu.import('resource://gre/modules/IndexedDBHelper.jsm'); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.importGlobalProperties(["indexedDB"]); XPCOMUtils.defineLazyServiceGetter(this, "uuidgen", "@mozilla.org/uuid-generator;1", diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index 90cf85144086..aefb62cccf4d 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -425,8 +425,7 @@ IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx, !IDBOpenDBRequestBinding::GetConstructorObject(aCx, aGlobal) || !IDBRequestBinding::GetConstructorObject(aCx, aGlobal) || !IDBTransactionBinding::GetConstructorObject(aCx, aGlobal) || - !IDBVersionChangeEventBinding::GetConstructorObject(aCx, aGlobal)) - { + !IDBVersionChangeEventBinding::GetConstructorObject(aCx, aGlobal)) { return false; } diff --git a/dom/indexedDB/test/unit/xpcshell.ini b/dom/indexedDB/test/unit/xpcshell.ini index 7f9a8a54b12f..d3e19e5e52cf 100644 --- a/dom/indexedDB/test/unit/xpcshell.ini +++ b/dom/indexedDB/test/unit/xpcshell.ini @@ -30,7 +30,7 @@ support-files = [test_getAll.js] [test_globalObjects_ipc.js] # FIXME/bug 575918: out-of-process xpcshell is broken on OS X -skip-if = os == "mac" || os == "android" +#skip-if = os == "mac" || os == "android" [test_globalObjects_other.js] [test_globalObjects_xpc.js] [test_global_data.js] From 45514699865c8d1810b2570050316863433c9f00 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 11:41:52 +0100 Subject: [PATCH 42/72] Backed out changeset 5cda44ae1ba0 (bug 921478) for perma-orange on Mochitest-1 on B2G Linux Opt on a CLOSED TREE --HG-- rename : dom/indexedDB/test/test_globalObjects_content.html => dom/indexedDB/test/test_globalObjects.html rename : dom/indexedDB/test/test_globalObjects_chrome.xul => dom/indexedDB/test/test_globalObjects.xul rename : dom/indexedDB/test/unit/test_globalObjects_xpc.js => dom/indexedDB/test/unit/test_globalObjects.js --- dom/base/IndexedDBHelper.jsm | 1 - dom/contacts/fallback/ContactDB.jsm | 1 - dom/contacts/tests/test_contacts_upgrade.html | 1 - dom/indexedDB/IndexedDatabaseManager.cpp | 183 +++++++++++++++--- dom/indexedDB/IndexedDatabaseManager.h | 12 +- dom/indexedDB/test/chrome.ini | 3 +- dom/indexedDB/test/chromeHelpers.js | 12 +- dom/indexedDB/test/mochitest.ini | 2 +- ...s_content.html => test_globalObjects.html} | 0 ...jects_other.xul => test_globalObjects.xul} | 20 +- .../test/test_globalObjects_chrome.xul | 43 ---- dom/indexedDB/test/unit/GlobalObjectsChild.js | 2 - .../test/unit/GlobalObjectsComponent.js | 5 +- .../test/unit/GlobalObjectsModule.jsm | 2 - dom/indexedDB/test/unit/head.js | 18 +- dom/indexedDB/test/unit/mochitest.ini | 3 +- ...Objects_other.js => test_globalObjects.js} | 21 +- .../test/unit/test_globalObjects_xpc.js | 26 --- dom/indexedDB/test/unit/xpcshell.ini | 5 +- .../src/gonk/MobileMessageDatabaseService.js | 1 - dom/network/src/NetworkStatsDB.jsm | 1 - dom/push/src/PushService.jsm | 1 - js/xpconnect/src/Sandbox.cpp | 3 +- js/xpconnect/src/XPCRuntimeService.cpp | 10 + js/xpconnect/src/nsXPConnect.cpp | 7 + 25 files changed, 231 insertions(+), 152 deletions(-) rename dom/indexedDB/test/{test_globalObjects_content.html => test_globalObjects.html} (100%) rename dom/indexedDB/test/{test_globalObjects_other.xul => test_globalObjects.xul} (82%) delete mode 100644 dom/indexedDB/test/test_globalObjects_chrome.xul rename dom/indexedDB/test/unit/{test_globalObjects_other.js => test_globalObjects.js} (81%) delete mode 100644 dom/indexedDB/test/unit/test_globalObjects_xpc.js diff --git a/dom/base/IndexedDBHelper.jsm b/dom/base/IndexedDBHelper.jsm index 1a4302996cfc..818921ff50af 100644 --- a/dom/base/IndexedDBHelper.jsm +++ b/dom/base/IndexedDBHelper.jsm @@ -20,7 +20,6 @@ this.EXPORTED_SYMBOLS = ["IndexedDBHelper"]; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -Cu.importGlobalProperties(["indexedDB"]); this.IndexedDBHelper = function IndexedDBHelper() {} diff --git a/dom/contacts/fallback/ContactDB.jsm b/dom/contacts/fallback/ContactDB.jsm index 52ec9f3118c0..c0db32c36fe4 100644 --- a/dom/contacts/fallback/ContactDB.jsm +++ b/dom/contacts/fallback/ContactDB.jsm @@ -18,7 +18,6 @@ const Ci = Components.interfaces; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); Cu.import("resource://gre/modules/PhoneNumberUtils.jsm"); -Cu.importGlobalProperties(["indexedDB"]); const DB_NAME = "contacts"; const DB_VERSION = 18; diff --git a/dom/contacts/tests/test_contacts_upgrade.html b/dom/contacts/tests/test_contacts_upgrade.html index b271fe655199..b4438292aaa2 100644 --- a/dom/contacts/tests/test_contacts_upgrade.html +++ b/dom/contacts/tests/test_contacts_upgrade.html @@ -148,7 +148,6 @@ function makeFailure(reason) { const {Cc, Ci, Cu} = SpecialPowers; Cu.import("resource://gre/modules/ContactDB.jsm", window); -Cu.importGlobalProperties(["indexedDB"]); let cdb = new ContactDB(); cdb.init(); diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index aefb62cccf4d..67fb0b19cbc2 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -111,6 +111,35 @@ mozilla::StaticRefPtr gInstance; mozilla::Atomic gInitialized(0); mozilla::Atomic gClosed(0); +// See ResolveConstructors below. +struct ConstructorInfo { + const char* const name; + JS::Handle (* const resolve)(JSContext*, JS::Handle, + bool); + jsid id; +}; + +ConstructorInfo gConstructorInfo[] = { + +#define BINDING_ENTRY(_name) \ + { #_name, _name##Binding::GetConstructorObject, JSID_VOID }, + + BINDING_ENTRY(IDBCursor) + BINDING_ENTRY(IDBCursorWithValue) + BINDING_ENTRY(IDBDatabase) + BINDING_ENTRY(IDBFactory) + BINDING_ENTRY(IDBFileHandle) + BINDING_ENTRY(IDBIndex) + BINDING_ENTRY(IDBKeyRange) + BINDING_ENTRY(IDBObjectStore) + BINDING_ENTRY(IDBOpenDBRequest) + BINDING_ENTRY(IDBRequest) + BINDING_ENTRY(IDBTransaction) + BINDING_ENTRY(IDBVersionChangeEvent) + +#undef BINDING_ENTRY +}; + class AsyncDeleteFileRunnable MOZ_FINAL : public nsIRunnable { public: @@ -178,6 +207,53 @@ struct MOZ_STACK_CLASS InvalidateInfo const nsACString& pattern; }; +bool +GetIndexedDB(JSContext* aCx, JS::Handle aGlobal, + JS::MutableHandle aResult) +{ + MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); + MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, + "Not a global object!"); + + nsRefPtr factory; + if (NS_FAILED(IDBFactory::Create(aCx, aGlobal, nullptr, + getter_AddRefs(factory)))) { + return false; + } + + MOZ_ASSERT(factory, "This should never fail for chrome!"); + + return !!WrapNewBindingObject(aCx, aGlobal, factory, aResult); +} + +bool +IndexedDBLazyGetter(JSContext* aCx, JS::Handle aGlobal, + JS::Handle aId, JS::MutableHandle aVp) +{ + MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); + MOZ_ASSERT(JSID_IS_STRING(aId), "Bad id!"); + MOZ_ASSERT(JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(aId), IDB_STR), + "Bad id!"); + + JS::Rooted global(aCx, CheckedUnwrap(aGlobal, + /* stopAtOuter = */ false)); + NS_ENSURE_TRUE(global, false); + NS_ENSURE_TRUE(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL, false); + + JS::Rooted indexedDB(aCx); + if (!GetIndexedDB(aCx, global, &indexedDB)) { + return false; + } + + if (!JS_DefinePropertyById(aCx, global, aId, indexedDB, nullptr, nullptr, + JSPROP_ENUMERATE)) { + return false; + } + + aVp.set(indexedDB); + return true; +} + } // anonymous namespace IndexedDatabaseManager::IndexedDatabaseManager() @@ -406,39 +482,32 @@ IndexedDatabaseManager::TabContextMayAccessOrigin(const TabContext& aContext, // static bool -IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx, - JS::Handle aGlobal) +IndexedDatabaseManager::DefineConstructors(JSContext* aCx, + JS::Handle aGlobal) +{ + MOZ_ASSERT(NS_IsMainThread()); + + for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { + if (!gConstructorInfo[i].resolve(aCx, aGlobal, true)) { + return false; + } + } + + return true; +} + +// static +bool +IndexedDatabaseManager::DefineIndexedDBGetter(JSContext* aCx, + JS::Handle aGlobal) { MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, "Passed object is not a global object!"); - if (!IDBCursorBinding::GetConstructorObject(aCx, aGlobal) || - !IDBCursorWithValueBinding::GetConstructorObject(aCx, aGlobal) || - !IDBDatabaseBinding::GetConstructorObject(aCx, aGlobal) || - !IDBFactoryBinding::GetConstructorObject(aCx, aGlobal) || - !IDBFileHandleBinding::GetConstructorObject(aCx, aGlobal) || - !IDBIndexBinding::GetConstructorObject(aCx, aGlobal) || - !IDBKeyRangeBinding::GetConstructorObject(aCx, aGlobal) || - !IDBObjectStoreBinding::GetConstructorObject(aCx, aGlobal) || - !IDBOpenDBRequestBinding::GetConstructorObject(aCx, aGlobal) || - !IDBRequestBinding::GetConstructorObject(aCx, aGlobal) || - !IDBTransactionBinding::GetConstructorObject(aCx, aGlobal) || - !IDBVersionChangeEventBinding::GetConstructorObject(aCx, aGlobal)) { - return false; - } - - nsRefPtr factory; - if (NS_FAILED(IDBFactory::Create(aCx, aGlobal, nullptr, - getter_AddRefs(factory)))) { - return false; - } - - MOZ_ASSERT(factory, "This should never fail for chrome!"); - JS::Rooted indexedDB(aCx); - if (!WrapNewBindingObject(aCx, aGlobal, factory, &indexedDB)) { + if (!GetIndexedDB(aCx, aGlobal, &indexedDB)) { return false; } @@ -446,6 +515,20 @@ IndexedDatabaseManager::DefineIndexedDB(JSContext* aCx, JSPROP_ENUMERATE); } +// static +bool +IndexedDatabaseManager::DefineIndexedDBLazyGetter(JSContext* aCx, + JS::Handle aGlobal) +{ + MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(nsContentUtils::IsCallerChrome(), "Only for chrome!"); + MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL, + "Passed object is not a global object!"); + + return JS_DefineProperty(aCx, aGlobal, IDB_STR, JSVAL_VOID, + IndexedDBLazyGetter, nullptr, 0); +} + // static bool IndexedDatabaseManager::IsClosed() @@ -666,7 +749,7 @@ IndexedDatabaseManager::InitWindowless(const jsval& aGlobal, JSContext* aCx) return NS_ERROR_FAILURE; } - if (!DefineIndexedDB(aCx, global)) { + if (!DefineConstructors(aCx, global) || !DefineIndexedDBGetter(aCx, global)) { return NS_ERROR_FAILURE; } @@ -918,3 +1001,49 @@ GetFileReferencesHelper::Run() return NS_OK; } + +BEGIN_INDEXEDDB_NAMESPACE + +bool +ResolveConstructors(JSContext* aCx, JS::Handle aObj, + JS::Handle aId, JS::MutableHandle aObjp) +{ + MOZ_ASSERT(NS_IsMainThread()); + + // The first time this function is called we need to intern all the strings we + // care about. + if (JSID_IS_VOID(gConstructorInfo[0].id)) { + for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { + JS::Rooted str(aCx, + JS_InternString(aCx, gConstructorInfo[i].name)); + if (!str) { + NS_WARNING("Failed to intern string!"); + while (i) { + gConstructorInfo[--i].id = JSID_VOID; + } + return false; + } + gConstructorInfo[i].id = INTERNED_STRING_TO_JSID(aCx, str); + } + } + + // Now resolve. + for (uint32_t i = 0; i < mozilla::ArrayLength(gConstructorInfo); i++) { + if (gConstructorInfo[i].id == aId) { + JS::Rooted constructor(aCx, + gConstructorInfo[i].resolve(aCx, aObj, true)); + if (!constructor) { + return false; + } + + aObjp.set(aObj); + return true; + } + } + + // Not resolved. + aObjp.set(nullptr); + return true; +} + +END_INDEXEDDB_NAMESPACE diff --git a/dom/indexedDB/IndexedDatabaseManager.h b/dom/indexedDB/IndexedDatabaseManager.h index c3ec871fa07d..e81236fbc7bb 100644 --- a/dom/indexedDB/IndexedDatabaseManager.h +++ b/dom/indexedDB/IndexedDatabaseManager.h @@ -140,7 +140,13 @@ public: const nsACString& aOrigin); static bool - DefineIndexedDB(JSContext* aCx, JS::Handle aGlobal); + DefineConstructors(JSContext* aCx, JS::Handle aGlobal); + + static bool + DefineIndexedDBGetter(JSContext* aCx, JS::Handle aGlobal); + + static bool + DefineIndexedDBLazyGetter(JSContext* aCx, JS::Handle aGlobal); private: IndexedDatabaseManager(); @@ -170,6 +176,10 @@ private: static mozilla::Atomic sLowDiskSpaceMode; }; +bool +ResolveConstructors(JSContext* aCx, JS::Handle aObj, + JS::Handle aId, JS::MutableHandle aObjp); + END_INDEXEDDB_NAMESPACE #endif /* mozilla_dom_indexeddb_indexeddatabasemanager_h__ */ diff --git a/dom/indexedDB/test/chrome.ini b/dom/indexedDB/test/chrome.ini index a809b45b5d1f..636a72c429dd 100644 --- a/dom/indexedDB/test/chrome.ini +++ b/dom/indexedDB/test/chrome.ini @@ -1,5 +1,4 @@ [DEFAULT] support-files = chromeHelpers.js -[test_globalObjects_chrome.xul] -[test_globalObjects_other.xul] +[test_globalObjects.xul] diff --git a/dom/indexedDB/test/chromeHelpers.js b/dom/indexedDB/test/chromeHelpers.js index cb86f2747ec6..1233661060bb 100644 --- a/dom/indexedDB/test/chromeHelpers.js +++ b/dom/indexedDB/test/chromeHelpers.js @@ -7,15 +7,11 @@ const { 'classes': Cc, 'interfaces': Ci, 'utils': Cu } = Components; let testGenerator = testSteps(); -if (!window.runTest) { - window.runTest = function() - { - Cu.importGlobalProperties(["indexedDB"]); +function runTest() +{ + SimpleTest.waitForExplicitFinish(); - SimpleTest.waitForExplicitFinish(); - - testGenerator.next(); - } + testGenerator.next(); } function finishTest() diff --git a/dom/indexedDB/test/mochitest.ini b/dom/indexedDB/test/mochitest.ini index 4f9e4b9eae3c..54783fece01c 100644 --- a/dom/indexedDB/test/mochitest.ini +++ b/dom/indexedDB/test/mochitest.ini @@ -58,7 +58,7 @@ support-files = [test_filehandle_store_snapshot.html] [test_getAll.html] [test_get_filehandle.html] -[test_globalObjects_content.html] +[test_globalObjects.html] [test_global_data.html] [test_index_empty_keyPath.html] [test_index_getAll.html] diff --git a/dom/indexedDB/test/test_globalObjects_content.html b/dom/indexedDB/test/test_globalObjects.html similarity index 100% rename from dom/indexedDB/test/test_globalObjects_content.html rename to dom/indexedDB/test/test_globalObjects.html diff --git a/dom/indexedDB/test/test_globalObjects_other.xul b/dom/indexedDB/test/test_globalObjects.xul similarity index 82% rename from dom/indexedDB/test/test_globalObjects_other.xul rename to dom/indexedDB/test/test_globalObjects.xul index cfab5deace9d..c3d2520a2c70 100644 --- a/dom/indexedDB/test/test_globalObjects_other.xul +++ b/dom/indexedDB/test/test_globalObjects.xul @@ -14,6 +14,20 @@ diff --git a/dom/indexedDB/test/test_globalObjects_chrome.xul b/dom/indexedDB/test/test_globalObjects_chrome.xul deleted file mode 100644 index 47e967d9692e..000000000000 --- a/dom/indexedDB/test/test_globalObjects_chrome.xul +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - Mozilla Bug 832883 - - diff --git a/dom/indexedDB/test/unit/GlobalObjectsChild.js b/dom/indexedDB/test/unit/GlobalObjectsChild.js index 5351ff2f1a9a..586d27f7b4f4 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsChild.js +++ b/dom/indexedDB/test/unit/GlobalObjectsChild.js @@ -18,8 +18,6 @@ function finishTest() function run_test() { const name = "Splendid Test"; - Cu.importGlobalProperties(["indexedDB"]); - do_test_pending(); let keyRange = IDBKeyRange.only(42); diff --git a/dom/indexedDB/test/unit/GlobalObjectsComponent.js b/dom/indexedDB/test/unit/GlobalObjectsComponent.js index 44bc1afe9b69..01c3e23dafc8 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsComponent.js +++ b/dom/indexedDB/test/unit/GlobalObjectsComponent.js @@ -3,10 +3,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -const Cu = Components.utils; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.importGlobalProperties(["indexedDB"]); +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); function GlobalObjectsComponent() { this.wrappedJSObject = this; diff --git a/dom/indexedDB/test/unit/GlobalObjectsModule.jsm b/dom/indexedDB/test/unit/GlobalObjectsModule.jsm index fe214f722e72..cb085b6f3355 100644 --- a/dom/indexedDB/test/unit/GlobalObjectsModule.jsm +++ b/dom/indexedDB/test/unit/GlobalObjectsModule.jsm @@ -3,8 +3,6 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ -Components.utils.importGlobalProperties(["indexedDB"]); - this.EXPORTED_SYMBOLS = [ "GlobalObjectsModule" ]; diff --git a/dom/indexedDB/test/unit/head.js b/dom/indexedDB/test/unit/head.js index 1ec20b3463e0..b3757ec25bb3 100644 --- a/dom/indexedDB/test/unit/head.js +++ b/dom/indexedDB/test/unit/head.js @@ -38,19 +38,15 @@ function run_test() { runTest(); }; -if (!this.runTest) { - this.runTest = function() - { - // XPCShell does not get a profile by default. - do_get_profile(); +function runTest() +{ + // XPCShell does not get a profile by default. + do_get_profile(); - enableExperimental(); + enableExperimental(); - Cu.importGlobalProperties(["indexedDB"]); - - do_test_pending(); - testGenerator.next(); - } + do_test_pending(); + testGenerator.next(); } function finishTest() diff --git a/dom/indexedDB/test/unit/mochitest.ini b/dom/indexedDB/test/unit/mochitest.ini index e0fcdf40d12a..e2823e9587f4 100644 --- a/dom/indexedDB/test/unit/mochitest.ini +++ b/dom/indexedDB/test/unit/mochitest.ini @@ -18,9 +18,8 @@ [test_deleteDatabase_interactions.js] [test_event_source.js] [test_getAll.js] +[test_globalObjects.js] [test_globalObjects_ipc.js] -[test_globalObjects_other.js] -[test_globalObjects_xpc.js] [test_global_data.js] [test_index_empty_keyPath.js] [test_index_getAll.js] diff --git a/dom/indexedDB/test/unit/test_globalObjects_other.js b/dom/indexedDB/test/unit/test_globalObjects.js similarity index 81% rename from dom/indexedDB/test/unit/test_globalObjects_other.js rename to dom/indexedDB/test/unit/test_globalObjects.js index a1338459c83b..40ae45fcd0f1 100644 --- a/dom/indexedDB/test/unit/test_globalObjects_other.js +++ b/dom/indexedDB/test/unit/test_globalObjects.js @@ -7,6 +7,8 @@ var testGenerator = testSteps(); function testSteps() { + const name = "Splendid Test"; + let ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); @@ -16,6 +18,18 @@ function testSteps() return uri.spec; } + // Test for IDBKeyRange and indexedDB availability in xpcshell. + let keyRange = IDBKeyRange.only(42); + ok(keyRange, "Got keyRange"); + + let request = indexedDB.open(name, 1); + request.onerror = errorHandler; + request.onsuccess = grabEventAndContinueHandler; + let event = yield undefined; + + let db = event.target.result; + ok(db, "Got database"); + // Test for IDBKeyRange and indexedDB availability in JS modules. Cu.import(getSpec("GlobalObjectsModule.jsm")); let test = new GlobalObjectsModule(); @@ -51,10 +65,3 @@ function testSteps() finishTest(); yield undefined; } - -this.runTest = function() { - do_get_profile(); - - do_test_pending(); - testGenerator.next(); -} diff --git a/dom/indexedDB/test/unit/test_globalObjects_xpc.js b/dom/indexedDB/test/unit/test_globalObjects_xpc.js deleted file mode 100644 index 57611d046900..000000000000 --- a/dom/indexedDB/test/unit/test_globalObjects_xpc.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -var testGenerator = testSteps(); - -function testSteps() -{ - const name = "Splendid Test"; - - // Test for IDBKeyRange and indexedDB availability in xpcshell. - let keyRange = IDBKeyRange.only(42); - ok(keyRange, "Got keyRange"); - - let request = indexedDB.open(name, 1); - request.onerror = errorHandler; - request.onsuccess = grabEventAndContinueHandler; - let event = yield undefined; - - let db = event.target.result; - ok(db, "Got database"); - - finishTest(); - yield undefined; -} diff --git a/dom/indexedDB/test/unit/xpcshell.ini b/dom/indexedDB/test/unit/xpcshell.ini index d3e19e5e52cf..fdfedcedb64e 100644 --- a/dom/indexedDB/test/unit/xpcshell.ini +++ b/dom/indexedDB/test/unit/xpcshell.ini @@ -28,11 +28,10 @@ support-files = [test_deleteDatabase_interactions.js] [test_event_source.js] [test_getAll.js] +[test_globalObjects.js] [test_globalObjects_ipc.js] # FIXME/bug 575918: out-of-process xpcshell is broken on OS X -#skip-if = os == "mac" || os == "android" -[test_globalObjects_other.js] -[test_globalObjects_xpc.js] +skip-if = os == "mac" || os == "android" [test_global_data.js] [test_index_empty_keyPath.js] [test_index_getAll.js] diff --git a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js index 918a8d1f853a..e17a37c63f27 100644 --- a/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js +++ b/dom/mobilemessage/src/gonk/MobileMessageDatabaseService.js @@ -9,7 +9,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/PhoneNumberUtils.jsm"); -Cu.importGlobalProperties(["indexedDB"]); const RIL_MOBILEMESSAGEDATABASESERVICE_CONTRACTID = "@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"; diff --git a/dom/network/src/NetworkStatsDB.jsm b/dom/network/src/NetworkStatsDB.jsm index c8e64347cbf1..3d22ef9ca139 100644 --- a/dom/network/src/NetworkStatsDB.jsm +++ b/dom/network/src/NetworkStatsDB.jsm @@ -13,7 +13,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); -Cu.importGlobalProperties(["indexedDB"]); const DB_NAME = "net_stats"; const DB_VERSION = 3; diff --git a/dom/push/src/PushService.jsm b/dom/push/src/PushService.jsm index ae22aabf6fb1..92295580a36c 100644 --- a/dom/push/src/PushService.jsm +++ b/dom/push/src/PushService.jsm @@ -23,7 +23,6 @@ Cu.import("resource://gre/modules/IndexedDBHelper.jsm"); Cu.import("resource://gre/modules/Timer.jsm"); Cu.import("resource://gre/modules/Preferences.jsm"); Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js"); -Cu.importGlobalProperties(["indexedDB"]); XPCOMUtils.defineLazyModuleGetter(this, "AlarmService", "resource://gre/modules/AlarmService.jsm"); diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index aaeacde6ea70..fbe0c506b67a 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -948,7 +948,8 @@ bool xpc::GlobalProperties::Define(JSContext *cx, JS::HandleObject obj) { if (indexedDB && AccessCheck::isChrome(obj) && - !IndexedDatabaseManager::DefineIndexedDB(cx, obj)) + (!IndexedDatabaseManager::DefineConstructors(cx, obj) || + !IndexedDatabaseManager::DefineIndexedDBGetter(cx, obj))) return false; if (XMLHttpRequest && diff --git a/js/xpconnect/src/XPCRuntimeService.cpp b/js/xpconnect/src/XPCRuntimeService.cpp index 5499df49cac7..188a15c98aad 100644 --- a/js/xpconnect/src/XPCRuntimeService.cpp +++ b/js/xpconnect/src/XPCRuntimeService.cpp @@ -10,9 +10,11 @@ #include "nsDOMClassInfo.h" #include "nsIPrincipal.h" +#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h" #include "mozilla/dom/workers/Workers.h" using mozilla::dom::workers::ResolveWorkerClasses; +namespace indexedDB = mozilla::dom::indexedDB; NS_INTERFACE_MAP_BEGIN(BackstagePass) NS_INTERFACE_MAP_ENTRY(nsIGlobalObject) @@ -73,6 +75,14 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper, return NS_OK; } + *_retval = indexedDB::ResolveConstructors(cx, obj, id, &objp); + NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE); + + if (objp) { + *objpArg = objp; + return NS_OK; + } + return NS_OK; } diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index f730f7e2fea0..ba6235a08c0b 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -515,6 +515,7 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL); // Init WebIDL binding constructors wanted on all XPConnect globals. + // Additional bindings may be created lazily, see BackstagePass::NewResolve. // // XXX Please do not add any additional classes here without the approval of // the XPConnect module owner. @@ -524,6 +525,12 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext, return UnexpectedFailure(NS_ERROR_FAILURE); } + if (nsContentUtils::IsSystemPrincipal(aPrincipal) && + !IndexedDatabaseManager::DefineIndexedDBLazyGetter(aJSContext, + global)) { + return UnexpectedFailure(NS_ERROR_FAILURE); + } + wrappedGlobal.forget(_retval); return NS_OK; } From bf78efbbd3d057b8e9d2c1b3e6edd01029ff4daf Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 11:47:30 +0100 Subject: [PATCH 43/72] Backed out changeset 027fced104dc (bug 939385) for perma failures/orange in XPCShell Tests on Linux and OS X on a CLOSED TREE --- xpcom/base/nsMemoryReporterManager.cpp | 82 ++++++++++---------------- 1 file changed, 30 insertions(+), 52 deletions(-) diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 3b470b9ae162..c18a6bc87e6b 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -59,22 +59,19 @@ static nsresult GetProcSelfStatmField(int aField, int64_t* aN) } #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult -VsizeDistinguishedAmount(int64_t* aN) +static nsresult GetVsize(int64_t* aN) { return GetProcSelfStatmField(0, aN); } -static nsresult -ResidentDistinguishedAmount(int64_t* aN) +static nsresult GetResident(int64_t* aN) { return GetProcSelfStatmField(1, aN); } -static nsresult -ResidentFastDistinguishedAmount(int64_t* aN) +static nsresult GetResidentFast(int64_t* aN) { - return ResidentDistinguishedAmount(aN); + return GetResident(aN); } #define HAVE_RESIDENT_UNIQUE_REPORTER @@ -175,8 +172,7 @@ static nsresult GetKinfoProcSelf(KINFO_PROC* aProc) } #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult -VsizeDistinguishedAmount(int64_t* aN) +static nsresult GetVsize(int64_t* aN) { KINFO_PROC proc; nsresult rv = GetKinfoProcSelf(&proc); @@ -186,8 +182,7 @@ VsizeDistinguishedAmount(int64_t* aN) return rv; } -static nsresult -ResidentDistinguishedAmount(int64_t* aN) +static nsresult GetResident(int64_t* aN) { KINFO_PROC proc; nsresult rv = GetKinfoProcSelf(&proc); @@ -197,10 +192,9 @@ ResidentDistinguishedAmount(int64_t* aN) return rv; } -static nsresult -ResidentFastDistinguishedAmount(int64_t* aN) +static nsresult GetResidentFast(int64_t* aN) { - return ResidentDistinguishedAmount(aN); + return GetResident(aN); } #elif defined(SOLARIS) @@ -251,8 +245,7 @@ static void XMappingIter(int64_t& vsize, int64_t& resident) } #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult -VsizeDistinguishedAmount(int64_t* aN) +static nsresult GetVsize(int64_t* aN) { int64_t vsize, resident; XMappingIter(vsize, resident); @@ -263,8 +256,7 @@ VsizeDistinguishedAmount(int64_t* aN) return NS_OK; } -static nsresult -ResidentDistinguishedAmount(int64_t* aN) +static nsresult GetResident(int64_t* aN) { int64_t vsize, resident; XMappingIter(vsize, resident); @@ -275,10 +267,9 @@ ResidentDistinguishedAmount(int64_t* aN) return NS_OK; } -static nsresult -ResidentFastDistinguishedAmount(int64_t* aN) +static nsresult GetResidentFast(int64_t* aN) { - return ResidentDistinguishedAmount(aN); + return GetResident(aN); } #elif defined(XP_MACOSX) @@ -298,8 +289,7 @@ static bool GetTaskBasicInfo(struct task_basic_info* aTi) // absurdly high, eg. 2GB+ even at start-up. But both 'top' and 'ps' report // it, so we might as well too. #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult -VsizeDistinguishedAmount(int64_t* aN) +static nsresult GetVsize(int64_t* aN) { task_basic_info ti; if (!GetTaskBasicInfo(&ti)) @@ -316,7 +306,7 @@ VsizeDistinguishedAmount(int64_t* aN) // // Purging these pages can take a long time for some users (see bug 789975), // so we provide the option to get the RSS without purging first. -static nsresult ResidentDistinguishedAmountHelper(int64_t* aN, bool aDoPurge) +static nsresult GetResident(int64_t* aN, bool aDoPurge) { #ifdef HAVE_JEMALLOC_STATS if (aDoPurge) { @@ -333,16 +323,14 @@ static nsresult ResidentDistinguishedAmountHelper(int64_t* aN, bool aDoPurge) return NS_OK; } -static nsresult -ResidentFastDistinguishedAmount(int64_t* aN) +static nsresult GetResidentFast(int64_t* aN) { - return ResidentDistinguishedAmountHelper(aN, /* doPurge = */ false); + return GetResident(aN, /* doPurge = */ false); } -static nsresult -ResidentDistinguishedAmount(int64_t* aN) +static nsresult GetResident(int64_t* aN) { - return ResidentDistinguishedAmountHelper(aN, /* doPurge = */ true); + return GetResident(aN, /* doPurge = */ true); } #elif defined(XP_WIN) @@ -352,8 +340,7 @@ ResidentDistinguishedAmount(int64_t* aN) #include #define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1 -static nsresult -VsizeDistinguishedAmount(int64_t* aN) +static nsresult GetVsize(int64_t* aN) { MEMORYSTATUSEX s; s.dwLength = sizeof(s); @@ -366,8 +353,7 @@ VsizeDistinguishedAmount(int64_t* aN) return NS_OK; } -static nsresult -ResidentDistinguishedAmount(int64_t* aN) +static nsresult GetResident(int64_t* aN) { PROCESS_MEMORY_COUNTERS pmc; pmc.cb = sizeof(PROCESS_MEMORY_COUNTERS); @@ -380,15 +366,13 @@ ResidentDistinguishedAmount(int64_t* aN) return NS_OK; } -static nsresult -ResidentFastDistinguishedAmount(int64_t* aN) +static nsresult GetResidentFast(int64_t* aN) { - return ResidentDistinguishedAmount(aN); + return GetResident(aN); } #define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1 -static nsresult -VsizeMaxContiguousDistinguishedAmount(int64_t* aN) +static nsresult GetVsizeMaxContiguous(int64_t* aN) { SIZE_T biggestRegion = 0; MEMORY_BASIC_INFORMATION vmemInfo = {0}; @@ -425,7 +409,7 @@ public: NS_IMETHOD GetAmount(int64_t* aAmount) { - return VsizeMaxContiguousDistinguishedAmount(aAmount); + return GetVsizeMaxContiguous(aAmount); } }; @@ -473,10 +457,7 @@ public: "resources used by the process.") {} - NS_IMETHOD GetAmount(int64_t* aAmount) - { - return VsizeDistinguishedAmount(aAmount); - } + NS_IMETHOD GetAmount(int64_t* aAmount) { return GetVsize(aAmount); } }; class ResidentReporter MOZ_FINAL : public MemoryUniReporter @@ -492,10 +473,7 @@ public: "time.") {} - NS_IMETHOD GetAmount(int64_t* aAmount) - { - return ResidentDistinguishedAmount(aAmount); - } + NS_IMETHOD GetAmount(int64_t* aAmount) { return GetResident(aAmount); } }; #endif // HAVE_VSIZE_AND_RESIDENT_REPORTERS @@ -1318,7 +1296,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetVsize(int64_t* aVsize) { #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS - return VsizeDistinguishedAmount(aVsize); + return ::GetVsize(aVsize); #else *aResident = 0; return NS_ERROR_NOT_AVAILABLE; @@ -1329,7 +1307,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetVsizeMaxContiguous(int64_t* aAmount) { #ifdef HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER - return VsizeMaxContiguousDistinguishedAmount(aAmount); + return ::GetVsizeMaxContiguous(aAmount); #else *aAmount = 0; return NS_ERROR_NOT_AVAILABLE; @@ -1340,7 +1318,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetResident(int64_t* aAmount) { #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS - return ResidentDistinguishedAmount(aAmount); + return ::GetResident(aAmount); #else *aAmount = 0; return NS_ERROR_NOT_AVAILABLE; @@ -1351,7 +1329,7 @@ NS_IMETHODIMP nsMemoryReporterManager::GetResidentFast(int64_t* aAmount) { #ifdef HAVE_VSIZE_AND_RESIDENT_REPORTERS - return ResidentFastDistinguishedAmount(aAmount); + return ::GetResidentFast(aAmount); #else *aAmount = 0; return NS_ERROR_NOT_AVAILABLE; From 130960c77463a99191c6184c81fc3e14b79ad3e7 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 11:47:41 +0100 Subject: [PATCH 44/72] Backed out changeset 65048ac4ae6f (bug 939385) for perma failures/orange in XPCShell Tests on Linux and OS X on a CLOSED TREE --- .../aboutmemory/tests/test_aboutmemory5.xul | 3 +-- xpcom/base/nsMemoryReporterManager.cpp | 18 ------------------ 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul b/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul index 9aa61e290a66..50a464310cce 100644 --- a/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul +++ b/toolkit/components/aboutmemory/tests/test_aboutmemory5.xul @@ -104,8 +104,7 @@ // If we have more than 1000 chars, we've probably successfully // copy+pasted. if (actual.length > 1000) { - // Note: Match "vsize" but not "vsize-max-contiguous". - let vsizes = actual.match(/vsize[^-]/g); + let vsizes = actual.match(/vsize/g); let endOfBrowsers = actual.match(/End of Browser/g); if (vsizes.length == 4 && endOfBrowsers.length == 3) { diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index c18a6bc87e6b..2f3c7b19d99a 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -399,20 +399,6 @@ static nsresult GetVsizeMaxContiguous(int64_t* aN) return NS_OK; } -class VsizeMaxContiguousReporter MOZ_FINAL : public MemoryUniReporter -{ -public: - VsizeMaxContiguousReporter() - : MemoryUniReporter("vsize-max-contiguous", KIND_OTHER, UNITS_BYTES, -"Size of the maximum contiguous block of available virtual memory.") - {} - - NS_IMETHOD GetAmount(int64_t* aAmount) - { - return GetVsizeMaxContiguous(aAmount); - } -}; - #define HAVE_PRIVATE_REPORTER class PrivateReporter MOZ_FINAL : public MemoryUniReporter { @@ -790,10 +776,6 @@ nsMemoryReporterManager::Init() RegisterReporter(new ResidentReporter); #endif -#ifdef HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER - RegisterReporter(new VsizeMaxContiguousReporter); -#endif - #ifdef HAVE_RESIDENT_UNIQUE_REPORTER RegisterReporter(new ResidentUniqueReporter); #endif From 868ba65c94afef32fa2a5a3d435b7a162915a6d8 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 11:47:51 +0100 Subject: [PATCH 45/72] Backed out changeset a045549217e2 (bug 939385) for perma failures/orange in XPCShell Tests on Linux and OS X on a CLOSED TREE --- toolkit/components/telemetry/Histograms.json | 8 -------- toolkit/components/telemetry/TelemetryPing.js | 1 - 2 files changed, 9 deletions(-) diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 2649439359af..0d89d6761170 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -255,14 +255,6 @@ "extended_statistics_ok": true, "description": "Virtual memory size (KB)" }, - "MEMORY_VSIZE_MAX_CONTIGUOUS": { - "kind": "exponential", - "low": "32 * 1024", - "high": "16 * 1024 * 1024", - "n_buckets": 100, - "extended_statistics_ok": true, - "description": "Maximum-sized block of contiguous virtual memory (KB)" - }, "MEMORY_JS_COMPARTMENTS_SYSTEM": { "kind": "exponential", "high": "1000", diff --git a/toolkit/components/telemetry/TelemetryPing.js b/toolkit/components/telemetry/TelemetryPing.js index c2eca6adb067..f206ef760a13 100644 --- a/toolkit/components/telemetry/TelemetryPing.js +++ b/toolkit/components/telemetry/TelemetryPing.js @@ -452,7 +452,6 @@ TelemetryPing.prototype = { let p = (id, n) => h(id, Ci.nsIMemoryReporter.UNITS_PERCENTAGE, n); b("MEMORY_VSIZE", "vsize"); - b("MEMORY_VSIZE_MAX_CONTIGUOUS", "vsizeMaxContiguous"); b("MEMORY_RESIDENT", "residentFast"); b("MEMORY_HEAP_ALLOCATED", "heapAllocated"); p("MEMORY_HEAP_COMMITTED_UNUSED_RATIO", "heapOverheadRatio"); From 370964d25d1ec46f86c9574e1d139785cff231b1 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 11:48:01 +0100 Subject: [PATCH 46/72] Backed out changeset a06dd3421421 (bug 939385) for perma failures/orange in XPCShell Tests on Linux and OS X on a CLOSED TREE --- .../mochitest/tests/SimpleTest/TestRunner.js | 2 +- xpcom/base/nsIMemoryReporter.idl | 10 ++++--- xpcom/base/nsMemoryReporterManager.cpp | 26 +++++++++---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/testing/mochitest/tests/SimpleTest/TestRunner.js b/testing/mochitest/tests/SimpleTest/TestRunner.js index b6f14d0a1a21..28254f437752 100644 --- a/testing/mochitest/tests/SimpleTest/TestRunner.js +++ b/testing/mochitest/tests/SimpleTest/TestRunner.js @@ -405,8 +405,8 @@ var MEM_STAT_UNSUPPORTED = 1; var MEM_STAT_SUPPORTED = 2; TestRunner._hasMemoryStatistics = {} TestRunner._hasMemoryStatistics.vsize = MEM_STAT_UNKNOWN; -TestRunner._hasMemoryStatistics.vsizeMaxContiguous = MEM_STAT_UNKNOWN; TestRunner._hasMemoryStatistics.heapAllocated = MEM_STAT_UNKNOWN; +TestRunner._hasMemoryStatistics.largestContiguousVMBlock = MEM_STAT_UNKNOWN; /** * This stub is called by SimpleTest when a test is finished. diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl index 59330f1b5655..66e7ade7ac8f 100644 --- a/xpcom/base/nsIMemoryReporter.idl +++ b/xpcom/base/nsIMemoryReporter.idl @@ -263,9 +263,6 @@ interface nsIMemoryReporterManager : nsISupports * |vsize| (UNITS_BYTES) The virtual size, i.e. the amount of address space * taken up. * - * |vsizeMaxContiguous| (UNITS_BYTES) The size of the largest contiguous - * block of virtual memory. - * * |resident| (UNITS_BYTES) The resident size (a.k.a. RSS or physical memory * used). * @@ -303,10 +300,13 @@ interface nsIMemoryReporterManager : nsISupports * * |pageFaultsHard| (UNITS_COUNT_CUMULATIVE) The number of hard (a.k.a. * major) page faults that have occurred since the process started. + * + * |largestContiguousVMBlock| (UNITS_BYTES) The size of the largest + * contiguous block of virtual memory. Only available on Windows; on all + * other platforms, reading this value returns 0. */ readonly attribute int64_t explicit; readonly attribute int64_t vsize; - readonly attribute int64_t vsizeMaxContiguous; readonly attribute int64_t resident; readonly attribute int64_t residentFast; @@ -329,6 +329,8 @@ interface nsIMemoryReporterManager : nsISupports readonly attribute int64_t pageFaultsHard; + readonly attribute int64_t largestContiguousVMBlock; + /* * This attribute indicates if moz_malloc_usable_size() works. */ diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp index 2f3c7b19d99a..dfa41367055c 100644 --- a/xpcom/base/nsMemoryReporterManager.cpp +++ b/xpcom/base/nsMemoryReporterManager.cpp @@ -371,8 +371,8 @@ static nsresult GetResidentFast(int64_t* aN) return GetResident(aN); } -#define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1 -static nsresult GetVsizeMaxContiguous(int64_t* aN) +#define HAVE_LARGEST_CONTIGUOUS_BLOCK_REPORTERS 1 +static nsresult LargestContiguousVMBlock(int64_t* aN) { SIZE_T biggestRegion = 0; MEMORY_BASIC_INFORMATION vmemInfo = {0}; @@ -1285,17 +1285,6 @@ nsMemoryReporterManager::GetVsize(int64_t* aVsize) #endif } -NS_IMETHODIMP -nsMemoryReporterManager::GetVsizeMaxContiguous(int64_t* aAmount) -{ -#ifdef HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER - return ::GetVsizeMaxContiguous(aAmount); -#else - *aAmount = 0; - return NS_ERROR_NOT_AVAILABLE; -#endif -} - NS_IMETHODIMP nsMemoryReporterManager::GetResident(int64_t* aAmount) { @@ -1422,6 +1411,17 @@ nsMemoryReporterManager::GetPageFaultsHard(int64_t* aAmount) #endif } +NS_IMETHODIMP +nsMemoryReporterManager::GetLargestContiguousVMBlock(int64_t* aAmount) +{ +#ifdef HAVE_LARGEST_CONTIGUOUS_BLOCK_REPORTERS + return LargestContiguousVMBlock(aAmount); +#else + *aAmount = 0; + return NS_ERROR_NOT_AVAILABLE; +#endif +} + NS_IMETHODIMP nsMemoryReporterManager::GetHasMozMallocUsableSize(bool* aHas) { From 711ae6dcdcd49209de272dea8428309405759e48 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 12:28:41 +0100 Subject: [PATCH 47/72] Backed out changeset 002e26035367 (bug 938437) to fix PGO Build Bustage on a CLOSED TREE --- toolkit/library/Makefile.in | 51 +++- .../StaticXULComponentsEnd.cpp | 4 - .../library/StaticXULComponentsEnd/moz.build | 11 - toolkit/library/StaticXULComponentsStart.cpp | 4 - toolkit/library/moz.build | 2 +- toolkit/library/nsStaticXULComponents.cpp | 267 ++++++++++++++++++ toolkit/toolkit.mozbuild | 1 - xpcom/components/Module.h | 17 +- xpcom/components/nsComponentManager.cpp | 20 +- 9 files changed, 326 insertions(+), 51 deletions(-) delete mode 100644 toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp delete mode 100644 toolkit/library/StaticXULComponentsEnd/moz.build delete mode 100644 toolkit/library/StaticXULComponentsStart.cpp create mode 100644 toolkit/library/nsStaticXULComponents.cpp diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in index 9de89a088ae0..02c7eefa553e 100644 --- a/toolkit/library/Makefile.in +++ b/toolkit/library/Makefile.in @@ -69,6 +69,49 @@ endif endif # component libraries +ifdef MOZ_JSDEBUGGER +DEFINES += -DMOZ_JSDEBUGGER +endif + +ifdef MOZ_PREF_EXTENSIONS +DEFINES += -DMOZ_PREF_EXTENSIONS +endif + +ifdef MOZ_AUTH_EXTENSION +DEFINES += -DMOZ_AUTH_EXTENSION +endif + +ifdef MOZ_PERMISSIONS +DEFINES += -DMOZ_PERMISSIONS +endif + +ifdef MOZ_UNIVERSALCHARDET +DEFINES += -DMOZ_UNIVERSALCHARDET +endif + +ifeq (,$(filter android gonk qt os2 cocoa windows,$(MOZ_WIDGET_TOOLKIT))) +ifdef MOZ_XUL +DEFINES += -DMOZ_FILEVIEW +endif +endif + +# Platform-specific icon channel stuff - supported mostly-everywhere +ifneq (,$(filter windows os2 mac cocoa gtk2 gtk3 qt android,$(MOZ_WIDGET_TOOLKIT))) +DEFINES += -DICON_DECODER +endif + +ifdef MOZ_SPELLCHECK +DEFINES += -DMOZ_SPELLCHECK +endif + +ifdef MOZ_ZIPWRITER +DEFINES += -DMOZ_ZIPWRITER +endif + +ifdef MOZ_GIO_COMPONENT +DEFINES += -DMOZ_GIO_COMPONENT +endif + ifdef MOZ_APP_COMPONENT_LIBS COMPONENT_LIBS += $(MOZ_APP_COMPONENT_LIBS) endif @@ -357,6 +400,12 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),windows) OS_LIBS += $(call EXPAND_LIBNAME,usp10 oleaut32) endif +ifdef MOZ_DEBUG +ifdef ENABLE_TESTS +DEFINES += -DENABLE_LAYOUTDEBUG +endif +endif + ifeq (WINNT_1,$(OS_TARGET)_$(MOZ_PROFILE_USE)) # Wrap linker to measure peak virtual memory usage. LD := $(PYTHON) $(topsrcdir)/build/link.py $(CURDIR)/linker-vsize $(LD) @@ -395,5 +444,3 @@ endif $(FINAL_TARGET)/dependentlibs.list: dependentlibs.py $(SHARED_LIBRARY) $(wildcard $(if $(wildcard $(FINAL_TARGET)/dependentlibs.list),$(addprefix $(FINAL_TARGET)/,$(shell cat $(FINAL_TARGET)/dependentlibs.list)))) $(PYTHON) $< $(SHARED_LIBRARY) -L $(FINAL_TARGET) $(if $(TOOLCHAIN_PREFIX),$(addprefix -p ,$(TOOLCHAIN_PREFIX))) > $@ - -EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME_PATH,StaticXULComponentsEnd,$(CURDIR)/StaticXULComponentsEnd) diff --git a/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp b/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp deleted file mode 100644 index 015f8865df4b..000000000000 --- a/toolkit/library/StaticXULComponentsEnd/StaticXULComponentsEnd.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "mozilla/Module.h" -#include "mozilla/NullPtr.h" - -NSMODULE_DEFN(end_kPStaticModules) = nullptr; diff --git a/toolkit/library/StaticXULComponentsEnd/moz.build b/toolkit/library/StaticXULComponentsEnd/moz.build deleted file mode 100644 index 493bb7721e0e..000000000000 --- a/toolkit/library/StaticXULComponentsEnd/moz.build +++ /dev/null @@ -1,11 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -SOURCES += [ - 'StaticXULComponentsEnd.cpp', -] - -LIBRARY_NAME = 'StaticXULComponentsEnd' - -LIBXUL_LIBRARY = True diff --git a/toolkit/library/StaticXULComponentsStart.cpp b/toolkit/library/StaticXULComponentsStart.cpp deleted file mode 100644 index dc24b589459e..000000000000 --- a/toolkit/library/StaticXULComponentsStart.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "mozilla/Module.h" -#include "mozilla/NullPtr.h" - -NSMODULE_DEFN(start_kPStaticModules) = nullptr; diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 435ef159f6b3..b20253bfd391 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -10,7 +10,7 @@ if CONFIG['MOZ_METRO'] and CONFIG['OS_ARCH'] == 'WINNT': LIBRARY_NAME = 'xul' SOURCES += [ - 'StaticXULComponentsStart.cpp', + 'nsStaticXULComponents.cpp', ] if CONFIG['OS_ARCH'] == 'WINNT': diff --git a/toolkit/library/nsStaticXULComponents.cpp b/toolkit/library/nsStaticXULComponents.cpp new file mode 100644 index 000000000000..ddc0699ec365 --- /dev/null +++ b/toolkit/library/nsStaticXULComponents.cpp @@ -0,0 +1,267 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/Module.h" +#include "nsXPCOM.h" +#include "nsMemory.h" + +#ifdef MOZ_AUTH_EXTENSION +#define AUTH_MODULE MODULE(nsAuthModule) +#else +#define AUTH_MODULE +#endif + +#ifdef MOZ_PERMISSIONS +#define PERMISSIONS_MODULES \ + MODULE(nsCookieModule) \ + MODULE(nsPermissionsModule) +#else +#define PERMISSIONS_MODULES +#endif + +#ifdef MOZ_UNIVERSALCHARDET +#define UNIVERSALCHARDET_MODULE MODULE(nsUniversalCharDetModule) +#else +#define UNIVERSALCHARDET_MODULE +#endif + +#ifdef XP_WIN +# define WIDGET_MODULES MODULE(nsWidgetModule) +#elif defined(XP_MACOSX) +# define WIDGET_MODULES MODULE(nsWidgetMacModule) +#elif defined(XP_OS2) +# define WIDGET_MODULES MODULE(nsWidgetOS2Module) +#elif defined(MOZ_WIDGET_GTK) +# define WIDGET_MODULES MODULE(nsWidgetGtk2Module) +#elif defined(MOZ_WIDGET_QT) +# define WIDGET_MODULES MODULE(nsWidgetQtModule) +#elif defined(MOZ_WIDGET_ANDROID) +# define WIDGET_MODULES MODULE(nsWidgetAndroidModule) +#elif defined(MOZ_WIDGET_GONK) +# define WIDGET_MODULES MODULE(nsWidgetGonkModule) +#else +# error Unknown widget module. +#endif + +#ifdef ICON_DECODER +#define ICON_MODULE MODULE(nsIconDecoderModule) +#else +#define ICON_MODULE +#endif + +#ifdef MOZ_ENABLE_XREMOTE +#define XREMOTE_MODULES MODULE(RemoteServiceModule) +#else +#define XREMOTE_MODULES +#endif + +#ifdef MOZ_PREF_EXTENSIONS +#define SYSTEMPREF_MODULES MODULE(nsAutoConfigModule) +#else +#define SYSTEMPREF_MODULES +#endif + +#ifdef ENABLE_LAYOUTDEBUG +#define LAYOUT_DEBUG_MODULE MODULE(nsLayoutDebugModule) +#else +#define LAYOUT_DEBUG_MODULE +#endif + +#ifdef MOZ_JSDEBUGGER +#define JSDEBUGGER_MODULES \ + MODULE(JavaScript_Debugger) +#else +#define JSDEBUGGER_MODULES +#endif + +#if defined(MOZ_FILEVIEW) && defined(MOZ_XUL) +#define FILEVIEW_MODULE MODULE(nsFileViewModule) +#else +#define FILEVIEW_MODULE +#endif + +#ifdef MOZ_ZIPWRITER +#define ZIPWRITER_MODULE MODULE(ZipWriterModule) +#else +#define ZIPWRITER_MODULE +#endif + +#ifdef MOZ_PLACES +#define PLACES_MODULES \ + MODULE(nsPlacesModule) +#else +#define PLACES_MODULES +#endif + +#ifdef MOZ_XUL +#define XULENABLED_MODULES \ + MODULE(tkAutoCompleteModule) \ + MODULE(satchel) \ + MODULE(PKI) +#else +#define XULENABLED_MODULES +#endif + +#ifdef MOZ_SPELLCHECK +#define SPELLCHECK_MODULE MODULE(mozSpellCheckerModule) +#else +#define SPELLCHECK_MODULE +#endif + +#ifdef MOZ_XUL +#ifdef MOZ_WIDGET_GTK +#define UNIXPROXY_MODULE MODULE(nsUnixProxyModule) +#endif +#if defined(MOZ_WIDGET_QT) +#define UNIXPROXY_MODULE MODULE(nsUnixProxyModule) +#endif +#endif +#ifndef UNIXPROXY_MODULE +#define UNIXPROXY_MODULE +#endif + +#if defined(XP_MACOSX) +#define OSXPROXY_MODULE MODULE(nsOSXProxyModule) +#else +#define OSXPROXY_MODULE +#endif + +#if defined(XP_WIN) +#define WINDOWSPROXY_MODULE MODULE(nsWindowsProxyModule) +#else +#define WINDOWSPROXY_MODULE +#endif + +#if defined(MOZ_WIDGET_ANDROID) +#define ANDROIDPROXY_MODULE MODULE(nsAndroidProxyModule) +#else +#define ANDROIDPROXY_MODULE +#endif + +#if defined(BUILD_CTYPES) +#define JSCTYPES_MODULE MODULE(jsctypes) +#else +#define JSCTYPES_MODULE +#endif + +#ifndef MOZ_APP_COMPONENT_MODULES +#if defined(MOZ_APP_COMPONENT_INCLUDE) +#include MOZ_APP_COMPONENT_INCLUDE +#define MOZ_APP_COMPONENT_MODULES APP_COMPONENT_MODULES +#else +#define MOZ_APP_COMPONENT_MODULES +#endif +#endif + +#if defined(MOZ_ENABLE_PROFILER_SPS) +#define PROFILER_MODULE MODULE(nsProfilerModule) +#else +#define PROFILER_MODULE +#endif + +#if defined(MOZ_WEBRTC) +#define PEERCONNECTION_MODULE MODULE(peerconnection) +#else +#define PEERCONNECTION_MODULE +#endif + +#if defined(MOZ_GIO_COMPONENT) +#define GIO_MODULE MODULE(nsGIOModule) +#else +#define GIO_MODULE +#endif + +#if defined(MOZ_SYNTH_PICO) +#define SYNTH_PICO_MODULE MODULE(synthpico) +#else +#define SYNTH_PICO_MODULE +#endif + +#define XUL_MODULES \ + MODULE(nsUConvModule) \ + MODULE(nsI18nModule) \ + MODULE(nsChardetModule) \ + UNIVERSALCHARDET_MODULE \ + MODULE(necko) \ + PERMISSIONS_MODULES \ + AUTH_MODULE \ + MODULE(nsJarModule) \ + ZIPWRITER_MODULE \ + MODULE(StartupCacheModule) \ + MODULE(nsPrefModule) \ + MODULE(nsRDFModule) \ + MODULE(nsWindowDataSourceModule) \ + MODULE(nsParserModule) \ + MODULE(nsImageLib2Module) \ + MODULE(nsMediaSnifferModule) \ + MODULE(nsGfxModule) \ + PROFILER_MODULE \ + WIDGET_MODULES \ + ICON_MODULE \ + MODULE(nsPluginModule) \ + MODULE(nsLayoutModule) \ + MODULE(docshell_provider) \ + MODULE(embedcomponents) \ + MODULE(Browser_Embedding_Module) \ + MODULE(appshell) \ + MODULE(nsTransactionManagerModule) \ + MODULE(nsComposerModule) \ + MODULE(application) \ + MODULE(Apprunner) \ + MODULE(CommandLineModule) \ + FILEVIEW_MODULE \ + MODULE(mozStorageModule) \ + PLACES_MODULES \ + XULENABLED_MODULES \ + MODULE(nsToolkitCompsModule) \ + XREMOTE_MODULES \ + JSDEBUGGER_MODULES \ + MODULE(BOOT) \ + MODULE(NSS) \ + SYSTEMPREF_MODULES \ + SPELLCHECK_MODULE \ + LAYOUT_DEBUG_MODULE \ + UNIXPROXY_MODULE \ + OSXPROXY_MODULE \ + WINDOWSPROXY_MODULE \ + ANDROIDPROXY_MODULE \ + JSCTYPES_MODULE \ + MODULE(jsreflect) \ + MODULE(jsperf) \ + MODULE(identity) \ + MODULE(nsServicesCryptoModule) \ + MOZ_APP_COMPONENT_MODULES \ + MODULE(nsTelemetryModule) \ + MODULE(jsinspector) \ + MODULE(jsdebugger) \ + PEERCONNECTION_MODULE \ + GIO_MODULE \ + SYNTH_PICO_MODULE \ + MODULE(DiskSpaceWatcherModule) \ + /* end of list */ + +#define MODULE(_name) \ + NSMODULE_DECL(_name); + +XUL_MODULES + +#ifdef MOZ_WIDGET_GONK +MODULE(WifiProxyServiceModule) +#endif + +#undef MODULE + +#define MODULE(_name) \ + &NSMODULE_NAME(_name), + +extern const mozilla::Module *const *const kPStaticModules[] = { + XUL_MODULES +#ifdef MOZ_WIDGET_GONK +MODULE(WifiProxyServiceModule) +#endif + nullptr +}; + +#undef MODULE diff --git a/toolkit/toolkit.mozbuild b/toolkit/toolkit.mozbuild index bb4215a6a811..1bfbee8e53a9 100644 --- a/toolkit/toolkit.mozbuild +++ b/toolkit/toolkit.mozbuild @@ -161,7 +161,6 @@ if CONFIG['MOZ_GIO_COMPONENT']: add_tier_dir('platform', app_libxul_dirs) add_tier_dir('platform', app_libxul_static_dirs, static=True) -add_tier_dir('platform', 'toolkit/library/StaticXULComponentsEnd') add_tier_dir('platform', 'toolkit/library') if CONFIG['MOZ_REPLACE_MALLOC']: diff --git a/xpcom/components/Module.h b/xpcom/components/Module.h index c6fa5f600ab6..27449291b13e 100644 --- a/xpcom/components/Module.h +++ b/xpcom/components/Module.h @@ -105,21 +105,8 @@ struct Module #if defined(MOZILLA_INTERNAL_API) # define NSMODULE_NAME(_name) _name##_NSModule -# if defined(_MSC_VER) -# pragma section(".kPStaticModules", read) -# pragma comment(linker, "/merge:.kPStaticModules=.rdata") -# define NSMODULE_SECTION __declspec(allocate(".kPStaticModules")) -# elif defined(__GNUC__) -# if defined(__ELF__) -# define NSMODULE_SECTION __attribute__((section(".kPStaticModules"), visibility("protected"))) -# elif defined(__MACH__) -# define NSMODULE_SECTION __attribute__((section("__DATA, .kPStaticModules"), visibility("default"))) -# endif -# endif -# if !defined(NSMODULE_SECTION) -# error Do not know how to define sections. -# endif -# define NSMODULE_DEFN(_name) extern NSMODULE_SECTION mozilla::Module const *const NSMODULE_NAME(_name) +# define NSMODULE_DECL(_name) extern mozilla::Module const *const NSMODULE_NAME(_name) +# define NSMODULE_DEFN(_name) NSMODULE_DECL(_name) #else # define NSMODULE_NAME(_name) NSModule # define NSMODULE_DEFN(_name) extern "C" NS_EXPORT mozilla::Module const *const NSModule diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index f81f59a0d1da..b8b908be994d 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -79,6 +79,10 @@ using namespace mozilla; PRLogModuleInfo* nsComponentManagerLog = nullptr; +// defined in nsStaticXULComponents.cpp to contain all the components in +// libxul. +extern mozilla::Module const *const *const kPStaticModules[]; + #if 0 || defined (DEBUG_timeless) #define SHOW_DENIED_ON_SHUTDOWN #define SHOW_CI_ON_EXISTING_SERVICE @@ -318,15 +322,6 @@ nsComponentManagerImpl::nsComponentManagerImpl() nsTArray* nsComponentManagerImpl::sStaticModules; -NSMODULE_DEFN(start_kPStaticModules); -NSMODULE_DEFN(end_kPStaticModules); - -/* The content between start_kPStaticModules and end_kPStaticModules is gathered - * by the linker from various objects containing symbols in a specific section. - * ASAN considers (rightfully) the use of this content as a global buffer - * overflow. But this is a deliberate and well-considered choice, with no proper - * way to make ASAN happy. */ -MOZ_ASAN_BLACKLIST /* static */ void nsComponentManagerImpl::InitializeStaticModules() { @@ -334,10 +329,9 @@ nsComponentManagerImpl::InitializeStaticModules() return; sStaticModules = new nsTArray; - for (const mozilla::Module *const *staticModules = &NSMODULE_NAME(start_kPStaticModules) + 1; - staticModules < &NSMODULE_NAME(end_kPStaticModules); ++staticModules) - if (*staticModules) // ASAN adds padding - sStaticModules->AppendElement(*staticModules); + for (const mozilla::Module *const *const *staticModules = kPStaticModules; + *staticModules; ++staticModules) + sStaticModules->AppendElement(**staticModules); } nsTArray* From afa82c35ec268799272097bd2919b09a8df87ec9 Mon Sep 17 00:00:00 2001 From: Eddy Bruel Date: Tue, 19 Nov 2013 12:41:42 +0100 Subject: [PATCH 48/72] Bug 938907 - Get rid of the compile and go flag on ContextOptions; r=bholley --- ipc/testshell/XPCShellEnvironment.cpp | 16 ++-- js/jsd/jsd_xpc.cpp | 11 +-- js/src/jsapi-tests/testChromeBuffer.cpp | 36 ++++++--- js/src/jsapi-tests/testCloneScript.cpp | 15 ++-- js/src/jsapi-tests/testEnclosingFunction.cpp | 15 ++-- js/src/jsapi-tests/testScriptInfo.cpp | 5 +- js/src/jsapi-tests/testScriptObject.cpp | 39 ++++++---- js/src/jsapi-tests/testTrap.cpp | 5 +- js/src/jsapi-tests/testXDR.cpp | 18 ++++- js/src/jsapi.cpp | 78 +++----------------- js/src/jsapi.h | 47 ++---------- js/src/shell/js.cpp | 34 +++++---- js/xpconnect/src/XPCShellImpl.cpp | 9 ++- netwerk/base/src/ProxyAutoConfig.cpp | 8 +- 14 files changed, 151 insertions(+), 185 deletions(-) diff --git a/ipc/testshell/XPCShellEnvironment.cpp b/ipc/testshell/XPCShellEnvironment.cpp index 160d0a47b2cd..1a111013694d 100644 --- a/ipc/testshell/XPCShellEnvironment.cpp +++ b/ipc/testshell/XPCShellEnvironment.cpp @@ -373,9 +373,10 @@ XPCShellEnvironment::ProcessFile(JSContext *cx, /* Clear any pending exception from previous failed compiles. */ JS_ClearPendingException(cx); - script = - JS_CompileScriptForPrincipals(cx, obj, env->GetPrincipal(), buffer, - strlen(buffer), "typein", startline); + JS::CompileOptions options(cx); + options.setFileAndLine("typein", startline) + .setPrincipals(env->GetPrincipal()); + script = JS_CompileScript(cx, obj, buffer, strlen(buffer), options); if (script) { JSErrorReporter older; @@ -583,10 +584,11 @@ XPCShellEnvironment::EvaluateString(const nsString& aString, JS::Rooted global(cx, GetGlobalObject()); JSAutoCompartment ac(cx, global); - JSScript* script = - JS_CompileUCScriptForPrincipals(cx, global, GetPrincipal(), - aString.get(), aString.Length(), - "typein", 0); + JS::CompileOptions options(cx); + options.setFileAndLine("typein", 0) + .setPrincipals(GetPrincipal()); + JSScript* script = JS_CompileUCScript(cx, global, aString.get(), + aString.Length(), options); if (!script) { return false; } diff --git a/js/jsd/jsd_xpc.cpp b/js/jsd/jsd_xpc.cpp index 91c31c0546ea..4d3f0142321f 100644 --- a/js/jsd/jsd_xpc.cpp +++ b/js/jsd/jsd_xpc.cpp @@ -1009,8 +1009,10 @@ jsdScript::CreatePPLineMap() "arg5", "arg6", "arg7", "arg8", "arg9", "arg10", "arg11", "arg12" }; + JS::CompileOptions options(cx); + options.setFileAndLine("x-jsd:ppbuffer?type=function", 3); fun = JS_CompileUCFunction (cx, obj, "ppfun", nargs, argnames, chars, - length, "x-jsd:ppbuffer?type=function", 3); + length, options); if (!fun || !(script = JS_GetFunctionScript(cx, fun))) return nullptr; baseLine = 3; @@ -1030,7 +1032,9 @@ jsdScript::CreatePPLineMap() } JS::Anchor kungFuDeathGrip(jsstr); - script = JS_CompileUCScript (cx, obj, chars, length, "x-jsd:ppbuffer?type=script", 1); + JS::CompileOptions options(cx); + options.setFileAndLine("x-jsd:ppbuffer?type=script", 1); + script = JS_CompileUCScript(cx, obj, chars, length, options); if (!script) return nullptr; baseLine = 1; @@ -1647,7 +1651,6 @@ jsdContext::GetJSContext(JSContext **_rval) #define JSOPTION_WERROR JS_BIT(1) #define JSOPTION_VAROBJFIX JS_BIT(2) #define JSOPTION_PRIVATE_IS_NSISUPPORTS JS_BIT(3) -#define JSOPTION_COMPILE_N_GO JS_BIT(4) #define JSOPTION_DONT_REPORT_UNCAUGHT JS_BIT(8) #define JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT JS_BIT(11) #define JSOPTION_NO_SCRIPT_RVAL JS_BIT(12) @@ -1666,7 +1669,6 @@ jsdContext::GetOptions(uint32_t *_rval) | (JS::ContextOptionsRef(mJSCx).werror() ? JSOPTION_WERROR : 0) | (JS::ContextOptionsRef(mJSCx).varObjFix() ? JSOPTION_VAROBJFIX : 0) | (JS::ContextOptionsRef(mJSCx).privateIsNSISupports() ? JSOPTION_PRIVATE_IS_NSISUPPORTS : 0) - | (JS::ContextOptionsRef(mJSCx).compileAndGo() ? JSOPTION_COMPILE_N_GO : 0) | (JS::ContextOptionsRef(mJSCx).dontReportUncaught() ? JSOPTION_DONT_REPORT_UNCAUGHT : 0) | (JS::ContextOptionsRef(mJSCx).noDefaultCompartmentObject() ? JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT : 0) | (JS::ContextOptionsRef(mJSCx).noScriptRval() ? JSOPTION_NO_SCRIPT_RVAL : 0) @@ -1692,7 +1694,6 @@ jsdContext::SetOptions(uint32_t options) JS::ContextOptionsRef(mJSCx).setExtraWarnings(options & JSOPTION_EXTRA_WARNINGS) .setWerror(options & JSOPTION_WERROR) .setVarObjFix(options & JSOPTION_VAROBJFIX) - .setCompileAndGo(options & JSOPTION_COMPILE_N_GO) .setDontReportUncaught(options & JSOPTION_DONT_REPORT_UNCAUGHT) .setNoDefaultCompartmentObject(options & JSOPTION_NO_DEFAULT_COMPARTMENT_OBJECT) .setNoScriptRval(options & JSOPTION_NO_SCRIPT_RVAL) diff --git a/js/src/jsapi-tests/testChromeBuffer.cpp b/js/src/jsapi-tests/testChromeBuffer.cpp index 6c111fcdb2d6..02cec9d0f64b 100644 --- a/js/src/jsapi-tests/testChromeBuffer.cpp +++ b/js/src/jsapi-tests/testChromeBuffer.cpp @@ -64,9 +64,11 @@ BEGIN_TEST(testChromeBuffer) const char *paramName = "x"; const char *bytes = "return x ? 1 + trusted(x-1) : 0"; JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob); - CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals, - "trusted", 1, ¶mName, bytes, strlen(bytes), - "", 0)); + JS::CompileOptions options(cx); + options.setFileAndLine("", 0) + .setPrincipals(&system_principals); + CHECK(fun = JS_CompileFunction(cx, global, "trusted", 1, ¶mName, + bytes, strlen(bytes), options)); trusted_fun = JS_GetFunctionObject(fun); if (!JS_AddNamedObjectRoot(cx, &trusted_fun, "trusted-function")) return false; @@ -85,8 +87,10 @@ BEGIN_TEST(testChromeBuffer) " return -1; " " } " "} "; + JS::CompileOptions options(cx); + options.setFileAndLine("", 0); CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, ¶mName, - bytes, strlen(bytes), "", 0)); + bytes, strlen(bytes), options)); JS::RootedValue rval(cx); CHECK(JS_CallFunction(cx, nullptr, fun, 1, v.address(), rval.address())); @@ -107,9 +111,11 @@ BEGIN_TEST(testChromeBuffer) " return 'From trusted: ' + e; " "} "; JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob); - CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals, - "trusted", 1, ¶mName, bytes, strlen(bytes), - "", 0)); + JS::CompileOptions options(cx); + options.setFileAndLine("", 0) + .setPrincipals(&system_principals); + CHECK(fun = JS_CompileFunction(cx, global, "trusted", 1, ¶mName, + bytes, strlen(bytes), options)); trusted_fun = JS_GetFunctionObject(fun); } @@ -122,8 +128,10 @@ BEGIN_TEST(testChromeBuffer) "} catch (e) { " " return trusted(untrusted); " "} "; + JS::CompileOptions options(cx); + options.setFileAndLine("", 0); CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, ¶mName, - bytes, strlen(bytes), "", 0)); + bytes, strlen(bytes), options)); JS::RootedValue rval(cx); CHECK(JS_CallFunction(cx, nullptr, fun, 1, v.address(), rval.address())); @@ -141,9 +149,11 @@ BEGIN_TEST(testChromeBuffer) JSAutoCompartment ac(cx, trusted_glob); const char *bytes = "return 42"; JS::HandleObject global = JS::HandleObject::fromMarkedLocation(&trusted_glob); - CHECK(fun = JS_CompileFunctionForPrincipals(cx, global, &system_principals, - "trusted", 0, nullptr, - bytes, strlen(bytes), "", 0)); + JS::CompileOptions options(cx); + options.setFileAndLine("", 0) + .setPrincipals(&system_principals); + CHECK(fun = JS_CompileFunction(cx, global, "trusted", 0, nullptr, + bytes, strlen(bytes), options)); trusted_fun = JS_GetFunctionObject(fun); } @@ -156,8 +166,10 @@ BEGIN_TEST(testChromeBuffer) "} catch (e) { " " return f(); " "} "; + JS::CompileOptions options(cx); + options.setFileAndLine("", 0); CHECK(fun = JS_CompileFunction(cx, global, "untrusted", 1, ¶mName, - bytes, strlen(bytes), "", 0)); + bytes, strlen(bytes), options)); JS::RootedValue arg(cx, JS::ObjectValue(*callTrusted)); JS::RootedValue rval(cx); diff --git a/js/src/jsapi-tests/testCloneScript.cpp b/js/src/jsapi-tests/testCloneScript.cpp index 72c440157c52..18392a6d740e 100644 --- a/js/src/jsapi-tests/testCloneScript.cpp +++ b/js/src/jsapi-tests/testCloneScript.cpp @@ -33,8 +33,10 @@ BEGIN_TEST(test_cloneScript) { JSAutoCompartment a(cx, A); JSFunction *fun; - CHECK(fun = JS_CompileFunction(cx, A, "f", 0, nullptr, source, strlen(source), - __FILE__, 1)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, 1); + CHECK(fun = JS_CompileFunction(cx, A, "f", 0, nullptr, source, + strlen(source), options)); CHECK(obj = JS_GetFunctionObject(fun)); } @@ -104,9 +106,12 @@ BEGIN_TEST(test_cloneScriptWithPrincipals) // Compile in A { JSAutoCompartment a(cx, A); - JS::RootedFunction fun(cx, JS_CompileFunctionForPrincipals(cx, A, principalsA, "f", - mozilla::ArrayLength(argnames), argnames, - source, strlen(source), __FILE__, 1)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, 1) + .setPrincipals(principalsA); + JS::RootedFunction fun(cx, JS_CompileFunction(cx, A, "f", + mozilla::ArrayLength(argnames), argnames, source, + strlen(source), options)); CHECK(fun); JSScript *script; diff --git a/js/src/jsapi-tests/testEnclosingFunction.cpp b/js/src/jsapi-tests/testEnclosingFunction.cpp index 2f2657926afa..0e73928779dc 100644 --- a/js/src/jsapi-tests/testEnclosingFunction.cpp +++ b/js/src/jsapi-tests/testEnclosingFunction.cpp @@ -36,23 +36,26 @@ BEGIN_TEST(test_enclosingFunction) RootedFunction fun(cx); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + const char s1chars[] = "checkEnclosing()"; - fun = JS_CompileFunction(cx, global, "s1", 0, nullptr, s1chars, strlen(s1chars), - __FILE__, __LINE__); + fun = JS_CompileFunction(cx, global, "s1", 0, nullptr, s1chars, + strlen(s1chars), options); CHECK(fun); EXEC("s1()"); CHECK(found == JS_GetFunctionScript(cx, fun)); const char s2chars[] = "return function() { checkEnclosing() }"; - fun = JS_CompileFunction(cx, global, "s2", 0, nullptr, s2chars, strlen(s2chars), - __FILE__, __LINE__); + fun = JS_CompileFunction(cx, global, "s2", 0, nullptr, s2chars, + strlen(s2chars), options); CHECK(fun); EXEC("s2()()"); CHECK(found == JS_GetFunctionScript(cx, fun)); const char s3chars[] = "return function() { let (x) { function g() { checkEnclosing() } return g() } }"; - fun = JS_CompileFunction(cx, global, "s3", 0, nullptr, s3chars, strlen(s3chars), - __FILE__, __LINE__); + fun = JS_CompileFunction(cx, global, "s3", 0, nullptr, s3chars, + strlen(s3chars), options); CHECK(fun); EXEC("s3()()"); CHECK(found == JS_GetFunctionScript(cx, fun)); diff --git a/js/src/jsapi-tests/testScriptInfo.cpp b/js/src/jsapi-tests/testScriptInfo.cpp index 57b40a6c4ae2..ad9dee3c19f3 100644 --- a/js/src/jsapi-tests/testScriptInfo.cpp +++ b/js/src/jsapi-tests/testScriptInfo.cpp @@ -37,7 +37,10 @@ BEGIN_TEST(testScriptInfo) { unsigned startLine = 1000; - JS::RootedScript script(cx, JS_CompileScript(cx, global, code, strlen(code), __FILE__, startLine)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, startLine); + JS::RootedScript script(cx, JS_CompileScript(cx, global, code, strlen(code), + options)); CHECK(script); diff --git a/js/src/jsapi-tests/testScriptObject.cpp b/js/src/jsapi-tests/testScriptObject.cpp index 561a028599fc..26f7dbb8fc64 100644 --- a/js/src/jsapi-tests/testScriptObject.cpp +++ b/js/src/jsapi-tests/testScriptObject.cpp @@ -40,47 +40,56 @@ jschar ScriptObjectFixture::uc_code[ScriptObjectFixture::code_size]; BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript) { + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); return tryScript(global, JS_CompileScript(cx, global, code, code_size, - __FILE__, __LINE__)); + options)); } END_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript) BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript_empty) { - return tryScript(global, JS_CompileScript(cx, global, "", 0, - __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + return tryScript(global, JS_CompileScript(cx, global, "", 0, options)); } END_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScript_empty) BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScriptForPrincipals) { - return tryScript(global, JS_CompileScriptForPrincipals(cx, global, nullptr, - code, code_size, - __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__) + .setPrincipals(nullptr); + return tryScript(global, JS_CompileScript(cx, global, code, code_size, + options)); } END_FIXTURE_TEST(ScriptObjectFixture, bug438633_CompileScriptForPrincipals) BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_JS_CompileUCScript) { - return tryScript(global, JS_CompileUCScript(cx, global, - uc_code, code_size, - __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + return tryScript(global, JS_CompileUCScript(cx, global, uc_code, code_size, + options)); } END_FIXTURE_TEST(ScriptObjectFixture, bug438633_JS_CompileUCScript) BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_JS_CompileUCScript_empty) { - return tryScript(global, JS_CompileUCScript(cx, global, - uc_code, 0, - __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + return tryScript(global, JS_CompileUCScript(cx, global, uc_code, 0, + options)); } END_FIXTURE_TEST(ScriptObjectFixture, bug438633_JS_CompileUCScript_empty) BEGIN_FIXTURE_TEST(ScriptObjectFixture, bug438633_JS_CompileUCScriptForPrincipals) { - return tryScript(global, JS_CompileUCScriptForPrincipals(cx, global, nullptr, - uc_code, code_size, - __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__) + .setPrincipals(nullptr); + return tryScript(global, JS_CompileUCScript(cx, global, uc_code, code_size, + options)); } END_FIXTURE_TEST(ScriptObjectFixture, bug438633_JS_CompileUCScriptForPrincipals) diff --git a/js/src/jsapi-tests/testTrap.cpp b/js/src/jsapi-tests/testTrap.cpp index b64fe628ce25..e1dae7788aee 100644 --- a/js/src/jsapi-tests/testTrap.cpp +++ b/js/src/jsapi-tests/testTrap.cpp @@ -34,7 +34,10 @@ BEGIN_TEST(testTrap_gc) ; // compile - JS::RootedScript script(cx, JS_CompileScript(cx, global, source, strlen(source), __FILE__, 1)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, 1); + JS::RootedScript script(cx, JS_CompileScript(cx, global, source, + strlen(source), options)); CHECK(script); // execute diff --git a/js/src/jsapi-tests/testXDR.cpp b/js/src/jsapi-tests/testXDR.cpp index 69e96d931a65..9a8d0ae4498f 100644 --- a/js/src/jsapi-tests/testXDR.cpp +++ b/js/src/jsapi-tests/testXDR.cpp @@ -163,7 +163,10 @@ BEGIN_TEST(testXDR_bug506491) "var f = makeClosure('0;', 'status', 'ok');\n"; // compile - JS::RootedScript script(cx, JS_CompileScript(cx, global, s, strlen(s), __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + JS::RootedScript script(cx, JS_CompileScript(cx, global, s, strlen(s), + options)); CHECK(script); script = FreezeThaw(cx, script); @@ -187,7 +190,9 @@ END_TEST(testXDR_bug506491) BEGIN_TEST(testXDR_bug516827) { // compile an empty script - JS::RootedScript script(cx, JS_CompileScript(cx, global, "", 0, __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + JS::RootedScript script(cx, JS_CompileScript(cx, global, "", 0, options)); CHECK(script); script = FreezeThaw(cx, script); @@ -208,7 +213,10 @@ BEGIN_TEST(testXDR_source) nullptr }; for (const char **s = samples; *s; s++) { - JS::RootedScript script(cx, JS_CompileScript(cx, global, *s, strlen(*s), __FILE__, __LINE__)); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + JS::RootedScript script(cx, JS_CompileScript(cx, global, *s, strlen(*s), + options)); CHECK(script); script = FreezeThaw(cx, script); CHECK(script); @@ -231,7 +239,9 @@ BEGIN_TEST(testXDR_sourceMap) }; JS::RootedScript script(cx); for (const char **sm = sourceMaps; *sm; sm++) { - script = JS_CompileScript(cx, global, "", 0, __FILE__, __LINE__); + JS::CompileOptions options(cx); + options.setFileAndLine(__FILE__, __LINE__); + script = JS_CompileScript(cx, global, "", 0, options); CHECK(script); size_t len = strlen(*sm); diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 082453ed643c..97b1463cb1ef 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -4399,7 +4399,7 @@ JS::CompileOptions::CompileOptions(JSContext *cx, JSVersion version) { this->version = (version != JSVERSION_UNKNOWN) ? version : cx->findVersion(); - compileAndGo = cx->options().compileAndGo(); + compileAndGo = false; noScriptRval = cx->options().noScriptRval(); strictOption = cx->options().strictMode(); extraWarningsOption = cx->options().extraWarnings(); @@ -4514,52 +4514,17 @@ JS::FinishOffThreadScript(JSContext *maybecx, JSRuntime *rt, void *token) } JS_PUBLIC_API(JSScript *) -JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *objArg, JSPrincipals *principals, - const jschar *chars, size_t length, - const char *filename, unsigned lineno) +JS_CompileScript(JSContext *cx, JS::HandleObject obj, const char *ascii, + size_t length, const JS::CompileOptions &options) { - RootedObject obj(cx, objArg); - CompileOptions options(cx); - options.setPrincipals(principals) - .setFileAndLine(filename, lineno); - - return Compile(cx, obj, options, chars, length); -} - -JS_PUBLIC_API(JSScript *) -JS_CompileUCScript(JSContext *cx, JSObject *objArg, const jschar *chars, size_t length, - const char *filename, unsigned lineno) -{ - RootedObject obj(cx, objArg); - CompileOptions options(cx); - options.setFileAndLine(filename, lineno); - - return Compile(cx, obj, options, chars, length); -} - -JS_PUBLIC_API(JSScript *) -JS_CompileScriptForPrincipals(JSContext *cx, JSObject *objArg, - JSPrincipals *principals, - const char *ascii, size_t length, - const char *filename, unsigned lineno) -{ - RootedObject obj(cx, objArg); - CompileOptions options(cx); - options.setPrincipals(principals) - .setFileAndLine(filename, lineno); - return Compile(cx, obj, options, ascii, length); } JS_PUBLIC_API(JSScript *) -JS_CompileScript(JSContext *cx, JSObject *objArg, const char *ascii, size_t length, - const char *filename, unsigned lineno) +JS_CompileUCScript(JSContext *cx, JS::HandleObject obj, const jschar *chars, + size_t length, const JS::CompileOptions &options) { - RootedObject obj(cx, objArg); - CompileOptions options(cx); - options.setFileAndLine(filename, lineno); - - return Compile(cx, obj, options, ascii, length); + return Compile(cx, obj, options, chars, length); } JS_PUBLIC_API(bool) @@ -4675,43 +4640,20 @@ JS::CompileFunction(JSContext *cx, HandleObject obj, const ReadOnlyCompileOption } JS_PUBLIC_API(JSFunction *) -JS_CompileUCFunction(JSContext *cx, JSObject *objArg, const char *name, +JS_CompileUCFunction(JSContext *cx, JS::HandleObject obj, const char *name, unsigned nargs, const char *const *argnames, const jschar *chars, size_t length, - const char *filename, unsigned lineno) + const CompileOptions &options) { - RootedObject obj(cx, objArg); - CompileOptions options(cx); - options.setFileAndLine(filename, lineno); - return CompileFunction(cx, obj, options, name, nargs, argnames, chars, length); } JS_PUBLIC_API(JSFunction *) -JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *objArg, - JSPrincipals *principals, const char *name, - unsigned nargs, const char *const *argnames, - const char *ascii, size_t length, - const char *filename, unsigned lineno) -{ - RootedObject obj(cx, objArg); - CompileOptions options(cx); - options.setPrincipals(principals) - .setFileAndLine(filename, lineno); - - return CompileFunction(cx, obj, options, name, nargs, argnames, ascii, length); -} - -JS_PUBLIC_API(JSFunction *) -JS_CompileFunction(JSContext *cx, JSObject *objArg, const char *name, +JS_CompileFunction(JSContext *cx, JS::HandleObject obj, const char *name, unsigned nargs, const char *const *argnames, const char *ascii, size_t length, - const char *filename, unsigned lineno) + const JS::CompileOptions &options) { - RootedObject obj(cx, objArg); - CompileOptions options(cx); - options.setFileAndLine(filename, lineno); - return CompileFunction(cx, obj, options, name, nargs, argnames, ascii, length); } diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 0e54bab8d9ab..bee0b4f9abc3 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -1447,7 +1447,6 @@ class JS_PUBLIC_API(ContextOptions) { werror_(false), varObjFix_(false), privateIsNSISupports_(false), - compileAndGo_(false), dontReportUncaught_(false), noDefaultCompartmentObject_(false), noScriptRval_(false), @@ -1499,16 +1498,6 @@ class JS_PUBLIC_API(ContextOptions) { return *this; } - bool compileAndGo() const { return compileAndGo_; } - ContextOptions &setCompileAndGo(bool flag) { - compileAndGo_ = flag; - return *this; - } - ContextOptions &toggleCompileAndGo() { - compileAndGo_ = !compileAndGo_; - return *this; - } - bool dontReportUncaught() const { return dontReportUncaught_; } ContextOptions &setDontReportUncaught(bool flag) { dontReportUncaught_ = flag; @@ -1594,7 +1583,6 @@ class JS_PUBLIC_API(ContextOptions) { bool werror_ : 1; bool varObjFix_ : 1; bool privateIsNSISupports_ : 1; - bool compileAndGo_ : 1; bool dontReportUncaught_ : 1; bool noDefaultCompartmentObject_ : 1; bool noScriptRval_ : 1; @@ -3333,48 +3321,29 @@ extern JS_PUBLIC_API(bool) JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj, const char *utf8, size_t length); extern JS_PUBLIC_API(JSScript *) -JS_CompileScript(JSContext *cx, JSObject *obj, +JS_CompileScript(JSContext *cx, JS::HandleObject obj, const char *ascii, size_t length, - const char *filename, unsigned lineno); + const JS::CompileOptions &options); extern JS_PUBLIC_API(JSScript *) -JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj, - JSPrincipals *principals, - const char *ascii, size_t length, - const char *filename, unsigned lineno); - -extern JS_PUBLIC_API(JSScript *) -JS_CompileUCScript(JSContext *cx, JSObject *obj, +JS_CompileUCScript(JSContext *cx, JS::HandleObject obj, const jschar *chars, size_t length, - const char *filename, unsigned lineno); - -extern JS_PUBLIC_API(JSScript *) -JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj, - JSPrincipals *principals, - const jschar *chars, size_t length, - const char *filename, unsigned lineno); + const JS::CompileOptions &options); extern JS_PUBLIC_API(JSObject *) JS_GetGlobalFromScript(JSScript *script); extern JS_PUBLIC_API(JSFunction *) -JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name, +JS_CompileFunction(JSContext *cx, JS::HandleObject obj, const char *name, unsigned nargs, const char *const *argnames, const char *bytes, size_t length, - const char *filename, unsigned lineno); + const JS::CompileOptions &options); extern JS_PUBLIC_API(JSFunction *) -JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj, - JSPrincipals *principals, const char *name, - unsigned nargs, const char *const *argnames, - const char *bytes, size_t length, - const char *filename, unsigned lineno); - -extern JS_PUBLIC_API(JSFunction *) -JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name, +JS_CompileUCFunction(JSContext *cx, JS::HandleObject obj, const char *name, unsigned nargs, const char *const *argnames, const jschar *chars, size_t length, - const char *filename, unsigned lineno); + const JS::CompileOptions &options); namespace JS { diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index bd814f390c57..9d64c2575ccc 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -388,12 +388,12 @@ RunFile(JSContext *cx, Handle obj, const char *filename, FILE *file, { JS::AutoSaveContextOptions asco(cx); - JS::ContextOptionsRef(cx).setCompileAndGo(true) - .setNoScriptRval(true); + JS::ContextOptionsRef(cx).setNoScriptRval(true); CompileOptions options(cx); options.setUTF8(true) - .setFileAndLine(filename, 1); + .setFileAndLine(filename, 1) + .setCompileAndGo(true); gGotError = false; script = JS::Compile(cx, obj, options, file); @@ -1007,13 +1007,13 @@ Evaluate(JSContext *cx, unsigned argc, jsval *vp) { JS::AutoSaveContextOptions asco(cx); - JS::ContextOptionsRef(cx).setCompileAndGo(compileAndGo) - .setNoScriptRval(noScriptRval); + JS::ContextOptionsRef(cx).setNoScriptRval(noScriptRval); CompileOptions options(cx); options.setFileAndLine(fileName, lineNumber) .setElement(element) - .setSourcePolicy(sourcePolicy); + .setSourcePolicy(sourcePolicy) + .setCompileAndGo(compileAndGo); script = JS::Compile(cx, global, options, codeChars, codeLength); if (!script) @@ -1170,10 +1170,12 @@ Run(JSContext *cx, unsigned argc, jsval *vp) int64_t startClock = PRMJ_Now(); { JS::AutoSaveContextOptions asco(cx); - JS::ContextOptionsRef(cx).setCompileAndGo(true) - .setNoScriptRval(true); + JS::ContextOptionsRef(cx).setNoScriptRval(true); - script = JS_CompileUCScript(cx, thisobj, ucbuf, buflen, filename.ptr(), 1); + JS::CompileOptions options(cx); + options.setFileAndLine(filename.ptr(), 1) + .setCompileAndGo(true); + script = JS_CompileUCScript(cx, thisobj, ucbuf, buflen, options); if (!script) return false; } @@ -2005,12 +2007,12 @@ DisassFile(JSContext *cx, unsigned argc, jsval *vp) { JS::AutoSaveContextOptions asco(cx); - JS::ContextOptionsRef(cx).setCompileAndGo(true) - .setNoScriptRval(true); + JS::ContextOptionsRef(cx).setNoScriptRval(true); CompileOptions options(cx); options.setUTF8(true) - .setFileAndLine(filename.ptr(), 1); + .setFileAndLine(filename.ptr(), 1) + .setCompileAndGo(true); script = JS::Compile(cx, thisobj, options, filename.ptr()); if (!script) @@ -3081,10 +3083,12 @@ Compile(JSContext *cx, unsigned argc, jsval *vp) RootedObject global(cx, JS::CurrentGlobalOrNull(cx)); JSString *scriptContents = JSVAL_TO_STRING(arg0); JS::AutoSaveContextOptions asco(cx); - JS::ContextOptionsRef(cx).setCompileAndGo(true) - .setNoScriptRval(true); + JS::ContextOptionsRef(cx).setNoScriptRval(true); + JS::CompileOptions options(cx); + options.setFileAndLine("", 1) + .setCompileAndGo(true); bool ok = JS_CompileUCScript(cx, global, JS_GetStringCharsZ(cx, scriptContents), - JS_GetStringLength(scriptContents), "", 1); + JS_GetStringLength(scriptContents), options); JS_SET_RVAL(cx, vp, UndefinedValue()); return ok; } diff --git a/js/xpconnect/src/XPCShellImpl.cpp b/js/xpconnect/src/XPCShellImpl.cpp index d1842c86f485..07d3e64de5fa 100644 --- a/js/xpconnect/src/XPCShellImpl.cpp +++ b/js/xpconnect/src/XPCShellImpl.cpp @@ -946,8 +946,10 @@ ProcessFile(JSContext *cx, JS::Handle obj, const char *filename, FILE DoBeginRequest(cx); /* Clear any pending exception from previous failed compiles. */ JS_ClearPendingException(cx); - script = JS_CompileScriptForPrincipals(cx, obj, gJSPrincipals, buffer, - strlen(buffer), "typein", startline); + JS::CompileOptions options(cx); + options.setFileAndLine("typein", startline) + .setPrincipals(gJSPrincipals); + script = JS_CompileScript(cx, obj, buffer, strlen(buffer), options); if (script) { JSErrorReporter older; @@ -1023,8 +1025,7 @@ ProcessArgsForCompartment(JSContext *cx, char **argv, int argc) ContextOptionsRef(cx).toggleExtraWarnings(); break; case 'I': - ContextOptionsRef(cx).toggleCompileAndGo() - .toggleIon() + ContextOptionsRef(cx).toggleIon() .toggleAsmJS(); break; case 'n': diff --git a/netwerk/base/src/ProxyAutoConfig.cpp b/netwerk/base/src/ProxyAutoConfig.cpp index 62db38b98698..414f320dad28 100644 --- a/netwerk/base/src/ProxyAutoConfig.cpp +++ b/netwerk/base/src/ProxyAutoConfig.cpp @@ -616,10 +616,12 @@ ProxyAutoConfig::SetupJS() bool isDataURI = nsDependentCSubstring(mPACURI, 0, 5).LowerCaseEqualsASCII("data:", 5); sRunning = this; - JSScript *script = JS_CompileScript(mJSRuntime->Context(), - mJSRuntime->Global(), + JS::Rooted global(mJSRuntime->Context(), mJSRuntime->Global()); + JS::CompileOptions options(mJSRuntime->Context()); + options.setFileAndLine(mPACURI.get(), 1); + JSScript *script = JS_CompileScript(mJSRuntime->Context(), global, mPACScript.get(), mPACScript.Length(), - mPACURI.get(), 1); + options); if (!script || !JS_ExecuteScript(mJSRuntime->Context(), mJSRuntime->Global(), script, nullptr)) { nsString alertMessage(NS_LITERAL_STRING("PAC file failed to install from ")); From fefa49c8724b78ce0c5689dd6fe66d97c2affd4a Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Fri, 5 Jul 2013 21:20:04 +0200 Subject: [PATCH 49/72] Bug 890545 - provide a way to enumerate registered manifests, r=froydnj,f=glandium --HG-- extra : rebase_source : 7534f0d3c0257ff34f1477c0bfdd23b540e7a7c7 --- js/xpconnect/loader/mozJSComponentLoader.cpp | 1 - js/xpconnect/loader/mozJSComponentLoader.h | 1 + xpcom/build/FileLocation.h | 1 - xpcom/components/nsComponentManager.cpp | 29 ++++++++++++++++++++ xpcom/components/nsIComponentManager.idl | 13 +++++++-- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 07978411c07f..00998080564e 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -32,7 +32,6 @@ #include "nsIXPConnect.h" #include "nsIObserverService.h" #include "nsIScriptSecurityManager.h" -#include "nsIURI.h" #include "nsIFileURL.h" #include "nsIJARURI.h" #include "nsNetUtil.h" diff --git a/js/xpconnect/loader/mozJSComponentLoader.h b/js/xpconnect/loader/mozJSComponentLoader.h index cb1d45f27d0e..8927ebe886c0 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.h +++ b/js/xpconnect/loader/mozJSComponentLoader.h @@ -10,6 +10,7 @@ #include "mozilla/ModuleLoader.h" #include "nsISupports.h" #include "nsIObserver.h" +#include "nsIURI.h" #include "xpcIJSModuleLoader.h" #include "nsClassHashtable.h" #include "nsDataHashtable.h" diff --git a/xpcom/build/FileLocation.h b/xpcom/build/FileLocation.h index b306e5effca9..d27175031ebb 100644 --- a/xpcom/build/FileLocation.h +++ b/xpcom/build/FileLocation.h @@ -9,7 +9,6 @@ #include "nsCOMPtr.h" #include "nsAutoPtr.h" #include "nsIFile.h" -#include "nsIURI.h" #include "FileUtils.h" class nsZipArchive; diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp index b8b908be994d..0d27e9f17f82 100644 --- a/xpcom/components/nsComponentManager.cpp +++ b/xpcom/components/nsComponentManager.cpp @@ -65,9 +65,12 @@ #include "nsManifestLineReader.h" #include "mozilla/GenericFactory.h" #include "nsSupportsPrimitives.h" +#include "nsArray.h" +#include "nsIMutableArray.h" #include "nsArrayEnumerator.h" #include "nsStringEnumerator.h" #include "mozilla/FileUtils.h" +#include "nsNetUtil.h" #include // for placement new @@ -1914,6 +1917,32 @@ nsComponentManagerImpl::RemoveBootstrappedManifestLocation(nsIFile* aLocation) return rv; } +NS_IMETHODIMP +nsComponentManagerImpl::GetManifestLocations(nsIArray **aLocations) +{ + NS_ENSURE_ARG_POINTER(aLocations); + *aLocations = nullptr; + + if (!sModuleLocations) + return NS_ERROR_NOT_INITIALIZED; + + nsCOMPtr locations = nsArray::Create(); + nsresult rv; + for (uint32_t i = 0; i < sModuleLocations->Length(); ++i) { + ComponentLocation& l = sModuleLocations->ElementAt(i); + FileLocation loc = l.location; + nsCString uriString; + loc.GetURIString(uriString); + nsCOMPtr uri; + rv = NS_NewURI(getter_AddRefs(uri), uriString); + if (NS_SUCCEEDED(rv)) + locations->AppendElement(uri, false); + } + + locations.forget(aLocations); + return NS_OK; +} + EXPORT_XPCOM_API(nsresult) XRE_AddManifestLocation(NSLocationType aType, nsIFile* aLocation) { diff --git a/xpcom/components/nsIComponentManager.idl b/xpcom/components/nsIComponentManager.idl index bd3922b0662d..1e5693a285a9 100644 --- a/xpcom/components/nsIComponentManager.idl +++ b/xpcom/components/nsIComponentManager.idl @@ -2,7 +2,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - + /** * The nsIComponentManager interface. */ @@ -11,10 +11,11 @@ interface nsIFile; interface nsIFactory; +interface nsIArray; -[scriptable, uuid(1d940426-5fe5-42c3-84ae-a300f2d9ebd5)] +[scriptable, uuid(d604ffc3-1ba3-4f6c-b65f-1ed4199364c3)] interface nsIComponentManager : nsISupports -{ +{ /** * getClassObject * @@ -89,6 +90,12 @@ interface nsIComponentManager : nsISupports */ void removeBootstrappedManifestLocation(in nsIFile aLocation); + /** + * getManifestLocations + * + * Get an array of nsIURIs of all registered and builtin manifest locations. + */ + nsIArray getManifestLocations(); }; From 56f51b56ab55ad698e3531b9bfd8528a7f727c4d Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Tue, 19 Nov 2013 06:24:07 -0600 Subject: [PATCH 50/72] Bug 939557 - Build bustage fix in vs11 and up in browsercomps - don't link to unicharutil and replace glue string compare calls with suitable crt replacements. r=rstrong --- browser/components/build/Makefile.in | 3 +-- browser/components/shell/src/nsWindowsShellService.cpp | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/browser/components/build/Makefile.in b/browser/components/build/Makefile.in index 1b05ef513fb2..cf39a5b1f3a2 100644 --- a/browser/components/build/Makefile.in +++ b/browser/components/build/Makefile.in @@ -20,8 +20,7 @@ OS_LIBS += $(call EXPAND_LIBNAME,version) endif EXTRA_DSO_LDOPTS += \ - $(call EXPAND_LIBNAME_PATH,unicharutil_external_s,$(LIBXUL_DIST)/lib) \ - $(XPCOM_STATICRUNTIME_GLUE_LDOPTS) \ + $(XPCOM_GLUE_LDOPTS) \ $(MOZ_COMPONENT_LIBS) \ $(NULL) diff --git a/browser/components/shell/src/nsWindowsShellService.cpp b/browser/components/shell/src/nsWindowsShellService.cpp index 30f9cf355d45..e0cc7ca6a12f 100644 --- a/browser/components/shell/src/nsWindowsShellService.cpp +++ b/browser/components/shell/src/nsWindowsShellService.cpp @@ -460,13 +460,13 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck, // Close the key that was opened. ::RegCloseKey(theKey); if (REG_FAILED(res) || - !valueData.Equals(currValue, CaseInsensitiveCompare)) { + _wcsicmp(valueData.get(), currValue)) { // Key wasn't set or was set to something other than our registry entry. NS_ConvertUTF8toUTF16 oldValueData(settings->oldValueData); offset = oldValueData.Find("%APPPATH%"); oldValueData.Replace(offset, 9, appLongPath); // The current registry value doesn't match the current or the old format. - if (!oldValueData.Equals(currValue, CaseInsensitiveCompare)) { + if (_wcsicmp(oldValueData.get(), currValue)) { *aIsDefaultBrowser = false; return NS_OK; } @@ -579,7 +579,7 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck, // Don't update the FTP protocol handler's shell open command when the // current registry value doesn't exist or matches the old format. if (REG_FAILED(res) || - !oldValueOpen.Equals(currValue, CaseInsensitiveCompare)) { + _wcsicmp(oldValueOpen.get(), currValue)) { ::RegCloseKey(theKey); return NS_OK; } From b438a082865280087eadfaf751ec149f5c44cd69 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 18 Nov 2013 21:51:48 -0500 Subject: [PATCH 51/72] Bug 940170 - part 1 - constify PLDHashTableOps in layout/; r=bz --- layout/base/nsFrameManager.cpp | 2 +- layout/style/nsCSSRuleProcessor.cpp | 4 ++-- layout/style/nsHTMLStyleSheet.cpp | 4 ++-- layout/style/nsRuleNode.cpp | 2 +- layout/style/nsRuleNode.h | 2 +- layout/tables/SpanningCellSorter.cpp | 2 +- layout/tables/SpanningCellSorter.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 84b41059cbff..174ab2be9e22 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -65,7 +65,7 @@ PlaceholderMapMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, return entry->placeholderFrame->GetOutOfFlowFrame() == key; } -static PLDHashTableOps PlaceholderMapOps = { +static const PLDHashTableOps PlaceholderMapOps = { PL_DHashAllocTable, PL_DHashFreeTable, PL_DHashVoidPtrKeyStub, diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index aad90fc21012..c0c512f18373 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -194,7 +194,7 @@ typedef nsIAtom* (* RuleHashGetKey) (PLDHashTable *table, const PLDHashEntryHdr *entry); struct RuleHashTableOps { - PLDHashTableOps ops; + const PLDHashTableOps ops; // Extra callback to avoid duplicating the matchEntry callback for // each table. (There used to be a getKey callback in // PLDHashTableOps.) @@ -3097,7 +3097,7 @@ InitWeightEntry(PLDHashTable *table, PLDHashEntryHdr *hdr, return true; } -static PLDHashTableOps gRulesByWeightOps = { +static const PLDHashTableOps gRulesByWeightOps = { PL_DHashAllocTable, PL_DHashFreeTable, HashIntKey, diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 78051edb4ffc..2113c561e9a1 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -158,7 +158,7 @@ MappedAttrTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, return attributes->Equals(entry->mAttributes); } -static PLDHashTableOps MappedAttrTable_Ops = { +static const PLDHashTableOps MappedAttrTable_Ops = { PL_DHashAllocTable, PL_DHashFreeTable, MappedAttrTable_HashKey, @@ -215,7 +215,7 @@ LangRuleTable_InitEntry(PLDHashTable *table, PLDHashEntryHdr *hdr, return true; } -static PLDHashTableOps LangRuleTable_Ops = { +static const PLDHashTableOps LangRuleTable_Ops = { PL_DHashAllocTable, PL_DHashFreeTable, LangRuleTable_HashKey, diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 467f15789da1..9d95887bd0c9 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -104,7 +104,7 @@ nsRuleNode::ChildrenHashMatchEntry(PLDHashTable *aTable, return entry->mRuleNode->GetKey() == *key; } -/* static */ PLDHashTableOps +/* static */ const PLDHashTableOps nsRuleNode::ChildrenHashOps = { // It's probably better to allocate the table itself using malloc and // free rather than the pres shell's arena because the table doesn't diff --git a/layout/style/nsRuleNode.h b/layout/style/nsRuleNode.h index 788d178e305d..950c2760ac5e 100644 --- a/layout/style/nsRuleNode.h +++ b/layout/style/nsRuleNode.h @@ -304,7 +304,7 @@ private: const PLDHashEntryHdr *aHdr, const void *aKey); - static PLDHashTableOps ChildrenHashOps; + static const PLDHashTableOps ChildrenHashOps; static PLDHashOperator EnqueueRuleNodeChildren(PLDHashTable *table, PLDHashEntryHdr *hdr, diff --git a/layout/tables/SpanningCellSorter.cpp b/layout/tables/SpanningCellSorter.cpp index 6c0cd28addde..acb2cee2505b 100644 --- a/layout/tables/SpanningCellSorter.cpp +++ b/layout/tables/SpanningCellSorter.cpp @@ -31,7 +31,7 @@ SpanningCellSorter::~SpanningCellSorter() delete [] mSortedHashTable; } -/* static */ PLDHashTableOps +/* static */ const PLDHashTableOps SpanningCellSorter::HashTableOps = { PL_DHashAllocTable, PL_DHashFreeTable, diff --git a/layout/tables/SpanningCellSorter.h b/layout/tables/SpanningCellSorter.h index fe473b9e21d2..b83e8acf80db 100644 --- a/layout/tables/SpanningCellSorter.h +++ b/layout/tables/SpanningCellSorter.h @@ -70,7 +70,7 @@ private: Item *mItems; }; - static PLDHashTableOps HashTableOps; + static const PLDHashTableOps HashTableOps; static PLDHashNumber HashTableHashKey(PLDHashTable *table, const void *key); From 1e28810bf27fbb56394961e6a09868a3a506f8ef Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 18 Nov 2013 21:52:15 -0500 Subject: [PATCH 52/72] Bug 940170 - part 2 - constify PLDHashTableOps in content/; r=bz --- content/base/src/nsContentList.cpp | 4 ++-- content/base/src/nsContentUtils.cpp | 2 +- content/base/src/nsDocument.cpp | 2 +- content/xbl/src/nsBindingManager.cpp | 2 +- content/xul/document/src/XULDocument.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/content/base/src/nsContentList.cpp b/content/base/src/nsContentList.cpp index f93b724fafc6..8449f86d0eae 100644 --- a/content/base/src/nsContentList.cpp +++ b/content/base/src/nsContentList.cpp @@ -205,7 +205,7 @@ NS_GetContentList(nsINode* aRootNode, return list.forget(); } - static PLDHashTableOps hash_table_ops = + static const PLDHashTableOps hash_table_ops = { PL_DHashAllocTable, PL_DHashFreeTable, @@ -326,7 +326,7 @@ GetFuncStringContentList(nsINode* aRootNode, nsRefPtr list; - static PLDHashTableOps hash_table_ops = + static const PLDHashTableOps hash_table_ops = { PL_DHashAllocTable, PL_DHashFreeTable, diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index b01b60594690..787a1d5fd2c7 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -395,7 +395,7 @@ nsContentUtils::Init() return NS_ERROR_FAILURE; if (!sEventListenerManagersHash.ops) { - static PLDHashTableOps hash_table_ops = + static const PLDHashTableOps hash_table_ops = { PL_DHashAllocTable, PL_DHashFreeTable, diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index da1efd648433..6b5feb2e73ff 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -3592,7 +3592,7 @@ nsDocument::SetSubDocumentFor(Element* aElement, nsIDocument* aSubDoc) if (!mSubDocuments) { // Create a new hashtable - static PLDHashTableOps hash_table_ops = + static const PLDHashTableOps hash_table_ops = { PL_DHashAllocTable, PL_DHashFreeTable, diff --git a/content/xbl/src/nsBindingManager.cpp b/content/xbl/src/nsBindingManager.cpp index 1206077f6148..f91980b1bbdf 100644 --- a/content/xbl/src/nsBindingManager.cpp +++ b/content/xbl/src/nsBindingManager.cpp @@ -92,7 +92,7 @@ InitObjectEntry(PLDHashTable* table, PLDHashEntryHdr* entry, const void* key) -static PLDHashTableOps ObjectTableOps = { +static const PLDHashTableOps ObjectTableOps = { PL_DHashAllocTable, PL_DHashFreeTable, PL_DHashVoidPtrKeyStub, diff --git a/content/xul/document/src/XULDocument.cpp b/content/xul/document/src/XULDocument.cpp index 7a62613af819..88b7d9d5588c 100644 --- a/content/xul/document/src/XULDocument.cpp +++ b/content/xul/document/src/XULDocument.cpp @@ -780,7 +780,7 @@ XULDocument::AddBroadcastListenerFor(Element& aBroadcaster, Element& aListener, return; } - static PLDHashTableOps gOps = { + static const PLDHashTableOps gOps = { PL_DHashAllocTable, PL_DHashFreeTable, PL_DHashVoidPtrKeyStub, From 08e317a625395e9e28817f751435518983435c22 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 18 Nov 2013 21:53:12 -0500 Subject: [PATCH 53/72] Bug 940170 - part 3 - constify PLDHashTableOps in dom/; r=bz --- dom/base/nsScriptNameSpaceManager.cpp | 2 +- dom/plugins/base/nsJSNPRuntime.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dom/base/nsScriptNameSpaceManager.cpp b/dom/base/nsScriptNameSpaceManager.cpp index 3cdca72faa33..c8b22bf2133c 100644 --- a/dom/base/nsScriptNameSpaceManager.cpp +++ b/dom/base/nsScriptNameSpaceManager.cpp @@ -337,7 +337,7 @@ nsScriptNameSpaceManager::RegisterInterface(const char* aIfName, nsresult nsScriptNameSpaceManager::Init() { - static PLDHashTableOps hash_table_ops = + static const PLDHashTableOps hash_table_ops = { PL_DHashAllocTable, PL_DHashFreeTable, diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index d3ca0781ca76..53b97e9a98f8 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -993,7 +993,7 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JSContext *cx, JS::Handle obj) if (!sJSObjWrappers.ops) { // No hash yet (or any more), initialize it. - static PLDHashTableOps ops = + static const PLDHashTableOps ops = { PL_DHashAllocTable, PL_DHashFreeTable, From 1cdb070dd95f31833c7a1496db65d9bf920678ad Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 18 Nov 2013 21:58:27 -0500 Subject: [PATCH 54/72] Bug 940170 - part 4 - constify PLDHashTableOps in miscellaneous other places; r=bz --- .../components/commandhandler/src/nsCommandParams.cpp | 2 +- .../components/commandhandler/src/nsCommandParams.h | 2 +- rdf/base/src/nsRDFService.cpp | 10 +++++----- uriloader/base/nsDocLoader.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/embedding/components/commandhandler/src/nsCommandParams.cpp b/embedding/components/commandhandler/src/nsCommandParams.cpp index 489952f4d1d4..27d52d72459f 100644 --- a/embedding/components/commandhandler/src/nsCommandParams.cpp +++ b/embedding/components/commandhandler/src/nsCommandParams.cpp @@ -13,7 +13,7 @@ using namespace mozilla; -PLDHashTableOps nsCommandParams::sHashOps = +const PLDHashTableOps nsCommandParams::sHashOps = { PL_DHashAllocTable, PL_DHashFreeTable, diff --git a/embedding/components/commandhandler/src/nsCommandParams.h b/embedding/components/commandhandler/src/nsCommandParams.h index f18189a99d96..92a68ecb8238 100644 --- a/embedding/components/commandhandler/src/nsCommandParams.h +++ b/embedding/components/commandhandler/src/nsCommandParams.h @@ -147,7 +147,7 @@ protected: int32_t mCurEntry; int32_t mNumEntries; // number of entries at start of enumeration (-1 indicates not known) - static PLDHashTableOps sHashOps; + static const PLDHashTableOps sHashOps; }; diff --git a/rdf/base/src/nsRDFService.cpp b/rdf/base/src/nsRDFService.cpp index 76ac6bbe7a7f..f8d06892e4a9 100644 --- a/rdf/base/src/nsRDFService.cpp +++ b/rdf/base/src/nsRDFService.cpp @@ -139,7 +139,7 @@ struct ResourceHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gResourceTableOps = { +static const PLDHashTableOps gResourceTableOps = { PL_DHashAllocTable, PL_DHashFreeTable, ResourceHashEntry::HashKey, @@ -177,7 +177,7 @@ struct LiteralHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gLiteralTableOps = { +static const PLDHashTableOps gLiteralTableOps = { PL_DHashAllocTable, PL_DHashFreeTable, LiteralHashEntry::HashKey, @@ -214,7 +214,7 @@ struct IntHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gIntTableOps = { +static const PLDHashTableOps gIntTableOps = { PL_DHashAllocTable, PL_DHashFreeTable, IntHashEntry::HashKey, @@ -255,7 +255,7 @@ struct DateHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gDateTableOps = { +static const PLDHashTableOps gDateTableOps = { PL_DHashAllocTable, PL_DHashFreeTable, DateHashEntry::HashKey, @@ -373,7 +373,7 @@ struct BlobHashEntry : public PLDHashEntryHdr { } }; -static PLDHashTableOps gBlobTableOps = { +static const PLDHashTableOps gBlobTableOps = { PL_DHashAllocTable, PL_DHashFreeTable, BlobHashEntry::HashKey, diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index 45574ad48eb3..17c6339d95a4 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -116,7 +116,7 @@ nsDocLoader::nsDocLoader() } #endif /* PR_LOGGING */ - static PLDHashTableOps hash_table_ops = + static const PLDHashTableOps hash_table_ops = { PL_DHashAllocTable, PL_DHashFreeTable, From 8d7557e7b2ab9c14c92281a25291a5e46aa1742a Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 18 Nov 2013 08:32:32 -0500 Subject: [PATCH 55/72] Bug 939659 - Build parts of the spellchecker in unified mode; r=roc --HG-- extra : rebase_source : a3468510cc0e3b0f0cf95a1b851662296fef5a27 --- extensions/spellcheck/hunspell/src/moz.build | 2 +- extensions/spellcheck/hunspell/src/mozHunspell.cpp | 1 - extensions/spellcheck/src/moz.build | 2 +- extensions/spellcheck/src/mozInlineSpellWordUtil.h | 5 +++++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/extensions/spellcheck/hunspell/src/moz.build b/extensions/spellcheck/hunspell/src/moz.build index cd5198b7d82f..c052431203c6 100644 --- a/extensions/spellcheck/hunspell/src/moz.build +++ b/extensions/spellcheck/hunspell/src/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ +UNIFIED_SOURCES += [ 'mozHunspell.cpp', 'mozHunspellDirProvider.cpp', ] diff --git a/extensions/spellcheck/hunspell/src/mozHunspell.cpp b/extensions/spellcheck/hunspell/src/mozHunspell.cpp index 4dfcaed32885..44b7b46cc026 100644 --- a/extensions/spellcheck/hunspell/src/mozHunspell.cpp +++ b/extensions/spellcheck/hunspell/src/mozHunspell.cpp @@ -78,7 +78,6 @@ #include "nsIPrefService.h" #include "nsIPrefBranch.h" -static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); static NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID); NS_IMPL_CYCLE_COLLECTING_ADDREF(mozHunspell) diff --git a/extensions/spellcheck/src/moz.build b/extensions/spellcheck/src/moz.build index 3198f58c4906..abe8e9f50edb 100644 --- a/extensions/spellcheck/src/moz.build +++ b/extensions/spellcheck/src/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ +UNIFIED_SOURCES += [ 'mozEnglishWordUtils.cpp', 'mozGenericWordUtils.cpp', 'mozInlineSpellChecker.cpp', diff --git a/extensions/spellcheck/src/mozInlineSpellWordUtil.h b/extensions/spellcheck/src/mozInlineSpellWordUtil.h index 87d7c4651e5d..584acbaa6334 100644 --- a/extensions/spellcheck/src/mozInlineSpellWordUtil.h +++ b/extensions/spellcheck/src/mozInlineSpellWordUtil.h @@ -3,6 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef mozInlineSpellWordUtil_h +#define mozInlineSpellWordUtil_h + #include "nsCOMPtr.h" #include "nsIDOMDocument.h" #include "nsIDocument.h" @@ -159,3 +162,5 @@ private: nsresult MakeRange(NodeOffset aBegin, NodeOffset aEnd, nsRange** aRange); nsresult MakeRangeForWord(const RealWord& aWord, nsRange** aRange); }; + +#endif From e19377c4a92e8db2c3f3296afdb5664da9058243 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Mon, 18 Nov 2013 21:34:00 -0500 Subject: [PATCH 56/72] Bug 936912 - Build xpcom in unified mode; r=froydnj --- xpcom/base/moz.build | 4 ++-- xpcom/base/nsGZFileWriter.h | 5 +++++ xpcom/build/moz.build | 6 +++--- xpcom/components/moz.build | 7 ++++++- xpcom/ds/moz.build | 11 ++++++++--- xpcom/glue/moz.build | 6 +++--- xpcom/glue/nsQuickSort.cpp | 6 ++++++ xpcom/io/moz.build | 2 +- xpcom/io/nsAppFileLocationProvider.h | 5 +++++ xpcom/io/nsInputStreamTee.cpp | 3 +++ xpcom/io/nsPipe3.cpp | 3 +++ xpcom/io/nsStorageStream.cpp | 3 +++ xpcom/reflect/xptinfo/src/moz.build | 2 +- xpcom/sample/moz.build | 2 +- xpcom/sample/nsSample.h | 5 +++++ xpcom/string/src/moz.build | 2 +- xpcom/threads/moz.build | 2 +- xpcom/threads/nsEventQueue.cpp | 3 +++ xpcom/threads/nsThread.cpp | 3 +++ xpcom/threads/nsThreadPool.cpp | 3 +++ xpcom/typelib/xpt/src/moz.build | 2 +- 21 files changed, 67 insertions(+), 18 deletions(-) diff --git a/xpcom/base/moz.build b/xpcom/base/moz.build index 1f5c4f702e96..d54dd77ba98a 100644 --- a/xpcom/base/moz.build +++ b/xpcom/base/moz.build @@ -86,7 +86,7 @@ if CONFIG['OS_ARCH'] == 'WINNT': 'WindowsVersion.h', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'AvailableMemoryTracker.cpp', 'ClearOnShutdown.cpp', 'CycleCollectedJSRuntime.cpp', @@ -120,7 +120,7 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': 'nsCrashOnException.cpp', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'nsErrorAssertsC.c', ] diff --git a/xpcom/base/nsGZFileWriter.h b/xpcom/base/nsGZFileWriter.h index 002c49e56e59..faacf099b007 100644 --- a/xpcom/base/nsGZFileWriter.h +++ b/xpcom/base/nsGZFileWriter.h @@ -4,6 +4,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef nsGZFileWriter_h +#define nsGZFileWriter_h + #include "nsIGZFileWriter.h" #include "zlib.h" @@ -39,3 +42,5 @@ private: bool mFinished; gzFile mGZFile; }; + +#endif diff --git a/xpcom/build/moz.build b/xpcom/build/moz.build index 981209ad298a..88905faa868d 100644 --- a/xpcom/build/moz.build +++ b/xpcom/build/moz.build @@ -44,10 +44,10 @@ else: include('../glue/objs.mozbuild') -SOURCES += xpcom_gluens_src_cppsrcs -SOURCES += xpcom_glue_src_cppsrcs +UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs +UNIFIED_SOURCES += xpcom_glue_src_cppsrcs -SOURCES += [ +UNIFIED_SOURCES += [ 'FileLocation.cpp', 'FrozenFunctions.cpp', 'LateWriteChecks.cpp', diff --git a/xpcom/components/moz.build b/xpcom/components/moz.build index 9a2d9eabdd38..0a50f7c0443a 100644 --- a/xpcom/components/moz.build +++ b/xpcom/components/moz.build @@ -26,10 +26,15 @@ EXPORTS.mozilla += [ 'ModuleUtils.h', ] +# These two files cannot be built in unified mode because they use the +# PL_ARENA_CONST_ALIGN_MASK macro with plarena.h. SOURCES += [ - 'ManifestParser.cpp', 'nsCategoryManager.cpp', 'nsComponentManager.cpp', +] + +UNIFIED_SOURCES += [ + 'ManifestParser.cpp', 'nsNativeComponentLoader.cpp', ] diff --git a/xpcom/ds/moz.build b/xpcom/ds/moz.build index 31de5dbc1551..5e6c31058e0f 100644 --- a/xpcom/ds/moz.build +++ b/xpcom/ds/moz.build @@ -70,7 +70,7 @@ EXPORTS.mozilla += [ 'TimeStamp.h', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'nsArray.cpp', 'nsAtomService.cpp', 'nsAtomTable.cpp', @@ -80,9 +80,7 @@ SOURCES += [ 'nsINIParserImpl.cpp', 'nsObserverList.cpp', 'nsObserverService.cpp', - 'nsPersistentProperties.cpp', 'nsProperties.cpp', - 'nsStaticNameTable.cpp', 'nsStringEnumerator.cpp', 'nsSupportsArray.cpp', 'nsSupportsArrayEnumerator.cpp', @@ -91,6 +89,13 @@ SOURCES += [ 'TimeStamp.cpp', ] +# These two files cannot be built in unified mode because they use the +# PL_ARENA_CONST_ALIGN_MASK macro with plarena.h. +SOURCES += [ + 'nsPersistentProperties.cpp', + 'nsStaticNameTable.cpp', +] + if CONFIG['OS_ARCH'] == 'WINNT': SOURCES += [ 'TimeStamp_windows.cpp', diff --git a/xpcom/glue/moz.build b/xpcom/glue/moz.build index 2bb3c1d1a925..e5b47aed6baf 100644 --- a/xpcom/glue/moz.build +++ b/xpcom/glue/moz.build @@ -87,10 +87,10 @@ EXPORTS.mozilla.threads += [ include('objs.mozbuild') -SOURCES += xpcom_gluens_src_cppsrcs -SOURCES += xpcom_glue_src_cppsrcs +UNIFIED_SOURCES += xpcom_gluens_src_cppsrcs +UNIFIED_SOURCES += xpcom_glue_src_cppsrcs -SOURCES += [ +UNIFIED_SOURCES += [ 'GenericModule.cpp', 'nsStringAPI.cpp', ] diff --git a/xpcom/glue/nsQuickSort.cpp b/xpcom/glue/nsQuickSort.cpp index caa829297285..0096cd112d8a 100644 --- a/xpcom/glue/nsQuickSort.cpp +++ b/xpcom/glue/nsQuickSort.cpp @@ -179,3 +179,9 @@ loop: SWAPINIT(a, es); } } + +#undef INLINE +#undef swapcode +#undef SWAPINIT +#undef swap +#undef vecswap diff --git a/xpcom/io/moz.build b/xpcom/io/moz.build index 84c9862d3f54..36da194bc477 100644 --- a/xpcom/io/moz.build +++ b/xpcom/io/moz.build @@ -90,7 +90,7 @@ EXPORTS.mozilla += [ 'Base64.h', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'Base64.cpp', 'nsAnonymousTemporaryFile.cpp', 'nsAppFileLocationProvider.cpp', diff --git a/xpcom/io/nsAppFileLocationProvider.h b/xpcom/io/nsAppFileLocationProvider.h index 7fb7e313088b..a552f8315ef2 100644 --- a/xpcom/io/nsAppFileLocationProvider.h +++ b/xpcom/io/nsAppFileLocationProvider.h @@ -3,6 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef nsAppFileLocationProvider_h +#define nsAppFileLocationProvider_h + #include "nsIDirectoryService.h" #include "nsIFile.h" #include "mozilla/Attributes.h" @@ -45,3 +48,5 @@ protected: nsCOMPtr mMozBinDirectory; }; + +#endif diff --git a/xpcom/io/nsInputStreamTee.cpp b/xpcom/io/nsInputStreamTee.cpp index 7ccf4cf75fd3..4ac153dfe217 100644 --- a/xpcom/io/nsInputStreamTee.cpp +++ b/xpcom/io/nsInputStreamTee.cpp @@ -18,6 +18,9 @@ using namespace mozilla; +#ifdef LOG +#undef LOG +#endif #ifdef PR_LOGGING static PRLogModuleInfo* GetTeeLog() diff --git a/xpcom/io/nsPipe3.cpp b/xpcom/io/nsPipe3.cpp index c5d88b0a56f8..eb63ef92432f 100644 --- a/xpcom/io/nsPipe3.cpp +++ b/xpcom/io/nsPipe3.cpp @@ -21,6 +21,9 @@ using namespace mozilla; +#ifdef LOG +#undef LOG +#endif #if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=nsPipe:5 diff --git a/xpcom/io/nsStorageStream.cpp b/xpcom/io/nsStorageStream.cpp index c67e74ab46da..1bf82156757a 100644 --- a/xpcom/io/nsStorageStream.cpp +++ b/xpcom/io/nsStorageStream.cpp @@ -45,6 +45,9 @@ GetStorageStreamLog() return sLog; } #endif +#ifdef LOG +#undef LOG +#endif #define LOG(args) PR_LOG(GetStorageStreamLog(), PR_LOG_DEBUG, args) nsStorageStream::nsStorageStream() diff --git a/xpcom/reflect/xptinfo/src/moz.build b/xpcom/reflect/xptinfo/src/moz.build index 3e27c711acef..cc4a3279638b 100644 --- a/xpcom/reflect/xptinfo/src/moz.build +++ b/xpcom/reflect/xptinfo/src/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ +UNIFIED_SOURCES += [ 'xptiInterfaceInfo.cpp', 'xptiInterfaceInfoManager.cpp', 'xptiTypelibGuts.cpp', diff --git a/xpcom/sample/moz.build b/xpcom/sample/moz.build index 9229070cca4b..9ced7e753326 100644 --- a/xpcom/sample/moz.build +++ b/xpcom/sample/moz.build @@ -17,7 +17,7 @@ XPIDL_SOURCES += ['nsISample.idl'] XPIDL_MODULE = 'xpcomsample' # CPP_SOURCES specifies C++ files to be built into a library. -SOURCES += [ +UNIFIED_SOURCES += [ 'nsSample.cpp', 'nsSampleModule.cpp', ] diff --git a/xpcom/sample/nsSample.h b/xpcom/sample/nsSample.h index 0b55abcc9ac5..8122c5ae129b 100644 --- a/xpcom/sample/nsSample.h +++ b/xpcom/sample/nsSample.h @@ -3,6 +3,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef nsSample_h +#define nsSample_h + /** * A sample of XPConnect. This file is the header of an implementation * nsSample of the nsISample interface. @@ -96,3 +99,5 @@ private: char* mValue; }; + +#endif diff --git a/xpcom/string/src/moz.build b/xpcom/string/src/moz.build index d3e2eaf2fcc7..5098c62f2bac 100644 --- a/xpcom/string/src/moz.build +++ b/xpcom/string/src/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -SOURCES += [ +UNIFIED_SOURCES += [ 'nsDependentString.cpp', 'nsDependentSubstring.cpp', 'nsPromiseFlatString.cpp', diff --git a/xpcom/threads/moz.build b/xpcom/threads/moz.build index c81de0a996fd..071c7357b070 100644 --- a/xpcom/threads/moz.build +++ b/xpcom/threads/moz.build @@ -33,7 +33,7 @@ EXPORTS.mozilla += [ 'SyncRunnable.h', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'HangMonitor.cpp', 'LazyIdleThread.cpp', 'nsEnvironment.cpp', diff --git a/xpcom/threads/nsEventQueue.cpp b/xpcom/threads/nsEventQueue.cpp index 2b36b1f7462e..496945f1f9aa 100644 --- a/xpcom/threads/nsEventQueue.cpp +++ b/xpcom/threads/nsEventQueue.cpp @@ -21,6 +21,9 @@ GetLog() return sLog; } #endif +#ifdef LOG +#undef LOG +#endif #define LOG(args) PR_LOG(GetLog(), PR_LOG_DEBUG, args) nsEventQueue::nsEventQueue() diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp index 236fb4b1bb8e..94e8a04da130 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -51,6 +51,9 @@ GetThreadLog() return sLog; } #endif +#ifdef LOG +#undef LOG +#endif #define LOG(args) PR_LOG(GetThreadLog(), PR_LOG_DEBUG, args) NS_DECL_CI_INTERFACE_GETTER(nsThread) diff --git a/xpcom/threads/nsThreadPool.cpp b/xpcom/threads/nsThreadPool.cpp index f837d24ff9bf..2ccc4b0142f2 100644 --- a/xpcom/threads/nsThreadPool.cpp +++ b/xpcom/threads/nsThreadPool.cpp @@ -25,6 +25,9 @@ GetThreadPoolLog() return sLog; } #endif +#ifdef LOG +#undef LOG +#endif #define LOG(args) PR_LOG(GetThreadPoolLog(), PR_LOG_DEBUG, args) // DESIGN: diff --git a/xpcom/typelib/xpt/src/moz.build b/xpcom/typelib/xpt/src/moz.build index fe5586214ad0..ce9c012bf4a2 100644 --- a/xpcom/typelib/xpt/src/moz.build +++ b/xpcom/typelib/xpt/src/moz.build @@ -6,7 +6,7 @@ LIBRARY_NAME = 'xpt' -SOURCES += [ +UNIFIED_SOURCES += [ 'xpt_arena.c', 'xpt_struct.c', 'xpt_xdr.c', From 84a8a1d796f5ce037b265509ffbe5149cfbe1a88 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 19 Nov 2013 07:38:59 -0500 Subject: [PATCH 57/72] Bug 939538 - Build parts of the ipc code in unified mode; r=glandium --- ipc/chromium/moz.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build index e5a2a29ef9dc..c898fe2ca431 100644 --- a/ipc/chromium/moz.build +++ b/ipc/chromium/moz.build @@ -35,7 +35,7 @@ else: else: os_linux = 1 -SOURCES += [ +UNIFIED_SOURCES += [ 'src/base/at_exit.cc', 'src/base/base_paths.cc', 'src/base/base_switches.cc', @@ -179,7 +179,7 @@ if os_posix: ] if os_macosx: - SOURCES += [ + UNIFIED_SOURCES += [ 'src/base/debug_util_mac.cc', 'src/base/hmac_mac.cc', 'src/base/idle_timer.cc', @@ -204,7 +204,7 @@ if os_macosx: 'src/chrome/common/mach_ipc_mac.mm', ] if not CONFIG['MOZ_NATIVE_LIBEVENT']: - SOURCES += [ + UNIFIED_SOURCES += [ 'src/third_party/libevent/kqueue.c', ] From 15ab27326d3ebdc124561cb35f7800e7b6671585 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 19 Nov 2013 07:42:45 -0500 Subject: [PATCH 58/72] Bug 939596 - Build content/event in unified mode; r=glandium --- content/events/src/moz.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/content/events/src/moz.build b/content/events/src/moz.build index 2a6a88032bc5..ce5b30b5cb11 100644 --- a/content/events/src/moz.build +++ b/content/events/src/moz.build @@ -20,7 +20,7 @@ EXPORTS.mozilla.dom += [ if CONFIG['MOZ_WEBSPEECH']: EXPORTS.mozilla.dom += ['SpeechRecognitionError.h'] -SOURCES += [ +UNIFIED_SOURCES += [ 'DOMWheelEvent.cpp', 'EventTarget.cpp', 'nsAsyncDOMEvent.cpp', @@ -54,7 +54,6 @@ SOURCES += [ 'nsEventDispatcher.cpp', 'nsEventListenerManager.cpp', 'nsEventListenerService.cpp', - 'nsEventStateManager.cpp', 'nsIMEStateManager.cpp', 'nsPaintRequest.cpp', 'nsPrivateTextRange.cpp', @@ -62,8 +61,13 @@ SOURCES += [ 'Touch.cpp', ] +# nsEventStateManager.cpp should be built separately because of Mac OS X headers. +SOURCES += [ + 'nsEventStateManager.cpp', +] + if CONFIG['MOZ_WEBSPEECH']: - SOURCES += ['SpeechRecognitionError.cpp'] + UNIFIED_SOURCES += ['SpeechRecognitionError.cpp'] FAIL_ON_WARNINGS = True From a79fd702d0134426eb09ef3f832042e2bd833a3f Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 14:12:53 +0100 Subject: [PATCH 59/72] Backed out changeset 21df28ade757 (bug 939608) PGO build issue --- js/xpconnect/src/XPCJSID.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/xpconnect/src/XPCJSID.cpp b/js/xpconnect/src/XPCJSID.cpp index 8f5b8cb1cf37..974f75c7a379 100644 --- a/js/xpconnect/src/XPCJSID.cpp +++ b/js/xpconnect/src/XPCJSID.cpp @@ -825,7 +825,7 @@ nsJSCID::Construct(nsIXPConnectWrappedNative *wrapper, // 'push' a call context and call on it RootedId name(cx, rt->GetStringID(XPCJSRuntime::IDX_CREATE_INSTANCE)); - XPCCallContext ccx(JS_CALLER, cx, obj, JS::NullPtr(), name, args.length(), args.array(), + XPCCallContext ccx(JS_CALLER, cx, obj, js::NullPtr(), name, args.length(), args.array(), args.rval().address()); *_retval = XPCWrappedNative::CallMethod(ccx); From 30de6cc6d3db4bed1f23bdcf597cdfb66d65ab08 Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Tue, 19 Nov 2013 14:13:15 +0100 Subject: [PATCH 60/72] Backed out changeset 161bfee3f57a (bug 939608) PGO build issue --- js/xpconnect/loader/moz.build | 2 +- js/xpconnect/loader/mozJSComponentLoader.h | 5 ----- js/xpconnect/src/XPCJSID.cpp | 2 +- js/xpconnect/src/moz.build | 2 +- js/xpconnect/tests/components/native/moz.build | 2 +- js/xpconnect/wrappers/XrayWrapper.h | 4 ---- js/xpconnect/wrappers/moz.build | 6 +----- 7 files changed, 5 insertions(+), 18 deletions(-) diff --git a/js/xpconnect/loader/moz.build b/js/xpconnect/loader/moz.build index 8b17ac0d5c28..af7d6b10a8d7 100644 --- a/js/xpconnect/loader/moz.build +++ b/js/xpconnect/loader/moz.build @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -UNIFIED_SOURCES += [ +SOURCES += [ 'mozJSComponentLoader.cpp', 'mozJSLoaderUtils.cpp', 'mozJSSubScriptLoader.cpp', diff --git a/js/xpconnect/loader/mozJSComponentLoader.h b/js/xpconnect/loader/mozJSComponentLoader.h index 8927ebe886c0..c7d7b4112910 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.h +++ b/js/xpconnect/loader/mozJSComponentLoader.h @@ -4,9 +4,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef mozJSComponentLoader_h -#define mozJSComponentLoader_h - #include "mozilla/ModuleLoader.h" #include "nsISupports.h" #include "nsIObserver.h" @@ -146,5 +143,3 @@ class mozJSComponentLoader : public mozilla::ModuleLoader, bool mInitialized; bool mReuseLoaderGlobal; }; - -#endif /* mozJSComponentLoader_h */ diff --git a/js/xpconnect/src/XPCJSID.cpp b/js/xpconnect/src/XPCJSID.cpp index 974f75c7a379..18c2decad4ea 100644 --- a/js/xpconnect/src/XPCJSID.cpp +++ b/js/xpconnect/src/XPCJSID.cpp @@ -825,7 +825,7 @@ nsJSCID::Construct(nsIXPConnectWrappedNative *wrapper, // 'push' a call context and call on it RootedId name(cx, rt->GetStringID(XPCJSRuntime::IDX_CREATE_INSTANCE)); - XPCCallContext ccx(JS_CALLER, cx, obj, js::NullPtr(), name, args.length(), args.array(), + XPCCallContext ccx(JS_CALLER, cx, obj, NullPtr(), name, args.length(), args.array(), args.rval().address()); *_retval = XPCWrappedNative::CallMethod(ccx); diff --git a/js/xpconnect/src/moz.build b/js/xpconnect/src/moz.build index ac52043c14e0..00bd09627038 100644 --- a/js/xpconnect/src/moz.build +++ b/js/xpconnect/src/moz.build @@ -13,7 +13,7 @@ EXPORTS += [ 'xpcpublic.h', ] -UNIFIED_SOURCES += [ +SOURCES += [ 'nsCxPusher.cpp', 'nsScriptError.cpp', 'nsXPConnect.cpp', diff --git a/js/xpconnect/tests/components/native/moz.build b/js/xpconnect/tests/components/native/moz.build index bb6c4e8040de..a1d17d666102 100644 --- a/js/xpconnect/tests/components/native/moz.build +++ b/js/xpconnect/tests/components/native/moz.build @@ -6,7 +6,7 @@ NO_DIST_INSTALL = True -UNIFIED_SOURCES += [ +SOURCES += [ 'xpctest_attributes.cpp', 'xpctest_module.cpp', 'xpctest_params.cpp', diff --git a/js/xpconnect/wrappers/XrayWrapper.h b/js/xpconnect/wrappers/XrayWrapper.h index 083d82210d5f..91f147076813 100644 --- a/js/xpconnect/wrappers/XrayWrapper.h +++ b/js/xpconnect/wrappers/XrayWrapper.h @@ -5,9 +5,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef __XrayWrapper_h__ -#define __XrayWrapper_h__ - #include "mozilla/Attributes.h" #include "jswrapper.h" @@ -193,4 +190,3 @@ private: } -#endif /* __XrayWrapper_h__ */ diff --git a/js/xpconnect/wrappers/moz.build b/js/xpconnect/wrappers/moz.build index 5ee2135232c5..a12a03ef6f97 100644 --- a/js/xpconnect/wrappers/moz.build +++ b/js/xpconnect/wrappers/moz.build @@ -8,16 +8,12 @@ EXPORTS += [ 'WrapperFactory.h', ] -UNIFIED_SOURCES += [ +SOURCES += [ 'AccessCheck.cpp', 'ChromeObjectWrapper.cpp', 'FilteringWrapper.cpp', 'WaiveXrayWrapper.cpp', 'WrapperFactory.cpp', -] - -# XrayWrapper needs to be built separately because of template instantiations. -SOURCES += [ 'XrayWrapper.cpp', ] From b6ab6af557c30699cfda4c0444fc47260138f3e4 Mon Sep 17 00:00:00 2001 From: Michael Shuen Date: Tue, 19 Nov 2013 08:13:29 -0500 Subject: [PATCH 61/72] Bug 940153 - Build dom/encoding in unified mode; r=bzbarsky --HG-- extra : rebase_source : ee7223645f90a009eafbced43b8cfc2b93aeb47c --- dom/encoding/moz.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/encoding/moz.build b/dom/encoding/moz.build index 35a8fd6f5342..4d46c9fee339 100644 --- a/dom/encoding/moz.build +++ b/dom/encoding/moz.build @@ -13,7 +13,7 @@ EXPORTS.mozilla.dom += [ 'TextEncoder.h', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'EncodingUtils.cpp', 'FallbackEncoding.cpp', 'TextDecoder.cpp', From 00aca41e7a6cb2773f6fb9ad35626c4dd7933ce8 Mon Sep 17 00:00:00 2001 From: Michael Shuen Date: Tue, 19 Nov 2013 08:17:35 -0500 Subject: [PATCH 62/72] Bug 940117 - Build startupcache in unified mode; r=ehsan --- startupcache/moz.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/startupcache/moz.build b/startupcache/moz.build index 740539c799ff..feb70f864b7d 100644 --- a/startupcache/moz.build +++ b/startupcache/moz.build @@ -18,7 +18,7 @@ EXPORTS.mozilla.scache += [ 'StartupCacheUtils.h', ] -SOURCES += [ +UNIFIED_SOURCES += [ 'StartupCache.cpp', 'StartupCacheModule.cpp', 'StartupCacheUtils.cpp', From d24a8dc958f1d36ec1962b0a83fbdf8c54cc64df Mon Sep 17 00:00:00 2001 From: Michael Shuen Date: Tue, 19 Nov 2013 08:19:16 -0500 Subject: [PATCH 63/72] Bug 939795 - Build image/decoder in unified mode; r=ehsan --- image/decoders/moz.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image/decoders/moz.build b/image/decoders/moz.build index f3593d78b840..689c10a4257e 100644 --- a/image/decoders/moz.build +++ b/image/decoders/moz.build @@ -23,7 +23,7 @@ if toolkit == 'cocoa': elif toolkit == 'android': DIRS += ['icon/android', 'icon'] -SOURCES += [ +UNIFIED_SOURCES += [ 'EXIF.cpp', 'nsBMPDecoder.cpp', 'nsGIFDecoder2.cpp', From 31635f47cfc5faa84e959b31c2143ffb965b54c4 Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Tue, 19 Nov 2013 13:29:29 +0000 Subject: [PATCH 64/72] Bug 869696 - Enable Gralloc on the Geeksphone Peak again. r=bjacob The issues that caused it to be disabled initially have now been resolved. --- gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp index 750c21388972..00c9a4cc1661 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp @@ -386,9 +386,6 @@ ISurfaceAllocator::PlatformAllocSurfaceDescriptor(const gfxIntSize& aSize, if (strcmp("crespo",propValue) == 0) { NS_WARNING("Nexus S has issues with gralloc, falling back to shmem"); disableGralloc = true; - } else if (strcmp("peak", propValue) == 0) { - NS_WARNING("Geeksphone Peak has issues with gralloc, falling back to shmem"); - disableGralloc = true; } checkedDevice = true; From f228124f2df5fac7b70b785bc0db44d8dfe73c2d Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Tue, 19 Nov 2013 08:44:56 -0500 Subject: [PATCH 65/72] Backed out changeset 962d9383207f (bug 940153) because of build bustage Landed on a CLOSED TREE --- dom/encoding/moz.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/encoding/moz.build b/dom/encoding/moz.build index 4d46c9fee339..35a8fd6f5342 100644 --- a/dom/encoding/moz.build +++ b/dom/encoding/moz.build @@ -13,7 +13,7 @@ EXPORTS.mozilla.dom += [ 'TextEncoder.h', ] -UNIFIED_SOURCES += [ +SOURCES += [ 'EncodingUtils.cpp', 'FallbackEncoding.cpp', 'TextDecoder.cpp', From ddceaa0d729d012fbd3bc9c64d8d2e2479cc6809 Mon Sep 17 00:00:00 2001 From: huxuan Date: Tue, 19 Nov 2013 09:08:30 -0500 Subject: [PATCH 66/72] Bug 685628 - Make mpadded apply height/depth to logical metrics. r=fredw, r=karlt --- layout/mathml/nsMathMLmpaddedFrame.cpp | 29 +++++++++++------------ layout/mathml/nsMathMLmpaddedFrame.h | 2 +- layout/reftests/mathml/mpadded-7-ref.html | 15 ++++++++++++ layout/reftests/mathml/mpadded-7.html | 16 +++++++++++++ layout/reftests/mathml/mpadded-8-ref.html | 15 ++++++++++++ layout/reftests/mathml/mpadded-8.html | 16 +++++++++++++ layout/reftests/mathml/mpadded-9-ref.html | 15 ++++++++++++ layout/reftests/mathml/mpadded-9.html | 16 +++++++++++++ layout/reftests/mathml/reftest.list | 3 +++ 9 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 layout/reftests/mathml/mpadded-7-ref.html create mode 100644 layout/reftests/mathml/mpadded-7.html create mode 100644 layout/reftests/mathml/mpadded-8-ref.html create mode 100644 layout/reftests/mathml/mpadded-8.html create mode 100644 layout/reftests/mathml/mpadded-9-ref.html create mode 100644 layout/reftests/mathml/mpadded-9.html diff --git a/layout/mathml/nsMathMLmpaddedFrame.cpp b/layout/mathml/nsMathMLmpaddedFrame.cpp index 87a34e196869..987e18abbd67 100644 --- a/layout/mathml/nsMathMLmpaddedFrame.cpp +++ b/layout/mathml/nsMathMLmpaddedFrame.cpp @@ -266,7 +266,7 @@ void nsMathMLmpaddedFrame::UpdateValue(int32_t aSign, int32_t aPseudoUnit, const nsCSSValue& aCSSValue, - const nsBoundingMetrics& aBoundingMetrics, + const nsHTMLReflowMetrics& aDesiredSize, nscoord& aValueToUpdate) const { nsCSSUnit unit = aCSSValue.GetUnit(); @@ -276,15 +276,15 @@ nsMathMLmpaddedFrame::UpdateValue(int32_t aSign, if (eCSSUnit_Percent == unit || eCSSUnit_Number == unit) { switch(aPseudoUnit) { case NS_MATHML_PSEUDO_UNIT_WIDTH: - scaler = aBoundingMetrics.width; + scaler = aDesiredSize.width; break; case NS_MATHML_PSEUDO_UNIT_HEIGHT: - scaler = aBoundingMetrics.ascent; + scaler = aDesiredSize.ascent; break; case NS_MATHML_PSEUDO_UNIT_DEPTH: - scaler = aBoundingMetrics.descent; + scaler = aDesiredSize.height - aDesiredSize.ascent; break; default: @@ -339,8 +339,8 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, return rv; } - nscoord height = mBoundingMetrics.ascent; - nscoord depth = mBoundingMetrics.descent; + nscoord height = aDesiredSize.ascent; + nscoord depth = aDesiredSize.height - aDesiredSize.ascent; // The REC says: // // "The lspace attribute ('leading' space) specifies the horizontal location @@ -366,7 +366,7 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, // refer "to the horizontal distance between the positioning point of the // mpadded and the positioning point for the following content". MathML2 // doesn't make the distinction. - nscoord width = mBoundingMetrics.width; + nscoord width = aDesiredSize.width; nscoord voffset = 0; int32_t pseudoUnit; @@ -376,35 +376,35 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, pseudoUnit = (mWidthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF) ? NS_MATHML_PSEUDO_UNIT_WIDTH : mWidthPseudoUnit; UpdateValue(mWidthSign, pseudoUnit, mWidth, - mBoundingMetrics, width); + aDesiredSize, width); width = std::max(0, width); // update "height" (this is the ascent in the terminology of the REC) pseudoUnit = (mHeightPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF) ? NS_MATHML_PSEUDO_UNIT_HEIGHT : mHeightPseudoUnit; UpdateValue(mHeightSign, pseudoUnit, mHeight, - mBoundingMetrics, height); + aDesiredSize, height); height = std::max(0, height); // update "depth" (this is the descent in the terminology of the REC) pseudoUnit = (mDepthPseudoUnit == NS_MATHML_PSEUDO_UNIT_ITSELF) ? NS_MATHML_PSEUDO_UNIT_DEPTH : mDepthPseudoUnit; UpdateValue(mDepthSign, pseudoUnit, mDepth, - mBoundingMetrics, depth); + aDesiredSize, depth); depth = std::max(0, depth); // update lspace if (mLeadingSpacePseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) { pseudoUnit = mLeadingSpacePseudoUnit; UpdateValue(mLeadingSpaceSign, pseudoUnit, mLeadingSpace, - mBoundingMetrics, lspace); + aDesiredSize, lspace); } // update voffset if (mVerticalOffsetPseudoUnit != NS_MATHML_PSEUDO_UNIT_ITSELF) { pseudoUnit = mVerticalOffsetPseudoUnit; UpdateValue(mVerticalOffsetSign, pseudoUnit, mVerticalOffset, - mBoundingMetrics, voffset); + aDesiredSize, voffset); } // do the padding now that we have everything // The idea here is to maintain the invariant that ... (i.e., @@ -427,13 +427,12 @@ nsMathMLmpaddedFrame::Place(nsRenderingContext& aRenderingContext, mBoundingMetrics.rightBearing = mBoundingMetrics.width; } - nscoord dy = height - mBoundingMetrics.ascent; nscoord dx = (StyleVisibility()->mDirection ? width - initialWidth - lspace : lspace); - aDesiredSize.ascent += dy; + aDesiredSize.ascent = height; aDesiredSize.width = mBoundingMetrics.width; - aDesiredSize.height += dy + depth - mBoundingMetrics.descent; + aDesiredSize.height = depth + aDesiredSize.ascent; mBoundingMetrics.ascent = height; mBoundingMetrics.descent = depth; aDesiredSize.mBoundingMetrics = mBoundingMetrics; diff --git a/layout/mathml/nsMathMLmpaddedFrame.h b/layout/mathml/nsMathMLmpaddedFrame.h index a08ef8984a1e..a4dfabfe7642 100644 --- a/layout/mathml/nsMathMLmpaddedFrame.h +++ b/layout/mathml/nsMathMLmpaddedFrame.h @@ -79,7 +79,7 @@ private: UpdateValue(int32_t aSign, int32_t aPseudoUnit, const nsCSSValue& aCSSValue, - const nsBoundingMetrics& aBoundingMetrics, + const nsHTMLReflowMetrics& aDesiredSize, nscoord& aValueToUpdate) const; }; diff --git a/layout/reftests/mathml/mpadded-7-ref.html b/layout/reftests/mathml/mpadded-7-ref.html new file mode 100644 index 000000000000..950df9c530a4 --- /dev/null +++ b/layout/reftests/mathml/mpadded-7-ref.html @@ -0,0 +1,15 @@ + + + + Test mpadded + + + + + + X + + + + + diff --git a/layout/reftests/mathml/mpadded-7.html b/layout/reftests/mathml/mpadded-7.html new file mode 100644 index 000000000000..e52dbeba2f2a --- /dev/null +++ b/layout/reftests/mathml/mpadded-7.html @@ -0,0 +1,16 @@ + + + + Test mpadded + + + + + + + _ + + + + + diff --git a/layout/reftests/mathml/mpadded-8-ref.html b/layout/reftests/mathml/mpadded-8-ref.html new file mode 100644 index 000000000000..949c042319bd --- /dev/null +++ b/layout/reftests/mathml/mpadded-8-ref.html @@ -0,0 +1,15 @@ + + + + Test mpadded + + + + + + X + + + + + diff --git a/layout/reftests/mathml/mpadded-8.html b/layout/reftests/mathml/mpadded-8.html new file mode 100644 index 000000000000..fe0ab8d0957d --- /dev/null +++ b/layout/reftests/mathml/mpadded-8.html @@ -0,0 +1,16 @@ + + + + Test mpadded + + + + + + + | + + + + + diff --git a/layout/reftests/mathml/mpadded-9-ref.html b/layout/reftests/mathml/mpadded-9-ref.html new file mode 100644 index 000000000000..97c158913fa7 --- /dev/null +++ b/layout/reftests/mathml/mpadded-9-ref.html @@ -0,0 +1,15 @@ + + + + Test mpadded + + + + + + X + + + + + diff --git a/layout/reftests/mathml/mpadded-9.html b/layout/reftests/mathml/mpadded-9.html new file mode 100644 index 000000000000..a5234e110204 --- /dev/null +++ b/layout/reftests/mathml/mpadded-9.html @@ -0,0 +1,16 @@ + + + + Test mpadded + + + + + + + | + + + + + diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list index 45907469250a..e03148125b45 100644 --- a/layout/reftests/mathml/reftest.list +++ b/layout/reftests/mathml/reftest.list @@ -92,6 +92,9 @@ fails == mstyle-5.xhtml mstyle-5-ref.xhtml # Bug 787215 == mpadded-5.html mpadded-5-ref.html == mpadded-1-2.html mpadded-1-2-ref.html == mpadded-6.html mpadded-6-ref.html +== mpadded-7.html mpadded-7-ref.html +== mpadded-8.html mpadded-8-ref.html +== mpadded-9.html mpadded-9-ref.html == math-display.html math-display-ref.html == scriptlevel-movablelimits-1.html scriptlevel-movablelimits-1-ref.html == munderover-align-accent-false.html munderover-align-accent-false-ref.html From fd3ed78a40cb24b66b9f7efe0879ef4ffdeaf5e3 Mon Sep 17 00:00:00 2001 From: David Caabeiro Date: Mon, 18 Nov 2013 20:15:37 +0100 Subject: [PATCH 67/72] Bug 897027 - Handle one argument cases for both Math.atan2() and Math.pow(). r=till --- js/src/jsmath.cpp | 26 +++-- js/src/tests/ecma_6/Math/20.2.2.ToNumber.js | 112 ++++++++++++++++++++ 2 files changed, 124 insertions(+), 14 deletions(-) create mode 100644 js/src/tests/ecma_6/Math/20.2.2.ToNumber.js diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index 039efacb36b1..682501f27256 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -294,16 +294,15 @@ js::math_atan2(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (args.length() <= 1) { - args.rval().setNaN(); - return true; - } - - double x, y; - if (!ToNumber(cx, args[0], &x) || !ToNumber(cx, args[1], &y)) + double y; + if (!ToNumber(cx, args.get(0), &y)) return false; - double z = ecmaAtan2(x, y); + double x; + if (!ToNumber(cx, args.get(1), &x)) + return false; + + double z = ecmaAtan2(y, x); args.rval().setDouble(z); return true; } @@ -640,13 +639,12 @@ js_math_pow(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (args.length() <= 1) { - args.rval().setNaN(); - return true; - } + double x; + if (!ToNumber(cx, args.get(0), &x)) + return false; - double x, y; - if (!ToNumber(cx, args[0], &x) || !ToNumber(cx, args[1], &y)) + double y; + if (!ToNumber(cx, args.get(1), &y)) return false; /* diff --git a/js/src/tests/ecma_6/Math/20.2.2.ToNumber.js b/js/src/tests/ecma_6/Math/20.2.2.ToNumber.js new file mode 100644 index 000000000000..de1f4e612c32 --- /dev/null +++ b/js/src/tests/ecma_6/Math/20.2.2.ToNumber.js @@ -0,0 +1,112 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +/* + * ECMA-262 6th Edition / Draft November 8, 2013 + * + * 20.2.2 Function Properties of the Math Object + */ + +/* + * This custom object will allow us to check if valueOf() is called + */ + +TestNumber.prototype = new Number(); + +function TestNumber(value) { + this.value = value; + this.valueOfCalled = false; +} + +TestNumber.prototype = { + valueOf: function() { + this.valueOfCalled = true; + return this.value; + } +} + +// Verify that each TestNumber's flag is set after calling Math func +function test(func /*, args */) { + var args = Array.prototype.slice.call(arguments, 1); + func.apply(null, args); + + for (var i = 0; i < args.length; ++i) + assertEq(args[i].valueOfCalled, true); +} + +// Note that we are not testing these functions' return values +// We only test whether valueOf() is called for each argument + +// 1. Test Math.atan2() +var x = new TestNumber(1); +test(Math.atan2, x); + +var x = new TestNumber(1); +var y = new TestNumber(2); +test(Math.atan2, y, x); + +// Remove comment block once patch for bug 896264 is approved +/* +// 2. Test Math.hypot() +var x = new TestNumber(1); +test(Math.hypot, x); + +var x = new TestNumber(1); +var y = new TestNumber(2); +test(Math.hypot, x, y); + +var x = new TestNumber(1); +var y = new TestNumber(2); +var z = new TestNumber(3); +test(Math.hypot, x, y, z); +*/ + +// Remove comment block once patch for bug 808148 is approved +/* +// 3. Test Math.imul() +var x = new TestNumber(1); +test(Math.imul, x); + +var x = new TestNumber(1); +var y = new TestNumber(2); +test(Math.imul, x, y); +*/ + +// 4. Test Math.max() +var x = new TestNumber(1); +test(Math.max, x); + +var x = new TestNumber(1); +var y = new TestNumber(2); +test(Math.max, x, y); + +var x = new TestNumber(1); +var y = new TestNumber(2); +var z = new TestNumber(3); +test(Math.max, x, y, z); + +// 5. Test Math.min() +var x = new TestNumber(1); +test(Math.min, x); + +var x = new TestNumber(1); +var y = new TestNumber(2); +test(Math.min, x, y); + +var x = new TestNumber(1); +var y = new TestNumber(2); +var z = new TestNumber(3); +test(Math.min, x, y, z); + +// 6. Test Math.pow() +var x = new TestNumber(1); +test(Math.pow, x); + +var x = new TestNumber(1); +var y = new TestNumber(2); +test(Math.pow, x, y); + +reportCompare(0, 0, "ok"); + From 8d6c5dce65238312ba8e2c4dda4ed585621daf16 Mon Sep 17 00:00:00 2001 From: James Kitchener Date: Tue, 19 Nov 2013 09:09:41 -0500 Subject: [PATCH 68/72] Bug 936886 - Account for possibility of non-null terminated strings in nsWindowsRegKey::ReadStringValue(). r=dmajor --- xpcom/ds/nsWindowsRegKey.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xpcom/ds/nsWindowsRegKey.cpp b/xpcom/ds/nsWindowsRegKey.cpp index c57ddfa239be..524e382061b9 100644 --- a/xpcom/ds/nsWindowsRegKey.cpp +++ b/xpcom/ds/nsWindowsRegKey.cpp @@ -287,8 +287,8 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result) return NS_OK; } - // |size| includes room for the terminating null character - DWORD resultLen = size / 2 - 1; + // |size| may or may not include the terminating null character. + DWORD resultLen = size / 2; result.SetLength(resultLen); nsAString::iterator begin; @@ -299,6 +299,11 @@ nsWindowsRegKey::ReadStringValue(const nsAString &name, nsAString &result) rv = RegQueryValueExW(mKey, flatName.get(), 0, &type, (LPBYTE) begin.get(), &size); + if (!result.CharAt(resultLen-1)) { + // The string passed to us had a null terminator in the final position. + result.Truncate(resultLen-1); + } + // Expand the environment variables if needed if (type == REG_EXPAND_SZ) { const nsString &flatSource = PromiseFlatString(result); From ad5b86b5ef675aaadef01606e7a09396ee3cd96f Mon Sep 17 00:00:00 2001 From: Michael Shuen Date: Tue, 19 Nov 2013 09:09:53 -0500 Subject: [PATCH 69/72] Bug 939471 - Fix typo in gcparam() error message. r=luke --- js/src/builtin/TestingFunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 9f2c11509833..720e623ae57b 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -285,7 +285,7 @@ GCParameter(JSContext *cx, unsigned argc, Value *vp) for (;; paramIndex++) { if (paramIndex == ArrayLength(paramMap)) { JS_ReportError(cx, - "the first argument argument must be maxBytes, " + "the first argument must be maxBytes, " "maxMallocBytes, gcStackpoolLifespan, gcBytes or " "gcNumber"); return false; From 6d6385c6cc54e1bcf96130368ee55c14d918af9f Mon Sep 17 00:00:00 2001 From: Johannes Buchner Date: Tue, 19 Nov 2013 09:13:44 -0500 Subject: [PATCH 70/72] Bug 912465 - Use MsgNewSafeBufferedFileOutputStream instead of NewLocalFileOutputStream in various places. r=ehsan --- extensions/spellcheck/src/mozPersonalDictionary.cpp | 10 +++++++++- modules/libpref/src/Preferences.cpp | 2 +- netwerk/base/src/nsBufferedStreams.cpp | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/extensions/spellcheck/src/mozPersonalDictionary.cpp b/extensions/spellcheck/src/mozPersonalDictionary.cpp index d6f9b55ee5f0..b7c99b0d4bfe 100644 --- a/extensions/spellcheck/src/mozPersonalDictionary.cpp +++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp @@ -153,7 +153,7 @@ NS_IMETHODIMP mozPersonalDictionary::Save() if(NS_FAILED(res)) return res; nsCOMPtr outStream; - NS_NewLocalFileOutputStream(getter_AddRefs(outStream), theFile, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE ,0664); + NS_NewSafeLocalFileOutputStream(getter_AddRefs(outStream), theFile, PR_CREATE_FILE | PR_WRONLY | PR_TRUNCATE ,0664); // get a buffered output stream 4096 bytes big, to optimize writes nsCOMPtr bufferedOutputStream; @@ -171,6 +171,14 @@ NS_IMETHODIMP mozPersonalDictionary::Save() bufferedOutputStream->Write(utf8Key.get(), utf8Key.Length(), &bytesWritten); bufferedOutputStream->Write("\n", 1, &bytesWritten); } + nsCOMPtr safeStream = do_QueryInterface(bufferedOutputStream); + NS_ASSERTION(safeStream, "expected a safe output stream!"); + if (safeStream) { + res = safeStream->Finish(); + if (NS_FAILED(res)) { + NS_WARNING("failed to save personal dictionary file! possible data loss"); + } + } return res; } diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp index 0160eb9c5119..593f0b97454b 100644 --- a/modules/libpref/src/Preferences.cpp +++ b/modules/libpref/src/Preferences.cpp @@ -939,7 +939,7 @@ Preferences::WritePrefFile(nsIFile* aFile) if (safeStream) { rv = safeStream->Finish(); if (NS_FAILED(rv)) { - NS_WARNING("failed to save prefs file! possible dataloss"); + NS_WARNING("failed to save prefs file! possible data loss"); return rv; } } diff --git a/netwerk/base/src/nsBufferedStreams.cpp b/netwerk/base/src/nsBufferedStreams.cpp index 60d918ab2201..0c91b4271534 100644 --- a/netwerk/base/src/nsBufferedStreams.cpp +++ b/netwerk/base/src/nsBufferedStreams.cpp @@ -629,7 +629,7 @@ nsBufferedOutputStream::Flush() nsresult rv; uint32_t amt; if (!mStream) { - // Stream already cancelled/flushed; probably because of error. + // Stream already cancelled/flushed; probably because of previous error. return NS_OK; } rv = Sink()->Write(mBuffer, mFillPoint, &amt); From ed0a7770ab6c678350905870993648c541246a76 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Tue, 19 Nov 2013 08:41:57 -0600 Subject: [PATCH 71/72] Bug 928804 - Always use an up-to-date texture transform when compositing SharedTextureSourceOGL r=nical --- dom/plugins/base/android/ANPNativeWindow.cpp | 1 + gfx/layers/opengl/TextureHostOGL.cpp | 21 ++++++++++++++------ gfx/layers/opengl/TextureHostOGL.h | 6 ++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/dom/plugins/base/android/ANPNativeWindow.cpp b/dom/plugins/base/android/ANPNativeWindow.cpp index c66d5eb8d3f3..4579c7ae7b5f 100644 --- a/dom/plugins/base/android/ANPNativeWindow.cpp +++ b/dom/plugins/base/android/ANPNativeWindow.cpp @@ -26,6 +26,7 @@ static ANPNativeWindow anp_native_window_acquireNativeWindow(NPP instance) { static void anp_native_window_invertPluginContent(NPP instance, bool isContentInverted) { nsNPAPIPluginInstance* pinst = static_cast(instance->ndata); pinst->SetInverted(isContentInverted); + pinst->RedrawPlugin(); } diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 067cce7a7fa1..0e3c9632a46e 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -300,10 +300,8 @@ SharedTextureSourceOGL::SharedTextureSourceOGL(CompositorOGL* aCompositor, GLenum aTarget, GLenum aWrapMode, SharedTextureShareType aShareType, - gfx::IntSize aSize, - const gfx3DMatrix& aTexTransform) - : mTextureTransform(aTexTransform) - , mSize(aSize) + gfx::IntSize aSize) + : mSize(aSize) , mCompositor(aCompositor) , mSharedHandle(aHandle) , mFormat(aFormat) @@ -357,6 +355,18 @@ SharedTextureSourceOGL::gl() const return mCompositor ? mCompositor->gl() : nullptr; } +gfx3DMatrix +SharedTextureSourceOGL::GetTextureTransform() +{ + GLContext::SharedHandleDetails handleDetails; + if (!gl()->GetSharedHandleDetails(mShareType, mSharedHandle, handleDetails)) { + NS_WARNING("Could not get shared handle details"); + return gfx3DMatrix(); + } + + return handleDetails.mTextureTransform; +} + SharedTextureHostOGL::SharedTextureHostOGL(uint64_t aID, TextureFlags aFlags, gl::SharedTextureShareType aShareType, @@ -406,8 +416,7 @@ SharedTextureHostOGL::Lock() handleDetails.mTarget, wrapMode, mShareType, - mSize, - handleDetails.mTextureTransform); + mSize); } return true; } diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index 9548acfe79ae..5ecde58b2920 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -251,8 +251,7 @@ public: GLenum aTarget, GLenum aWrapMode, SharedTextureShareType aShareType, - gfx::IntSize aSize, - const gfx3DMatrix& aTexTransform); + gfx::IntSize aSize); virtual TextureSourceOGL* AsSourceOGL() { return this; } @@ -264,7 +263,7 @@ public: virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; } - virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE { return mTextureTransform; } + virtual gfx3DMatrix GetTextureTransform() MOZ_OVERRIDE; virtual GLenum GetTextureTarget() const { return mTextureTarget; } @@ -282,7 +281,6 @@ public: gl::GLContext* gl() const; protected: - gfx3DMatrix mTextureTransform; gfx::IntSize mSize; CompositorOGL* mCompositor; gl::SharedTextureHandle mSharedHandle; From 4d640a0d2f60ad3266e5e235db7ff0ab7edaf9f1 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 19 Nov 2013 15:42:55 +0100 Subject: [PATCH 72/72] Bug 810716 - Detect res_ninit() on DragonFly and FreeBSD. r=ted --- configure.in | 3 +++ extensions/auth/nsAuthGSSAPI.cpp | 3 +++ js/src/configure.in | 3 +++ 3 files changed, 9 insertions(+) diff --git a/configure.in b/configure.in index fbf2b5e3f0f8..b5f39812ad6f 100644 --- a/configure.in +++ b/configure.in @@ -3105,6 +3105,9 @@ AC_CACHE_CHECK( #ifdef linux #define _BSD_SOURCE 1 #endif + #include + #include + #include #include ], [int foo = res_ninit(&_res);], diff --git a/extensions/auth/nsAuthGSSAPI.cpp b/extensions/auth/nsAuthGSSAPI.cpp index 1308b822fbc2..acfefd8b3073 100644 --- a/extensions/auth/nsAuthGSSAPI.cpp +++ b/extensions/auth/nsAuthGSSAPI.cpp @@ -40,6 +40,9 @@ typedef KLStatus (*KLCacheHasValidTickets_type)( #endif #if defined(HAVE_RES_NINIT) +#include +#include +#include #include #endif diff --git a/js/src/configure.in b/js/src/configure.in index 933d8b74f21c..a5596763dec8 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -2554,6 +2554,9 @@ AC_CACHE_CHECK( #ifdef linux #define _BSD_SOURCE 1 #endif + #include + #include + #include #include ], [int foo = res_ninit(&_res);],