LCOV - code coverage report
Current view: top level - gfx/src - nsThebesFontEnumerator.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 63 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       5             : 
       6             : #include "nsThebesFontEnumerator.h"
       7             : #include <stdint.h>                     // for uint32_t
       8             : #include "gfxPlatform.h"                // for gfxPlatform
       9             : #include "mozilla/Assertions.h"         // for MOZ_ASSERT_HELPER2
      10             : #include "nsCOMPtr.h"                   // for nsCOMPtr
      11             : #include "nsDebug.h"                    // for NS_ENSURE_ARG_POINTER
      12             : #include "nsError.h"                    // for NS_OK, NS_FAILED, nsresult
      13             : #include "nsIAtom.h"                    // for nsIAtom, NS_Atomize
      14             : #include "nsID.h"
      15             : #include "nsMemory.h"                   // for nsMemory
      16             : #include "nsString.h"               // for nsAutoCString, nsAutoString, etc
      17             : #include "nsTArray.h"                   // for nsTArray, nsTArray_Impl, etc
      18             : #include "nscore.h"                     // for char16_t, NS_IMETHODIMP
      19             : 
      20           0 : NS_IMPL_ISUPPORTS(nsThebesFontEnumerator, nsIFontEnumerator)
      21             : 
      22           0 : nsThebesFontEnumerator::nsThebesFontEnumerator()
      23             : {
      24           0 : }
      25             : 
      26             : NS_IMETHODIMP
      27           0 : nsThebesFontEnumerator::EnumerateAllFonts(uint32_t *aCount,
      28             :                                           char16_t ***aResult)
      29             : {
      30           0 :     return EnumerateFonts (nullptr, nullptr, aCount, aResult);
      31             : }
      32             : 
      33             : NS_IMETHODIMP
      34           0 : nsThebesFontEnumerator::EnumerateFonts(const char *aLangGroup,
      35             :                                        const char *aGeneric,
      36             :                                        uint32_t *aCount,
      37             :                                        char16_t ***aResult)
      38             : {
      39           0 :     NS_ENSURE_ARG_POINTER(aCount);
      40           0 :     NS_ENSURE_ARG_POINTER(aResult);
      41             : 
      42           0 :     nsTArray<nsString> fontList;
      43             : 
      44           0 :     nsAutoCString generic;
      45           0 :     if (aGeneric)
      46           0 :         generic.Assign(aGeneric);
      47             :     else
      48           0 :         generic.SetIsVoid(true);
      49             : 
      50           0 :     nsCOMPtr<nsIAtom> langGroupAtom;
      51           0 :     if (aLangGroup) {
      52           0 :         nsAutoCString lowered;
      53           0 :         lowered.Assign(aLangGroup);
      54           0 :         ToLowerCase(lowered);
      55           0 :         langGroupAtom = NS_Atomize(lowered);
      56             :     }
      57             : 
      58           0 :     nsresult rv = gfxPlatform::GetPlatform()->GetFontList(langGroupAtom, generic, fontList);
      59             : 
      60           0 :     if (NS_FAILED(rv)) {
      61           0 :         *aCount = 0;
      62           0 :         *aResult = nullptr;
      63             :         /* XXX in this case, do we want to return the CSS generics? */
      64           0 :         return NS_OK;
      65             :     }
      66             : 
      67             :     char16_t **fs = static_cast<char16_t **>
      68           0 :                                 (moz_xmalloc(fontList.Length() * sizeof(char16_t*)));
      69           0 :     for (uint32_t i = 0; i < fontList.Length(); i++) {
      70           0 :         fs[i] = ToNewUnicode(fontList[i]);
      71             :     }
      72             : 
      73           0 :     *aResult = fs;
      74           0 :     *aCount = fontList.Length();
      75             : 
      76           0 :     return NS_OK;
      77             : }
      78             : 
      79             : NS_IMETHODIMP
      80           0 : nsThebesFontEnumerator::HaveFontFor(const char *aLangGroup,
      81             :                                     bool *aResult)
      82             : {
      83           0 :     NS_ENSURE_ARG_POINTER(aResult);
      84             : 
      85           0 :     *aResult = true;
      86           0 :     return NS_OK;
      87             : }
      88             : 
      89             : NS_IMETHODIMP
      90           0 : nsThebesFontEnumerator::GetDefaultFont(const char *aLangGroup,
      91             :                                        const char *aGeneric,
      92             :                                        char16_t **aResult)
      93             : {
      94           0 :     if (NS_WARN_IF(!aResult) || NS_WARN_IF(!aLangGroup) ||
      95           0 :         NS_WARN_IF(!aGeneric)) {
      96           0 :         return NS_ERROR_INVALID_ARG;
      97             :     }
      98             : 
      99           0 :     *aResult = nullptr;
     100             :     nsAutoString defaultFontName(gfxPlatform::GetPlatform()->
     101           0 :         GetDefaultFontName(nsDependentCString(aLangGroup),
     102           0 :                            nsDependentCString(aGeneric)));
     103           0 :     if (!defaultFontName.IsEmpty()) {
     104           0 :         *aResult = ToNewUnicode(defaultFontName);
     105             :     }
     106           0 :     return NS_OK;
     107             : }
     108             : 
     109             : NS_IMETHODIMP
     110           0 : nsThebesFontEnumerator::UpdateFontList(bool *_retval)
     111             : {
     112           0 :     gfxPlatform::GetPlatform()->UpdateFontList();
     113           0 :     *_retval = false; // always return false for now
     114           0 :     return NS_OK;
     115             : }
     116             : 
     117             : NS_IMETHODIMP
     118           0 : nsThebesFontEnumerator::GetStandardFamilyName(const char16_t *aName,
     119             :                                               char16_t **aResult)
     120             : {
     121           0 :     NS_ENSURE_ARG_POINTER(aResult);
     122           0 :     NS_ENSURE_ARG_POINTER(aName);
     123             : 
     124           0 :     nsAutoString name(aName);
     125           0 :     if (name.IsEmpty()) {
     126           0 :         *aResult = nullptr;
     127           0 :         return NS_OK;
     128             :     }
     129             : 
     130           0 :     nsAutoString family;
     131           0 :     nsresult rv = gfxPlatform::GetPlatform()->
     132           0 :         GetStandardFamilyName(nsDependentString(aName), family);
     133           0 :     if (NS_FAILED(rv) || family.IsEmpty()) {
     134           0 :         *aResult = nullptr;
     135           0 :         return NS_OK;
     136             :     }
     137           0 :     *aResult = ToNewUnicode(family);
     138           0 :     return NS_OK;
     139             : }

Generated by: LCOV version 1.13