mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Make Element::id not clone the attribute.
This commit is contained in:
parent
98c9292ecb
commit
f2efd04a5d
10 changed files with 46 additions and 37 deletions
|
@ -5,7 +5,7 @@
|
|||
//! A wrapper over an element and a snapshot, that allows us to selector-match
|
||||
//! against a past state of the element.
|
||||
|
||||
use {Atom, CaseSensitivityExt, LocalName, Namespace};
|
||||
use {Atom, CaseSensitivityExt, LocalName, Namespace, WeakAtom};
|
||||
use dom::TElement;
|
||||
use element_state::ElementState;
|
||||
use selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl, Snapshot, SnapshotMap, AttrValue};
|
||||
|
@ -44,7 +44,7 @@ pub trait ElementSnapshot : Sized {
|
|||
|
||||
/// The ID attribute per this snapshot. Should only be called if
|
||||
/// `has_attrs()` returns true.
|
||||
fn id_attr(&self) -> Option<Atom>;
|
||||
fn id_attr(&self) -> Option<&WeakAtom>;
|
||||
|
||||
/// Whether this snapshot contains the class `name`. Should only be called
|
||||
/// if `has_attrs()` returns true.
|
||||
|
@ -53,7 +53,8 @@ pub trait ElementSnapshot : Sized {
|
|||
/// A callback that should be called for each class of the snapshot. Should
|
||||
/// only be called if `has_attrs()` returns true.
|
||||
fn each_class<F>(&self, F)
|
||||
where F: FnMut(&Atom);
|
||||
where
|
||||
F: FnMut(&Atom);
|
||||
|
||||
/// The `xml:lang=""` or `lang=""` attribute value per this snapshot.
|
||||
fn lang_attr(&self) -> Option<AttrValue>;
|
||||
|
@ -63,7 +64,8 @@ pub trait ElementSnapshot : Sized {
|
|||
/// selector-match against a past state of the element.
|
||||
#[derive(Clone)]
|
||||
pub struct ElementWrapper<'a, E>
|
||||
where E: TElement,
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
element: E,
|
||||
cached_snapshot: Cell<Option<&'a Snapshot>>,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! An invalidation processor for style changes due to state and attribute
|
||||
//! changes.
|
||||
|
||||
use Atom;
|
||||
use {Atom, WeakAtom};
|
||||
use context::{QuirksMode, SharedStyleContext};
|
||||
use data::ElementData;
|
||||
use dom::TElement;
|
||||
|
@ -42,8 +42,8 @@ where
|
|||
snapshot: &'a Snapshot,
|
||||
quirks_mode: QuirksMode,
|
||||
lookup_element: E,
|
||||
removed_id: Option<&'a Atom>,
|
||||
added_id: Option<&'a Atom>,
|
||||
removed_id: Option<&'a WeakAtom>,
|
||||
added_id: Option<&'a WeakAtom>,
|
||||
classes_removed: &'a SmallVec<[Atom; 8]>,
|
||||
classes_added: &'a SmallVec<[Atom; 8]>,
|
||||
state_changes: ElementState,
|
||||
|
@ -239,8 +239,8 @@ where
|
|||
snapshot: &snapshot,
|
||||
quirks_mode: self.shared_context.quirks_mode(),
|
||||
nth_index_cache: self.matching_context.nth_index_cache.as_mut().map(|c| &mut **c),
|
||||
removed_id: id_removed.as_ref(),
|
||||
added_id: id_added.as_ref(),
|
||||
removed_id: id_removed,
|
||||
added_id: id_added,
|
||||
classes_removed: &classes_removed,
|
||||
classes_added: &classes_added,
|
||||
descendant_invalidations,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue