mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Add support for resolving default computed styles.
This commit is contained in:
parent
1f323f8848
commit
cc44f05f44
9 changed files with 2784 additions and 2437 deletions
|
@ -205,6 +205,7 @@ use gecko_bindings::structs::UpdateAnimationsTasks;
|
|||
use gecko_bindings::structs::ParsingMode;
|
||||
use gecko_bindings::structs::InheritTarget;
|
||||
use gecko_bindings::structs::URLMatchingFunction;
|
||||
use gecko_bindings::structs::StyleRuleInclusion;
|
||||
pub type nsTArrayBorrowed_uintptr_t<'a> = &'a mut ::gecko_bindings::structs::nsTArray<usize>;
|
||||
pub type RawServoStyleSetOwned = ::gecko_bindings::sugar::ownership::Owned<RawServoStyleSet>;
|
||||
pub type RawServoStyleSetOwnedOrNull = ::gecko_bindings::sugar::ownership::OwnedOrNull<RawServoStyleSet>;
|
||||
|
@ -2413,6 +2414,11 @@ extern "C" {
|
|||
target: InheritTarget)
|
||||
-> ServoComputedValuesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ComputedValues_GetVisitedStyle(values:
|
||||
ServoComputedValuesBorrowed)
|
||||
-> ServoComputedValuesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_Initialize(dummy_url_data: *mut RawGeckoURLExtraData);
|
||||
}
|
||||
|
@ -2453,6 +2459,7 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
rule_inclusion: StyleRuleInclusion,
|
||||
snapshots:
|
||||
*const ServoElementSnapshotTable,
|
||||
set: RawServoStyleSetBorrowed)
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -72,6 +72,8 @@ use std::cell::RefCell;
|
|||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::mem;
|
||||
use std::ops::DerefMut;
|
||||
use std::ptr;
|
||||
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
|
||||
use stylearc::Arc;
|
||||
|
@ -422,6 +424,29 @@ impl<'le> GeckoElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Sets the specified element data, return any existing data.
|
||||
///
|
||||
/// Like `ensure_data`, only safe to call with exclusive access to the
|
||||
/// element.
|
||||
pub unsafe fn set_data(&self, replace_data: Option<ElementData>) -> Option<ElementData> {
|
||||
match (self.get_data(), replace_data) {
|
||||
(Some(old), Some(replace_data)) => {
|
||||
Some(mem::replace(old.borrow_mut().deref_mut(), replace_data))
|
||||
}
|
||||
(Some(old), None) => {
|
||||
let old_data = mem::replace(old.borrow_mut().deref_mut(), ElementData::new(None));
|
||||
self.0.mServoData.set(ptr::null_mut());
|
||||
Some(old_data)
|
||||
}
|
||||
(None, Some(replace_data)) => {
|
||||
let ptr = Box::into_raw(Box::new(AtomicRefCell::new(replace_data)));
|
||||
self.0.mServoData.set(ptr);
|
||||
None
|
||||
}
|
||||
(None, None) => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn has_id(&self) -> bool {
|
||||
self.as_node().get_bool_flag(nsINode_BooleanFlag::ElementHasID)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue