mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #16280 - hiikezoe:handle-base-style, r=heycam,birtles
Handle base style <!-- Please describe your changes on the following line: --> This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1311257 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] These changes do not require tests because it's for stylo. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/16280) <!-- Reviewable:end -->
This commit is contained in:
commit
d7fb2cc27f
7 changed files with 9113 additions and 8073 deletions
|
@ -273,6 +273,9 @@ mod bindings {
|
|||
.include(add_include("gfxFontConstants.h"))
|
||||
.include(add_include("nsThemeConstants.h"))
|
||||
.include(add_include("mozilla/dom/AnimationEffectReadOnlyBinding.h"))
|
||||
.include(add_include("mozilla/AnimationPropertySegment.h"))
|
||||
.include(add_include("mozilla/ComputedTiming.h"))
|
||||
.include(add_include("mozilla/ComputedTimingFunction.h"))
|
||||
.include(add_include("mozilla/Keyframe.h"))
|
||||
.include(add_include("mozilla/ServoElementSnapshot.h"))
|
||||
.include(add_include("mozilla/dom/Element.h"))
|
||||
|
@ -308,6 +311,10 @@ mod bindings {
|
|||
];
|
||||
let whitelist = [
|
||||
"RawGecko.*",
|
||||
"mozilla::AnimationPropertySegment",
|
||||
"mozilla::ComputedTiming",
|
||||
"mozilla::ComputedTimingFunction",
|
||||
"mozilla::ComputedTimingFunction::BeforeFlag",
|
||||
"mozilla::ServoStyleSheet",
|
||||
"mozilla::ServoElementSnapshot.*",
|
||||
"mozilla::CSSPseudoClassType",
|
||||
|
@ -591,6 +598,8 @@ mod bindings {
|
|||
.whitelisted_function("Gecko_.*");
|
||||
let structs_types = [
|
||||
"mozilla::css::URLValue",
|
||||
"RawGeckoAnimationPropertySegment",
|
||||
"RawGeckoComputedTiming",
|
||||
"RawGeckoDocument",
|
||||
"RawGeckoElement",
|
||||
"RawGeckoKeyframeList",
|
||||
|
@ -608,6 +617,7 @@ mod bindings {
|
|||
"RefPtr",
|
||||
"CSSPseudoClassType",
|
||||
"TraversalRootBehavior",
|
||||
"ComputedTimingFunction_BeforeFlag",
|
||||
"FontFamilyList",
|
||||
"FontFamilyType",
|
||||
"Keyframe",
|
||||
|
@ -708,7 +718,9 @@ mod bindings {
|
|||
let servo_borrow_types = [
|
||||
"nsCSSValue",
|
||||
"nsTimingFunction",
|
||||
"RawGeckoAnimationPropertySegment",
|
||||
"RawGeckoAnimationValueList",
|
||||
"RawGeckoComputedTiming",
|
||||
"RawGeckoKeyframeList",
|
||||
"RawGeckoComputedKeyframeValuesList",
|
||||
"RawGeckoFontFaceRuleList",
|
||||
|
|
|
@ -4,6 +4,8 @@ pub use nsstring::{nsACString, nsAString, nsString};
|
|||
type nsACString_internal = nsACString;
|
||||
type nsAString_internal = nsAString;
|
||||
use gecko_bindings::structs::mozilla::css::URLValue;
|
||||
use gecko_bindings::structs::RawGeckoAnimationPropertySegment;
|
||||
use gecko_bindings::structs::RawGeckoComputedTiming;
|
||||
use gecko_bindings::structs::RawGeckoDocument;
|
||||
use gecko_bindings::structs::RawGeckoElement;
|
||||
use gecko_bindings::structs::RawGeckoKeyframeList;
|
||||
|
@ -21,6 +23,7 @@ use gecko_bindings::structs::RawGeckoURLExtraData;
|
|||
use gecko_bindings::structs::RefPtr;
|
||||
use gecko_bindings::structs::CSSPseudoClassType;
|
||||
use gecko_bindings::structs::TraversalRootBehavior;
|
||||
use gecko_bindings::structs::ComputedTimingFunction_BeforeFlag;
|
||||
use gecko_bindings::structs::FontFamilyList;
|
||||
use gecko_bindings::structs::FontFamilyType;
|
||||
use gecko_bindings::structs::Keyframe;
|
||||
|
@ -269,10 +272,18 @@ pub type nsTimingFunctionBorrowed<'a> = &'a nsTimingFunction;
|
|||
pub type nsTimingFunctionBorrowedOrNull<'a> = Option<&'a nsTimingFunction>;
|
||||
pub type nsTimingFunctionBorrowedMut<'a> = &'a mut nsTimingFunction;
|
||||
pub type nsTimingFunctionBorrowedMutOrNull<'a> = Option<&'a mut nsTimingFunction>;
|
||||
pub type RawGeckoAnimationPropertySegmentBorrowed<'a> = &'a RawGeckoAnimationPropertySegment;
|
||||
pub type RawGeckoAnimationPropertySegmentBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationPropertySegment>;
|
||||
pub type RawGeckoAnimationPropertySegmentBorrowedMut<'a> = &'a mut RawGeckoAnimationPropertySegment;
|
||||
pub type RawGeckoAnimationPropertySegmentBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationPropertySegment>;
|
||||
pub type RawGeckoAnimationValueListBorrowed<'a> = &'a RawGeckoAnimationValueList;
|
||||
pub type RawGeckoAnimationValueListBorrowedOrNull<'a> = Option<&'a RawGeckoAnimationValueList>;
|
||||
pub type RawGeckoAnimationValueListBorrowedMut<'a> = &'a mut RawGeckoAnimationValueList;
|
||||
pub type RawGeckoAnimationValueListBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoAnimationValueList>;
|
||||
pub type RawGeckoComputedTimingBorrowed<'a> = &'a RawGeckoComputedTiming;
|
||||
pub type RawGeckoComputedTimingBorrowedOrNull<'a> = Option<&'a RawGeckoComputedTiming>;
|
||||
pub type RawGeckoComputedTimingBorrowedMut<'a> = &'a mut RawGeckoComputedTiming;
|
||||
pub type RawGeckoComputedTimingBorrowedMutOrNull<'a> = Option<&'a mut RawGeckoComputedTiming>;
|
||||
pub type RawGeckoKeyframeListBorrowed<'a> = &'a RawGeckoKeyframeList;
|
||||
pub type RawGeckoKeyframeListBorrowedOrNull<'a> = Option<&'a RawGeckoKeyframeList>;
|
||||
pub type RawGeckoKeyframeListBorrowedMut<'a> = &'a mut RawGeckoKeyframeList;
|
||||
|
@ -450,18 +461,9 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Gecko_ElementState(element: RawGeckoElementBorrowed) -> u64;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_IsLink(element: RawGeckoElementBorrowed) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_IsTextNode(node: RawGeckoNodeBorrowed) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_IsVisitedLink(element: RawGeckoElementBorrowed) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_IsUnvisitedLink(element: RawGeckoElementBorrowed) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_IsRootElement(element: RawGeckoElementBorrowed) -> bool;
|
||||
}
|
||||
|
@ -587,7 +589,8 @@ extern "C" {
|
|||
-> RawServoDeclarationBlockStrongBorrowedOrNull;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_GetExtraContentStyleDeclarations(element: RawGeckoElementBorrowed)
|
||||
pub fn Gecko_GetExtraContentStyleDeclarations(element:
|
||||
RawGeckoElementBorrowed)
|
||||
-> RawServoDeclarationBlockStrongBorrowedOrNull;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -624,6 +627,25 @@ extern "C" {
|
|||
aPseudoTagOrNull: *mut nsIAtom)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_GetProgressFromComputedTiming(aComputedTiming:
|
||||
RawGeckoComputedTimingBorrowed)
|
||||
-> f64;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_GetPositionInSegment(aSegment:
|
||||
RawGeckoAnimationPropertySegmentBorrowed,
|
||||
aProgress: f64,
|
||||
aBeforeFlag:
|
||||
ComputedTimingFunction_BeforeFlag)
|
||||
-> f64;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_AnimationGetBaseStyle(aBaseStyles:
|
||||
*mut ::std::os::raw::c_void,
|
||||
aProperty: nsCSSPropertyID)
|
||||
-> RawServoAnimationValueBorrowedOrNull;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_Atomize(aString: *const ::std::os::raw::c_char, aLength: u32)
|
||||
-> *mut nsIAtom;
|
||||
|
@ -1585,6 +1607,13 @@ extern "C" {
|
|||
value:
|
||||
RawServoAnimationValueBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_ExtractAnimationValue(computed_values:
|
||||
ServoComputedValuesBorrowed,
|
||||
property:
|
||||
nsCSSPropertyID)
|
||||
-> RawServoAnimationValueStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValues_Interpolate(from:
|
||||
RawServoAnimationValueBorrowed,
|
||||
|
@ -1710,6 +1739,16 @@ extern "C" {
|
|||
property:
|
||||
nsCSSPropertyID);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationCompose(animation_values:
|
||||
RawServoAnimationValueMapBorrowed,
|
||||
base_values: *mut ::std::os::raw::c_void,
|
||||
property: nsCSSPropertyID,
|
||||
animation_segment:
|
||||
RawGeckoAnimationPropertySegmentBorrowed,
|
||||
computed_timing:
|
||||
RawGeckoComputedTimingBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DeclarationBlock_PropertyIsSet(declarations:
|
||||
RawServoDeclarationBlockBorrowed,
|
||||
|
@ -1841,8 +1880,7 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
||||
set: RawServoStyleSetBorrowed,
|
||||
allow_stale: bool)
|
||||
-> ServoComputedValuesStrong;
|
||||
allow_stale: bool) -> ServoComputedValuesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||
|
@ -1865,6 +1903,15 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleSet_GetBaseComputedValuesForElement(set:
|
||||
RawServoStyleSetBorrowed,
|
||||
element:
|
||||
RawGeckoElementBorrowed,
|
||||
pseudo_tag:
|
||||
*mut nsIAtom)
|
||||
-> ServoComputedValuesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_GetStyleFont(computed_values:
|
||||
ServoComputedValuesBorrowedOrNull)
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -468,19 +468,18 @@ trait PrivateMatchMethods: TElement {
|
|||
}
|
||||
|
||||
fn cascade_with_rules(&self,
|
||||
context: &StyleContext<Self>,
|
||||
shared_context: &SharedStyleContext,
|
||||
rule_node: &StrongRuleNode,
|
||||
primary_style: &ComputedStyle,
|
||||
pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>,
|
||||
cascade_flags: CascadeFlags)
|
||||
cascade_flags: CascadeFlags,
|
||||
is_pseudo: bool)
|
||||
-> Arc<ComputedValues> {
|
||||
let shared_context = context.shared;
|
||||
let mut cascade_info = CascadeInfo::new();
|
||||
|
||||
// Grab the inherited values.
|
||||
let parent_el;
|
||||
let parent_data;
|
||||
let inherited_values_ = if pseudo_style.is_none() {
|
||||
let inherited_values_ = if !is_pseudo {
|
||||
parent_el = self.parent_element();
|
||||
parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_values = parent_data.as_ref().map(|d| {
|
||||
|
@ -517,7 +516,7 @@ trait PrivateMatchMethods: TElement {
|
|||
//
|
||||
// Note that this is not needed for pseudos since we already do that
|
||||
// when we resolve the non-pseudo style.
|
||||
if pseudo_style.is_none() {
|
||||
if !is_pseudo {
|
||||
if let Some(ref p) = layout_parent_style {
|
||||
let can_be_fragmented =
|
||||
p.is_multicol() ||
|
||||
|
@ -557,7 +556,7 @@ trait PrivateMatchMethods: TElement {
|
|||
|
||||
// Grab the rule node.
|
||||
let rule_node = &pseudo_style.as_ref().map_or(primary_style, |p| &*p.1).rules;
|
||||
self.cascade_with_rules(context, rule_node, primary_style, pseudo_style, cascade_flags)
|
||||
self.cascade_with_rules(context.shared, rule_node, primary_style, cascade_flags, pseudo_style.is_some())
|
||||
}
|
||||
|
||||
/// Computes values and damage for the primary or pseudo style of an element,
|
||||
|
@ -606,7 +605,7 @@ trait PrivateMatchMethods: TElement {
|
|||
fn get_after_change_style(&self,
|
||||
context: &mut StyleContext<Self>,
|
||||
primary_style: &ComputedStyle,
|
||||
pseudo_style: &Option<(&PseudoElement, &mut ComputedStyle)>)
|
||||
pseudo_style: &Option<(&PseudoElement, &ComputedStyle)>)
|
||||
-> Arc<ComputedValues> {
|
||||
let style = &pseudo_style.as_ref().map_or(primary_style, |p| &*p.1);
|
||||
let rule_node = &style.rules;
|
||||
|
@ -622,11 +621,11 @@ trait PrivateMatchMethods: TElement {
|
|||
if self.skip_root_and_item_based_display_fixup() {
|
||||
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP)
|
||||
}
|
||||
self.cascade_with_rules(context,
|
||||
self.cascade_with_rules(context.shared,
|
||||
&without_transition_rules,
|
||||
primary_style,
|
||||
&pseudo_style,
|
||||
cascade_flags)
|
||||
cascade_flags,
|
||||
pseudo_style.is_some())
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -1211,6 +1210,34 @@ pub trait MatchMethods : TElement {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns computed values without animation and transition rules.
|
||||
fn get_base_style(&self,
|
||||
shared_context: &SharedStyleContext,
|
||||
primary_style: &ComputedStyle,
|
||||
pseudo_style: &Option<(&PseudoElement, &ComputedStyle)>)
|
||||
-> Arc<ComputedValues> {
|
||||
let style = &pseudo_style.as_ref().map_or(primary_style, |p| &*p.1);
|
||||
let rule_node = &style.rules;
|
||||
let without_animation_rules =
|
||||
shared_context.stylist.rule_tree.remove_animation_and_transition_rules(rule_node);
|
||||
if without_animation_rules == *rule_node {
|
||||
// Note that unwrapping here is fine, because the style is
|
||||
// only incomplete during the styling process.
|
||||
return style.values.as_ref().unwrap().clone();
|
||||
}
|
||||
|
||||
let mut cascade_flags = CascadeFlags::empty();
|
||||
if self.skip_root_and_item_based_display_fixup() {
|
||||
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP)
|
||||
}
|
||||
self.cascade_with_rules(shared_context,
|
||||
&without_animation_rules,
|
||||
primary_style,
|
||||
cascade_flags,
|
||||
pseudo_style.is_some())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl<E: TElement> MatchMethods for E {}
|
||||
|
|
|
@ -81,6 +81,7 @@ impl TransitionProperty {
|
|||
|
||||
/// Get a transition property from a property declaration.
|
||||
pub fn from_declaration(declaration: &PropertyDeclaration) -> Option<Self> {
|
||||
use properties::LonghandId;
|
||||
match *declaration {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
|
@ -88,6 +89,18 @@ impl TransitionProperty {
|
|||
=> Some(TransitionProperty::${prop.camel_case}),
|
||||
% endif
|
||||
% endfor
|
||||
PropertyDeclaration::CSSWideKeyword(id, _) |
|
||||
PropertyDeclaration::WithVariables(id, _) => {
|
||||
match id {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
LonghandId::${prop.camel_case} =>
|
||||
Some(TransitionProperty::${prop.camel_case}),
|
||||
% endif
|
||||
% endfor
|
||||
_ => None,
|
||||
}
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -386,6 +399,23 @@ impl AnimationValue {
|
|||
_ => None // non animatable properties will get included because of shorthands. ignore.
|
||||
}
|
||||
}
|
||||
|
||||
/// Get an AnimationValue for a TransitionProperty from a given computed values.
|
||||
pub fn from_computed_values(transition_property: &TransitionProperty,
|
||||
computed_values: &ComputedValues)
|
||||
-> Self {
|
||||
match *transition_property {
|
||||
TransitionProperty::All => panic!("Can't use TransitionProperty::All here."),
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
TransitionProperty::${prop.camel_case} => {
|
||||
AnimationValue::${prop.camel_case}(
|
||||
computed_values.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
|
||||
}
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Interpolate for AnimationValue {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue