Bug 1708193 - Remove mozapps/extensions/internal/Content.js r=rpl
[gecko.git] / gfx / thebes / gfxTypes.h
blob0e08c2154750e9c62112cf2d906f11ce785580c8
1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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 #ifndef GFX_TYPES_H
7 #define GFX_TYPES_H
9 #include <stdint.h>
10 #include "mozilla/TypedEnumBits.h"
12 namespace mozilla {
13 enum class StyleGenericFontFamily : uint32_t;
16 typedef struct _cairo_surface cairo_surface_t;
17 typedef struct _cairo_user_data_key cairo_user_data_key_t;
19 typedef void (*thebes_destroy_func_t)(void* data);
21 /**
22 * Currently needs to be 'double' for Cairo compatibility. Could
23 * become 'float', perhaps, in some configurations.
25 typedef double gfxFloat;
27 /**
28 * Priority of a line break opportunity.
30 * eNoBreak The line has no break opportunities
31 * eWordWrapBreak The line has a break opportunity only within a word. With
32 * overflow-wrap|word-wrap: break-word we will break at this
33 * point only if there are no other break opportunities in the
34 * line.
35 * eNormalBreak The line has a break opportunity determined by the standard
36 * line-breaking algorithm.
38 * Future expansion: split eNormalBreak into multiple priorities, e.g.
39 * punctuation break and whitespace break (bug 389710).
40 * As and when we implement it, text-wrap: unrestricted will
41 * mean that priorities are ignored and all line-break
42 * opportunities are equal.
44 * @see gfxTextRun::BreakAndMeasureText
45 * @see nsLineLayout::NotifyOptionalBreakPosition
47 enum class gfxBreakPriority { eNoBreak = 0, eWordWrapBreak, eNormalBreak };
49 enum class gfxSurfaceType {
50 Image,
51 PDF,
52 PS,
53 Xlib,
54 Xcb,
55 Glitz, // unused, but needed for cairo parity
56 Quartz,
57 Win32,
58 BeOS,
59 DirectFB, // unused, but needed for cairo parity
60 SVG,
61 OS2,
62 Win32Printing,
63 QuartzImage,
64 Script,
65 QPainter,
66 Recording,
67 VG,
68 GL,
69 DRM,
70 Tee,
71 XML,
72 Skia,
73 Subsurface,
74 Max
77 enum class gfxContentType {
78 COLOR = 0x1000,
79 ALPHA = 0x2000,
80 COLOR_ALPHA = 0x3000,
81 SENTINEL = 0xffff
84 enum class gfxAlphaType {
85 Opaque,
86 Premult,
87 NonPremult,
90 /**
91 * Type used to record how a particular font is selected during the font-
92 * matching process, so that this can be exposed to the Inspector.
94 struct FontMatchType {
95 enum class Kind : uint8_t {
96 kUnspecified = 0,
97 kFontGroup = 1,
98 kPrefsFallback = 1 << 1,
99 kSystemFallback = 1 << 2,
102 inline FontMatchType& operator|=(const FontMatchType& aOther);
104 bool operator==(const FontMatchType& aOther) const {
105 return kind == aOther.kind && generic == aOther.generic;
108 bool operator!=(const FontMatchType& aOther) const {
109 return !(*this == aOther);
112 MOZ_IMPLICIT FontMatchType() = default;
113 MOZ_IMPLICIT FontMatchType(Kind aKind) : kind(aKind) {}
114 FontMatchType(Kind aKind, mozilla::StyleGenericFontFamily aGeneric)
115 : kind(aKind), generic(aGeneric) {}
117 Kind kind = static_cast<Kind>(0);
118 // Using 0 to avoid pulling ServoStyleConsts.h everywhere.
119 mozilla::StyleGenericFontFamily generic = mozilla::StyleGenericFontFamily(0);
122 MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(FontMatchType::Kind)
124 FontMatchType& FontMatchType::operator|=(const FontMatchType& aOther) {
125 kind |= aOther.kind;
126 // We only keep track of one generic.
127 if (generic != aOther.generic) {
128 generic = mozilla::StyleGenericFontFamily(0);
130 return *this;
133 // Installation status (base system / langpack / user-installed) may determine
134 // whether the font is visible to CSS font-family or src:local() lookups.
135 // (Exactly what these mean and how accurate they are may be vary across
136 // platforms -- e.g. on Linux there is no clear "base" set of fonts.)
137 enum class FontVisibility : uint8_t {
138 Unknown = 0, // No categorization of families available on this system
139 Base = 1, // Standard part of the base OS installation
140 LangPack = 2, // From an optional OS component such as language support
141 User = 3, // User-installed font (or installed by another app, etc)
142 Hidden = 4, // Internal system font, should never exposed to users
143 Webfont = 5, // Webfont defined by @font-face
144 Count = 6, // Count of values, for IPC serialization
147 struct HwStretchingSupport {
148 uint32_t mBoth;
149 uint32_t mWindowOnly;
150 uint32_t mFullScreenOnly;
151 uint32_t mNone;
152 uint32_t mError;
154 HwStretchingSupport()
155 : mBoth(0), mWindowOnly(0), mFullScreenOnly(0), mNone(0), mError(0) {}
157 bool IsFullySupported() const {
158 return mBoth > 0 && mWindowOnly == 0 && mFullScreenOnly == 0 &&
159 mNone == 0 && mError == 0;
163 #endif /* GFX_TYPES_H */