mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +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,6 +5,7 @@
|
|||
//! A gecko snapshot, that stores the element attributes and state before they
|
||||
//! change in order to properly calculate restyle hints.
|
||||
|
||||
use WeakAtom;
|
||||
use dom::TElement;
|
||||
use element_state::ElementState;
|
||||
use gecko::snapshot_helpers;
|
||||
|
@ -80,17 +81,20 @@ impl GeckoElementSnapshot {
|
|||
}
|
||||
|
||||
/// selectors::Element::attr_matches
|
||||
pub fn attr_matches(&self,
|
||||
ns: &NamespaceConstraint<&Namespace>,
|
||||
local_name: &Atom,
|
||||
operation: &AttrSelectorOperation<&Atom>)
|
||||
-> bool {
|
||||
pub fn attr_matches(
|
||||
&self,
|
||||
ns: &NamespaceConstraint<&Namespace>,
|
||||
local_name: &Atom,
|
||||
operation: &AttrSelectorOperation<&Atom>,
|
||||
) -> bool {
|
||||
unsafe {
|
||||
match *operation {
|
||||
AttrSelectorOperation::Exists => {
|
||||
bindings:: Gecko_SnapshotHasAttr(self,
|
||||
ns.atom_or_null(),
|
||||
local_name.as_ptr())
|
||||
bindings:: Gecko_SnapshotHasAttr(
|
||||
self,
|
||||
ns.atom_or_null(),
|
||||
local_name.as_ptr(),
|
||||
)
|
||||
}
|
||||
AttrSelectorOperation::WithValue { operator, case_sensitivity, expected_value } => {
|
||||
let ignore_case = match case_sensitivity {
|
||||
|
@ -163,7 +167,7 @@ impl ElementSnapshot for GeckoElementSnapshot {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn id_attr(&self) -> Option<Atom> {
|
||||
fn id_attr(&self) -> Option<&WeakAtom> {
|
||||
if !self.has_any(Flags::Id) {
|
||||
return None
|
||||
}
|
||||
|
@ -172,10 +176,11 @@ impl ElementSnapshot for GeckoElementSnapshot {
|
|||
bindings::Gecko_SnapshotAtomAttrValue(self, atom!("id").as_ptr())
|
||||
};
|
||||
|
||||
// FIXME(emilio): This should assert, since this flag is exact.
|
||||
if ptr.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(Atom::from(ptr))
|
||||
Some(unsafe { WeakAtom::new(ptr) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue