gfx/src/nsThebesGfxFactory.cpp

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "gfxPlatform.h"                // for gfxPlatform
     7 #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
     8 #include "mozilla/Attributes.h"         // for MOZ_FINAL
     9 #include "mozilla/Module.h"             // for Module, Module::CIDEntry, etc
    10 #include "mozilla/ModuleUtils.h"
    11 #include "mozilla/mozalloc.h"           // for operator new
    12 #include "nsCOMPtr.h"                   // for nsCOMPtr
    13 #include "nsError.h"                    // for NS_ERROR_NO_AGGREGATION, etc
    14 #include "nsGfxCIID.h"                  // for NS_FONT_ENUMERATOR_CID, etc
    15 #include "nsID.h"                       // for NS_DEFINE_NAMED_CID, etc
    16 #include "nsIScriptableRegion.h"        // for nsIScriptableRegion
    17 #include "nsISupports.h"                // for NS_DECL_ISUPPORTS, etc
    18 #include "nsScriptableRegion.h"         // for nsScriptableRegion
    19 #include "nsThebesFontEnumerator.h"     // for nsThebesFontEnumerator
    21 NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator)
    23 static nsresult
    24 nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
    25 {
    26   if (!aResult) {
    27     return NS_ERROR_NULL_POINTER;
    28   }
    29   *aResult = nullptr;
    30   if (aOuter) {
    31     return NS_ERROR_NO_AGGREGATION;
    32   }
    34   nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion();
    35   return scriptableRgn->QueryInterface(aIID, aResult);
    36 }
    38 NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID);
    39 NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID);
    41 static const mozilla::Module::CIDEntry kThebesCIDs[] = {
    42     { &kNS_FONT_ENUMERATOR_CID, false, nullptr, nsThebesFontEnumeratorConstructor },
    43     { &kNS_SCRIPTABLE_REGION_CID, false, nullptr, nsScriptableRegionConstructor },
    44     { nullptr }
    45 };
    47 static const mozilla::Module::ContractIDEntry kThebesContracts[] = {
    48     { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID },
    49     { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
    50     { nullptr }
    51 };
    53 static const mozilla::Module kThebesModule = {
    54     mozilla::Module::kVersion,
    55     kThebesCIDs,
    56     kThebesContracts,
    57     nullptr,
    58     nullptr,
    59     nullptr,
    60     nullptr
    61 };
    63 NSMODULE_DEFN(nsGfxModule) = &kThebesModule;

mercurial