Bug 1921049 - Remove some bindgen includes. r=firefox-style-system-reviewers,boris

Differential Revision: https://phabricator.services.mozilla.com/D223615
This commit is contained in:
Emilio Cobos Álvarez 2024-09-25 17:43:28 +00:00
parent c903afa293
commit fe1d67cc92
16 changed files with 89 additions and 107 deletions

32
gfx/2d/FontFeature.h Normal file
View File

@ -0,0 +1,32 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_gfx_FontFeature
#define mozilla_gfx_FontFeature
#include <cstdint>
namespace mozilla::gfx {
// An OpenType feature tag and value pair
struct FontFeature {
// see http://www.microsoft.com/typography/otspec/featuretags.htm
uint32_t mTag;
// 0 = off, 1 = on, larger values may be used as parameters
// to features that select among multiple alternatives
uint32_t mValue;
};
inline bool operator<(const FontFeature& a, const FontFeature& b) {
return (a.mTag < b.mTag) || ((a.mTag == b.mTag) && (a.mValue < b.mValue));
}
inline bool operator==(const FontFeature& a, const FontFeature& b) {
return (a.mTag == b.mTag) && (a.mValue == b.mValue);
}
} // namespace mozilla::gfx
#endif

View File

@ -29,6 +29,7 @@ EXPORTS.mozilla.gfx += [
"DrawTargetRecording.h",
"DrawTargetSkia.h",
"Filters.h",
"FontFeature.h",
"FontVariation.h",
"Helpers.h",
"HelpersCairo.h",

View File

@ -14,7 +14,6 @@
#include "mozilla/StyleColorInlines.h" // for StyleAbsoluteColor
#include "nsTArray.h" // for nsTArray
struct gfxFontFeature;
struct gfxFontStyle;
// Font structure.

View File

@ -16,6 +16,7 @@
#include "gfxFontVariations.h"
#include "gfxRect.h"
#include "gfxTypes.h"
#include "gfxFontFeatures.h"
#include "harfbuzz/hb.h"
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Assertions.h"
@ -44,7 +45,6 @@ class gfxSVGGlyphs;
class gfxUserFontData;
class nsAtom;
struct FontListSizes;
struct gfxFontFeature;
struct gfxFontStyle;
enum class eFontPresentation : uint8_t;

View File

@ -11,24 +11,9 @@
#include "nsTHashtable.h"
#include "nsTArray.h"
#include "nsString.h"
#include "mozilla/gfx/FontFeature.h"
// An OpenType feature tag and value pair
struct gfxFontFeature {
uint32_t
mTag; // see http://www.microsoft.com/typography/otspec/featuretags.htm
uint32_t mValue; // 0 = off, 1 = on, larger values may be used as parameters
// to features that select among multiple alternatives
};
inline bool operator<(const gfxFontFeature& a, const gfxFontFeature& b) {
return (a.mTag < b.mTag) || ((a.mTag == b.mTag) && (a.mValue < b.mValue));
}
inline bool operator==(const gfxFontFeature& a, const gfxFontFeature& b) {
return (a.mTag == b.mTag) && (a.mValue == b.mValue);
}
class nsAtom;
using gfxFontFeature = mozilla::gfx::FontFeature;
class gfxFontFeatureValueSet final {
public:

View File

@ -36,6 +36,7 @@ class StyleSheet;
enum class PseudoStyleType : uint8_t;
enum class PointerCapabilities : uint8_t;
enum class UpdateAnimationsTasks : uint8_t;
enum class StyleColorGamut : uint8_t;
struct Keyframe;
struct StyleStylesheetContents;
@ -44,7 +45,6 @@ class LoaderReusableStyleSheets;
}
namespace dom {
enum class CompositeOperationOrAuto : uint8_t;
enum class ScreenColorGamut : uint8_t;
} // namespace dom
} // namespace mozilla
@ -583,7 +583,7 @@ bool Gecko_MediaFeatures_UseOverlayScrollbars(const mozilla::dom::Document*);
int32_t Gecko_MediaFeatures_GetColorDepth(const mozilla::dom::Document*);
int32_t Gecko_MediaFeatures_GetMonochromeBitsPerPixel(
const mozilla::dom::Document*);
mozilla::dom::ScreenColorGamut Gecko_MediaFeatures_ColorGamut(
mozilla::StyleColorGamut Gecko_MediaFeatures_ColorGamut(
const mozilla::dom::Document*);
void Gecko_MediaFeatures_GetDeviceSize(const mozilla::dom::Document*,

View File

@ -2,20 +2,16 @@
headers = [
"nsStyleStruct.h",
"mozilla/StyleAnimationValue.h",
"gfxFontConstants.h",
"gfxFontFeatures.h",
"COLRFonts.h",
"nsStyleConsts.h",
"mozilla/css/Loader.h",
"nsCSSValue.h",
"mozilla/AnimatedPropertyID.h",
"mozilla/css/SheetLoadData.h",
"mozilla/DeclarationBlock.h",
"mozilla/dom/AnimationEffectBinding.h",
"mozilla/dom/HTMLSlotElement.h",
"mozilla/dom/KeyframeEffectBinding.h",
"mozilla/dom/MediaList.h",
"mozilla/dom/ScreenBinding.h",
"mozilla/dom/ShadowRoot.h",
"mozilla/gfx/FontFeature.h",
"mozilla/ipc/ByteBuf.h",
"mozilla/AnimationPropertySegment.h",
"mozilla/ComputedTiming.h",
@ -88,7 +84,6 @@ rusty-enums = [
"mozilla::Side",
"mozilla::dom::PlaybackDirection",
"mozilla::dom::FillMode",
"mozilla::dom::ScreenColorGamut",
"mozilla::HalfCorner",
"mozilla::StyleFloatEdge",
"mozilla::StyleShapeRadius",
@ -160,7 +155,6 @@ rusty-enums = [
"mozilla::PseudoStyleType",
"mozilla::LookAndFeel_ColorID",
"mozilla::LookAndFeel_FontID",
"nsStyleTransformMatrix::MatrixTransformOperator",
"mozilla::StyleGeometryBox",
"mozilla::SystemColor",
"mozilla::StyleMaskMode",
@ -189,6 +183,7 @@ allowlist-vars = [
# TODO(emilio): A bunch of types here can go away once we generate bindings and
# structs together.
allowlist-types = [
"nsCSSUnit",
"nsFontFaceRuleContainer",
"mozilla::ComputedKeyframeValues",
"mozilla::Keyframe",
@ -224,13 +219,10 @@ allowlist-types = [
"mozilla::UpdateAnimationsTasks",
"mozilla::PointerCapabilities",
"mozilla::LookAndFeel",
"mozilla::gfx::Float",
"mozilla::gfx::FontFeature",
"mozilla::gfx::FontVariation",
"mozilla::gfx::FontPaletteValueSet",
"mozilla::StyleImageLayerAttachment",
"gfxFontFeature",
"gfxFontVariation",
"Element",
"GeckoFontMetrics",
"GeckoImplicitShadowRoot",
"gfxFontFeatureValueSet",
@ -248,7 +240,6 @@ allowlist-types = [
"nsCSSPropertyID",
"nsCSSPropertyIDSet",
"nsCSSProps",
"nsCSSValue",
"nsFont",
"nsAtom",
"nsDynamicAtom",
@ -289,11 +280,20 @@ allowlist-types = [
"mozilla::InheritTarget",
"mozilla::dom::MediaList",
"mozilla::StyleRuleInclusion",
"nsStyleTransformMatrix::MatrixTransformOperator",
"NodeSelectorFlags",
]
opaque-types = [
"mozilla::StyleThinArc", # https://github.com/rust-lang/rust-bindgen/issues/1557
"mozilla::gfx::.*Point",
"mozilla::gfx::.*Rect",
"mozilla::gfx::.*Size",
"mozilla::gfx::.*Margin",
"mozilla::gfx::.*Matrix",
"mozilla::gfx::.*Typed",
"mozilla::gfx::Matrix4x4TypedFlagged",
"mozilla::gfx::DrawTarget",
"mozilla::TouchManager",
"mozilla::CanvasUsage",
"std::pair__PCCP",
"std::namespace::atomic___base", "std::atomic__My_base",
"std::atomic",
@ -301,9 +301,7 @@ opaque-types = [
"std::tuple.*", # Causes "Cannot find type _Pred in this scope" error on mac, like rust-skia#571
"std::.*::tuple.*",
# We want everything but FontVariation and Float to be opaque but we don't
# have negative regexes.
"mozilla::gfx::(.{0,4}|.{6,12}|.{14,}|([^F][^o][^n][^t][^V][^a][^r][^i][^a][^t][^i][^o][^n])|([^F][^l][^o][^a][^t]))",
"mozilla::dom::Touch",
"mozilla::dom::Sequence",
"mozilla::SmallPointerArray",
"mozilla::dom::Optional",
@ -368,6 +366,7 @@ cbindgen-types = [
{ gecko = "StyleComputedFontWeightRange", servo = "crate::font_face::ComputedFontWeightRange" },
{ gecko = "StyleComputedTimingFunction", servo = "crate::values::computed::easing::TimingFunction" },
{ gecko = "StylePrefersContrast", servo = "crate::gecko::media_features::PrefersContrast" },
{ gecko = "StyleColorGamut", servo = "crate::gecko::media_features::ColorGamut" },
{ gecko = "StyleCursorKind", servo = "crate::values::computed::ui::CursorKind" },
{ gecko = "StyleDisplay", servo = "crate::values::specified::Display" },
{ gecko = "StyleDisplayMode", servo = "crate::gecko::media_features::DisplayMode" },

View File

@ -46,14 +46,15 @@ class imgRequestProxy;
struct nsCSSValueSharedList;
class gfxFontFeatureValueSet;
struct gfxFontFeature;
struct GeckoFontMetrics;
namespace mozilla {
namespace gfx {
struct FontVariation;
struct FontFeature;
} // namespace gfx
} // namespace mozilla
typedef mozilla::gfx::FontVariation gfxFontVariation;
using gfxFontVariation = mozilla::gfx::FontVariation;
using gfxFontFeature = mozilla::gfx::FontFeature;
enum nsCSSUnit : uint32_t;
enum nsChangeHint : uint32_t;

View File

@ -9,23 +9,16 @@
#ifndef mozilla_StyleAnimationValue_h_
#define mozilla_StyleAnimationValue_h_
#include "mozilla/gfx/MatrixFwd.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/RefPtr.h"
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/ServoStyleConsts.h" // Servo_AnimationValue_Dump
#include "mozilla/DbgMacro.h"
#include "mozilla/AnimatedPropertyID.h"
#include "nsStringFwd.h"
#include "nsCoord.h"
#include "nsColor.h"
#include "nsCSSPropertyID.h"
#include "nsCSSValue.h"
#include "nsStyleConsts.h"
#include "nsStyleTransformMatrix.h"
class nsIFrame;
class gfx3DMatrix;
namespace mozilla {

View File

@ -9,34 +9,12 @@
#ifndef nsCSSValue_h___
#define nsCSSValue_h___
#include "mozilla/Attributes.h"
#include "mozilla/CORSMode.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/ServoBindingTypes.h"
#include "mozilla/URLExtraData.h"
#include "mozilla/UniquePtr.h"
#include "nsCoord.h"
#include "nsTArray.h"
#include <type_traits>
// XXX Avoid including this here by moving function bodies to the cpp file
#include "mozilla/FloatingPoint.h"
class imgRequestProxy;
class nsAtom;
class nsIContent;
class nsIPrincipal;
class nsIURI;
class nsPresContext;
template <class T>
class nsPtrHashKey;
struct RawServoCssUrlData;
namespace mozilla {
struct URLExtraData;
class CSSStyleSheet;
} // namespace mozilla

View File

@ -142,15 +142,20 @@ int32_t Gecko_MediaFeatures_GetMonochromeBitsPerPixel(
return color ? 0 : kDefaultMonochromeBpp;
}
dom::ScreenColorGamut Gecko_MediaFeatures_ColorGamut(
const Document* aDocument) {
auto colorGamut = dom::ScreenColorGamut::Srgb;
if (!aDocument->ShouldResistFingerprinting(RFPTarget::CSSColorInfo)) {
if (auto* dx = GetDeviceContextFor(aDocument)) {
colorGamut = dx->GetColorGamut();
StyleColorGamut Gecko_MediaFeatures_ColorGamut(const Document* aDocument) {
auto* dx = GetDeviceContextFor(aDocument);
if (!dx || aDocument->ShouldResistFingerprinting(RFPTarget::CSSColorInfo)) {
return StyleColorGamut::Srgb;
}
switch (dx->GetColorGamut()) {
case dom::ScreenColorGamut::Srgb:
return StyleColorGamut::Srgb;
case dom::ScreenColorGamut::Rec2020:
return StyleColorGamut::Rec2020;
case dom::ScreenColorGamut::P3:
return StyleColorGamut::P3;
}
return colorGamut;
return StyleColorGamut::Srgb;
}
int32_t Gecko_MediaFeatures_GetColorDepth(const Document* aDocument) {

View File

@ -280,7 +280,7 @@ class Accumulate {
static Matrix4x4 operateByServo(const Matrix4x4& aMatrix1,
const Matrix4x4& aMatrix2, double aCount) {
Matrix4x4 result;
Servo_MatrixTransform_Operate(MatrixTransformOperator::Accumulate,
Servo_MatrixTransform_Operate(/* aInterpolate = */ false,
&aMatrix1.components, &aMatrix2.components,
aCount, &result.components);
return result;
@ -318,7 +318,7 @@ class Interpolate {
static Matrix4x4 operateByServo(const Matrix4x4& aMatrix1,
const Matrix4x4& aMatrix2, double aProgress) {
Matrix4x4 result;
Servo_MatrixTransform_Operate(MatrixTransformOperator::Interpolate,
Servo_MatrixTransform_Operate(/* aInterpolate = */ true,
&aMatrix1.components, &aMatrix2.components,
aProgress, &result.components);
return result;

View File

@ -18,7 +18,6 @@ class nsCSSValue;
class nsIContent;
class nsIPrincipal;
class nsIURI;
struct gfxFontFeature;
struct nsCSSKTableEntry;
struct nsCSSValueList;
struct nsStylePosition;

View File

@ -6,7 +6,6 @@
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs;
use crate::gecko_bindings::structs::ScreenColorGamut;
use crate::media_queries::{Device, MediaType};
use crate::parser::ParserContext;
use crate::queries::feature::{AllowsRanges, Evaluator, FeatureFlags, QueryFeatureDescription};
@ -150,7 +149,7 @@ fn eval_monochrome(context: &Context) -> i32 {
/// higher capabilities.
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, PartialEq, PartialOrd, ToCss)]
#[repr(u8)]
enum ColorGamut {
pub enum ColorGamut {
/// The sRGB gamut.
Srgb,
/// The gamut specified by the Display P3 Color Space.
@ -168,12 +167,7 @@ fn eval_color_gamut(context: &Context, query_value: Option<ColorGamut>) -> bool
let color_gamut =
unsafe { bindings::Gecko_MediaFeatures_ColorGamut(context.device().document()) };
// Match if our color gamut is at least as wide as the query value
query_value <=
match color_gamut {
ScreenColorGamut::Srgb => ColorGamut::Srgb,
ScreenColorGamut::P3 => ColorGamut::P3,
ScreenColorGamut::Rec2020 => ColorGamut::Rec2020,
}
query_value <= color_gamut
}
/// https://drafts.csswg.org/mediaqueries-4/#resolution

View File

@ -105,6 +105,7 @@ include = [
"BoolInteger",
"OutlineStyle",
"CaptionSide",
"ColorGamut",
"FontSizeAdjust",
"FontPalette",
"FontLanguageOverride",

View File

@ -67,7 +67,6 @@ use style::gecko_bindings::structs::nsCSSFontDesc;
use style::gecko_bindings::structs::nsCSSPropertyID;
use style::gecko_bindings::structs::nsChangeHint;
use style::gecko_bindings::structs::nsCompatibility;
use style::gecko_bindings::structs::nsStyleTransformMatrix::MatrixTransformOperator;
use style::gecko_bindings::structs::nsresult;
use style::gecko_bindings::structs::CallerType;
use style::gecko_bindings::structs::CompositeOperation;
@ -4768,28 +4767,24 @@ pub extern "C" fn Servo_GetProperties_Overriding_Animation(
#[no_mangle]
pub extern "C" fn Servo_MatrixTransform_Operate(
matrix_operator: MatrixTransformOperator,
from: *const structs::Matrix4x4Components,
to: *const structs::Matrix4x4Components,
interpolate: bool,
from: &structs::Matrix4x4Components,
to: &structs::Matrix4x4Components,
progress: f64,
output: *mut structs::Matrix4x4Components,
output: &mut structs::Matrix4x4Components,
) {
use self::MatrixTransformOperator::{Accumulate, Interpolate};
use style::values::computed::transform::Matrix3D;
let from = Matrix3D::from(unsafe { from.as_ref() }.expect("not a valid 'from' matrix"));
let to = Matrix3D::from(unsafe { to.as_ref() }.expect("not a valid 'to' matrix"));
let result = match matrix_operator {
Interpolate => from.animate(&to, Procedure::Interpolate { progress }),
Accumulate => from.animate(
&to,
let from = Matrix3D::from(from);
let to = Matrix3D::from(to);
let proc = if interpolate {
Procedure::Interpolate { progress }
} else {
Procedure::Accumulate {
count: progress as u64,
},
),
}
};
let output = unsafe { output.as_mut() }.expect("not a valid 'output' matrix");
let result = from.animate(&to, proc);
if let Ok(result) = result {
*output = result.into();
} else if progress < 0.5 {