LCOV - code coverage report
Current view: top level - gfx/thebes - gfxFontFeatures.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 22 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 22 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             : 
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef GFX_FONT_FEATURES_H
       8             : #define GFX_FONT_FEATURES_H
       9             : 
      10             : #include "nsTHashtable.h"
      11             : #include "nsTArray.h"
      12             : #include "nsString.h"
      13             : 
      14             : // An OpenType feature tag and value pair
      15             : struct gfxFontFeature {
      16             :     uint32_t mTag; // see http://www.microsoft.com/typography/otspec/featuretags.htm
      17             :     uint32_t mValue; // 0 = off, 1 = on, larger values may be used as parameters
      18             :                      // to features that select among multiple alternatives
      19             : };
      20             : 
      21             : inline bool
      22             : operator<(const gfxFontFeature& a, const gfxFontFeature& b)
      23             : {
      24             :     return (a.mTag < b.mTag) || ((a.mTag == b.mTag) && (a.mValue < b.mValue));
      25             : }
      26             : 
      27             : inline bool
      28           0 : operator==(const gfxFontFeature& a, const gfxFontFeature& b)
      29             : {
      30           0 :     return (a.mTag == b.mTag) && (a.mValue == b.mValue);
      31             : }
      32             : 
      33           0 : struct gfxAlternateValue {
      34             :     uint32_t           alternate;  // constants in gfxFontConstants.h
      35             :     nsString           value;      // string value to be looked up
      36             : };
      37             : 
      38             : inline bool
      39             : operator<(const gfxAlternateValue& a, const gfxAlternateValue& b)
      40             : {
      41             :     return (a.alternate < b.alternate) ||
      42             :         ((a.alternate == b.alternate) && (a.value < b.value));
      43             : }
      44             : 
      45             : inline bool
      46           0 : operator==(const gfxAlternateValue& a, const gfxAlternateValue& b)
      47             : {
      48           0 :     return (a.alternate == b.alternate) && (a.value == b.value);
      49             : }
      50             : 
      51             : class gfxFontFeatureValueSet final {
      52             : public:
      53           0 :     NS_INLINE_DECL_REFCOUNTING(gfxFontFeatureValueSet)
      54             : 
      55             :     gfxFontFeatureValueSet();
      56             : 
      57           0 :     struct ValueList {
      58           0 :         ValueList(const nsAString& aName, const nsTArray<uint32_t>& aSelectors)
      59           0 :           : name(aName), featureSelectors(aSelectors)
      60           0 :         {}
      61             :         nsString             name;
      62             :         nsTArray<uint32_t>   featureSelectors;
      63             :     };
      64             : 
      65           0 :     struct FeatureValues {
      66             :         uint32_t             alternate;
      67             :         nsTArray<ValueList>  valuelist;
      68             :     };
      69             : 
      70             :     // returns true if found, false otherwise
      71             :     bool
      72             :     GetFontFeatureValuesFor(const nsAString& aFamily,
      73             :                             uint32_t aVariantProperty,
      74             :                             const nsAString& aName,
      75             :                             nsTArray<uint32_t>& aValues);
      76             :     void
      77             :     AddFontFeatureValues(const nsAString& aFamily,
      78             :                 const nsTArray<gfxFontFeatureValueSet::FeatureValues>& aValues);
      79             : 
      80             : private:
      81             :     // Private destructor, to discourage deletion outside of Release():
      82           0 :     ~gfxFontFeatureValueSet() {}
      83             : 
      84           0 :     struct FeatureValueHashKey {
      85             :         nsString mFamily;
      86             :         uint32_t mPropVal;
      87             :         nsString mName;
      88             : 
      89           0 :         FeatureValueHashKey()
      90           0 :             : mPropVal(0)
      91           0 :         { }
      92           0 :         FeatureValueHashKey(const nsAString& aFamily,
      93             :                             uint32_t aPropVal,
      94             :                             const nsAString& aName)
      95           0 :             : mFamily(aFamily), mPropVal(aPropVal), mName(aName)
      96           0 :         { }
      97             :         FeatureValueHashKey(const FeatureValueHashKey& aKey)
      98             :             : mFamily(aKey.mFamily), mPropVal(aKey.mPropVal), mName(aKey.mName)
      99             :         { }
     100             :     };
     101             : 
     102             :     class FeatureValueHashEntry : public PLDHashEntryHdr {
     103             :     public:
     104             :         typedef const FeatureValueHashKey &KeyType;
     105             :         typedef const FeatureValueHashKey *KeyTypePointer;
     106             : 
     107           0 :         explicit FeatureValueHashEntry(KeyTypePointer aKey) { }
     108             :         FeatureValueHashEntry(const FeatureValueHashEntry& toCopy)
     109             :         {
     110             :             NS_ERROR("Should not be called");
     111             :         }
     112           0 :         ~FeatureValueHashEntry() { }
     113             : 
     114             :         bool KeyEquals(const KeyTypePointer aKey) const;
     115           0 :         static KeyTypePointer KeyToPointer(KeyType aKey) { return &aKey; }
     116             :         static PLDHashNumber HashKey(const KeyTypePointer aKey);
     117             :         enum { ALLOW_MEMMOVE = true };
     118             : 
     119             :         FeatureValueHashKey mKey;
     120             :         nsTArray<uint32_t>  mValues;
     121             :     };
     122             : 
     123             :     nsTHashtable<FeatureValueHashEntry> mFontFeatureValues;
     124             :   };
     125             : 
     126             : #endif

Generated by: LCOV version 1.13