Auto merge of #9515 - bholley:stylo_uplifts_2, r=SimonSapin

Stylo uplifts Part 2

A bunch of random things that we might as well merge into the tree.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9515)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-02-04 23:25:09 +05:30
commit 629b1d33d5
8 changed files with 353 additions and 117 deletions

View file

@ -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]