author Emilio Cobos Álvarez <>
Wed, 10 Aug 2016 21:02:30 -0500
changeset 368499 48d70a3b372b6eefc472d3ac777bc9fd47b82343
parent 368354 c240fafa26f6fdedc44dd6c3a7f3d172536e6b87
child 368541 53148dde6135ef48a1035b82c1b5dfbcbc77f79f
permissions -rw-r--r--
servo: Merge #12757 - stylo: Stop restyling display: none elements, remove the has_changed hack that made us use ReconstructFrame unconditionally (from emilio:stylo); r=bholley,pcwalton <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> r? @bholley Source-Repo: Source-Revision: 1b2450339c40dbcb65e94a346ea434d45f0edf90

/* 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 */

use context::StandaloneStyleContext;
use std::mem;
use style::context::SharedStyleContext;
use style::dom::OpaqueNode;
use style::traversal::RestyleResult;
use style::traversal::{DomTraversalContext, recalc_style_at};
use wrapper::GeckoNode;

pub struct RecalcStyleOnly<'lc> {
    context: StandaloneStyleContext<'lc>,
    root: OpaqueNode,

impl<'lc, 'ln> DomTraversalContext<GeckoNode<'ln>> for RecalcStyleOnly<'lc> {
    type SharedContext = SharedStyleContext;
    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 Self::SharedContext = unsafe { mem::transmute(shared) };
        RecalcStyleOnly {
            context: StandaloneStyleContext::new(shared_lc),
            root: root,

    fn process_preorder(&self, node: GeckoNode<'ln>) -> RestyleResult {
        // FIXME(pcwalton): Stop allocating here. Ideally this should just be done by the HTML
        // parser.

        recalc_style_at(&self.context, self.root, node)

    fn process_postorder(&self, _: GeckoNode<'ln>) {

    /// We don't use the post-order traversal for anything.
    fn needs_postorder_traversal(&self) -> bool { false }