mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #19493 - emilio:chrome-perf, r=xidorn,Manishearth
style: Some stylo-chrome perf tweaks. <!-- 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/19493) <!-- Reviewable:end -->
This commit is contained in:
commit
8f30880d36
4 changed files with 399 additions and 58 deletions
|
@ -528,14 +528,10 @@ extern "C" {
|
||||||
pub fn Gecko_LoadStyleSheet ( loader : * mut Loader , parent : * mut ServoStyleSheet , reusable_sheets : * mut LoaderReusableStyleSheets , base_url_data : * mut RawGeckoURLExtraData , url_bytes : * const u8 , url_length : u32 , media_list : RawServoMediaListStrong , ) -> * mut ServoStyleSheet ;
|
pub fn Gecko_LoadStyleSheet ( loader : * mut Loader , parent : * mut ServoStyleSheet , reusable_sheets : * mut LoaderReusableStyleSheets , base_url_data : * mut RawGeckoURLExtraData , url_bytes : * const u8 , url_length : u32 , media_list : RawServoMediaListStrong , ) -> * mut ServoStyleSheet ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_ElementState ( element : RawGeckoElementBorrowed , ) -> u64 ;
|
pub fn Gecko_ElementState ( element : RawGeckoElementBorrowed , ) -> u64 ;
|
||||||
} extern "C" {
|
|
||||||
pub fn Gecko_DocumentState ( aDocument : * const nsIDocument , ) -> u64 ;
|
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_IsRootElement ( element : RawGeckoElementBorrowed , ) -> bool ;
|
pub fn Gecko_IsRootElement ( element : RawGeckoElementBorrowed , ) -> bool ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_MatchesElement ( type_ : CSSPseudoClassType , element : RawGeckoElementBorrowed , ) -> bool ;
|
pub fn Gecko_MatchesElement ( type_ : CSSPseudoClassType , element : RawGeckoElementBorrowed , ) -> bool ;
|
||||||
} extern "C" {
|
|
||||||
pub fn Gecko_Namespace ( element : RawGeckoElementBorrowed , ) -> * mut nsAtom ;
|
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_MatchLang ( element : RawGeckoElementBorrowed , override_lang : * mut nsAtom , has_override_lang : bool , value : * const u16 , ) -> bool ;
|
pub fn Gecko_MatchLang ( element : RawGeckoElementBorrowed , override_lang : * mut nsAtom , has_override_lang : bool , value : * const u16 , ) -> bool ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
|
@ -600,8 +596,6 @@ extern "C" {
|
||||||
pub fn Gecko_IsPrivateBrowsingEnabled ( aDoc : * const nsIDocument , ) -> bool ;
|
pub fn Gecko_IsPrivateBrowsingEnabled ( aDoc : * const nsIDocument , ) -> bool ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_GetAnimationRule ( aElementOrPseudo : RawGeckoElementBorrowed , aCascadeLevel : EffectCompositor_CascadeLevel , aAnimationValues : RawServoAnimationValueMapBorrowedMut , ) -> bool ;
|
pub fn Gecko_GetAnimationRule ( aElementOrPseudo : RawGeckoElementBorrowed , aCascadeLevel : EffectCompositor_CascadeLevel , aAnimationValues : RawServoAnimationValueMapBorrowedMut , ) -> bool ;
|
||||||
} extern "C" {
|
|
||||||
pub fn Gecko_GetSMILOverrideDeclarationBlock ( element : RawGeckoElementBorrowed , ) -> RawServoDeclarationBlockStrongBorrowedOrNull ;
|
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
pub fn Gecko_StyleAnimationsEquals ( arg1 : RawGeckoStyleAnimationListBorrowed , arg2 : RawGeckoStyleAnimationListBorrowed , ) -> bool ;
|
pub fn Gecko_StyleAnimationsEquals ( arg1 : RawGeckoStyleAnimationListBorrowed , arg2 : RawGeckoStyleAnimationListBorrowed , ) -> bool ;
|
||||||
} extern "C" {
|
} extern "C" {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -29,9 +29,9 @@ use gecko::selector_parser::{SelectorImpl, NonTSPseudoClass, PseudoElement};
|
||||||
use gecko::snapshot_helpers;
|
use gecko::snapshot_helpers;
|
||||||
use gecko_bindings::bindings;
|
use gecko_bindings::bindings;
|
||||||
use gecko_bindings::bindings::{Gecko_ConstructStyleChildrenIterator, Gecko_DestroyStyleChildrenIterator};
|
use gecko_bindings::bindings::{Gecko_ConstructStyleChildrenIterator, Gecko_DestroyStyleChildrenIterator};
|
||||||
use gecko_bindings::bindings::{Gecko_DocumentState, Gecko_ElementState, Gecko_GetDocumentLWTheme};
|
use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentLWTheme};
|
||||||
use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetNextStyleChild};
|
use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetNextStyleChild};
|
||||||
use gecko_bindings::bindings::{Gecko_IsRootElement, Gecko_MatchesElement, Gecko_Namespace};
|
use gecko_bindings::bindings::{Gecko_IsRootElement, Gecko_MatchesElement};
|
||||||
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
|
use gecko_bindings::bindings::{Gecko_SetNodeFlags, Gecko_UnsetNodeFlags};
|
||||||
use gecko_bindings::bindings::Gecko_ClassOrClassList;
|
use gecko_bindings::bindings::Gecko_ClassOrClassList;
|
||||||
use gecko_bindings::bindings::Gecko_ElementHasAnimations;
|
use gecko_bindings::bindings::Gecko_ElementHasAnimations;
|
||||||
|
@ -41,7 +41,6 @@ use gecko_bindings::bindings::Gecko_GetActiveLinkAttrDeclarationBlock;
|
||||||
use gecko_bindings::bindings::Gecko_GetAnimationRule;
|
use gecko_bindings::bindings::Gecko_GetAnimationRule;
|
||||||
use gecko_bindings::bindings::Gecko_GetExtraContentStyleDeclarations;
|
use gecko_bindings::bindings::Gecko_GetExtraContentStyleDeclarations;
|
||||||
use gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock;
|
use gecko_bindings::bindings::Gecko_GetHTMLPresentationAttrDeclarationBlock;
|
||||||
use gecko_bindings::bindings::Gecko_GetSMILOverrideDeclarationBlock;
|
|
||||||
use gecko_bindings::bindings::Gecko_GetStyleAttrDeclarationBlock;
|
use gecko_bindings::bindings::Gecko_GetStyleAttrDeclarationBlock;
|
||||||
use gecko_bindings::bindings::Gecko_GetUnvisitedLinkAttrDeclarationBlock;
|
use gecko_bindings::bindings::Gecko_GetUnvisitedLinkAttrDeclarationBlock;
|
||||||
use gecko_bindings::bindings::Gecko_GetVisitedLinkAttrDeclarationBlock;
|
use gecko_bindings::bindings::Gecko_GetVisitedLinkAttrDeclarationBlock;
|
||||||
|
@ -610,6 +609,7 @@ impl<'le> GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn namespace_id(&self) -> i32 {
|
fn namespace_id(&self) -> i32 {
|
||||||
self.as_node().node_info().mInner.mNamespaceID
|
self.as_node().node_info().mInner.mNamespaceID
|
||||||
}
|
}
|
||||||
|
@ -658,12 +658,11 @@ impl<'le> GeckoElement<'le> {
|
||||||
unsafe { Gecko_ElementState(self.0) }
|
unsafe { Gecko_ElementState(self.0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
fn document_state(&self) -> DocumentState {
|
fn document_state(&self) -> DocumentState {
|
||||||
let node = self.as_node();
|
DocumentState::from_bits_truncate(
|
||||||
unsafe {
|
self.as_node().owner_doc().0.mDocumentState.mStates
|
||||||
let states = Gecko_DocumentState(node.owner_doc().0);
|
)
|
||||||
DocumentState::from_bits_truncate(states)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -1054,14 +1053,43 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_smil_override(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
|
fn get_smil_override(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
|
||||||
let declarations = unsafe { Gecko_GetSMILOverrideDeclarationBlock(self.0) };
|
unsafe {
|
||||||
let declarations: Option<&RawOffsetArc<Locked<PropertyDeclarationBlock>>> =
|
let slots = match self.get_extended_slots() {
|
||||||
declarations.and_then(|s| s.as_arc_opt());
|
Some(s) => s,
|
||||||
declarations.map(|s| s.borrow_arc())
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let base_declaration: &structs::DeclarationBlock =
|
||||||
|
match slots.mSMILOverrideStyleDeclaration.mRawPtr.as_ref() {
|
||||||
|
Some(decl) => decl,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
assert_eq!(base_declaration.mType, structs::StyleBackendType_Servo);
|
||||||
|
let declaration: &structs::ServoDeclarationBlock =
|
||||||
|
mem::transmute(base_declaration);
|
||||||
|
|
||||||
|
debug_assert_eq!(
|
||||||
|
&declaration._base as *const structs::DeclarationBlock,
|
||||||
|
base_declaration as *const structs::DeclarationBlock
|
||||||
|
);
|
||||||
|
|
||||||
|
let raw: &structs::RawServoDeclarationBlock =
|
||||||
|
match declaration.mRaw.mRawPtr.as_ref() {
|
||||||
|
Some(decl) => decl,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(Locked::<PropertyDeclarationBlock>::as_arc(
|
||||||
|
&*(&raw as *const &structs::RawServoDeclarationBlock)
|
||||||
|
).borrow_arc())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_animation_rule_by_cascade(&self, cascade_level: ServoCascadeLevel)
|
fn get_animation_rule_by_cascade(
|
||||||
-> Option<Arc<Locked<PropertyDeclarationBlock>>> {
|
&self,
|
||||||
|
cascade_level: ServoCascadeLevel,
|
||||||
|
) -> Option<Arc<Locked<PropertyDeclarationBlock>>> {
|
||||||
match cascade_level {
|
match cascade_level {
|
||||||
ServoCascadeLevel::Animations => self.get_animation_rule(),
|
ServoCascadeLevel::Animations => self.get_animation_rule(),
|
||||||
ServoCascadeLevel::Transitions => self.get_transition_rule(),
|
ServoCascadeLevel::Transitions => self.get_transition_rule(),
|
||||||
|
@ -1940,7 +1968,8 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace(&self) -> &WeakNamespace {
|
fn get_namespace(&self) -> &WeakNamespace {
|
||||||
unsafe {
|
unsafe {
|
||||||
WeakNamespace::new(Gecko_Namespace(self.0))
|
let namespace_manager = structs::nsContentUtils_sNameSpaceManager;
|
||||||
|
WeakNamespace::new((*namespace_manager).mURIArray[self.namespace_id() as usize].mRawPtr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,14 @@ use dom::TElement;
|
||||||
use selectors::NthIndexCache;
|
use selectors::NthIndexCache;
|
||||||
use sharing::{StyleSharingCandidate, StyleSharingTarget};
|
use sharing::{StyleSharingCandidate, StyleSharingTarget};
|
||||||
|
|
||||||
/// Determines whether a target and a candidate have compatible parents for sharing.
|
/// Determines whether a target and a candidate have compatible parents for
|
||||||
|
/// sharing.
|
||||||
pub fn parents_allow_sharing<E>(
|
pub fn parents_allow_sharing<E>(
|
||||||
target: &mut StyleSharingTarget<E>,
|
target: &mut StyleSharingTarget<E>,
|
||||||
candidate: &mut StyleSharingCandidate<E>
|
candidate: &mut StyleSharingCandidate<E>
|
||||||
) -> bool
|
) -> bool
|
||||||
where E: TElement,
|
where
|
||||||
|
E: TElement,
|
||||||
{
|
{
|
||||||
// If the identity of the parent style isn't equal, we can't share. We check
|
// If the identity of the parent style isn't equal, we can't share. We check
|
||||||
// this first, because the result is cached.
|
// this first, because the result is cached.
|
||||||
|
@ -58,7 +60,8 @@ pub fn have_same_style_attribute<E>(
|
||||||
target: &mut StyleSharingTarget<E>,
|
target: &mut StyleSharingTarget<E>,
|
||||||
candidate: &mut StyleSharingCandidate<E>
|
candidate: &mut StyleSharingCandidate<E>
|
||||||
) -> bool
|
) -> bool
|
||||||
where E: TElement,
|
where
|
||||||
|
E: TElement,
|
||||||
{
|
{
|
||||||
match (target.style_attribute(), candidate.style_attribute()) {
|
match (target.style_attribute(), candidate.style_attribute()) {
|
||||||
(None, None) => true,
|
(None, None) => true,
|
||||||
|
@ -72,7 +75,8 @@ pub fn have_same_presentational_hints<E>(
|
||||||
target: &mut StyleSharingTarget<E>,
|
target: &mut StyleSharingTarget<E>,
|
||||||
candidate: &mut StyleSharingCandidate<E>
|
candidate: &mut StyleSharingCandidate<E>
|
||||||
) -> bool
|
) -> bool
|
||||||
where E: TElement,
|
where
|
||||||
|
E: TElement,
|
||||||
{
|
{
|
||||||
target.pres_hints() == candidate.pres_hints()
|
target.pres_hints() == candidate.pres_hints()
|
||||||
}
|
}
|
||||||
|
@ -80,10 +84,12 @@ pub fn have_same_presentational_hints<E>(
|
||||||
/// Whether a given element has the same class attribute than a given candidate.
|
/// Whether a given element has the same class attribute than a given candidate.
|
||||||
///
|
///
|
||||||
/// We don't try to share style across elements with different class attributes.
|
/// We don't try to share style across elements with different class attributes.
|
||||||
pub fn have_same_class<E>(target: &mut StyleSharingTarget<E>,
|
pub fn have_same_class<E>(
|
||||||
candidate: &mut StyleSharingCandidate<E>)
|
target: &mut StyleSharingTarget<E>,
|
||||||
-> bool
|
candidate: &mut StyleSharingCandidate<E>,
|
||||||
where E: TElement,
|
) -> bool
|
||||||
|
where
|
||||||
|
E: TElement,
|
||||||
{
|
{
|
||||||
target.class_list() == candidate.class_list()
|
target.class_list() == candidate.class_list()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue