mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
style: Inline a bunch of trivial stuff we're paying calls for in Geckolib.
This commit is contained in:
parent
10779f0251
commit
fcd6e79659
5 changed files with 23 additions and 0 deletions
|
@ -72,6 +72,7 @@ impl RestyleData {
|
|||
///
|
||||
/// FIXME(bholley): The only caller of this should probably just assert that
|
||||
/// the hint is empty and call clear_flags_and_damage().
|
||||
#[inline]
|
||||
fn clear_restyle_state(&mut self) {
|
||||
self.clear_restyle_flags_and_damage();
|
||||
self.hint = RestyleHint::empty();
|
||||
|
@ -83,6 +84,7 @@ impl RestyleData {
|
|||
/// set to the correct value on each traversal. There's no reason anyone
|
||||
/// needs to clear it, and clearing it accidentally mid-traversal could
|
||||
/// cause incorrect style sharing behavior.
|
||||
#[inline]
|
||||
fn clear_restyle_flags_and_damage(&mut self) {
|
||||
self.damage = RestyleDamage::empty();
|
||||
self.flags = self.flags & TRAVERSED_WITHOUT_STYLING;
|
||||
|
@ -124,6 +126,7 @@ impl RestyleData {
|
|||
}
|
||||
|
||||
/// Returns true if this element was restyled.
|
||||
#[inline]
|
||||
pub fn is_restyle(&self) -> bool {
|
||||
self.flags.contains(WAS_RESTYLED)
|
||||
}
|
||||
|
@ -140,6 +143,7 @@ impl RestyleData {
|
|||
}
|
||||
|
||||
/// Returns whether this element has been part of a restyle.
|
||||
#[inline]
|
||||
pub fn contains_restyle_data(&self) -> bool {
|
||||
self.is_restyle() || !self.hint.is_empty() || !self.damage.is_empty()
|
||||
}
|
||||
|
@ -353,6 +357,7 @@ impl ElementData {
|
|||
}
|
||||
|
||||
/// Returns true if this element has styles.
|
||||
#[inline]
|
||||
pub fn has_styles(&self) -> bool {
|
||||
self.styles.primary.is_some()
|
||||
}
|
||||
|
@ -429,11 +434,13 @@ impl ElementData {
|
|||
}
|
||||
|
||||
/// Drops any restyle state from the element.
|
||||
#[inline]
|
||||
pub fn clear_restyle_state(&mut self) {
|
||||
self.restyle.clear_restyle_state();
|
||||
}
|
||||
|
||||
/// Drops restyle flags and damage from the element.
|
||||
#[inline]
|
||||
pub fn clear_restyle_flags_and_damage(&mut self) {
|
||||
self.restyle.clear_restyle_flags_and_damage();
|
||||
}
|
||||
|
|
|
@ -18,21 +18,25 @@ pub struct GeckoRestyleDamage(nsChangeHint);
|
|||
|
||||
impl GeckoRestyleDamage {
|
||||
/// Trivially construct a new `GeckoRestyleDamage`.
|
||||
#[inline]
|
||||
pub fn new(raw: nsChangeHint) -> Self {
|
||||
GeckoRestyleDamage(raw)
|
||||
}
|
||||
|
||||
/// Get the inner change hint for this damage.
|
||||
#[inline]
|
||||
pub fn as_change_hint(&self) -> nsChangeHint {
|
||||
self.0
|
||||
}
|
||||
|
||||
/// Get an empty change hint, that is (`nsChangeHint(0)`).
|
||||
#[inline]
|
||||
pub fn empty() -> Self {
|
||||
GeckoRestyleDamage(nsChangeHint(0))
|
||||
}
|
||||
|
||||
/// Returns whether this restyle damage represents the empty damage.
|
||||
#[inline]
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0 == nsChangeHint(0)
|
||||
}
|
||||
|
|
|
@ -294,6 +294,7 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn as_element(&self) -> Option<GeckoElement<'ln>> {
|
||||
if self.is_element() {
|
||||
unsafe { Some(GeckoElement(&*(self.0 as *const _ as *const RawGeckoElement))) }
|
||||
|
@ -1019,10 +1020,12 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
Gecko_ClassOrClassList)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn has_snapshot(&self) -> bool {
|
||||
self.flags() & (ELEMENT_HAS_SNAPSHOT as u32) != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn handled_snapshot(&self) -> bool {
|
||||
self.flags() & (ELEMENT_HANDLED_SNAPSHOT as u32) != 0
|
||||
}
|
||||
|
@ -1032,6 +1035,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
self.set_flags(ELEMENT_HANDLED_SNAPSHOT as u32)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn has_dirty_descendants(&self) -> bool {
|
||||
self.flags() & (ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO as u32) != 0
|
||||
}
|
||||
|
@ -1046,6 +1050,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
self.unset_flags(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO as u32)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn has_animation_only_dirty_descendants(&self) -> bool {
|
||||
self.flags() & (ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO as u32) != 0
|
||||
}
|
||||
|
@ -1064,11 +1069,13 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
NODE_DESCENDANTS_NEED_FRAMES as u32)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_visited_link(&self) -> bool {
|
||||
use element_state::IN_VISITED_STATE;
|
||||
self.get_state().intersects(IN_VISITED_STATE)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_native_anonymous(&self) -> bool {
|
||||
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS;
|
||||
self.flags() & (NODE_IS_NATIVE_ANONYMOUS as u32) != 0
|
||||
|
@ -1096,6 +1103,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
panic!("Atomic child count not implemented in Gecko");
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> {
|
||||
unsafe { self.0.mServoData.get().as_ref() }
|
||||
}
|
||||
|
@ -1127,6 +1135,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn skip_root_and_item_based_display_fixup(&self) -> bool {
|
||||
// We don't want to fix up display values of native anonymous content.
|
||||
// Additionally, we want to skip root-based display fixup for document
|
||||
|
|
|
@ -57,6 +57,7 @@ impl TraversalDriver {
|
|||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
fn is_servo_nonincremental_layout() -> bool {
|
||||
use servo_config::opts;
|
||||
|
||||
|
@ -64,6 +65,7 @@ fn is_servo_nonincremental_layout() -> bool {
|
|||
}
|
||||
|
||||
#[cfg(not(feature = "servo"))]
|
||||
#[inline]
|
||||
fn is_servo_nonincremental_layout() -> bool {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -77,6 +77,7 @@ pub fn assert_traversal_flags_match() {
|
|||
|
||||
impl TraversalFlags {
|
||||
/// Returns true if the traversal is for animation-only restyles.
|
||||
#[inline]
|
||||
pub fn for_animation_only(&self) -> bool {
|
||||
self.contains(AnimationOnly)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue