mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Simplify rule_tree::StyleSourceGuardHandle
This commit is contained in:
parent
98bd99b74c
commit
2dd2c9cedd
1 changed files with 4 additions and 13 deletions
|
@ -8,7 +8,6 @@ use arc_ptr_eq;
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
use heapsize::HeapSizeOf;
|
use heapsize::HeapSizeOf;
|
||||||
use owning_handle::OwningHandle;
|
use owning_handle::OwningHandle;
|
||||||
use owning_ref::{ArcRef, OwningRef};
|
|
||||||
use parking_lot::{RwLock, RwLockReadGuard};
|
use parking_lot::{RwLock, RwLockReadGuard};
|
||||||
use properties::{Importance, PropertyDeclarationBlock};
|
use properties::{Importance, PropertyDeclarationBlock};
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
|
@ -30,12 +29,9 @@ pub enum StyleSource {
|
||||||
Declarations(Arc<RwLock<PropertyDeclarationBlock>>),
|
Declarations(Arc<RwLock<PropertyDeclarationBlock>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is really nasty.
|
|
||||||
type StyleSourceGuardHandle<'a> =
|
type StyleSourceGuardHandle<'a> =
|
||||||
OwningHandle<
|
OwningHandle<
|
||||||
OwningHandle<
|
RwLockReadGuard<'a, StyleRule>,
|
||||||
OwningRef<Arc<RwLock<StyleRule>>, RwLock<StyleRule>>,
|
|
||||||
RwLockReadGuard<'a, StyleRule>>,
|
|
||||||
RwLockReadGuard<'a, PropertyDeclarationBlock>>;
|
RwLockReadGuard<'a, PropertyDeclarationBlock>>;
|
||||||
|
|
||||||
pub enum StyleSourceGuard<'a> {
|
pub enum StyleSourceGuard<'a> {
|
||||||
|
@ -80,13 +76,8 @@ impl StyleSource {
|
||||||
use self::StyleSource::*;
|
use self::StyleSource::*;
|
||||||
match *self {
|
match *self {
|
||||||
Style(ref rule) => {
|
Style(ref rule) => {
|
||||||
let arc_ref = ArcRef::new(rule.clone());
|
let owning_ref = OwningHandle::new(rule.read(), |r| unsafe { &*r }.block.read());
|
||||||
let rule_owning_ref =
|
StyleSourceGuard::Style(owning_ref)
|
||||||
OwningHandle::new(arc_ref, |r| unsafe { &*r }.read());
|
|
||||||
let block_owning_ref =
|
|
||||||
OwningHandle::new(rule_owning_ref, |r| unsafe { &*r }.block.read());
|
|
||||||
|
|
||||||
StyleSourceGuard::Style(block_owning_ref)
|
|
||||||
}
|
}
|
||||||
Declarations(ref block) => StyleSourceGuard::Declarations(block.read()),
|
Declarations(ref block) => StyleSourceGuard::Declarations(block.read()),
|
||||||
}
|
}
|
||||||
|
@ -325,7 +316,7 @@ impl StrongRuleNode {
|
||||||
last = Some(child);
|
last = Some(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
let node = Box::new(RuleNode::new(root.clone(),
|
let node = Box::new(RuleNode::new(root,
|
||||||
self.clone(),
|
self.clone(),
|
||||||
source.clone(),
|
source.clone(),
|
||||||
importance));
|
importance));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue