tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

InspectorFontFace.h (2540B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_InspectorFontFace_h
      8 #define mozilla_InspectorFontFace_h
      9 
     10 #include "gfxTypes.h"
     11 #include "mozilla/dom/CSSFontFaceRule.h"
     12 #include "mozilla/dom/InspectorUtilsBinding.h"
     13 #include "mozilla/dom/NonRefcountedDOMObject.h"
     14 #include "nsRange.h"
     15 
     16 class gfxFontEntry;
     17 class gfxFontGroup;
     18 
     19 namespace mozilla::dom {
     20 
     21 /**
     22 * Information on font face usage by a given DOM Range, as returned by
     23 * InspectorUtils.getUsedFontFaces.
     24 */
     25 class InspectorFontFace final : public NonRefcountedDOMObject {
     26 public:
     27  InspectorFontFace(gfxFontEntry* aFontEntry, gfxFontGroup* aFontGroup,
     28                    FontMatchType aMatchType);
     29 
     30  ~InspectorFontFace();
     31 
     32  gfxFontEntry* GetFontEntry() const { return mFontEntry; }
     33  void AddMatchType(FontMatchType aMatchType) { mMatchType |= aMatchType; }
     34 
     35  void AddRange(nsRange* aRange);
     36  size_t RangeCount() const { return mRanges.Length(); }
     37 
     38  // Web IDL
     39  bool FromFontGroup();
     40  bool FromLanguagePrefs();
     41  bool FromSystemFallback();
     42  void GetName(nsAString& aName);
     43  void GetCSSFamilyName(nsAString& aCSSFamilyName);
     44  void GetCSSGeneric(nsAString& aGeneric);
     45  CSSFontFaceRule* GetRule();
     46  int32_t SrcIndex();
     47  void GetURI(nsAString& aURI);
     48  void GetLocalName(nsAString& aLocalName);
     49  void GetFormat(nsAString& aFormat);
     50  void GetMetadata(nsAString& aMetadata);
     51 
     52  void GetNameString(uint16_t aNameId, nsAString& aResult);
     53 
     54  void GetVariationAxes(nsTArray<InspectorVariationAxis>& aResult,
     55                        ErrorResult& aRV);
     56  void GetVariationInstances(nsTArray<InspectorVariationInstance>& aResult,
     57                             ErrorResult& aRV);
     58  void GetFeatures(nsTArray<InspectorFontFeature>& aResult, ErrorResult& aRV);
     59 
     60  void GetRanges(nsTArray<RefPtr<nsRange>>& aResult);
     61 
     62  bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
     63                  JS::MutableHandle<JSObject*> aReflector) {
     64    return InspectorFontFace_Binding::Wrap(aCx, this, aGivenProto, aReflector);
     65  }
     66 
     67 protected:
     68  RefPtr<gfxFontEntry> mFontEntry;
     69  RefPtr<gfxFontGroup> mFontGroup;
     70  RefPtr<CSSFontFaceRule> mRule;
     71  FontMatchType mMatchType;
     72 
     73  nsTArray<RefPtr<nsRange>> mRanges;
     74 };
     75 
     76 }  // namespace mozilla::dom
     77 
     78 #endif  // mozilla_InspectorFontFace_h