Merge mozilla-central and inbound
authorEd Morley <emorley@mozilla.com>
Mon, 06 Jan 2014 15:20:18 +0000
changeset 162190 6c4c65228af1b71e1daa3ae3c737957836d693d2
parent 162182 bafaf8d078d8e0c2f61973b54231ef23ac3c7571 (current diff)
parent 162189 5954f2857de4a9d9d39f147279e33b9691da3051 (diff)
child 162191 5568609fa907c87e48d5cb78bd612cf6f7402949
push idunknown
push userunknown
push dateunknown
milestone29.0a1
Merge mozilla-central and inbound
--- a/content/base/src/nsScriptLoader.cpp
+++ b/content/base/src/nsScriptLoader.cpp
@@ -719,17 +719,17 @@ class NotifyOffThreadScriptLoadCompleted
 {
   nsRefPtr<nsScriptLoadRequest> mRequest;
   nsRefPtr<nsScriptLoader> mLoader;
   void *mToken;
 
 public:
   NotifyOffThreadScriptLoadCompletedRunnable(nsScriptLoadRequest* aRequest,
                                              nsScriptLoader* aLoader)
-    : mRequest(aRequest), mLoader(aLoader), mToken(NULL)
+    : mRequest(aRequest), mLoader(aLoader), mToken(nullptr)
   {}
 
   void SetToken(void* aToken) {
     MOZ_ASSERT(aToken && !mToken);
     mToken = aToken;
   }
 
   NS_DECL_NSIRUNNABLE
--- a/content/media/fmp4/wmf/MFTDecoder.cpp
+++ b/content/media/fmp4/wmf/MFTDecoder.cpp
@@ -31,17 +31,17 @@ MFTDecoder::~MFTDecoder()
 }
 
 HRESULT
 MFTDecoder::Create(const GUID& aMFTClsID)
 {
   // Create the IMFTransform to do the decoding.
   HRESULT hr;
   hr = CoCreateInstance(aMFTClsID,
-                        NULL,
+                        nullptr,
                         CLSCTX_INPROC_SERVER,
                         IID_IMFTransform,
                         reinterpret_cast<void**>(static_cast<IMFTransform**>(byRef(mDecoder))));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   return S_OK;
 }
 
--- a/content/media/fmp4/wmf/WMFVideoDecoder.cpp
+++ b/content/media/fmp4/wmf/WMFVideoDecoder.cpp
@@ -240,17 +240,17 @@ WMFVideoDecoder::CreateBasicVideoFrame(I
   BYTE* data = nullptr;
   LONG stride = 0;
   RefPtr<IMF2DBuffer> twoDBuffer;
   hr = buffer->QueryInterface(static_cast<IMF2DBuffer**>(byRef(twoDBuffer)));
   if (SUCCEEDED(hr)) {
     hr = twoDBuffer->Lock2D(&data, &stride);
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
   } else {
-    hr = buffer->Lock(&data, NULL, NULL);
+    hr = buffer->Lock(&data, nullptr, nullptr);
     NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
     stride = mVideoStride;
   }
 
   // YV12, planar format: [YYYY....][VVVV....][UUUU....]
   // i.e., Y, then V, then U.
   VideoData::YCbCrBuffer b;
 
--- a/dom/asmjscache/AsmJSCache.cpp
+++ b/dom/asmjscache/AsmJSCache.cpp
@@ -456,17 +456,17 @@ MainProcessRunnable::OpenFileOnIOThread(
 
   rv = path->Append(NS_LITERAL_STRING(ASMJSCACHE_FILE_NAME));
   NS_ENSURE_SUCCESS(rv, rv);
 
   mQuotaObject = qm->GetQuotaObject(quota::PERSISTENCE_TYPE_TEMPORARY,
                                     mGroup, mOrigin, path);
   NS_ENSURE_STATE(mQuotaObject);
 
-  int openFlags;
+  int32_t openFlags;
   if (mOpenMode == eOpenForRead) {
     rv = path->GetFileSize(&mFileSize);
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     openFlags = PR_RDONLY | nsIFile::OS_READAHEAD;
   } else {
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -421,17 +421,17 @@ DroidSocketImpl::ReadMsg(int aFd, void *
     return 0;
   }
 
   NS_ENSURE_FALSE(ret < 0, -1);
   NS_ENSURE_FALSE(msg.msg_flags & (MSG_CTRUNC | MSG_OOB | MSG_ERRQUEUE), -1);
 
   // Extract client fd from message header
   for (struct cmsghdr *cmsgptr = CMSG_FIRSTHDR(&msg);
-       cmsgptr != NULL; cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) {
+       cmsgptr != nullptr; cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) {
     if (cmsgptr->cmsg_level != SOL_SOCKET) {
       continue;
     }
     if (cmsgptr->cmsg_type == SCM_RIGHTS) {
       int *pDescriptors = (int *)CMSG_DATA(cmsgptr);
       // Overwrite fd with client fd
       mFd.reset(pDescriptors[0]);
       break;
--- a/gfx/2d/BaseRect.h
+++ b/gfx/2d/BaseRect.h
@@ -436,28 +436,28 @@ struct BaseRect {
    */
   Point ClampPoint(const Point& aPoint) const
   {
     return Point(std::max(x, std::min(XMost(), aPoint.x)),
                  std::max(y, std::min(YMost(), aPoint.y)));
   }
 
   /**
-   * Clamp aRect to this rectangle. This returns aRect after it is forced
-   * inside the bounds of this rectangle. It will attempt to retain the size
-   * but will shrink the dimensions that don't fit.
+   * Clamp this rectangle to be inside aRect. The function returns a copy of
+   * this rect after it is forced inside the bounds of aRect. It will attempt to
+   * retain the size but will shrink the dimensions that don't fit.
    */
-  Sub ClampRect(const Sub& aRect) const
+  Sub ForceInside(const Sub& aRect) const
   {
     Sub rect(std::max(aRect.x, x),
              std::max(aRect.y, y),
              std::min(aRect.width, width),
              std::min(aRect.height, height));
-    rect.x = std::min(rect.XMost(), XMost()) - rect.width;
-    rect.y = std::min(rect.YMost(), YMost()) - rect.height;
+    rect.x = std::min(rect.XMost(), aRect.XMost()) - rect.width;
+    rect.y = std::min(rect.YMost(), aRect.YMost()) - rect.height;
     return rect;
   }
 
 private:
   // Do not use the default operator== or operator!= !
   // Use IsEqualEdges or IsEqualInterior explicitly.
   bool operator==(const Sub& aRect) const { return false; }
   bool operator!=(const Sub& aRect) const { return false; }
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -746,17 +746,19 @@ DrawTargetSkia::CopySurface(SourceSurfac
 
   mCanvas->drawBitmapRect(bitmap, &source, dest, &paint);
   mCanvas->restore();
 }
 
 bool
 DrawTargetSkia::Init(const IntSize &aSize, SurfaceFormat aFormat)
 {
-  SkAutoTUnref<SkDevice> device(new SkDevice(GfxFormatToSkiaConfig(aFormat), aSize.width, aSize.height));
+  SkAutoTUnref<SkDevice> device(new SkDevice(GfxFormatToSkiaConfig(aFormat),
+                                             aSize.width, aSize.height,
+                                             aFormat == FORMAT_B8G8R8X8));
 
   SkBitmap bitmap = device->accessBitmap(true);
   if (!bitmap.allocPixels()) {
     return false;
   }
 
   bitmap.eraseARGB(0, 0, 0, 0);
 
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -184,17 +184,17 @@ struct EffectSolidColor : public Effect
 
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 
   gfx::Color mColor;
 };
 
 struct EffectChain
 {
-  EffectChain() : mLayerRef(NULL) {}
+  EffectChain() : mLayerRef(nullptr) {}
   explicit EffectChain(void* aLayerRef) : mLayerRef(aLayerRef) {}
 
   RefPtr<Effect> mPrimaryEffect;
   RefPtr<Effect> mSecondaryEffects[EFFECT_MAX_SECONDARY];
   void* mLayerRef; //!< For LayerScope logging
 };
 
 /**
--- a/gfx/layers/composite/ImageHost.h
+++ b/gfx/layers/composite/ImageHost.h
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * 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/. */
 
 #ifndef MOZILLA_GFX_IMAGEHOST_H
 #define MOZILLA_GFX_IMAGEHOST_H
 
-#include <stdio.h>                      // for FILE, NULL
+#include <stdio.h>                      // for FILE
 #include "CompositableHost.h"           // for CompositableHost
 #include "mozilla/Attributes.h"         // for MOZ_OVERRIDE
 #include "mozilla/RefPtr.h"             // for RefPtr
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for Rect
 #include "mozilla/gfx/Types.h"          // for Filter
 #include "mozilla/layers/CompositorTypes.h"  // for TextureInfo, etc
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor
@@ -65,19 +65,19 @@ public:
     mHasPictureRect = true;
   }
 
   virtual LayerRenderState GetRenderState() MOZ_OVERRIDE;
 
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 
 #ifdef MOZ_DUMP_PAINTING
-  virtual void Dump(FILE* aFile=NULL,
-                    const char* aPrefix="",
-                    bool aDumpHtml=false) MOZ_OVERRIDE;
+  virtual void Dump(FILE* aFile = nullptr,
+                    const char* aPrefix = "",
+                    bool aDumpHtml = false) MOZ_OVERRIDE;
 
   virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE;
 #endif
 
 protected:
 
   RefPtr<TextureHost> mFrontBuffer;
   nsIntRect mPictureRect;
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -93,17 +93,17 @@ CompositorD3D9::CreateRenderTarget(const
   if (!mDeviceManager) {
     return nullptr;
   }
 
   RefPtr<IDirect3DTexture9> texture;
   HRESULT hr = device()->CreateTexture(aRect.width, aRect.height, 1,
                                        D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
                                        D3DPOOL_DEFAULT, byRef(texture),
-                                       NULL);
+                                       nullptr);
   if (FAILED(hr)) {
     ReportFailure(NS_LITERAL_CSTRING("CompositorD3D9::CreateRenderTarget: Failed to create texture"),
                   hr);
     return nullptr;
   }
 
   RefPtr<CompositingRenderTargetD3D9> rt =
     new CompositingRenderTargetD3D9(texture, aInit, aRect);
@@ -119,17 +119,17 @@ CompositorD3D9::CreateRenderTargetFromSo
   if (!mDeviceManager) {
     return nullptr;
   }
 
   RefPtr<IDirect3DTexture9> texture;
   HRESULT hr = device()->CreateTexture(aRect.width, aRect.height, 1,
                                        D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
                                        D3DPOOL_DEFAULT, byRef(texture),
-                                       NULL);
+                                       nullptr);
   if (FAILED(hr)) {
     ReportFailure(NS_LITERAL_CSTRING("CompositorD3D9::CreateRenderTargetFromSource: Failed to create texture"),
                   hr);
     return nullptr;
   }
 
   if (aSource) {
     nsRefPtr<IDirect3DSurface9> sourceSurface =
@@ -404,17 +404,17 @@ CompositorD3D9::DrawQuad(const gfx::Rect
       maskTexture = mDeviceManager->SetShaderMode(DeviceManagerD3D9::COMPONENTLAYERPASS2, maskType);
       d3d9Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
       d3d9Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
       d3d9Device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
 
       // Restore defaults
       d3d9Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
       d3d9Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
-      d3d9Device->SetTexture(1, NULL);
+      d3d9Device->SetTexture(1, nullptr);
     }
     return;
   default:
     NS_WARNING("Unknown shader type");
     return;
   }
 
   SetMask(aEffectChain, maskTexture);
@@ -565,17 +565,17 @@ CompositorD3D9::BeginFrame(const nsIntRe
                            Rect *aRenderBoundsOut)
 {
   MOZ_ASSERT(mDeviceManager && mSwapChain);
 
   mDeviceManager->SetupRenderState();
 
   EnsureSize();
 
-  device()->Clear(0, NULL, D3DCLEAR_TARGET, 0x00000000, 0, 0);
+  device()->Clear(0, nullptr, D3DCLEAR_TARGET, 0x00000000, 0, 0);
   device()->BeginScene();
 
   if (aClipRectOut) {
     *aClipRectOut = Rect(0, 0, mSize.width, mSize.height);
   }
   if (aRenderBoundsOut) {
     *aRenderBoundsOut = Rect(0, 0, mSize.width, mSize.height);
   }
@@ -682,22 +682,22 @@ CompositorD3D9::PaintToTarget()
   nsRefPtr<IDirect3DSurface9> destSurf;
   device()->GetRenderTarget(0, getter_AddRefs(backBuff));
 
   D3DSURFACE_DESC desc;
   backBuff->GetDesc(&desc);
 
   device()->CreateOffscreenPlainSurface(desc.Width, desc.Height,
                                         D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM,
-                                        getter_AddRefs(destSurf), NULL);
+                                        getter_AddRefs(destSurf), nullptr);
 
   device()->GetRenderTargetData(backBuff, destSurf);
 
   D3DLOCKED_RECT rect;
-  destSurf->LockRect(&rect, NULL, D3DLOCK_READONLY);
+  destSurf->LockRect(&rect, nullptr, D3DLOCK_READONLY);
   RefPtr<DataSourceSurface> sourceSurface =
     Factory::CreateWrappingDataSourceSurface((uint8_t*)rect.pBits,
                                              rect.Pitch,
                                              IntSize(desc.Width, desc.Height),
                                              FORMAT_B8G8R8A8);
   mTarget->CopySurface(sourceSurface,
                        IntRect(0, 0, desc.Width, desc.Height),
                        IntPoint());
--- a/gfx/layers/d3d9/CompositorD3D9.h
+++ b/gfx/layers/d3d9/CompositorD3D9.h
@@ -154,17 +154,17 @@ private:
 
   /* Swap chain associated with this compositor */
   nsRefPtr<SwapChainD3D9> mSwapChain;
 
   /* Widget associated with this layer manager */
   nsIWidget *mWidget;
 
   /*
-   * Context target, NULL when drawing directly to our swap chain.
+   * Context target, nullptr when drawing directly to our swap chain.
    */
   RefPtr<gfx::DrawTarget> mTarget;
 
   RefPtr<CompositingRenderTargetD3D9> mDefaultRT;
   RefPtr<CompositingRenderTargetD3D9> mCurrentRT;
 
   nsIntSize mSize;
 
--- a/gfx/layers/d3d9/DeviceManagerD3D9.cpp
+++ b/gfx/layers/d3d9/DeviceManagerD3D9.cpp
@@ -150,17 +150,17 @@ SwapChainD3D9::Present(const nsIntRect &
   r.bottom = aRect.YMost();
 
   mSwapChain->Present(&r, &r, 0, 0, 0);
 }
 
 void
 SwapChainD3D9::Present()
 {
-  mSwapChain->Present(NULL, NULL, 0, 0, 0);
+  mSwapChain->Present(nullptr, nullptr, 0, 0, 0);
 }
 
 void
 SwapChainD3D9::Reset()
 {
   mSwapChain = nullptr;
 }
 
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -179,17 +179,17 @@ TextureSourceD3D9::InitTextures(DeviceMa
 
   RefPtr<IDirect3DTexture9> tmpTexture =
     aDeviceManager->CreateTexture(aSize, aFormat, D3DPOOL_SYSTEMMEM, this);
   if (!tmpTexture) {
     return nullptr;
   }
 
   tmpTexture->GetSurfaceLevel(0, byRef(aSurface));
-  aSurface->LockRect(&aLockedRect, NULL, 0);
+  aSurface->LockRect(&aLockedRect, nullptr, 0);
   if (!aLockedRect.pBits) {
     NS_WARNING("Could not lock surface");
     return nullptr;
   }
 
   return result;
 }
 
@@ -203,17 +203,18 @@ FinishTextures(DeviceManagerD3D9* aDevic
 {
   if (!aDeviceManager) {
     return;
   }
 
   aSurface->UnlockRect();
   nsRefPtr<IDirect3DSurface9> dstSurface;
   aTexture->GetSurfaceLevel(0, getter_AddRefs(dstSurface));
-  aDeviceManager->device()->UpdateSurface(aSurface, NULL, dstSurface, NULL);
+  aDeviceManager->device()->UpdateSurface(aSurface, nullptr, dstSurface,
+                                          nullptr);
 }
 
 TemporaryRef<IDirect3DTexture9>
 TextureSourceD3D9::DataToTexture(DeviceManagerD3D9* aDeviceManager,
                                  unsigned char *aData,
                                  int aStride,
                                  const IntSize &aSize,
                                  _D3DFORMAT aFormat,
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -1252,18 +1252,17 @@ const CSSRect AsyncPanZoomController::Ca
     scrollOffset.x = scrollableRect.x;
   }
   if (scrollOffset.y + compositionBounds.height > scrollableRect.height) {
     scrollOffset.y -= compositionBounds.height + scrollOffset.y - scrollableRect.height;
   } else if (scrollOffset.y < scrollableRect.y) {
     scrollOffset.y = scrollableRect.y;
   }
 
-  CSSRect shiftedDisplayPort = displayPort + scrollOffset;
-  return scrollableRect.ClampRect(shiftedDisplayPort) - scrollOffset;
+  return displayPort.ForceInside(scrollableRect - scrollOffset);
 }
 
 void AsyncPanZoomController::ScheduleComposite() {
   if (mCompositorParent) {
     mCompositorParent->ScheduleRenderOnCompositorThread();
   }
 }
 
--- a/gfx/src/nsRegion.h
+++ b/gfx/src/nsRegion.h
@@ -261,17 +261,17 @@ private:
     return *this;
   }
 
   nsRegion& Copy (const nsRect& aRect)
   {
     // pixman needs to distinguish between an empty region and a region
     // with one rect so that it can return a different number of rectangles.
     // Empty rect: data = empty_box
-    //     1 rect: data = NULL
+    //     1 rect: data = null
     //    >1 rect: data = rects
     if (aRect.IsEmpty()) {
       pixman_region32_clear(&mImpl);
     } else {
       pixman_box32_t box = RectToBox(aRect);
       pixman_region32_reset(&mImpl, &box);
     }
     return *this;
--- a/gfx/thebes/gfxASurface.cpp
+++ b/gfx/thebes/gfxASurface.cpp
@@ -871,17 +871,17 @@ gfxASurface::WriteAsPNG_internal(FILE* a
     if (aFile) {
       fwrite(imgData, 1, imgSize, aFile);
     } else {
       NS_WARNING("Can't write binary image data without a file!");
     }
     return;
   }
 
-  // base 64, result will be NULL terminated
+  // base 64, result will be null-terminated
   nsCString encodedImg;
   rv = Base64Encode(Substring(imgData, imgSize), encodedImg);
   moz_free(imgData);
   if (NS_FAILED(rv)) // not sure why this would fail
     return;
 
   nsCString string("data:image/png;base64,");
   string.Append(encodedImg);
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -73,25 +73,25 @@ struct Int32x4 {
 };
 } // namespace js
 
 #define LANE_ACCESSOR(Type32x4, lane) \
     bool Type32x4##Lane##lane(JSContext *cx, unsigned argc, Value *vp) { \
         static const char *laneNames[] = {"lane 0", "lane 1", "lane 2", "lane3"}; \
         CallArgs args = CallArgsFromVp(argc, vp); \
         if(!args.thisv().isObject() || !IsTypedDatum(args.thisv().toObject())) { \
-            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO, \
+            JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, \
                                  X4Type::class_.name, laneNames[lane], \
                                  InformalValueTypeName(args.thisv())); \
             return false; \
         } \
         TypedDatum &datum = AsTypedDatum(args.thisv().toObject()); \
         TypeRepresentation *typeRepr = datum.datumTypeRepresentation(); \
         if (typeRepr->kind() != TypeRepresentation::X4 || typeRepr->asX4()->type() != Type32x4::type) { \
-            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO, \
+            JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, \
                                  X4Type::class_.name, laneNames[lane], \
                                  InformalValueTypeName(args.thisv())); \
             return false; \
         } \
         Type32x4::Elem *data = reinterpret_cast<Type32x4::Elem *>(datum.typedMem()); \
         Type32x4::setReturn(args, data[lane]); \
         return true; \
     }
@@ -104,25 +104,25 @@ struct Int32x4 {
     LANE_ACCESSOR(Int32x4, 2);
     LANE_ACCESSOR(Int32x4, 3);
 #undef LANE_ACCESSOR
 
 #define SIGN_MASK(Type32x4) \
     bool Type32x4##SignMask(JSContext *cx, unsigned argc, Value *vp) { \
         CallArgs args = CallArgsFromVp(argc, vp); \
         if(!args.thisv().isObject() || !IsTypedDatum(args.thisv().toObject())) { \
-            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO, \
+            JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, \
                                  X4Type::class_.name, "signMask", \
                                  InformalValueTypeName(args.thisv())); \
             return false; \
         } \
         TypedDatum &datum = AsTypedDatum(args.thisv().toObject()); \
         TypeRepresentation *typeRepr = datum.datumTypeRepresentation(); \
         if (typeRepr->kind() != TypeRepresentation::X4 || typeRepr->asX4()->type() != Type32x4::type) { \
-            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INCOMPATIBLE_PROTO, \
+            JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO, \
                                  X4Type::class_.name, "signMask", \
                                  InformalValueTypeName(args.thisv())); \
             return false; \
         } \
         Type32x4::Elem *data = reinterpret_cast<Type32x4::Elem *>(datum.typedMem()); \
         int32_t mx = data[0] < 0.0 ? 1 : 0; \
         int32_t my = data[1] < 0.0 ? 1 : 0; \
         int32_t mz = data[2] < 0.0 ? 1 : 0; \
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -1123,16 +1123,40 @@ SetJitCompilerOption(JSContext *cx, unsi
 
     JS_SetGlobalJitCompilerOption(cx, opt, uint32_t(number));
 
     args.rval().setUndefined();
     return true;
 }
 
 static bool
+GetJitCompilerOptions(JSContext *cx, unsigned argc, jsval *vp)
+{
+    RootedObject info(cx, JS_NewObject(cx, nullptr, nullptr, nullptr));
+    if (!info)
+        return false;
+
+    RootedValue value(cx);
+
+#define JIT_COMPILER_MATCH(key, string)                         \
+    opt = JSJITCOMPILER_ ## key;                                \
+    value.setInt32(JS_GetGlobalJitCompilerOption(cx, opt));     \
+    if (!JS_SetProperty(cx, info, string, value))               \
+        return false;
+
+    JSJitCompilerOption opt = JSJITCOMPILER_NOT_AN_OPTION;
+    JIT_COMPILER_OPTIONS(JIT_COMPILER_MATCH);
+#undef JIT_COMPILER_MATCH
+
+    *vp = ObjectValue(*info);
+
+    return true;
+}
+
+static bool
 SetIonCheckGraphCoherency(JSContext *cx, unsigned argc, jsval *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 #ifdef JS_ION
     jit::js_JitOptions.checkGraphConsistency = ToBoolean(args.get(0));
 #endif
     args.rval().setUndefined();
     return true;
@@ -1541,16 +1565,20 @@ static const JSFunctionSpecWithHelp Test
 "  inferred name based on where the function was defined. This can be\n"
 "  different from the 'name' property on the function."),
 
     JS_FN_HELP("isAsmJSCompilationAvailable", IsAsmJSCompilationAvailable, 0, 0,
 "isAsmJSCompilationAvailable",
 "  Returns whether asm.js compilation is currently available or whether it is disabled\n"
 "  (e.g., by the debugger)."),
 
+    JS_FN_HELP("getJitCompilerOptions", GetJitCompilerOptions, 0, 0,
+"getCompilerOptions()",
+"Return an object describing some of the JIT compiler options.\n"),
+
     JS_FN_HELP("isAsmJSModule", IsAsmJSModule, 1, 0,
 "isAsmJSModule(fn)",
 "  Returns whether the given value is a function containing \"use asm\" that has been\n"
 "  validated according to the asm.js spec."),
 
     JS_FN_HELP("isAsmJSModuleLoadedFromCache", IsAsmJSModuleLoadedFromCache, 1, 0,
 "isAsmJSModuleLoadedFromCache(fn)",
 "  Return whether the given asm.js module function has been loaded directly\n"
--- a/js/src/builtin/TypeRepresentation.cpp
+++ b/js/src/builtin/TypeRepresentation.cpp
@@ -776,17 +776,17 @@ SizedArrayTypeRepresentation::appendStri
     SizedTypeRepresentation *elementType = element();
     while (elementType->isSizedArray())
         elementType = elementType->asSizedArray()->element();
     if (!elementType->appendString(cx, contents))
         return false;
 
     contents.append(".array(");
     SizedArrayTypeRepresentation *arrayType = this;
-    while (arrayType != NULL) {
+    while (arrayType != nullptr) {
         if (!NumberValueToStringBuffer(cx, NumberValue(length()), contents))
             return false;
 
         if (arrayType->element()->isSizedArray()) {
             if (!contents.append(","))
                 return false;
             arrayType = arrayType->element()->asSizedArray();
         } else {
--- a/js/src/devtools/vprof/vprof.cpp
+++ b/js/src/devtools/vprof/vprof.cpp
@@ -48,17 +48,17 @@
 #if THREAD_SAFE
 #define LOCK(lock) DO_LOCK(lock)
 #define UNLOCK(lock) DO_UNLOCK(lock)
 #else
 #define LOCK(lock) { (void)(lock);
 #define UNLOCK(lock) }
 #endif
 
-static entry* entries = NULL;
+static entry* entries = nullptr;
 static bool notInitialized = true;
 static long glock = LOCK_IS_FREE;
 
 #define Lock(lock) while (_InterlockedCompareExchange(lock, LOCK_IS_TAKEN, LOCK_IS_FREE) == LOCK_IS_TAKEN){};
 #define Unlock(lock) _InterlockedCompareExchange(lock, LOCK_IS_FREE, LOCK_IS_TAKEN);
 
 #if defined(WIN32)
 	static void vprof_printf(const char* format, ...)
@@ -77,17 +77,17 @@ static long glock = LOCK_IS_FREE;
 #else
 	#define vprof_printf printf
 #endif
 
 static inline entry* reverse (entry* s)
 {
     entry_t e, n, p;
 
-    p = NULL;
+    p = nullptr;
     for (e = s; e; e = n) {
         n = e->next;
         e->next = p;
         p = e;
     }
 
     return p;
 }
@@ -153,56 +153,56 @@ static void dumpProfile (void)
 
 static inline entry_t findEntry (char* file, int line)
 {
     for (entry_t e =  entries; e; e = e->next) {
         if ((e->line == line) && (VMPI_strcmp (e->file, file) == 0)) {
             return e;
         }
     }
-    return NULL;
+    return nullptr;
 }
 
 // Initialize the location pointed to by 'id' to a new value profile entry
 // associated with 'file' and 'line', or do nothing if already initialized.
 // An optional final argument provides a user-defined probe function.
 
 int initValueProfile(void** id, char* file, int line, ...)
 {
     DO_LOCK (&glock);
         entry_t e = (entry_t) *id;
         if (notInitialized) {
             atexit (dumpProfile);
             notInitialized = false;
         }
 
-        if (e == NULL) {
+        if (e == nullptr) {
             e = findEntry (file, line);
             if (e) {
                 *id = e;
             }
         }
 
-        if (e == NULL) {
+        if (e == nullptr) {
             va_list va;
             e = (entry_t) malloc (sizeof(entry));
             e->lock = LOCK_IS_FREE;
             e->file = file;
             e->line = line;
             e->value = 0;
             e->sum = 0;
             e->count = 0;
             e->min = 0;
             e->max = 0;
             // optional probe function argument
             va_start (va, line);
             e->func = (void (__cdecl*)(void*)) va_arg (va, void*);
             va_end (va);
-            e->h = NULL;
-            e->genptr = NULL;
+            e->h = nullptr;
+            e->genptr = nullptr;
             VMPI_memset (&e->ivar,   0, sizeof(e->ivar));
             VMPI_memset (&e->i64var, 0, sizeof(e->i64var));
             VMPI_memset (&e->dvar,   0, sizeof(e->dvar));
             e->next = entries;
             entries = e;
             *id = e;
         }
     DO_UNLOCK (&glock);
@@ -242,39 +242,39 @@ int initHistProfile(void** id, char* fil
 {
     DO_LOCK (&glock);
         entry_t e = (entry_t) *id;
         if (notInitialized) {
             atexit (dumpProfile);
             notInitialized = false;
         }
 
-        if (e == NULL) {
+        if (e == nullptr) {
             e = findEntry (file, line);
             if (e) {
                 *id = e;
             }
         }
 
-        if (e == NULL) {
+        if (e == nullptr) {
             va_list va;
             hist_t h;
             int b, n, s;
             int64_t* lb;
 
             e = (entry_t) malloc (sizeof(entry));
             e->lock = LOCK_IS_FREE;
             e->file = file;
             e->line = line;
             e->value = 0;
             e->sum = 0;
             e->count = 0;
             e->min = 0;
             e->max = 0;
-            e->func = NULL;
+            e->func = nullptr;
             e->h = h = (hist_t) malloc (sizeof(hist));
             n = 1+MAX(nbins,0);
             h->nbins = n-1;
             s = n*sizeof(int64_t);
             lb = (int64_t*) malloc (s);
             h->lb = lb;
             VMPI_memset (h->lb, 0, s);
             h->count = (int64_t*) malloc (s);
@@ -283,17 +283,17 @@ int initHistProfile(void** id, char* fil
             va_start (va, nbins);
             for (b = 0; b < nbins; b++) {
                 //lb[b] = va_arg (va, int64_t);
                 lb[b] = va_arg (va, int);
             }
             lb[b] = MAXINT64;
             va_end (va);
 
-            e->genptr = NULL;
+            e->genptr = nullptr;
             VMPI_memset (&e->ivar,   0, sizeof(e->ivar));
             VMPI_memset (&e->i64var, 0, sizeof(e->i64var));
             VMPI_memset (&e->dvar,   0, sizeof(e->dvar));
             e->next = entries;
             entries = e;
             *id = e;
         }
     DO_UNLOCK (&glock);
--- a/js/src/jit-test/tests/ion/bug909997.js
+++ b/js/src/jit-test/tests/ion/bug909997.js
@@ -16,11 +16,14 @@ var method_D = function() {
     for (var t = 0; t < wait; ++t) {}
 }
 
 var func = [method_A, method_B, method_C, method_D]
 
 for (var n = 0; n < 4; ++n) {
     setJitCompilerOption("baseline.enable", n & 1);
     setJitCompilerOption("ion.enable", n & 2 ? 1: 0);
+    var opt = getJitCompilerOptions();
+    assertEq(opt["baseline.enable"], n & 1);
+    assertEq(opt["ion.enable"], n & 2 ? 1 : 0);
     for (var i = 0; i < 1001; ++i)
         func[n]();
 }
\ No newline at end of file
--- a/js/src/jit/AsmJS.cpp
+++ b/js/src/jit/AsmJS.cpp
@@ -2073,17 +2073,17 @@ class FunctionCompiler
         MConstant *constant = MConstant::New(alloc(), v);
         curBlock_->add(constant);
         return constant;
     }
 
     MDefinition *constantFloat(float f)
     {
         if (!curBlock_)
-            return NULL;
+            return nullptr;
 
         MConstant *constant = MConstant::NewAsmJS(alloc(), DoubleValue(double(f)), MIRType_Float32);
         curBlock_->add(constant);
         return constant;
     }
 
     template <class T>
     MDefinition *unary(MDefinition *op)
@@ -3037,17 +3037,17 @@ CheckGlobalVariableInitImport(ModuleComp
         return false;
     return CheckGlobalVariableImportExpr(m, varName, coercion, coercedExpr, isConst);
 }
 
 static bool
 CheckGlobalVariableInitFloat32(ModuleCompiler &m, PropertyName *varName, ParseNode *initNode,
                                bool isConst)
 {
-    ParseNode *arg = NULL;
+    ParseNode *arg = nullptr;
     if (!CheckFloat32Coercion(m, initNode, &arg, "call must be of the form fround(x)"))
         return false;
 
     if (IsNumericLiteral(arg)) {
         double value;
         if (!ExtractFRoundableLiteral(arg, &value))
             return m.fail(arg, "float global initializer needs to be a double literal");
         return m.addGlobalVarInitConstant(varName, VarType::Float, DoubleValue(value), isConst);
@@ -3300,17 +3300,17 @@ CheckVariable(FunctionCompiler &f, Parse
     if (!CheckIdentifier(f.m(), var, name))
         return false;
 
     ParseNode *initNode = MaybeDefinitionInitializer(var);
     if (!initNode)
         return f.failName(var, "var '%s' needs explicit type declaration via an initial value", name);
 
     if (initNode->isKind(PNK_CALL)) {
-        ParseNode *coercedVar = NULL;
+        ParseNode *coercedVar = nullptr;
         if (!CheckFloat32Coercion(f.m(), initNode, &coercedVar, "caller in var initializer can only be fround"))
             return false;
 
         double value;
         if (!ExtractFRoundableLiteral(coercedVar, &value))
             return f.failName(coercedVar, "float initializer for '%s' needs to be a double literal", name);
 
         return f.addVariable(var, name, VarType::Float, DoubleValue(value));
@@ -3981,17 +3981,17 @@ CheckFFICall(FunctionCompiler &f, ParseN
     return true;
 }
 
 static bool CheckCall(FunctionCompiler &f, ParseNode *call, RetType retType, MDefinition **def, Type *type);
 
 static bool
 CheckFRoundArg(FunctionCompiler &f, ParseNode *expr, MDefinition **def, Type *type, const char* error)
 {
-    ParseNode *arg = NULL;
+    ParseNode *arg = nullptr;
     if (!CheckFloat32Coercion(f.m(), expr, &arg, error))
         return false;
 
     if (arg->isKind(PNK_CALL))
         return CheckCall(f, arg, RetType::Float, def, type);
 
     if (IsNumericLiteral(arg)) {
         double value;
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -2425,17 +2425,17 @@ JS_SetPrototype(JSContext *cx, JS::Handl
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, proto);
 
     bool succeeded;
     if (!JSObject::setProto(cx, obj, proto, &succeeded))
         return false;
 
     if (!succeeded) {
-        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_SETPROTOTYPEOF_FAIL);
+        JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL);
         return false;
     }
 
     return true;
 }
 
 JS_PUBLIC_API(JSObject *)
 JS_GetParent(JSObject *obj)
@@ -6035,16 +6035,36 @@ JS_SetGlobalJitCompilerOption(JSContext 
         }
         break;
       default:
         break;
     }
 #endif
 }
 
+JS_PUBLIC_API(int)
+JS_GetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt)
+{
+#ifdef JS_ION
+    switch (opt) {
+      case JSJITCOMPILER_BASELINE_USECOUNT_TRIGGER:
+        return jit::js_JitOptions.baselineUsesBeforeCompile;
+      case JSJITCOMPILER_ION_USECOUNT_TRIGGER:
+        return jit::js_JitOptions.forcedDefaultIonUsesBeforeCompile;
+      case JSJITCOMPILER_ION_ENABLE:
+        return JS::ContextOptionsRef(cx).ion();
+      case JSJITCOMPILER_BASELINE_ENABLE:
+        return JS::ContextOptionsRef(cx).baseline();
+      default:
+        break;
+    }
+#endif
+    return 0;
+}
+
 /************************************************************************/
 
 #if !defined(STATIC_EXPORTABLE_JS_API) && !defined(STATIC_JS_API) && defined(XP_WIN)
 
 #include "jswin.h"
 
 /*
  * Initialization routine for the JS DLL.
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -4552,16 +4552,18 @@ typedef enum JSJitCompilerOption {
     JIT_COMPILER_OPTIONS(JIT_COMPILER_DECLARE)
 #undef JIT_COMPILER_DECLARE
 
     JSJITCOMPILER_NOT_AN_OPTION
 } JSJitCompilerOption;
 
 extern JS_PUBLIC_API(void)
 JS_SetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt, uint32_t value);
+extern JS_PUBLIC_API(int)
+JS_GetGlobalJitCompilerOption(JSContext *cx, JSJitCompilerOption opt);
 
 /*
  * Convert a uint32_t index into a jsid.
  */
 extern JS_PUBLIC_API(bool)
 JS_IndexToId(JSContext *cx, uint32_t index, JS::MutableHandleId);
 
 /*
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -349,17 +349,17 @@ BaseProxyHandler::getPrototypeOf(JSConte
 }
 
 bool
 BaseProxyHandler::setPrototypeOf(JSContext *cx, HandleObject, HandleObject, bool *)
 {
     // Disallow sets of protos on proxies with lazy protos, but no hook.
     // This keeps us away from the footgun of having the first proto set opt
     // you out of having dynamic protos altogether.
-    JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_SETPROTOTYPEOF_FAIL);
+    JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL);
     return false;
 }
 
 bool
 BaseProxyHandler::watch(JSContext *cx, HandleObject proxy, HandleId id, HandleObject callable)
 {
     JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_WATCH,
                          proxy->getClass()->name);
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -843,17 +843,17 @@ js::XDRScript(XDRState<mode> *xdr, Handl
     }
 
     if (mode == XDR_DECODE) {
         scriptp.set(script);
 
         /* see BytecodeEmitter::tellDebuggerAboutCompiledScript */
         CallNewScriptHook(cx, script, fun);
         if (!fun) {
-            RootedGlobalObject global(cx, script->compileAndGo() ? &script->global() : NULL);
+            RootedGlobalObject global(cx, script->compileAndGo() ? &script->global() : nullptr);
             Debugger::onNewScript(cx, script, global);
         }
     }
 
     return true;
 }
 
 template bool
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -660,17 +660,17 @@ SecurityWrapper<Base>::nativeCall(JSCont
     return false;
 }
 
 template <class Base>
 bool
 SecurityWrapper<Base>::setPrototypeOf(JSContext *cx, HandleObject wrapper,
                                       HandleObject proto, bool *bp)
 {
-    JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_UNWRAP_DENIED);
+    JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_UNWRAP_DENIED);
     return false;
 }
 
 // For security wrappers, we run the DefaultValue algorithm on the wrapper
 // itself, which means that the existing security policy on operations like
 // toString() will take effect and do the right thing here.
 template <class Base>
 bool
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -148,17 +148,17 @@ ProtoSetterImpl(JSContext *cx, CallArgs 
     if (!CheckAccess(cx, obj, nid, JSAccessMode(JSACC_PROTO | JSACC_WRITE), &v, &dummy))
         return false;
 
     bool success;
     if (!JSObject::setProto(cx, obj, newProto, &success))
         return false;
 
     if (!success) {
-        JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_SETPROTOTYPEOF_FAIL);
+        JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_SETPROTOTYPEOF_FAIL);
         return false;
     }
 
     args.rval().setUndefined();
     return true;
 }
 
 static bool
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -711,17 +711,17 @@ static void RecordFrameMetrics(nsIFrame*
                                       && aScrollFrame == presShell->GetRootScrollFrame();
   if (isRootContentDocRootScrollFrame) {
     if (nsIWidget* widget = aForFrame->GetNearestWidget()) {
       nsIntRect bounds;
       widget->GetBounds(bounds);
       ScreenIntRect screenBounds = ScreenIntRect::FromUnknownRect(mozilla::gfx::IntRect(
           bounds.x, bounds.y, bounds.width, bounds.height));
       AdjustForScrollBars(screenBounds, scrollableFrame);
-      metrics.mCompositionBounds = screenBounds.ClampRect(metrics.mCompositionBounds);
+      metrics.mCompositionBounds = metrics.mCompositionBounds.ForceInside(screenBounds);
       useWidgetBounds = true;
     }
   }
 
   // Adjust composition bounds for the size of scroll bars.
   // If the widget bounds were used to clamp the composition bounds,
   // this adjustment was already made to the widget bounds.
   if (!useWidgetBounds) {
--- a/netwerk/dns/nsHostResolver.cpp
+++ b/netwerk/dns/nsHostResolver.cpp
@@ -1008,22 +1008,22 @@ public:
         }
         rv = uuidgen->GenerateUUIDInPlace(&id);
         NS_ENSURE_SUCCESS(rv, NS_OK);
         id.ToProvidedString(uuid);
         // Strip off the { and } surrounding the UUID string
         dnsUUID.Assign(Substring(nsDependentCString(uuid), 1, NSID_LENGTH - 3));
 
         // Create events for A and SRV resolvers
-        events[0] = CreateEvent(NULL, TRUE, FALSE, TEXT("FinishedA"));
+        events[0] = CreateEvent(nullptr, TRUE, FALSE, TEXT("FinishedA"));
         if (!events[0]) {
             goto library_cleanup;
         }
 
-        events[1] = CreateEvent(NULL, TRUE, FALSE, TEXT("FinishedSRV"));
+        events[1] = CreateEvent(nullptr, TRUE, FALSE, TEXT("FinishedSRV"));
         if (!events[1]) {
             goto aevent_cleanup;
         }
 
         // dispatch A resolver
         mResolveAThread->Dispatch(new ExperimentResolver(DNS_TYPE_A,
                                                          dnsUUID,
                                                          &events[0],
--- a/netwerk/sctp/src/user_environment.c
+++ b/netwerk/sctp/src/user_environment.c
@@ -87,15 +87,15 @@ read_random_phony(void *buf, int count)
 	uint32_t randval;
 	int size, i;
 
 	/* srandom() is called in kern/init_main.c:proc0_post() */
 
 	/* Fill buf[] with random(9) output */
 	for (i = 0; i < count; i+= (int)sizeof(uint32_t)) {
 		randval = random();
-		size = MIN(count - i, sizeof(uint32_t));
+		size = MIN(count - i, (int)sizeof(uint32_t));
 		memcpy(&((char *)buf)[i], &randval, (size_t)size);
 	}
 
 	return (count);
 }
 
--- a/tools/jprof/bfd.cpp
+++ b/tools/jprof/bfd.cpp
@@ -13,50 +13,50 @@
 #include <libgen.h>
 #include <bfd.h>
 #include <cxxabi.h>
 
 static bfd *try_debug_file(const char *filename, unsigned long crc32)
 {
   int fd = open(filename, O_RDONLY);
   if (fd < 0)
-    return NULL;
+    return nullptr;
 
   unsigned char buf[4*1024];
   unsigned long crc = 0;
 
   while (1) {
     ssize_t count = read(fd, buf, sizeof(buf));
     if (count <= 0)
       break;
 
     crc = bfd_calc_gnu_debuglink_crc32(crc, buf, count);
   }
 
   close(fd);
 
   if (crc != crc32)
-    return NULL;
+    return nullptr;
 
-  bfd *object = bfd_openr(filename, NULL);
+  bfd *object = bfd_openr(filename, nullptr);
   if (!bfd_check_format(object, bfd_object)) {
     bfd_close(object);
-    return NULL;
+    return nullptr;
   }
 
   return object;
 }
 
 static bfd *find_debug_file(bfd *lib, const char *aFileName)
 {
   // check for a separate debug file with symbols
   asection *sect = bfd_get_section_by_name(lib, ".gnu_debuglink");
 
   if (!sect)
-    return NULL;
+    return nullptr;
 
   bfd_size_type debuglinkSize = bfd_section_size (objfile->obfd, sect);
 
   char *debuglink = new char[debuglinkSize];
   bfd_get_section_contents(lib, sect, debuglink, 0, debuglinkSize);
 
   // crc checksum is aligned to 4 bytes, and after the NUL.
   int crc_offset = (int(strlen(debuglink)) & ~3) + 4;
@@ -120,17 +120,17 @@ Symbol ** leaky::ExtendSymbols(int num)
                          if (sp >= lastSymbol) { \
                            sp = ExtendSymbols(16384); \
                          } \
                        } while (0)
 
 void leaky::ReadSymbols(const char *aFileName, u_long aBaseAddress)
 {
   int initialSymbols = usefulSymbols;
-  if (NULL == externalSymbols) {
+  if (nullptr == externalSymbols) {
     externalSymbols = (Symbol**) calloc(sizeof(Symbol*),10000);
     Symbol *new_array = new Symbol[10000];
     for (int i = 0; i < 10000; i++) {
       externalSymbols[i] = &new_array[i];
     }
     numExternalSymbols = 10000;
   }
   Symbol** sp = externalSymbols + usefulSymbols;
@@ -144,18 +144,18 @@ void leaky::ReadSymbols(const char *aFil
   bfd_boolean kDynamic = (bfd_boolean) false;
 
   static int firstTime = 1;
   if (firstTime) {
     firstTime = 0;
     bfd_init ();
   }
 
-  bfd* lib = bfd_openr(aFileName, NULL);
-  if (NULL == lib) {
+  bfd* lib = bfd_openr(aFileName, nullptr);
+  if (nullptr == lib) {
     return;
   }
   if (!bfd_check_format(lib, bfd_object)) {
     bfd_close(lib);
     return;
   }
 
   bfd *symbolFile = find_debug_file(lib, aFileName);
@@ -194,17 +194,17 @@ void leaky::ReadSymbols(const char *aFil
     sym = bfd_minisymbol_to_symbol(symbolFile, kDynamic, (const PTR) from, store);
 
     symbol_info syminfo;
     bfd_get_symbol_info (symbolFile, sym, &syminfo);
 
 //    if ((syminfo.type == 'T') || (syminfo.type == 't')) {
       const char* nm = bfd_asymbol_name(sym);
       if (nm && nm[0]) {
-        char* dnm = NULL;
+        char* dnm = nullptr;
         if (strncmp("__thunk", nm, 7)) {
           dnm = abi::__cxa_demangle(nm, 0, 0, 0);
         }
         (*sp)->Init(dnm ? dnm : nm, syminfo.value + aBaseAddress);
         if (dnm) {
           free(dnm);
         }
         NEXT_SYMBOL;
--- a/tools/jprof/coff.cpp
+++ b/tools/jprof/coff.cpp
@@ -33,17 +33,17 @@ static char *Demangle(char *rawName)
     return strdup(namebuf);
 #endif
 }
 
 void leaky::readSymbols(const char *fileName)
 {
     LDFILE *ldptr;
 
-    ldptr = ldopen(fileName, NULL);
+    ldptr = ldopen(fileName, nullptr);
     if (!ldptr) {
 	fprintf(stderr, "%s: unable to open \"%s\"\n", applicationName,
 		fileName);
 	exit(-1);
     }
     if (PSYMTAB(ldptr) == 0) {
 	fprintf(stderr, "%s: \"%s\": has no symbol table\n", applicationName,
 		fileName);
--- a/tools/jprof/leaky.cpp
+++ b/tools/jprof/leaky.cpp
@@ -54,17 +54,17 @@ int main(int argc, char** argv)
       l->outputfd = fopen(name,"w");
       // if an error we won't process the file
     }
     if (l->outputfd) { // paranoia
       l->open(argv[l->logFileIndex + i]);
 
       if (l->outputfd != stderr) {
         fclose(l->outputfd);
-        l->outputfd = NULL;
+        l->outputfd = nullptr;
       }
     }
   }
 
   return 0;
 }
 
 char *
@@ -110,18 +110,18 @@ htmlify(const char *in)
   } while (*p);
   *q = '\0';
 
   return out;
 }
 
 leaky::leaky()
 {
-  applicationName = NULL;
-  progFile = NULL;
+  applicationName = nullptr;
+  progFile = nullptr;
 
   quiet = true;
   showAddress = false;
   showThreads = false;
   stackDepth = 100000;
   onlyThread = 0;
   cleo = false;
 
@@ -130,17 +130,17 @@ leaky::leaky()
 
   sfd = -1;
   externalSymbols = 0;
   usefulSymbols = 0;
   numExternalSymbols = 0;
   lowestSymbolAddr = 0;
   highestSymbolAddr = 0;
 
-  loadMap = NULL;
+  loadMap = nullptr;
 
   collect_last  = false;
   collect_start = -1;
   collect_end   = -1;
 }
 
 leaky::~leaky()
 {
@@ -162,24 +162,24 @@ void leaky::usageError()
           "\t--output-dir dir: write output files to dir\n"
           "\tIf there's one log, output goes to stdout unless --output-dir is set\n"
           "\tIf there are more than one log, output files will be named with .html added\n"
           );
   exit(-1);
 }
 
 static struct option longopts[] = {
-    { "threads", 0, NULL, 't' },
-    { "only-thread", 1, NULL, 'T' },
-    { "last", 0, NULL, 'l' },
-    { "start", 1, NULL, 'x' },
-    { "end", 1, NULL, 'n' },
-    { "cleo",0, NULL, 'c' },
-    { "output-dir", 1, NULL, 'd' },
-    { NULL, 0, NULL, 0 },
+    { "threads", 0, nullptr, 't' },
+    { "only-thread", 1, nullptr, 'T' },
+    { "last", 0, nullptr, 'l' },
+    { "start", 1, nullptr, 'x' },
+    { "end", 1, nullptr, 'n' },
+    { "cleo",0, nullptr, 'c' },
+    { "output-dir", 1, nullptr, 'd' },
+    { nullptr, 0, nullptr, 0 },
 };
 
 void leaky::initialize(int argc, char** argv)
 {
   applicationName = argv[0];
   applicationName = strrchr(applicationName, '/');
   if (!applicationName) {
     applicationName = argv[0];
@@ -187,17 +187,17 @@ void leaky::initialize(int argc, char** 
     applicationName++;
   }
 
   int arg;
   int errflg = 0;
   int longindex = 0;
 
   onlyThread = 0;
-  output_dir = NULL;
+  output_dir = nullptr;
   cleo = false;
 
   // XXX tons of cruft here left over from tracemalloc
   // XXX The -- options shouldn't need short versions, or they should be documented
   while (((arg = getopt_long(argc, argv, "adEe:gh:i:r:Rs:tT:qvx:ln:",longopts,&longindex)) != -1)) {
     switch (arg) {
       case '?':
       default:
@@ -459,17 +459,17 @@ static int symbolOrder(void const* a, vo
   Symbol const** bp = (Symbol const **)b;
   return (*ap)->address == (*bp)->address ? 0 :
     ((*ap)->address > (*bp)->address ? 1 : -1);
 }
 
 void leaky::ReadSharedLibrarySymbols()
 {
   LoadMapEntry* lme = loadMap;
-  while (NULL != lme) {
+  while (nullptr != lme) {
     ReadSymbols(lme->name, lme->address);
     lme = lme->next;
   }
 }
 
 void leaky::setupSymbols(const char *fileName)
 {
   if (usefulSymbols == 0) {
@@ -521,17 +521,17 @@ int leaky::findSymbolIndex(u_long addr)
   return -1;
 }
 
 Symbol* leaky::findSymbol(u_long addr)
 {
   int idx = findSymbolIndex(addr);
 
   if(idx<0) {
-    return NULL;
+    return nullptr;
   } else {
     return externalSymbols[idx];
   }
 }
 
 //----------------------------------------------------------------------
 
 bool leaky::excluded(malloc_log_entry* lep)
--- a/tools/jprof/stub/libmalloc.cpp
+++ b/tools/jprof/stub/libmalloc.cpp
@@ -166,17 +166,17 @@ static void DumpAddressMap()
   {
     startSignalCounter(0);
   }
 
   int mfd = open(M_MAPFILE, O_CREAT|O_WRONLY|O_TRUNC, 0666);
   if (mfd >= 0) {
     malloc_map_entry mme;
     link_map* map = _r_debug.r_map;
-    while (NULL != map) {
+    while (nullptr != map) {
       if (map->l_name && *map->l_name) {
 	mme.nameLen = strlen(map->l_name);
 	mme.address = map->l_addr;
 	write(mfd, &mme, sizeof(mme));
 	write(mfd, map->l_name, mme.nameLen);
 #if 0
 	write(1, map->l_name, mme.nameLen);
 	write(1, "\n", 1);
@@ -434,34 +434,34 @@ static void startSignalCounter(unsigned 
     struct itimerval tvalue;
 
     tvalue.it_interval.tv_sec = 0;
     tvalue.it_interval.tv_usec = 0;
     tvalue.it_value.tv_sec = millisec/1000;
     tvalue.it_value.tv_usec = (millisec%1000)*1000;
 
     if (realTime) {
-	setitimer(ITIMER_REAL, &tvalue, NULL);
+        setitimer(ITIMER_REAL, &tvalue, nullptr);
     } else {
-    	setitimer(ITIMER_PROF, &tvalue, NULL);
+        setitimer(ITIMER_PROF, &tvalue, nullptr);
     }
 }
 
 static long timerMilliSec = 50;
 
 #if defined(linux)
 static int setupRTCSignals(int hz, struct sigaction *sap)
 {
     /* global */ rtcFD = open("/dev/rtc", O_RDONLY);
     if (rtcFD < 0) {
         perror("JPROF_RTC setup: open(\"/dev/rtc\", O_RDONLY)");
         return 0;
     }
 
-    if (sigaction(SIGIO, sap, NULL) == -1) {
+    if (sigaction(SIGIO, sap, nullptr) == -1) {
         perror("JPROF_RTC setup: sigaction(SIGIO)");
         return 0;
     }
 
     if (ioctl(rtcFD, RTC_IRQP_SET, hz) == -1) {
         perror("JPROF_RTC setup: ioctl(/dev/rtc, RTC_IRQP_SET, $JPROF_RTC_HZ)");
         return 0;
     }
@@ -612,17 +612,17 @@ NS_EXPORT_(void) setupProfilingStuff(voi
 		startTimer = 0;
 	    }
 	    if(strstr(tst, "JP_START")) doNotStart = 0;
 	    if(strstr(tst, "JP_REALTIME")) realTime = 1;
 	    if(strstr(tst, "JP_APPEND")) append = O_APPEND;
 
 	    char *delay = strstr(tst,"JP_PERIOD=");
 	    if(delay) {
-                double tmp = strtod(delay+strlen("JP_PERIOD="), NULL);
+                double tmp = strtod(delay+strlen("JP_PERIOD="), nullptr);
                 if (tmp>=1e-3) {
 		    timerMilliSec = static_cast<unsigned long>(1000 * tmp);
                 } else {
                     fprintf(stderr,
                             "JP_PERIOD of %g less than 0.001 (1ms), using 1ms\n",
                             tmp);
                     timerMilliSec = 1;
                 }
@@ -703,56 +703,56 @@ NS_EXPORT_(void) setupProfilingStuff(voi
 
 		    main_thread = pthread_self();
                     //fprintf(stderr,"jprof: main_thread = %u\n",
                     //        (unsigned int)main_thread);
 
                     // FIX!  probably should block these against each other
                     // Very unlikely.
 		    sigemptyset(&mset);
-		    action.sa_handler = NULL;
+		    action.sa_handler = nullptr;
 		    action.sa_sigaction = StackHook;
 		    action.sa_mask  = mset;
 		    action.sa_flags = SA_RESTART | SA_SIGINFO;
 #if defined(linux)
                     if (rtcHz) {
                         if (!setupRTCSignals(rtcHz, &action)) {
                             fputs("jprof: Error initializing RTC, NOT "
                                   "profiling\n", stderr);
                             return;
                         }
                     }
 
                     if (!rtcHz || firstDelay != 0)
 #endif
                     {
                         if (realTime) {
-                            sigaction(SIGALRM, &action, NULL);
+                            sigaction(SIGALRM, &action, nullptr);
                         }
                     }
                     // enable PROF in all cases to simplify JP_DEFER/pause/restart
-                    sigaction(SIGPROF, &action, NULL);
+                    sigaction(SIGPROF, &action, nullptr);
 
 		    // make it so a SIGUSR1 will stop the profiling
 		    // Note:  It currently does not close the logfile.
 		    // This could be configurable (so that it could
 		    // later be reopened).
 
 		    struct sigaction stop_action;
 		    stop_action.sa_handler = EndProfilingHook;
 		    stop_action.sa_mask  = mset;
 		    stop_action.sa_flags = SA_RESTART;
-		    sigaction(SIGUSR1, &stop_action, NULL);
+		    sigaction(SIGUSR1, &stop_action, nullptr);
 
 		    // make it so a SIGUSR2 will clear the circular buffer
 
 		    stop_action.sa_handler = ClearProfilingHook;
 		    stop_action.sa_mask  = mset;
 		    stop_action.sa_flags = SA_RESTART;
-		    sigaction(SIGUSR2, &stop_action, NULL);
+		    sigaction(SIGUSR2, &stop_action, nullptr);
 
                     printf("Jprof: Initialized signal handler and set "
                            "timer for %lu %s, %d s "
                            "initial delay\n",
                            rtcHz ? rtcHz : timerMilliSec, 
                            rtcHz ? "Hz" : "ms",
                            firstDelay);
 
--- a/tools/trace-malloc/leaksoup.cpp
+++ b/tools/trace-malloc/leaksoup.cpp
@@ -97,17 +97,17 @@ int main(int argc, char **argv)
     if (argc != 2) {
         fprintf(stderr,
                 "Expected usage:  %s <sd-leak-file>\n"
                 "  sd-leak-file: Output of --shutdown-leaks=<file> option.\n",
                 argv[0]);
         return 1;
     }
 
-    NS_InitXPCOM2(NULL, NULL, NULL);
+    NS_InitXPCOM2(nullptr, nullptr, nullptr);
 
     ADLog log;
     if (!log.Read(argv[1])) {
         fprintf(stderr,
                 "%s: Error reading input file %s.\n", argv[0], argv[1]);
     }
 
     const size_t count = log.count();
@@ -396,12 +396,12 @@ int main(int argc, char **argv)
         }
         printf("</body>\n"
                "</html>\n");
     }
 
     delete [] sorted_nodes;
     delete [] nodes;
 
-    NS_ShutdownXPCOM(NULL);
+    NS_ShutdownXPCOM(nullptr);
 
     return 0;
 }
--- a/widget/android/AndroidBridge.cpp
+++ b/widget/android/AndroidBridge.cpp
@@ -159,17 +159,17 @@ AndroidBridge::Init(JNIEnv *jEnv)
 {
     ALOG_BRIDGE("AndroidBridge::Init");
     jEnv->GetJavaVM(&mJavaVM);
 
     AutoLocalJNIFrame jniFrame(jEnv);
 
     mJNIEnv = nullptr;
     mThread = -1;
-    mGLControllerObj = NULL;
+    mGLControllerObj = nullptr;
     mOpenedGraphicsLibraries = false;
     mHasNativeBitmapAccess = false;
     mHasNativeWindowAccess = false;
     mHasNativeWindowFallback = false;
 
     initInit();
 
 #ifdef MOZ_WEBSMS_BACKEND
@@ -264,34 +264,34 @@ jstring AndroidBridge::NewJavaString(Aut
 jstring AndroidBridge::NewJavaString(AutoLocalJNIFrame* frame, const nsACString& string) {
     return NewJavaString(frame, NS_ConvertUTF8toUTF16(string));
 }
 
 extern "C" {
     __attribute__ ((visibility("default")))
     JNIEnv * GetJNIForThread()
     {
-        JNIEnv *jEnv = NULL;
+        JNIEnv *jEnv = nullptr;
         JavaVM *jVm  = mozilla::AndroidBridge::GetVM();
         if (!jVm) {
             __android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "Returned a null VM");
-            return NULL;
+            return nullptr;
         }
         jEnv = static_cast<JNIEnv*>(PR_GetThreadPrivate(sJavaEnvThreadIndex));
 
         if (jEnv)
             return jEnv;
 
         int status = jVm->GetEnv((void**) &jEnv, JNI_VERSION_1_2);
         if (status) {
 
-            status = jVm->AttachCurrentThread(&jEnv, NULL);
+            status = jVm->AttachCurrentThread(&jEnv, nullptr);
             if (status) {
                 __android_log_print(ANDROID_LOG_INFO, "GetJNIForThread",  "Could not attach");
-                return NULL;
+                return nullptr;
             }
 
             PR_SetThreadPrivate(sJavaEnvThreadIndex, jEnv);
         }
         if (!jEnv) {
             __android_log_print(ANDROID_LOG_INFO, "GetJNIForThread", "returning NULL");
         }
         return jEnv;
@@ -299,17 +299,17 @@ extern "C" {
 }
 
 void AutoGlobalWrappedJavaObject::Dispose() {
     if (isNull()) {
         return;
     }
 
     GetJNIForThread()->DeleteGlobalRef(wrapped_obj);
-    wrapped_obj = NULL;
+    wrapped_obj = nullptr;
 }
 
 AutoGlobalWrappedJavaObject::~AutoGlobalWrappedJavaObject() {
     Dispose();
 }
 
 static void
 getHandlersFromStringArray(JNIEnv *aJNIEnv, jobjectArray jArr, jsize aLen,
@@ -689,17 +689,17 @@ AndroidBridge::SetLayerClient(JNIEnv* en
         // and we do that by setting the first-paint flag.
         nsWindow::ForceIsFirstPaint();
     }
 }
 
 void
 AndroidBridge::RegisterCompositor(JNIEnv *env)
 {
-    if (mGLControllerObj != NULL && !mGLControllerObj->isNull()) {
+    if (mGLControllerObj != nullptr && !mGLControllerObj->isNull()) {
         // we already have this set up, no need to do it again
         return;
     }
 
     jobject glController = LayerView::RegisterCompositorWrapper();
     if (!glController) {
         return;
     }
--- a/widget/android/AndroidJNI.cpp
+++ b/widget/android/AndroidJNI.cpp
@@ -906,17 +906,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 
 NS_EXPORT void JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy(JNIEnv* env, jobject instance)
 {
     if (!AndroidBridge::Bridge()) {
         return;
     }
 
-    NativePanZoomController* oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(NULL);
+    NativePanZoomController* oldRef = AndroidBridge::Bridge()->SetNativePanZoomController(nullptr);
     if (!oldRef || oldRef->isNull()) {
         MOZ_ASSERT(false, "Clearing a non-existent NPZC");
     } else {
         delete oldRef;
     }
 }
 
 NS_EXPORT void JNICALL
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -62,61 +62,61 @@ public:
 private:
     int32_t mRefCnt;
     jobject mObject;
 };
 
 class WrappedJavaObject {
 public:
     WrappedJavaObject() :
-        wrapped_obj(NULL)
+        wrapped_obj(nullptr)
     { }
 
-    WrappedJavaObject(jobject jobj) : wrapped_obj(NULL) {
+    WrappedJavaObject(jobject jobj) : wrapped_obj(nullptr) {
         Init(jobj);
     }
 
     void Init(jobject jobj) {
         wrapped_obj = jobj;
     }
 
     bool isNull() const {
-        return wrapped_obj == NULL;
+        return wrapped_obj == nullptr;
     }
 
     jobject wrappedObject() const {
         return wrapped_obj;
     }
 
 protected:
     jobject wrapped_obj;
 };
 
 class AutoGlobalWrappedJavaObject : protected WrappedJavaObject{
 public:
     AutoGlobalWrappedJavaObject() :
-        wrapped_obj(NULL)
+        wrapped_obj(nullptr)
     { }
 
-    AutoGlobalWrappedJavaObject(jobject jobj, JNIEnv* env) : wrapped_obj(NULL) {
+    AutoGlobalWrappedJavaObject(jobject jobj, JNIEnv* env) : wrapped_obj(nullptr) {
         Init(jobj, env);
     }
 
     virtual ~AutoGlobalWrappedJavaObject();
     void Dispose();
 
     void Init(jobject jobj, JNIEnv* env) {
         if (!isNull()) {
             env->DeleteGlobalRef(wrapped_obj);
         }
         wrapped_obj = env->NewGlobalRef(jobj);
     }
 
     bool isNull() const {
-        return wrapped_obj == NULL;
+        return wrapped_obj == nullptr;
     }
 
     jobject wrappedObject() const {
         return wrapped_obj;
     }
 
 protected:
     jobject wrapped_obj;
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -499,17 +499,17 @@ class nsIWidget : public nsISupports {
     {
       ClearNativeTouchSequence();
     }
 
         
     /**
      * Create and initialize a widget. 
      *
-     * All the arguments can be NULL in which case a top level window
+     * All the arguments can be null in which case a top level window
      * with size 0 is created. The event callback function has to be
      * provided only if the caller wants to deal with the events this
      * widget receives.  The event callback is basically a preprocess
      * hook called synchronously. The return value determines whether
      * the event goes to the default window procedure or it is hidden
      * to the os. The assumption is that if the event handler returns
      * false the widget does not see the event. The widget should not 
      * automatically clear the window to the background color. The 
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -207,17 +207,17 @@ ResidentFastDistinguishedAmount(int64_t*
 #include <libutil.h>
 #include <algorithm>
 
 static nsresult
 GetKinfoVmentrySelf(int64_t* prss, uint64_t* maxreg)
 {
     int cnt;
     struct kinfo_vmentry *vmmap, *kve;
-    if ((vmmap = kinfo_getvmmap(getpid(), &cnt)) == NULL)
+    if ((vmmap = kinfo_getvmmap(getpid(), &cnt)) == nullptr)
         return NS_ERROR_FAILURE;
 
     if (prss)
         *prss = 0;
     if (maxreg)
         *maxreg = 0;
 
     for (int i = 0; i < cnt; i++) {
@@ -233,28 +233,28 @@ GetKinfoVmentrySelf(int64_t* prss, uint6
     return NS_OK;
 }
 
 #define HAVE_PRIVATE_REPORTER
 static nsresult
 PrivateDistinguishedAmount(int64_t* aN)
 {
     int64_t priv;
-    nsresult rv = GetKinfoVmentrySelf(&priv, NULL);
+    nsresult rv = GetKinfoVmentrySelf(&priv, nullptr);
     NS_ENSURE_SUCCESS(rv, rv);
     *aN = priv * getpagesize();
     return NS_OK;
 }
 
 #define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1
 static nsresult
 VsizeMaxContiguousDistinguishedAmount(int64_t* aN)
 {
     uint64_t biggestRegion;
-    nsresult rv = GetKinfoVmentrySelf(NULL, &biggestRegion);
+    nsresult rv = GetKinfoVmentrySelf(nullptr, &biggestRegion);
     if (NS_SUCCEEDED(rv))
         *aN = biggestRegion;
 
     return NS_OK;
 }
 #endif // FreeBSD
 
 #elif defined(SOLARIS)