mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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,
|
||||
|
|
|
@ -46,7 +46,6 @@ use gecko_bindings::structs;
|
|||
use gecko_bindings::structs::nsCSSPropertyID;
|
||||
use gecko_bindings::structs::nsStyleVariables;
|
||||
use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
|
||||
use gecko_bindings::sugar::ownership::HasArcFFI;
|
||||
use gecko::values::convert_nscolor_to_rgba;
|
||||
use gecko::values::convert_rgba_to_nscolor;
|
||||
use gecko::values::GeckoStyleCoordConvertible;
|
||||
|
@ -58,7 +57,7 @@ use properties::computed_value_flags::ComputedValueFlags;
|
|||
use properties::{longhands, FontComputationData, Importance, LonghandId};
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
|
||||
use rule_tree::StrongRuleNode;
|
||||
use std::mem::{forget, transmute, zeroed};
|
||||
use std::mem::{forget, uninitialized, transmute, zeroed};
|
||||
use std::{cmp, ops, ptr};
|
||||
use stylearc::{Arc, RawOffsetArc};
|
||||
use values::{Auto, CustomIdent, Either, KeyframesName};
|
||||
|
@ -74,11 +73,27 @@ pub mod style_structs {
|
|||
}
|
||||
|
||||
|
||||
pub use ::gecko_bindings::structs::mozilla::ServoComputedValues2 as ComputedValuesInner;
|
||||
pub type ComputedValuesInner = ::gecko_bindings::structs::ServoComputedValues;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ComputedValues {
|
||||
pub inner: ComputedValuesInner
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
pub struct ComputedValues(::gecko_bindings::structs::mozilla::ServoStyleContext);
|
||||
|
||||
impl Drop for ComputedValues {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
bindings::Gecko_ServoStyleContext_Destroy(&mut self.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Sync for ComputedValues {}
|
||||
unsafe impl Send for ComputedValues {}
|
||||
|
||||
impl Clone for ComputedValues {
|
||||
fn clone(&self) -> Self {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
impl Clone for ComputedValuesInner {
|
||||
|
@ -97,6 +112,9 @@ impl Clone for ComputedValuesInner {
|
|||
}
|
||||
}
|
||||
|
||||
pub type PseudoInfo = (*mut structs::nsIAtom, structs::CSSPseudoElementType);
|
||||
pub type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
|
||||
|
||||
impl ComputedValuesInner {
|
||||
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||
writing_mode: WritingMode,
|
||||
|
@ -134,21 +152,42 @@ impl ComputedValuesInner {
|
|||
% endfor
|
||||
}
|
||||
}
|
||||
pub fn to_outer(self) -> Arc<ComputedValues> {
|
||||
Arc::new(ComputedValues {inner: self})
|
||||
pub fn to_outer(self, device: &Device, parent: ParentStyleContextInfo,
|
||||
info: Option<PseudoInfo>) -> Arc<ComputedValues> {
|
||||
let (tag, ty) = if let Some(info) = info {
|
||||
info
|
||||
} else {
|
||||
(ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo)
|
||||
};
|
||||
|
||||
unsafe { Self::to_outer_from_arc(Arc::new(self), device.pres_context(), parent, ty, tag) }
|
||||
}
|
||||
|
||||
pub unsafe fn to_outer_from_arc(s: Arc<Self>, pres_context: bindings::RawGeckoPresContextBorrowed,
|
||||
parent: ParentStyleContextInfo,
|
||||
pseudo_ty: structs::CSSPseudoElementType,
|
||||
pseudo_tag: *mut structs::nsIAtom) -> Arc<ComputedValues> {
|
||||
use gecko_bindings::sugar::ownership::FFIArcHelpers;
|
||||
let arc = unsafe {
|
||||
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
|
||||
bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _, parent, pres_context,
|
||||
s.into_strong(), pseudo_ty, pseudo_tag);
|
||||
arc
|
||||
};
|
||||
arc
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::Deref for ComputedValues {
|
||||
type Target = ComputedValuesInner;
|
||||
fn deref(&self) -> &ComputedValuesInner {
|
||||
&self.inner
|
||||
unsafe { &*self.0.mSource.mRawPtr }
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for ComputedValues {
|
||||
fn deref_mut(&mut self) -> &mut ComputedValuesInner {
|
||||
&mut self.inner
|
||||
unsafe { &mut *self.0.mSource.mRawPtr }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,12 +236,12 @@ impl ComputedValuesInner {
|
|||
}
|
||||
|
||||
/// Gets a reference to the visited style, if any.
|
||||
pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> {
|
||||
self.visited_style.as_ref().map(|x| &***x)
|
||||
pub fn get_visited_style(&self) -> Option< & ComputedValues> {
|
||||
self.visited_style.as_ref().map(|x| &**x)
|
||||
}
|
||||
|
||||
/// Gets a reference to the visited style. Panic if no visited style exists.
|
||||
pub fn visited_style(&self) -> &ComputedValuesInner {
|
||||
pub fn visited_style(&self) -> &ComputedValues {
|
||||
self.get_visited_style().unwrap()
|
||||
}
|
||||
|
||||
|
@ -4801,7 +4840,7 @@ clip-path
|
|||
#[allow(non_snake_case, unused_variables)]
|
||||
pub unsafe extern "C" fn Servo_GetStyle${style_struct.gecko_name}(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull) -> *const ${style_struct.gecko_ffi_name} {
|
||||
ComputedValues::arc_from_borrowed(&computed_values).unwrap().get_${style_struct.name_lower}().get_gecko()
|
||||
computed_values.unwrap().get_${style_struct.name_lower}().get_gecko()
|
||||
as *const ${style_struct.gecko_ffi_name}
|
||||
}
|
||||
</%def>
|
||||
|
|
|
@ -1871,9 +1871,14 @@ pub mod style_structs {
|
|||
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use gecko_properties::ComputedValues;
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use gecko_properties::ComputedValuesInner;
|
||||
pub use gecko_properties::{ComputedValues, ComputedValuesInner, ParentStyleContextInfo, PseudoInfo};
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
/// Servo doesn't have style contexts so this is extraneous info
|
||||
pub type PseudoInfo = ();
|
||||
#[cfg(feature = "servo")]
|
||||
/// Servo doesn't have style contexts so this is extraneous info
|
||||
pub type ParentStyleContextInfo = ();
|
||||
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
|
@ -1970,7 +1975,8 @@ impl ops::DerefMut for ComputedValues {
|
|||
#[cfg(feature = "servo")]
|
||||
impl ComputedValuesInner {
|
||||
/// Convert to an Arc<ComputedValues>
|
||||
pub fn to_outer(self) -> Arc<ComputedValues> {
|
||||
pub fn to_outer(self, _: &Device, _: ParentStyleContextInfo,
|
||||
_: Option<PseudoInfo>) -> Arc<ComputedValues> {
|
||||
Arc::new(ComputedValues {inner: self})
|
||||
}
|
||||
|
||||
|
@ -2011,13 +2017,13 @@ impl ComputedValuesInner {
|
|||
}
|
||||
|
||||
/// Gets a reference to the visited style, if any.
|
||||
pub fn get_visited_style(&self) -> Option< & ComputedValuesInner> {
|
||||
self.visited_style.as_ref().map(|x| &***x)
|
||||
pub fn get_visited_style(&self) -> Option< & ComputedValues> {
|
||||
self.visited_style.as_ref().map(|x| &**x)
|
||||
}
|
||||
|
||||
/// Gets a reference to the visited style. Panic if no visited style exists.
|
||||
pub fn visited_style(&self) -> &ComputedValuesInner {
|
||||
self.get_visited_style().as_ref().map(|x| &**x).unwrap()
|
||||
pub fn visited_style(&self) -> &ComputedValues {
|
||||
self.get_visited_style().unwrap()
|
||||
}
|
||||
|
||||
/// Clone the visited style. Used for inheriting parent styles in
|
||||
|
|
|
@ -166,6 +166,9 @@ impl PseudoElement {
|
|||
pub fn canonical(&self) -> PseudoElement {
|
||||
self.clone()
|
||||
}
|
||||
|
||||
/// Stub, only Gecko needs this
|
||||
pub fn pseudo_info(&self) -> () { () }
|
||||
}
|
||||
|
||||
/// The type used for storing pseudo-class string arguments.
|
||||
|
|
|
@ -47,7 +47,7 @@ pub struct PrimaryStyle {
|
|||
fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
|
||||
where
|
||||
E: TElement,
|
||||
F: FnOnce(Option<&ComputedValuesInner>, Option<&ComputedValuesInner>) -> R,
|
||||
F: FnOnce(Option<&ComputedValues>, Option<&ComputedValuesInner>) -> R,
|
||||
{
|
||||
let parent_el = element.inheritance_parent();
|
||||
let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
|
||||
|
@ -72,7 +72,7 @@ where
|
|||
layout_parent_style = Some(layout_parent_data.styles.primary());
|
||||
}
|
||||
|
||||
f(parent_style.map(|s| &***s), layout_parent_style.map(|s| &***s))
|
||||
f(parent_style.map(|x| &**x), layout_parent_style.map(|s| &***s))
|
||||
}
|
||||
|
||||
impl<'a, 'ctx, 'le, E> StyleResolverForElement<'a, 'ctx, 'le, E>
|
||||
|
@ -98,7 +98,7 @@ where
|
|||
/// Resolve just the style of a given element.
|
||||
pub fn resolve_primary_style(
|
||||
&mut self,
|
||||
parent_style: Option<&ComputedValuesInner>,
|
||||
parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
) -> PrimaryStyle {
|
||||
let primary_results =
|
||||
|
@ -119,6 +119,7 @@ where
|
|||
relevant_link_found ||
|
||||
parent_style.and_then(|s| s.get_visited_style()).is_some();
|
||||
|
||||
let pseudo = self.element.implemented_pseudo_element();
|
||||
if should_compute_visited_style {
|
||||
visited_style = Some(self.cascade_style(
|
||||
visited_rules.as_ref().or(Some(&primary_results.rule_node)),
|
||||
|
@ -126,17 +127,16 @@ where
|
|||
parent_style,
|
||||
layout_parent_style,
|
||||
CascadeVisitedMode::Visited,
|
||||
/* pseudo = */ None,
|
||||
/* pseudo = */ pseudo.as_ref(),
|
||||
));
|
||||
}
|
||||
|
||||
let style = self.cascade_style(
|
||||
Some(&primary_results.rule_node),
|
||||
visited_style,
|
||||
parent_style,
|
||||
layout_parent_style,
|
||||
CascadeVisitedMode::Unvisited,
|
||||
/* pseudo = */ None,
|
||||
/* pseudo = */ pseudo.as_ref(),
|
||||
);
|
||||
|
||||
PrimaryStyle { style, }
|
||||
|
@ -146,7 +146,7 @@ where
|
|||
/// Resolve the style of a given element, and all its eager pseudo-elements.
|
||||
pub fn resolve_style(
|
||||
&mut self,
|
||||
parent_style: Option<&ComputedValuesInner>,
|
||||
parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
) -> ElementStyles {
|
||||
use properties::longhands::display::computed_value::T as display;
|
||||
|
@ -215,7 +215,7 @@ where
|
|||
fn cascade_style_and_visited(
|
||||
&mut self,
|
||||
inputs: CascadeInputs,
|
||||
parent_style: Option<&ComputedValuesInner>,
|
||||
parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
pseudo: Option<&PseudoElement>,
|
||||
) -> Arc<ComputedValues> {
|
||||
|
@ -462,7 +462,7 @@ where
|
|||
&mut self,
|
||||
rules: Option<&StrongRuleNode>,
|
||||
style_if_visited: Option<Arc<ComputedValues>>,
|
||||
mut parent_style: Option<&ComputedValuesInner>,
|
||||
mut parent_style: Option<&ComputedValues>,
|
||||
layout_parent_style: Option<&ComputedValuesInner>,
|
||||
cascade_visited: CascadeVisitedMode,
|
||||
pseudo: Option<&PseudoElement>,
|
||||
|
@ -485,12 +485,17 @@ where
|
|||
cascade_flags.insert(IS_ROOT_ELEMENT);
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
let parent_style_context = parent_style;
|
||||
#[cfg(feature = "servo")]
|
||||
let parent_style_context = ();
|
||||
|
||||
let values =
|
||||
cascade(
|
||||
self.context.shared.stylist.device(),
|
||||
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
|
||||
&self.context.shared.guards,
|
||||
parent_style,
|
||||
parent_style.map(|x| &**x),
|
||||
layout_parent_style,
|
||||
style_if_visited,
|
||||
Some(&mut cascade_info),
|
||||
|
@ -500,6 +505,18 @@ where
|
|||
);
|
||||
|
||||
cascade_info.finish(&self.element.as_node());
|
||||
values.to_outer()
|
||||
|
||||
// In case of NAC like ::placeholder we style it via
|
||||
// cascade_primary without a PseudoElement, but
|
||||
// the element itself is a pseudo, so try to use that
|
||||
// when `pseudo` is unset
|
||||
let pseudo_info = if let Some(pseudo) = pseudo {
|
||||
Some(pseudo.pseudo_info())
|
||||
} else {
|
||||
self.element.implemented_pseudo_element().map(|x| x.pseudo_info())
|
||||
};
|
||||
values.to_outer(self.context.shared.stylist.device(),
|
||||
parent_style_context,
|
||||
pseudo_info)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use invalidation::element::invalidation_map::InvalidationMap;
|
|||
use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey};
|
||||
use media_queries::Device;
|
||||
use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner};
|
||||
use properties::{AnimationRules, PropertyDeclarationBlock};
|
||||
use properties::{AnimationRules, PropertyDeclarationBlock, PseudoInfo, ParentStyleContextInfo};
|
||||
#[cfg(feature = "servo")]
|
||||
use properties::INHERIT_ALL;
|
||||
use rule_tree::{CascadeLevel, RuleTree, StyleSource};
|
||||
|
@ -601,7 +601,9 @@ impl Stylist {
|
|||
pseudo: &PseudoElement,
|
||||
parent: Option<&ComputedValuesInner>,
|
||||
cascade_flags: CascadeFlags,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Arc<ComputedValues> {
|
||||
debug_assert!(pseudo.is_precomputed());
|
||||
|
||||
|
@ -638,7 +640,8 @@ impl Stylist {
|
|||
None,
|
||||
font_metrics,
|
||||
cascade_flags,
|
||||
self.quirks_mode).to_outer()
|
||||
self.quirks_mode).to_outer(self.device(), parent_style_context,
|
||||
Some(pseudo_info))
|
||||
}
|
||||
|
||||
/// Returns the style for an anonymous box of the given type.
|
||||
|
@ -675,7 +678,7 @@ impl Stylist {
|
|||
cascade_flags.insert(INHERIT_ALL);
|
||||
}
|
||||
self.precomputed_values_for_pseudo(guards, &pseudo, Some(parent_style), cascade_flags,
|
||||
&ServoMetricsProvider)
|
||||
&ServoMetricsProvider, (), ())
|
||||
}
|
||||
|
||||
/// Computes a pseudo-element style lazily during layout.
|
||||
|
@ -692,7 +695,9 @@ impl Stylist {
|
|||
rule_inclusion: RuleInclusion,
|
||||
parent_style: &ComputedValuesInner,
|
||||
is_probe: bool,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Option<Arc<ComputedValues>>
|
||||
where E: TElement,
|
||||
{
|
||||
|
@ -701,7 +706,9 @@ impl Stylist {
|
|||
self.compute_pseudo_element_style_with_inputs(&cascade_inputs,
|
||||
guards,
|
||||
parent_style,
|
||||
font_metrics)
|
||||
font_metrics,
|
||||
pseudo_info,
|
||||
parent_style_context)
|
||||
}
|
||||
|
||||
/// Computes a pseudo-element style lazily using the given CascadeInputs.
|
||||
|
@ -712,7 +719,9 @@ impl Stylist {
|
|||
inputs: &CascadeInputs,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: &ComputedValuesInner,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Option<Arc<ComputedValues>>
|
||||
{
|
||||
// We may have only visited rules in cases when we are actually
|
||||
|
@ -734,7 +743,7 @@ impl Stylist {
|
|||
// We want to use the visited bits (if any) from our parent style as
|
||||
// our parent.
|
||||
let inherited_style =
|
||||
parent_style.get_visited_style().unwrap_or(parent_style);
|
||||
parent_style.get_visited_style().map(|x| &**x).unwrap_or(parent_style);
|
||||
|
||||
// FIXME(emilio): The lack of layout_parent_style here could be
|
||||
// worrying, but we're probably dropping the display fixup for
|
||||
|
@ -751,7 +760,8 @@ impl Stylist {
|
|||
None,
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode).to_outer();
|
||||
self.quirks_mode).to_outer(self.device(), parent_style_context,
|
||||
Some(pseudo_info.clone()));
|
||||
|
||||
Some(computed)
|
||||
} else {
|
||||
|
@ -775,7 +785,9 @@ impl Stylist {
|
|||
None,
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode).to_outer())
|
||||
self.quirks_mode).to_outer(self.device(),
|
||||
parent_style_context,
|
||||
Some(pseudo_info)))
|
||||
}
|
||||
|
||||
/// Computes the cascade inputs for a lazily-cascaded pseudo-element.
|
||||
|
@ -1313,7 +1325,8 @@ impl Stylist {
|
|||
pub fn compute_for_declarations(&self,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: &ComputedValuesInner,
|
||||
declarations: Arc<Locked<PropertyDeclarationBlock>>)
|
||||
declarations: Arc<Locked<PropertyDeclarationBlock>>,
|
||||
parent_style_context: ParentStyleContextInfo)
|
||||
-> Arc<ComputedValues> {
|
||||
use font_metrics::get_metrics_provider_for_product;
|
||||
|
||||
|
@ -1337,7 +1350,7 @@ impl Stylist {
|
|||
None,
|
||||
&metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode).to_outer()
|
||||
self.quirks_mode).to_outer(self.device(), parent_style_context, None)
|
||||
}
|
||||
|
||||
/// Accessor for a shared reference to the device.
|
||||
|
|
|
@ -484,7 +484,7 @@ where
|
|||
let primary_style =
|
||||
StyleResolverForElement::new(*ancestor, context, rule_inclusion)
|
||||
.resolve_primary_style(
|
||||
style.as_ref().map(|s| &***s),
|
||||
style.as_ref().map(|s| &**s),
|
||||
layout_parent_style.as_ref().map(|s| &***s)
|
||||
);
|
||||
|
||||
|
@ -501,7 +501,7 @@ where
|
|||
context.thread_local.bloom_filter.assert_complete(element);
|
||||
StyleResolverForElement::new(element, context, rule_inclusion)
|
||||
.resolve_style(
|
||||
style.as_ref().map(|s| &***s),
|
||||
style.as_ref().map(|s| &**s),
|
||||
layout_parent_style.as_ref().map(|s| &***s)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue