2015-11-25 04:14:39 +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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_ServoBindings_h
|
|
|
|
#define mozilla_ServoBindings_h
|
|
|
|
|
2016-03-03 07:23:45 +03:00
|
|
|
#include "stdint.h"
|
2016-04-28 02:15:56 +03:00
|
|
|
#include "mozilla/css/SheetParsingMode.h"
|
2015-11-25 04:14:39 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* API for Servo to access Gecko data structures. This file must compile as valid
|
|
|
|
* C code in order for the binding generator to parse it.
|
|
|
|
*
|
|
|
|
* Functions beginning with Gecko_ are implemented in Gecko and invoked from Servo.
|
|
|
|
* Functions beginning with Servo_ are implemented in Servo and invoked from Gecko.
|
|
|
|
*/
|
|
|
|
|
2016-03-18 23:14:07 +03:00
|
|
|
class nsIAtom;
|
2015-11-25 04:14:39 +03:00
|
|
|
class nsINode;
|
|
|
|
typedef nsINode RawGeckoNode;
|
|
|
|
namespace mozilla { namespace dom { class Element; } }
|
|
|
|
using mozilla::dom::Element;
|
|
|
|
typedef mozilla::dom::Element RawGeckoElement;
|
|
|
|
class nsIDocument;
|
|
|
|
typedef nsIDocument RawGeckoDocument;
|
2016-02-24 04:28:50 +03:00
|
|
|
struct ServoNodeData;
|
2016-03-19 02:56:47 +03:00
|
|
|
struct ServoComputedValues;
|
2016-02-26 04:51:01 +03:00
|
|
|
struct RawServoStyleSheet;
|
2016-01-27 05:02:04 +03:00
|
|
|
struct RawServoStyleSet;
|
2015-11-25 04:14:39 +03:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
|
|
// DOM Traversal.
|
|
|
|
uint32_t Gecko_ChildrenCount(RawGeckoNode* node);
|
2016-03-03 07:27:07 +03:00
|
|
|
bool Gecko_NodeIsElement(RawGeckoNode* node);
|
2015-11-25 04:14:39 +03:00
|
|
|
RawGeckoNode* Gecko_GetParentNode(RawGeckoNode* node);
|
|
|
|
RawGeckoNode* Gecko_GetFirstChild(RawGeckoNode* node);
|
|
|
|
RawGeckoNode* Gecko_GetLastChild(RawGeckoNode* node);
|
|
|
|
RawGeckoNode* Gecko_GetPrevSibling(RawGeckoNode* node);
|
|
|
|
RawGeckoNode* Gecko_GetNextSibling(RawGeckoNode* node);
|
|
|
|
RawGeckoElement* Gecko_GetParentElement(RawGeckoElement* element);
|
|
|
|
RawGeckoElement* Gecko_GetFirstChildElement(RawGeckoElement* element);
|
|
|
|
RawGeckoElement* Gecko_GetLastChildElement(RawGeckoElement* element);
|
|
|
|
RawGeckoElement* Gecko_GetPrevSiblingElement(RawGeckoElement* element);
|
|
|
|
RawGeckoElement* Gecko_GetNextSiblingElement(RawGeckoElement* element);
|
|
|
|
RawGeckoElement* Gecko_GetDocumentElement(RawGeckoDocument* document);
|
|
|
|
|
|
|
|
// Selector Matching.
|
2016-02-24 04:51:47 +03:00
|
|
|
uint8_t Gecko_ElementState(RawGeckoElement* element);
|
2016-03-03 07:27:07 +03:00
|
|
|
bool Gecko_IsHTMLElementInHTMLDocument(RawGeckoElement* element);
|
|
|
|
bool Gecko_IsLink(RawGeckoElement* element);
|
|
|
|
bool Gecko_IsTextNode(RawGeckoNode* node);
|
|
|
|
bool Gecko_IsVisitedLink(RawGeckoElement* element);
|
|
|
|
bool Gecko_IsUnvisitedLink(RawGeckoElement* element);
|
|
|
|
bool Gecko_IsRootElement(RawGeckoElement* element);
|
2016-05-18 22:05:36 +03:00
|
|
|
nsIAtom* Gecko_LocalName(RawGeckoElement* element);
|
|
|
|
nsIAtom* Gecko_Namespace(RawGeckoElement* element);
|
2015-11-25 04:14:39 +03:00
|
|
|
|
2016-02-24 04:28:50 +03:00
|
|
|
// Node data.
|
|
|
|
ServoNodeData* Gecko_GetNodeData(RawGeckoNode* node);
|
|
|
|
void Gecko_SetNodeData(RawGeckoNode* node, ServoNodeData* data);
|
|
|
|
void Servo_DropNodeData(ServoNodeData* data);
|
|
|
|
|
2016-05-18 22:05:36 +03:00
|
|
|
// Atoms.
|
|
|
|
nsIAtom* Gecko_Atomize(const char* aString, uint32_t aLength);
|
|
|
|
void Gecko_AddRefAtom(nsIAtom* aAtom);
|
|
|
|
void Gecko_ReleaseAtom(nsIAtom* aAtom);
|
|
|
|
uint32_t Gecko_HashAtom(nsIAtom* aAtom);
|
|
|
|
const uint16_t* Gecko_GetAtomAsUTF16(nsIAtom* aAtom, uint32_t* aLength);
|
|
|
|
bool Gecko_AtomEqualsUTF8(nsIAtom* aAtom, const char* aString, uint32_t aLength);
|
|
|
|
bool Gecko_AtomEqualsUTF8IgnoreCase(nsIAtom* aAtom, const char* aString, uint32_t aLength);
|
|
|
|
|
2016-05-04 03:42:40 +03:00
|
|
|
// Counter style.
|
|
|
|
struct nsStyleList;
|
|
|
|
void Gecko_SetListStyleType(nsStyleList* style_struct, uint32_t type);
|
|
|
|
void Gecko_CopyListStyleTypeFrom(nsStyleList* dst, const nsStyleList* src);
|
|
|
|
|
2016-01-27 05:02:04 +03:00
|
|
|
// Styleset and Stylesheet management.
|
|
|
|
//
|
|
|
|
// TODO: Make these return already_AddRefed and UniquePtr when the binding
|
|
|
|
// generator is smart enough to handle them.
|
2016-04-28 02:15:56 +03:00
|
|
|
RawServoStyleSheet* Servo_StylesheetFromUTF8Bytes(const uint8_t* bytes, uint32_t length,
|
|
|
|
mozilla::css::SheetParsingMode parsing_mode);
|
2016-03-19 02:56:47 +03:00
|
|
|
void Servo_AddRefStyleSheet(RawServoStyleSheet* sheet);
|
|
|
|
void Servo_ReleaseStyleSheet(RawServoStyleSheet* sheet);
|
2016-02-26 05:57:42 +03:00
|
|
|
void Servo_AppendStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
|
|
|
|
void Servo_PrependStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
|
|
|
|
void Servo_RemoveStyleSheet(RawServoStyleSheet* sheet, RawServoStyleSet* set);
|
2016-04-29 07:01:44 +03:00
|
|
|
void Servo_InsertStyleSheetBefore(RawServoStyleSheet* sheet,
|
|
|
|
RawServoStyleSheet* reference,
|
|
|
|
RawServoStyleSet* set);
|
2016-03-03 07:27:07 +03:00
|
|
|
bool Servo_StyleSheetHasRules(RawServoStyleSheet* sheet);
|
2016-01-27 05:02:04 +03:00
|
|
|
RawServoStyleSet* Servo_InitStyleSet();
|
|
|
|
void Servo_DropStyleSet(RawServoStyleSet* set);
|
2016-02-26 04:51:01 +03:00
|
|
|
|
2016-03-19 02:56:47 +03:00
|
|
|
// Computed style data.
|
2016-04-29 07:01:44 +03:00
|
|
|
ServoComputedValues* Servo_GetComputedValues(RawGeckoNode* node);
|
2016-03-18 23:14:07 +03:00
|
|
|
ServoComputedValues* Servo_GetComputedValuesForAnonymousBox(ServoComputedValues* parentStyleOrNull,
|
2016-04-27 00:09:03 +03:00
|
|
|
nsIAtom* pseudoTag,
|
|
|
|
RawServoStyleSet* set);
|
2016-04-29 03:56:37 +03:00
|
|
|
ServoComputedValues* Servo_GetComputedValuesForPseudoElement(ServoComputedValues* parent_style,
|
|
|
|
RawGeckoElement* match_element,
|
|
|
|
nsIAtom* pseudo_tag,
|
|
|
|
RawServoStyleSet* set,
|
|
|
|
bool is_probe);
|
2016-05-06 01:32:00 +03:00
|
|
|
ServoComputedValues* Servo_InheritComputedValues(ServoComputedValues* parent_style);
|
2016-03-19 02:56:47 +03:00
|
|
|
void Servo_AddRefComputedValues(ServoComputedValues*);
|
|
|
|
void Servo_ReleaseComputedValues(ServoComputedValues*);
|
|
|
|
|
2016-05-05 01:34:21 +03:00
|
|
|
// Initialize Servo components. Should be called exactly once at startup.
|
|
|
|
void Servo_Initialize();
|
|
|
|
|
|
|
|
// Restyle the given document.
|
2016-01-27 05:02:04 +03:00
|
|
|
void Servo_RestyleDocument(RawGeckoDocument* doc, RawServoStyleSet* set);
|
2015-11-25 04:14:39 +03:00
|
|
|
|
2016-04-02 03:04:59 +03:00
|
|
|
// Style-struct management.
|
|
|
|
#define STYLE_STRUCT(name, checkdata_cb) \
|
|
|
|
struct nsStyle##name; \
|
|
|
|
void Gecko_Construct_nsStyle##name(nsStyle##name* ptr); \
|
|
|
|
void Gecko_CopyConstruct_nsStyle##name(nsStyle##name* ptr, const nsStyle##name* other); \
|
2016-04-27 05:34:49 +03:00
|
|
|
void Gecko_Destroy_nsStyle##name(nsStyle##name* ptr); \
|
|
|
|
const nsStyle##name* Servo_GetStyle##name(ServoComputedValues* computedValues);
|
2016-04-02 03:04:59 +03:00
|
|
|
#include "nsStyleStructList.h"
|
|
|
|
#undef STYLE_STRUCT
|
|
|
|
|
2015-11-25 04:14:39 +03:00
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
#endif // mozilla_ServoBindings_h
|