mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #17773 - emilio:removing-the-ugly, r=manishearth
style: Cleanup post #17767 Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1381764 <!-- 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/17773) <!-- Reviewable:end -->
This commit is contained in:
commit
66e06578ee
27 changed files with 3431 additions and 2695 deletions
|
@ -416,7 +416,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
&style_pseudo,
|
&style_pseudo,
|
||||||
Some(data.styles.primary()),
|
Some(data.styles.primary()),
|
||||||
CascadeFlags::empty(),
|
CascadeFlags::empty(),
|
||||||
&ServoMetricsProvider, (), ())
|
&ServoMetricsProvider)
|
||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
PseudoElementCascadeType::Lazy => {
|
PseudoElementCascadeType::Lazy => {
|
||||||
|
@ -428,7 +428,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
RuleInclusion::All,
|
RuleInclusion::All,
|
||||||
data.styles.primary(),
|
data.styles.primary(),
|
||||||
/* is_probe = */ false,
|
/* is_probe = */ false,
|
||||||
&ServoMetricsProvider, (), ())
|
&ServoMetricsProvider)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.clone()
|
.clone()
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use context::SharedStyleContext;
|
||||||
use dom::OpaqueNode;
|
use dom::OpaqueNode;
|
||||||
use euclid::Point2D;
|
use euclid::Point2D;
|
||||||
use font_metrics::FontMetricsProvider;
|
use font_metrics::FontMetricsProvider;
|
||||||
use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner, Importance};
|
use properties::{self, CascadeFlags, ComputedValues, Importance};
|
||||||
use properties::animated_properties::{AnimatableLonghand, AnimatedProperty, TransitionProperty};
|
use properties::animated_properties::{AnimatableLonghand, AnimatedProperty, TransitionProperty};
|
||||||
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
|
use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
|
||||||
use properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
|
use properties::longhands::animation_iteration_count::single_value::computed_value::T as AnimationIterationCount;
|
||||||
|
@ -347,8 +347,8 @@ impl PropertyAnimation {
|
||||||
fn from_animatable_longhand(animatable_longhand: &AnimatableLonghand,
|
fn from_animatable_longhand(animatable_longhand: &AnimatableLonghand,
|
||||||
timing_function: TimingFunction,
|
timing_function: TimingFunction,
|
||||||
duration: Time,
|
duration: Time,
|
||||||
old_style: &ComputedValuesInner,
|
old_style: &ComputedValues,
|
||||||
new_style: &ComputedValuesInner)
|
new_style: &ComputedValues)
|
||||||
-> Option<PropertyAnimation> {
|
-> Option<PropertyAnimation> {
|
||||||
let animated_property = AnimatedProperty::from_animatable_longhand(animatable_longhand,
|
let animated_property = AnimatedProperty::from_animatable_longhand(animatable_longhand,
|
||||||
old_style,
|
old_style,
|
||||||
|
@ -480,10 +480,10 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>
|
||||||
|
|
||||||
fn compute_style_for_animation_step(context: &SharedStyleContext,
|
fn compute_style_for_animation_step(context: &SharedStyleContext,
|
||||||
step: &KeyframesStep,
|
step: &KeyframesStep,
|
||||||
previous_style: &ComputedValuesInner,
|
previous_style: &ComputedValues,
|
||||||
style_from_cascade: &ComputedValuesInner,
|
style_from_cascade: &Arc<ComputedValues>,
|
||||||
font_metrics_provider: &FontMetricsProvider)
|
font_metrics_provider: &FontMetricsProvider)
|
||||||
-> ComputedValuesInner {
|
-> Arc<ComputedValues> {
|
||||||
match step.value {
|
match step.value {
|
||||||
KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
|
KeyframesStepValue::ComputedValues => style_from_cascade.clone(),
|
||||||
KeyframesStepValue::Declarations { block: ref declarations } => {
|
KeyframesStepValue::Declarations { block: ref declarations } => {
|
||||||
|
@ -502,10 +502,11 @@ fn compute_style_for_animation_step(context: &SharedStyleContext,
|
||||||
// as existing browsers don't appear to animate visited styles.
|
// as existing browsers don't appear to animate visited styles.
|
||||||
let computed =
|
let computed =
|
||||||
properties::apply_declarations(context.stylist.device(),
|
properties::apply_declarations(context.stylist.device(),
|
||||||
|
/* pseudo = */ None,
|
||||||
previous_style.rules(),
|
previous_style.rules(),
|
||||||
iter,
|
iter,
|
||||||
previous_style,
|
Some(previous_style),
|
||||||
previous_style,
|
Some(previous_style),
|
||||||
/* cascade_info = */ None,
|
/* cascade_info = */ None,
|
||||||
/* visited_style = */ None,
|
/* visited_style = */ None,
|
||||||
font_metrics_provider,
|
font_metrics_provider,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use data::ElementData;
|
||||||
use element_state::ElementState;
|
use element_state::ElementState;
|
||||||
use font_metrics::FontMetricsProvider;
|
use font_metrics::FontMetricsProvider;
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use properties::{AnimationRules, ComputedValues, ComputedValuesInner, PropertyDeclarationBlock};
|
use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock};
|
||||||
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
|
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
|
||||||
#[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty;
|
#[cfg(feature = "gecko")] use properties::animated_properties::TransitionProperty;
|
||||||
use rule_tree::CascadeLevel;
|
use rule_tree::CascadeLevel;
|
||||||
|
@ -437,7 +437,7 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
|
||||||
fn may_generate_pseudo(
|
fn may_generate_pseudo(
|
||||||
&self,
|
&self,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
_primary_style: &ComputedValuesInner,
|
_primary_style: &ComputedValues,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
// ::before/::after are always supported for now, though we could try to
|
// ::before/::after are always supported for now, though we could try to
|
||||||
// optimize out leaf elements.
|
// optimize out leaf elements.
|
||||||
|
|
|
@ -16,7 +16,7 @@ use gecko_bindings::structs::nsIDocument;
|
||||||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
|
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||||
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||||
use media_queries::{Device, MediaList};
|
use media_queries::{Device, MediaList};
|
||||||
use properties::ComputedValuesInner;
|
use properties::ComputedValues;
|
||||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||||
use stylearc::Arc;
|
use stylearc::Arc;
|
||||||
use stylesheet_set::StylesheetSet;
|
use stylesheet_set::StylesheetSet;
|
||||||
|
@ -188,8 +188,8 @@ impl PerDocumentStyleDataImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the default computed values for this document.
|
/// Get the default computed values for this document.
|
||||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
|
||||||
self.stylist.device().default_computed_values()
|
self.stylist.device().default_computed_values_arc()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear the stylist. This will be a no-op if the stylist is
|
/// Clear the stylist. This will be a no-op if the stylist is
|
||||||
|
|
|
@ -1971,6 +1971,12 @@ extern "C" {
|
||||||
RawServoDeclarationBlockBorrowed)
|
RawServoDeclarationBlockBorrowed)
|
||||||
-> ServoStyleContextStrong;
|
-> ServoStyleContextStrong;
|
||||||
}
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_StyleContext_AddRef(ctx: ServoStyleContextBorrowed);
|
||||||
|
}
|
||||||
|
extern "C" {
|
||||||
|
pub fn Servo_StyleContext_Release(ctx: ServoStyleContextBorrowed);
|
||||||
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_StyleSet_MightHaveAttributeDependency(set:
|
pub fn Servo_StyleSet_MightHaveAttributeDependency(set:
|
||||||
RawServoStyleSetBorrowed,
|
RawServoStyleSetBorrowed,
|
||||||
|
@ -2289,14 +2295,14 @@ extern "C" {
|
||||||
pub fn Servo_GetComputedKeyframeValues(keyframes:
|
pub fn Servo_GetComputedKeyframeValues(keyframes:
|
||||||
RawGeckoKeyframeListBorrowed,
|
RawGeckoKeyframeListBorrowed,
|
||||||
element: RawGeckoElementBorrowed,
|
element: RawGeckoElementBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoStyleContextBorrowed,
|
||||||
set: RawServoStyleSetBorrowed,
|
set: RawServoStyleSetBorrowed,
|
||||||
result:
|
result:
|
||||||
RawGeckoComputedKeyframeValuesListBorrowedMut);
|
RawGeckoComputedKeyframeValuesListBorrowedMut);
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ComputedValues_ExtractAnimationValue(computed_values:
|
pub fn Servo_ComputedValues_ExtractAnimationValue(computed_values:
|
||||||
ServoComputedValuesBorrowed,
|
ServoStyleContextBorrowed,
|
||||||
property:
|
property:
|
||||||
nsCSSPropertyID)
|
nsCSSPropertyID)
|
||||||
-> RawServoAnimationValueStrong;
|
-> RawServoAnimationValueStrong;
|
||||||
|
@ -2336,7 +2342,7 @@ extern "C" {
|
||||||
pub fn Servo_GetAnimationValues(declarations:
|
pub fn Servo_GetAnimationValues(declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
element: RawGeckoElementBorrowed,
|
element: RawGeckoElementBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoStyleContextBorrowed,
|
||||||
style_set: RawServoStyleSetBorrowed,
|
style_set: RawServoStyleSetBorrowed,
|
||||||
animation_values:
|
animation_values:
|
||||||
RawGeckoServoAnimationValueListBorrowedMut);
|
RawGeckoServoAnimationValueListBorrowedMut);
|
||||||
|
@ -2419,7 +2425,7 @@ extern "C" {
|
||||||
pub fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
pub fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
||||||
declarations:
|
declarations:
|
||||||
RawServoDeclarationBlockBorrowed,
|
RawServoDeclarationBlockBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoStyleContextBorrowed,
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed)
|
||||||
-> RawServoAnimationValueStrong;
|
-> RawServoAnimationValueStrong;
|
||||||
}
|
}
|
||||||
|
@ -2671,8 +2677,6 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
pub fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||||
ServoStyleContextBorrowedOrNull,
|
ServoStyleContextBorrowedOrNull,
|
||||||
pseudo_type:
|
|
||||||
CSSPseudoElementType,
|
|
||||||
pseudo_tag: *mut nsIAtom,
|
pseudo_tag: *mut nsIAtom,
|
||||||
set:
|
set:
|
||||||
RawServoStyleSetBorrowed)
|
RawServoStyleSetBorrowed)
|
||||||
|
@ -2680,7 +2684,6 @@ extern "C" {
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ComputedValues_Inherit(set: RawServoStyleSetBorrowed,
|
pub fn Servo_ComputedValues_Inherit(set: RawServoStyleSetBorrowed,
|
||||||
pseudo_type: CSSPseudoElementType,
|
|
||||||
pseudo_tag: *mut nsIAtom,
|
pseudo_tag: *mut nsIAtom,
|
||||||
parent_style:
|
parent_style:
|
||||||
ServoStyleContextBorrowedOrNull,
|
ServoStyleContextBorrowedOrNull,
|
||||||
|
@ -2705,16 +2708,6 @@ extern "C" {
|
||||||
rules:
|
rules:
|
||||||
RawGeckoServoStyleRuleListBorrowedMut);
|
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" {
|
extern "C" {
|
||||||
pub fn Servo_Initialize(dummy_url_data: *mut RawGeckoURLExtraData);
|
pub fn Servo_Initialize(dummy_url_data: *mut RawGeckoURLExtraData);
|
||||||
}
|
}
|
||||||
|
@ -2740,10 +2733,8 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
pub fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||||
pseudo_type: CSSPseudoElementType,
|
pseudo_type: CSSPseudoElementType,
|
||||||
pseudo_tag: *mut nsIAtom, is_probe: bool,
|
is_probe: bool,
|
||||||
inherited_style:
|
inherited_style:
|
||||||
ServoComputedValuesBorrowedOrNull,
|
|
||||||
parent_style_context:
|
|
||||||
ServoStyleContextBorrowedOrNull,
|
ServoStyleContextBorrowedOrNull,
|
||||||
set: RawServoStyleSetBorrowed)
|
set: RawServoStyleSetBorrowed)
|
||||||
-> ServoStyleContextStrong;
|
-> ServoStyleContextStrong;
|
||||||
|
@ -2760,9 +2751,6 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
pub fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||||
pseudo_type: CSSPseudoElementType,
|
pseudo_type: CSSPseudoElementType,
|
||||||
pseudo_tag: *mut nsIAtom,
|
|
||||||
parent_style_context:
|
|
||||||
ServoStyleContextBorrowedOrNull,
|
|
||||||
rule_inclusion: StyleRuleInclusion,
|
rule_inclusion: StyleRuleInclusion,
|
||||||
snapshots:
|
snapshots:
|
||||||
*const ServoElementSnapshotTable,
|
*const ServoElementSnapshotTable,
|
||||||
|
|
|
@ -689,10 +689,11 @@ impl PseudoElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
||||||
|
use gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox;
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
PseudoElement::After => CSSPseudoElementType::after,
|
PseudoElement::After => CSSPseudoElementType::after,
|
||||||
PseudoElement::Before => CSSPseudoElementType::before,
|
PseudoElement::Before => CSSPseudoElementType::before,
|
||||||
|
@ -719,7 +720,64 @@ impl PseudoElement {
|
||||||
PseudoElement::MozPlaceholder => CSSPseudoElementType::mozPlaceholder,
|
PseudoElement::MozPlaceholder => CSSPseudoElementType::mozPlaceholder,
|
||||||
PseudoElement::Placeholder => CSSPseudoElementType::placeholder,
|
PseudoElement::Placeholder => CSSPseudoElementType::placeholder,
|
||||||
PseudoElement::MozColorSwatch => CSSPseudoElementType::mozColorSwatch,
|
PseudoElement::MozColorSwatch => CSSPseudoElementType::mozColorSwatch,
|
||||||
_ => CSSPseudoElementType::NotPseudo
|
PseudoElement::MozText => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::OofPlaceholder => CSSPseudoElementType::NonInheritingAnonBox,
|
||||||
|
PseudoElement::FirstLetterContinuation => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozBlockInsideInlineWrapper => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozMathMLAnonymousBlock => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozXULAnonymousBlock => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::HorizontalFramesetBorder => CSSPseudoElementType::NonInheritingAnonBox,
|
||||||
|
PseudoElement::VerticalFramesetBorder => CSSPseudoElementType::NonInheritingAnonBox,
|
||||||
|
PseudoElement::MozLineFrame => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::ButtonContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::CellContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::DropDownList => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::FieldsetContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::FramesetBlank => CSSPseudoElementType::NonInheritingAnonBox,
|
||||||
|
PseudoElement::MozDisplayComboboxControlFrame => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::HtmlCanvasContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::InlineTable => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::Table => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::TableCell => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::TableColGroup => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::TableCol => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::TableWrapper => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::TableRowGroup => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::TableRow => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::Canvas => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::PageBreak => CSSPseudoElementType::NonInheritingAnonBox,
|
||||||
|
PseudoElement::Page => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::PageContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::PageSequence => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::ScrolledContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::ScrolledCanvas => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::ScrolledPageSequence => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::ColumnContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::Viewport => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::ViewportScroll => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::AnonymousFlexItem => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::AnonymousGridItem => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::Ruby => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::RubyBase => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::RubyBaseContainer => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::RubyText => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::RubyTextContainer => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeColumn(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeRow(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeSeparator(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeCell(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeIndentation(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeLine(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeTwisty(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeImage(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeCellText(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeCheckbox(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeProgressmeter(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozTreeDropFeedback(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozSVGMarkerAnonChild => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozSVGOuterSVGAnonChild => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozSVGForeignContent => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
PseudoElement::MozSVGText => CSSPseudoElementType_InheritingAnonBox,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,6 +786,237 @@ impl PseudoElement {
|
||||||
(self.atom().as_ptr(), self.pseudo_type())
|
(self.atom().as_ptr(), self.pseudo_type())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct a pseudo-element from an `Atom`.
|
||||||
|
#[inline]
|
||||||
|
pub fn from_atom(atom: &Atom) -> Option<Self> {
|
||||||
|
if atom == &atom!(":after") {
|
||||||
|
return Some(PseudoElement::After);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":before") {
|
||||||
|
return Some(PseudoElement::Before);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":backdrop") {
|
||||||
|
return Some(PseudoElement::Backdrop);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":cue") {
|
||||||
|
return Some(PseudoElement::Cue);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":first-letter") {
|
||||||
|
return Some(PseudoElement::FirstLetter);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":first-line") {
|
||||||
|
return Some(PseudoElement::FirstLine);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-selection") {
|
||||||
|
return Some(PseudoElement::MozSelection);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-focus-inner") {
|
||||||
|
return Some(PseudoElement::MozFocusInner);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-focus-outer") {
|
||||||
|
return Some(PseudoElement::MozFocusOuter);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-list-bullet") {
|
||||||
|
return Some(PseudoElement::MozListBullet);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-list-number") {
|
||||||
|
return Some(PseudoElement::MozListNumber);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-math-anonymous") {
|
||||||
|
return Some(PseudoElement::MozMathAnonymous);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-number-wrapper") {
|
||||||
|
return Some(PseudoElement::MozNumberWrapper);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-number-text") {
|
||||||
|
return Some(PseudoElement::MozNumberText);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-number-spin-box") {
|
||||||
|
return Some(PseudoElement::MozNumberSpinBox);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-number-spin-up") {
|
||||||
|
return Some(PseudoElement::MozNumberSpinUp);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-number-spin-down") {
|
||||||
|
return Some(PseudoElement::MozNumberSpinDown);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-progress-bar") {
|
||||||
|
return Some(PseudoElement::MozProgressBar);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-range-track") {
|
||||||
|
return Some(PseudoElement::MozRangeTrack);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-range-progress") {
|
||||||
|
return Some(PseudoElement::MozRangeProgress);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-range-thumb") {
|
||||||
|
return Some(PseudoElement::MozRangeThumb);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-meter-bar") {
|
||||||
|
return Some(PseudoElement::MozMeterBar);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-placeholder") {
|
||||||
|
return Some(PseudoElement::MozPlaceholder);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":placeholder") {
|
||||||
|
return Some(PseudoElement::Placeholder);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-color-swatch") {
|
||||||
|
return Some(PseudoElement::MozColorSwatch);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-text") {
|
||||||
|
return Some(PseudoElement::MozText);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-oof-placeholder") {
|
||||||
|
return Some(PseudoElement::OofPlaceholder);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-first-letter-continuation") {
|
||||||
|
return Some(PseudoElement::FirstLetterContinuation);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-block-inside-inline-wrapper") {
|
||||||
|
return Some(PseudoElement::MozBlockInsideInlineWrapper);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-mathml-anonymous-block") {
|
||||||
|
return Some(PseudoElement::MozMathMLAnonymousBlock);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-xul-anonymous-block") {
|
||||||
|
return Some(PseudoElement::MozXULAnonymousBlock);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-hframeset-border") {
|
||||||
|
return Some(PseudoElement::HorizontalFramesetBorder);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-vframeset-border") {
|
||||||
|
return Some(PseudoElement::VerticalFramesetBorder);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-line-frame") {
|
||||||
|
return Some(PseudoElement::MozLineFrame);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-button-content") {
|
||||||
|
return Some(PseudoElement::ButtonContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-cell-content") {
|
||||||
|
return Some(PseudoElement::CellContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-dropdown-list") {
|
||||||
|
return Some(PseudoElement::DropDownList);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-fieldset-content") {
|
||||||
|
return Some(PseudoElement::FieldsetContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-frameset-blank") {
|
||||||
|
return Some(PseudoElement::FramesetBlank);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-display-comboboxcontrol-frame") {
|
||||||
|
return Some(PseudoElement::MozDisplayComboboxControlFrame);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-html-canvas-content") {
|
||||||
|
return Some(PseudoElement::HtmlCanvasContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-inline-table") {
|
||||||
|
return Some(PseudoElement::InlineTable);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-table") {
|
||||||
|
return Some(PseudoElement::Table);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-table-cell") {
|
||||||
|
return Some(PseudoElement::TableCell);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-table-column-group") {
|
||||||
|
return Some(PseudoElement::TableColGroup);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-table-column") {
|
||||||
|
return Some(PseudoElement::TableCol);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-table-wrapper") {
|
||||||
|
return Some(PseudoElement::TableWrapper);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-table-row-group") {
|
||||||
|
return Some(PseudoElement::TableRowGroup);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-table-row") {
|
||||||
|
return Some(PseudoElement::TableRow);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-canvas") {
|
||||||
|
return Some(PseudoElement::Canvas);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-pagebreak") {
|
||||||
|
return Some(PseudoElement::PageBreak);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-page") {
|
||||||
|
return Some(PseudoElement::Page);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-pagecontent") {
|
||||||
|
return Some(PseudoElement::PageContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-page-sequence") {
|
||||||
|
return Some(PseudoElement::PageSequence);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-scrolled-content") {
|
||||||
|
return Some(PseudoElement::ScrolledContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-scrolled-canvas") {
|
||||||
|
return Some(PseudoElement::ScrolledCanvas);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-scrolled-page-sequence") {
|
||||||
|
return Some(PseudoElement::ScrolledPageSequence);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-column-content") {
|
||||||
|
return Some(PseudoElement::ColumnContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-viewport") {
|
||||||
|
return Some(PseudoElement::Viewport);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-viewport-scroll") {
|
||||||
|
return Some(PseudoElement::ViewportScroll);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-anonymous-flex-item") {
|
||||||
|
return Some(PseudoElement::AnonymousFlexItem);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-anonymous-grid-item") {
|
||||||
|
return Some(PseudoElement::AnonymousGridItem);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-ruby") {
|
||||||
|
return Some(PseudoElement::Ruby);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-ruby-base") {
|
||||||
|
return Some(PseudoElement::RubyBase);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-ruby-base-container") {
|
||||||
|
return Some(PseudoElement::RubyBaseContainer);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-ruby-text") {
|
||||||
|
return Some(PseudoElement::RubyText);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-ruby-text-container") {
|
||||||
|
return Some(PseudoElement::RubyTextContainer);
|
||||||
|
}
|
||||||
|
// We cannot generate PseudoElement::MozTreeColumn(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeRow(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeSeparator(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeCell(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeIndentation(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeLine(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeTwisty(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeImage(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeCellText(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeCheckbox(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeProgressmeter(..) from just an atom.
|
||||||
|
// We cannot generate PseudoElement::MozTreeDropFeedback(..) from just an atom.
|
||||||
|
if atom == &atom!(":-moz-svg-marker-anon-child") {
|
||||||
|
return Some(PseudoElement::MozSVGMarkerAnonChild);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-svg-outer-svg-anon-child") {
|
||||||
|
return Some(PseudoElement::MozSVGOuterSVGAnonChild);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-svg-foreign-content") {
|
||||||
|
return Some(PseudoElement::MozSVGForeignContent);
|
||||||
|
}
|
||||||
|
if atom == &atom!(":-moz-svg-text") {
|
||||||
|
return Some(PseudoElement::MozSVGText);
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
/// Construct a pseudo-element from an anonymous box `Atom`.
|
/// Construct a pseudo-element from an anonymous box `Atom`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
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
|
@ -17,9 +17,10 @@ use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType
|
||||||
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
|
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
|
||||||
use media_queries::MediaType;
|
use media_queries::MediaType;
|
||||||
use parser::ParserContext;
|
use parser::ParserContext;
|
||||||
use properties::{ComputedValuesInner, StyleBuilder};
|
use properties::{ComputedValues, StyleBuilder};
|
||||||
use properties::longhands::font_size;
|
use properties::longhands::font_size;
|
||||||
use selectors::parser::SelectorParseError;
|
use selectors::parser::SelectorParseError;
|
||||||
|
use servo_arc::Arc;
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
|
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
|
||||||
use str::starts_with_ignore_ascii_case;
|
use str::starts_with_ignore_ascii_case;
|
||||||
|
@ -36,7 +37,7 @@ pub struct Device {
|
||||||
/// stylist, and thus the `Device`, so having a raw pres context pointer
|
/// stylist, and thus the `Device`, so having a raw pres context pointer
|
||||||
/// here is fine.
|
/// here is fine.
|
||||||
pres_context: RawGeckoPresContextOwned,
|
pres_context: RawGeckoPresContextOwned,
|
||||||
default_values: ComputedValuesInner,
|
default_values: Arc<ComputedValues>,
|
||||||
viewport_override: Option<ViewportConstraints>,
|
viewport_override: Option<ViewportConstraints>,
|
||||||
/// The font size of the root element
|
/// The font size of the root element
|
||||||
/// This is set when computing the style of the root
|
/// This is set when computing the style of the root
|
||||||
|
@ -61,7 +62,7 @@ impl Device {
|
||||||
assert!(!pres_context.is_null());
|
assert!(!pres_context.is_null());
|
||||||
Device {
|
Device {
|
||||||
pres_context: pres_context,
|
pres_context: pres_context,
|
||||||
default_values: ComputedValuesInner::default_values(unsafe { &*pres_context }),
|
default_values: ComputedValues::default_values(unsafe { &*pres_context }),
|
||||||
viewport_override: None,
|
viewport_override: None,
|
||||||
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
|
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
|
||||||
used_root_font_size: AtomicBool::new(false),
|
used_root_font_size: AtomicBool::new(false),
|
||||||
|
@ -77,7 +78,12 @@ impl Device {
|
||||||
|
|
||||||
/// Returns the default computed values as a reference, in order to match
|
/// Returns the default computed values as a reference, in order to match
|
||||||
/// Servo.
|
/// Servo.
|
||||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
pub fn default_computed_values(&self) -> &ComputedValues {
|
||||||
|
&self.default_values
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the default computed values as an `Arc`.
|
||||||
|
pub fn default_computed_values_arc(&self) -> &Arc<ComputedValues> {
|
||||||
&self.default_values
|
&self.default_values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +107,7 @@ impl Device {
|
||||||
pub fn reset_computed_values(&mut self) {
|
pub fn reset_computed_values(&mut self) {
|
||||||
// NB: A following stylesheet flush will populate this if appropriate.
|
// NB: A following stylesheet flush will populate this if appropriate.
|
||||||
self.viewport_override = None;
|
self.viewport_override = None;
|
||||||
self.default_values = ComputedValuesInner::default_values(self.pres_context());
|
self.default_values = ComputedValues::default_values(self.pres_context());
|
||||||
self.used_root_font_size.store(false, Ordering::Relaxed);
|
self.used_root_font_size.store(false, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,8 +626,7 @@ impl Expression {
|
||||||
is_root_element: false,
|
is_root_element: false,
|
||||||
device: device,
|
device: device,
|
||||||
inherited_style: default_values,
|
inherited_style: default_values,
|
||||||
layout_parent_style: default_values,
|
style: StyleBuilder::for_derived_style(device, default_values, None),
|
||||||
style: StyleBuilder::for_derived_style(default_values),
|
|
||||||
font_metrics_provider: &provider,
|
font_metrics_provider: &provider,
|
||||||
cached_system_font: None,
|
cached_system_font: None,
|
||||||
in_media_query: true,
|
in_media_query: true,
|
||||||
|
|
|
@ -107,17 +107,23 @@ impl PseudoElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
||||||
|
use gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox;
|
||||||
|
|
||||||
match *self {
|
match *self {
|
||||||
% for pseudo in PSEUDOS:
|
% for pseudo in PSEUDOS:
|
||||||
% if not pseudo.is_anon_box():
|
% if not pseudo.is_anon_box():
|
||||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::${pseudo.original_ident},
|
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::${pseudo.original_ident},
|
||||||
|
% elif pseudo.is_tree_pseudo_element():
|
||||||
|
PseudoElement::${pseudo.capitalized()}(..) => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
% elif pseudo.is_inheriting_anon_box():
|
||||||
|
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType_InheritingAnonBox,
|
||||||
|
% else:
|
||||||
|
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::NonInheritingAnonBox,
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
_ => CSSPseudoElementType::NotPseudo
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +132,21 @@ impl PseudoElement {
|
||||||
(self.atom().as_ptr(), self.pseudo_type())
|
(self.atom().as_ptr(), self.pseudo_type())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Construct a pseudo-element from an `Atom`.
|
||||||
|
#[inline]
|
||||||
|
pub fn from_atom(atom: &Atom) -> Option<Self> {
|
||||||
|
% for pseudo in PSEUDOS:
|
||||||
|
% if pseudo.is_tree_pseudo_element():
|
||||||
|
// We cannot generate ${pseudo_element_variant(pseudo)} from just an atom.
|
||||||
|
% else:
|
||||||
|
if atom == &atom!("${pseudo.value}") {
|
||||||
|
return Some(${pseudo_element_variant(pseudo)});
|
||||||
|
}
|
||||||
|
% endif
|
||||||
|
% endfor
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
/// Construct a pseudo-element from an anonymous box `Atom`.
|
/// Construct a pseudo-element from an anonymous box `Atom`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
||||||
|
|
|
@ -39,14 +39,14 @@ def msvc32_symbolify(source, ident):
|
||||||
|
|
||||||
|
|
||||||
class GkAtomSource:
|
class GkAtomSource:
|
||||||
PATTERN = re.compile('^GK_ATOM\((.+),\s*"(.*)"\)')
|
PATTERN = re.compile('^(GK_ATOM)\((.+),\s*"(.*)"\)')
|
||||||
FILE = "include/nsGkAtomList.h"
|
FILE = "include/nsGkAtomList.h"
|
||||||
CLASS = "nsGkAtoms"
|
CLASS = "nsGkAtoms"
|
||||||
TYPE = "nsIAtom"
|
TYPE = "nsIAtom"
|
||||||
|
|
||||||
|
|
||||||
class CSSPseudoElementsAtomSource:
|
class CSSPseudoElementsAtomSource:
|
||||||
PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((.+),\s*"(.*)",')
|
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\((.+),\s*"(.*)",')
|
||||||
FILE = "include/nsCSSPseudoElementList.h"
|
FILE = "include/nsCSSPseudoElementList.h"
|
||||||
CLASS = "nsCSSPseudoElements"
|
CLASS = "nsCSSPseudoElements"
|
||||||
# NB: nsICSSPseudoElement is effectively the same as a nsIAtom, but we need
|
# NB: nsICSSPseudoElement is effectively the same as a nsIAtom, but we need
|
||||||
|
@ -55,7 +55,7 @@ class CSSPseudoElementsAtomSource:
|
||||||
|
|
||||||
|
|
||||||
class CSSAnonBoxesAtomSource:
|
class CSSAnonBoxesAtomSource:
|
||||||
PATTERN = re.compile('^(?:CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX)\((.+),\s*"(.*)"\)')
|
PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX)\((.+),\s*"(.*)"\)')
|
||||||
FILE = "include/nsCSSAnonBoxList.h"
|
FILE = "include/nsCSSAnonBoxList.h"
|
||||||
CLASS = "nsCSSAnonBoxes"
|
CLASS = "nsCSSAnonBoxes"
|
||||||
TYPE = "nsICSSAnonBoxPseudo"
|
TYPE = "nsICSSAnonBoxPseudo"
|
||||||
|
@ -76,11 +76,14 @@ def map_atom(ident):
|
||||||
|
|
||||||
|
|
||||||
class Atom:
|
class Atom:
|
||||||
def __init__(self, source, ident, value):
|
def __init__(self, source, macro_name, ident, value):
|
||||||
self.ident = "{}_{}".format(source.CLASS, ident)
|
self.ident = "{}_{}".format(source.CLASS, ident)
|
||||||
self.original_ident = ident
|
self.original_ident = ident
|
||||||
self.value = value
|
self.value = value
|
||||||
self.source = source
|
self.source = source
|
||||||
|
self.macro = macro_name
|
||||||
|
if self.is_anon_box():
|
||||||
|
assert self.is_inheriting_anon_box() or self.is_non_inheriting_anon_box()
|
||||||
|
|
||||||
def cpp_class(self):
|
def cpp_class(self):
|
||||||
return self.source.CLASS
|
return self.source.CLASS
|
||||||
|
@ -103,6 +106,12 @@ class Atom:
|
||||||
def is_anon_box(self):
|
def is_anon_box(self):
|
||||||
return self.type() == "nsICSSAnonBoxPseudo"
|
return self.type() == "nsICSSAnonBoxPseudo"
|
||||||
|
|
||||||
|
def is_non_inheriting_anon_box(self):
|
||||||
|
return self.macro == "CSS_NON_INHERITING_ANON_BOX"
|
||||||
|
|
||||||
|
def is_inheriting_anon_box(self):
|
||||||
|
return self.macro == "CSS_ANON_BOX"
|
||||||
|
|
||||||
def is_tree_pseudo_element(self):
|
def is_tree_pseudo_element(self):
|
||||||
return self.value.startswith(":-moz-tree-")
|
return self.value.startswith(":-moz-tree-")
|
||||||
|
|
||||||
|
@ -116,7 +125,7 @@ def collect_atoms(objdir):
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
result = re.match(source.PATTERN, line)
|
result = re.match(source.PATTERN, line)
|
||||||
if result:
|
if result:
|
||||||
atoms.append(Atom(source, result.group(1), result.group(2)))
|
atoms.append(Atom(source, result.group(1), result.group(2), result.group(3)))
|
||||||
return atoms
|
return atoms
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,13 +110,13 @@ impl<'a> Iterator for PropertyDeclarationIterator<'a> {
|
||||||
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
|
pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
|
||||||
iter: Iter<'a, (PropertyDeclaration, Importance)>,
|
iter: Iter<'a, (PropertyDeclaration, Importance)>,
|
||||||
context: &'cx mut Context<'cx_a>,
|
context: &'cx mut Context<'cx_a>,
|
||||||
default_values: &'a ComputedValuesInner,
|
default_values: &'a ComputedValues,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||||
fn new(declarations: &'a PropertyDeclarationBlock,
|
fn new(declarations: &'a PropertyDeclarationBlock,
|
||||||
context: &'cx mut Context<'cx_a>,
|
context: &'cx mut Context<'cx_a>,
|
||||||
default_values: &'a ComputedValuesInner) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
default_values: &'a ComputedValues) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||||
AnimationValueIterator {
|
AnimationValueIterator {
|
||||||
iter: declarations.declarations().iter(),
|
iter: declarations.declarations().iter(),
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -204,7 +204,7 @@ impl PropertyDeclarationBlock {
|
||||||
/// Return an iterator of (AnimatableLonghand, AnimationValue).
|
/// Return an iterator of (AnimatableLonghand, AnimationValue).
|
||||||
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
|
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
|
||||||
context: &'cx mut Context<'cx_a>,
|
context: &'cx mut Context<'cx_a>,
|
||||||
default_values: &'a ComputedValuesInner)
|
default_values: &'a ComputedValues)
|
||||||
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||||
AnimationValueIterator::new(self, context, default_values)
|
AnimationValueIterator::new(self, context, default_values)
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ use properties::computed_value_flags::ComputedValueFlags;
|
||||||
use properties::{longhands, FontComputationData, Importance, LonghandId};
|
use properties::{longhands, FontComputationData, Importance, LonghandId};
|
||||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
|
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
|
||||||
use rule_tree::StrongRuleNode;
|
use rule_tree::StrongRuleNode;
|
||||||
|
use selector_parser::PseudoElement;
|
||||||
use std::mem::{forget, uninitialized, transmute, zeroed};
|
use std::mem::{forget, uninitialized, transmute, zeroed};
|
||||||
use std::{cmp, ops, ptr};
|
use std::{cmp, ops, ptr};
|
||||||
use stylearc::{Arc, RawOffsetArc};
|
use stylearc::{Arc, RawOffsetArc};
|
||||||
|
@ -72,13 +73,72 @@ pub mod style_structs {
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// FIXME(emilio): This is completely duplicated with the other properties code.
|
||||||
pub type ComputedValuesInner = ::gecko_bindings::structs::ServoComputedValues;
|
pub type ComputedValuesInner = ::gecko_bindings::structs::ServoComputedValues;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ComputedValues(::gecko_bindings::structs::mozilla::ServoStyleContext);
|
pub struct ComputedValues(::gecko_bindings::structs::mozilla::ServoStyleContext);
|
||||||
|
|
||||||
|
impl ComputedValues {
|
||||||
|
pub fn new(
|
||||||
|
device: &Device,
|
||||||
|
parent: Option<<&ComputedValues>,
|
||||||
|
pseudo: Option<<&PseudoElement>,
|
||||||
|
custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||||
|
writing_mode: WritingMode,
|
||||||
|
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
|
||||||
|
flags: ComputedValueFlags,
|
||||||
|
rules: Option<StrongRuleNode>,
|
||||||
|
visited_style: Option<Arc<ComputedValues>>,
|
||||||
|
% for style_struct in data.style_structs:
|
||||||
|
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||||
|
% endfor
|
||||||
|
) -> Arc<Self> {
|
||||||
|
ComputedValuesInner::new(
|
||||||
|
custom_properties,
|
||||||
|
writing_mode,
|
||||||
|
font_size_keyword,
|
||||||
|
flags,
|
||||||
|
rules,
|
||||||
|
visited_style,
|
||||||
|
% for style_struct in data.style_structs:
|
||||||
|
${style_struct.ident},
|
||||||
|
% endfor
|
||||||
|
).to_outer(
|
||||||
|
device.pres_context(),
|
||||||
|
parent,
|
||||||
|
pseudo.map(|p| p.pseudo_info())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||||
|
ComputedValuesInner::new(
|
||||||
|
/* custom_properties = */ None,
|
||||||
|
/* writing_mode = */ WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||||
|
FontComputationData::default_font_size_keyword(),
|
||||||
|
ComputedValueFlags::empty(),
|
||||||
|
/* rules = */ None,
|
||||||
|
/* visited_style = */ None,
|
||||||
|
% for style_struct in data.style_structs:
|
||||||
|
style_structs::${style_struct.name}::default(pres_context),
|
||||||
|
% endfor
|
||||||
|
).to_outer(pres_context, None, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pseudo(&self) -> Option<PseudoElement> {
|
||||||
|
use string_cache::Atom;
|
||||||
|
|
||||||
|
let atom = (self.0)._base.mPseudoTag.raw::<structs::nsIAtom>();
|
||||||
|
if atom.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
let atom = Atom::from(atom);
|
||||||
|
PseudoElement::from_atom(&atom)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Drop for ComputedValues {
|
impl Drop for ComputedValues {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -112,8 +172,8 @@ impl Clone for ComputedValuesInner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PseudoInfo = (*mut structs::nsIAtom, structs::CSSPseudoElementType);
|
type PseudoInfo = (*mut structs::nsIAtom, structs::CSSPseudoElementType);
|
||||||
pub type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
|
type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
|
||||||
|
|
||||||
impl ComputedValuesInner {
|
impl ComputedValuesInner {
|
||||||
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
|
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||||
|
@ -139,36 +199,28 @@ impl ComputedValuesInner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Self {
|
fn to_outer(
|
||||||
ComputedValuesInner {
|
self,
|
||||||
custom_properties: None,
|
pres_context: RawGeckoPresContextBorrowed,
|
||||||
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
parent: ParentStyleContextInfo,
|
||||||
font_computation_data: FontComputationData::default_values(),
|
info: Option<PseudoInfo>
|
||||||
rules: None,
|
) -> Arc<ComputedValues> {
|
||||||
visited_style: None,
|
|
||||||
flags: ComputedValueFlags::empty(),
|
|
||||||
% for style_struct in data.style_structs:
|
|
||||||
${style_struct.gecko_name}: Arc::into_raw_offset(
|
|
||||||
style_structs::${style_struct.name}::default(pres_context)
|
|
||||||
),
|
|
||||||
% endfor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn to_outer(self, device: &Device, parent: ParentStyleContextInfo,
|
|
||||||
info: Option<PseudoInfo>) -> Arc<ComputedValues> {
|
|
||||||
let (tag, ty) = if let Some(info) = info {
|
let (tag, ty) = if let Some(info) = info {
|
||||||
info
|
info
|
||||||
} else {
|
} else {
|
||||||
(ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo)
|
(ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo)
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe { self.to_outer_helper(device.pres_context(), parent, ty, tag) }
|
unsafe { self.to_outer_helper(pres_context, parent, ty, tag) }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn to_outer_helper(self, pres_context: bindings::RawGeckoPresContextBorrowed,
|
unsafe fn to_outer_helper(
|
||||||
parent: ParentStyleContextInfo,
|
self,
|
||||||
pseudo_ty: structs::CSSPseudoElementType,
|
pres_context: bindings::RawGeckoPresContextBorrowed,
|
||||||
pseudo_tag: *mut structs::nsIAtom) -> Arc<ComputedValues> {
|
parent: ParentStyleContextInfo,
|
||||||
|
pseudo_ty: structs::CSSPseudoElementType,
|
||||||
|
pseudo_tag: *mut structs::nsIAtom
|
||||||
|
) -> Arc<ComputedValues> {
|
||||||
let arc = unsafe {
|
let arc = unsafe {
|
||||||
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
|
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
|
||||||
bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _, parent, pres_context,
|
bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _, parent, pres_context,
|
||||||
|
|
|
@ -292,7 +292,7 @@
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use properties::{DeclaredValue, LonghandId, LonghandIdSet};
|
use properties::{DeclaredValue, LonghandId, LonghandIdSet};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use properties::{CSSWideKeyword, ComputedValuesInner, PropertyDeclaration};
|
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use properties::style_structs;
|
use properties::style_structs;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
@ -310,8 +310,8 @@
|
||||||
${caller.body()}
|
${caller.body()}
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
pub fn cascade_property(declaration: &PropertyDeclaration,
|
pub fn cascade_property(declaration: &PropertyDeclaration,
|
||||||
inherited_style: &ComputedValuesInner,
|
inherited_style: &ComputedValues,
|
||||||
default_style: &ComputedValuesInner,
|
default_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
cacheable: &mut bool,
|
cacheable: &mut bool,
|
||||||
cascade_info: &mut Option<<&mut CascadeInfo>) {
|
cascade_info: &mut Option<<&mut CascadeInfo>) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ use smallvec::SmallVec;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
#[cfg(feature = "gecko")] use fnv::FnvHashMap;
|
#[cfg(feature = "gecko")] use fnv::FnvHashMap;
|
||||||
use style_traits::ParseError;
|
use style_traits::ParseError;
|
||||||
use super::ComputedValuesInner;
|
use super::ComputedValues;
|
||||||
#[cfg(any(feature = "gecko", feature = "testing"))]
|
#[cfg(any(feature = "gecko", feature = "testing"))]
|
||||||
use values::Auto;
|
use values::Auto;
|
||||||
use values::{CSSFloat, CustomIdent, Either};
|
use values::{CSSFloat, CustomIdent, Either};
|
||||||
|
@ -394,7 +394,7 @@ impl AnimatedProperty {
|
||||||
|
|
||||||
/// Update `style` with the proper computed style corresponding to this
|
/// Update `style` with the proper computed style corresponding to this
|
||||||
/// animation at `progress`.
|
/// animation at `progress`.
|
||||||
pub fn update(&self, style: &mut ComputedValuesInner, progress: f64) {
|
pub fn update(&self, style: &mut ComputedValues, progress: f64) {
|
||||||
match *self {
|
match *self {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
|
@ -427,8 +427,8 @@ impl AnimatedProperty {
|
||||||
/// Get an animatable value from a transition-property, an old style, and a
|
/// Get an animatable value from a transition-property, an old style, and a
|
||||||
/// new style.
|
/// new style.
|
||||||
pub fn from_animatable_longhand(property: &AnimatableLonghand,
|
pub fn from_animatable_longhand(property: &AnimatableLonghand,
|
||||||
old_style: &ComputedValuesInner,
|
old_style: &ComputedValues,
|
||||||
new_style: &ComputedValuesInner)
|
new_style: &ComputedValues)
|
||||||
-> AnimatedProperty {
|
-> AnimatedProperty {
|
||||||
match *property {
|
match *property {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
|
@ -521,7 +521,7 @@ impl AnimationValue {
|
||||||
|
|
||||||
/// Construct an AnimationValue from a property declaration
|
/// Construct an AnimationValue from a property declaration
|
||||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
||||||
initial: &ComputedValuesInner) -> Option<Self> {
|
initial: &ComputedValues) -> Option<Self> {
|
||||||
use properties::LonghandId;
|
use properties::LonghandId;
|
||||||
|
|
||||||
match *decl {
|
match *decl {
|
||||||
|
@ -593,7 +593,7 @@ impl AnimationValue {
|
||||||
|
|
||||||
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
||||||
pub fn from_computed_values(property: &AnimatableLonghand,
|
pub fn from_computed_values(property: &AnimatableLonghand,
|
||||||
computed_values: &ComputedValuesInner)
|
computed_values: &ComputedValues)
|
||||||
-> Self {
|
-> Self {
|
||||||
match *property {
|
match *property {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
|
|
|
@ -181,7 +181,7 @@
|
||||||
|
|
||||||
% if product == "servo":
|
% if product == "servo":
|
||||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||||
_inherited_style: &ComputedValuesInner,
|
_inherited_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
_cacheable: &mut bool) {
|
_cacheable: &mut bool) {
|
||||||
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
||||||
|
|
|
@ -249,7 +249,7 @@ ${helpers.single_keyword("unicode-bidi",
|
||||||
|
|
||||||
% if product == "servo":
|
% if product == "servo":
|
||||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||||
_inherited_style: &ComputedValuesInner,
|
_inherited_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
_cacheable: &mut bool) {
|
_cacheable: &mut bool) {
|
||||||
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
||||||
|
|
|
@ -32,6 +32,7 @@ use media_queries::Device;
|
||||||
use parser::{Parse, ParserContext};
|
use parser::{Parse, ParserContext};
|
||||||
use properties::animated_properties::AnimatableLonghand;
|
use properties::animated_properties::AnimatableLonghand;
|
||||||
#[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont;
|
#[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont;
|
||||||
|
use selector_parser::PseudoElement;
|
||||||
use selectors::parser::SelectorParseError;
|
use selectors::parser::SelectorParseError;
|
||||||
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
|
||||||
use shared_lock::StylesheetGuards;
|
use shared_lock::StylesheetGuards;
|
||||||
|
@ -107,22 +108,26 @@ pub struct FontComputationData {
|
||||||
///
|
///
|
||||||
/// When this is Some, we compute font sizes by computing the keyword against
|
/// When this is Some, we compute font sizes by computing the keyword against
|
||||||
/// the generic font, and then multiplying it by the ratio.
|
/// the generic font, and then multiplying it by the ratio.
|
||||||
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>
|
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl FontComputationData {
|
impl FontComputationData {
|
||||||
/// Assigns values for variables in struct FontComputationData
|
/// Assigns values for variables in struct FontComputationData
|
||||||
pub fn new(font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>) -> Self {
|
pub fn new(font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>) -> Self {
|
||||||
FontComputationData {
|
FontComputationData {
|
||||||
font_size_keyword: font_size_keyword
|
font_size_keyword: font_size_keyword
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Assigns default values for variables in struct FontComputationData
|
|
||||||
pub fn default_values() -> Self {
|
/// Assigns default values for variables in struct FontComputationData
|
||||||
FontComputationData{
|
pub fn default_font_size_keyword() -> Option<(longhands::font_size::KeywordSize, f32)> {
|
||||||
font_size_keyword: Some((Default::default(), 1.))
|
Some((Default::default(), 1.))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Gets a FontComputationData with the default values.
|
||||||
|
pub fn default_values() -> Self {
|
||||||
|
Self::new(Self::default_font_size_keyword())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1871,15 +1876,7 @@ pub mod style_structs {
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub use gecko_properties::{ComputedValues, ComputedValuesInner, ParentStyleContextInfo, PseudoInfo};
|
pub use gecko_properties::{ComputedValues, ComputedValuesInner};
|
||||||
|
|
||||||
#[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")]
|
#[cfg(feature = "servo")]
|
||||||
#[cfg_attr(feature = "servo", derive(Clone, Debug))]
|
#[cfg_attr(feature = "servo", derive(Clone, Debug))]
|
||||||
|
@ -1891,6 +1888,7 @@ pub struct ComputedValuesInner {
|
||||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
/// The writing mode of this computed values struct.
|
/// The writing mode of this computed values struct.
|
||||||
pub writing_mode: WritingMode,
|
pub writing_mode: WritingMode,
|
||||||
|
|
||||||
/// The keyword behind the current font-size property, if any
|
/// The keyword behind the current font-size property, if any
|
||||||
pub font_computation_data: FontComputationData,
|
pub font_computation_data: FontComputationData,
|
||||||
|
|
||||||
|
@ -1923,12 +1921,48 @@ pub struct ComputedValues {
|
||||||
/// whereas ComputedValuesInner is the core set of computed values.
|
/// whereas ComputedValuesInner is the core set of computed values.
|
||||||
///
|
///
|
||||||
/// We maintain this distinction in servo to reduce the amount of special casing.
|
/// We maintain this distinction in servo to reduce the amount of special casing.
|
||||||
pub inner: ComputedValuesInner,
|
inner: ComputedValuesInner,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
impl ComputedValues {
|
||||||
|
/// Create a new refcounted `ComputedValues`
|
||||||
|
pub fn new(
|
||||||
|
_: &Device,
|
||||||
|
_: Option<<&ComputedValues>,
|
||||||
|
_: Option<<&PseudoElement>,
|
||||||
|
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
|
writing_mode: WritingMode,
|
||||||
|
font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
|
||||||
|
flags: ComputedValueFlags,
|
||||||
|
rules: Option<StrongRuleNode>,
|
||||||
|
visited_style: Option<Arc<ComputedValues>>,
|
||||||
|
% for style_struct in data.active_style_structs():
|
||||||
|
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||||
|
% endfor
|
||||||
|
) -> Arc<Self> {
|
||||||
|
Arc::new(Self {
|
||||||
|
inner: ComputedValuesInner::new(
|
||||||
|
custom_properties,
|
||||||
|
writing_mode,
|
||||||
|
font_size_keyword,
|
||||||
|
flags,
|
||||||
|
rules,
|
||||||
|
visited_style,
|
||||||
|
% for style_struct in data.active_style_structs():
|
||||||
|
${style_struct.ident},
|
||||||
|
% endfor
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the initial computed values.
|
||||||
|
pub fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
impl ComputedValuesInner {
|
impl ComputedValuesInner {
|
||||||
/// Construct a `ComputedValues` instance.
|
/// Construct a `ComputedValuesInner` instance.
|
||||||
pub fn new(
|
pub fn new(
|
||||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
writing_mode: WritingMode,
|
writing_mode: WritingMode,
|
||||||
|
@ -1952,9 +1986,6 @@ impl ComputedValuesInner {
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the initial computed values.
|
|
||||||
pub fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
@ -1974,12 +2005,6 @@ impl ops::DerefMut for ComputedValues {
|
||||||
|
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
impl ComputedValuesInner {
|
impl ComputedValuesInner {
|
||||||
/// Convert to an Arc<ComputedValues>
|
|
||||||
pub fn to_outer(self, _: &Device, _: ParentStyleContextInfo,
|
|
||||||
_: Option<PseudoInfo>) -> Arc<ComputedValues> {
|
|
||||||
Arc::new(ComputedValues {inner: self})
|
|
||||||
}
|
|
||||||
|
|
||||||
% for style_struct in data.active_style_structs():
|
% for style_struct in data.active_style_structs():
|
||||||
/// Clone the ${style_struct.name} struct.
|
/// Clone the ${style_struct.name} struct.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -2428,6 +2453,9 @@ impl<'a, T: 'a> ops::Deref for StyleStructRef<'a, T> {
|
||||||
/// actually cloning them, until we either build the style, or mutate the
|
/// actually cloning them, until we either build the style, or mutate the
|
||||||
/// inherited value.
|
/// inherited value.
|
||||||
pub struct StyleBuilder<'a> {
|
pub struct StyleBuilder<'a> {
|
||||||
|
device: &'a Device,
|
||||||
|
parent_style: Option<<&'a ComputedValues>,
|
||||||
|
pseudo: Option<<&'a PseudoElement>,
|
||||||
/// The rule node representing the ordered list of rules matched for this
|
/// The rule node representing the ordered list of rules matched for this
|
||||||
/// node.
|
/// node.
|
||||||
rules: Option<StrongRuleNode>,
|
rules: Option<StrongRuleNode>,
|
||||||
|
@ -2452,8 +2480,11 @@ pub struct StyleBuilder<'a> {
|
||||||
impl<'a> StyleBuilder<'a> {
|
impl<'a> StyleBuilder<'a> {
|
||||||
/// Trivially construct a `StyleBuilder`.
|
/// Trivially construct a `StyleBuilder`.
|
||||||
fn new(
|
fn new(
|
||||||
inherited_style: &'a ComputedValuesInner,
|
device: &'a Device,
|
||||||
reset_style: &'a ComputedValuesInner,
|
parent_style: Option<<&'a ComputedValues>,
|
||||||
|
reset_style: &'a ComputedValues,
|
||||||
|
pseudo: Option<<&'a PseudoElement>,
|
||||||
|
cascade_flags: CascadeFlags,
|
||||||
rules: Option<StrongRuleNode>,
|
rules: Option<StrongRuleNode>,
|
||||||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
writing_mode: WritingMode,
|
writing_mode: WritingMode,
|
||||||
|
@ -2461,7 +2492,17 @@ impl<'a> StyleBuilder<'a> {
|
||||||
flags: ComputedValueFlags,
|
flags: ComputedValueFlags,
|
||||||
visited_style: Option<Arc<ComputedValues>>,
|
visited_style: Option<Arc<ComputedValues>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let inherited_style = parent_style.unwrap_or(reset_style);
|
||||||
|
let reset_style = if cascade_flags.contains(INHERIT_ALL) {
|
||||||
|
inherited_style
|
||||||
|
} else {
|
||||||
|
reset_style
|
||||||
|
};
|
||||||
|
|
||||||
StyleBuilder {
|
StyleBuilder {
|
||||||
|
device,
|
||||||
|
parent_style,
|
||||||
|
pseudo,
|
||||||
rules,
|
rules,
|
||||||
custom_properties,
|
custom_properties,
|
||||||
writing_mode,
|
writing_mode,
|
||||||
|
@ -2480,19 +2521,31 @@ impl<'a> StyleBuilder<'a> {
|
||||||
|
|
||||||
/// Creates a StyleBuilder holding only references to the structs of `s`, in
|
/// Creates a StyleBuilder holding only references to the structs of `s`, in
|
||||||
/// order to create a derived style.
|
/// order to create a derived style.
|
||||||
pub fn for_derived_style(s: &'a ComputedValuesInner) -> Self {
|
pub fn for_derived_style(
|
||||||
Self::for_inheritance(s, s)
|
device: &'a Device,
|
||||||
|
s: &'a ComputedValues,
|
||||||
|
pseudo: Option<<&'a PseudoElement>,
|
||||||
|
) -> Self {
|
||||||
|
Self::for_inheritance(device, s, s, pseudo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inherits style from the parent element, accounting for the default
|
/// Inherits style from the parent element, accounting for the default
|
||||||
/// computed values that need to be provided as well.
|
/// computed values that need to be provided as well.
|
||||||
pub fn for_inheritance(
|
pub fn for_inheritance(
|
||||||
parent: &'a ComputedValuesInner,
|
device: &'a Device,
|
||||||
default: &'a ComputedValuesInner
|
parent: &'a ComputedValues,
|
||||||
|
reset: &'a ComputedValues,
|
||||||
|
pseudo: Option<<&'a PseudoElement>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
// FIXME(emilio): This Some(parent) here is inconsistent with what we
|
||||||
|
// usually do if `parent` is the default computed values, but that's
|
||||||
|
// fine, and we want to eventually get rid of it.
|
||||||
Self::new(
|
Self::new(
|
||||||
parent,
|
device,
|
||||||
default,
|
Some(parent),
|
||||||
|
reset,
|
||||||
|
pseudo,
|
||||||
|
CascadeFlags::empty(),
|
||||||
/* rules = */ None,
|
/* rules = */ None,
|
||||||
parent.custom_properties(),
|
parent.custom_properties(),
|
||||||
parent.writing_mode,
|
parent.writing_mode,
|
||||||
|
@ -2566,16 +2619,20 @@ impl<'a> StyleBuilder<'a> {
|
||||||
|
|
||||||
|
|
||||||
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
||||||
pub fn build(self) -> ComputedValuesInner {
|
pub fn build(self) -> Arc<ComputedValues> {
|
||||||
ComputedValuesInner::new(self.custom_properties,
|
ComputedValues::new(
|
||||||
self.writing_mode,
|
self.device,
|
||||||
self.font_size_keyword,
|
self.parent_style,
|
||||||
self.flags,
|
self.pseudo,
|
||||||
self.rules,
|
self.custom_properties,
|
||||||
self.visited_style,
|
self.writing_mode,
|
||||||
% for style_struct in data.active_style_structs():
|
self.font_size_keyword,
|
||||||
self.${style_struct.ident}.build(),
|
self.flags,
|
||||||
% endfor
|
self.rules,
|
||||||
|
self.visited_style,
|
||||||
|
% for style_struct in data.active_style_structs():
|
||||||
|
self.${style_struct.ident}.build(),
|
||||||
|
% endfor
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2597,28 +2654,30 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
|
||||||
mod lazy_static_module {
|
mod lazy_static_module {
|
||||||
use logical_geometry::WritingMode;
|
use logical_geometry::WritingMode;
|
||||||
use stylearc::Arc;
|
use stylearc::Arc;
|
||||||
use super::{ComputedValuesInner, longhands, style_structs, FontComputationData};
|
use super::{ComputedValues, ComputedValuesInner, longhands, style_structs, FontComputationData};
|
||||||
use super::computed_value_flags::ComputedValueFlags;
|
use super::computed_value_flags::ComputedValueFlags;
|
||||||
|
|
||||||
/// The initial values for all style structs as defined by the specification.
|
/// The initial values for all style structs as defined by the specification.
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref INITIAL_SERVO_VALUES: ComputedValuesInner = ComputedValuesInner {
|
pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues {
|
||||||
% for style_struct in data.active_style_structs():
|
inner: ComputedValuesInner {
|
||||||
${style_struct.ident}: Arc::new(style_structs::${style_struct.name} {
|
% for style_struct in data.active_style_structs():
|
||||||
% for longhand in style_struct.longhands:
|
${style_struct.ident}: Arc::new(style_structs::${style_struct.name} {
|
||||||
${longhand.ident}: longhands::${longhand.ident}::get_initial_value(),
|
% for longhand in style_struct.longhands:
|
||||||
% endfor
|
${longhand.ident}: longhands::${longhand.ident}::get_initial_value(),
|
||||||
% if style_struct.name == "Font":
|
% endfor
|
||||||
hash: 0,
|
% if style_struct.name == "Font":
|
||||||
% endif
|
hash: 0,
|
||||||
}),
|
% endif
|
||||||
% endfor
|
}),
|
||||||
custom_properties: None,
|
% endfor
|
||||||
writing_mode: WritingMode::empty(),
|
custom_properties: None,
|
||||||
font_computation_data: FontComputationData::default_values(),
|
writing_mode: WritingMode::empty(),
|
||||||
rules: None,
|
font_computation_data: FontComputationData::default_values(),
|
||||||
visited_style: None,
|
rules: None,
|
||||||
flags: ComputedValueFlags::empty(),
|
visited_style: None,
|
||||||
|
flags: ComputedValueFlags::empty(),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2626,8 +2685,8 @@ mod lazy_static_module {
|
||||||
/// A per-longhand function that performs the CSS cascade for that longhand.
|
/// A per-longhand function that performs the CSS cascade for that longhand.
|
||||||
pub type CascadePropertyFn =
|
pub type CascadePropertyFn =
|
||||||
extern "Rust" fn(declaration: &PropertyDeclaration,
|
extern "Rust" fn(declaration: &PropertyDeclaration,
|
||||||
inherited_style: &ComputedValuesInner,
|
inherited_style: &ComputedValues,
|
||||||
default_style: &ComputedValuesInner,
|
default_style: &ComputedValues,
|
||||||
context: &mut computed::Context,
|
context: &mut computed::Context,
|
||||||
cacheable: &mut bool,
|
cacheable: &mut bool,
|
||||||
cascade_info: &mut Option<<&mut CascadeInfo>);
|
cascade_info: &mut Option<<&mut CascadeInfo>);
|
||||||
|
@ -2688,29 +2747,19 @@ bitflags! {
|
||||||
/// Returns the computed values.
|
/// Returns the computed values.
|
||||||
/// * `flags`: Various flags.
|
/// * `flags`: Various flags.
|
||||||
///
|
///
|
||||||
pub fn cascade(device: &Device,
|
pub fn cascade(
|
||||||
rule_node: &StrongRuleNode,
|
device: &Device,
|
||||||
guards: &StylesheetGuards,
|
pseudo: Option<<&PseudoElement>,
|
||||||
parent_style: Option<<&ComputedValuesInner>,
|
rule_node: &StrongRuleNode,
|
||||||
layout_parent_style: Option<<&ComputedValuesInner>,
|
guards: &StylesheetGuards,
|
||||||
visited_style: Option<Arc<ComputedValues>>,
|
parent_style: Option<<&ComputedValues>,
|
||||||
cascade_info: Option<<&mut CascadeInfo>,
|
layout_parent_style: Option<<&ComputedValues>,
|
||||||
font_metrics_provider: &FontMetricsProvider,
|
visited_style: Option<Arc<ComputedValues>>,
|
||||||
flags: CascadeFlags,
|
cascade_info: Option<<&mut CascadeInfo>,
|
||||||
quirks_mode: QuirksMode)
|
font_metrics_provider: &FontMetricsProvider,
|
||||||
-> ComputedValuesInner {
|
flags: CascadeFlags,
|
||||||
debug_assert!(layout_parent_style.is_none() || parent_style.is_some());
|
quirks_mode: QuirksMode
|
||||||
let (inherited_style, layout_parent_style) = match parent_style {
|
) -> Arc<ComputedValues> {
|
||||||
Some(parent_style) => {
|
|
||||||
(parent_style,
|
|
||||||
layout_parent_style.unwrap_or(parent_style))
|
|
||||||
},
|
|
||||||
None => {
|
|
||||||
(device.default_computed_values(),
|
|
||||||
device.default_computed_values())
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let iter_declarations = || {
|
let iter_declarations = || {
|
||||||
rule_node.self_and_ancestors().flat_map(|node| {
|
rule_node.self_and_ancestors().flat_map(|node| {
|
||||||
let cascade_level = node.cascade_level();
|
let cascade_level = node.cascade_level();
|
||||||
|
@ -2735,35 +2784,53 @@ pub fn cascade(device: &Device,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
apply_declarations(device,
|
apply_declarations(
|
||||||
rule_node,
|
device,
|
||||||
iter_declarations,
|
pseudo,
|
||||||
inherited_style,
|
rule_node,
|
||||||
layout_parent_style,
|
iter_declarations,
|
||||||
visited_style,
|
parent_style,
|
||||||
cascade_info,
|
layout_parent_style,
|
||||||
font_metrics_provider,
|
visited_style,
|
||||||
flags,
|
cascade_info,
|
||||||
quirks_mode)
|
font_metrics_provider,
|
||||||
|
flags,
|
||||||
|
quirks_mode,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// NOTE: This function expects the declaration with more priority to appear
|
/// NOTE: This function expects the declaration with more priority to appear
|
||||||
/// first.
|
/// first.
|
||||||
#[allow(unused_mut)] // conditionally compiled code for "position"
|
#[allow(unused_mut)] // conditionally compiled code for "position"
|
||||||
pub fn apply_declarations<'a, F, I>(device: &Device,
|
pub fn apply_declarations<'a, F, I>(
|
||||||
rules: &StrongRuleNode,
|
device: &Device,
|
||||||
iter_declarations: F,
|
pseudo: Option<<&PseudoElement>,
|
||||||
inherited_style: &ComputedValuesInner,
|
rules: &StrongRuleNode,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
iter_declarations: F,
|
||||||
visited_style: Option<Arc<ComputedValues>>,
|
parent_style: Option<<&ComputedValues>,
|
||||||
mut cascade_info: Option<<&mut CascadeInfo>,
|
layout_parent_style: Option<<&ComputedValues>,
|
||||||
font_metrics_provider: &FontMetricsProvider,
|
visited_style: Option<Arc<ComputedValues>>,
|
||||||
flags: CascadeFlags,
|
mut cascade_info: Option<<&mut CascadeInfo>,
|
||||||
quirks_mode: QuirksMode)
|
font_metrics_provider: &FontMetricsProvider,
|
||||||
-> ComputedValuesInner
|
flags: CascadeFlags,
|
||||||
where F: Fn() -> I,
|
quirks_mode: QuirksMode,
|
||||||
I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>,
|
) -> Arc<ComputedValues>
|
||||||
|
where
|
||||||
|
F: Fn() -> I,
|
||||||
|
I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>,
|
||||||
{
|
{
|
||||||
|
debug_assert!(layout_parent_style.is_none() || parent_style.is_some());
|
||||||
|
let (inherited_style, layout_parent_style) = match parent_style {
|
||||||
|
Some(parent_style) => {
|
||||||
|
(parent_style,
|
||||||
|
layout_parent_style.unwrap_or(parent_style))
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
(device.default_computed_values(),
|
||||||
|
device.default_computed_values())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let default_style = device.default_computed_values();
|
let default_style = device.default_computed_values();
|
||||||
let inherited_custom_properties = inherited_style.custom_properties();
|
let inherited_custom_properties = inherited_style.custom_properties();
|
||||||
let mut custom_properties = None;
|
let mut custom_properties = None;
|
||||||
|
@ -2780,23 +2847,19 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
::custom_properties::finish_cascade(
|
::custom_properties::finish_cascade(
|
||||||
custom_properties, &inherited_custom_properties);
|
custom_properties, &inherited_custom_properties);
|
||||||
|
|
||||||
let reset_style = if flags.contains(INHERIT_ALL) {
|
|
||||||
inherited_style
|
|
||||||
} else {
|
|
||||||
default_style
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut context = computed::Context {
|
let mut context = computed::Context {
|
||||||
is_root_element: flags.contains(IS_ROOT_ELEMENT),
|
is_root_element: flags.contains(IS_ROOT_ELEMENT),
|
||||||
device: device,
|
device: device,
|
||||||
inherited_style: inherited_style,
|
inherited_style: inherited_style,
|
||||||
layout_parent_style: layout_parent_style,
|
|
||||||
// We'd really like to own the rules here to avoid refcount traffic, but
|
// We'd really like to own the rules here to avoid refcount traffic, but
|
||||||
// animation's usage of `apply_declarations` make this tricky. See bug
|
// animation's usage of `apply_declarations` make this tricky. See bug
|
||||||
// 1375525.
|
// 1375525.
|
||||||
style: StyleBuilder::new(
|
style: StyleBuilder::new(
|
||||||
inherited_style,
|
device,
|
||||||
reset_style,
|
parent_style,
|
||||||
|
device.default_computed_values(),
|
||||||
|
pseudo,
|
||||||
|
flags,
|
||||||
Some(rules.clone()),
|
Some(rules.clone()),
|
||||||
custom_properties,
|
custom_properties,
|
||||||
WritingMode::empty(),
|
WritingMode::empty(),
|
||||||
|
@ -3038,8 +3101,11 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
||||||
|
|
||||||
{
|
{
|
||||||
StyleAdjuster::new(&mut style)
|
StyleAdjuster::new(&mut style)
|
||||||
.adjust(context.layout_parent_style,
|
.adjust(
|
||||||
context.device.default_computed_values(), flags);
|
layout_parent_style,
|
||||||
|
context.device.default_computed_values(),
|
||||||
|
flags
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
% if product == "gecko":
|
% if product == "gecko":
|
||||||
|
|
|
@ -11,7 +11,7 @@ use euclid::{Size2D, TypedSize2D};
|
||||||
use font_metrics::ServoMetricsProvider;
|
use font_metrics::ServoMetricsProvider;
|
||||||
use media_queries::MediaType;
|
use media_queries::MediaType;
|
||||||
use parser::ParserContext;
|
use parser::ParserContext;
|
||||||
use properties::{ComputedValuesInner, StyleBuilder};
|
use properties::{ComputedValues, StyleBuilder};
|
||||||
use properties::longhands::font_size;
|
use properties::longhands::font_size;
|
||||||
use selectors::parser::SelectorParseError;
|
use selectors::parser::SelectorParseError;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -62,11 +62,11 @@ impl Device {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the default computed values for this device.
|
/// Return the default computed values for this device.
|
||||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
pub fn default_computed_values(&self) -> &ComputedValues {
|
||||||
// FIXME(bz): This isn't really right, but it's no more wrong
|
// FIXME(bz): This isn't really right, but it's no more wrong
|
||||||
// than what we used to do. See
|
// than what we used to do. See
|
||||||
// https://github.com/servo/servo/issues/14773 for fixing it properly.
|
// https://github.com/servo/servo/issues/14773 for fixing it properly.
|
||||||
ComputedValuesInner::initial_values()
|
ComputedValues::initial_values()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the font size of the root element (for rem)
|
/// Get the font size of the root element (for rem)
|
||||||
|
@ -231,8 +231,7 @@ impl Range<specified::Length> {
|
||||||
is_root_element: false,
|
is_root_element: false,
|
||||||
device: device,
|
device: device,
|
||||||
inherited_style: default_values,
|
inherited_style: default_values,
|
||||||
layout_parent_style: default_values,
|
style: StyleBuilder::for_derived_style(device, default_values, None),
|
||||||
style: StyleBuilder::for_derived_style(default_values),
|
|
||||||
// Servo doesn't support font metrics
|
// Servo doesn't support font metrics
|
||||||
// A real provider will be needed here once we do; since
|
// A real provider will be needed here once we do; since
|
||||||
// ch units can exist in media queries.
|
// ch units can exist in media queries.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//! a computed style needs in order for it to adhere to the CSS spec.
|
//! a computed style needs in order for it to adhere to the CSS spec.
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use properties::{self, CascadeFlags, ComputedValuesInner};
|
use properties::{self, CascadeFlags, ComputedValues};
|
||||||
use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
|
use properties::{IS_ROOT_ELEMENT, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, StyleBuilder};
|
||||||
use properties::longhands::display::computed_value::T as display;
|
use properties::longhands::display::computed_value::T as display;
|
||||||
use properties::longhands::float::computed_value::T as float;
|
use properties::longhands::float::computed_value::T as float;
|
||||||
|
@ -54,7 +54,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// Apply the blockification rules based on the table in CSS 2.2 section 9.7.
|
/// Apply the blockification rules based on the table in CSS 2.2 section 9.7.
|
||||||
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
|
/// https://drafts.csswg.org/css2/visuren.html#dis-pos-flo
|
||||||
fn blockify_if_necessary(&mut self,
|
fn blockify_if_necessary(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
let mut blockify = false;
|
let mut blockify = false;
|
||||||
macro_rules! blockify_if {
|
macro_rules! blockify_if {
|
||||||
|
@ -136,7 +136,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html
|
/// https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html
|
||||||
/// https://github.com/servo/servo/issues/15754
|
/// https://github.com/servo/servo/issues/15754
|
||||||
fn adjust_for_writing_mode(&mut self,
|
fn adjust_for_writing_mode(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner) {
|
layout_parent_style: &ComputedValues) {
|
||||||
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
let our_writing_mode = self.style.get_inheritedbox().clone_writing_mode();
|
||||||
let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
|
let parent_writing_mode = layout_parent_style.get_inheritedbox().clone_writing_mode();
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
///
|
///
|
||||||
/// See https://github.com/servo/servo/issues/15229
|
/// See https://github.com/servo/servo/issues/15229
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValuesInner) {
|
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) {
|
||||||
use computed_values::align_items::T as align_items;
|
use computed_values::align_items::T as align_items;
|
||||||
use computed_values::align_self::T as align_self;
|
use computed_values::align_self::T as align_self;
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// this type into its ::-moz-fieldset-content anonymous box.
|
/// this type into its ::-moz-fieldset-content anonymous box.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn adjust_for_fieldset_content(&mut self,
|
fn adjust_for_fieldset_content(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
use properties::IS_FIELDSET_CONTENT;
|
use properties::IS_FIELDSET_CONTENT;
|
||||||
if !flags.contains(IS_FIELDSET_CONTENT) {
|
if !flags.contains(IS_FIELDSET_CONTENT) {
|
||||||
|
@ -340,7 +340,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
||||||
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValuesInner) {
|
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValues) {
|
||||||
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
|
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
|
||||||
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
|
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
|
||||||
!self.style.get_text().clone_text_decoration_line().is_empty() {
|
!self.style.get_text().clone_text_decoration_line().is_empty() {
|
||||||
|
@ -349,7 +349,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValuesInner) -> bool {
|
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValues) -> bool {
|
||||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||||
// Line break suppression should only be propagated to in-flow children.
|
// Line break suppression should only be propagated to in-flow children.
|
||||||
if self.style.floated() || self.style.out_of_flow_positioned() {
|
if self.style.floated() || self.style.out_of_flow_positioned() {
|
||||||
|
@ -386,8 +386,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// * correct unicode-bidi.
|
/// * correct unicode-bidi.
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn adjust_for_ruby(&mut self,
|
fn adjust_for_ruby(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
default_computed_values: &'b ComputedValuesInner,
|
default_computed_values: &'b ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
use properties::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
|
||||||
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
use properties::computed_value_flags::SHOULD_SUPPRESS_LINEBREAK;
|
||||||
|
@ -431,8 +431,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
||||||
/// When comparing to Gecko, this is similar to the work done by
|
/// When comparing to Gecko, this is similar to the work done by
|
||||||
/// `nsStyleContext::ApplyStyleFixups`.
|
/// `nsStyleContext::ApplyStyleFixups`.
|
||||||
pub fn adjust(&mut self,
|
pub fn adjust(&mut self,
|
||||||
layout_parent_style: &ComputedValuesInner,
|
layout_parent_style: &ComputedValues,
|
||||||
_default_computed_values: &'b ComputedValuesInner,
|
_default_computed_values: &'b ComputedValues,
|
||||||
flags: CascadeFlags) {
|
flags: CascadeFlags) {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ use data::{ElementStyles, EagerPseudoStyles};
|
||||||
use dom::TElement;
|
use dom::TElement;
|
||||||
use log::LogLevel::Trace;
|
use log::LogLevel::Trace;
|
||||||
use matching::{CascadeVisitedMode, MatchMethods};
|
use matching::{CascadeVisitedMode, MatchMethods};
|
||||||
use properties::{AnimationRules, CascadeFlags, ComputedValues, ComputedValuesInner};
|
use properties::{AnimationRules, CascadeFlags, ComputedValues};
|
||||||
use properties::{IS_ROOT_ELEMENT, PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
|
use properties::{IS_ROOT_ELEMENT, PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
|
||||||
use properties::{VISITED_DEPENDENT_ONLY, cascade};
|
use properties::{VISITED_DEPENDENT_ONLY, cascade};
|
||||||
use rule_tree::StrongRuleNode;
|
use rule_tree::StrongRuleNode;
|
||||||
|
@ -47,7 +47,7 @@ pub struct PrimaryStyle {
|
||||||
fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
|
fn with_default_parent_styles<E, F, R>(element: E, f: F) -> R
|
||||||
where
|
where
|
||||||
E: TElement,
|
E: TElement,
|
||||||
F: FnOnce(Option<&ComputedValues>, Option<&ComputedValuesInner>) -> R,
|
F: FnOnce(Option<&ComputedValues>, Option<&ComputedValues>) -> R,
|
||||||
{
|
{
|
||||||
let parent_el = element.inheritance_parent();
|
let parent_el = element.inheritance_parent();
|
||||||
let parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
|
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());
|
layout_parent_style = Some(layout_parent_data.styles.primary());
|
||||||
}
|
}
|
||||||
|
|
||||||
f(parent_style.map(|x| &**x), 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>
|
impl<'a, 'ctx, 'le, E> StyleResolverForElement<'a, 'ctx, 'le, E>
|
||||||
|
@ -99,7 +99,7 @@ where
|
||||||
pub fn resolve_primary_style(
|
pub fn resolve_primary_style(
|
||||||
&mut self,
|
&mut self,
|
||||||
parent_style: Option<&ComputedValues>,
|
parent_style: Option<&ComputedValues>,
|
||||||
layout_parent_style: Option<&ComputedValuesInner>,
|
layout_parent_style: Option<&ComputedValues>,
|
||||||
) -> PrimaryStyle {
|
) -> PrimaryStyle {
|
||||||
let primary_results =
|
let primary_results =
|
||||||
self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
|
self.match_primary(VisitedHandlingMode::AllLinksUnvisited);
|
||||||
|
@ -147,7 +147,7 @@ where
|
||||||
pub fn resolve_style(
|
pub fn resolve_style(
|
||||||
&mut self,
|
&mut self,
|
||||||
parent_style: Option<&ComputedValues>,
|
parent_style: Option<&ComputedValues>,
|
||||||
layout_parent_style: Option<&ComputedValuesInner>,
|
layout_parent_style: Option<&ComputedValues>,
|
||||||
) -> ElementStyles {
|
) -> ElementStyles {
|
||||||
use properties::longhands::display::computed_value::T as display;
|
use properties::longhands::display::computed_value::T as display;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ where
|
||||||
if primary_style.style.is_display_contents() {
|
if primary_style.style.is_display_contents() {
|
||||||
layout_parent_style
|
layout_parent_style
|
||||||
} else {
|
} else {
|
||||||
Some(&**primary_style.style)
|
Some(&*primary_style.style)
|
||||||
};
|
};
|
||||||
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
|
SelectorImpl::each_eagerly_cascaded_pseudo_element(|pseudo| {
|
||||||
let pseudo_style = self.resolve_pseudo_style(
|
let pseudo_style = self.resolve_pseudo_style(
|
||||||
|
@ -216,7 +216,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
inputs: CascadeInputs,
|
inputs: CascadeInputs,
|
||||||
parent_style: Option<&ComputedValues>,
|
parent_style: Option<&ComputedValues>,
|
||||||
layout_parent_style: Option<&ComputedValuesInner>,
|
layout_parent_style: Option<&ComputedValues>,
|
||||||
pseudo: Option<&PseudoElement>,
|
pseudo: Option<&PseudoElement>,
|
||||||
) -> Arc<ComputedValues> {
|
) -> Arc<ComputedValues> {
|
||||||
let mut style_if_visited = None;
|
let mut style_if_visited = None;
|
||||||
|
@ -272,7 +272,7 @@ where
|
||||||
if primary_style.style.is_display_contents() {
|
if primary_style.style.is_display_contents() {
|
||||||
layout_parent_style
|
layout_parent_style
|
||||||
} else {
|
} else {
|
||||||
Some(&**primary_style.style)
|
Some(&*primary_style.style)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() {
|
for (i, mut inputs) in pseudo_array.unwrap().iter_mut().enumerate() {
|
||||||
|
@ -302,7 +302,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
originating_element_style: &PrimaryStyle,
|
originating_element_style: &PrimaryStyle,
|
||||||
layout_parent_style: Option<&ComputedValuesInner>,
|
layout_parent_style: Option<&ComputedValues>,
|
||||||
) -> Option<Arc<ComputedValues>> {
|
) -> Option<Arc<ComputedValues>> {
|
||||||
let rules = self.match_pseudo(
|
let rules = self.match_pseudo(
|
||||||
&originating_element_style.style,
|
&originating_element_style.style,
|
||||||
|
@ -398,7 +398,7 @@ where
|
||||||
|
|
||||||
fn match_pseudo(
|
fn match_pseudo(
|
||||||
&mut self,
|
&mut self,
|
||||||
originating_element_style: &ComputedValuesInner,
|
originating_element_style: &ComputedValues,
|
||||||
pseudo_element: &PseudoElement,
|
pseudo_element: &PseudoElement,
|
||||||
visited_handling: VisitedHandlingMode,
|
visited_handling: VisitedHandlingMode,
|
||||||
) -> Option<StrongRuleNode> {
|
) -> Option<StrongRuleNode> {
|
||||||
|
@ -463,7 +463,7 @@ where
|
||||||
rules: Option<&StrongRuleNode>,
|
rules: Option<&StrongRuleNode>,
|
||||||
style_if_visited: Option<Arc<ComputedValues>>,
|
style_if_visited: Option<Arc<ComputedValues>>,
|
||||||
mut parent_style: Option<&ComputedValues>,
|
mut parent_style: Option<&ComputedValues>,
|
||||||
layout_parent_style: Option<&ComputedValuesInner>,
|
layout_parent_style: Option<&ComputedValues>,
|
||||||
cascade_visited: CascadeVisitedMode,
|
cascade_visited: CascadeVisitedMode,
|
||||||
pseudo: Option<&PseudoElement>,
|
pseudo: Option<&PseudoElement>,
|
||||||
) -> Arc<ComputedValues> {
|
) -> Arc<ComputedValues> {
|
||||||
|
@ -485,17 +485,14 @@ where
|
||||||
cascade_flags.insert(IS_ROOT_ELEMENT);
|
cascade_flags.insert(IS_ROOT_ELEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "gecko")]
|
let implemented_pseudo = self.element.implemented_pseudo_element();
|
||||||
let parent_style_context = parent_style;
|
|
||||||
#[cfg(feature = "servo")]
|
|
||||||
let parent_style_context = ();
|
|
||||||
|
|
||||||
let values =
|
let values =
|
||||||
cascade(
|
cascade(
|
||||||
self.context.shared.stylist.device(),
|
self.context.shared.stylist.device(),
|
||||||
|
pseudo.or(implemented_pseudo.as_ref()),
|
||||||
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
|
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
|
||||||
&self.context.shared.guards,
|
&self.context.shared.guards,
|
||||||
parent_style.map(|x| &**x),
|
parent_style,
|
||||||
layout_parent_style,
|
layout_parent_style,
|
||||||
style_if_visited,
|
style_if_visited,
|
||||||
Some(&mut cascade_info),
|
Some(&mut cascade_info),
|
||||||
|
@ -506,17 +503,6 @@ where
|
||||||
|
|
||||||
cascade_info.finish(&self.element.as_node());
|
cascade_info.finish(&self.element.as_node());
|
||||||
|
|
||||||
// In case of NAC like ::placeholder we style it via
|
values
|
||||||
// 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)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -702,13 +702,11 @@ impl MaybeNew for ViewportConstraints {
|
||||||
|
|
||||||
let default_values = device.default_computed_values();
|
let default_values = device.default_computed_values();
|
||||||
|
|
||||||
// TODO(emilio): Stop cloning `ComputedValues` around!
|
|
||||||
let context = Context {
|
let context = Context {
|
||||||
is_root_element: false,
|
is_root_element: false,
|
||||||
device: device,
|
device: device,
|
||||||
inherited_style: default_values,
|
inherited_style: default_values,
|
||||||
layout_parent_style: default_values,
|
style: StyleBuilder::for_derived_style(device, default_values, None),
|
||||||
style: StyleBuilder::for_derived_style(default_values),
|
|
||||||
font_metrics_provider: &provider,
|
font_metrics_provider: &provider,
|
||||||
cached_system_font: None,
|
cached_system_font: None,
|
||||||
in_media_query: false,
|
in_media_query: false,
|
||||||
|
|
|
@ -16,8 +16,8 @@ use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion};
|
||||||
use invalidation::element::invalidation_map::InvalidationMap;
|
use invalidation::element::invalidation_map::InvalidationMap;
|
||||||
use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey};
|
use invalidation::media_queries::{EffectiveMediaQueryResults, ToMediaListKey};
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
use properties::{self, CascadeFlags, ComputedValues, ComputedValuesInner};
|
use properties::{self, CascadeFlags, ComputedValues};
|
||||||
use properties::{AnimationRules, PropertyDeclarationBlock, PseudoInfo, ParentStyleContextInfo};
|
use properties::{AnimationRules, PropertyDeclarationBlock};
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
use properties::INHERIT_ALL;
|
use properties::INHERIT_ALL;
|
||||||
use rule_tree::{CascadeLevel, RuleTree, StyleSource};
|
use rule_tree::{CascadeLevel, RuleTree, StyleSource};
|
||||||
|
@ -599,11 +599,9 @@ impl Stylist {
|
||||||
pub fn precomputed_values_for_pseudo(&self,
|
pub fn precomputed_values_for_pseudo(&self,
|
||||||
guards: &StylesheetGuards,
|
guards: &StylesheetGuards,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
parent: Option<&ComputedValuesInner>,
|
parent: Option<&ComputedValues>,
|
||||||
cascade_flags: CascadeFlags,
|
cascade_flags: CascadeFlags,
|
||||||
font_metrics: &FontMetricsProvider,
|
font_metrics: &FontMetricsProvider)
|
||||||
pseudo_info: PseudoInfo,
|
|
||||||
parent_style_context: ParentStyleContextInfo)
|
|
||||||
-> Arc<ComputedValues> {
|
-> Arc<ComputedValues> {
|
||||||
debug_assert!(pseudo.is_precomputed());
|
debug_assert!(pseudo.is_precomputed());
|
||||||
|
|
||||||
|
@ -632,6 +630,7 @@ impl Stylist {
|
||||||
// the actual used value, and the computed value of it would need
|
// the actual used value, and the computed value of it would need
|
||||||
// blockification.
|
// blockification.
|
||||||
properties::cascade(&self.device,
|
properties::cascade(&self.device,
|
||||||
|
Some(pseudo),
|
||||||
&rule_node,
|
&rule_node,
|
||||||
guards,
|
guards,
|
||||||
parent,
|
parent,
|
||||||
|
@ -640,8 +639,7 @@ impl Stylist {
|
||||||
None,
|
None,
|
||||||
font_metrics,
|
font_metrics,
|
||||||
cascade_flags,
|
cascade_flags,
|
||||||
self.quirks_mode).to_outer(self.device(), parent_style_context,
|
self.quirks_mode)
|
||||||
Some(pseudo_info))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the style for an anonymous box of the given type.
|
/// Returns the style for an anonymous box of the given type.
|
||||||
|
@ -649,7 +647,7 @@ impl Stylist {
|
||||||
pub fn style_for_anonymous(&self,
|
pub fn style_for_anonymous(&self,
|
||||||
guards: &StylesheetGuards,
|
guards: &StylesheetGuards,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
parent_style: &ComputedValuesInner)
|
parent_style: &ComputedValues)
|
||||||
-> Arc<ComputedValues> {
|
-> Arc<ComputedValues> {
|
||||||
use font_metrics::ServoMetricsProvider;
|
use font_metrics::ServoMetricsProvider;
|
||||||
|
|
||||||
|
@ -678,7 +676,7 @@ impl Stylist {
|
||||||
cascade_flags.insert(INHERIT_ALL);
|
cascade_flags.insert(INHERIT_ALL);
|
||||||
}
|
}
|
||||||
self.precomputed_values_for_pseudo(guards, &pseudo, Some(parent_style), cascade_flags,
|
self.precomputed_values_for_pseudo(guards, &pseudo, Some(parent_style), cascade_flags,
|
||||||
&ServoMetricsProvider, (), ())
|
&ServoMetricsProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes a pseudo-element style lazily during layout.
|
/// Computes a pseudo-element style lazily during layout.
|
||||||
|
@ -693,22 +691,19 @@ impl Stylist {
|
||||||
element: &E,
|
element: &E,
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
rule_inclusion: RuleInclusion,
|
rule_inclusion: RuleInclusion,
|
||||||
parent_style: &ComputedValuesInner,
|
parent_style: &ComputedValues,
|
||||||
is_probe: bool,
|
is_probe: bool,
|
||||||
font_metrics: &FontMetricsProvider,
|
font_metrics: &FontMetricsProvider)
|
||||||
pseudo_info: PseudoInfo,
|
|
||||||
parent_style_context: ParentStyleContextInfo)
|
|
||||||
-> Option<Arc<ComputedValues>>
|
-> Option<Arc<ComputedValues>>
|
||||||
where E: TElement,
|
where E: TElement,
|
||||||
{
|
{
|
||||||
let cascade_inputs =
|
let cascade_inputs =
|
||||||
self.lazy_pseudo_rules(guards, element, pseudo, is_probe, rule_inclusion);
|
self.lazy_pseudo_rules(guards, element, pseudo, is_probe, rule_inclusion);
|
||||||
self.compute_pseudo_element_style_with_inputs(&cascade_inputs,
|
self.compute_pseudo_element_style_with_inputs(&cascade_inputs,
|
||||||
|
pseudo,
|
||||||
guards,
|
guards,
|
||||||
parent_style,
|
parent_style,
|
||||||
font_metrics,
|
font_metrics)
|
||||||
pseudo_info,
|
|
||||||
parent_style_context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes a pseudo-element style lazily using the given CascadeInputs.
|
/// Computes a pseudo-element style lazily using the given CascadeInputs.
|
||||||
|
@ -717,11 +712,10 @@ impl Stylist {
|
||||||
/// their style with a new parent style.
|
/// their style with a new parent style.
|
||||||
pub fn compute_pseudo_element_style_with_inputs(&self,
|
pub fn compute_pseudo_element_style_with_inputs(&self,
|
||||||
inputs: &CascadeInputs,
|
inputs: &CascadeInputs,
|
||||||
|
pseudo: &PseudoElement,
|
||||||
guards: &StylesheetGuards,
|
guards: &StylesheetGuards,
|
||||||
parent_style: &ComputedValuesInner,
|
parent_style: &ComputedValues,
|
||||||
font_metrics: &FontMetricsProvider,
|
font_metrics: &FontMetricsProvider)
|
||||||
pseudo_info: PseudoInfo,
|
|
||||||
parent_style_context: ParentStyleContextInfo)
|
|
||||||
-> Option<Arc<ComputedValues>>
|
-> Option<Arc<ComputedValues>>
|
||||||
{
|
{
|
||||||
// We may have only visited rules in cases when we are actually
|
// We may have only visited rules in cases when we are actually
|
||||||
|
@ -743,7 +737,7 @@ impl Stylist {
|
||||||
// We want to use the visited bits (if any) from our parent style as
|
// We want to use the visited bits (if any) from our parent style as
|
||||||
// our parent.
|
// our parent.
|
||||||
let inherited_style =
|
let inherited_style =
|
||||||
parent_style.get_visited_style().map(|x| &**x).unwrap_or(parent_style);
|
parent_style.get_visited_style().unwrap_or(parent_style);
|
||||||
|
|
||||||
// FIXME(emilio): The lack of layout_parent_style here could be
|
// FIXME(emilio): The lack of layout_parent_style here could be
|
||||||
// worrying, but we're probably dropping the display fixup for
|
// worrying, but we're probably dropping the display fixup for
|
||||||
|
@ -752,6 +746,7 @@ impl Stylist {
|
||||||
// (Though the flags don't indicate so!)
|
// (Though the flags don't indicate so!)
|
||||||
let computed =
|
let computed =
|
||||||
properties::cascade(&self.device,
|
properties::cascade(&self.device,
|
||||||
|
Some(pseudo),
|
||||||
rule_node,
|
rule_node,
|
||||||
guards,
|
guards,
|
||||||
Some(inherited_style),
|
Some(inherited_style),
|
||||||
|
@ -760,8 +755,7 @@ impl Stylist {
|
||||||
None,
|
None,
|
||||||
font_metrics,
|
font_metrics,
|
||||||
CascadeFlags::empty(),
|
CascadeFlags::empty(),
|
||||||
self.quirks_mode).to_outer(self.device(), parent_style_context,
|
self.quirks_mode);
|
||||||
Some(pseudo_info.clone()));
|
|
||||||
|
|
||||||
Some(computed)
|
Some(computed)
|
||||||
} else {
|
} else {
|
||||||
|
@ -777,17 +771,16 @@ impl Stylist {
|
||||||
// (tl;dr: It doesn't apply for replaced elements and such, but the
|
// (tl;dr: It doesn't apply for replaced elements and such, but the
|
||||||
// computed value is still "contents").
|
// computed value is still "contents").
|
||||||
Some(properties::cascade(&self.device,
|
Some(properties::cascade(&self.device,
|
||||||
rules,
|
Some(pseudo),
|
||||||
guards,
|
rules,
|
||||||
Some(parent_style),
|
guards,
|
||||||
Some(parent_style),
|
Some(parent_style),
|
||||||
visited_values,
|
Some(parent_style),
|
||||||
None,
|
visited_values,
|
||||||
font_metrics,
|
None,
|
||||||
CascadeFlags::empty(),
|
font_metrics,
|
||||||
self.quirks_mode).to_outer(self.device(),
|
CascadeFlags::empty(),
|
||||||
parent_style_context,
|
self.quirks_mode))
|
||||||
Some(pseudo_info)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the cascade inputs for a lazily-cascaded pseudo-element.
|
/// Computes the cascade inputs for a lazily-cascaded pseudo-element.
|
||||||
|
@ -1324,9 +1317,8 @@ impl Stylist {
|
||||||
/// Computes styles for a given declaration with parent_style.
|
/// Computes styles for a given declaration with parent_style.
|
||||||
pub fn compute_for_declarations(&self,
|
pub fn compute_for_declarations(&self,
|
||||||
guards: &StylesheetGuards,
|
guards: &StylesheetGuards,
|
||||||
parent_style: &ComputedValuesInner,
|
parent_style: &ComputedValues,
|
||||||
declarations: Arc<Locked<PropertyDeclarationBlock>>,
|
declarations: Arc<Locked<PropertyDeclarationBlock>>)
|
||||||
parent_style_context: ParentStyleContextInfo)
|
|
||||||
-> Arc<ComputedValues> {
|
-> Arc<ComputedValues> {
|
||||||
use font_metrics::get_metrics_provider_for_product;
|
use font_metrics::get_metrics_provider_for_product;
|
||||||
|
|
||||||
|
@ -1341,7 +1333,9 @@ impl Stylist {
|
||||||
// font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.
|
// font styles in <canvas> via Servo_StyleSet_ResolveForDeclarations.
|
||||||
// It is unclear if visited styles are meaningful for this case.
|
// It is unclear if visited styles are meaningful for this case.
|
||||||
let metrics = get_metrics_provider_for_product();
|
let metrics = get_metrics_provider_for_product();
|
||||||
|
// FIXME(emilio): the pseudo bit looks quite dubious!
|
||||||
properties::cascade(&self.device,
|
properties::cascade(&self.device,
|
||||||
|
/* pseudo = */ None,
|
||||||
&rule_node,
|
&rule_node,
|
||||||
guards,
|
guards,
|
||||||
Some(parent_style),
|
Some(parent_style),
|
||||||
|
@ -1350,7 +1344,7 @@ impl Stylist {
|
||||||
None,
|
None,
|
||||||
&metrics,
|
&metrics,
|
||||||
CascadeFlags::empty(),
|
CascadeFlags::empty(),
|
||||||
self.quirks_mode).to_outer(self.device(), parent_style_context, None)
|
self.quirks_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Accessor for a shared reference to the device.
|
/// Accessor for a shared reference to the device.
|
||||||
|
|
|
@ -486,7 +486,7 @@ where
|
||||||
StyleResolverForElement::new(*ancestor, context, rule_inclusion)
|
StyleResolverForElement::new(*ancestor, context, rule_inclusion)
|
||||||
.resolve_primary_style(
|
.resolve_primary_style(
|
||||||
style.as_ref().map(|s| &**s),
|
style.as_ref().map(|s| &**s),
|
||||||
layout_parent_style.as_ref().map(|s| &***s)
|
layout_parent_style.as_ref().map(|s| &**s)
|
||||||
);
|
);
|
||||||
|
|
||||||
let is_display_contents = primary_style.style.is_display_contents();
|
let is_display_contents = primary_style.style.is_display_contents();
|
||||||
|
@ -503,7 +503,7 @@ where
|
||||||
StyleResolverForElement::new(element, context, rule_inclusion)
|
StyleResolverForElement::new(element, context, rule_inclusion)
|
||||||
.resolve_style(
|
.resolve_style(
|
||||||
style.as_ref().map(|s| &**s),
|
style.as_ref().map(|s| &**s),
|
||||||
layout_parent_style.as_ref().map(|s| &***s)
|
layout_parent_style.as_ref().map(|s| &**s)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use font_metrics::FontMetricsProvider;
|
||||||
use media_queries::Device;
|
use media_queries::Device;
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use properties;
|
use properties;
|
||||||
use properties::{ComputedValuesInner, StyleBuilder};
|
use properties::{ComputedValues, StyleBuilder};
|
||||||
use std::f32;
|
use std::f32;
|
||||||
use std::f64;
|
use std::f64;
|
||||||
use std::f64::consts::PI;
|
use std::f64::consts::PI;
|
||||||
|
@ -72,13 +72,7 @@ pub struct Context<'a> {
|
||||||
pub device: &'a Device,
|
pub device: &'a Device,
|
||||||
|
|
||||||
/// The style we're inheriting from.
|
/// The style we're inheriting from.
|
||||||
pub inherited_style: &'a ComputedValuesInner,
|
pub inherited_style: &'a ComputedValues,
|
||||||
|
|
||||||
/// The style of the layout parent node. This will almost always be
|
|
||||||
/// `inherited_style`, except when `display: contents` is at play, in which
|
|
||||||
/// case it's the style of the last ancestor with a `display` value that
|
|
||||||
/// isn't `contents`.
|
|
||||||
pub layout_parent_style: &'a ComputedValuesInner,
|
|
||||||
|
|
||||||
/// Values accessed through this need to be in the properties "computed
|
/// Values accessed through this need to be in the properties "computed
|
||||||
/// early": color, text-decoration, font-size, display, position, float,
|
/// early": color, text-decoration, font-size, display, position, float,
|
||||||
|
@ -115,7 +109,7 @@ impl<'a> Context<'a> {
|
||||||
/// The current viewport size.
|
/// The current viewport size.
|
||||||
pub fn viewport_size(&self) -> Size2D<Au> { self.device.au_viewport_size() }
|
pub fn viewport_size(&self) -> Size2D<Au> { self.device.au_viewport_size() }
|
||||||
/// The style we're inheriting from.
|
/// The style we're inheriting from.
|
||||||
pub fn inherited_style(&self) -> &ComputedValuesInner { &self.inherited_style }
|
pub fn inherited_style(&self) -> &ComputedValues { &self.inherited_style }
|
||||||
/// The current style. Note that only "eager" properties should be accessed
|
/// The current style. Note that only "eager" properties should be accessed
|
||||||
/// from here, see the comment in the member.
|
/// from here, see the comment in the member.
|
||||||
pub fn style(&self) -> &StyleBuilder { &self.style }
|
pub fn style(&self) -> &StyleBuilder { &self.style }
|
||||||
|
|
|
@ -60,7 +60,6 @@ use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
|
||||||
use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowedMut;
|
use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowedMut;
|
||||||
use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
|
use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
|
||||||
use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed;
|
use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed;
|
||||||
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
|
||||||
use style::gecko_bindings::bindings::ServoStyleContextBorrowedOrNull;
|
use style::gecko_bindings::bindings::ServoStyleContextBorrowedOrNull;
|
||||||
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
||||||
use style::gecko_bindings::bindings::nsTimingFunctionBorrowed;
|
use style::gecko_bindings::bindings::nsTimingFunctionBorrowed;
|
||||||
|
@ -91,9 +90,8 @@ use style::invalidation::element::restyle_hints::{self, RestyleHint};
|
||||||
use style::media_queries::{MediaList, parse_media_query_list};
|
use style::media_queries::{MediaList, parse_media_query_list};
|
||||||
use style::parallel;
|
use style::parallel;
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::properties::{ComputedValues, ComputedValuesInner, Importance};
|
use style::properties::{ComputedValues, Importance};
|
||||||
use style::properties::{IS_FIELDSET_CONTENT, LonghandIdSet};
|
use style::properties::{IS_FIELDSET_CONTENT, LonghandIdSet};
|
||||||
use style::properties::{ParentStyleContextInfo, PseudoInfo};
|
|
||||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
|
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
|
||||||
use style::properties::{SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, SourcePropertyDeclaration, StyleBuilder};
|
use style::properties::{SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, SourcePropertyDeclaration, StyleBuilder};
|
||||||
use style::properties::animated_properties::{Animatable, AnimatableLonghand, AnimationValue};
|
use style::properties::animated_properties::{Animatable, AnimatableLonghand, AnimationValue};
|
||||||
|
@ -725,15 +723,16 @@ pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawSe
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: ServoComputedValuesBorrowed,
|
pub extern "C" fn Servo_ComputedValues_ExtractAnimationValue(computed_values: ServoStyleContextBorrowed,
|
||||||
property_id: nsCSSPropertyID)
|
property_id: nsCSSPropertyID)
|
||||||
-> RawServoAnimationValueStrong
|
-> RawServoAnimationValueStrong
|
||||||
{
|
{
|
||||||
let property = match AnimatableLonghand::from_nscsspropertyid(property_id) {
|
let property = match AnimatableLonghand::from_nscsspropertyid(property_id) {
|
||||||
Some(longhand) => longhand,
|
Some(longhand) => longhand,
|
||||||
None => { return Strong::null(); }
|
None => return Strong::null(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let computed_values = ComputedValues::as_arc(&computed_values);
|
||||||
Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong()
|
Arc::new(AnimationValue::from_computed_values(&property, computed_values)).into_strong()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1504,7 +1503,6 @@ pub extern "C" fn Servo_DocumentRule_GetConditionText(rule: RawServoDocumentRule
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoStyleContextBorrowedOrNull,
|
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoStyleContextBorrowedOrNull,
|
||||||
pseudo_type: CSSPseudoElementType,
|
|
||||||
pseudo_tag: *mut nsIAtom,
|
pseudo_tag: *mut nsIAtom,
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed)
|
||||||
-> ServoStyleContextStrong {
|
-> ServoStyleContextStrong {
|
||||||
|
@ -1521,20 +1519,19 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||||
cascade_flags.insert(IS_FIELDSET_CONTENT);
|
cascade_flags.insert(IS_FIELDSET_CONTENT);
|
||||||
}
|
}
|
||||||
let metrics = get_metrics_provider_for_product();
|
let metrics = get_metrics_provider_for_product();
|
||||||
data.stylist.precomputed_values_for_pseudo(&guards, &pseudo, parent_style_or_null.map(|x| &**x),
|
data.stylist.precomputed_values_for_pseudo(
|
||||||
cascade_flags, &metrics,
|
&guards,
|
||||||
(pseudo_tag, pseudo_type),
|
&pseudo,
|
||||||
parent_style_or_null)
|
parent_style_or_null.map(|x| &*x),
|
||||||
.into_strong()
|
cascade_flags, &metrics
|
||||||
|
).into_strong()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||||
pseudo_type: CSSPseudoElementType,
|
pseudo_type: CSSPseudoElementType,
|
||||||
pseudo_tag: *mut nsIAtom,
|
|
||||||
is_probe: bool,
|
is_probe: bool,
|
||||||
inherited_style: ServoComputedValuesBorrowedOrNull,
|
inherited_style: ServoStyleContextBorrowedOrNull,
|
||||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed)
|
||||||
-> ServoStyleContextStrong
|
-> ServoStyleContextStrong
|
||||||
{
|
{
|
||||||
|
@ -1551,9 +1548,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||||
return if is_probe {
|
return if is_probe {
|
||||||
Strong::null()
|
Strong::null()
|
||||||
} else {
|
} else {
|
||||||
doc_data.default_computed_values()
|
doc_data.default_computed_values().clone().into_strong()
|
||||||
.clone().to_outer(doc_data.stylist.device(), parent_style_context,
|
|
||||||
Some((pseudo_tag, pseudo_type))).into_strong()
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1571,8 +1566,6 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||||
inherited_style,
|
inherited_style,
|
||||||
&*doc_data,
|
&*doc_data,
|
||||||
is_probe,
|
is_probe,
|
||||||
(pseudo_tag, pseudo_type),
|
|
||||||
parent_style_context
|
|
||||||
);
|
);
|
||||||
|
|
||||||
match style {
|
match style {
|
||||||
|
@ -1624,11 +1617,9 @@ fn get_pseudo_style(
|
||||||
pseudo: &PseudoElement,
|
pseudo: &PseudoElement,
|
||||||
rule_inclusion: RuleInclusion,
|
rule_inclusion: RuleInclusion,
|
||||||
styles: &ElementStyles,
|
styles: &ElementStyles,
|
||||||
inherited_styles: Option<&ComputedValuesInner>,
|
inherited_styles: Option<&ComputedValues>,
|
||||||
doc_data: &PerDocumentStyleDataImpl,
|
doc_data: &PerDocumentStyleDataImpl,
|
||||||
is_probe: bool,
|
is_probe: bool,
|
||||||
pseudo_info: PseudoInfo,
|
|
||||||
parent_style_context: ParentStyleContextInfo,
|
|
||||||
) -> Option<Arc<ComputedValues>> {
|
) -> Option<Arc<ComputedValues>> {
|
||||||
let style = match pseudo.cascade_type() {
|
let style = match pseudo.cascade_type() {
|
||||||
PseudoElementCascadeType::Eager => {
|
PseudoElementCascadeType::Eager => {
|
||||||
|
@ -1648,17 +1639,17 @@ fn get_pseudo_style(
|
||||||
doc_data.stylist
|
doc_data.stylist
|
||||||
.compute_pseudo_element_style_with_inputs(
|
.compute_pseudo_element_style_with_inputs(
|
||||||
&inputs,
|
&inputs,
|
||||||
|
pseudo,
|
||||||
&guards,
|
&guards,
|
||||||
inherited_styles,
|
inherited_styles,
|
||||||
&metrics,
|
&metrics
|
||||||
pseudo_info.clone(),
|
)
|
||||||
parent_style_context)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
debug_assert!(inherited_styles.is_none() ||
|
debug_assert!(inherited_styles.is_none() ||
|
||||||
ptr::eq(&*inherited_styles.unwrap(),
|
ptr::eq(inherited_styles.unwrap(),
|
||||||
&***styles.primary()));
|
&**styles.primary()));
|
||||||
styles.pseudos.get(&pseudo).cloned()
|
styles.pseudos.get(&pseudo).cloned()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1666,8 +1657,8 @@ fn get_pseudo_style(
|
||||||
PseudoElementCascadeType::Precomputed => unreachable!("No anonymous boxes"),
|
PseudoElementCascadeType::Precomputed => unreachable!("No anonymous boxes"),
|
||||||
PseudoElementCascadeType::Lazy => {
|
PseudoElementCascadeType::Lazy => {
|
||||||
debug_assert!(inherited_styles.is_none() ||
|
debug_assert!(inherited_styles.is_none() ||
|
||||||
ptr::eq(&*inherited_styles.unwrap(),
|
ptr::eq(inherited_styles.unwrap(),
|
||||||
&***styles.primary()));
|
&**styles.primary()));
|
||||||
let base = if pseudo.inherits_from_default_values() {
|
let base = if pseudo.inherits_from_default_values() {
|
||||||
doc_data.default_computed_values()
|
doc_data.default_computed_values()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1684,8 +1675,7 @@ fn get_pseudo_style(
|
||||||
base,
|
base,
|
||||||
is_probe,
|
is_probe,
|
||||||
&metrics,
|
&metrics,
|
||||||
pseudo_info.clone(),
|
)
|
||||||
parent_style_context)
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1695,17 +1685,17 @@ fn get_pseudo_style(
|
||||||
|
|
||||||
Some(style.unwrap_or_else(|| {
|
Some(style.unwrap_or_else(|| {
|
||||||
StyleBuilder::for_inheritance(
|
StyleBuilder::for_inheritance(
|
||||||
|
doc_data.stylist.device(),
|
||||||
styles.primary(),
|
styles.primary(),
|
||||||
doc_data.default_computed_values(),
|
doc_data.default_computed_values(),
|
||||||
).build().to_outer(doc_data.stylist.device(), parent_style_context,
|
Some(pseudo),
|
||||||
Some(pseudo_info))
|
).build()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ComputedValues_Inherit(
|
pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||||
raw_data: RawServoStyleSetBorrowed,
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
pseudo_type: CSSPseudoElementType,
|
|
||||||
pseudo_tag: *mut nsIAtom,
|
pseudo_tag: *mut nsIAtom,
|
||||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||||
target: structs::InheritTarget
|
target: structs::InheritTarget
|
||||||
|
@ -1713,10 +1703,17 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
|
|
||||||
let for_text = target == structs::InheritTarget::Text;
|
let for_text = target == structs::InheritTarget::Text;
|
||||||
|
let atom = Atom::from(pseudo_tag);
|
||||||
|
let pseudo = PseudoElement::from_anon_box_atom(&atom)
|
||||||
|
.expect("Not an anon-box? Gah!");
|
||||||
let style = if let Some(reference) = parent_style_context {
|
let style = if let Some(reference) = parent_style_context {
|
||||||
let mut style =
|
let mut style = StyleBuilder::for_inheritance(
|
||||||
StyleBuilder::for_inheritance(reference,
|
data.stylist.device(),
|
||||||
&data.default_computed_values());
|
reference,
|
||||||
|
data.default_computed_values(),
|
||||||
|
Some(&pseudo)
|
||||||
|
);
|
||||||
|
|
||||||
if for_text {
|
if for_text {
|
||||||
StyleAdjuster::new(&mut style)
|
StyleAdjuster::new(&mut style)
|
||||||
.adjust_for_text();
|
.adjust_for_text();
|
||||||
|
@ -1725,29 +1722,14 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||||
style.build()
|
style.build()
|
||||||
} else {
|
} else {
|
||||||
debug_assert!(!for_text);
|
debug_assert!(!for_text);
|
||||||
data.default_computed_values().clone()
|
StyleBuilder::for_derived_style(
|
||||||
|
data.stylist.device(),
|
||||||
|
data.default_computed_values(),
|
||||||
|
Some(&pseudo),
|
||||||
|
).build()
|
||||||
};
|
};
|
||||||
|
|
||||||
let pseudo_info = if pseudo_tag.is_null() {
|
style.into_strong()
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some((pseudo_tag, pseudo_type))
|
|
||||||
};
|
|
||||||
|
|
||||||
style.to_outer(data.stylist.device(), parent_style_context, pseudo_info).into_strong()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn Servo_StyleContext_NewContext(values: ServoComputedValuesBorrowed,
|
|
||||||
parent: ServoStyleContextBorrowedOrNull,
|
|
||||||
pres_context: bindings::RawGeckoPresContextBorrowed,
|
|
||||||
pseudo_type: CSSPseudoElementType,
|
|
||||||
pseudo_tag: *mut nsIAtom)
|
|
||||||
-> ServoStyleContextStrong {
|
|
||||||
unsafe {
|
|
||||||
(*values).clone().to_outer_helper(pres_context, parent,
|
|
||||||
pseudo_type, pseudo_tag).into_strong()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -2827,8 +2809,6 @@ pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||||
pseudo_type: CSSPseudoElementType,
|
pseudo_type: CSSPseudoElementType,
|
||||||
pseudo_tag: *mut nsIAtom,
|
|
||||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
|
||||||
rule_inclusion: StyleRuleInclusion,
|
rule_inclusion: StyleRuleInclusion,
|
||||||
snapshots: *const ServoElementSnapshotTable,
|
snapshots: *const ServoElementSnapshotTable,
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed)
|
||||||
|
@ -2853,8 +2833,6 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||||
/* inherited_styles = */ None,
|
/* inherited_styles = */ None,
|
||||||
&*data,
|
&*data,
|
||||||
/* is_probe = */ false,
|
/* is_probe = */ false,
|
||||||
(pseudo_tag, pseudo_type),
|
|
||||||
parent_style_context
|
|
||||||
).expect("We're not probing, so we should always get a style \
|
).expect("We're not probing, so we should always get a style \
|
||||||
back")
|
back")
|
||||||
}
|
}
|
||||||
|
@ -2908,8 +2886,9 @@ fn simulate_compute_values_failure(_: &PropertyValuePair) -> bool {
|
||||||
|
|
||||||
fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||||
font_metrics_provider: &'a FontMetricsProvider,
|
font_metrics_provider: &'a FontMetricsProvider,
|
||||||
style: &'a ComputedValuesInner,
|
style: &'a ComputedValues,
|
||||||
parent_style: &'a Option<&ComputedValuesInner>)
|
parent_style: Option<&'a ComputedValues>,
|
||||||
|
pseudo: Option<&'a PseudoElement>)
|
||||||
-> Context<'a> {
|
-> Context<'a> {
|
||||||
let default_values = per_doc_data.default_computed_values();
|
let default_values = per_doc_data.default_computed_values();
|
||||||
let inherited_style = parent_style.unwrap_or(default_values);
|
let inherited_style = parent_style.unwrap_or(default_values);
|
||||||
|
@ -2918,8 +2897,7 @@ fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||||
is_root_element: false,
|
is_root_element: false,
|
||||||
device: per_doc_data.stylist.device(),
|
device: per_doc_data.stylist.device(),
|
||||||
inherited_style: inherited_style,
|
inherited_style: inherited_style,
|
||||||
layout_parent_style: inherited_style,
|
style: StyleBuilder::for_derived_style(per_doc_data.stylist.device(), style, pseudo),
|
||||||
style: StyleBuilder::for_derived_style(&style),
|
|
||||||
font_metrics_provider: font_metrics_provider,
|
font_metrics_provider: font_metrics_provider,
|
||||||
cached_system_font: None,
|
cached_system_font: None,
|
||||||
in_media_query: false,
|
in_media_query: false,
|
||||||
|
@ -2930,7 +2908,7 @@ fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeListBorrowed,
|
pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeListBorrowed,
|
||||||
element: RawGeckoElementBorrowed,
|
element: RawGeckoElementBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoStyleContextBorrowed,
|
||||||
raw_data: RawServoStyleSetBorrowed,
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut)
|
computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut)
|
||||||
{
|
{
|
||||||
|
@ -2939,13 +2917,15 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
||||||
|
|
||||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
let metrics = get_metrics_provider_for_product();
|
let metrics = get_metrics_provider_for_product();
|
||||||
|
let style = ComputedValues::as_arc(&style);
|
||||||
|
|
||||||
let element = GeckoElement(element);
|
let element = GeckoElement(element);
|
||||||
let parent_element = element.inheritance_parent();
|
let parent_element = element.inheritance_parent();
|
||||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x);
|
||||||
|
|
||||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
let pseudo = style.pseudo();
|
||||||
|
let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref());
|
||||||
|
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let guard = global_style_data.shared_lock.read();
|
let guard = global_style_data.shared_lock.read();
|
||||||
|
@ -3014,18 +2994,20 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBlockBorrowed,
|
pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBlockBorrowed,
|
||||||
element: RawGeckoElementBorrowed,
|
element: RawGeckoElementBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoStyleContextBorrowed,
|
||||||
raw_data: RawServoStyleSetBorrowed,
|
raw_data: RawServoStyleSetBorrowed,
|
||||||
animation_values: RawGeckoServoAnimationValueListBorrowedMut) {
|
animation_values: RawGeckoServoAnimationValueListBorrowedMut) {
|
||||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
let metrics = get_metrics_provider_for_product();
|
let metrics = get_metrics_provider_for_product();
|
||||||
|
let style = ComputedValues::as_arc(&style);
|
||||||
|
|
||||||
let element = GeckoElement(element);
|
let element = GeckoElement(element);
|
||||||
let parent_element = element.inheritance_parent();
|
let parent_element = element.inheritance_parent();
|
||||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x);
|
||||||
|
|
||||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
let pseudo = style.pseudo();
|
||||||
|
let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref());
|
||||||
|
|
||||||
let default_values = data.default_computed_values();
|
let default_values = data.default_computed_values();
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
|
@ -3042,18 +3024,20 @@ pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBloc
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
pub extern "C" fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
||||||
declarations: RawServoDeclarationBlockBorrowed,
|
declarations: RawServoDeclarationBlockBorrowed,
|
||||||
style: ServoComputedValuesBorrowed,
|
style: ServoStyleContextBorrowed,
|
||||||
raw_data: RawServoStyleSetBorrowed)
|
raw_data: RawServoStyleSetBorrowed)
|
||||||
-> RawServoAnimationValueStrong {
|
-> RawServoAnimationValueStrong {
|
||||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||||
let metrics = get_metrics_provider_for_product();
|
let metrics = get_metrics_provider_for_product();
|
||||||
|
let style = ComputedValues::as_arc(&style);
|
||||||
|
|
||||||
let element = GeckoElement(element);
|
let element = GeckoElement(element);
|
||||||
let parent_element = element.inheritance_parent();
|
let parent_element = element.inheritance_parent();
|
||||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x);
|
||||||
|
|
||||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
let pseudo = style.pseudo();
|
||||||
|
let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref());
|
||||||
|
|
||||||
let default_values = data.default_computed_values();
|
let default_values = data.default_computed_values();
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
|
@ -3304,16 +3288,17 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
|
||||||
let guards = StylesheetGuards::same(&guard);
|
let guards = StylesheetGuards::same(&guard);
|
||||||
|
|
||||||
let parent_style = match parent_style_context {
|
let parent_style = match parent_style_context {
|
||||||
Some(parent) => &**parent,
|
Some(parent) => &*parent,
|
||||||
None => doc_data.default_computed_values(),
|
None => doc_data.default_computed_values(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||||
|
|
||||||
doc_data.stylist.compute_for_declarations(&guards,
|
doc_data.stylist.compute_for_declarations(
|
||||||
parent_style,
|
&guards,
|
||||||
declarations.clone_arc(),
|
parent_style,
|
||||||
parent_style_context).into_strong()
|
declarations.clone_arc(),
|
||||||
|
).into_strong()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
|
@ -11,7 +11,7 @@ use style::context::QuirksMode;
|
||||||
use style::font_metrics::ServoMetricsProvider;
|
use style::font_metrics::ServoMetricsProvider;
|
||||||
use style::media_queries::{Device, MediaType};
|
use style::media_queries::{Device, MediaType};
|
||||||
use style::parser::ParserContext;
|
use style::parser::ParserContext;
|
||||||
use style::properties::{ComputedValues, ComputedValuesInner, StyleBuilder};
|
use style::properties::{ComputedValues, StyleBuilder};
|
||||||
use style::stylesheets::{CssRuleType, Origin};
|
use style::stylesheets::{CssRuleType, Origin};
|
||||||
use style::values::computed::{Context, ToComputedValue};
|
use style::values::computed::{Context, ToComputedValue};
|
||||||
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
|
use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError};
|
||||||
|
@ -49,15 +49,14 @@ fn assert_computed_serialization<C, F, T>(f: F, input: &'static str, output: &st
|
||||||
T: ToComputedValue<ComputedValue=C>, C: ToCss
|
T: ToComputedValue<ComputedValue=C>, C: ToCss
|
||||||
{
|
{
|
||||||
let viewport_size = TypedSize2D::new(0., 0.);
|
let viewport_size = TypedSize2D::new(0., 0.);
|
||||||
let initial_style = ComputedValuesInner::initial_values();
|
let initial_style = ComputedValues::initial_values();
|
||||||
let device = Device::new(MediaType::Screen, viewport_size);
|
let device = Device::new(MediaType::Screen, viewport_size);
|
||||||
|
|
||||||
let context = Context {
|
let context = Context {
|
||||||
is_root_element: true,
|
is_root_element: true,
|
||||||
device: &device,
|
device: &device,
|
||||||
inherited_style: initial_style,
|
inherited_style: initial_style,
|
||||||
layout_parent_style: initial_style,
|
style: StyleBuilder::for_derived_style(&device, initial_style, None),
|
||||||
style: StyleBuilder::for_derived_style(&initial_style),
|
|
||||||
cached_system_font: None,
|
cached_system_font: None,
|
||||||
font_metrics_provider: &ServoMetricsProvider,
|
font_metrics_provider: &ServoMetricsProvider,
|
||||||
in_media_query: false,
|
in_media_query: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue