Remove the ComputedValue traits and style_struct_traits

This commit is contained in:
Simon Sapin 2016-07-19 20:29:22 +02:00
parent b2a7e44373
commit 789807b7b0
60 changed files with 589 additions and 652 deletions

View file

@ -6,12 +6,10 @@ use std::cell::RefCell;
use std::rc::Rc;
use style::context::{LocalStyleContext, StyleContext};
thread_local!(static LOCAL_CONTEXT_KEY:
RefCell<Option<Rc<LocalStyleContext<GeckoSelectorImpl>>>> = RefCell::new(None));
thread_local!(static LOCAL_CONTEXT_KEY: RefCell<Option<Rc<LocalStyleContext>>> = RefCell::new(None));
// Keep this implementation in sync with the one in components/layout/context.rs.
fn create_or_get_local_context(shared: &SharedStyleContext)
-> Rc<LocalStyleContext<GeckoSelectorImpl>> {
fn create_or_get_local_context(shared: &SharedStyleContext) -> Rc<LocalStyleContext> {
LOCAL_CONTEXT_KEY.with(|r| {
let mut r = r.borrow_mut();
if let Some(context) = r.clone() {
@ -29,7 +27,7 @@ fn create_or_get_local_context(shared: &SharedStyleContext)
pub struct StandaloneStyleContext<'a> {
pub shared: &'a SharedStyleContext,
cached_local_context: Rc<LocalStyleContext<GeckoSelectorImpl>>,
cached_local_context: Rc<LocalStyleContext>,
}
impl<'a> StandaloneStyleContext<'a> {
@ -47,7 +45,7 @@ impl<'a> StyleContext<'a, GeckoSelectorImpl> for StandaloneStyleContext<'a> {
&self.shared
}
fn local_context(&self) -> &LocalStyleContext<GeckoSelectorImpl> {
fn local_context(&self) -> &LocalStyleContext {
&self.cached_local_context
}
}

View file

@ -14,7 +14,7 @@ use gecko_bindings::bindings::{ServoDeclarationBlock, ServoNodeData, ThreadSafeP
use gecko_bindings::bindings::{ThreadSafeURIHolder, nsHTMLCSSStyleSheet};
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
use gecko_bindings::structs::{SheetParsingMode, nsIAtom};
use properties::GeckoComputedValues;
use properties::ComputedValuesStruct;
use selector_impl::{GeckoSelectorImpl, PseudoElement, SharedStyleContext, Stylesheet};
use std::mem::transmute;
use std::ptr;
@ -28,7 +28,7 @@ use style::error_reporting::StdoutErrorReporter;
use style::gecko_glue::ArcHelpers;
use style::parallel;
use style::parser::ParserContextExtraData;
use style::properties::{ComputedValues, PropertyDeclarationBlock, parse_one_declaration};
use style::properties::{PropertyDeclarationBlock, parse_one_declaration};
use style::selector_impl::{SelectorImplExt, PseudoElementCascadeType};
use style::sequential;
use style::stylesheets::Origin;
@ -87,7 +87,7 @@ fn restyle_subtree(node: GeckoNode, raw_data: *mut RawServoStyleSet) {
// rid of the HackilyFindSomeDeviceContext stuff that happens during
// initial_values computation, since that stuff needs to be called further
// along in startup than the sensible place to call Servo_Initialize.
GeckoComputedValues::initial_values();
ComputedValuesStruct::initial_values();
let _needs_dirtying = Arc::get_mut(&mut per_doc_data.stylist).unwrap()
.update(&per_doc_data.stylesheets,
@ -259,7 +259,7 @@ pub extern "C" fn Servo_GetComputedValues(node: *mut RawGeckoNode)
// cases where Gecko wants the style for a node that Servo never
// traversed. We should remove this as soon as possible.
error!("stylo: encountered unstyled node, substituting default values.");
Arc::new(GeckoComputedValues::initial_values().clone())
Arc::new(ComputedValuesStruct::initial_values().clone())
},
};
unsafe { transmute(arc_cv) }
@ -280,7 +280,7 @@ pub extern "C" fn Servo_GetComputedValuesForAnonymousBox(parent_style_or_null: *
}
};
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
Helpers::maybe_with(parent_style_or_null, |maybe_parent| {
let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent);
@ -319,7 +319,7 @@ pub extern "C" fn Servo_GetComputedValuesForPseudoElement(parent_style: *mut Ser
let element = unsafe { GeckoElement::from_raw(match_element) };
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
match GeckoSelectorImpl::pseudo_element_cascade_type(&pseudo) {
PseudoElementCascadeType::Eager => {
@ -347,22 +347,22 @@ pub extern "C" fn Servo_GetComputedValuesForPseudoElement(parent_style: *mut Ser
#[no_mangle]
pub extern "C" fn Servo_InheritComputedValues(parent_style: *mut ServoComputedValues)
-> *mut ServoComputedValues {
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
Helpers::with(parent_style, |parent| {
let style = GeckoComputedValues::inherit_from(parent);
let style = ComputedValuesStruct::inherit_from(parent);
Helpers::from(style)
})
}
#[no_mangle]
pub extern "C" fn Servo_AddRefComputedValues(ptr: *mut ServoComputedValues) -> () {
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
unsafe { Helpers::addref(ptr) };
}
#[no_mangle]
pub extern "C" fn Servo_ReleaseComputedValues(ptr: *mut ServoComputedValues) -> () {
type Helpers = ArcHelpers<ServoComputedValues, GeckoComputedValues>;
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
unsafe { Helpers::release(ptr) };
}

View file

@ -27,7 +27,7 @@ use gecko_bindings::structs::nsIAtom;
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
use glue::GeckoDeclarationBlock;
use libc::uintptr_t;
use properties::GeckoComputedValues;
use properties::ComputedValuesStruct;
use selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PrivateStyleData};
use selectors::Element;
use selectors::matching::DeclarationBlock;
@ -99,8 +99,7 @@ impl<'ln> GeckoNode<'ln> {
#[derive(Clone, Copy)]
pub struct DummyRestyleDamage;
impl TRestyleDamage for DummyRestyleDamage {
type ConcreteComputedValues = GeckoComputedValues;
fn compute(_: Option<&Arc<GeckoComputedValues>>, _: &GeckoComputedValues) -> Self { DummyRestyleDamage }
fn compute(_: Option<&Arc<ComputedValuesStruct>>, _: &ComputedValuesStruct) -> Self { DummyRestyleDamage }
fn rebuild_and_reflow() -> Self { DummyRestyleDamage }
}
impl BitOr for DummyRestyleDamage {
@ -114,7 +113,6 @@ impl<'ln> TNode for GeckoNode<'ln> {
type ConcreteDocument = GeckoDocument<'ln>;
type ConcreteElement = GeckoElement<'ln>;
type ConcreteRestyleDamage = DummyRestyleDamage;
type ConcreteComputedValues = GeckoComputedValues;
fn to_unsafe(&self) -> UnsafeNode {
(self.node as usize, 0)