mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
stylo: Switch Gecko over to ServoStyleContext
This commit is contained in:
parent
74519cc1a7
commit
89930e7565
19 changed files with 4479 additions and 2353 deletions
|
@ -10,14 +10,15 @@
|
|||
|
||||
use gecko_bindings::bindings::{RawServoImportRule, RawServoSupportsRule};
|
||||
use gecko_bindings::bindings::{RawServoKeyframe, RawServoKeyframesRule};
|
||||
use gecko_bindings::bindings::RawServoMediaRule;
|
||||
use gecko_bindings::bindings::{RawServoNamespaceRule, RawServoPageRule};
|
||||
use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong, RawServoDocumentRule, RawServoMediaRule};
|
||||
use gecko_bindings::bindings::{ServoComputedValues, ServoCssRules};
|
||||
use gecko_bindings::bindings::{RawServoRuleNode, RawServoRuleNodeStrong, RawServoDocumentRule};
|
||||
use gecko_bindings::bindings::ServoCssRules;
|
||||
use gecko_bindings::structs::{RawServoAnimationValue, RawServoDeclarationBlock, RawServoStyleRule, RawServoMediaList};
|
||||
use gecko_bindings::structs::RawServoStyleSheetContents;
|
||||
use gecko_bindings::structs::{RawServoStyleSheetContents, ServoComputedValues, ServoStyleContext};
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasFFI};
|
||||
use media_queries::MediaList;
|
||||
use properties::{ComputedValues, PropertyDeclarationBlock};
|
||||
use properties::{ComputedValues, ComputedValuesInner, PropertyDeclarationBlock};
|
||||
use properties::animated_properties::AnimationValue;
|
||||
use rule_tree::StrongRuleNode;
|
||||
use shared_lock::Locked;
|
||||
|
@ -51,9 +52,12 @@ impl_arc_ffi!(Locked<CssRules> => ServoCssRules
|
|||
impl_arc_ffi!(StylesheetContents => RawServoStyleSheetContents
|
||||
[Servo_StyleSheetContents_AddRef, Servo_StyleSheetContents_Release]);
|
||||
|
||||
impl_arc_ffi!(ComputedValues => ServoComputedValues
|
||||
impl_arc_ffi!(ComputedValuesInner => ServoComputedValues
|
||||
[Servo_ComputedValues_AddRef, Servo_ComputedValues_Release]);
|
||||
|
||||
impl_arc_ffi!(ComputedValues => ServoStyleContext
|
||||
[Servo_StyleContext_AddRef, Servo_StyleContext_Release]);
|
||||
|
||||
impl_arc_ffi!(Locked<PropertyDeclarationBlock> => RawServoDeclarationBlock
|
||||
[Servo_DeclarationBlock_AddRef, Servo_DeclarationBlock_Release]);
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ use gecko_bindings::structs::nsStyleTransformMatrix;
|
|||
use gecko_bindings::structs::nsTArray;
|
||||
type nsACString_internal = nsACString;
|
||||
type nsAString_internal = nsAString;
|
||||
pub type ServoStyleContextBorrowed<'a> = &'a ServoStyleContext;
|
||||
pub type ServoStyleContextBorrowedOrNull<'a> = Option<&'a ::properties::ComputedValues>;
|
||||
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
||||
use gecko_bindings::structs::mozilla::css::ErrorReporter;
|
||||
use gecko_bindings::structs::mozilla::css::ImageValue;
|
||||
|
@ -215,6 +217,9 @@ use gecko_bindings::structs::nsresult;
|
|||
use gecko_bindings::structs::Loader;
|
||||
use gecko_bindings::structs::LoaderReusableStyleSheets;
|
||||
use gecko_bindings::structs::ServoStyleSheet;
|
||||
use gecko_bindings::structs::ServoComputedValues;
|
||||
use gecko_bindings::structs::ServoStyleContext;
|
||||
use gecko_bindings::structs::ServoStyleContextStrong;
|
||||
use gecko_bindings::structs::EffectCompositor_CascadeLevel;
|
||||
use gecko_bindings::structs::UpdateAnimationsTasks;
|
||||
use gecko_bindings::structs::ParsingMode;
|
||||
|
@ -317,8 +322,6 @@ pub type RawServoStyleSheetContentsBorrowedOrNull<'a> = Option<&'a RawServoStyle
|
|||
pub type ServoComputedValuesStrong = ::gecko_bindings::sugar::ownership::Strong<ServoComputedValues>;
|
||||
pub type ServoComputedValuesBorrowed<'a> = &'a ServoComputedValues;
|
||||
pub type ServoComputedValuesBorrowedOrNull<'a> = Option<&'a ServoComputedValues>;
|
||||
enum ServoComputedValuesVoid { }
|
||||
pub struct ServoComputedValues(ServoComputedValuesVoid);
|
||||
pub type RawServoDeclarationBlockStrong = ::gecko_bindings::sugar::ownership::Strong<RawServoDeclarationBlock>;
|
||||
pub type RawServoDeclarationBlockBorrowed<'a> = &'a RawServoDeclarationBlock;
|
||||
pub type RawServoDeclarationBlockBorrowedOrNull<'a> = Option<&'a RawServoDeclarationBlock>;
|
||||
|
@ -528,6 +531,19 @@ extern "C" {
|
|||
pub fn Gecko_DestroyAnonymousContentList(anon_content:
|
||||
*mut nsTArray<*mut nsIContent>);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ServoStyleContext_Init(context: *mut ServoStyleContext,
|
||||
parent_context:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed,
|
||||
values: ServoComputedValuesStrong,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ServoStyleContext_Destroy(context: *mut ServoStyleContext);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ConstructStyleChildrenIterator(aElement:
|
||||
RawGeckoElementBorrowed,
|
||||
|
@ -755,9 +771,9 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_UpdateAnimations(aElementOrPseudo: RawGeckoElementBorrowed,
|
||||
aOldComputedValues:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
aComputedValues:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
aTasks: UpdateAnimationsTasks);
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -1957,10 +1973,10 @@ extern "C" {
|
|||
pub fn Servo_StyleSet_ResolveForDeclarations(set:
|
||||
RawServoStyleSetBorrowed,
|
||||
parent_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
declarations:
|
||||
RawServoDeclarationBlockBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_MightHaveAttributeDependency(set:
|
||||
|
@ -2661,23 +2677,27 @@ extern "C" {
|
|||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
pseudo_type:
|
||||
CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
set:
|
||||
RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_Inherit(set: RawServoStyleSetBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
target: InheritTarget)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_GetVisitedStyle(values:
|
||||
ServoComputedValuesBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_GetStyleBits(values:
|
||||
|
@ -2697,6 +2717,16 @@ extern "C" {
|
|||
rules:
|
||||
RawGeckoServoStyleRuleListBorrowedMut);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleContext_NewContext(values: ServoComputedValuesBorrowed,
|
||||
parent:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
pres_context:
|
||||
RawGeckoPresContextBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom)
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_Initialize(dummy_url_data: *mut RawGeckoURLExtraData);
|
||||
}
|
||||
|
@ -2716,20 +2746,22 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||
set: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
is_probe: bool,
|
||||
pseudo_tag: *mut nsIAtom, is_probe: bool,
|
||||
inherited_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
parent_style_context:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
set: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_SetExplicitStyle(element: RawGeckoElementBorrowed,
|
||||
primary_style: ServoComputedValuesBorrowed);
|
||||
primary_style: ServoStyleContextBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_HasAuthorSpecifiedRules(element: RawGeckoElementBorrowed,
|
||||
|
@ -2739,11 +2771,14 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style_context:
|
||||
ServoStyleContextBorrowedOrNull,
|
||||
rule_inclusion: StyleRuleInclusion,
|
||||
snapshots:
|
||||
*const ServoElementSnapshotTable,
|
||||
set: RawServoStyleSetBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_TraverseSubtree(root: RawGeckoElementBorrowed,
|
||||
|
@ -2765,12 +2800,12 @@ extern "C" {
|
|||
element:
|
||||
RawGeckoElementBorrowed,
|
||||
existing_style:
|
||||
ServoComputedValuesBorrowed,
|
||||
ServoStyleContextBorrowed,
|
||||
snapshots:
|
||||
*const ServoElementSnapshotTable,
|
||||
pseudo_type:
|
||||
CSSPseudoElementType)
|
||||
-> ServoComputedValuesStrong;
|
||||
-> ServoStyleContextStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_SerializeFontValueForCanvas(declarations:
|
||||
|
|
|
@ -689,6 +689,45 @@ impl PseudoElement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
||||
#[inline]
|
||||
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
||||
match *self {
|
||||
PseudoElement::After => CSSPseudoElementType::after,
|
||||
PseudoElement::Before => CSSPseudoElementType::before,
|
||||
PseudoElement::Backdrop => CSSPseudoElementType::backdrop,
|
||||
PseudoElement::Cue => CSSPseudoElementType::cue,
|
||||
PseudoElement::FirstLetter => CSSPseudoElementType::firstLetter,
|
||||
PseudoElement::FirstLine => CSSPseudoElementType::firstLine,
|
||||
PseudoElement::MozSelection => CSSPseudoElementType::mozSelection,
|
||||
PseudoElement::MozFocusInner => CSSPseudoElementType::mozFocusInner,
|
||||
PseudoElement::MozFocusOuter => CSSPseudoElementType::mozFocusOuter,
|
||||
PseudoElement::MozListBullet => CSSPseudoElementType::mozListBullet,
|
||||
PseudoElement::MozListNumber => CSSPseudoElementType::mozListNumber,
|
||||
PseudoElement::MozMathAnonymous => CSSPseudoElementType::mozMathAnonymous,
|
||||
PseudoElement::MozNumberWrapper => CSSPseudoElementType::mozNumberWrapper,
|
||||
PseudoElement::MozNumberText => CSSPseudoElementType::mozNumberText,
|
||||
PseudoElement::MozNumberSpinBox => CSSPseudoElementType::mozNumberSpinBox,
|
||||
PseudoElement::MozNumberSpinUp => CSSPseudoElementType::mozNumberSpinUp,
|
||||
PseudoElement::MozNumberSpinDown => CSSPseudoElementType::mozNumberSpinDown,
|
||||
PseudoElement::MozProgressBar => CSSPseudoElementType::mozProgressBar,
|
||||
PseudoElement::MozRangeTrack => CSSPseudoElementType::mozRangeTrack,
|
||||
PseudoElement::MozRangeProgress => CSSPseudoElementType::mozRangeProgress,
|
||||
PseudoElement::MozRangeThumb => CSSPseudoElementType::mozRangeThumb,
|
||||
PseudoElement::MozMeterBar => CSSPseudoElementType::mozMeterBar,
|
||||
PseudoElement::MozPlaceholder => CSSPseudoElementType::mozPlaceholder,
|
||||
PseudoElement::Placeholder => CSSPseudoElementType::placeholder,
|
||||
PseudoElement::MozColorSwatch => CSSPseudoElementType::mozColorSwatch,
|
||||
_ => CSSPseudoElementType::NotPseudo
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a PseudoInfo for a pseudo
|
||||
pub fn pseudo_info(&self) -> (*mut structs::nsIAtom, CSSPseudoElementType) {
|
||||
(self.atom().as_ptr(), self.pseudo_type())
|
||||
}
|
||||
|
||||
/// Construct a pseudo-element from an anonymous box `Atom`.
|
||||
#[inline]
|
||||
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -107,6 +107,25 @@ impl PseudoElement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
||||
#[inline]
|
||||
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
||||
match *self {
|
||||
% for pseudo in PSEUDOS:
|
||||
% if not pseudo.is_anon_box():
|
||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::${pseudo.original_ident},
|
||||
% endif
|
||||
% endfor
|
||||
_ => CSSPseudoElementType::NotPseudo
|
||||
}
|
||||
}
|
||||
|
||||
/// Get a PseudoInfo for a pseudo
|
||||
pub fn pseudo_info(&self) -> (*mut structs::nsIAtom, CSSPseudoElementType) {
|
||||
(self.atom().as_ptr(), self.pseudo_type())
|
||||
}
|
||||
|
||||
/// Construct a pseudo-element from an anonymous box `Atom`.
|
||||
#[inline]
|
||||
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
use gecko_bindings::bindings;
|
||||
use gecko_bindings::structs;
|
||||
use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
|
||||
use gecko_bindings::sugar::ownership::FFIArcHelpers;
|
||||
use matching::{StyleChange, StyleDifference};
|
||||
use properties::ComputedValues;
|
||||
use std::ops::{BitAnd, BitOr, BitOrAssign, Not};
|
||||
|
@ -56,7 +55,7 @@ impl GeckoRestyleDamage {
|
|||
let mut any_style_changed: bool = false;
|
||||
let hint = unsafe {
|
||||
bindings::Gecko_CalcStyleDifference(context,
|
||||
new_style.as_borrowed(),
|
||||
&new_style,
|
||||
&mut any_style_changed)
|
||||
};
|
||||
let change = if any_style_changed { StyleChange::Changed } else { StyleChange::Unchanged };
|
||||
|
|
|
@ -64,7 +64,7 @@ use gecko_bindings::structs::EffectCompositor_CascadeLevel as CascadeLevel;
|
|||
use gecko_bindings::structs::NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE;
|
||||
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS;
|
||||
use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme;
|
||||
use gecko_bindings::sugar::ownership::{FFIArcHelpers, HasArcFFI, HasSimpleFFI};
|
||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI};
|
||||
use logical_geometry::WritingMode;
|
||||
use media_queries::Device;
|
||||
use properties::{ComputedValues, parse_style_attribute};
|
||||
|
@ -1101,10 +1101,9 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
let computed_data = self.borrow_data();
|
||||
let computed_values =
|
||||
computed_data.as_ref().map(|d| d.styles.primary());
|
||||
let computed_values_opt =
|
||||
computed_values.map(|v| v.as_borrowed());
|
||||
let before_change_values =
|
||||
before_change_style.as_ref().map(|v| v.as_borrowed());
|
||||
before_change_style.as_ref().map(|x| &**x);
|
||||
let computed_values_opt = computed_values.as_ref().map(|x| &***x);
|
||||
unsafe {
|
||||
Gecko_UpdateAnimations(self.0,
|
||||
before_change_values,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue