Auto merge of #14608 - upsuper:bug1323147, r=heycam

Use string and nsCSSProperty for stylo CSSOM FFI

<!-- Please describe your changes on the following line: -->
This is the Servo side change of [bug 1323147](https://bugzilla.mozilla.org/show_bug.cgi?id=1323147) which has been reviewed by @heycam and @SimonSapin on Bugzilla.

r? @heycam

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14608)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-12-17 18:22:10 -08:00 committed by GitHub
commit 11dffa8958
5 changed files with 108 additions and 2967 deletions

View file

@ -33,14 +33,14 @@ def msvc32_symbolify(source, ident):
class GkAtomSource:
PATTERN = re.compile('^GK_ATOM\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M)
PATTERN = re.compile('^GK_ATOM\((.+),\s*"(.*)"\)')
FILE = "include/nsGkAtomList.h"
CLASS = "nsGkAtoms"
TYPE = "nsIAtom"
class CSSPseudoElementsAtomSource:
PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((?P<ident>.+),\s*"(?P<value>.*)",', re.M)
PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((.+),\s*"(.*)",')
FILE = "include/nsCSSPseudoElementList.h"
CLASS = "nsCSSPseudoElements"
# NB: nsICSSPseudoElement is effectively the same as a nsIAtom, but we need
@ -49,24 +49,16 @@ class CSSPseudoElementsAtomSource:
class CSSAnonBoxesAtomSource:
PATTERN = re.compile('^CSS_ANON_BOX\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M)
PATTERN = re.compile('^CSS_ANON_BOX\((.+),\s*"(.*)"\)')
FILE = "include/nsCSSAnonBoxList.h"
CLASS = "nsCSSAnonBoxes"
TYPE = "nsICSSAnonBoxPseudo"
class CSSPropsAtomSource:
PATTERN = re.compile('^CSS_PROP_[A-Z]+\(\s*(?P<value>[^,]+),\s*(?P<ident>[^,]+)', re.M)
FILE = "include/nsCSSPropList.h"
CLASS = "nsCSSProps"
TYPE = "nsICSSProperty"
SOURCES = [
GkAtomSource,
CSSPseudoElementsAtomSource,
CSSAnonBoxesAtomSource,
CSSPropsAtomSource,
]
@ -104,14 +96,10 @@ def collect_atoms(objdir):
atoms = []
for source in SOURCES:
with open(os.path.join(objdir, source.FILE)) as f:
content = f.read()
found = set()
for match in source.PATTERN.finditer(content):
ident = match.group('ident')
if ident in found:
continue
found.add(ident)
atoms.append(Atom(source, ident, match.group('value')))
for line in f.readlines():
result = re.match(source.PATTERN, line)
if result:
atoms.append(Atom(source, result.group(1), result.group(2)))
return atoms

View file

@ -460,6 +460,7 @@ mod bindings {
"StyleBasicShapeType",
"StyleClipPath",
"nsCSSKeyword",
"nsCSSPropertyID",
"nsCSSShadowArray",
"nsCSSValue",
"nsCSSValueSharedList",

View file

@ -19,6 +19,7 @@ use gecko_bindings::structs::StyleBasicShape;
use gecko_bindings::structs::StyleBasicShapeType;
use gecko_bindings::structs::StyleClipPath;
use gecko_bindings::structs::nsCSSKeyword;
use gecko_bindings::structs::nsCSSPropertyID;
use gecko_bindings::structs::nsCSSShadowArray;
use gecko_bindings::structs::nsCSSValue;
use gecko_bindings::structs::nsCSSValueSharedList;
@ -1092,8 +1093,7 @@ extern "C" {
extern "C" {
pub fn Servo_DeclarationBlock_SerializeOneValue(declarations:
RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom,
is_custom: bool,
property: nsCSSPropertyID,
buffer:
*mut nsAString_internal);
}
@ -1113,32 +1113,53 @@ extern "C" {
extern "C" {
pub fn Servo_DeclarationBlock_GetPropertyValue(declarations:
RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom,
is_custom: bool,
property:
*const nsACString_internal,
value:
*mut nsAString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_GetPropertyValueById(declarations:
RawServoDeclarationBlockBorrowed,
property:
nsCSSPropertyID,
value:
*mut nsAString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations:
RawServoDeclarationBlockBorrowed,
property:
*mut nsIAtom,
is_custom: bool)
*const nsACString_internal)
-> bool;
}
extern "C" {
pub fn Servo_DeclarationBlock_SetProperty(declarations:
RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom,
is_custom: bool,
property:
*const nsACString_internal,
value: *mut nsACString_internal,
is_important: bool) -> bool;
}
extern "C" {
pub fn Servo_DeclarationBlock_SetPropertyById(declarations:
RawServoDeclarationBlockBorrowed,
property: nsCSSPropertyID,
value:
*mut nsACString_internal,
is_important: bool) -> bool;
}
extern "C" {
pub fn Servo_DeclarationBlock_RemoveProperty(declarations:
RawServoDeclarationBlockBorrowed,
property: *mut nsIAtom,
is_custom: bool);
property:
*const nsACString_internal);
}
extern "C" {
pub fn Servo_DeclarationBlock_RemovePropertyById(declarations:
RawServoDeclarationBlockBorrowed,
property:
nsCSSPropertyID);
}
extern "C" {
pub fn Servo_CSSSupports(name: *const nsACString_internal,

File diff suppressed because it is too large Load diff