style: Inline a bunch of trivial stuff we're paying calls for in Geckolib.

This commit is contained in:
Emilio Cobos Álvarez 2017-08-22 11:03:15 +02:00
parent 10779f0251
commit fcd6e79659
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 23 additions and 0 deletions

View file

@ -72,6 +72,7 @@ impl RestyleData {
/// ///
/// FIXME(bholley): The only caller of this should probably just assert that /// FIXME(bholley): The only caller of this should probably just assert that
/// the hint is empty and call clear_flags_and_damage(). /// the hint is empty and call clear_flags_and_damage().
#[inline]
fn clear_restyle_state(&mut self) { fn clear_restyle_state(&mut self) {
self.clear_restyle_flags_and_damage(); self.clear_restyle_flags_and_damage();
self.hint = RestyleHint::empty(); self.hint = RestyleHint::empty();
@ -83,6 +84,7 @@ impl RestyleData {
/// set to the correct value on each traversal. There's no reason anyone /// set to the correct value on each traversal. There's no reason anyone
/// needs to clear it, and clearing it accidentally mid-traversal could /// needs to clear it, and clearing it accidentally mid-traversal could
/// cause incorrect style sharing behavior. /// cause incorrect style sharing behavior.
#[inline]
fn clear_restyle_flags_and_damage(&mut self) { fn clear_restyle_flags_and_damage(&mut self) {
self.damage = RestyleDamage::empty(); self.damage = RestyleDamage::empty();
self.flags = self.flags & TRAVERSED_WITHOUT_STYLING; self.flags = self.flags & TRAVERSED_WITHOUT_STYLING;
@ -124,6 +126,7 @@ impl RestyleData {
} }
/// Returns true if this element was restyled. /// Returns true if this element was restyled.
#[inline]
pub fn is_restyle(&self) -> bool { pub fn is_restyle(&self) -> bool {
self.flags.contains(WAS_RESTYLED) self.flags.contains(WAS_RESTYLED)
} }
@ -140,6 +143,7 @@ impl RestyleData {
} }
/// Returns whether this element has been part of a restyle. /// Returns whether this element has been part of a restyle.
#[inline]
pub fn contains_restyle_data(&self) -> bool { pub fn contains_restyle_data(&self) -> bool {
self.is_restyle() || !self.hint.is_empty() || !self.damage.is_empty() self.is_restyle() || !self.hint.is_empty() || !self.damage.is_empty()
} }
@ -353,6 +357,7 @@ impl ElementData {
} }
/// Returns true if this element has styles. /// Returns true if this element has styles.
#[inline]
pub fn has_styles(&self) -> bool { pub fn has_styles(&self) -> bool {
self.styles.primary.is_some() self.styles.primary.is_some()
} }
@ -429,11 +434,13 @@ impl ElementData {
} }
/// Drops any restyle state from the element. /// Drops any restyle state from the element.
#[inline]
pub fn clear_restyle_state(&mut self) { pub fn clear_restyle_state(&mut self) {
self.restyle.clear_restyle_state(); self.restyle.clear_restyle_state();
} }
/// Drops restyle flags and damage from the element. /// Drops restyle flags and damage from the element.
#[inline]
pub fn clear_restyle_flags_and_damage(&mut self) { pub fn clear_restyle_flags_and_damage(&mut self) {
self.restyle.clear_restyle_flags_and_damage(); self.restyle.clear_restyle_flags_and_damage();
} }

View file

@ -18,21 +18,25 @@ pub struct GeckoRestyleDamage(nsChangeHint);
impl GeckoRestyleDamage { impl GeckoRestyleDamage {
/// Trivially construct a new `GeckoRestyleDamage`. /// Trivially construct a new `GeckoRestyleDamage`.
#[inline]
pub fn new(raw: nsChangeHint) -> Self { pub fn new(raw: nsChangeHint) -> Self {
GeckoRestyleDamage(raw) GeckoRestyleDamage(raw)
} }
/// Get the inner change hint for this damage. /// Get the inner change hint for this damage.
#[inline]
pub fn as_change_hint(&self) -> nsChangeHint { pub fn as_change_hint(&self) -> nsChangeHint {
self.0 self.0
} }
/// Get an empty change hint, that is (`nsChangeHint(0)`). /// Get an empty change hint, that is (`nsChangeHint(0)`).
#[inline]
pub fn empty() -> Self { pub fn empty() -> Self {
GeckoRestyleDamage(nsChangeHint(0)) GeckoRestyleDamage(nsChangeHint(0))
} }
/// Returns whether this restyle damage represents the empty damage. /// Returns whether this restyle damage represents the empty damage.
#[inline]
pub fn is_empty(&self) -> bool { pub fn is_empty(&self) -> bool {
self.0 == nsChangeHint(0) self.0 == nsChangeHint(0)
} }

View file

@ -294,6 +294,7 @@ impl<'ln> TNode for GeckoNode<'ln> {
unimplemented!() unimplemented!()
} }
#[inline]
fn as_element(&self) -> Option<GeckoElement<'ln>> { fn as_element(&self) -> Option<GeckoElement<'ln>> {
if self.is_element() { if self.is_element() {
unsafe { Some(GeckoElement(&*(self.0 as *const _ as *const RawGeckoElement))) } unsafe { Some(GeckoElement(&*(self.0 as *const _ as *const RawGeckoElement))) }
@ -1019,10 +1020,12 @@ impl<'le> TElement for GeckoElement<'le> {
Gecko_ClassOrClassList) Gecko_ClassOrClassList)
} }
#[inline]
fn has_snapshot(&self) -> bool { fn has_snapshot(&self) -> bool {
self.flags() & (ELEMENT_HAS_SNAPSHOT as u32) != 0 self.flags() & (ELEMENT_HAS_SNAPSHOT as u32) != 0
} }
#[inline]
fn handled_snapshot(&self) -> bool { fn handled_snapshot(&self) -> bool {
self.flags() & (ELEMENT_HANDLED_SNAPSHOT as u32) != 0 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) self.set_flags(ELEMENT_HANDLED_SNAPSHOT as u32)
} }
#[inline]
fn has_dirty_descendants(&self) -> bool { fn has_dirty_descendants(&self) -> bool {
self.flags() & (ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO as u32) != 0 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) self.unset_flags(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO as u32)
} }
#[inline]
fn has_animation_only_dirty_descendants(&self) -> bool { fn has_animation_only_dirty_descendants(&self) -> bool {
self.flags() & (ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO as u32) != 0 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) NODE_DESCENDANTS_NEED_FRAMES as u32)
} }
#[inline]
fn is_visited_link(&self) -> bool { fn is_visited_link(&self) -> bool {
use element_state::IN_VISITED_STATE; use element_state::IN_VISITED_STATE;
self.get_state().intersects(IN_VISITED_STATE) self.get_state().intersects(IN_VISITED_STATE)
} }
#[inline]
fn is_native_anonymous(&self) -> bool { fn is_native_anonymous(&self) -> bool {
use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS; use gecko_bindings::structs::NODE_IS_NATIVE_ANONYMOUS;
self.flags() & (NODE_IS_NATIVE_ANONYMOUS as u32) != 0 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"); panic!("Atomic child count not implemented in Gecko");
} }
#[inline(always)]
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> { fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> {
unsafe { self.0.mServoData.get().as_ref() } 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 { fn skip_root_and_item_based_display_fixup(&self) -> bool {
// We don't want to fix up display values of native anonymous content. // We don't want to fix up display values of native anonymous content.
// Additionally, we want to skip root-based display fixup for document // Additionally, we want to skip root-based display fixup for document

View file

@ -57,6 +57,7 @@ impl TraversalDriver {
} }
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
#[inline]
fn is_servo_nonincremental_layout() -> bool { fn is_servo_nonincremental_layout() -> bool {
use servo_config::opts; use servo_config::opts;
@ -64,6 +65,7 @@ fn is_servo_nonincremental_layout() -> bool {
} }
#[cfg(not(feature = "servo"))] #[cfg(not(feature = "servo"))]
#[inline]
fn is_servo_nonincremental_layout() -> bool { fn is_servo_nonincremental_layout() -> bool {
false false
} }

View file

@ -77,6 +77,7 @@ pub fn assert_traversal_flags_match() {
impl TraversalFlags { impl TraversalFlags {
/// Returns true if the traversal is for animation-only restyles. /// Returns true if the traversal is for animation-only restyles.
#[inline]
pub fn for_animation_only(&self) -> bool { pub fn for_animation_only(&self) -> bool {
self.contains(AnimationOnly) self.contains(AnimationOnly)
} }