Bug 1577910 - Remove using namespace std from gfx/2d r=nical FIREFOX_NIGHTLY_70_END
authorEric Rahm <erahm@mozilla.com>
Sun, 01 Sep 2019 18:32:06 +0000
changeset 491059 b338d55d5007ce5a7d4cdce3aaa8e9f63c5555f7
parent 491058 f103fcfc4c16c1f3f4afcabf308064274ee06f61
child 491060 dc8cd8acd5ad5d63fb2a2cd10b569dcdd1534edc
child 491238 bea2caa20ba4b6cba258ada739f3fd80dddd7ea1
push id94211
push usererahm@mozilla.com
push dateSun, 01 Sep 2019 18:33:22 +0000
treeherderautoland@b338d55d5007 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1577910
milestone70.0a1
first release with
nightly linux32
b338d55d5007 / 70.0a1 / 20190901214807 / files
nightly linux64
b338d55d5007 / 70.0a1 / 20190901214807 / files
nightly mac
b338d55d5007 / 70.0a1 / 20190901214807 / files
nightly win32
b338d55d5007 / 70.0a1 / 20190901214807 / files
nightly win64
b338d55d5007 / 70.0a1 / 20190901214807 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1577910 - Remove using namespace std from gfx/2d r=nical Differential Revision: https://phabricator.services.mozilla.com/D44281
gfx/2d/Blur.cpp
gfx/2d/DrawEventRecorder.cpp
gfx/2d/DrawTargetD2D1.cpp
gfx/2d/DrawTargetOffset.cpp
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetTiled.cpp
gfx/2d/ImageScaling.cpp
gfx/2d/JobScheduler_posix.cpp
gfx/2d/JobScheduler_win32.cpp
gfx/2d/Matrix.cpp
gfx/2d/PathCapture.cpp
gfx/2d/PathRecording.cpp
gfx/2d/Quaternion.cpp
gfx/2d/RecordedEvent.cpp
gfx/2d/ScaledFontBase.cpp
gfx/2d/ScaledFontDWrite.cpp
gfx/2d/SourceSurfaceSkia.cpp
gfx/2d/unittest/Main.cpp
gfx/2d/unittest/TestBase.cpp
gfx/2d/unittest/TestDrawTargetBase.cpp
gfx/tests/gtest/TestArena.cpp
--- a/gfx/2d/Blur.cpp
+++ b/gfx/2d/Blur.cpp
@@ -15,18 +15,16 @@
 #include "2D.h"
 #include "DataSurfaceHelpers.h"
 #include "Tools.h"
 
 #ifdef USE_NEON
 #  include "mozilla/arm.h"
 #endif
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 /**
  * Helper function to process each row of the box blur.
  * It takes care of transposing the data on input or output depending
  * on whether we intend a horizontal or vertical blur, and whether we're
  * reading from the initial source or writing to the final destination.
@@ -118,24 +116,25 @@ static inline void BoxBlurRow(const uint
   }
 
   // Now we start moving the window over the row. We will be accessing
   // pixels form aStart - aLeftLobe up to aEnd + aRightLobe, which may be
   // out of bounds of the row. To avoid having to check within the inner
   // loops if we are in bound, we instead compute the points at which
   // we will move out of bounds of the row on the left side (splitLeft)
   // and right side (splitRight).
-  int32_t splitLeft = min(max(aLeftLobe, aStart), aEnd);
-  int32_t splitRight = min(max(aWidth - (boxSize - aLeftLobe), aStart), aEnd);
+  int32_t splitLeft = std::min(std::max(aLeftLobe, aStart), aEnd);
+  int32_t splitRight =
+      std::min(std::max(aWidth - (boxSize - aLeftLobe), aStart), aEnd);
   // If the filter window is actually large than the size of the row,
   // there will be a middle area of overlap where the leftmost and rightmost
   // pixel of the filter will both be outside the row. In this case, we need
   // to invert the splits so that splitLeft <= splitRight.
   if (boxSize > aWidth) {
-    swap(splitLeft, splitRight);
+    std::swap(splitLeft, splitRight);
   }
 
   // Process all pixels up to splitLeft that would sample before the start of
   // the row. Note that because inputStep and outputStep may not be a const 1
   // value, it is more performant to increment pointers here for the source and
   // destination rather than use a loop counter, since doing so would entail an
   // expensive multiplication that significantly slows down the loop.
   uint8_t* dst = &aOutput[aStart * outputStep];
@@ -266,17 +265,17 @@ static inline void BoxBlurRow(const uint
  * @param aWidth The number of columns in the buffers.
  * @param aRows The number of rows in the buffers.
  * @param aStride The stride of the buffer.
  */
 template <bool aTranspose>
 static void BoxBlur(uint8_t* aData, const int32_t aLobes[3][2], int32_t aWidth,
                     int32_t aRows, int32_t aStride, IntRect aSkipRect) {
   if (aTranspose) {
-    swap(aWidth, aRows);
+    std::swap(aWidth, aRows);
     aSkipRect.Swap();
   }
 
   MOZ_ASSERT(aWidth > 0);
 
   // All three passes of the box blur that approximate the Gaussian are done
   // on each row in turn, so we only need two temporary row buffers to process
   // each row, instead of a full-sized buffer. Data moves from the source to the
@@ -312,18 +311,18 @@ static void BoxBlur(uint8_t* aData, cons
     // to be post-transposed yet.
     BoxBlurRow<false, false>(tmpRow, tmpRow2, aLobes[1][0], aLobes[1][1],
                              aWidth, aStride, 0, aWidth);
 
     // Write back data to the destination transposed if necessary too.
     // Make sure not to overwrite the skip rect by only outputting to the
     // destination before and after the skip rect, if requested.
     int32_t skipStart =
-        inSkipRectY ? min(max(aSkipRect.X(), 0), aWidth) : aWidth;
-    int32_t skipEnd = max(skipStart, aSkipRect.XMost());
+        inSkipRectY ? std::min(std::max(aSkipRect.X(), 0), aWidth) : aWidth;
+    int32_t skipEnd = std::max(skipStart, aSkipRect.XMost());
     if (skipStart > 0) {
       BoxBlurRow<false, aTranspose>(tmpRow2, aData, aLobes[2][0], aLobes[2][1],
                                     aWidth, aStride, 0, skipStart);
     }
     if (skipEnd < aWidth) {
       BoxBlurRow<false, aTranspose>(tmpRow2, aData, aLobes[2][0], aLobes[2][1],
                                     aWidth, aStride, skipEnd, aWidth);
     }
@@ -401,21 +400,21 @@ static void SpreadHorizontal(uint8_t* aI
     for (int32_t x = 0; x < aWidth; x++) {
       // Check whether we are within the skip rect. If so, go
       // to the next point outside the skip rect.
       if (inSkipRectY && aSkipRect.ContainsX(x)) {
         x = aSkipRect.XMost();
         if (x >= aWidth) break;
       }
 
-      int32_t sMin = max(x - aRadius, 0);
-      int32_t sMax = min(x + aRadius, aWidth - 1);
+      int32_t sMin = std::max(x - aRadius, 0);
+      int32_t sMax = std::min(x + aRadius, aWidth - 1);
       int32_t v = 0;
       for (int32_t s = sMin; s <= sMax; ++s) {
-        v = max<int32_t>(v, aInput[aStride * y + s]);
+        v = std::max<int32_t>(v, aInput[aStride * y + s]);
       }
       aOutput[aStride * y + x] = v;
     }
   }
 }
 
 static void SpreadVertical(uint8_t* aInput, uint8_t* aOutput, int32_t aRadius,
                            int32_t aWidth, int32_t aRows, int32_t aStride,
@@ -437,21 +436,21 @@ static void SpreadVertical(uint8_t* aInp
     for (int32_t y = 0; y < aRows; y++) {
       // Check whether we are within the skip rect. If so, go
       // to the next point outside the skip rect.
       if (inSkipRectX && aSkipRect.ContainsY(y)) {
         y = aSkipRect.YMost();
         if (y >= aRows) break;
       }
 
-      int32_t sMin = max(y - aRadius, 0);
-      int32_t sMax = min(y + aRadius, aRows - 1);
+      int32_t sMin = std::max(y - aRadius, 0);
+      int32_t sMax = std::min(y + aRadius, aRows - 1);
       int32_t v = 0;
       for (int32_t s = sMin; s <= sMax; ++s) {
-        v = max<int32_t>(v, aInput[aStride * s + x]);
+        v = std::max<int32_t>(v, aInput[aStride * s + x]);
       }
       aOutput[aStride * y + x] = v;
     }
   }
 }
 
 CheckedInt<int32_t> AlphaBoxBlur::RoundUpToMultipleOf4(int32_t aVal) {
   CheckedInt<int32_t> val(aVal);
--- a/gfx/2d/DrawEventRecorder.cpp
+++ b/gfx/2d/DrawEventRecorder.cpp
@@ -7,18 +7,16 @@
 #include "DrawEventRecorder.h"
 #include "PathRecording.h"
 #include "RecordingTypes.h"
 #include "RecordedEventImpl.h"
 
 namespace mozilla {
 namespace gfx {
 
-using namespace std;
-
 DrawEventRecorderPrivate::DrawEventRecorderPrivate() : mExternalFonts(false) {}
 
 void DrawEventRecorderPrivate::StoreExternalSurfaceRecording(
     SourceSurface* aSurface, uint64_t aKey) {
   RecordEvent(RecordedExternalSurfaceCreation(aSurface, aKey));
   mExternalSurfaces.push_back(aSurface);
 }
 
@@ -59,30 +57,30 @@ void DrawEventRecorderMemory::AddDepende
 }
 
 nsTHashtable<nsUint64HashKey>&&
 DrawEventRecorderMemory::TakeDependentSurfaces() {
   return std::move(mDependentSurfaces);
 }
 
 DrawEventRecorderFile::DrawEventRecorderFile(const char_type* aFilename)
-    : mOutputStream(aFilename, ofstream::binary) {
+    : mOutputStream(aFilename, std::ofstream::binary) {
   WriteHeader(mOutputStream);
 }
 
 DrawEventRecorderFile::~DrawEventRecorderFile() { mOutputStream.close(); }
 
 void DrawEventRecorderFile::Flush() { mOutputStream.flush(); }
 
 bool DrawEventRecorderFile::IsOpen() { return mOutputStream.is_open(); }
 
 void DrawEventRecorderFile::OpenNew(const char_type* aFilename) {
   MOZ_ASSERT(!mOutputStream.is_open());
 
-  mOutputStream.open(aFilename, ofstream::binary);
+  mOutputStream.open(aFilename, std::ofstream::binary);
   WriteHeader(mOutputStream);
 }
 
 void DrawEventRecorderFile::Close() {
   MOZ_ASSERT(mOutputStream.is_open());
 
   mOutputStream.close();
 }
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -17,35 +17,33 @@
 #include "HelpersD2D.h"
 #include "FilterNodeD2D1.h"
 #include "ExtendInputEffectD2D1.h"
 #include "nsAppRunner.h"
 #include "MainThreadUtils.h"
 
 #include "mozilla/Mutex.h"
 
-using namespace std;
-
 // decltype is not usable for overloaded functions.
 typedef HRESULT(WINAPI* D2D1CreateFactoryFunc)(
     D2D1_FACTORY_TYPE factoryType, REFIID iid,
     CONST D2D1_FACTORY_OPTIONS* pFactoryOptions, void** factory);
 
 namespace mozilla {
 namespace gfx {
 
 uint64_t DrawTargetD2D1::mVRAMUsageDT;
 uint64_t DrawTargetD2D1::mVRAMUsageSS;
 StaticRefPtr<ID2D1Factory1> DrawTargetD2D1::mFactory;
 
 RefPtr<ID2D1Factory1> D2DFactory() { return DrawTargetD2D1::factory(); }
 
 DrawTargetD2D1::DrawTargetD2D1()
     : mPushedLayers(1),
-      mSnapshotLock(make_shared<Mutex>("DrawTargetD2D1::mSnapshotLock")),
+      mSnapshotLock(std::make_shared<Mutex>("DrawTargetD2D1::mSnapshotLock")),
       mUsedCommandListsSincePurge(0),
       mTransformedGlyphsSinceLastPurge(0),
       mComplexBlendsWithListInList(0),
       mDeviceSeq(0),
       mInitState(InitState::Uninitialized) {}
 
 DrawTargetD2D1::~DrawTargetD2D1() {
   PopAllClips();
@@ -1683,23 +1681,23 @@ void DrawTargetD2D1::AddDependencyOnSour
       mDependingOnTargets.insert(aSource->mDrawTarget);
     }
   }
 }
 
 static D2D1_RECT_F IntersectRect(const D2D1_RECT_F& aRect1,
                                  const D2D1_RECT_F& aRect2) {
   D2D1_RECT_F result;
-  result.left = max(aRect1.left, aRect2.left);
-  result.top = max(aRect1.top, aRect2.top);
-  result.right = min(aRect1.right, aRect2.right);
-  result.bottom = min(aRect1.bottom, aRect2.bottom);
+  result.left = std::max(aRect1.left, aRect2.left);
+  result.top = std::max(aRect1.top, aRect2.top);
+  result.right = std::min(aRect1.right, aRect2.right);
+  result.bottom = std::min(aRect1.bottom, aRect2.bottom);
 
-  result.right = max(result.right, result.left);
-  result.bottom = max(result.bottom, result.top);
+  result.right = std::max(result.right, result.left);
+  result.bottom = std::max(result.bottom, result.top);
 
   return result;
 }
 
 bool DrawTargetD2D1::GetDeviceSpaceClipRect(D2D1_RECT_F& aClipRect,
                                             bool& aIsPixelAligned) {
   aIsPixelAligned = true;
   aClipRect = D2D1::RectF(0, 0, mSize.width, mSize.height);
--- a/gfx/2d/DrawTargetOffset.cpp
+++ b/gfx/2d/DrawTargetOffset.cpp
@@ -3,18 +3,16 @@
 /* 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 "DrawTargetOffset.h"
 #include "Logging.h"
 #include "PathHelpers.h"
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 DrawTargetOffset::DrawTargetOffset() {}
 
 bool DrawTargetOffset::Init(DrawTarget* aDrawTarget, IntPoint aOrigin) {
   mDrawTarget = aDrawTarget;
   mOrigin = aOrigin;
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -37,18 +37,16 @@
 #  include "ScaledFontMac.h"
 #  include "CGTextDrawing.h"
 #endif
 
 #ifdef XP_WIN
 #  include "ScaledFontDWrite.h"
 #endif
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 class GradientStopsSkia : public GradientStops {
  public:
   MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GradientStopsSkia, override)
 
   GradientStopsSkia(const std::vector<GradientStop>& aStops, uint32_t aNumStops,
--- a/gfx/2d/DrawTargetTiled.cpp
+++ b/gfx/2d/DrawTargetTiled.cpp
@@ -3,18 +3,16 @@
 /* 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 "DrawTargetTiled.h"
 #include "Logging.h"
 #include "PathHelpers.h"
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 DrawTargetTiled::DrawTargetTiled() {}
 
 bool DrawTargetTiled::Init(const TileSet& aTiles) {
   if (!aTiles.mTileCount) {
     return false;
@@ -28,26 +26,26 @@ bool DrawTargetTiled::Init(const TileSet
     }
     if (mTiles[0].mDrawTarget->GetFormat() !=
             mTiles.back().mDrawTarget->GetFormat() ||
         mTiles[0].mDrawTarget->GetBackendType() !=
             mTiles.back().mDrawTarget->GetBackendType()) {
       return false;
     }
     uint32_t newXMost =
-        max(mRect.XMost(),
-            mTiles[i].mTileOrigin.x + mTiles[i].mDrawTarget->GetSize().width);
+        std::max(mRect.XMost(), mTiles[i].mTileOrigin.x +
+                                    mTiles[i].mDrawTarget->GetSize().width);
     uint32_t newYMost =
-        max(mRect.YMost(),
-            mTiles[i].mTileOrigin.y + mTiles[i].mDrawTarget->GetSize().height);
+        std::max(mRect.YMost(), mTiles[i].mTileOrigin.y +
+                                    mTiles[i].mDrawTarget->GetSize().height);
     if (i == 0) {
       mRect.MoveTo(mTiles[0].mTileOrigin.x, mTiles[0].mTileOrigin.y);
     } else {
-      mRect.MoveTo(min(mRect.X(), mTiles[i].mTileOrigin.x),
-                   min(mRect.Y(), mTiles[i].mTileOrigin.y));
+      mRect.MoveTo(std::min(mRect.X(), mTiles[i].mTileOrigin.x),
+                   std::min(mRect.Y(), mTiles[i].mTileOrigin.y));
     }
     mRect.SetRightEdge(newXMost);
     mRect.SetBottomEdge(newYMost);
     mTiles[i].mDrawTarget->SetTransform(Matrix::Translation(
         -mTiles[i].mTileOrigin.x, -mTiles[i].mTileOrigin.y));
   }
   mFormat = mTiles[0].mDrawTarget->GetFormat();
   SetPermitSubpixelAA(IsOpaque(mFormat));
--- a/gfx/2d/ImageScaling.cpp
+++ b/gfx/2d/ImageScaling.cpp
@@ -6,18 +6,16 @@
 
 #include "ImageScaling.h"
 #include "2D.h"
 #include "DataSurfaceHelpers.h"
 
 #include <math.h>
 #include <algorithm>
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 inline uint32_t Avg2x2(uint32_t a, uint32_t b, uint32_t c, uint32_t d) {
   // Prepare half-adder work
   uint32_t sum = a ^ b ^ c;
   uint32_t carry = (a & b) | (a & c) | (b & c);
 
@@ -60,18 +58,18 @@ void ImageHalfScaler::ScaleForSize(const
 
   if (scaleSize == mOrigSize) {
     return;
   }
 
   delete[] mDataStorage;
 
   IntSize internalSurfSize;
-  internalSurfSize.width = max(scaleSize.width, mOrigSize.width / 2);
-  internalSurfSize.height = max(scaleSize.height, mOrigSize.height / 2);
+  internalSurfSize.width = std::max(scaleSize.width, mOrigSize.width / 2);
+  internalSurfSize.height = std::max(scaleSize.height, mOrigSize.height / 2);
 
   size_t bufLen = 0;
   mStride = GetAlignedStride<16>(internalSurfSize.width, 4);
   if (mStride > 0) {
     // Allocate 15 bytes extra to make sure we can get 16 byte alignment. We
     // should add tools for this, see bug 751696.
     bufLen =
         BufferSizeFromStrideAndHeight(mStride, internalSurfSize.height, 15);
--- a/gfx/2d/JobScheduler_posix.cpp
+++ b/gfx/2d/JobScheduler_posix.cpp
@@ -2,18 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "JobScheduler.h"
 #include "mozilla/gfx/Logging.h"
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 void* ThreadCallback(void* threadData);
 
 class WorkerThreadPosix : public WorkerThread {
  public:
   explicit WorkerThreadPosix(MultiThreadedJobQueue* aJobQueue)
--- a/gfx/2d/JobScheduler_win32.cpp
+++ b/gfx/2d/JobScheduler_win32.cpp
@@ -2,18 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "JobScheduler.h"
 #include "mozilla/gfx/Logging.h"
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 DWORD __stdcall ThreadCallback(void* threadData);
 
 class WorkerThreadWin32 : public WorkerThread {
  public:
   explicit WorkerThreadWin32(MultiThreadedJobQueue* aJobQueue)
--- a/gfx/2d/Matrix.cpp
+++ b/gfx/2d/Matrix.cpp
@@ -9,18 +9,16 @@
 #include "Tools.h"
 #include <algorithm>
 #include <ostream>
 #include <math.h>
 #include <float.h>  // for FLT_EPSILON
 
 #include "mozilla/FloatingPoint.h"  // for UnspecifiedNaN
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 /* Force small values to zero.  We do this to avoid having sin(360deg)
  * evaluate to a tiny but nonzero value.
  */
 double FlushToZero(double aVal) {
   // XXX Is double precision really necessary here
--- a/gfx/2d/PathCapture.cpp
+++ b/gfx/2d/PathCapture.cpp
@@ -4,18 +4,16 @@
  * 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 "PathCapture.h"
 
 namespace mozilla {
 namespace gfx {
 
-using namespace std;
-
 void PathBuilderCapture::MoveTo(const Point& aPoint) {
   PathOp op;
   op.mType = PathOp::OP_MOVETO;
   op.mP1 = aPoint;
   mPathOps.push_back(op);
   mCurrentPoint = aPoint;
   mBeginPoint = aPoint;
 }
--- a/gfx/2d/PathRecording.cpp
+++ b/gfx/2d/PathRecording.cpp
@@ -10,18 +10,16 @@
 
 namespace mozilla {
 namespace gfx {
 
 #define NEXT_PARAMS(_type)                                        \
   const _type params = *reinterpret_cast<const _type*>(nextByte); \
   nextByte += sizeof(_type);
 
-using namespace std;
-
 bool PathOps::StreamToSink(PathSink& aPathSink) const {
   if (mPathData.empty()) {
     return true;
   }
 
   const uint8_t* nextByte = mPathData.data();
   const uint8_t* end = nextByte + mPathData.size();
   while (nextByte < end) {
--- a/gfx/2d/Quaternion.cpp
+++ b/gfx/2d/Quaternion.cpp
@@ -6,18 +6,16 @@
 
 #include "Quaternion.h"
 #include "Matrix.h"
 #include "Tools.h"
 #include <algorithm>
 #include <ostream>
 #include <math.h>
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 std::ostream& operator<<(std::ostream& aStream, const Quaternion& aQuat) {
   return aStream << "< " << aQuat.x << " " << aQuat.y << " " << aQuat.z << " "
                  << aQuat.w << ">";
 }
 
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -12,33 +12,31 @@
 #include "Filters.h"
 #include "Logging.h"
 #include "ScaledFontBase.h"
 #include "SFNTData.h"
 
 namespace mozilla {
 namespace gfx {
 
-using namespace std;
-
 /* static */
 bool RecordedEvent::DoWithEventFromStream(
     EventStream& aStream, EventType aType,
     const std::function<bool(RecordedEvent*)>& aAction) {
   return DoWithEvent(aStream, aType, aAction);
 }
 
 /* static */
 bool RecordedEvent::DoWithEventFromStream(
     EventRingBuffer& aStream, EventType aType,
     const std::function<bool(RecordedEvent*)>& aAction) {
   return DoWithEvent(aStream, aType, aAction);
 }
 
-string RecordedEvent::GetEventName(EventType aType) {
+std::string RecordedEvent::GetEventName(EventType aType) {
   switch (aType) {
     case DRAWTARGETCREATION:
       return "DrawTarget Creation";
     case DRAWTARGETDESTRUCTION:
       return "DrawTarget Destruction";
     case FILLRECT:
       return "FillRect";
     case STROKERECT:
--- a/gfx/2d/ScaledFontBase.cpp
+++ b/gfx/2d/ScaledFontBase.cpp
@@ -17,18 +17,16 @@
 #  include "PathCairo.h"
 #  include "DrawTargetCairo.h"
 #  include "HelpersCairo.h"
 #endif
 
 #include <vector>
 #include <cmath>
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 Atomic<uint32_t> UnscaledFont::sDeletionCounter(0);
 
 UnscaledFont::~UnscaledFont() { sDeletionCounter++; }
 
 Atomic<uint32_t> ScaledFont::sDeletionCounter(0);
--- a/gfx/2d/ScaledFontDWrite.cpp
+++ b/gfx/2d/ScaledFontDWrite.cpp
@@ -22,18 +22,16 @@
 // not be present.
 // To work around this, until the build environment is updated,
 // we #include an extra header that contains copies of the relevant
 // classes/interfaces we need.
 #if !defined(__MINGW32__) && WINVER < 0x0A00
 #  include "dw-extra.h"
 #endif
 
-using namespace std;
-
 #ifdef USE_SKIA
 #  include "PathSkia.h"
 #  include "skia/include/core/SkPaint.h"
 #  include "skia/include/core/SkPath.h"
 #  include "skia/include/ports/SkTypeface_win.h"
 #endif
 
 #include <vector>
@@ -215,17 +213,17 @@ void ScaledFontDWrite::CopyGlyphsToBuild
 }
 
 void ScaledFontDWrite::GetGlyphDesignMetrics(const uint16_t* aGlyphs,
                                              uint32_t aNumGlyphs,
                                              GlyphMetrics* aGlyphMetrics) {
   DWRITE_FONT_METRICS fontMetrics;
   mFontFace->GetMetrics(&fontMetrics);
 
-  vector<DWRITE_GLYPH_METRICS> metrics(aNumGlyphs);
+  std::vector<DWRITE_GLYPH_METRICS> metrics(aNumGlyphs);
   mFontFace->GetDesignGlyphMetrics(aGlyphs, aNumGlyphs, &metrics.front());
 
   Float scaleFactor = mSize / fontMetrics.designUnitsPerEm;
 
   for (uint32_t i = 0; i < aNumGlyphs; i++) {
     aGlyphMetrics[i].mXBearing = metrics[i].leftSideBearing * scaleFactor;
     aGlyphMetrics[i].mXAdvance = metrics[i].advanceWidth * scaleFactor;
     aGlyphMetrics[i].mYBearing =
--- a/gfx/2d/SourceSurfaceSkia.cpp
+++ b/gfx/2d/SourceSurfaceSkia.cpp
@@ -7,18 +7,16 @@
 #include "Logging.h"
 #include "SourceSurfaceSkia.h"
 #include "HelpersSkia.h"
 #include "DrawTargetSkia.h"
 #include "DataSurfaceHelpers.h"
 #include "skia/include/core/SkData.h"
 #include "mozilla/CheckedInt.h"
 
-using namespace std;
-
 namespace mozilla {
 namespace gfx {
 
 SourceSurfaceSkia::SourceSurfaceSkia()
     : mFormat(SurfaceFormat::UNKNOWN),
       mStride(0),
       mDrawTarget(nullptr),
       mChangeMutex("SourceSurfaceSkia::mChangeMutex"),
--- a/gfx/2d/unittest/Main.cpp
+++ b/gfx/2d/unittest/Main.cpp
@@ -15,30 +15,28 @@
 #include <string>
 #include <sstream>
 
 struct TestObject {
   TestBase* test;
   std::string name;
 };
 
-using namespace std;
-
 int main() {
   TestObject tests[] = {
       {new SanityChecks(), "Sanity Checks"},
 #ifdef WIN32
       {new TestDrawTargetD2D(), "DrawTarget (D2D)"},
 #endif
       {new TestPoint(), "Point Tests"},
       {new TestScaling(), "Scaling Tests"} {new TestBugs(), "Bug Tests"}};
 
   int totalFailures = 0;
   int totalTests = 0;
-  stringstream message;
+  std::stringstream message;
   printf("------ STARTING RUNNING TESTS ------\n");
   for (int i = 0; i < sizeof(tests) / sizeof(TestObject); i++) {
     message << "--- RUNNING TESTS: " << tests[i].name << " ---\n";
     printf(message.str().c_str());
     message.str("");
     int failures = 0;
     totalTests += tests[i].test->RunTests(&failures);
     totalFailures += failures;
--- a/gfx/2d/unittest/TestBase.cpp
+++ b/gfx/2d/unittest/TestBase.cpp
@@ -3,24 +3,22 @@
 /* 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 "TestBase.h"
 
 #include <sstream>
 
-using namespace std;
-
 int TestBase::RunTests(int* aFailures) {
   int testsRun = 0;
   *aFailures = 0;
 
   for (unsigned int i = 0; i < mTests.size(); i++) {
-    stringstream stream;
+    std::stringstream stream;
     stream << "Test (" << mTests[i].name << "): ";
     LogMessage(stream.str());
     stream.str("");
 
     mTestFailed = false;
 
     // Don't try this at home! We know these are actually pointers to members
     // of child clases, so we reinterpret cast those child class pointers to
@@ -36,9 +34,11 @@ int TestBase::RunTests(int* aFailures) {
       (*aFailures)++;
     }
     testsRun++;
   }
 
   return testsRun;
 }
 
-void TestBase::LogMessage(string aMessage) { printf("%s", aMessage.c_str()); }
+void TestBase::LogMessage(std::string aMessage) {
+  printf("%s", aMessage.c_str());
+}
--- a/gfx/2d/unittest/TestDrawTargetBase.cpp
+++ b/gfx/2d/unittest/TestDrawTargetBase.cpp
@@ -4,17 +4,16 @@
  * 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 "TestDrawTargetBase.h"
 #include <sstream>
 
 using namespace mozilla;
 using namespace mozilla::gfx;
-using namespace std;
 
 TestDrawTargetBase::TestDrawTargetBase() {
   REGISTER_TEST(TestDrawTargetBase, Initialized);
   REGISTER_TEST(TestDrawTargetBase, FillCompletely);
   REGISTER_TEST(TestDrawTargetBase, FillRect);
 }
 
 void TestDrawTargetBase::Initialized() { VERIFY(mDT); }
--- a/gfx/tests/gtest/TestArena.cpp
+++ b/gfx/tests/gtest/TestArena.cpp
@@ -46,17 +46,17 @@ class A : public Base {
 
   uint64_t mVal;
 };
 
 class B : public Base {
  public:
   virtual B* AsB() override { return this; }
 
-  explicit B(const string& str) : mVal(str) {}
+  explicit B(const std::string& str) : mVal(str) {}
   ~B() { ++sDtorItemB; }
 
   std::string mVal;
 };
 
 struct BigStruct {
   uint64_t mVal;
   uint8_t data[120];