mirror of
https://github.com/servo/servo.git
synced 2025-08-25 23:28:21 +01:00
Parameterize the rest of the style system on TNode.
This commit is contained in:
parent
5c749127cc
commit
c2daea2c9c
37 changed files with 149 additions and 113 deletions
|
@ -37,6 +37,7 @@ mod bindings;
|
|||
mod data;
|
||||
#[allow(non_snake_case)]
|
||||
pub mod glue;
|
||||
mod properties;
|
||||
mod selector_impl;
|
||||
mod traversal;
|
||||
mod wrapper;
|
||||
|
|
8
ports/geckolib/properties.rs
Normal file
8
ports/geckolib/properties.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use style::properties::ComputedValues;
|
||||
|
||||
// FIXME(bholley): Create and use an actual Gecko type here.
|
||||
pub type GeckoComputedValues = ComputedValues;
|
|
@ -7,6 +7,7 @@ use std::process;
|
|||
use style;
|
||||
use style::element_state::ElementState;
|
||||
use style::error_reporting::StdoutErrorReporter;
|
||||
use style::properties::ComputedValues;
|
||||
use style::selector_impl::SelectorImplExt;
|
||||
use style::stylesheets::Origin;
|
||||
use url::Url;
|
||||
|
@ -14,7 +15,7 @@ use url::Url;
|
|||
pub type Stylist = style::selector_matching::Stylist<GeckoSelectorImpl>;
|
||||
pub type Stylesheet = style::stylesheets::Stylesheet<GeckoSelectorImpl>;
|
||||
pub type SharedStyleContext = style::context::SharedStyleContext<GeckoSelectorImpl>;
|
||||
pub type PrivateStyleData = style::data::PrivateStyleData<GeckoSelectorImpl>;
|
||||
pub type PrivateStyleData = style::data::PrivateStyleData<GeckoSelectorImpl, ComputedValues>;
|
||||
|
||||
pub struct GeckoSelectorImpl;
|
||||
|
||||
|
|
|
@ -2,20 +2,23 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use properties::GeckoComputedValues;
|
||||
use selector_impl::{GeckoSelectorImpl, SharedStyleContext};
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use style::context::{LocalStyleContext, StyleContext};
|
||||
use style::dom::{OpaqueNode, TNode};
|
||||
use style::dom::OpaqueNode;
|
||||
use style::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
|
||||
use style::traversal::{DomTraversalContext, recalc_style_at};
|
||||
use wrapper::GeckoNode;
|
||||
|
||||
thread_local!(static LOCAL_CONTEXT_KEY: RefCell<Option<Rc<LocalStyleContext>>> = RefCell::new(None));
|
||||
thread_local!(static LOCAL_CONTEXT_KEY:
|
||||
RefCell<Option<Rc<LocalStyleContext<GeckoComputedValues>>>> = 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> {
|
||||
-> Rc<LocalStyleContext<GeckoComputedValues>> {
|
||||
LOCAL_CONTEXT_KEY.with(|r| {
|
||||
let mut r = r.borrow_mut();
|
||||
if let Some(context) = r.clone() {
|
||||
|
@ -36,7 +39,7 @@ fn create_or_get_local_context(shared: &SharedStyleContext)
|
|||
|
||||
pub struct StandaloneStyleContext<'a> {
|
||||
pub shared: &'a SharedStyleContext,
|
||||
cached_local_context: Rc<LocalStyleContext>,
|
||||
cached_local_context: Rc<LocalStyleContext<GeckoComputedValues>>,
|
||||
}
|
||||
|
||||
impl<'a> StandaloneStyleContext<'a> {
|
||||
|
@ -49,12 +52,12 @@ impl<'a> StandaloneStyleContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> StyleContext<'a, GeckoSelectorImpl> for StandaloneStyleContext<'a> {
|
||||
impl<'a> StyleContext<'a, GeckoSelectorImpl, GeckoComputedValues> for StandaloneStyleContext<'a> {
|
||||
fn shared_context(&self) -> &'a SharedStyleContext {
|
||||
&self.shared
|
||||
}
|
||||
|
||||
fn local_context(&self) -> &LocalStyleContext {
|
||||
fn local_context(&self) -> &LocalStyleContext<GeckoComputedValues> {
|
||||
&self.cached_local_context
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +67,7 @@ pub struct RecalcStyleOnly<'lc> {
|
|||
root: OpaqueNode,
|
||||
}
|
||||
|
||||
impl<'lc, N: TNode> DomTraversalContext<N> for RecalcStyleOnly<'lc>
|
||||
where N::ConcreteElement: ::selectors::Element<Impl=GeckoSelectorImpl> {
|
||||
impl<'lc, 'ln> DomTraversalContext<GeckoNode<'ln>> for RecalcStyleOnly<'lc> {
|
||||
type SharedContext = SharedStyleContext;
|
||||
#[allow(unsafe_code)]
|
||||
fn new<'a>(shared: &'a Self::SharedContext, root: OpaqueNode) -> Self {
|
||||
|
@ -78,7 +80,7 @@ impl<'lc, N: TNode> DomTraversalContext<N> for RecalcStyleOnly<'lc>
|
|||
}
|
||||
}
|
||||
|
||||
fn process_preorder(&self, node: N) { recalc_style_at(&self.context, self.root, node); }
|
||||
fn process_postorder(&self, _: N) {}
|
||||
fn process_preorder(&self, node: GeckoNode<'ln>) { recalc_style_at(&self.context, self.root, node); }
|
||||
fn process_postorder(&self, _: GeckoNode<'ln>) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ use bindings::{Gecko_LocalName, Gecko_Namespace, Gecko_NodeIsElement, Gecko_SetN
|
|||
use bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
|
||||
use bindings::{ServoNodeData};
|
||||
use libc::uintptr_t;
|
||||
use properties::GeckoComputedValues;
|
||||
use selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PrivateStyleData};
|
||||
use selectors::Element;
|
||||
use selectors::matching::DeclarationBlock;
|
||||
|
@ -35,7 +36,7 @@ use style::dom::{OpaqueNode, TDocument, TElement, TNode, TRestyleDamage, UnsafeN
|
|||
use style::element_state::ElementState;
|
||||
#[allow(unused_imports)] // Used in commented-out code.
|
||||
use style::error_reporting::StdoutErrorReporter;
|
||||
use style::properties::{ComputedValues, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
||||
#[allow(unused_imports)] // Used in commented-out code.
|
||||
use style::properties::{parse_style_attribute};
|
||||
use style::restyle_hints::ElementSnapshot;
|
||||
|
@ -78,7 +79,8 @@ impl<'ln> GeckoNode<'ln> {
|
|||
#[derive(Clone, Copy)]
|
||||
pub struct DummyRestyleDamage;
|
||||
impl TRestyleDamage for DummyRestyleDamage {
|
||||
fn compute(_: Option<&Arc<ComputedValues>>, _: &ComputedValues) -> Self { DummyRestyleDamage }
|
||||
type ConcreteComputedValues = GeckoComputedValues;
|
||||
fn compute(_: Option<&Arc<GeckoComputedValues>>, _: &GeckoComputedValues) -> Self { DummyRestyleDamage }
|
||||
fn rebuild_and_reflow() -> Self { DummyRestyleDamage }
|
||||
}
|
||||
impl BitOr for DummyRestyleDamage {
|
||||
|
@ -92,6 +94,7 @@ 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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue