зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1536584, bug 1538661, bug 1538694) for causing build bustages CLOSED TREE
Backed out changeset 563e8fb1be5d (bug 1538694) Backed out changeset 7bd834c5800c (bug 1536584) Backed out changeset f1eec8f7a3f8 (bug 1538694) Backed out changeset 73a48619739e (bug 1538661)
This commit is contained in:
Родитель
67acdcda59
Коммит
b68e341245
|
@ -1348,7 +1348,7 @@ Document::Document(const char* aContentType)
|
|||
SetIsConnected(true);
|
||||
|
||||
if (StaticPrefs::layout_css_use_counters_enabled()) {
|
||||
mStyleUseCounters = Servo_UseCounters_Create().Consume();
|
||||
mStyleUseCounters.reset(Servo_UseCounters_Create());
|
||||
}
|
||||
|
||||
SetContentTypeInternal(nsDependentCString(aContentType));
|
||||
|
|
|
@ -223,7 +223,7 @@ bool ResponsiveImageSelector::SetSizesFromDescriptor(const nsAString& aSizes) {
|
|||
ClearSelectedCandidate();
|
||||
|
||||
NS_ConvertUTF16toUTF8 sizes(aSizes);
|
||||
mServoSourceSizeList = Servo_SourceSizeList_Parse(&sizes).Consume();
|
||||
mServoSourceSizeList.reset(Servo_SourceSizeList_Parse(&sizes));
|
||||
return !!mServoSourceSizeList;
|
||||
}
|
||||
|
||||
|
|
|
@ -366,7 +366,7 @@ void ShadowRoot::InsertSheetIntoAuthorData(size_t aIndex, StyleSheet& aSheet) {
|
|||
MOZ_ASSERT(aSheet.IsApplicable());
|
||||
|
||||
if (!mServoStyles) {
|
||||
mServoStyles = Servo_AuthorStyles_Create().Consume();
|
||||
mServoStyles.reset(Servo_AuthorStyles_Create());
|
||||
}
|
||||
|
||||
if (mStyleRuleMap) {
|
||||
|
|
|
@ -2498,8 +2498,8 @@ const RawServoSelectorList* nsINode::ParseSelectorList(
|
|||
|
||||
NS_ConvertUTF16toUTF8 selectorString(aSelectorString);
|
||||
|
||||
UniquePtr<RawServoSelectorList> selectorList =
|
||||
Servo_SelectorList_Parse(&selectorString).Consume();
|
||||
auto selectorList = UniquePtr<RawServoSelectorList>(
|
||||
Servo_SelectorList_Parse(&selectorString));
|
||||
if (!selectorList) {
|
||||
aRv.ThrowDOMException(NS_ERROR_DOM_SYNTAX_ERR,
|
||||
NS_LITERAL_CSTRING("'") + selectorString +
|
||||
|
|
|
@ -120,7 +120,7 @@ void nsXBLPrototypeResources::ClearLoader() { mLoader = nullptr; }
|
|||
|
||||
void nsXBLPrototypeResources::SyncServoStyles() {
|
||||
mStyleRuleMap.reset(nullptr);
|
||||
mServoStyles = Servo_AuthorStyles_Create().Consume();
|
||||
mServoStyles.reset(Servo_AuthorStyles_Create());
|
||||
for (auto& sheet : mStyleSheetList) {
|
||||
Servo_AuthorStyles_AppendStyleSheet(mServoStyles.get(), sheet);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ class nsWindowSizes;
|
|||
#undef STYLE_STRUCT
|
||||
|
||||
extern "C" {
|
||||
void Servo_ComputedStyle_AddRef(const mozilla::ComputedStyle* aStyle);
|
||||
void Servo_ComputedStyle_Release(const mozilla::ComputedStyle* aStyle);
|
||||
void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle*);
|
||||
}
|
||||
|
||||
|
@ -89,6 +91,9 @@ class ComputedStyle {
|
|||
|
||||
Bit Bits() const { return static_cast<Bit>(mSource.flags.mFlags); }
|
||||
|
||||
void AddRef() { Servo_ComputedStyle_AddRef(this); }
|
||||
void Release() { Servo_ComputedStyle_Release(this); }
|
||||
|
||||
// Return the ComputedStyle whose style data should be used for the R,
|
||||
// G, and B components of color, background-color, and border-*-color
|
||||
// if RelevantLinkIsVisited().
|
||||
|
|
|
@ -148,16 +148,15 @@ class DeclarationBlock final {
|
|||
return reinterpret_cast<RawServoDeclarationBlock* const*>(&mRaw);
|
||||
}
|
||||
|
||||
const StyleStrong<RawServoDeclarationBlock>* RefRawStrong() const {
|
||||
const RawServoDeclarationBlockStrong* RefRawStrong() const {
|
||||
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
|
||||
sizeof(RawServoDeclarationBlock*),
|
||||
"RefPtr should just be a pointer");
|
||||
static_assert(
|
||||
sizeof(RefPtr<RawServoDeclarationBlock>) ==
|
||||
sizeof(StyleStrong<RawServoDeclarationBlock>),
|
||||
sizeof(RawServoDeclarationBlockStrong),
|
||||
"RawServoDeclarationBlockStrong should be the same as RefPtr");
|
||||
return reinterpret_cast<const StyleStrong<RawServoDeclarationBlock>*>(
|
||||
&mRaw);
|
||||
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&mRaw);
|
||||
}
|
||||
|
||||
void ToString(nsAString& aResult) const {
|
||||
|
|
|
@ -85,6 +85,16 @@ using namespace mozilla;
|
|||
using namespace mozilla::css;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
#define SERVO_ARC_TYPE(name_, type_) \
|
||||
already_AddRefed<type_> type_##Strong::Consume() { \
|
||||
RefPtr<type_> result; \
|
||||
result.swap(mPtr); \
|
||||
return result.forget(); \
|
||||
}
|
||||
#include "mozilla/ServoArcTypeList.h"
|
||||
SERVO_ARC_TYPE(ComputedStyle, ComputedStyle)
|
||||
#undef SERVO_ARC_TYPE
|
||||
|
||||
// Definitions of the global traversal stats.
|
||||
bool ServoTraversalStatistics::sActive = false;
|
||||
ServoTraversalStatistics ServoTraversalStatistics::sSingleton;
|
||||
|
@ -345,7 +355,7 @@ bool Gecko_HaveSeenPtr(SeenPtrs* aTable, const void* aPtr) {
|
|||
return aTable->HaveSeenPtr(aPtr);
|
||||
}
|
||||
|
||||
const StyleStrong<RawServoDeclarationBlock>* Gecko_GetStyleAttrDeclarationBlock(
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetStyleAttrDeclarationBlock(
|
||||
const Element* aElement) {
|
||||
DeclarationBlock* decl = aElement->GetInlineStyleDeclaration();
|
||||
if (!decl) {
|
||||
|
@ -362,15 +372,15 @@ void Gecko_UnsetDirtyStyleAttr(const Element* aElement) {
|
|||
decl->UnsetDirty();
|
||||
}
|
||||
|
||||
static const StyleStrong<RawServoDeclarationBlock>* AsRefRawStrong(
|
||||
static const RawServoDeclarationBlockStrong* AsRefRawStrong(
|
||||
const RefPtr<RawServoDeclarationBlock>& aDecl) {
|
||||
static_assert(sizeof(RefPtr<RawServoDeclarationBlock>) ==
|
||||
sizeof(StyleStrong<RawServoDeclarationBlock>),
|
||||
sizeof(RawServoDeclarationBlockStrong),
|
||||
"RefPtr should just be a pointer");
|
||||
return reinterpret_cast<const StyleStrong<RawServoDeclarationBlock>*>(&aDecl);
|
||||
return reinterpret_cast<const RawServoDeclarationBlockStrong*>(&aDecl);
|
||||
}
|
||||
|
||||
const StyleStrong<RawServoDeclarationBlock>*
|
||||
const RawServoDeclarationBlockStrong*
|
||||
Gecko_GetHTMLPresentationAttrDeclarationBlock(const Element* aElement) {
|
||||
const nsMappedAttributes* attrs = aElement->GetMappedAttributes();
|
||||
if (!attrs) {
|
||||
|
@ -386,8 +396,8 @@ Gecko_GetHTMLPresentationAttrDeclarationBlock(const Element* aElement) {
|
|||
return AsRefRawStrong(attrs->GetServoStyle());
|
||||
}
|
||||
|
||||
const StyleStrong<RawServoDeclarationBlock>*
|
||||
Gecko_GetExtraContentStyleDeclarations(const Element* aElement) {
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetExtraContentStyleDeclarations(
|
||||
const Element* aElement) {
|
||||
if (!aElement->IsAnyOfHTMLElements(nsGkAtoms::td, nsGkAtoms::th)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -400,7 +410,7 @@ Gecko_GetExtraContentStyleDeclarations(const Element* aElement) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const StyleStrong<RawServoDeclarationBlock>*
|
||||
const RawServoDeclarationBlockStrong*
|
||||
Gecko_GetUnvisitedLinkAttrDeclarationBlock(const Element* aElement) {
|
||||
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
|
||||
if (!sheet) {
|
||||
|
@ -438,8 +448,8 @@ void Gecko_StyleSheet_Release(const StyleSheet* aSheet) {
|
|||
const_cast<StyleSheet*>(aSheet)->Release();
|
||||
}
|
||||
|
||||
const StyleStrong<RawServoDeclarationBlock>*
|
||||
Gecko_GetVisitedLinkAttrDeclarationBlock(const Element* aElement) {
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetVisitedLinkAttrDeclarationBlock(
|
||||
const Element* aElement) {
|
||||
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
|
||||
if (!sheet) {
|
||||
return nullptr;
|
||||
|
@ -448,8 +458,8 @@ Gecko_GetVisitedLinkAttrDeclarationBlock(const Element* aElement) {
|
|||
return AsRefRawStrong(sheet->GetServoVisitedLinkDecl());
|
||||
}
|
||||
|
||||
const StyleStrong<RawServoDeclarationBlock>*
|
||||
Gecko_GetActiveLinkAttrDeclarationBlock(const Element* aElement) {
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetActiveLinkAttrDeclarationBlock(
|
||||
const Element* aElement) {
|
||||
nsHTMLStyleSheet* sheet = aElement->OwnerDoc()->GetAttributeStyleSheet();
|
||||
if (!sheet) {
|
||||
return nullptr;
|
||||
|
@ -1631,7 +1641,7 @@ void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* aDst,
|
|||
aDst->mContextPropsBits = aSrc->mContextPropsBits;
|
||||
}
|
||||
|
||||
URLValue* Gecko_URLValue_Create(StyleStrong<RawServoCssUrlData> aCssUrl,
|
||||
URLValue* Gecko_URLValue_Create(RawServoCssUrlDataStrong aCssUrl,
|
||||
CORSMode aCORSMode) {
|
||||
RefPtr<URLValue> url = new URLValue(aCssUrl.Consume(), aCORSMode);
|
||||
return url.forget().take();
|
||||
|
@ -2050,10 +2060,9 @@ GeckoFontMetrics Gecko_GetFontMetrics(const nsPresContext* aPresContext,
|
|||
NS_IMPL_THREADSAFE_FFI_REFCOUNTING(SheetLoadDataHolder, SheetLoadDataHolder);
|
||||
|
||||
void Gecko_StyleSheet_FinishAsyncParse(
|
||||
SheetLoadDataHolder* aData,
|
||||
StyleStrong<RawServoStyleSheetContents> aSheetContents,
|
||||
StyleOwnedOrNull<StyleUseCounters> aUseCounters) {
|
||||
UniquePtr<StyleUseCounters> useCounters = aUseCounters.Consume();
|
||||
SheetLoadDataHolder* aData, RawServoStyleSheetContentsStrong aSheetContents,
|
||||
StyleUseCountersOwned aUseCounters) {
|
||||
UniquePtr<StyleUseCounters> useCounters(aUseCounters);
|
||||
RefPtr<SheetLoadDataHolder> loadData = aData;
|
||||
RefPtr<RawServoStyleSheetContents> sheetContents = aSheetContents.Consume();
|
||||
NS_DispatchToMainThread(NS_NewRunnableFunction(
|
||||
|
@ -2119,8 +2128,8 @@ static already_AddRefed<StyleSheet> LoadImportSheet(
|
|||
StyleSheet* Gecko_LoadStyleSheet(Loader* aLoader, StyleSheet* aParent,
|
||||
SheetLoadData* aParentLoadData,
|
||||
LoaderReusableStyleSheets* aReusableSheets,
|
||||
StyleStrong<RawServoCssUrlData> aCssUrl,
|
||||
StyleStrong<RawServoMediaList> aMediaList) {
|
||||
RawServoCssUrlDataStrong aCssUrl,
|
||||
RawServoMediaListStrong aMediaList) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// The CORS mode in the URLValue is irrelevant here.
|
||||
|
@ -2132,9 +2141,9 @@ StyleSheet* Gecko_LoadStyleSheet(Loader* aLoader, StyleSheet* aParent,
|
|||
}
|
||||
|
||||
void Gecko_LoadStyleSheetAsync(SheetLoadDataHolder* aParentData,
|
||||
StyleStrong<RawServoCssUrlData> aCssUrl,
|
||||
StyleStrong<RawServoMediaList> aMediaList,
|
||||
StyleStrong<RawServoImportRule> aImportRule) {
|
||||
RawServoCssUrlDataStrong aCssUrl,
|
||||
RawServoMediaListStrong aMediaList,
|
||||
RawServoImportRuleStrong aImportRule) {
|
||||
RefPtr<SheetLoadDataHolder> loadData = aParentData;
|
||||
// The CORS mode in the URLValue is irrelevant here.
|
||||
// (CORS_NONE is used for all imported sheets in Load::LoadChildSheet.)
|
||||
|
|
|
@ -109,20 +109,19 @@ NS_DECL_THREADSAFE_FFI_REFCOUNTING(mozilla::css::SheetLoadDataHolder,
|
|||
|
||||
void Gecko_StyleSheet_FinishAsyncParse(
|
||||
mozilla::css::SheetLoadDataHolder* data,
|
||||
mozilla::StyleStrong<RawServoStyleSheetContents> sheet_contents,
|
||||
mozilla::StyleOwnedOrNull<StyleUseCounters> use_counters);
|
||||
RawServoStyleSheetContentsStrong sheet_contents,
|
||||
StyleUseCountersOwnedOrNull use_counters);
|
||||
|
||||
mozilla::StyleSheet* Gecko_LoadStyleSheet(
|
||||
mozilla::css::Loader* loader, mozilla::StyleSheet* parent,
|
||||
mozilla::css::SheetLoadData* parent_load_data,
|
||||
mozilla::css::LoaderReusableStyleSheets* reusable_sheets,
|
||||
mozilla::StyleStrong<RawServoCssUrlData> url,
|
||||
mozilla::StyleStrong<RawServoMediaList> media_list);
|
||||
RawServoCssUrlDataStrong url, RawServoMediaListStrong media_list);
|
||||
|
||||
void Gecko_LoadStyleSheetAsync(mozilla::css::SheetLoadDataHolder* parent_data,
|
||||
mozilla::StyleStrong<RawServoCssUrlData>,
|
||||
mozilla::StyleStrong<RawServoMediaList>,
|
||||
mozilla::StyleStrong<RawServoImportRule>);
|
||||
RawServoCssUrlDataStrong,
|
||||
RawServoMediaListStrong,
|
||||
RawServoImportRuleStrong);
|
||||
|
||||
// Selector Matching.
|
||||
uint64_t Gecko_ElementState(const mozilla::dom::Element*);
|
||||
|
@ -171,27 +170,27 @@ SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS(
|
|||
#undef SERVO_DECLARE_ELEMENT_ATTR_MATCHING_FUNCTIONS
|
||||
|
||||
// Style attributes.
|
||||
const mozilla::StyleStrong<RawServoDeclarationBlock>*
|
||||
Gecko_GetStyleAttrDeclarationBlock(const mozilla::dom::Element* element);
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetStyleAttrDeclarationBlock(
|
||||
const mozilla::dom::Element* element);
|
||||
|
||||
void Gecko_UnsetDirtyStyleAttr(const mozilla::dom::Element* element);
|
||||
|
||||
const mozilla::StyleStrong<RawServoDeclarationBlock>*
|
||||
const RawServoDeclarationBlockStrong*
|
||||
Gecko_GetHTMLPresentationAttrDeclarationBlock(
|
||||
const mozilla::dom::Element* element);
|
||||
|
||||
const mozilla::StyleStrong<RawServoDeclarationBlock>*
|
||||
Gecko_GetExtraContentStyleDeclarations(const mozilla::dom::Element* element);
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetExtraContentStyleDeclarations(
|
||||
const mozilla::dom::Element* element);
|
||||
|
||||
const mozilla::StyleStrong<RawServoDeclarationBlock>*
|
||||
const RawServoDeclarationBlockStrong*
|
||||
Gecko_GetUnvisitedLinkAttrDeclarationBlock(
|
||||
const mozilla::dom::Element* element);
|
||||
|
||||
const mozilla::StyleStrong<RawServoDeclarationBlock>*
|
||||
Gecko_GetVisitedLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetVisitedLinkAttrDeclarationBlock(
|
||||
const mozilla::dom::Element* element);
|
||||
|
||||
const mozilla::StyleStrong<RawServoDeclarationBlock>*
|
||||
Gecko_GetActiveLinkAttrDeclarationBlock(const mozilla::dom::Element* element);
|
||||
const RawServoDeclarationBlockStrong* Gecko_GetActiveLinkAttrDeclarationBlock(
|
||||
const mozilla::dom::Element* element);
|
||||
|
||||
// Visited handling.
|
||||
|
||||
|
@ -568,8 +567,8 @@ void Gecko_nsStyleSVG_SetContextPropertiesLength(nsStyleSVG* svg, uint32_t len);
|
|||
void Gecko_nsStyleSVG_CopyContextProperties(nsStyleSVG* dst,
|
||||
const nsStyleSVG* src);
|
||||
|
||||
mozilla::css::URLValue* Gecko_URLValue_Create(
|
||||
mozilla::StyleStrong<RawServoCssUrlData> url, mozilla::CORSMode aCORSMode);
|
||||
mozilla::css::URLValue* Gecko_URLValue_Create(RawServoCssUrlDataStrong url,
|
||||
mozilla::CORSMode aCORSMode);
|
||||
|
||||
size_t Gecko_URLValue_SizeOfIncludingThis(mozilla::css::URLValue* url);
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@ SERVO_ARC_TYPE(PageRule, RawServoPageRule)
|
|||
SERVO_ARC_TYPE(SupportsRule, RawServoSupportsRule)
|
||||
SERVO_ARC_TYPE(DocumentRule, RawServoMozDocumentRule)
|
||||
SERVO_ARC_TYPE(FontFeatureValuesRule, RawServoFontFeatureValuesRule)
|
||||
SERVO_ARC_TYPE(RuleNode, RawServoRuleNode)
|
||||
SERVO_ARC_TYPE(FontFaceRule, RawServoFontFaceRule)
|
||||
SERVO_ARC_TYPE(CounterStyleRule, RawServoCounterStyleRule)
|
||||
SERVO_ARC_TYPE(CssUrlData, RawServoCssUrlData)
|
||||
SERVO_ARC_TYPE(Quotes, RawServoQuotes)
|
||||
|
||||
// clang-format on
|
||||
|
|
|
@ -29,12 +29,18 @@
|
|||
// RawServo{Type}Strong
|
||||
// strong reference to an Arc-managed value
|
||||
//
|
||||
// RawServo{Type}Owned
|
||||
// RawServo{Type}OwnedOrNull
|
||||
// owned reference to a Box-managed value (or null)
|
||||
//
|
||||
// All of these strong, and owned types are generated by adding
|
||||
// entries to one of these files:
|
||||
//
|
||||
// ServoArcTypeList.h
|
||||
// generates the Strong type
|
||||
//
|
||||
// ServoBoxedTypeList.h
|
||||
// generates the Owned & OwnedOrNull types
|
||||
//
|
||||
// The strong, and owned reference types should be used in FFI function
|
||||
// signatures where possible, to help indicate the ownership properties that
|
||||
|
@ -56,6 +62,13 @@
|
|||
// RefPtr<RawServo{Type}>, but it's probably easier just to pass a raw pointer
|
||||
// and let the Rust code turn it into an Arc.
|
||||
//
|
||||
// The Owned types are C++ typedefs for raw pointers. When receiving an Owned
|
||||
// value from a Servo_* FFI function, it should be assigned to a UniquePtr<>,
|
||||
// otherwise it will leak.
|
||||
//
|
||||
// To pass an Owned value to Servo, call `release()` on the UniquePtr<> it's
|
||||
// living in (to take ownership of it), and pass that pointer in directly.
|
||||
//
|
||||
// TODO(heycam): We should perhaps have a similar struct for Owned types with a
|
||||
// Consume() method to convert them into a UniquePtr. The struct for Strong
|
||||
// types at least have MOZ_MUST_USE_TYPE on them.
|
||||
|
@ -88,9 +101,11 @@
|
|||
// This is another FFI safe type that represents the owning reference to the
|
||||
// value. Dropping an Owned<T> will leak the value.
|
||||
//
|
||||
// An Owned<RawServoFoo> received from FFI can be converted into a `Box<Foo>`
|
||||
// by calling `into_box()`. To pass an Owned<RawServoFoo> back to Gecko, call
|
||||
// `HasBoxFFI::into_ffi()` passing in the `Box<Foo>` value.
|
||||
// A RawServoFooOwned received from FFI can be converted into a `Box<Foo>`
|
||||
// by calling `into_box()` or `into_box_opt()` on it. To pass a
|
||||
// RawServoFooOwned back to Gecko, call `HasBoxFFI::into_ffi()` passing in
|
||||
// the `Box<Foo>` value.
|
||||
//
|
||||
//
|
||||
// Reading through servo/components/style/gecko_bindings/sugar/ownership.rs
|
||||
// is also instructive in understanding all this.
|
||||
|
@ -105,11 +120,14 @@
|
|||
#include "mozilla/gfx/Types.h"
|
||||
#include "nsCSSPropertyID.h"
|
||||
#include "nsStyleAutoArray.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsTArray.h"
|
||||
|
||||
// Forward declarations.
|
||||
|
||||
#define SERVO_BOXED_TYPE(name_, type_) struct type_;
|
||||
#include "mozilla/ServoBoxedTypeList.h"
|
||||
#undef SERVO_BOXED_TYPE
|
||||
|
||||
#define SERVO_ARC_TYPE(name_, type_) struct type_;
|
||||
#include "mozilla/ServoArcTypeList.h"
|
||||
#undef SERVO_ARC_TYPE
|
||||
|
@ -140,10 +158,18 @@ class StyleChildrenIterator;
|
|||
class Document;
|
||||
class Element;
|
||||
} // namespace dom
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#define DECL_OWNED_REF_TYPE_FOR(type_) typedef type_* type_##Owned;
|
||||
|
||||
#define DECL_NULLABLE_OWNED_REF_TYPE_FOR(type_) \
|
||||
typedef type_* type_##OwnedOrNull;
|
||||
|
||||
#define SERVO_ARC_TYPE(name_, type_) \
|
||||
struct MOZ_MUST_USE_TYPE type_##Strong { \
|
||||
type_* mPtr; \
|
||||
already_AddRefed<type_> Consume(); \
|
||||
}; \
|
||||
extern "C" { \
|
||||
void Servo_##name_##_AddRef(const type_*); \
|
||||
void Servo_##name_##_Release(const type_*); \
|
||||
|
@ -156,38 +182,35 @@ class Element;
|
|||
}; \
|
||||
}
|
||||
#include "mozilla/ServoArcTypeList.h"
|
||||
SERVO_ARC_TYPE(ComputedStyle, mozilla::ComputedStyle)
|
||||
#undef SERVO_ARC_TYPE
|
||||
|
||||
// See the comment in ServoBindings.h about the same.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
|
||||
|
||||
#define SERVO_BOXED_TYPE(name_, type_) \
|
||||
struct type_; \
|
||||
extern "C" void Servo_##name_##_Drop(mozilla::StyleOwned<type_>); \
|
||||
namespace mozilla { \
|
||||
template <> \
|
||||
class DefaultDelete<type_> { \
|
||||
public: \
|
||||
void operator()(type_* aPtr) const { \
|
||||
Servo_##name_##_Drop(mozilla::StyleOwned<type_>{aPtr}); \
|
||||
} \
|
||||
}; \
|
||||
#define SERVO_BOXED_TYPE(name_, type_) \
|
||||
DECL_OWNED_REF_TYPE_FOR(type_) \
|
||||
DECL_NULLABLE_OWNED_REF_TYPE_FOR(type_) \
|
||||
extern "C" void Servo_##name_##_Drop(type_##Owned ptr); \
|
||||
namespace mozilla { \
|
||||
template <> \
|
||||
class DefaultDelete<type_> { \
|
||||
public: \
|
||||
void operator()(type_* aPtr) const { Servo_##name_##_Drop(aPtr); } \
|
||||
}; \
|
||||
}
|
||||
SERVO_BOXED_TYPE(StyleSet, RawServoStyleSet)
|
||||
SERVO_BOXED_TYPE(AuthorStyles, RawServoAuthorStyles)
|
||||
SERVO_BOXED_TYPE(SelectorList, RawServoSelectorList)
|
||||
SERVO_BOXED_TYPE(SourceSizeList, RawServoSourceSizeList)
|
||||
SERVO_BOXED_TYPE(UseCounters, StyleUseCounters)
|
||||
#include "mozilla/ServoBoxedTypeList.h"
|
||||
#undef SERVO_BOXED_TYPE
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// Other special cases.
|
||||
|
||||
// TODO(heycam): Handle these elsewhere.
|
||||
struct RawServoAnimationValueTable;
|
||||
struct RawServoAnimationValueMap;
|
||||
|
||||
struct MOZ_MUST_USE_TYPE ComputedStyleStrong {
|
||||
mozilla::ComputedStyle* mPtr;
|
||||
already_AddRefed<mozilla::ComputedStyle> Consume();
|
||||
};
|
||||
|
||||
#undef DECL_ARC_REF_TYPE_FOR
|
||||
#undef DECL_OWNED_REF_TYPE_FOR
|
||||
#undef DECL_NULLABLE_OWNED_REF_TYPE_FOR
|
||||
|
||||
#endif // mozilla_ServoBindingTypes_h
|
||||
|
|
|
@ -50,13 +50,6 @@ namespace nsStyleTransformMatrix {
|
|||
enum class MatrixTransformOperator : uint8_t;
|
||||
}
|
||||
|
||||
// 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.
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wreturn-type-c-linkage"
|
||||
|
||||
extern "C" {
|
||||
|
||||
// Element data
|
||||
|
@ -69,15 +62,14 @@ size_t Servo_Element_SizeOfExcludingThisAndCVs(
|
|||
|
||||
bool Servo_Element_HasPrimaryComputedValues(const mozilla::dom::Element* node);
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle>
|
||||
Servo_Element_GetPrimaryComputedValues(const mozilla::dom::Element* node);
|
||||
ComputedStyleStrong Servo_Element_GetPrimaryComputedValues(
|
||||
const mozilla::dom::Element* node);
|
||||
|
||||
bool Servo_Element_HasPseudoComputedValues(const mozilla::dom::Element* node,
|
||||
size_t index);
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle>
|
||||
Servo_Element_GetPseudoComputedValues(const mozilla::dom::Element* node,
|
||||
size_t index);
|
||||
ComputedStyleStrong Servo_Element_GetPseudoComputedValues(
|
||||
const mozilla::dom::Element* node, size_t index);
|
||||
|
||||
bool Servo_Element_IsDisplayNone(const mozilla::dom::Element* element);
|
||||
bool Servo_Element_IsDisplayContents(const mozilla::dom::Element* element);
|
||||
|
@ -92,7 +84,7 @@ void Servo_InvalidateStyleForDocStateChanges(
|
|||
|
||||
// Styleset and Stylesheet management
|
||||
|
||||
mozilla::StyleStrong<RawServoStyleSheetContents> Servo_StyleSheet_FromUTF8Bytes(
|
||||
RawServoStyleSheetContentsStrong Servo_StyleSheet_FromUTF8Bytes(
|
||||
mozilla::css::Loader* loader, mozilla::StyleSheet* gecko_stylesheet,
|
||||
mozilla::css::SheetLoadData* load_data, const nsACString* bytes,
|
||||
mozilla::css::SheetParsingMode parsing_mode,
|
||||
|
@ -107,15 +99,15 @@ void Servo_StyleSheet_FromUTF8BytesAsync(
|
|||
mozilla::css::SheetParsingMode parsing_mode, uint32_t line_number_offset,
|
||||
nsCompatibility quirks_mode, bool should_record_use_counters);
|
||||
|
||||
mozilla::StyleStrong<RawServoStyleSheetContents> Servo_StyleSheet_Empty(
|
||||
RawServoStyleSheetContentsStrong Servo_StyleSheet_Empty(
|
||||
mozilla::css::SheetParsingMode parsing_mode);
|
||||
|
||||
bool Servo_StyleSheet_HasRules(const RawServoStyleSheetContents* sheet);
|
||||
|
||||
mozilla::StyleStrong<ServoCssRules> Servo_StyleSheet_GetRules(
|
||||
ServoCssRulesStrong Servo_StyleSheet_GetRules(
|
||||
const RawServoStyleSheetContents* sheet);
|
||||
|
||||
mozilla::StyleStrong<RawServoStyleSheetContents> Servo_StyleSheet_Clone(
|
||||
RawServoStyleSheetContentsStrong Servo_StyleSheet_Clone(
|
||||
const RawServoStyleSheetContents* sheet,
|
||||
const mozilla::StyleSheet* reference_sheet);
|
||||
|
||||
|
@ -146,6 +138,7 @@ mozilla::MediumFeaturesChangedResult Servo_StyleSet_MediumFeaturesChanged(
|
|||
nsTArray<RawServoAuthorStyles*>* non_document_sets,
|
||||
bool may_affect_default_style);
|
||||
|
||||
void Servo_StyleSet_Drop(RawServoStyleSetOwned set);
|
||||
void Servo_StyleSet_CompatModeChanged(const RawServoStyleSet* raw_data);
|
||||
|
||||
void Servo_StyleSet_AppendStyleSheet(const RawServoStyleSet* set,
|
||||
|
@ -185,19 +178,19 @@ const RawServoCounterStyleRule* Servo_StyleSet_GetCounterStyleRule(
|
|||
gfxFontFeatureValueSet* Servo_StyleSet_BuildFontFeatureValueSet(
|
||||
const RawServoStyleSet* set);
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle>
|
||||
Servo_StyleSet_ResolveForDeclarations(
|
||||
ComputedStyleStrong Servo_StyleSet_ResolveForDeclarations(
|
||||
const RawServoStyleSet* set, const mozilla::ComputedStyle* parent_style,
|
||||
const RawServoDeclarationBlock* declarations);
|
||||
|
||||
mozilla::StyleOwnedOrNull<RawServoSelectorList> Servo_SelectorList_Parse(
|
||||
const nsACString* selector_list);
|
||||
mozilla::StyleOwned<RawServoSourceSizeList> Servo_SourceSizeList_Parse(
|
||||
const nsACString* value);
|
||||
void Servo_SelectorList_Drop(RawServoSelectorList*);
|
||||
RawServoSelectorList* Servo_SelectorList_Parse(const nsACString* selector_list);
|
||||
RawServoSourceSizeList* Servo_SourceSizeList_Parse(const nsACString* value);
|
||||
|
||||
int32_t Servo_SourceSizeList_Evaluate(const RawServoStyleSet* set,
|
||||
const RawServoSourceSizeList*);
|
||||
|
||||
void Servo_SourceSizeList_Drop(RawServoSourceSizeList*);
|
||||
|
||||
bool Servo_SelectorList_Matches(const mozilla::dom::Element*,
|
||||
const RawServoSelectorList*);
|
||||
|
||||
|
@ -222,7 +215,8 @@ void Servo_UACache_AddSizeOf(mozilla::MallocSizeOf malloc_size_of,
|
|||
|
||||
// AuthorStyles
|
||||
|
||||
mozilla::StyleOwned<RawServoAuthorStyles> Servo_AuthorStyles_Create();
|
||||
RawServoAuthorStyles* Servo_AuthorStyles_Create();
|
||||
void Servo_AuthorStyles_Drop(RawServoAuthorStyles*);
|
||||
|
||||
void Servo_AuthorStyles_AppendStyleSheet(RawServoAuthorStyles*,
|
||||
const mozilla::StyleSheet*);
|
||||
|
@ -246,6 +240,10 @@ size_t Servo_AuthorStyles_SizeOfIncludingThis(
|
|||
mozilla::MallocSizeOf malloc_enclosing_size_of,
|
||||
const RawServoAuthorStyles* self);
|
||||
|
||||
void Servo_ComputedStyle_AddRef(const mozilla::ComputedStyle* ctx);
|
||||
|
||||
void Servo_ComputedStyle_Release(const mozilla::ComputedStyle* ctx);
|
||||
|
||||
bool Servo_StyleSet_MightHaveAttributeDependency(
|
||||
const RawServoStyleSet* set, const mozilla::dom::Element* element,
|
||||
nsAtom* local_name);
|
||||
|
@ -277,16 +275,15 @@ nsresult Servo_CssRules_DeleteRule(const ServoCssRules* rules, uint32_t index);
|
|||
void Servo_##type_##_Debug(const RawServo##type_*, nsACString* result); \
|
||||
void Servo_##type_##_GetCssText(const RawServo##type_*, nsAString* result);
|
||||
|
||||
#define BASIC_RULE_FUNCS(type_) \
|
||||
mozilla::StyleStrong<RawServo##type_##Rule> \
|
||||
Servo_CssRules_Get##type_##RuleAt(const ServoCssRules* rules, \
|
||||
uint32_t index, uint32_t* line, \
|
||||
uint32_t* column); \
|
||||
#define BASIC_RULE_FUNCS(type_) \
|
||||
RawServo##type_##RuleStrong Servo_CssRules_Get##type_##RuleAt( \
|
||||
const ServoCssRules* rules, uint32_t index, uint32_t* line, \
|
||||
uint32_t* column); \
|
||||
BASIC_RULE_FUNCS_WITHOUT_GETTER(type_##Rule)
|
||||
|
||||
#define GROUP_RULE_FUNCS(type_) \
|
||||
BASIC_RULE_FUNCS(type_) \
|
||||
mozilla::StyleStrong<ServoCssRules> Servo_##type_##Rule_GetRules( \
|
||||
#define GROUP_RULE_FUNCS(type_) \
|
||||
BASIC_RULE_FUNCS(type_) \
|
||||
ServoCssRulesStrong Servo_##type_##Rule_GetRules( \
|
||||
const RawServo##type_##Rule* rule);
|
||||
|
||||
BASIC_RULE_FUNCS(Style)
|
||||
|
@ -308,7 +305,7 @@ BASIC_RULE_FUNCS(CounterStyle)
|
|||
|
||||
using Matrix4x4Components = float[16];
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_StyleRule_GetStyle(
|
||||
RawServoDeclarationBlockStrong Servo_StyleRule_GetStyle(
|
||||
const RawServoStyleRule*);
|
||||
|
||||
void Servo_StyleRule_SetStyle(const RawServoStyleRule* rule,
|
||||
|
@ -351,7 +348,7 @@ void Servo_Keyframe_GetKeyText(const RawServoKeyframe* keyframe,
|
|||
bool Servo_Keyframe_SetKeyText(const RawServoKeyframe* keyframe,
|
||||
const nsACString* text);
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_Keyframe_GetStyle(
|
||||
RawServoDeclarationBlockStrong Servo_Keyframe_GetStyle(
|
||||
const RawServoKeyframe* keyframe);
|
||||
|
||||
void Servo_Keyframe_SetStyle(const RawServoKeyframe* keyframe,
|
||||
|
@ -365,7 +362,7 @@ void Servo_KeyframesRule_SetName(const RawServoKeyframesRule* rule,
|
|||
|
||||
uint32_t Servo_KeyframesRule_GetCount(const RawServoKeyframesRule* rule);
|
||||
|
||||
mozilla::StyleStrong<RawServoKeyframe> Servo_KeyframesRule_GetKeyframeAt(
|
||||
RawServoKeyframeStrong Servo_KeyframesRule_GetKeyframeAt(
|
||||
const RawServoKeyframesRule* rule, uint32_t index, uint32_t* line,
|
||||
uint32_t* column);
|
||||
|
||||
|
@ -381,13 +378,12 @@ bool Servo_KeyframesRule_AppendRule(const RawServoKeyframesRule* rule,
|
|||
void Servo_KeyframesRule_DeleteRule(const RawServoKeyframesRule* rule,
|
||||
uint32_t index);
|
||||
|
||||
mozilla::StyleStrong<RawServoMediaList> Servo_MediaRule_GetMedia(
|
||||
const RawServoMediaRule* rule);
|
||||
RawServoMediaListStrong Servo_MediaRule_GetMedia(const RawServoMediaRule* rule);
|
||||
|
||||
nsAtom* Servo_NamespaceRule_GetPrefix(const RawServoNamespaceRule* rule);
|
||||
nsAtom* Servo_NamespaceRule_GetURI(const RawServoNamespaceRule* rule);
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_PageRule_GetStyle(
|
||||
RawServoDeclarationBlockStrong Servo_PageRule_GetStyle(
|
||||
const RawServoPageRule* rule);
|
||||
|
||||
void Servo_PageRule_SetStyle(const RawServoPageRule* rule,
|
||||
|
@ -405,9 +401,9 @@ void Servo_FontFeatureValuesRule_GetFontFamily(
|
|||
void Servo_FontFeatureValuesRule_GetValueText(
|
||||
const RawServoFontFeatureValuesRule* rule, nsAString* result);
|
||||
|
||||
mozilla::StyleStrong<RawServoFontFaceRule> Servo_FontFaceRule_CreateEmpty();
|
||||
RawServoFontFaceRuleStrong Servo_FontFaceRule_CreateEmpty();
|
||||
|
||||
mozilla::StyleStrong<RawServoFontFaceRule> Servo_FontFaceRule_Clone(
|
||||
RawServoFontFaceRuleStrong Servo_FontFaceRule_Clone(
|
||||
const RawServoFontFaceRule* rule);
|
||||
|
||||
void Servo_FontFaceRule_GetSourceLocation(const RawServoFontFaceRule* rule,
|
||||
|
@ -500,7 +496,7 @@ bool Servo_CounterStyleRule_SetDescriptor(const RawServoCounterStyleRule* rule,
|
|||
|
||||
// Animations API
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_ParseProperty(
|
||||
RawServoDeclarationBlockStrong Servo_ParseProperty(
|
||||
nsCSSPropertyID property, const nsACString* value,
|
||||
mozilla::URLExtraData* data, mozilla::ParsingMode parsing_mode,
|
||||
nsCompatibility quirks_mode, mozilla::css::Loader* loader);
|
||||
|
@ -518,8 +514,7 @@ void Servo_GetComputedKeyframeValues(
|
|||
const RawServoStyleSet* set,
|
||||
nsTArray<mozilla::ComputedKeyframeValues>* result);
|
||||
|
||||
mozilla::StyleStrong<RawServoAnimationValue>
|
||||
Servo_ComputedValues_ExtractAnimationValue(
|
||||
RawServoAnimationValueStrong Servo_ComputedValues_ExtractAnimationValue(
|
||||
const mozilla::ComputedStyle* computed_values, nsCSSPropertyID property);
|
||||
|
||||
bool Servo_ComputedValues_SpecifiesAnimationsOrTransitions(
|
||||
|
@ -546,21 +541,21 @@ void Servo_GetAnimationValues(
|
|||
|
||||
// AnimationValues handling
|
||||
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_Interpolate(
|
||||
RawServoAnimationValueStrong Servo_AnimationValues_Interpolate(
|
||||
const RawServoAnimationValue* from, const RawServoAnimationValue* to,
|
||||
double progress);
|
||||
|
||||
bool Servo_AnimationValues_IsInterpolable(const RawServoAnimationValue* from,
|
||||
const RawServoAnimationValue* to);
|
||||
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_Add(
|
||||
RawServoAnimationValueStrong Servo_AnimationValues_Add(
|
||||
const RawServoAnimationValue* a, const RawServoAnimationValue* b);
|
||||
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_Accumulate(
|
||||
RawServoAnimationValueStrong Servo_AnimationValues_Accumulate(
|
||||
const RawServoAnimationValue* a, const RawServoAnimationValue* b,
|
||||
uint64_t count);
|
||||
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValues_GetZeroValue(
|
||||
RawServoAnimationValueStrong Servo_AnimationValues_GetZeroValue(
|
||||
const RawServoAnimationValue* value_to_match);
|
||||
|
||||
double Servo_AnimationValues_ComputeDistance(const RawServoAnimationValue* from,
|
||||
|
@ -572,40 +567,38 @@ void Servo_AnimationValue_Serialize(const RawServoAnimationValue* value,
|
|||
|
||||
nscolor Servo_AnimationValue_GetColor(const RawServoAnimationValue* value,
|
||||
nscolor foregroundColor);
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Color(
|
||||
nsCSSPropertyID, nscolor);
|
||||
RawServoAnimationValueStrong Servo_AnimationValue_Color(nsCSSPropertyID,
|
||||
nscolor);
|
||||
|
||||
float Servo_AnimationValue_GetOpacity(const RawServoAnimationValue* value);
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Opacity(
|
||||
float);
|
||||
RawServoAnimationValueStrong Servo_AnimationValue_Opacity(float);
|
||||
|
||||
nsCSSPropertyID Servo_AnimationValue_GetTransform(
|
||||
const RawServoAnimationValue* value, RefPtr<nsCSSValueSharedList>* list);
|
||||
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Transform(
|
||||
RawServoAnimationValueStrong Servo_AnimationValue_Transform(
|
||||
nsCSSPropertyID property, const nsCSSValueSharedList& list);
|
||||
|
||||
bool Servo_AnimationValue_DeepEqual(const RawServoAnimationValue*,
|
||||
const RawServoAnimationValue*);
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_AnimationValue_Uncompute(
|
||||
RawServoDeclarationBlockStrong Servo_AnimationValue_Uncompute(
|
||||
const RawServoAnimationValue* value);
|
||||
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_AnimationValue_Compute(
|
||||
RawServoAnimationValueStrong Servo_AnimationValue_Compute(
|
||||
const mozilla::dom::Element* element,
|
||||
const RawServoDeclarationBlock* declarations,
|
||||
const mozilla::ComputedStyle* style, const RawServoStyleSet* raw_data);
|
||||
|
||||
// Style attribute
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_ParseStyleAttribute(
|
||||
RawServoDeclarationBlockStrong Servo_ParseStyleAttribute(
|
||||
const nsACString* data, mozilla::URLExtraData* extra_data,
|
||||
nsCompatibility quirks_mode, mozilla::css::Loader* loader);
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock>
|
||||
Servo_DeclarationBlock_CreateEmpty();
|
||||
RawServoDeclarationBlockStrong Servo_DeclarationBlock_CreateEmpty();
|
||||
|
||||
mozilla::StyleStrong<RawServoDeclarationBlock> Servo_DeclarationBlock_Clone(
|
||||
RawServoDeclarationBlockStrong Servo_DeclarationBlock_Clone(
|
||||
const RawServoDeclarationBlock* declarations);
|
||||
|
||||
bool Servo_DeclarationBlock_Equals(const RawServoDeclarationBlock* a,
|
||||
|
@ -683,7 +676,7 @@ void Servo_AnimationCompose(
|
|||
// segment endpoints and the supplied iteration composite mode.
|
||||
// The caller is responsible for providing an underlying value and
|
||||
// last value in all situations where there are needed.
|
||||
mozilla::StyleStrong<RawServoAnimationValue> Servo_ComposeAnimationSegment(
|
||||
RawServoAnimationValueStrong Servo_ComposeAnimationSegment(
|
||||
const mozilla::AnimationPropertySegment* animation_segment,
|
||||
const RawServoAnimationValue* underlying_value,
|
||||
const RawServoAnimationValue* last_value,
|
||||
|
@ -754,9 +747,9 @@ void Servo_DeclarationBlock_SetBackgroundImage(
|
|||
|
||||
// MediaList
|
||||
|
||||
mozilla::StyleStrong<RawServoMediaList> Servo_MediaList_Create();
|
||||
RawServoMediaListStrong Servo_MediaList_Create();
|
||||
|
||||
mozilla::StyleStrong<RawServoMediaList> Servo_MediaList_DeepClone(
|
||||
RawServoMediaListStrong Servo_MediaList_DeepClone(
|
||||
const RawServoMediaList* list);
|
||||
|
||||
bool Servo_MediaList_Matches(const RawServoMediaList* list,
|
||||
|
@ -791,12 +784,11 @@ bool Servo_CSSSupports(const nsACString* cond);
|
|||
|
||||
// Computed style data
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle>
|
||||
Servo_ComputedValues_GetForAnonymousBox(
|
||||
ComputedStyleStrong Servo_ComputedValues_GetForAnonymousBox(
|
||||
const mozilla::ComputedStyle* parent_style_or_null,
|
||||
mozilla::PseudoStyleType, const RawServoStyleSet* set);
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ComputedValues_Inherit(
|
||||
ComputedStyleStrong Servo_ComputedValues_Inherit(
|
||||
const RawServoStyleSet*, mozilla::PseudoStyleType,
|
||||
const mozilla::ComputedStyle* parent_style, mozilla::InheritTarget);
|
||||
|
||||
|
@ -826,16 +818,15 @@ void Servo_NoteExplicitHints(const mozilla::dom::Element*, mozilla::RestyleHint,
|
|||
uint32_t Servo_TakeChangeHint(const mozilla::dom::Element* element,
|
||||
bool* was_restyled);
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ResolveStyle(
|
||||
const mozilla::dom::Element* element, const RawServoStyleSet* set);
|
||||
ComputedStyleStrong Servo_ResolveStyle(const mozilla::dom::Element* element,
|
||||
const RawServoStyleSet* set);
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ResolvePseudoStyle(
|
||||
ComputedStyleStrong Servo_ResolvePseudoStyle(
|
||||
const mozilla::dom::Element* element, mozilla::PseudoStyleType pseudo_type,
|
||||
bool is_probe, const mozilla::ComputedStyle* inherited_style,
|
||||
const RawServoStyleSet* set);
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle>
|
||||
Servo_ComputedValues_ResolveXULTreePseudoStyle(
|
||||
ComputedStyleStrong Servo_ComputedValues_ResolveXULTreePseudoStyle(
|
||||
const mozilla::dom::Element* element, nsAtom* pseudo_tag,
|
||||
const mozilla::ComputedStyle* inherited_style,
|
||||
const mozilla::AtomArray* input_word, const RawServoStyleSet* set);
|
||||
|
@ -857,14 +848,14 @@ bool Servo_HasAuthorSpecifiedRules(const RawServoStyleSet* set,
|
|||
// The tree must be in a consistent state such that a normal traversal could be
|
||||
// performed, and this function maintains that invariant.
|
||||
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ResolveStyleLazily(
|
||||
ComputedStyleStrong Servo_ResolveStyleLazily(
|
||||
const mozilla::dom::Element* element, mozilla::PseudoStyleType pseudo_type,
|
||||
mozilla::StyleRuleInclusion rule_inclusion,
|
||||
const mozilla::ServoElementSnapshotTable* snapshots,
|
||||
const RawServoStyleSet* set);
|
||||
|
||||
// Reparents style to the new parents.
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle> Servo_ReparentStyle(
|
||||
ComputedStyleStrong Servo_ReparentStyle(
|
||||
const mozilla::ComputedStyle* style_to_reparent,
|
||||
const mozilla::ComputedStyle* parent_style,
|
||||
const mozilla::ComputedStyle* parent_style_ignoring_first_line,
|
||||
|
@ -891,15 +882,13 @@ bool Servo_IsWorkerThread();
|
|||
void Servo_MaybeGCRuleTree(const RawServoStyleSet* set);
|
||||
|
||||
// Returns computed values for the given element without any animations rules.
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle>
|
||||
Servo_StyleSet_GetBaseComputedValuesForElement(
|
||||
ComputedStyleStrong Servo_StyleSet_GetBaseComputedValuesForElement(
|
||||
const RawServoStyleSet* set, const mozilla::dom::Element* element,
|
||||
const mozilla::ComputedStyle* existing_style,
|
||||
const mozilla::ServoElementSnapshotTable* snapshots);
|
||||
|
||||
// Returns computed values for the given element by adding an animation value.
|
||||
mozilla::StyleStrong<mozilla::ComputedStyle>
|
||||
Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
||||
ComputedStyleStrong Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
||||
const RawServoStyleSet* set, const mozilla::dom::Element* element,
|
||||
const mozilla::ComputedStyle* existing_style,
|
||||
const mozilla::ServoElementSnapshotTable* snapshots,
|
||||
|
@ -983,7 +972,8 @@ void Servo_Property_GetCSSValuesForProperty(const nsACString* name, bool* found,
|
|||
|
||||
uint64_t Servo_PseudoClass_GetStates(const nsACString* name);
|
||||
|
||||
mozilla::StyleOwned<StyleUseCounters> Servo_UseCounters_Create();
|
||||
StyleUseCounters* Servo_UseCounters_Create();
|
||||
void Servo_UseCounters_Drop(StyleUseCountersOwned);
|
||||
|
||||
void Servo_UseCounters_Merge(const StyleUseCounters* doc_counters,
|
||||
const StyleUseCounters* sheet_counters);
|
||||
|
@ -992,15 +982,20 @@ bool Servo_IsCssPropertyRecordedInUseCounter(const StyleUseCounters*,
|
|||
const nsACString* property,
|
||||
bool* out_known_prop);
|
||||
|
||||
mozilla::StyleStrong<RawServoQuotes> Servo_Quotes_GetInitialValue();
|
||||
RawServoQuotesStrong Servo_Quotes_GetInitialValue();
|
||||
bool Servo_Quotes_Equal(const RawServoQuotes* a, RawServoQuotes* b);
|
||||
|
||||
void Servo_Quotes_GetQuote(const RawServoQuotes* quotes, int32_t depth,
|
||||
mozilla::StyleContentType quote_type,
|
||||
nsAString* result);
|
||||
|
||||
// AddRef / Release functions
|
||||
#define SERVO_ARC_TYPE(name_, type_) \
|
||||
void Servo_##name_##_AddRef(const type_*); \
|
||||
void Servo_##name_##_Release(const type_*);
|
||||
#include "mozilla/ServoArcTypeList.h"
|
||||
#undef SERVO_ARC_TYPE
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#endif // mozilla_ServoBindings_h
|
||||
|
|
|
@ -26,7 +26,6 @@ headers = [
|
|||
"mozilla/LookAndFeel.h",
|
||||
"mozilla/StaticPrefs.h",
|
||||
"mozilla/GeckoBindings.h",
|
||||
"mozilla/ServoBindings.h",
|
||||
"mozilla/ComputedStyle.h",
|
||||
"mozilla/ServoTraversalStatistics.h",
|
||||
"mozilla/SizeOfState.h",
|
||||
|
@ -47,6 +46,7 @@ raw-lines = [
|
|||
"use data::ElementData;",
|
||||
]
|
||||
hide-types = [
|
||||
"nsString",
|
||||
".*char_traits",
|
||||
".*incompatible_char_type",
|
||||
# https://github.com/rust-lang/rust-bindgen/issues/1503
|
||||
|
@ -454,9 +454,6 @@ cbindgen-types = [
|
|||
{ gecko = "StyleWillChangeBits", servo = "values::specified::box_::WillChangeBits" },
|
||||
{ gecko = "StyleTextDecorationLine", servo = "values::computed::TextDecorationLine" },
|
||||
{ gecko = "StyleMozListReversed", servo = "values::computed::MozListReversed" },
|
||||
{ gecko = "StyleOwned", servo = "gecko_bindings::sugar::ownership::Owned" },
|
||||
{ gecko = "StyleOwnedOrNull", servo = "gecko_bindings::sugar::ownership::OwnedOrNull" },
|
||||
{ gecko = "StyleStrong", servo = "gecko_bindings::sugar::ownership::Strong" },
|
||||
]
|
||||
|
||||
mapped-generic-types = [
|
||||
|
@ -468,14 +465,36 @@ mapped-generic-types = [
|
|||
{ generic = false, gecko = "mozilla::ServoVisitedStyle", servo = "Option<::servo_arc::RawOffsetArc<::properties::ComputedValues>>" },
|
||||
{ generic = false, gecko = "mozilla::ServoComputedValueFlags", servo = "::properties::computed_value_flags::ComputedValueFlags" },
|
||||
{ generic = true, gecko = "mozilla::ServoRawOffsetArc", servo = "::servo_arc::RawOffsetArc" },
|
||||
{ generic = false, gecko = "nsACString", servo = "nsstring::nsACString" },
|
||||
{ generic = false, gecko = "nsAString", servo = "nsstring::nsAString" },
|
||||
{ generic = false, gecko = "nsCString", servo = "nsstring::nsCString" },
|
||||
{ generic = false, gecko = "nsString", servo = "nsstring::nsStringRepr" },
|
||||
{ generic = false, gecko = "ComputedStyleStrong", servo = "::gecko_bindings::sugar::ownership::Strong<::properties::ComputedValues>" },
|
||||
]
|
||||
|
||||
whitelist-functions = ["Servo_.*", "Gecko_.*"]
|
||||
|
||||
fixups = [
|
||||
{ pat = "\\broot\\s*::\\s*nsString\\b", rep = "::nsstring::nsStringRepr" },
|
||||
{ pat = "\\broot\\s*::\\s*nsTString\\s*<\\s*u16\\s*>", rep = "::nsstring::nsStringRepr" },
|
||||
]
|
||||
|
||||
[bindings]
|
||||
headers = [
|
||||
"mozilla/GeckoBindings.h",
|
||||
# We include ServoBindings.h so we can type check the C function declarations
|
||||
# in there against the function definitions in servo/ports/gecko/glue.rs.
|
||||
"mozilla/ServoBindings.h",
|
||||
]
|
||||
hide-types = [
|
||||
"nsACString_internal",
|
||||
"nsAString_internal",
|
||||
]
|
||||
raw-lines = [
|
||||
"pub use nsstring::{nsACString, nsAString, nsCString, nsString, nsStringRepr};",
|
||||
"use gecko_bindings::structs::*;",
|
||||
"use gecko_bindings::structs::mozilla::gfx::*;",
|
||||
"use gecko_bindings::structs::nsStyleTransformMatrix::*;",
|
||||
"type nsACString_internal = nsACString;",
|
||||
"type nsAString_internal = nsAString;",
|
||||
]
|
||||
whitelist-functions = ["Servo_.*", "Gecko_.*"]
|
||||
fixups = [
|
||||
# Remap the templated string type to the helper type
|
||||
{ pat = "\\bnsTString\\s*<\\s*u16\\s*>", rep = "nsString" },
|
||||
# hack for gecko-owned string
|
||||
{ pat = "<\\s*nsString\\s*", rep = "<nsStringRepr" },
|
||||
]
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
/* a list of all Servo Box<T> types used across bindings, for preprocessing */
|
||||
|
||||
// The first argument is the name of the Servo type used inside the Box.
|
||||
// This doesn't need to be accurate; it's only used to generate nice looking
|
||||
// FFI function names.
|
||||
//
|
||||
// The second argument is the name of an opaque Gecko type that will
|
||||
// correspond to the Servo type used inside the Box. The convention for the
|
||||
// the name of the opaque Gecko type is "RawServo{Type}", where {Type} is
|
||||
// the name of the Servo type or something close to it.
|
||||
//
|
||||
// See the comment at the top of ServoBindingTypes.h for how to use these.
|
||||
//
|
||||
// If you add an entry to this file, you should also add impls of HasFFI
|
||||
// (with FFIType equal to ::gecko_bindings::structs::RawServo{Type}),
|
||||
// HasSimpleFFI, and HasBoxFFI to the Servo type. You will also need to
|
||||
// add a Servo_{FriendlyServoName}_Drop function to servo/ports/gecko/glue.rs.
|
||||
//
|
||||
// TODO(heycam): Do some of this automatically.
|
||||
|
||||
// clang-format off
|
||||
// Needs to be a on single line
|
||||
SERVO_BOXED_TYPE(StyleSet, RawServoStyleSet)
|
||||
SERVO_BOXED_TYPE(AuthorStyles, RawServoAuthorStyles)
|
||||
SERVO_BOXED_TYPE(SelectorList, RawServoSelectorList)
|
||||
SERVO_BOXED_TYPE(SourceSizeList, RawServoSourceSizeList)
|
||||
SERVO_BOXED_TYPE(UseCounters, StyleUseCounters)
|
||||
// clang-format on
|
|
@ -93,6 +93,7 @@ EXPORTS.mozilla += [
|
|||
'ServoArcTypeList.h',
|
||||
'ServoBindings.h',
|
||||
'ServoBindingTypes.h',
|
||||
'ServoBoxedTypeList.h',
|
||||
'ServoComputedData.h',
|
||||
'ServoComputedDataInlines.h',
|
||||
'ServoCSSParser.h',
|
||||
|
|
|
@ -85,7 +85,7 @@ MOZ_GTEST_BENCH(Stylo, Servo_StyleSheet_FromUTF8Bytes_Bench,
|
|||
[] { ServoParsingBench(nullptr); });
|
||||
|
||||
MOZ_GTEST_BENCH(Stylo, Servo_StyleSheet_FromUTF8Bytes_Bench_UseCounters, [] {
|
||||
UniquePtr<StyleUseCounters> counters = Servo_UseCounters_Create().Consume();
|
||||
UniquePtr<StyleUseCounters> counters(Servo_UseCounters_Create());
|
||||
ServoParsingBench(counters.get());
|
||||
});
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ mod bindings {
|
|||
use toml::value::Table;
|
||||
|
||||
const STRUCTS_FILE: &'static str = "structs.rs";
|
||||
const BINDINGS_FILE: &'static str = "bindings.rs";
|
||||
|
||||
fn read_config(path: &PathBuf) -> Table {
|
||||
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
|
||||
|
@ -219,6 +220,51 @@ mod bindings {
|
|||
.expect("Unable to write output");
|
||||
}
|
||||
|
||||
fn get_types(filename: &str, macro_pat: &str) -> Vec<(String, String)> {
|
||||
// Read the file
|
||||
let path = DISTDIR_PATH.join("include/mozilla/").join(filename);
|
||||
let mut list_file = File::open(path).expect(&format!("Unable to open {}", filename));
|
||||
let mut content = String::new();
|
||||
list_file
|
||||
.read_to_string(&mut content)
|
||||
.expect(&format!("Failed to read {}", filename));
|
||||
// Remove comments
|
||||
let block_comment_re = Regex::new(r#"(?s)/\*.*?\*/"#).unwrap();
|
||||
let line_comment_re = Regex::new(r#"//.*"#).unwrap();
|
||||
let content = block_comment_re.replace_all(&content, "");
|
||||
let content = line_comment_re.replace_all(&content, "");
|
||||
// Extract the list
|
||||
let re_string = format!(r#"^({})\(.+,\s*(\w+)\)$"#, macro_pat);
|
||||
let re = Regex::new(&re_string).unwrap();
|
||||
content
|
||||
.lines()
|
||||
.map(|line| line.trim())
|
||||
.filter(|line| !line.is_empty())
|
||||
.map(|line| {
|
||||
let captures = re
|
||||
.captures(&line)
|
||||
.expect(&format!("Unrecognized line in {}: '{}'", filename, line));
|
||||
let macro_name = captures.get(1).unwrap().as_str().to_string();
|
||||
let type_name = captures.get(2).unwrap().as_str().to_string();
|
||||
(macro_name, type_name)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_arc_types() -> Vec<String> {
|
||||
get_types("ServoArcTypeList.h", "SERVO_ARC_TYPE")
|
||||
.into_iter()
|
||||
.map(|(_, type_name)| type_name)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_boxed_types() -> Vec<String> {
|
||||
get_types("ServoBoxedTypeList.h", "SERVO_BOXED_TYPE")
|
||||
.into_iter()
|
||||
.map(|(_, type_name)| type_name)
|
||||
.collect()
|
||||
}
|
||||
|
||||
struct BuilderWithConfig<'a> {
|
||||
builder: Builder,
|
||||
config: &'a Table,
|
||||
|
@ -294,11 +340,10 @@ mod bindings {
|
|||
fn generate_structs() {
|
||||
let builder = Builder::get_initial_builder()
|
||||
.enable_cxx_namespaces()
|
||||
.with_codegen_config(CodegenConfig::TYPES | CodegenConfig::VARS | CodegenConfig::FUNCTIONS);
|
||||
.with_codegen_config(CodegenConfig::TYPES | CodegenConfig::VARS);
|
||||
let mut fixups = vec![];
|
||||
let builder = BuilderWithConfig::new(builder, CONFIG["structs"].as_table().unwrap())
|
||||
.handle_common(&mut fixups)
|
||||
.handle_str_items("whitelist-functions", |b, item| b.whitelist_function(item))
|
||||
.handle_str_items("bitfield-enums", |b, item| b.bitfield_enum(item))
|
||||
.handle_str_items("rusty-enums", |b, item| b.rustified_enum(item))
|
||||
.handle_str_items("whitelist-vars", |b, item| b.whitelist_var(item))
|
||||
|
@ -389,6 +434,44 @@ mod bindings {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME(emilio): Avoid this altogether.
|
||||
fn generate_bindings() {
|
||||
let builder = Builder::get_initial_builder()
|
||||
.disable_name_namespacing()
|
||||
.with_codegen_config(CodegenConfig::FUNCTIONS);
|
||||
let config = CONFIG["bindings"].as_table().unwrap();
|
||||
let mut fixups = vec![];
|
||||
let mut builder = BuilderWithConfig::new(builder, config)
|
||||
.handle_common(&mut fixups)
|
||||
.handle_str_items("whitelist-functions", |b, item| b.whitelist_function(item))
|
||||
.get_builder();
|
||||
for ty in get_arc_types().iter() {
|
||||
builder = builder
|
||||
.blacklist_type(format!("{}Strong", ty))
|
||||
.raw_line(format!(
|
||||
"pub type {0}Strong = ::gecko_bindings::sugar::ownership::Strong<{0}>;",
|
||||
ty
|
||||
));
|
||||
}
|
||||
for ty in get_boxed_types().iter() {
|
||||
builder = builder
|
||||
.blacklist_type(format!("{}Owned", ty))
|
||||
.raw_line(format!(
|
||||
"pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;",
|
||||
ty
|
||||
))
|
||||
.blacklist_type(format!("{}OwnedOrNull", ty))
|
||||
.raw_line(format!(
|
||||
concat!(
|
||||
"pub type {0}OwnedOrNull = ",
|
||||
"::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;"
|
||||
),
|
||||
ty
|
||||
));
|
||||
}
|
||||
write_binding_file(builder, BINDINGS_FILE, &fixups);
|
||||
}
|
||||
|
||||
fn generate_atoms() {
|
||||
let script = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap())
|
||||
.join("gecko")
|
||||
|
@ -406,9 +489,24 @@ mod bindings {
|
|||
}
|
||||
|
||||
pub fn generate() {
|
||||
setup_logging();
|
||||
generate_structs();
|
||||
generate_atoms();
|
||||
use std::thread;
|
||||
macro_rules! run_tasks {
|
||||
($($task:expr,)+) => {
|
||||
if setup_logging() {
|
||||
$($task;)+
|
||||
} else {
|
||||
let threads = vec![$( thread::spawn(|| $task) ),+];
|
||||
for thread in threads.into_iter() {
|
||||
thread.join().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
run_tasks! {
|
||||
generate_structs(),
|
||||
generate_bindings(),
|
||||
generate_atoms(),
|
||||
}
|
||||
|
||||
for path in ADDED_PATHS.lock().unwrap().iter() {
|
||||
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
|
||||
|
|
|
@ -109,9 +109,6 @@ include = [
|
|||
"WillChangeBits",
|
||||
"TextDecorationLine",
|
||||
"MozListReversed",
|
||||
"Owned",
|
||||
"OwnedOrNull",
|
||||
"Strong",
|
||||
]
|
||||
item_types = ["enums", "structs", "typedefs"]
|
||||
|
||||
|
@ -211,29 +208,3 @@ item_types = ["enums", "structs", "typedefs"]
|
|||
static inline StyleRestyleHint RecascadeSubtree();
|
||||
static inline StyleRestyleHint ForAnimations();
|
||||
"""
|
||||
|
||||
# TODO(emilio): Add hooks to cbindgen to be able to generate MOZ_MUST_USE_TYPE
|
||||
# or MOZ_MUST_USE on the functions.
|
||||
"Owned" = """
|
||||
UniquePtr<GeckoType> Consume() {
|
||||
UniquePtr<GeckoType> ret(ptr);
|
||||
ptr = nullptr;
|
||||
return ret;
|
||||
}
|
||||
"""
|
||||
|
||||
"OwnedOrNull" = """
|
||||
UniquePtr<GeckoType> Consume() {
|
||||
UniquePtr<GeckoType> ret(ptr);
|
||||
ptr = nullptr;
|
||||
return ret;
|
||||
}
|
||||
"""
|
||||
|
||||
"Strong" = """
|
||||
already_AddRefed<GeckoType> Consume() {
|
||||
already_AddRefed<GeckoType> ret(const_cast<GeckoType*>(ptr));
|
||||
ptr = nullptr;
|
||||
return ret;
|
||||
}
|
||||
"""
|
||||
|
|
|
@ -18,6 +18,8 @@ use crate::gecko_bindings::structs::RawServoMediaRule;
|
|||
use crate::gecko_bindings::structs::RawServoMozDocumentRule;
|
||||
use crate::gecko_bindings::structs::RawServoNamespaceRule;
|
||||
use crate::gecko_bindings::structs::RawServoPageRule;
|
||||
use crate::gecko_bindings::structs::RawServoRuleNode;
|
||||
use crate::gecko_bindings::structs::RawServoRuleNodeStrong;
|
||||
use crate::gecko_bindings::structs::RawServoSupportsRule;
|
||||
use crate::gecko_bindings::structs::ServoCssRules;
|
||||
use crate::gecko_bindings::structs::RawServoAnimationValue;
|
||||
|
@ -32,6 +34,7 @@ use crate::gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI, Strong};
|
|||
use crate::media_queries::MediaList;
|
||||
use crate::properties::animated_properties::AnimationValue;
|
||||
use crate::properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
use crate::rule_tree::StrongRuleNode;
|
||||
use crate::shared_lock::Locked;
|
||||
use crate::stylesheets::keyframes_rule::Keyframe;
|
||||
use crate::stylesheets::{CounterStyleRule, CssRules, FontFaceRule, FontFeatureValuesRule};
|
||||
|
@ -118,6 +121,31 @@ impl_arc_ffi!(CssUrlData => RawServoCssUrlData
|
|||
impl_arc_ffi!(Box<[QuotePair]> => RawServoQuotes
|
||||
[Servo_Quotes_AddRef, Servo_Quotes_Release]);
|
||||
|
||||
// RuleNode is a Arc-like type but it does not use Arc.
|
||||
|
||||
impl StrongRuleNode {
|
||||
pub fn into_strong(self) -> RawServoRuleNodeStrong {
|
||||
let ptr = self.ptr();
|
||||
mem::forget(self);
|
||||
unsafe { mem::transmute(ptr) }
|
||||
}
|
||||
|
||||
pub fn from_ffi<'a>(ffi: &'a &RawServoRuleNode) -> &'a Self {
|
||||
unsafe { &*(ffi as *const &RawServoRuleNode as *const StrongRuleNode) }
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_RuleNode_AddRef(obj: &RawServoRuleNode) {
|
||||
mem::forget(StrongRuleNode::from_ffi(&obj).clone());
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_RuleNode_Release(obj: &RawServoRuleNode) {
|
||||
let ptr = StrongRuleNode::from_ffi(&obj);
|
||||
ptr::read(ptr as *const StrongRuleNode);
|
||||
}
|
||||
|
||||
// ComputedStyle is not an opaque type on any side of FFI.
|
||||
// This means that doing the HasArcFFI type trick is actually unsound,
|
||||
// since it gives us a way to construct an Arc<ComputedStyle> from
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
//! Gecko's C++ bindings, along with some rust helpers to ease its use.
|
||||
|
||||
#[allow(dead_code, improper_ctypes, non_camel_case_types, missing_docs)]
|
||||
pub mod bindings {
|
||||
include!(concat!(env!("OUT_DIR"), "/gecko/bindings.rs"));
|
||||
}
|
||||
|
||||
// FIXME: We allow `improper_ctypes` (for now), because the lint doesn't allow
|
||||
// foreign structs to have `PhantomData`. We should remove this once the lint
|
||||
// ignores this case.
|
||||
|
@ -20,6 +25,4 @@ pub mod structs {
|
|||
include!(concat!(env!("OUT_DIR"), "/gecko/structs.rs"));
|
||||
}
|
||||
|
||||
pub use self::structs as bindings;
|
||||
|
||||
pub mod sugar;
|
||||
|
|
|
@ -135,12 +135,12 @@ pub unsafe trait HasArcFFI: HasFFI {
|
|||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
/// Gecko-FFI-safe Arc (T is an ArcInner).
|
||||
///
|
||||
/// This can be null.
|
||||
///
|
||||
/// Leaks on drop. Please don't drop this.
|
||||
#[repr(C)]
|
||||
pub struct Strong<GeckoType> {
|
||||
ptr: *const GeckoType,
|
||||
_marker: PhantomData<GeckoType>,
|
||||
|
@ -320,6 +320,27 @@ impl<GeckoType> OwnedOrNull<GeckoType> {
|
|||
self.ptr.is_null()
|
||||
}
|
||||
|
||||
/// Returns an owned pointer if this is non-null, and `None` otherwise.
|
||||
pub fn into_box_opt<ServoType>(self) -> Option<Box<ServoType>>
|
||||
where
|
||||
ServoType: HasBoxFFI<FFIType = GeckoType>,
|
||||
{
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { transmute(self) })
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an `Owned<GeckoType>` if non-null, `None` otherwise.
|
||||
pub fn into_owned_opt(self) -> Option<Owned<GeckoType>> {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { transmute(self) })
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets a immutable reference to the underlying Gecko type, or `None` if
|
||||
/// null.
|
||||
pub fn borrow(&self) -> Option<&GeckoType> {
|
||||
|
|
|
@ -73,6 +73,7 @@ use style::gecko_bindings::structs::AtomArray;
|
|||
use style::gecko_bindings::structs::PseudoStyleType;
|
||||
use style::gecko_bindings::structs::CallerType;
|
||||
use style::gecko_bindings::structs::CompositeOperation;
|
||||
use style::gecko_bindings::structs::ComputedStyleStrong;
|
||||
use style::gecko_bindings::structs::DeclarationBlockMutationClosure;
|
||||
use style::gecko_bindings::structs::IterationCompositeOperation;
|
||||
use style::gecko_bindings::structs::Loader;
|
||||
|
@ -95,7 +96,7 @@ use style::gecko_bindings::structs::StyleRuleInclusion;
|
|||
use style::gecko_bindings::structs::StyleSheet as DomStyleSheet;
|
||||
use style::gecko_bindings::structs::URLExtraData;
|
||||
use style::gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasFFI};
|
||||
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, HasBoxFFI, Strong, Owned, OwnedOrNull};
|
||||
use style::gecko_bindings::sugar::ownership::{HasSimpleFFI, Strong};
|
||||
use style::gecko_bindings::sugar::refptr::RefPtr;
|
||||
use style::gecko_properties;
|
||||
use style::global_style_data::{GlobalStyleData, GLOBAL_STYLE_DATA, STYLE_THREAD_POOL};
|
||||
|
@ -361,7 +362,7 @@ pub extern "C" fn Servo_AnimationValues_Interpolate(
|
|||
from: &RawServoAnimationValue,
|
||||
to: &RawServoAnimationValue,
|
||||
progress: f64,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
let from_value = AnimationValue::as_arc(&from);
|
||||
let to_value = AnimationValue::as_arc(&to);
|
||||
if let Ok(value) = from_value.animate(to_value, Procedure::Interpolate { progress }) {
|
||||
|
@ -387,7 +388,7 @@ pub extern "C" fn Servo_AnimationValues_IsInterpolable(
|
|||
pub extern "C" fn Servo_AnimationValues_Add(
|
||||
a: &RawServoAnimationValue,
|
||||
b: &RawServoAnimationValue,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
let a_value = AnimationValue::as_arc(&a);
|
||||
let b_value = AnimationValue::as_arc(&b);
|
||||
if let Ok(value) = a_value.animate(b_value, Procedure::Add) {
|
||||
|
@ -402,7 +403,7 @@ pub extern "C" fn Servo_AnimationValues_Accumulate(
|
|||
a: &RawServoAnimationValue,
|
||||
b: &RawServoAnimationValue,
|
||||
count: u64,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
let a_value = AnimationValue::as_arc(&a);
|
||||
let b_value = AnimationValue::as_arc(&b);
|
||||
if let Ok(value) = a_value.animate(b_value, Procedure::Accumulate { count }) {
|
||||
|
@ -415,7 +416,7 @@ pub extern "C" fn Servo_AnimationValues_Accumulate(
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValues_GetZeroValue(
|
||||
value_to_match: &RawServoAnimationValue,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
let value_to_match = AnimationValue::as_arc(&value_to_match);
|
||||
if let Ok(zero_value) = value_to_match.to_animated_zero() {
|
||||
Arc::new(zero_value).into_strong()
|
||||
|
@ -597,7 +598,7 @@ pub extern "C" fn Servo_ComposeAnimationSegment(
|
|||
iteration_composite: IterationCompositeOperation,
|
||||
progress: f64,
|
||||
current_iteration: u64,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
let underlying_value = AnimationValue::arc_from_borrowed(&underlying_value).map(|v| &**v);
|
||||
let last_value = AnimationValue::arc_from_borrowed(&last_value).map(|v| &**v);
|
||||
let result = compose_animation_segment(
|
||||
|
@ -755,7 +756,7 @@ pub extern "C" fn Servo_AnimationValue_GetOpacity(value: &RawServoAnimationValue
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> Strong<RawServoAnimationValue> {
|
||||
pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> bindings::RawServoAnimationValueStrong {
|
||||
Arc::new(AnimationValue::Opacity(opacity)).into_strong()
|
||||
}
|
||||
|
||||
|
@ -763,7 +764,7 @@ pub extern "C" fn Servo_AnimationValue_Opacity(opacity: f32) -> Strong<RawServoA
|
|||
pub extern "C" fn Servo_AnimationValue_Color(
|
||||
color_property: nsCSSPropertyID,
|
||||
color: structs::nscolor,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
use style::gecko::values::convert_nscolor_to_rgba;
|
||||
use style::values::animated::color::RGBA as AnimatedRGBA;
|
||||
|
||||
|
@ -834,7 +835,7 @@ pub unsafe extern "C" fn Servo_AnimationValue_GetTransform(
|
|||
pub unsafe extern "C" fn Servo_AnimationValue_Transform(
|
||||
property: nsCSSPropertyID,
|
||||
list: *const nsCSSValueSharedList,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
use style::values::computed::transform::{Rotate, Scale, Translate};
|
||||
|
||||
let list = (&*list).mHead.as_ref();
|
||||
|
@ -883,7 +884,7 @@ pub extern "C" fn Servo_AnimationValue_DeepEqual(
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValue_Uncompute(
|
||||
value: &RawServoAnimationValue,
|
||||
) -> Strong<RawServoDeclarationBlock> {
|
||||
) -> bindings::RawServoDeclarationBlockStrong {
|
||||
let value = AnimationValue::as_arc(&value);
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
Arc::new(
|
||||
|
@ -930,7 +931,7 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(
|
|||
element: &RawGeckoElement,
|
||||
computed_values: &ComputedValues,
|
||||
snapshots: *const ServoElementSnapshotTable,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
debug_assert!(!snapshots.is_null());
|
||||
let computed_values = unsafe { ArcBorrow::from_ref(computed_values) };
|
||||
|
||||
|
@ -972,10 +973,10 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
|||
computed_values: &ComputedValues,
|
||||
snapshots: *const ServoElementSnapshotTable,
|
||||
animation_value: &RawServoAnimationValue,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
debug_assert!(!snapshots.is_null());
|
||||
let rules = match computed_values.rules {
|
||||
None => return Strong::null(),
|
||||
None => return ComputedStyleStrong::null(),
|
||||
Some(ref rules) => rules,
|
||||
};
|
||||
|
||||
|
@ -997,7 +998,7 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
|||
|
||||
let element = GeckoElement(element);
|
||||
if element.borrow_data().is_none() {
|
||||
return Strong::null();
|
||||
return ComputedStyleStrong::null();
|
||||
}
|
||||
|
||||
let shared = create_shared_context(
|
||||
|
@ -1020,7 +1021,7 @@ pub extern "C" fn Servo_StyleSet_GetComputedValuesByAddingAnimation(
|
|||
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(
|
||||
computed_values: &ComputedValues,
|
||||
property_id: nsCSSPropertyID,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
let property = match LonghandId::from_nscsspropertyid(property_id) {
|
||||
Ok(longhand) => longhand,
|
||||
Err(()) => return Strong::null(),
|
||||
|
@ -1216,7 +1217,7 @@ pub extern "C" fn Servo_Element_HasPrimaryComputedValues(element: &RawGeckoEleme
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Element_GetPrimaryComputedValues(
|
||||
element: &RawGeckoElement,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let element = GeckoElement(element);
|
||||
let data = element
|
||||
.borrow_data()
|
||||
|
@ -1240,7 +1241,7 @@ pub extern "C" fn Servo_Element_HasPseudoComputedValues(
|
|||
pub extern "C" fn Servo_Element_GetPseudoComputedValues(
|
||||
element: &RawGeckoElement,
|
||||
index: usize,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let element = GeckoElement(element);
|
||||
let data = element
|
||||
.borrow_data()
|
||||
|
@ -1307,7 +1308,7 @@ fn mode_to_origin(mode: SheetParsingMode) -> Origin {
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_Empty(
|
||||
mode: SheetParsingMode,
|
||||
) -> Strong<RawServoStyleSheetContents> {
|
||||
) -> bindings::RawServoStyleSheetContentsStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let origin = mode_to_origin(mode);
|
||||
let shared_lock = &global_style_data.shared_lock;
|
||||
|
@ -1340,7 +1341,7 @@ pub extern "C" fn Servo_StyleSheet_FromUTF8Bytes(
|
|||
quirks_mode: nsCompatibility,
|
||||
reusable_sheets: *mut LoaderReusableStyleSheets,
|
||||
use_counters: Option<&UseCounters>,
|
||||
) -> Strong<RawServoStyleSheetContents> {
|
||||
) -> bindings::RawServoStyleSheetContentsStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let input: &str = unsafe { (*bytes).as_str_unchecked() };
|
||||
|
||||
|
@ -1426,12 +1427,12 @@ pub extern "C" fn Servo_StyleSet_AppendStyleSheet(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AuthorStyles_Create() -> Owned<RawServoAuthorStyles> {
|
||||
Box::new(AuthorStyles::<GeckoStyleSheet>::new()).into_ffi()
|
||||
pub extern "C" fn Servo_AuthorStyles_Create() -> *mut RawServoAuthorStyles {
|
||||
Box::into_raw(Box::new(AuthorStyles::<GeckoStyleSheet>::new())) as *mut _
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AuthorStyles_Drop(styles: Owned<RawServoAuthorStyles>) {
|
||||
pub extern "C" fn Servo_AuthorStyles_Drop(styles: bindings::RawServoAuthorStylesOwned) {
|
||||
let _ = styles.into_box::<AuthorStyles<_>>();
|
||||
}
|
||||
|
||||
|
@ -1683,7 +1684,7 @@ pub extern "C" fn Servo_StyleSheet_HasRules(
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSheet_GetRules(
|
||||
sheet: &RawServoStyleSheetContents,
|
||||
) -> Strong<ServoCssRules> {
|
||||
) -> bindings::ServoCssRulesStrong {
|
||||
StylesheetContents::as_arc(&sheet)
|
||||
.rules
|
||||
.clone()
|
||||
|
@ -1694,7 +1695,7 @@ pub extern "C" fn Servo_StyleSheet_GetRules(
|
|||
pub extern "C" fn Servo_StyleSheet_Clone(
|
||||
raw_sheet: &RawServoStyleSheetContents,
|
||||
reference_sheet: *const DomStyleSheet,
|
||||
) -> Strong<RawServoStyleSheetContents> {
|
||||
) -> bindings::RawServoStyleSheetContentsStrong {
|
||||
use style::shared_lock::{DeepCloneParams, DeepCloneWithLock};
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
|
@ -1945,7 +1946,7 @@ macro_rules! impl_group_rule_funcs {
|
|||
impl_basic_rule_funcs! { ($name, $rule_type, $raw_type), $($basic)+ }
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn $get_rules(rule: &$raw_type) -> Strong<ServoCssRules> {
|
||||
pub extern "C" fn $get_rules(rule: &$raw_type) -> bindings::ServoCssRulesStrong {
|
||||
read_locked_arc(rule, |rule: &$rule_type| {
|
||||
rule.rules.clone().into_strong()
|
||||
})
|
||||
|
@ -2030,7 +2031,7 @@ impl_basic_rule_funcs! { (CounterStyle, CounterStyleRule, RawServoCounterStyleRu
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleRule_GetStyle(
|
||||
rule: &RawServoStyleRule,
|
||||
) -> Strong<RawServoDeclarationBlock> {
|
||||
) -> bindings::RawServoDeclarationBlockStrong {
|
||||
read_locked_arc(rule, |rule: &StyleRule| rule.block.clone().into_strong())
|
||||
}
|
||||
|
||||
|
@ -2334,7 +2335,7 @@ pub extern "C" fn Servo_Keyframe_SetKeyText(
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Keyframe_GetStyle(
|
||||
keyframe: &RawServoKeyframe,
|
||||
) -> Strong<RawServoDeclarationBlock> {
|
||||
) -> bindings::RawServoDeclarationBlockStrong {
|
||||
read_locked_arc(keyframe, |keyframe: &Keyframe| {
|
||||
keyframe.block.clone().into_strong()
|
||||
})
|
||||
|
@ -2377,7 +2378,7 @@ pub extern "C" fn Servo_KeyframesRule_GetKeyframeAt(
|
|||
index: u32,
|
||||
line: *mut u32,
|
||||
column: *mut u32,
|
||||
) -> Strong<RawServoKeyframe> {
|
||||
) -> bindings::RawServoKeyframeStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let key = Locked::<KeyframesRule>::as_arc(&rule)
|
||||
|
@ -2436,7 +2437,7 @@ pub extern "C" fn Servo_KeyframesRule_DeleteRule(rule: &RawServoKeyframesRule, i
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_MediaRule_GetMedia(
|
||||
rule: &RawServoMediaRule,
|
||||
) -> Strong<RawServoMediaList> {
|
||||
) -> bindings::RawServoMediaListStrong {
|
||||
read_locked_arc(rule, |rule: &MediaRule| {
|
||||
rule.media_queries.clone().into_strong()
|
||||
})
|
||||
|
@ -2459,7 +2460,7 @@ pub extern "C" fn Servo_NamespaceRule_GetURI(rule: &RawServoNamespaceRule) -> *m
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_PageRule_GetStyle(
|
||||
rule: &RawServoPageRule,
|
||||
) -> Strong<RawServoDeclarationBlock> {
|
||||
) -> bindings::RawServoDeclarationBlockStrong {
|
||||
read_locked_arc(rule, |rule: &PageRule| rule.block.clone().into_strong())
|
||||
}
|
||||
|
||||
|
@ -2521,7 +2522,7 @@ pub extern "C" fn Servo_FontFeatureValuesRule_GetValueText(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_FontFaceRule_CreateEmpty() -> Strong<RawServoFontFaceRule> {
|
||||
pub extern "C" fn Servo_FontFaceRule_CreateEmpty() -> bindings::RawServoFontFaceRuleStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
// XXX This is not great. We should split FontFace descriptor data
|
||||
// from the rule, so that we don't need to create the rule like this
|
||||
|
@ -2538,7 +2539,7 @@ pub extern "C" fn Servo_FontFaceRule_CreateEmpty() -> Strong<RawServoFontFaceRul
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_FontFaceRule_Clone(
|
||||
rule: &RawServoFontFaceRule,
|
||||
) -> Strong<RawServoFontFaceRule> {
|
||||
) -> bindings::RawServoFontFaceRuleStrong {
|
||||
let clone = read_locked_arc(rule, |rule: &FontFaceRule| rule.clone());
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
Arc::new(global_style_data.shared_lock.wrap(clone)).into_strong()
|
||||
|
@ -3105,7 +3106,7 @@ pub unsafe extern "C" fn Servo_ComputedValues_GetForAnonymousBox(
|
|||
parent_style_or_null: Option<&ComputedValues>,
|
||||
pseudo: PseudoStyleType,
|
||||
raw_data: &RawServoStyleSet,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let guards = StylesheetGuards::same(&guard);
|
||||
|
@ -3161,7 +3162,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(
|
|||
is_probe: bool,
|
||||
inherited_style: Option<&ComputedValues>,
|
||||
raw_data: &RawServoStyleSet,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let element = GeckoElement(element);
|
||||
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
|
||||
|
@ -3240,7 +3241,7 @@ pub extern "C" fn Servo_ComputedValues_ResolveXULTreePseudoStyle(
|
|||
inherited_style: &ComputedValues,
|
||||
input_word: *const AtomArray,
|
||||
raw_data: &RawServoStyleSet,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let element = GeckoElement(element);
|
||||
let data = element
|
||||
.borrow_data()
|
||||
|
@ -3434,7 +3435,7 @@ pub unsafe extern "C" fn Servo_ComputedValues_Inherit(
|
|||
pseudo: PseudoStyleType,
|
||||
parent_style_context: Option<&ComputedValues>,
|
||||
target: structs::InheritTarget,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
|
||||
let for_text = target == structs::InheritTarget::Text;
|
||||
|
@ -3513,7 +3514,7 @@ pub extern "C" fn Servo_StyleSet_RebuildCachedData(raw_data: &RawServoStyleSet)
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_Drop(data: Owned<RawServoStyleSet>) {
|
||||
pub extern "C" fn Servo_StyleSet_Drop(data: bindings::RawServoStyleSetOwned) {
|
||||
let _ = data.into_box::<PerDocumentStyleData>();
|
||||
}
|
||||
|
||||
|
@ -3557,7 +3558,7 @@ pub extern "C" fn Servo_ParseProperty(
|
|||
parsing_mode: structs::ParsingMode,
|
||||
quirks_mode: nsCompatibility,
|
||||
loader: *mut Loader,
|
||||
) -> Strong<RawServoDeclarationBlock> {
|
||||
) -> bindings::RawServoDeclarationBlockStrong {
|
||||
let id =
|
||||
get_property_id_from_nscsspropertyid!(property, Strong::null());
|
||||
let mut declarations = SourcePropertyDeclaration::new();
|
||||
|
@ -3713,7 +3714,7 @@ pub unsafe extern "C" fn Servo_ParseStyleAttribute(
|
|||
raw_extra_data: *mut URLExtraData,
|
||||
quirks_mode: nsCompatibility,
|
||||
loader: *mut Loader,
|
||||
) -> Strong<RawServoDeclarationBlock> {
|
||||
) -> bindings::RawServoDeclarationBlockStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let value = (*data).as_str_unchecked();
|
||||
let reporter = ErrorReporter::new(ptr::null_mut(), loader, raw_extra_data);
|
||||
|
@ -3728,7 +3729,7 @@ pub unsafe extern "C" fn Servo_ParseStyleAttribute(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> Strong<RawServoDeclarationBlock> {
|
||||
pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> bindings::RawServoDeclarationBlockStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
Arc::new(
|
||||
global_style_data
|
||||
|
@ -3741,7 +3742,7 @@ pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> Strong<RawServoDeclara
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_DeclarationBlock_Clone(
|
||||
declarations: &RawServoDeclarationBlock,
|
||||
) -> Strong<RawServoDeclarationBlock> {
|
||||
) -> bindings::RawServoDeclarationBlockStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
|
@ -4067,7 +4068,7 @@ pub extern "C" fn Servo_DeclarationBlock_RemovePropertyById(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_MediaList_Create() -> Strong<RawServoMediaList> {
|
||||
pub extern "C" fn Servo_MediaList_Create() -> bindings::RawServoMediaListStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
Arc::new(global_style_data.shared_lock.wrap(MediaList::empty())).into_strong()
|
||||
}
|
||||
|
@ -4075,7 +4076,7 @@ pub extern "C" fn Servo_MediaList_Create() -> Strong<RawServoMediaList> {
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_MediaList_DeepClone(
|
||||
list: &RawServoMediaList,
|
||||
) -> Strong<RawServoMediaList> {
|
||||
) -> bindings::RawServoMediaListStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
read_locked_arc(list, |list: &MediaList| {
|
||||
Arc::new(global_style_data.shared_lock.wrap(list.clone())).into_strong()
|
||||
|
@ -4825,7 +4826,7 @@ pub extern "C" fn Servo_TakeChangeHint(
|
|||
pub extern "C" fn Servo_ResolveStyle(
|
||||
element: &RawGeckoElement,
|
||||
_raw_data: &RawServoStyleSet,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let element = GeckoElement(element);
|
||||
debug!("Servo_ResolveStyle: {:?}", element);
|
||||
let data = element
|
||||
|
@ -4848,7 +4849,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(
|
|||
rule_inclusion: StyleRuleInclusion,
|
||||
snapshots: *const ServoElementSnapshotTable,
|
||||
raw_data: &RawServoStyleSet,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
debug_assert!(!snapshots.is_null());
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
|
@ -4926,7 +4927,7 @@ pub extern "C" fn Servo_ReparentStyle(
|
|||
layout_parent_style: &ComputedValues,
|
||||
element: Option<&RawGeckoElement>,
|
||||
raw_data: &RawServoStyleSet,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
|
@ -5200,7 +5201,7 @@ pub extern "C" fn Servo_AnimationValue_Compute(
|
|||
declarations: &RawServoDeclarationBlock,
|
||||
style: &ComputedValues,
|
||||
raw_data: &RawServoStyleSet,
|
||||
) -> Strong<RawServoAnimationValue> {
|
||||
) -> bindings::RawServoAnimationValueStrong {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
|
||||
|
@ -5583,7 +5584,7 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
|
|||
raw_data: &RawServoStyleSet,
|
||||
parent_style_context: Option<&ComputedValues>,
|
||||
declarations: &RawServoDeclarationBlock,
|
||||
) -> Strong<ComputedValues> {
|
||||
) -> ComputedStyleStrong {
|
||||
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
|
@ -5887,7 +5888,7 @@ pub extern "C" fn Servo_HasPendingRestyleAncestor(element: &RawGeckoElement) ->
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_SelectorList_Parse(
|
||||
selector_list: *const nsACString,
|
||||
) -> OwnedOrNull<RawServoSelectorList> {
|
||||
) -> *mut RawServoSelectorList {
|
||||
use style::selector_parser::SelectorParser;
|
||||
|
||||
debug_assert!(!selector_list.is_null());
|
||||
|
@ -5895,14 +5896,14 @@ pub unsafe extern "C" fn Servo_SelectorList_Parse(
|
|||
let input = (*selector_list).as_str_unchecked();
|
||||
let selector_list = match SelectorParser::parse_author_origin_no_namespace(&input) {
|
||||
Ok(selector_list) => selector_list,
|
||||
Err(..) => return OwnedOrNull::null(),
|
||||
Err(..) => return ptr::null_mut(),
|
||||
};
|
||||
|
||||
Box::new(selector_list).into_ffi().maybe()
|
||||
Box::into_raw(Box::new(selector_list)) as *mut RawServoSelectorList
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_SelectorList_Drop(list: Owned<RawServoSelectorList>) {
|
||||
pub unsafe extern "C" fn Servo_SelectorList_Drop(list: bindings::RawServoSelectorListOwned) {
|
||||
let _ = list.into_box::<::selectors::SelectorList<SelectorImpl>>();
|
||||
}
|
||||
|
||||
|
@ -6160,7 +6161,7 @@ pub unsafe extern "C" fn Servo_ParseFontShorthandForMatching(
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_SourceSizeList_Parse(
|
||||
value: *const nsACString,
|
||||
) -> Owned<RawServoSourceSizeList> {
|
||||
) -> *mut RawServoSourceSizeList {
|
||||
let value = (*value).as_str_unchecked();
|
||||
let mut input = ParserInput::new(value);
|
||||
let mut parser = Parser::new(&mut input);
|
||||
|
@ -6177,7 +6178,7 @@ pub unsafe extern "C" fn Servo_SourceSizeList_Parse(
|
|||
|
||||
// NB: Intentionally not calling parse_entirely.
|
||||
let list = SourceSizeList::parse(&context, &mut parser);
|
||||
Box::new(list).into_ffi()
|
||||
Box::into_raw(Box::new(list)) as *mut _
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -6198,7 +6199,7 @@ pub unsafe extern "C" fn Servo_SourceSizeList_Evaluate(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_SourceSizeList_Drop(list: Owned<RawServoSourceSizeList>) {
|
||||
pub unsafe extern "C" fn Servo_SourceSizeList_Drop(list: bindings::RawServoSourceSizeListOwned) {
|
||||
let _ = list.into_box::<SourceSizeList>();
|
||||
}
|
||||
|
||||
|
@ -6254,12 +6255,12 @@ pub unsafe extern "C" fn Servo_PseudoClass_GetStates(name: *const nsACString) ->
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_UseCounters_Create() -> Owned<structs::StyleUseCounters> {
|
||||
Box::<UseCounters>::default().into_ffi()
|
||||
pub unsafe extern "C" fn Servo_UseCounters_Create() -> *mut structs::StyleUseCounters {
|
||||
Box::into_raw(Box::<UseCounters>::default()) as *mut _
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_UseCounters_Drop(c: Owned<structs::StyleUseCounters>) {
|
||||
pub unsafe extern "C" fn Servo_UseCounters_Drop(c: bindings::StyleUseCountersOwned) {
|
||||
let _ = c.into_box::<UseCounters>();
|
||||
}
|
||||
|
||||
|
@ -6287,7 +6288,7 @@ pub unsafe extern "C" fn Servo_IsCssPropertyRecordedInUseCounter(
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Quotes_GetInitialValue() -> Strong<RawServoQuotes> {
|
||||
pub extern "C" fn Servo_Quotes_GetInitialValue() -> bindings::RawServoQuotesStrong {
|
||||
computed::Quotes::get_initial_value()
|
||||
.0
|
||||
.clone()
|
||||
|
|
Загрузка…
Ссылка в новой задаче