Replace RwLock<StyleRule> with Locked<StyleRule>

This commit is contained in:
Simon Sapin 2017-03-18 00:47:08 +01:00
parent 57724e5a37
commit aeffca2a59
33 changed files with 279 additions and 334 deletions

View file

@ -51,18 +51,7 @@ impl_arc_ffi!(ComputedValues => ServoComputedValues
impl_arc_ffi!(RwLock<PropertyDeclarationBlock> => RawServoDeclarationBlock
[Servo_DeclarationBlock_AddRef, Servo_DeclarationBlock_Release]);
/// FIXME: Remove once StyleRule is actually in Locked<_>
pub trait HackHackHack {
fn as_arc<'a>(ptr: &'a &RawServoStyleRule) -> &'a ::std::sync::Arc<RwLock<StyleRule>>;
}
impl HackHackHack for Locked<StyleRule> {
fn as_arc<'a>(ptr: &'a &RawServoStyleRule) -> &'a ::std::sync::Arc<RwLock<StyleRule>> {
RwLock::<StyleRule>::as_arc(ptr)
}
}
impl_arc_ffi!(RwLock<StyleRule> => RawServoStyleRule
impl_arc_ffi!(Locked<StyleRule> => RawServoStyleRule
[Servo_StyleRule_AddRef, Servo_StyleRule_Release]);
impl_arc_ffi!(Locked<ImportRule> => RawServoImportRule

View file

@ -13,7 +13,7 @@ use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use media_queries::Device;
use parking_lot::RwLock;
use properties::ComputedValues;
use shared_lock::SharedRwLockReadGuard;
use shared_lock::{ReadGuards, SharedRwLockReadGuard};
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::mpsc::{Receiver, Sender, channel};
@ -97,7 +97,7 @@ impl PerDocumentStyleDataImpl {
pub fn flush_stylesheets(&mut self, guard: &SharedRwLockReadGuard) {
if self.stylesheets_changed {
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
stylist.update(&self.stylesheets, guard, None, true);
stylist.update(&self.stylesheets, &ReadGuards::same(guard), None, true);
self.stylesheets_changed = false;
}
}

View file

@ -13,14 +13,14 @@ use traversal::{DomTraversal, PerLevelTraversalData, TraversalDriver, recalc_sty
/// This is the simple struct that Gecko uses to encapsulate a DOM traversal for
/// styling.
pub struct RecalcStyleOnly {
shared: SharedStyleContext,
pub struct RecalcStyleOnly<'a> {
shared: SharedStyleContext<'a>,
driver: TraversalDriver,
}
impl RecalcStyleOnly {
impl<'a> RecalcStyleOnly<'a> {
/// Create a `RecalcStyleOnly` traversal from a `SharedStyleContext`.
pub fn new(shared: SharedStyleContext, driver: TraversalDriver) -> Self {
pub fn new(shared: SharedStyleContext<'a>, driver: TraversalDriver) -> Self {
RecalcStyleOnly {
shared: shared,
driver: driver,
@ -28,10 +28,11 @@ impl RecalcStyleOnly {
}
}
impl<'le> DomTraversal<GeckoElement<'le>> for RecalcStyleOnly {
impl<'recalc, 'le> DomTraversal<GeckoElement<'le>> for RecalcStyleOnly<'recalc> {
type ThreadLocalContext = ThreadLocalStyleContext<GeckoElement<'le>>;
fn process_preorder(&self, traversal_data: &mut PerLevelTraversalData,
fn process_preorder(&self,
traversal_data: &mut PerLevelTraversalData,
thread_local: &mut Self::ThreadLocalContext,
node: GeckoNode<'le>)
{