2016-08-19 14:44:43 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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/. */
|
|
|
|
|
2018-10-14 03:05:36 +03:00
|
|
|
/* FFI functions for Gecko to call into Servo */
|
2016-08-19 14:44:43 +03:00
|
|
|
|
2018-10-14 03:05:48 +03:00
|
|
|
#ifndef mozilla_ServoBindings_h
|
|
|
|
#define mozilla_ServoBindings_h
|
|
|
|
|
2019-03-30 23:18:33 +03:00
|
|
|
#include "mozilla/ServoStyleConsts.h"
|
2018-10-14 03:05:48 +03:00
|
|
|
|
2019-03-30 23:18:33 +03:00
|
|
|
// These functions are defined via macros in Rust, so cbindgen doesn't see them.
|
2018-10-14 03:05:52 +03:00
|
|
|
|
2018-10-14 03:05:48 +03:00
|
|
|
namespace mozilla {
|
2018-10-14 03:05:59 +03:00
|
|
|
|
2019-03-26 21:15:59 +03:00
|
|
|
// The clang we use on windows complains about returning StyleStrong<> and
|
|
|
|
// StyleOwned<>, since the template parameters are incomplete.
|
|
|
|
//
|
|
|
|
// But they only contain pointers so it is ok. Also, this warning hilariously
|
|
|
|
// doesn't exist in GCC.
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#ifdef __clang__
|
|
|
|
# pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
|
|
|
|
#endif
|
|
|
|
|
2018-10-14 03:05:48 +03:00
|
|
|
extern "C" {
|
|
|
|
|
2019-03-21 20:00:27 +03:00
|
|
|
#define BASIC_RULE_FUNCS_WITHOUT_GETTER(type_) \
|
|
|
|
void Servo_##type_##_Debug(const RawServo##type_*, nsACString* result); \
|
|
|
|
void Servo_##type_##_GetCssText(const RawServo##type_*, nsAString* result);
|
2018-10-14 03:05:36 +03:00
|
|
|
|
2019-03-26 21:16:01 +03:00
|
|
|
#define BASIC_RULE_FUNCS(type_) \
|
2019-03-30 23:18:33 +03:00
|
|
|
StyleStrong<RawServo##type_##Rule> Servo_CssRules_Get##type_##RuleAt( \
|
|
|
|
const ServoCssRules* rules, uint32_t index, uint32_t* line, \
|
|
|
|
uint32_t* column); \
|
2017-05-19 09:12:34 +03:00
|
|
|
BASIC_RULE_FUNCS_WITHOUT_GETTER(type_##Rule)
|
2018-10-14 03:05:36 +03:00
|
|
|
|
2019-03-30 23:18:33 +03:00
|
|
|
#define GROUP_RULE_FUNCS(type_) \
|
|
|
|
BASIC_RULE_FUNCS(type_) \
|
|
|
|
StyleStrong<ServoCssRules> Servo_##type_##Rule_GetRules( \
|
2019-03-21 20:00:27 +03:00
|
|
|
const RawServo##type_##Rule* rule);
|
2018-06-01 13:35:39 +03:00
|
|
|
|
2017-03-14 09:52:37 +03:00
|
|
|
BASIC_RULE_FUNCS(Style)
|
2017-05-30 04:10:25 +03:00
|
|
|
BASIC_RULE_FUNCS(Import)
|
2017-05-19 09:12:34 +03:00
|
|
|
BASIC_RULE_FUNCS_WITHOUT_GETTER(Keyframe)
|
|
|
|
BASIC_RULE_FUNCS(Keyframes)
|
2017-04-26 10:57:57 +03:00
|
|
|
GROUP_RULE_FUNCS(Media)
|
2018-06-05 18:16:51 +03:00
|
|
|
GROUP_RULE_FUNCS(MozDocument)
|
2017-03-14 07:44:37 +03:00
|
|
|
BASIC_RULE_FUNCS(Namespace)
|
2017-03-31 05:25:22 +03:00
|
|
|
BASIC_RULE_FUNCS(Page)
|
2017-04-26 10:59:29 +03:00
|
|
|
GROUP_RULE_FUNCS(Supports)
|
2017-07-26 04:30:15 +03:00
|
|
|
BASIC_RULE_FUNCS(FontFeatureValues)
|
Bug 1449087 part 2 - Use Servo data to back @font-face rule. r=emilio
This patch does the following things:
* Create a new class ServoFontFaceRule for CSSOM of @font-face rule
which mostly follows how nsCSSFontFaceRule was implemented.
* Remove the old nsCSSFontFaceRule and binding code to create it.
* Have FontFace backed by Servo data via making mRule and mDescriptors
of the class hold RawServoFontFaceRule like ServoFontFaceRule.
To keep this patch small, it effectively just delays the conversion
from Servo data to nsCSSValue from parsing to using. This may cause
worse performance if the font set is flushed repeatedly. Supposing we
don't flush font set very frequently, it may not be a big deal.
We may still want to remove the intermediate nsCSSValue conversion at
some point, and have everything converted to their final form directly
when used, but that can happen in followups.
There are some unfortunate bits from this change:
* We lose style sheet for logging in FontFaceSet. This is probably not
all that worse, because we wouldn't have that before either if the
page doesn't use CSSOM to visit it. But we should figure out some
approach to fix it anyway.
* InspectorFontFace no longer shares the same rule object as CSSOM.
This isn't really a problem if the @font-face rule isn't very mutable.
Unless we want to make the rule returned from InspectorFontFace to be
mutable (i.e. via inspector), not using the same object probably isn't
too bad.
This patch switches the code we use to serialize stuff in FontFace and
CSSFontFaceRule, which leads to some failures in tests. Specifically,
the expected changes including:
* Value of font-family now can be serialized to identifier sequence like
font-family property. The old code always serializes it to string,
but it doesn't seem to have different requirement than the property.
Blink can serialize to identifier as well.
* Family name inside local() is also changed to use the same way as
family names elsewhere (i.e. can be identifier sequence). Blink has
the same behavior as the old code, but I don't think it's a big deal.
* The order of descriptors serialized gets changed. I don't think it
matters at all.
* Empty string as font-family via using string syntax is no longer
considered invalid for FontFace. I don't find it is mentioned anywhere
that it should be specifically treated invalid.
MozReview-Commit-ID: 32Fk3Fi9uTs
--HG--
extra : rebase_source : 6221ec8fc56de357b06dd27e770fb175348a2f77
2018-04-04 01:42:10 +03:00
|
|
|
BASIC_RULE_FUNCS(FontFace)
|
2018-04-05 01:41:28 +03:00
|
|
|
BASIC_RULE_FUNCS(CounterStyle)
|
2018-10-14 03:05:36 +03:00
|
|
|
|
2017-04-26 10:57:57 +03:00
|
|
|
#undef GROUP_RULE_FUNCS
|
2017-03-14 09:52:37 +03:00
|
|
|
#undef BASIC_RULE_FUNCS
|
2017-05-19 09:12:34 +03:00
|
|
|
#undef BASIC_RULE_FUNCS_WITHOUT_GETTER
|
2018-10-14 03:05:36 +03:00
|
|
|
|
|
|
|
void Servo_CounterStyleRule_GetDescriptorCssText(
|
2019-03-21 20:00:27 +03:00
|
|
|
const RawServoCounterStyleRule* rule, nsCSSCounterDesc desc,
|
2018-10-14 03:05:36 +03:00
|
|
|
nsAString* result);
|
|
|
|
|
2019-03-21 20:00:27 +03:00
|
|
|
bool Servo_CounterStyleRule_SetDescriptor(const RawServoCounterStyleRule* rule,
|
2018-10-14 03:05:36 +03:00
|
|
|
nsCSSCounterDesc desc,
|
|
|
|
const nsACString* value);
|
2016-11-23 02:26:20 +03:00
|
|
|
|
2019-03-26 17:40:20 +03:00
|
|
|
} // extern "C"
|
2019-03-26 17:11:53 +03:00
|
|
|
|
2019-03-26 21:15:59 +03:00
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
2019-03-30 23:18:33 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
2018-10-14 03:05:48 +03:00
|
|
|
#endif // mozilla_ServoBindings_h
|