mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Hoist style-only traversal into geckolib.
Implementing StandaloneStyleContext::new is going to require a TLS key (just like LayoutContext::new), and we don't want that key in shared code.
This commit is contained in:
parent
92d8e8bcdf
commit
cafc0aabdf
4 changed files with 54 additions and 45 deletions
|
@ -2,13 +2,11 @@
|
|||
* 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 context::{LocalStyleContext, SharedStyleContext, StyleContext};
|
||||
use context::{SharedStyleContext, StyleContext};
|
||||
use dom::{OpaqueNode, TNode, TRestyleDamage, UnsafeNode};
|
||||
use matching::{ApplicableDeclarations, ElementMatchMethods, MatchMethods, StyleSharingResult};
|
||||
use selectors::bloom::BloomFilter;
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use util::opts;
|
||||
use util::tid::tid;
|
||||
|
||||
|
@ -115,47 +113,6 @@ pub trait DomTraversalContext<'ln, N: TNode<'ln>> {
|
|||
fn process_postorder(&self, node: N);
|
||||
}
|
||||
|
||||
pub struct StandaloneStyleContext<'a> {
|
||||
pub shared: &'a SharedStyleContext,
|
||||
cached_local_style_context: Rc<LocalStyleContext>,
|
||||
}
|
||||
|
||||
impl<'a> StandaloneStyleContext<'a> {
|
||||
pub fn new(_: &'a SharedStyleContext) -> Self { panic!("Not implemented") }
|
||||
}
|
||||
|
||||
impl<'a> StyleContext<'a> for StandaloneStyleContext<'a> {
|
||||
fn shared_context(&self) -> &'a SharedStyleContext {
|
||||
&self.shared
|
||||
}
|
||||
|
||||
fn local_context(&self) -> &LocalStyleContext {
|
||||
&self.cached_local_style_context
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RecalcStyleOnly<'lc> {
|
||||
context: StandaloneStyleContext<'lc>,
|
||||
root: OpaqueNode,
|
||||
}
|
||||
|
||||
impl<'lc, 'ln, N: TNode<'ln>> DomTraversalContext<'ln, N> for RecalcStyleOnly<'lc> {
|
||||
type SharedContext = SharedStyleContext;
|
||||
#[allow(unsafe_code)]
|
||||
fn new<'a>(shared: &'a Self::SharedContext, root: OpaqueNode) -> Self {
|
||||
// See the comment in RecalcStyleAndConstructFlows::new for an explanation of why this is
|
||||
// necessary.
|
||||
let shared_lc: &'lc SharedStyleContext = unsafe { mem::transmute(shared) };
|
||||
RecalcStyleOnly {
|
||||
context: StandaloneStyleContext::new(shared_lc),
|
||||
root: root,
|
||||
}
|
||||
}
|
||||
|
||||
fn process_preorder(&self, node: N) { recalc_style_at(&self.context, self.root, node); }
|
||||
fn process_postorder(&self, _: N) {}
|
||||
}
|
||||
|
||||
/// The recalc-style-for-node traversal, which styles each node and must run before
|
||||
/// layout computation. This computes the styles applied to each node.
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue