Bug 1203379 - Fix indentation of gfxWordCacheTest.cpp. r=jrmuizel.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 09 Sep 2015 20:51:33 -0700
changeset 294390 88f44d76266b67c9dbadaa826e8942554f60423b
parent 294389 a530b8b339b4967d2935be5af7242aed35b982d1
child 294391 856d68a4477a59d3401f4e58c49cb9efa90fab8b
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1203379
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1203379 - Fix indentation of gfxWordCacheTest.cpp. r=jrmuizel. This file has an intriguing mix of 1, 2, 3 and 4 space indentation, which this patch fixes. The patch also fixes a small number of other style violations, such as long lines.
gfx/tests/gtest/gfxWordCacheTest.cpp
--- a/gfx/tests/gtest/gfxWordCacheTest.cpp
+++ b/gfx/tests/gtest/gfxWordCacheTest.cpp
@@ -1,10 +1,11 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* 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 "gtest/gtest.h"
 
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "nsCOMPtr.h"
@@ -28,110 +29,113 @@ class FrameTextRunCache;
 
 static FrameTextRunCache *gTextRuns = nullptr;
 
 /*
  * Cache textruns and expire them after 3*10 seconds of no use.
  */
 class FrameTextRunCache final : public nsExpirationTracker<gfxTextRun,3> {
 public:
- enum { TIMEOUT_SECONDS = 10 };
- FrameTextRunCache()
-     : nsExpirationTracker<gfxTextRun,3>(TIMEOUT_SECONDS*1000) {}
- ~FrameTextRunCache() {
-   AgeAllGenerations();
- }
+  enum { TIMEOUT_SECONDS = 10 };
+  FrameTextRunCache()
+    : nsExpirationTracker<gfxTextRun,3>(TIMEOUT_SECONDS*1000) {}
+  ~FrameTextRunCache() {
+    AgeAllGenerations();
+  }
 
- void RemoveFromCache(gfxTextRun* aTextRun) {
-   if (aTextRun->GetExpirationState()->IsTracked()) {
-     RemoveObject(aTextRun);
-   }
- }
+  void RemoveFromCache(gfxTextRun* aTextRun) {
+    if (aTextRun->GetExpirationState()->IsTracked()) {
+      RemoveObject(aTextRun);
+    }
+  }
 
- // This gets called when the timeout has expired on a gfxTextRun
- virtual void NotifyExpired(gfxTextRun* aTextRun) {
-   RemoveFromCache(aTextRun);
-   delete aTextRun;
- }
+  // This gets called when the timeout has expired on a gfxTextRun
+  virtual void NotifyExpired(gfxTextRun* aTextRun) {
+    RemoveFromCache(aTextRun);
+    delete aTextRun;
+  }
 };
 
 static gfxTextRun *
-MakeTextRun(const char16_t *aText, uint32_t aLength,
-           gfxFontGroup *aFontGroup, const gfxFontGroup::Parameters* aParams,
-           uint32_t aFlags)
+MakeTextRun(const char16_t *aText, uint32_t aLength, gfxFontGroup *aFontGroup,
+            const gfxFontGroup::Parameters* aParams, uint32_t aFlags)
 {
-   nsAutoPtr<gfxTextRun> textRun;
-   if (aLength == 0) {
-       abort();
-       //textRun = aFontGroup->MakeEmptyTextRun(aParams, aFlags);
-   } else if (aLength == 1 && aText[0] == ' ') {
-       abort();
-       //textRun = aFontGroup->MakeSpaceTextRun(aParams, aFlags);
-   } else {
-       textRun = aFontGroup->MakeTextRun(aText, aLength, aParams, aFlags);
-   }
-   if (!textRun)
-       return nullptr;
-   nsresult rv = gTextRuns->AddObject(textRun);
-   if (NS_FAILED(rv)) {
-       gTextRuns->RemoveFromCache(textRun);
-       return nullptr;
-   }
-   return textRun.forget();
+  nsAutoPtr<gfxTextRun> textRun;
+  if (aLength == 0) {
+    abort();
+    //textRun = aFontGroup->MakeEmptyTextRun(aParams, aFlags);
+  } else if (aLength == 1 && aText[0] == ' ') {
+    abort();
+    //textRun = aFontGroup->MakeSpaceTextRun(aParams, aFlags);
+  } else {
+    textRun = aFontGroup->MakeTextRun(aText, aLength, aParams, aFlags);
+  }
+  if (!textRun) {
+    return nullptr;
+  }
+  nsresult rv = gTextRuns->AddObject(textRun);
+  if (NS_FAILED(rv)) {
+    gTextRuns->RemoveFromCache(textRun);
+    return nullptr;
+  }
+  return textRun.forget();
 }
 
 static already_AddRefed<gfxContext>
 MakeContext ()
 {
-   const int size = 200;
+  const int size = 200;
 
-    RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
-        CreateOffscreenContentDrawTarget(IntSize(size, size),
-                                         SurfaceFormat::B8G8R8X8);
-    nsRefPtr<gfxContext> ctx = new gfxContext(drawTarget);
+  RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
+      CreateOffscreenContentDrawTarget(IntSize(size, size),
+                                       SurfaceFormat::B8G8R8X8);
+  nsRefPtr<gfxContext> ctx = new gfxContext(drawTarget);
 
-    return ctx.forget();
+  return ctx.forget();
 }
 
 TEST(Gfx, WordCache) {
-   gTextRuns = new FrameTextRunCache();
+  gTextRuns = new FrameTextRunCache();
 
-   nsRefPtr<gfxContext> ctx = MakeContext();
-   {
-       gfxFontStyle style (mozilla::gfx::FontStyle::NORMAL,
-                           139,
-                           10.0,
-                           0,
-                           NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
-                           0.0,
-                           false, false,
-                           NS_LITERAL_STRING(""));
+  nsRefPtr<gfxContext> ctx = MakeContext();
+  {
+    gfxFontStyle style(mozilla::gfx::FontStyle::NORMAL,
+                       139,
+                       10.0,
+                       0,
+                       NS_NewPermanentAtom(NS_LITERAL_STRING("en")),
+                       0.0,
+                       false, false,
+                       NS_LITERAL_STRING(""));
 
-       nsRefPtr<gfxFontGroup> fontGroup =
-           gfxPlatform::GetPlatform()->CreateFontGroup(NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style, nullptr);
+    nsRefPtr<gfxFontGroup> fontGroup =
+      gfxPlatform::GetPlatform()->CreateFontGroup(
+        NS_LITERAL_STRING("Geneva, MS Sans Serif, Helvetica,serif"), &style,
+        nullptr);
 
-       gfxTextRunFactory::Parameters params = {
-           ctx, nullptr, nullptr, nullptr, 0, 60
-       };
-
-       uint32_t flags = gfxTextRunFactory::TEXT_IS_PERSISTENT;
+    gfxTextRunFactory::Parameters params = {
+      ctx, nullptr, nullptr, nullptr, 0, 60
+    };
 
-       // First load an Arabic word into the cache
-       const char cString[] = "\xd8\xaa\xd9\x85";
-       nsDependentCString cStr(cString);
-       NS_ConvertUTF8toUTF16 str(cStr);
-       gfxTextRun *tr = MakeTextRun(str.get(), str.Length(), fontGroup, &params, flags);
-       tr->GetAdvanceWidth(0, str.Length(), nullptr);
+    uint32_t flags = gfxTextRunFactory::TEXT_IS_PERSISTENT;
+
+    // First load an Arabic word into the cache
+    const char cString[] = "\xd8\xaa\xd9\x85";
+    nsDependentCString cStr(cString);
+    NS_ConvertUTF8toUTF16 str(cStr);
+    gfxTextRun *tr =
+      MakeTextRun(str.get(), str.Length(), fontGroup, &params, flags);
+    tr->GetAdvanceWidth(0, str.Length(), nullptr);
 
-       // Now try to trigger an assertion with a word cache bug. The first
-       // word is in the cache so it gets added to the new textrun directly.
-       // The second word is not in the cache 
-       const char cString2[] = "\xd8\xaa\xd9\x85\n\xd8\xaa\xd8\x85 ";
-       nsDependentCString cStr2(cString2);
-       NS_ConvertUTF8toUTF16 str2(cStr2);
-       gfxTextRun *tr2 = MakeTextRun(str2.get(), str2.Length(), fontGroup, &params, flags);
-       tr2->GetAdvanceWidth(0, str2.Length(), nullptr);
-   }
+    // Now try to trigger an assertion with a word cache bug. The first
+    // word is in the cache so it gets added to the new textrun directly.
+    // The second word is not in the cache.
+    const char cString2[] = "\xd8\xaa\xd9\x85\n\xd8\xaa\xd8\x85 ";
+    nsDependentCString cStr2(cString2);
+    NS_ConvertUTF8toUTF16 str2(cStr2);
+    gfxTextRun *tr2 =
+      MakeTextRun(str2.get(), str2.Length(), fontGroup, &params, flags);
+    tr2->GetAdvanceWidth(0, str2.Length(), nullptr);
+  }
 
-   delete gTextRuns;
-   gTextRuns = nullptr;
-
+  delete gTextRuns;
+  gTextRuns = nullptr;
 }