servo: Merge #14034 - incremental restyle: Use more concrete types in the style system (from bholley:more_concrete_types); r=emilio
authorBobby Holley <bobbyholley@gmail.com>
Mon, 07 Nov 2016 16:31:10 -0600
changeset 340090 3defb62e98c2ae9e6fb70fec1995882dd2fb1aef
parent 340089 1a45b7787ad825bc5b895d835b3ca90aba271b88
child 340091 0fced87fe853f062df4c13f3c928c234255fce0e
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
servo: Merge #14034 - incremental restyle: Use more concrete types in the style system (from bholley:more_concrete_types); r=emilio We need to hang both snapshots and restyle damage off of ElementData, and so we need them to be concrete to avoid infecting ElementData with the trait hierarchy. Source-Repo: https://github.com/servo/servo Source-Revision: d8ac5100e81ccbad4b5131688b96bedb9b5e279d
servo/components/layout/animation.rs
servo/components/layout/block.rs
servo/components/layout/construct.rs
servo/components/layout/display_list_builder.rs
servo/components/layout/flex.rs
servo/components/layout/flow.rs
servo/components/layout/fragment.rs
servo/components/layout/generated_content.rs
servo/components/layout/incremental.rs
servo/components/layout/inline.rs
servo/components/layout/list_item.rs
servo/components/layout/sequential.rs
servo/components/layout/table.rs
servo/components/layout/table_row.rs
servo/components/layout/traversal.rs
servo/components/layout_thread/lib.rs
servo/components/script/dom/bindings/trace.rs
servo/components/script/dom/document.rs
servo/components/script/layout_wrapper.rs
servo/components/script_layout_interface/lib.rs
servo/components/script_layout_interface/restyle_damage.rs
servo/components/script_layout_interface/wrapper_traits.rs
servo/components/style/dom.rs
servo/components/style/gecko/mod.rs
servo/components/style/gecko/restyle_damage.rs
servo/components/style/gecko/wrapper.rs
servo/components/style/lib.rs
servo/components/style/matching.rs
servo/components/style/restyle_hints.rs
servo/components/style/selector_impl.rs
servo/components/style/selector_matching.rs
servo/components/style/servo/mod.rs
servo/components/style/servo/restyle_damage.rs
servo/components/style/servo/selector_impl.rs
servo/components/style/servo_selector_impl.rs
--- a/servo/components/layout/animation.rs
+++ b/servo/components/layout/animation.rs
@@ -4,22 +4,22 @@
 
 //! CSS transitions and animations.
 
 use context::SharedLayoutContext;
 use flow::{self, Flow};
 use gfx::display_list::OpaqueNode;
 use ipc_channel::ipc::IpcSender;
 use msg::constellation_msg::PipelineId;
-use script_layout_interface::restyle_damage::RestyleDamage;
 use script_traits::{AnimationState, ConstellationControlMsg, LayoutMsg as ConstellationMsg};
 use std::collections::HashMap;
 use std::sync::mpsc::Receiver;
 use style::animation::{Animation, update_style_for_animation};
 use style::dom::TRestyleDamage;
+use style::selector_impl::RestyleDamage;
 use style::timer::Timer;
 
 /// Processes any new animations that were discovered after style recalculation.
 /// Also expire any old animations that have completed, inserting them into
 /// `expired_animations`.
 pub fn update_animation_state(constellation_chan: &IpcSender<ConstellationMsg>,
                               script_chan: &IpcSender<ConstellationControlMsg>,
                               running_animations: &mut HashMap<OpaqueNode, Vec<Animation>>,
--- a/servo/components/layout/block.rs
+++ b/servo/components/layout/block.rs
@@ -43,28 +43,27 @@ use flow_list::FlowList;
 use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
 use fragment::SpecificFragmentInfo;
 use gfx::display_list::{ClippingRegion, StackingContext};
 use gfx_traits::ScrollRootId;
 use gfx_traits::print_tree::PrintTree;
 use layout_debug;
 use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo, MaybeAuto};
 use model::{specified, specified_or_none};
-use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW};
-use script_layout_interface::restyle_damage::REPOSITION;
 use sequential;
 use serde::{Serialize, Serializer};
 use std::cmp::{max, min};
 use std::fmt;
 use std::sync::Arc;
 use style::computed_values::{border_collapse, box_sizing, display, float, overflow_x, overflow_y};
 use style::computed_values::{position, text_align};
 use style::context::{SharedStyleContext, StyleContext};
 use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
 use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION};
 use style::values::computed::{LengthOrPercentageOrNone, LengthOrPercentage};
 use style::values::computed::LengthOrPercentageOrAuto;
 use util::clamp;
 
 /// Information specific to floated blocks.
 #[derive(Clone, Serialize)]
 pub struct FloatedBlockInfo {
     /// The amount of inline size that is available for the float.
--- a/servo/components/layout/construct.rs
+++ b/servo/components/layout/construct.rs
@@ -31,31 +31,31 @@ use fragment::WhitespaceStrippingResult;
 use gfx::display_list::OpaqueNode;
 use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, InlineFragmentNodeFlags};
 use inline::{InlineFragmentNodeInfo, LAST_FRAGMENT_OF_ELEMENT};
 use linked_list::prepend_from;
 use list_item::{ListItemFlow, ListStyleTypeContent};
 use multicol::{MulticolColumnFlow, MulticolFlow};
 use parallel;
 use script_layout_interface::{LayoutElementType, LayoutNodeType, is_image_data};
-use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW, RestyleDamage};
 use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
 use std::borrow::ToOwned;
 use std::collections::LinkedList;
 use std::marker::PhantomData;
 use std::mem;
 use std::sync::Arc;
 use std::sync::atomic::Ordering;
 use style::computed_values::{caption_side, display, empty_cells, float, list_style_image, list_style_position};
 use style::computed_values::content::ContentItem;
 use style::computed_values::position;
 use style::context::SharedStyleContext;
 use style::properties::{self, ServoComputedValues};
+use style::selector_impl::{PseudoElement, RestyleDamage};
 use style::selector_matching::Stylist;
-use style::servo_selector_impl::PseudoElement;
+use style::servo::restyle_damage::{BUBBLE_ISIZES, RECONSTRUCT_FLOW};
 use table::TableFlow;
 use table_caption::TableCaptionFlow;
 use table_cell::TableCellFlow;
 use table_colgroup::TableColGroupFlow;
 use table_row::TableRowFlow;
 use table_rowgroup::TableRowGroupFlow;
 use table_wrapper::TableWrapperFlow;
 use text::TextRunScanner;
--- a/servo/components/layout/display_list_builder.rs
+++ b/servo/components/layout/display_list_builder.rs
@@ -30,32 +30,32 @@ use gfx::display_list::{TextDisplayItem,
 use gfx_traits::{ScrollPolicy, ScrollRootId, StackingContextId};
 use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
 use ipc_channel::ipc;
 use list_item::ListItemFlow;
 use model::{self, MaybeAuto, ToGfxMatrix};
 use net_traits::image::base::PixelFormat;
 use net_traits::image_cache_thread::UsePlaceholder;
 use range::Range;
-use script_layout_interface::restyle_damage::REPAINT;
 use std::{cmp, f32};
 use std::collections::HashMap;
 use std::default::Default;
 use std::mem;
 use std::sync::Arc;
 use style::computed_values::{background_attachment, background_clip, background_origin};
 use style::computed_values::{background_repeat, background_size, border_style};
 use style::computed_values::{cursor, image_rendering, overflow_x, pointer_events, position};
 use style::computed_values::{transform, transform_style, visibility};
 use style::computed_values::_servo_overflow_clip_box as overflow_clip_box;
 use style::computed_values::filter::Filter;
 use style::computed_values::text_shadow::TextShadow;
 use style::logical_geometry::{LogicalPoint, LogicalRect, LogicalSize, WritingMode};
 use style::properties::{self, ServoComputedValues};
 use style::properties::style_structs;
+use style::servo::restyle_damage::REPAINT;
 use style::values::RGBA;
 use style::values::computed;
 use style::values::computed::{Gradient, GradientKind, LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
 use style::values::specified::{AngleOrCorner, HorizontalDirection, VerticalDirection};
 use style_traits::cursor::Cursor;
 use table_cell::CollapsedBordersForCell;
 use url::Url;
 use util::opts;
--- a/servo/components/layout/flex.rs
+++ b/servo/components/layout/flex.rs
@@ -16,25 +16,25 @@ use flow;
 use flow::{Flow, FlowClass, ImmutableFlowUtils, OpaqueFlow};
 use flow::{INLINE_POSITION_IS_STATIC, IS_ABSOLUTELY_POSITIONED};
 use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
 use gfx::display_list::StackingContext;
 use gfx_traits::ScrollRootId;
 use layout_debug;
 use model::{Direction, IntrinsicISizes, MaybeAuto, MinMaxConstraint};
 use model::{specified, specified_or_none};
-use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
 use std::cmp::{max, min};
 use std::ops::Range;
 use std::sync::Arc;
 use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content};
 use style::computed_values::border_collapse;
 use style::context::{SharedStyleContext, StyleContext};
 use style::logical_geometry::LogicalSize;
 use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
 use style::values::computed::{LengthOrPercentage, LengthOrPercentageOrAuto};
 use style::values::computed::{LengthOrPercentageOrAutoOrContent, LengthOrPercentageOrNone};
 
 /// The size of an axis. May be a specified size, a min/max
 /// constraint, or an unlimited size
 #[derive(Debug)]
 enum AxisSize {
     Definite(Au),
--- a/servo/components/layout/flow.rs
+++ b/servo/components/layout/flow.rs
@@ -36,29 +36,29 @@ use flow_ref::{FlowRef, WeakFlowRef};
 use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
 use gfx::display_list::{ClippingRegion, StackingContext};
 use gfx_traits::{ScrollRootId, StackingContextId};
 use gfx_traits::print_tree::PrintTree;
 use inline::InlineFlow;
 use model::{CollapsibleMargins, IntrinsicISizes, MarginCollapseInfo};
 use multicol::MulticolFlow;
 use parallel::FlowParallelInfo;
-use script_layout_interface::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW};
-use script_layout_interface::restyle_damage::{REPAINT, REPOSITION, RestyleDamage};
 use serde::{Serialize, Serializer};
 use std::{fmt, mem, raw};
 use std::iter::Zip;
 use std::slice::IterMut;
 use std::sync::Arc;
 use std::sync::atomic::Ordering;
 use style::computed_values::{clear, float, overflow_x, position, text_align};
 use style::context::SharedStyleContext;
 use style::dom::TRestyleDamage;
 use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
 use style::properties::ServoComputedValues;
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::{RECONSTRUCT_FLOW, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
 use style::values::computed::LengthOrPercentageOrAuto;
 use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, TableFlow};
 use table_caption::TableCaptionFlow;
 use table_cell::TableCellFlow;
 use table_colgroup::TableColGroupFlow;
 use table_row::TableRowFlow;
 use table_rowgroup::TableRowGroupFlow;
 use table_wrapper::TableWrapperFlow;
--- a/servo/components/layout/fragment.rs
+++ b/servo/components/layout/fragment.rs
@@ -25,33 +25,34 @@ use ipc_channel::ipc::IpcSender;
 use layout_debug;
 use model::{self, Direction, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
 use msg::constellation_msg::PipelineId;
 use net_traits::image::base::{Image, ImageMetadata};
 use net_traits::image_cache_thread::{ImageOrMetadataAvailable, UsePlaceholder};
 use range::*;
 use script_layout_interface::HTMLCanvasData;
 use script_layout_interface::SVGSVGData;
-use script_layout_interface::restyle_damage::{RECONSTRUCT_FLOW, RestyleDamage};
 use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
 use serde::{Serialize, Serializer};
 use std::borrow::ToOwned;
 use std::cmp::{max, min};
 use std::collections::LinkedList;
 use std::fmt;
 use std::sync::{Arc, Mutex};
 use style::arc_ptr_eq;
 use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode};
 use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration};
 use style::computed_values::{transform_style, vertical_align, white_space, word_break, z_index};
 use style::computed_values::content::ContentItem;
 use style::context::SharedStyleContext;
 use style::dom::TRestyleDamage;
 use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
 use style::properties::ServoComputedValues;
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::RECONSTRUCT_FLOW;
 use style::str::char_is_whitespace;
 use style::values::computed::{LengthOrNone, LengthOrPercentage, LengthOrPercentageOrAuto};
 use style::values::computed::LengthOrPercentageOrNone;
 use text;
 use text::TextRunScanner;
 use url::Url;
 
 // From gfxFontConstants.h in Firefox.
--- a/servo/components/layout/generated_content.rs
+++ b/servo/components/layout/generated_content.rs
@@ -8,25 +8,26 @@
 //! done in parallel and is therefore a sequential pass that runs on as little of the flow tree
 //! as possible.
 
 use context::LayoutContext;
 use flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, ImmutableFlowUtils};
 use flow::InorderFlowTraversal;
 use fragment::{Fragment, GeneratedContentInfo, SpecificFragmentInfo, UnscannedTextFragmentInfo};
 use gfx::display_list::OpaqueNode;
-use script_layout_interface::restyle_damage::{RESOLVE_GENERATED_CONTENT, RestyleDamage};
 use script_layout_interface::wrapper_traits::PseudoElementType;
 use smallvec::SmallVec;
 use std::collections::{HashMap, LinkedList};
 use std::sync::Arc;
 use style::computed_values::{display, list_style_type};
 use style::computed_values::content::ContentItem;
 use style::dom::TRestyleDamage;
 use style::properties::ServoComputedValues;
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
 use text::TextRunScanner;
 
 // Decimal styles per CSS-COUNTER-STYLES § 6.1:
 static DECIMAL: [char; 10] = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
 // TODO(pcwalton): `decimal-leading-zero`
 static ARABIC_INDIC: [char; 10] = [ '٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩' ];
 // TODO(pcwalton): `armenian`, `upper-armenian`, `lower-armenian`
 static BENGALI: [char; 10] = [ '০', '১', '২', '৩', '৪', '৫', '৬', '৭', '৮', '৯' ];
--- a/servo/components/layout/incremental.rs
+++ b/servo/components/layout/incremental.rs
@@ -1,16 +1,17 @@
 /* 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 flow::{self, AFFECTS_COUNTERS, Flow, HAS_COUNTER_AFFECTING_CHILDREN, IS_ABSOLUTELY_POSITIONED};
-use script_layout_interface::restyle_damage::{RestyleDamage, REFLOW, RECONSTRUCT_FLOW};
 use style::computed_values::float;
 use style::dom::TRestyleDamage;
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::{REFLOW, RECONSTRUCT_FLOW};
 
 bitflags! {
     pub flags SpecialRestyleDamage: u8 {
         #[doc = "If this flag is set, we need to reflow the entire document. This is more or less a \
                  temporary hack to deal with cases that we don't handle incrementally yet."]
         const REFLOW_ENTIRE_DOCUMENT = 0x01,
     }
 }
--- a/servo/components/layout/inline.rs
+++ b/servo/components/layout/inline.rs
@@ -19,29 +19,28 @@ use fragment::SpecificFragmentInfo;
 use gfx::display_list::{OpaqueNode, StackingContext};
 use gfx::font::FontMetrics;
 use gfx::font_context::FontContext;
 use gfx_traits::ScrollRootId;
 use gfx_traits::print_tree::PrintTree;
 use layout_debug;
 use model::IntrinsicISizesContribution;
 use range::{Range, RangeIndex};
-use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW};
-use script_layout_interface::restyle_damage::{REPOSITION, RESOLVE_GENERATED_CONTENT};
 use script_layout_interface::wrapper_traits::PseudoElementType;
 use std::{fmt, i32, isize, mem};
 use std::cmp::max;
 use std::collections::VecDeque;
 use std::sync::Arc;
 use style::arc_ptr_eq;
 use style::computed_values::{display, overflow_x, position, text_align, text_justify};
 use style::computed_values::{text_overflow, vertical_align, white_space};
 use style::context::{SharedStyleContext, StyleContext};
 use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
 use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPOSITION, RESOLVE_GENERATED_CONTENT};
 use text;
 use unicode_bidi;
 
 /// `Line`s are represented as offsets into the child list, rather than
 /// as an object that "owns" fragments. Choosing a different set of line
 /// breaks requires a new list of offsets, and possibly some splitting and
 /// merging of TextFragments.
 ///
--- a/servo/components/layout/list_item.rs
+++ b/servo/components/layout/list_item.rs
@@ -15,22 +15,22 @@ use euclid::Point2D;
 use floats::FloatKind;
 use flow::{Flow, FlowClass, OpaqueFlow};
 use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedContentInfo};
 use fragment::Overflow;
 use generated_content;
 use gfx::display_list::StackingContext;
 use gfx_traits::ScrollRootId;
 use inline::InlineFlow;
-use script_layout_interface::restyle_damage::RESOLVE_GENERATED_CONTENT;
 use std::sync::Arc;
 use style::computed_values::{list_style_type, position};
 use style::context::SharedStyleContext;
 use style::logical_geometry::LogicalSize;
 use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::RESOLVE_GENERATED_CONTENT;
 
 /// A block with the CSS `display` property equal to `list-item`.
 #[derive(Debug)]
 pub struct ListItemFlow {
     /// Data common to all block flows.
     pub block_flow: BlockFlow,
     /// The marker, if outside. (Markers that are inside are instead just fragments on the interior
     /// `InlineFlow`.)
--- a/servo/components/layout/sequential.rs
+++ b/servo/components/layout/sequential.rs
@@ -10,18 +10,18 @@ use display_list_builder::DisplayListBui
 use euclid::point::Point2D;
 use floats::SpeculatedFloatPlacement;
 use flow::{self, Flow, ImmutableFlowUtils, InorderFlowTraversal, MutableFlowUtils};
 use flow::{PostorderFlowTraversal, PreorderFlowTraversal};
 use flow::IS_ABSOLUTELY_POSITIONED;
 use fragment::FragmentBorderBoxIterator;
 use generated_content::ResolveGeneratedContent;
 use gfx_traits::ScrollRootId;
-use script_layout_interface::restyle_damage::{REFLOW, STORE_OVERFLOW};
 use style::context::StyleContext;
+use style::servo::restyle_damage::{REFLOW, STORE_OVERFLOW};
 use traversal::{AssignBSizes, AssignISizes, BubbleISizes, BuildDisplayList};
 use util::opts;
 
 pub use style::sequential::traverse_dom;
 
 pub fn resolve_generated_content(root: &mut Flow, shared_layout_context: &SharedLayoutContext) {
     fn doit(flow: &mut Flow, level: u32, traversal: &mut ResolveGeneratedContent) {
         if !traversal.should_process(flow) {
--- a/servo/components/layout/table.rs
+++ b/servo/components/layout/table.rs
@@ -16,24 +16,24 @@ use flow;
 use flow::{BaseFlow, EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, OpaqueFlow};
 use flow_list::MutFlowListIterator;
 use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
 use gfx::display_list::StackingContext;
 use gfx_traits::ScrollRootId;
 use gfx_traits::print_tree::PrintTree;
 use layout_debug;
 use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
-use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
 use std::cmp;
 use std::fmt;
 use std::sync::Arc;
 use style::computed_values::{border_collapse, border_spacing, table_layout};
 use style::context::SharedStyleContext;
 use style::logical_geometry::LogicalSize;
 use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
 use style::values::CSSFloat;
 use style::values::computed::LengthOrPercentageOrAuto;
 use table_row::{self, CellIntrinsicInlineSize, CollapsedBorder, CollapsedBorderProvenance};
 use table_row::TableRowFlow;
 use table_wrapper::TableLayout;
 
 /// A table flow corresponded to the table's internal table fragment under a table wrapper flow.
 /// The properties `position`, `float`, and `margin-*` are used on the table wrapper fragment,
--- a/servo/components/layout/table_row.rs
+++ b/servo/components/layout/table_row.rs
@@ -15,26 +15,26 @@ use euclid::Point2D;
 use flow::{self, EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, OpaqueFlow};
 use flow_list::MutFlowListIterator;
 use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
 use gfx::display_list::StackingContext;
 use gfx_traits::ScrollRootId;
 use gfx_traits::print_tree::PrintTree;
 use layout_debug;
 use model::MaybeAuto;
-use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
 use serde::{Serialize, Serializer};
 use std::cmp::max;
 use std::fmt;
 use std::iter::{Enumerate, IntoIterator, Peekable};
 use std::sync::Arc;
 use style::computed_values::{border_collapse, border_spacing, border_top_style};
 use style::context::SharedStyleContext;
 use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
 use style::properties::ServoComputedValues;
+use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
 use style::values::computed::LengthOrPercentageOrAuto;
 use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
 use table_cell::{CollapsedBordersForCell, TableCellFlow};
 
 /// A single row of a table.
 pub struct TableRowFlow {
     /// Fields common to all block flows.
     pub block_flow: BlockFlow,
--- a/servo/components/layout/traversal.rs
+++ b/servo/components/layout/traversal.rs
@@ -5,23 +5,24 @@
 //! Traversals over the DOM and flow trees, running the layout computations.
 
 use construct::FlowConstructor;
 use context::{LayoutContext, SharedLayoutContext};
 use display_list_builder::DisplayListBuildState;
 use flow::{self, PreorderFlowTraversal};
 use flow::{CAN_BE_FRAGMENTED, Flow, ImmutableFlowUtils, PostorderFlowTraversal};
 use gfx::display_list::OpaqueNode;
-use script_layout_interface::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, RestyleDamage};
 use script_layout_interface::wrapper_traits::{LayoutElement, LayoutNode, ThreadSafeLayoutNode};
 use std::mem;
 use style::atomic_refcell::AtomicRefCell;
 use style::context::{LocalStyleContext, SharedStyleContext, StyleContext};
 use style::data::ElementData;
 use style::dom::{StylingMode, TElement, TNode};
+use style::selector_impl::RestyleDamage;
+use style::servo::restyle_damage::{BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, REPAINT};
 use style::traversal::{DomTraversalContext, put_thread_local_bloom_filter};
 use style::traversal::{recalc_style_at, remove_from_bloom_filter};
 use style::traversal::take_thread_local_bloom_filter;
 use util::opts;
 use wrapper::{GetRawData, LayoutNodeHelpers, LayoutNodeLayoutData};
 
 pub struct RecalcStyleAndConstructFlows<'lc> {
     context: LayoutContext<'lc>,
--- a/servo/components/layout_thread/lib.rs
+++ b/servo/components/layout_thread/lib.rs
@@ -82,18 +82,16 @@ use net_traits::image_cache_thread::{Ima
 use net_traits::image_cache_thread::UsePlaceholder;
 use parking_lot::RwLock;
 use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
 use profile_traits::time::{self, TimerMetadata, profile};
 use profile_traits::time::{TimerMetadataFrameType, TimerMetadataReflowType};
 use script::layout_wrapper::{ServoLayoutDocument, ServoLayoutNode};
 use script_layout_interface::message::{Msg, NewLayoutThreadInfo, Reflow, ReflowQueryType, ScriptReflow};
 use script_layout_interface::reporter::CSSErrorReporter;
-use script_layout_interface::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION};
-use script_layout_interface::restyle_damage::STORE_OVERFLOW;
 use script_layout_interface::rpc::{LayoutRPC, MarginStyleResponse, NodeOverflowResponse, OffsetParentResponse};
 use script_layout_interface::wrapper_traits::LayoutNode;
 use script_traits::{ConstellationControlMsg, LayoutControlMsg, LayoutMsg as ConstellationMsg};
 use script_traits::{StackingContextScrollState, UntrustedNodeAddress};
 use selectors::Element;
 use std::borrow::ToOwned;
 use std::collections::HashMap;
 use std::hash::BuildHasherDefault;
@@ -106,16 +104,17 @@ use style::animation::Animation;
 use style::context::{LocalStyleContextCreationInfo, ReflowGoal, SharedStyleContext};
 use style::dom::{TDocument, TElement, TNode};
 use style::error_reporting::{ParseErrorReporter, StdoutErrorReporter};
 use style::logical_geometry::LogicalPoint;
 use style::media_queries::{Device, MediaType};
 use style::parallel::WorkQueueData;
 use style::parser::ParserContextExtraData;
 use style::selector_matching::Stylist;
+use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
 use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
 use style::thread_state;
 use style::timer::Timer;
 use style::workqueue::WorkQueue;
 use url::Url;
 use util::geometry::max_rect;
 use util::opts;
 use util::prefs::PREFS;
--- a/servo/components/script/dom/bindings/trace.rs
+++ b/servo/components/script/dom/bindings/trace.rs
@@ -89,17 +89,17 @@ use std::rc::Rc;
 use std::sync::Arc;
 use std::sync::atomic::{AtomicBool, AtomicUsize};
 use std::sync::mpsc::{Receiver, Sender};
 use std::time::{SystemTime, Instant};
 use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
 use style::element_state::*;
 use style::media_queries::MediaQueryList;
 use style::properties::PropertyDeclarationBlock;
-use style::selector_impl::{ElementSnapshot, PseudoElement};
+use style::selector_impl::{PseudoElement, Snapshot};
 use style::values::specified::Length;
 use time::Duration;
 use url::Origin as UrlOrigin;
 use url::Url;
 use uuid::Uuid;
 use webrender_traits::{WebGLBufferId, WebGLError, WebGLFramebufferId, WebGLProgramId};
 use webrender_traits::{WebGLRenderbufferId, WebGLShaderId, WebGLTextureId};
 
@@ -341,17 +341,17 @@ no_jsmanaged_fields!(TimeProfilerChan);
 no_jsmanaged_fields!(MemProfilerChan);
 no_jsmanaged_fields!(PseudoElement);
 no_jsmanaged_fields!(Length);
 no_jsmanaged_fields!(ElementState);
 no_jsmanaged_fields!(DOMString);
 no_jsmanaged_fields!(Mime);
 no_jsmanaged_fields!(AttrIdentifier);
 no_jsmanaged_fields!(AttrValue);
-no_jsmanaged_fields!(ElementSnapshot);
+no_jsmanaged_fields!(Snapshot);
 no_jsmanaged_fields!(HttpsState);
 no_jsmanaged_fields!(Request);
 no_jsmanaged_fields!(SharedRt);
 no_jsmanaged_fields!(TouchpadPressurePhase);
 no_jsmanaged_fields!(USVString);
 no_jsmanaged_fields!(ReferrerPolicy);
 no_jsmanaged_fields!(Response);
 no_jsmanaged_fields!(ResponseBody);
--- a/servo/components/script/dom/document.rs
+++ b/servo/components/script/dom/document.rs
@@ -120,17 +120,17 @@ use std::collections::hash_map::Entry::{
 use std::default::Default;
 use std::iter::once;
 use std::mem;
 use std::rc::Rc;
 use std::sync::Arc;
 use std::time::{Duration, Instant};
 use style::attr::AttrValue;
 use style::context::ReflowGoal;
-use style::selector_impl::ElementSnapshot;
+use style::selector_impl::Snapshot;
 use style::str::{split_html_space_chars, str_join};
 use style::stylesheets::Stylesheet;
 use time;
 use url::Url;
 use url::percent_encoding::percent_decode;
 use util::prefs::PREFS;
 
 pub enum TouchEventResult {
@@ -231,17 +231,17 @@ pub struct Document {
     reflow_timeout: Cell<Option<u64>>,
     /// The cached first `base` element with an `href` attribute.
     base_element: MutNullableHeap<JS<HTMLBaseElement>>,
     /// This field is set to the document itself for inert documents.
     /// https://html.spec.whatwg.org/multipage/#appropriate-template-contents-owner-document
     appropriate_template_contents_owner_document: MutNullableHeap<JS<Document>>,
     /// For each element that has had a state or attribute change since the last restyle,
     /// track the original condition of the element.
-    modified_elements: DOMRefCell<HashMap<JS<Element>, ElementSnapshot>>,
+    modified_elements: DOMRefCell<HashMap<JS<Element>, Snapshot>>,
     /// This flag will be true if layout suppressed a reflow attempt that was
     /// needed in order for the page to be painted.
     needs_paint: Cell<bool>,
     /// http://w3c.github.io/touch-events/#dfn-active-touch-point
     active_touch_points: DOMRefCell<Vec<JS<Touch>>>,
     /// Navigation Timing properties:
     /// https://w3c.github.io/navigation-timing/#sec-PerformanceNavigationTiming
     dom_loading: Cell<u64>,
@@ -1703,31 +1703,31 @@ impl Document {
 pub enum DocumentSource {
     FromParser,
     NotFromParser,
 }
 
 #[allow(unsafe_code)]
 pub trait LayoutDocumentHelpers {
     unsafe fn is_html_document_for_layout(&self) -> bool;
-    unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, ElementSnapshot)>;
+    unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, Snapshot)>;
     unsafe fn needs_paint_from_layout(&self);
     unsafe fn will_paint(&self);
 }
 
 #[allow(unsafe_code)]
 impl LayoutDocumentHelpers for LayoutJS<Document> {
     #[inline]
     unsafe fn is_html_document_for_layout(&self) -> bool {
         (*self.unsafe_get()).is_html_document
     }
 
     #[inline]
     #[allow(unrooted_must_root)]
-    unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, ElementSnapshot)> {
+    unsafe fn drain_modified_elements(&self) -> Vec<(LayoutJS<Element>, Snapshot)> {
         let mut elements = (*self.unsafe_get()).modified_elements.borrow_mut_for_layout();
         let result = elements.drain().map(|(k, v)| (k.to_layout(), v)).collect();
         result
     }
 
     #[inline]
     unsafe fn needs_paint_from_layout(&self) {
         (*self.unsafe_get()).needs_paint.set(true)
@@ -1965,28 +1965,28 @@ impl Document {
     pub fn get_element_by_id(&self, id: &Atom) -> Option<Root<Element>> {
         self.id_map.borrow().get(&id).map(|ref elements| Root::from_ref(&*(*elements)[0]))
     }
 
     pub fn element_state_will_change(&self, el: &Element) {
         let mut map = self.modified_elements.borrow_mut();
         let snapshot = map.entry(JS::from_ref(el))
                           .or_insert_with(|| {
-                              ElementSnapshot::new(el.html_element_in_html_document())
+                              Snapshot::new(el.html_element_in_html_document())
                           });
         if snapshot.state.is_none() {
             snapshot.state = Some(el.state());
         }
     }
 
     pub fn element_attr_will_change(&self, el: &Element) {
         let mut map = self.modified_elements.borrow_mut();
         let mut snapshot = map.entry(JS::from_ref(el))
                               .or_insert_with(|| {
-                                  ElementSnapshot::new(el.html_element_in_html_document())
+                                  Snapshot::new(el.html_element_in_html_document())
                               });
         if snapshot.attrs.is_none() {
             let attrs = el.attrs()
                           .iter()
                           .map(|attr| (attr.identifier().clone(), attr.value().clone()))
                           .collect();
             snapshot.attrs = Some(attrs);
         }
--- a/servo/components/script/layout_wrapper.rs
+++ b/servo/components/script/layout_wrapper.rs
@@ -41,17 +41,16 @@ use dom::node::{LayoutNodeHelpers, Node}
 use dom::text::Text;
 use gfx_traits::ByteIndex;
 use html5ever_atoms::{LocalName, Namespace};
 use msg::constellation_msg::PipelineId;
 use parking_lot::RwLock;
 use range::Range;
 use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
 use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData};
-use script_layout_interface::restyle_damage::RestyleDamage;
 use script_layout_interface::wrapper_traits::{DangerousThreadSafeLayoutNode, GetLayoutData, LayoutElement, LayoutNode};
 use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayoutElement, ThreadSafeLayoutNode};
 use selectors::matching::ElementFlags;
 use selectors::parser::{AttrSelector, NamespaceConstraint};
 use servo_atoms::Atom;
 use std::fmt;
 use std::marker::PhantomData;
 use std::mem::transmute;
@@ -61,17 +60,17 @@ use style::atomic_refcell::{AtomicRef, A
 use style::attr::AttrValue;
 use style::computed_values::display;
 use style::context::SharedStyleContext;
 use style::data::ElementData;
 use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TDocument, TElement, TNode};
 use style::dom::{TRestyleDamage, UnsafeNode};
 use style::element_state::*;
 use style::properties::{ComputedValues, PropertyDeclarationBlock};
-use style::selector_impl::{ElementSnapshot, NonTSPseudoClass, PseudoElement, ServoSelectorImpl};
+use style::selector_impl::{NonTSPseudoClass, PseudoElement, RestyleDamage, ServoSelectorImpl, Snapshot};
 use style::selector_matching::ApplicableDeclarationBlock;
 use style::sink::Push;
 use style::str::is_whitespace;
 use url::Url;
 
 #[derive(Copy, Clone)]
 pub struct ServoLayoutNode<'a> {
     /// The wrapped node.
@@ -377,17 +376,17 @@ impl<'ld> TDocument for ServoLayoutDocum
     fn as_node(&self) -> ServoLayoutNode<'ld> {
         ServoLayoutNode::from_layout_js(self.document.upcast())
     }
 
     fn root_node(&self) -> Option<ServoLayoutNode<'ld>> {
         self.as_node().children().find(ServoLayoutNode::is_element)
     }
 
-    fn drain_modified_elements(&self) -> Vec<(ServoLayoutElement<'ld>, ElementSnapshot)> {
+    fn drain_modified_elements(&self) -> Vec<(ServoLayoutElement<'ld>, Snapshot)> {
         let elements =  unsafe { self.document.drain_modified_elements() };
         elements.into_iter().map(|(el, snapshot)| (ServoLayoutElement::from_layout_js(el), snapshot)).collect()
     }
 
     fn needs_paint_from_layout(&self) {
         unsafe { self.document.needs_paint_from_layout(); }
     }
 
@@ -430,17 +429,16 @@ impl<'le> PresentationalHintsSynthetizer
             self.element.synthesize_presentational_hints_for_legacy_attributes(hints);
         }
     }
 }
 
 impl<'le> TElement for ServoLayoutElement<'le> {
     type ConcreteNode = ServoLayoutNode<'le>;
     type ConcreteDocument = ServoLayoutDocument<'le>;
-    type ConcreteRestyleDamage = RestyleDamage;
 
     fn as_node(&self) -> ServoLayoutNode<'le> {
         ServoLayoutNode::from_layout_js(self.element.upcast())
     }
 
     fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>> {
         unsafe {
             (*self.element.style_attribute()).as_ref()
--- a/servo/components/script_layout_interface/lib.rs
+++ b/servo/components/script_layout_interface/lib.rs
@@ -36,28 +36,27 @@ extern crate range;
 extern crate script_traits;
 extern crate selectors;
 #[macro_use] extern crate servo_atoms;
 extern crate style;
 extern crate url;
 
 pub mod message;
 pub mod reporter;
-pub mod restyle_damage;
 pub mod rpc;
 pub mod wrapper_traits;
 
 use canvas_traits::CanvasMsg;
 use core::nonzero::NonZero;
 use ipc_channel::ipc::IpcSender;
 use libc::c_void;
-use restyle_damage::RestyleDamage;
 use std::sync::atomic::AtomicIsize;
 use style::atomic_refcell::AtomicRefCell;
 use style::data::ElementData;
+use style::selector_impl::RestyleDamage;
 
 pub struct PartialPersistentLayoutData {
     /// Data that the style system associates with a node. When the
     /// style system is being used standalone, this is all that hangs
     /// off the node. This must be first to permit the various
     /// transmutations between ElementData and PersistentLayoutData.
     pub style_data: ElementData,
 
--- a/servo/components/script_layout_interface/wrapper_traits.rs
+++ b/servo/components/script_layout_interface/wrapper_traits.rs
@@ -7,27 +7,26 @@
 use HTMLCanvasData;
 use LayoutNodeType;
 use OpaqueStyleAndLayoutData;
 use SVGSVGData;
 use gfx_traits::ByteIndex;
 use html5ever_atoms::{Namespace, LocalName};
 use msg::constellation_msg::PipelineId;
 use range::Range;
-use restyle_damage::RestyleDamage;
 use std::fmt::Debug;
 use std::sync::Arc;
 use style::atomic_refcell::AtomicRefCell;
 use style::computed_values::display;
 use style::context::SharedStyleContext;
 use style::data::ElementData;
 use style::dom::{LayoutIterator, NodeInfo, PresentationalHintsSynthetizer, TElement, TNode};
 use style::dom::OpaqueNode;
 use style::properties::ServoComputedValues;
-use style::selector_impl::{PseudoElement, PseudoElementCascadeType, ServoSelectorImpl};
+use style::selector_impl::{PseudoElement, PseudoElementCascadeType, RestyleDamage, ServoSelectorImpl};
 use url::Url;
 
 #[derive(Copy, PartialEq, Clone, Debug)]
 pub enum PseudoElementType<T> {
     Normal,
     Before(T),
     After(T),
     DetailsSummary(T),
--- a/servo/components/style/dom.rs
+++ b/servo/components/style/dom.rs
@@ -9,17 +9,17 @@
 use {Atom, Namespace, LocalName};
 use atomic_refcell::{AtomicRef, AtomicRefCell};
 use data::{ElementStyles, ElementData};
 use element_state::ElementState;
 use parking_lot::RwLock;
 use properties::{ComputedValues, PropertyDeclarationBlock};
 use properties::longhands::display::computed_value as display;
 use restyle_hints::{RESTYLE_DESCENDANTS, RESTYLE_LATER_SIBLINGS, RESTYLE_SELF, RestyleHint};
-use selector_impl::{ElementExt, PseudoElement};
+use selector_impl::{ElementExt, PseudoElement, RestyleDamage, Snapshot};
 use selector_matching::ApplicableDeclarationBlock;
 use sink::Push;
 use std::fmt::Debug;
 use std::ops::BitOr;
 use std::sync::Arc;
 use traversal::DomTraversalContext;
 use util::opts;
 
@@ -154,52 +154,50 @@ pub trait TNode : Sized + Copy + Clone +
 pub trait TDocument : Sized + Copy + Clone {
     type ConcreteNode: TNode<ConcreteElement = Self::ConcreteElement, ConcreteDocument = Self>;
     type ConcreteElement: TElement<ConcreteNode = Self::ConcreteNode, ConcreteDocument = Self>;
 
     fn as_node(&self) -> Self::ConcreteNode;
 
     fn root_node(&self) -> Option<Self::ConcreteNode>;
 
-    fn drain_modified_elements(&self) -> Vec<(Self::ConcreteElement,
-                                              <Self::ConcreteElement as ElementExt>::Snapshot)>;
+    fn drain_modified_elements(&self) -> Vec<(Self::ConcreteElement, Snapshot)>;
 
     fn needs_paint_from_layout(&self);
     fn will_paint(&self);
 }
 
 pub trait PresentationalHintsSynthetizer {
     fn synthesize_presentational_hints_for_legacy_attributes<V>(&self, hints: &mut V)
         where V: Push<ApplicableDeclarationBlock>;
 }
 
 pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + PresentationalHintsSynthetizer {
     type ConcreteNode: TNode<ConcreteElement = Self, ConcreteDocument = Self::ConcreteDocument>;
     type ConcreteDocument: TDocument<ConcreteNode = Self::ConcreteNode, ConcreteElement = Self>;
-    type ConcreteRestyleDamage: TRestyleDamage;
 
     fn as_node(&self) -> Self::ConcreteNode;
 
     fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>>;
 
     fn get_state(&self) -> ElementState;
 
     fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool;
     fn attr_equals(&self, namespace: &Namespace, attr: &LocalName, value: &Atom) -> bool;
 
     /// Set the restyle damage field.
-    fn set_restyle_damage(self, damage: Self::ConcreteRestyleDamage);
+    fn set_restyle_damage(self, damage: RestyleDamage);
 
     /// XXX: It's a bit unfortunate we need to pass the current computed values
     /// as an argument here, but otherwise Servo would crash due to double
     /// borrows to return it.
     fn existing_style_for_restyle_damage<'a>(&'a self,
                                              current_computed_values: Option<&'a Arc<ComputedValues>>,
                                              pseudo: Option<&PseudoElement>)
-        -> Option<&'a <Self::ConcreteRestyleDamage as TRestyleDamage>::PreExistingComputedValues>;
+        -> Option<&'a <RestyleDamage as TRestyleDamage>::PreExistingComputedValues>;
 
     /// The concept of a dirty bit doesn't exist in our new restyle algorithm.
     /// Instead, we associate restyle and change hints with nodes. However, we
     /// continue to allow the dirty bit to trigger unconditional restyles while
     /// we transition both Servo and Stylo to the new architecture.
     fn deprecated_dirty_bit_is_set(&self) -> bool;
 
     fn has_dirty_descendants(&self) -> bool;
--- a/servo/components/style/gecko/mod.rs
+++ b/servo/components/style/gecko/mod.rs
@@ -1,15 +1,16 @@
 /* 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/. */
 
 
 pub mod context;
 pub mod data;
+pub mod restyle_damage;
 pub mod snapshot;
 pub mod snapshot_helpers;
 pub mod traversal;
 pub mod wrapper;
 
 pub mod conversions;
 pub mod selector_impl;
 pub mod values;
new file mode 100644
--- /dev/null
+++ b/servo/components/style/gecko/restyle_damage.rs
@@ -0,0 +1,53 @@
+/* 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 dom::TRestyleDamage;
+use gecko_bindings::bindings;
+use gecko_bindings::structs::{nsChangeHint, nsStyleContext};
+use gecko_bindings::sugar::ownership::FFIArcHelpers;
+use properties::ComputedValues;
+use std::ops::BitOr;
+use std::sync::Arc;
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+pub struct GeckoRestyleDamage(nsChangeHint);
+
+impl GeckoRestyleDamage {
+    pub fn as_change_hint(&self) -> nsChangeHint {
+        self.0
+    }
+}
+
+impl TRestyleDamage for GeckoRestyleDamage {
+    type PreExistingComputedValues = nsStyleContext;
+
+    fn empty() -> Self {
+        use std::mem;
+        GeckoRestyleDamage(unsafe { mem::transmute(0u32) })
+    }
+
+    fn compute(source: &nsStyleContext,
+               new_style: &Arc<ComputedValues>) -> Self {
+        let context = source as *const nsStyleContext as *mut nsStyleContext;
+        let hint = unsafe {
+            bindings::Gecko_CalcStyleDifference(context,
+                                                new_style.as_borrowed_opt().unwrap())
+        };
+        GeckoRestyleDamage(hint)
+    }
+
+    fn rebuild_and_reflow() -> Self {
+        GeckoRestyleDamage(nsChangeHint::nsChangeHint_ReconstructFrame)
+    }
+}
+
+impl BitOr for GeckoRestyleDamage {
+    type Output = Self;
+
+    fn bitor(self, other: Self) -> Self {
+        use std::mem;
+        GeckoRestyleDamage(unsafe { mem::transmute(self.0 as u32 | other.0 as u32) })
+    }
+}
+
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -2,51 +2,50 @@
  * 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/. */
 
 #![allow(unsafe_code)]
 
 
 use atomic_refcell::{AtomicRef, AtomicRefCell};
 use data::ElementData;
-use dom::{LayoutIterator, NodeInfo, TDocument, TElement, TNode, TRestyleDamage, UnsafeNode};
+use dom::{LayoutIterator, NodeInfo, TDocument, TElement, TNode, UnsafeNode};
 use dom::{OpaqueNode, PresentationalHintsSynthetizer};
 use element_state::ElementState;
 use error_reporting::StdoutErrorReporter;
+use gecko::restyle_damage::GeckoRestyleDamage;
 use gecko::selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PseudoElement};
 use gecko::snapshot::GeckoElementSnapshot;
 use gecko::snapshot_helpers;
 use gecko_bindings::bindings;
-use gecko_bindings::bindings::{Gecko_CalcStyleDifference, Gecko_StoreStyleDifference};
 use gecko_bindings::bindings::{Gecko_DropStyleChildrenIterator, Gecko_MaybeCreateStyleChildrenIterator};
 use gecko_bindings::bindings::{Gecko_ElementState, Gecko_GetDocumentElement};
 use gecko_bindings::bindings::{Gecko_GetLastChild, Gecko_GetNextStyleChild};
 use gecko_bindings::bindings::{Gecko_GetServoDeclarationBlock, Gecko_IsHTMLElementInHTMLDocument};
 use gecko_bindings::bindings::{Gecko_IsLink, Gecko_IsRootElement};
 use gecko_bindings::bindings::{Gecko_IsUnvisitedLink, Gecko_IsVisitedLink, Gecko_Namespace};
 use gecko_bindings::bindings::{RawGeckoDocument, RawGeckoElement, RawGeckoNode};
 use gecko_bindings::bindings::Gecko_ClassOrClassList;
 use gecko_bindings::bindings::Gecko_GetStyleContext;
 use gecko_bindings::bindings::Gecko_SetNodeFlags;
+use gecko_bindings::bindings::Gecko_StoreStyleDifference;
 use gecko_bindings::structs;
 use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
-use gecko_bindings::structs::{nsChangeHint, nsIAtom, nsIContent, nsStyleContext};
-use gecko_bindings::sugar::ownership::FFIArcHelpers;
+use gecko_bindings::structs::{nsIAtom, nsIContent, nsStyleContext};
 use libc::uintptr_t;
 use parking_lot::RwLock;
 use parser::ParserContextExtraData;
 use properties::{ComputedValues, parse_style_attribute};
 use properties::PropertyDeclarationBlock;
 use selector_impl::ElementExt;
 use selector_matching::ApplicableDeclarationBlock;
 use selectors::Element;
 use selectors::parser::{AttrSelector, NamespaceConstraint};
 use sink::Push;
 use std::fmt;
-use std::ops::BitOr;
 use std::ptr;
 use std::sync::Arc;
 use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
 use url::Url;
 
 // Important: We don't currently refcount the DOM, because the wrapper lifetime
 // magic guarantees that our LayoutFoo references won't outlive the root, and
 // we don't mutate any of the references on the Gecko side during restyle. We
@@ -61,49 +60,16 @@ impl<'ln> GeckoNode<'ln> {
     }
 
     fn node_info(&self) -> &structs::NodeInfo {
         debug_assert!(!self.0.mNodeInfo.mRawPtr.is_null());
         unsafe { &*self.0.mNodeInfo.mRawPtr }
     }
 }
 
-#[derive(Clone, Copy, Debug, PartialEq)]
-pub struct GeckoRestyleDamage(nsChangeHint);
-
-impl TRestyleDamage for GeckoRestyleDamage {
-    type PreExistingComputedValues = nsStyleContext;
-
-    fn empty() -> Self {
-        use std::mem;
-        GeckoRestyleDamage(unsafe { mem::transmute(0u32) })
-    }
-
-    fn compute(source: &nsStyleContext,
-               new_style: &Arc<ComputedValues>) -> Self {
-        let context = source as *const nsStyleContext as *mut nsStyleContext;
-        let hint = unsafe { Gecko_CalcStyleDifference(context, new_style.as_borrowed_opt().unwrap()) };
-        GeckoRestyleDamage(hint)
-    }
-
-    fn rebuild_and_reflow() -> Self {
-        GeckoRestyleDamage(nsChangeHint::nsChangeHint_ReconstructFrame)
-    }
-}
-
-impl BitOr for GeckoRestyleDamage {
-    type Output = Self;
-
-    fn bitor(self, other: Self) -> Self {
-        use std::mem;
-        GeckoRestyleDamage(unsafe { mem::transmute(self.0 as u32 | other.0 as u32) })
-    }
-}
-
-
 impl<'ln> NodeInfo for GeckoNode<'ln> {
     fn is_element(&self) -> bool {
         use gecko_bindings::structs::nsINode_BooleanFlag;
         self.0.mBoolFlags & (1u32 << nsINode_BooleanFlag::NodeIsElement as u32) != 0
     }
 
     fn is_text_node(&self) -> bool {
         // This is a DOM constant that isn't going to change.
@@ -353,17 +319,16 @@ lazy_static! {
     pub static ref DUMMY_BASE_URL: Url = {
         Url::parse("http://www.example.org").unwrap()
     };
 }
 
 impl<'le> TElement for GeckoElement<'le> {
     type ConcreteNode = GeckoNode<'le>;
     type ConcreteDocument = GeckoDocument<'le>;
-    type ConcreteRestyleDamage = GeckoRestyleDamage;
 
     fn as_node(&self) -> Self::ConcreteNode {
         unsafe { GeckoNode(&*(self.0 as *const _ as *const RawGeckoNode)) }
     }
 
     fn style_attribute(&self) -> Option<&Arc<RwLock<PropertyDeclarationBlock>>> {
         let declarations = unsafe { Gecko_GetServoDeclarationBlock(self.0) };
         declarations.map(|s| s.as_arc_opt()).unwrap_or(None)
@@ -395,17 +360,17 @@ impl<'le> TElement for GeckoElement<'le>
         }
     }
 
     fn set_restyle_damage(self, damage: GeckoRestyleDamage) {
         // FIXME(bholley): Gecko currently relies on the dirty bit being set to
         // drive the post-traversal. This will go away soon.
         unsafe { self.set_flags(NODE_IS_DIRTY_FOR_SERVO as u32) }
 
-        unsafe { Gecko_StoreStyleDifference(self.as_node().0, damage.0) }
+        unsafe { Gecko_StoreStyleDifference(self.as_node().0, damage.as_change_hint()) }
     }
 
     fn existing_style_for_restyle_damage<'a>(&'a self,
                                              current_cv: Option<&'a Arc<ComputedValues>>,
                                              pseudo: Option<&PseudoElement>)
                                              -> Option<&'a nsStyleContext> {
         if current_cv.is_none() {
             // Don't bother in doing an ffi call to get null back.
@@ -686,15 +651,13 @@ impl<'le> ::selectors::MatchAttr for Gec
                                           attr.ns_or_null(),
                                           attr.select_name(self.is_html_element_in_html_document()),
                                           value.as_ptr())
         }
     }
 }
 
 impl<'le> ElementExt for GeckoElement<'le> {
-    type Snapshot = GeckoElementSnapshot;
-
     #[inline]
     fn is_link(&self) -> bool {
         self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)
     }
 }
--- a/servo/components/style/lib.rs
+++ b/servo/components/style/lib.rs
@@ -112,18 +112,18 @@ pub mod media_queries;
 pub mod owning_handle;
 pub mod parallel;
 pub mod parser;
 pub mod refcell;
 pub mod restyle_hints;
 pub mod rule_tree;
 pub mod selector_impl;
 pub mod selector_matching;
+#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod servo;
 pub mod sequential;
-#[cfg(feature = "servo")] pub mod servo_selector_impl;
 pub mod sink;
 pub mod str;
 pub mod stylesheets;
 pub mod thread_state;
 mod tid;
 pub mod timer;
 pub mod traversal;
 #[macro_use]
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -12,17 +12,17 @@ use atomic_refcell::AtomicRefMut;
 use cache::LRUCache;
 use cascade_info::CascadeInfo;
 use context::{SharedStyleContext, StyleContext};
 use data::{ElementData, ElementStyles, PseudoStyles};
 use dom::{TElement, TNode, TRestyleDamage, UnsafeNode};
 use properties::{CascadeFlags, ComputedValues, SHAREABLE, cascade};
 use properties::longhands::display::computed_value as display;
 use rule_tree::StrongRuleNode;
-use selector_impl::{TheSelectorImpl, PseudoElement};
+use selector_impl::{PseudoElement, RestyleDamage, TheSelectorImpl};
 use selector_matching::{ApplicableDeclarationBlock, Stylist};
 use selectors::MatchAttr;
 use selectors::bloom::BloomFilter;
 use selectors::matching::{AFFECTED_BY_PSEUDO_ELEMENTS, MatchingReason, StyleRelations};
 use sink::ForgetfulSink;
 use std::collections::HashMap;
 use std::hash::BuildHasherDefault;
 use std::mem;
@@ -368,24 +368,24 @@ impl StyleSharingCandidateCache {
     }
 
     pub fn clear(&mut self) {
         self.cache.evict_all()
     }
 }
 
 /// The results of attempting to share a style.
-pub enum StyleSharingResult<ConcreteRestyleDamage: TRestyleDamage> {
+pub enum StyleSharingResult {
     /// We didn't find anybody to share the style with.
     CannotShare,
     /// The node's style can be shared. The integer specifies the index in the
     /// LRU cache that was hit and the damage that was done, and the restyle
     /// result the original result of the candidate's styling, that is, whether
     /// it should stop the traversal or not.
-    StyleWasShared(usize, ConcreteRestyleDamage),
+    StyleWasShared(usize, RestyleDamage),
 }
 
 // Callers need to pass several boolean flags to cascade_node_pseudo_element.
 // We encapsulate them in this struct to avoid mixing them up.
 //
 // FIXME(pcwalton): Unify with `CascadeFlags`, perhaps?
 struct CascadeBooleans {
     shareable: bool,
@@ -560,17 +560,17 @@ pub trait MatchMethods : TElement {
     /// Attempts to share a style with another node. This method is unsafe because it depends on
     /// the `style_sharing_candidate_cache` having only live nodes in it, and we have no way to
     /// guarantee that at the type system level yet.
     unsafe fn share_style_if_possible(&self,
                                       style_sharing_candidate_cache:
                                         &mut StyleSharingCandidateCache,
                                       shared_context: &SharedStyleContext,
                                       data: &mut AtomicRefMut<ElementData>)
-                                      -> StyleSharingResult<Self::ConcreteRestyleDamage> {
+                                      -> StyleSharingResult {
         if opts::get().disable_share_style_cache {
             return StyleSharingResult::CannotShare
         }
 
         if self.style_attribute().is_some() {
             return StyleSharingResult::CannotShare
         }
 
@@ -586,22 +586,18 @@ pub trait MatchMethods : TElement {
                     // Yay, cache hit. Share the style.
 
                     // TODO: add the display: none optimisation here too! Even
                     // better, factor it out/make it a bit more generic so Gecko
                     // can decide more easily if it knows that it's a child of
                     // replaced content, or similar stuff!
                     let damage =
                         match self.existing_style_for_restyle_damage(data.previous_styles().map(|x| &x.primary), None) {
-                            Some(ref source) => {
-                                Self::ConcreteRestyleDamage::compute(source, &shared_style)
-                            }
-                            None => {
-                                Self::ConcreteRestyleDamage::rebuild_and_reflow()
-                            }
+                            Some(ref source) => RestyleDamage::compute(source, &shared_style),
+                            None => RestyleDamage::rebuild_and_reflow(),
                         };
 
                     data.finish_styling(ElementStyles::new(shared_style, rule_node));
 
                     return StyleSharingResult::StyleWasShared(i, damage)
                 }
                 Err(miss) => {
                     debug!("Cache miss: {:?}", miss);
@@ -673,23 +669,20 @@ pub trait MatchMethods : TElement {
         // TODO: case-sensitivity depends on the document type and quirks mode
         self.each_class(|class| bf.remove(class));
     }
 
     fn compute_restyle_damage(&self,
                               old_style: Option<&Arc<ComputedValues>>,
                               new_style: &Arc<ComputedValues>,
                               pseudo: Option<&PseudoElement>)
-                              -> Self::ConcreteRestyleDamage
+                              -> RestyleDamage
     {
         match self.existing_style_for_restyle_damage(old_style, pseudo) {
-            Some(ref source) => {
-                Self::ConcreteRestyleDamage::compute(source,
-                                                     new_style)
-            }
+            Some(ref source) => RestyleDamage::compute(source, new_style),
             None => {
                 // If there's no style source, two things can happen:
                 //
                 //  1. This is not an incremental restyle (old_style is none).
                 //     In this case we can't do too much than sending
                 //     rebuild_and_reflow.
                 //
                 //  2. This is an incremental restyle, but the old display value
@@ -705,17 +698,17 @@ pub trait MatchMethods : TElement {
                 //
                 // Unfortunately we can't strongly assert part of this, since
                 // we style some nodes that in Gecko never generate a frame,
                 // like children of replaced content. Arguably, we shouldn't be
                 // styling those here, but until we implement that we'll have to
                 // stick without the assertions.
                 debug_assert!(pseudo.is_none() ||
                               new_style.get_box().clone_display() != display::T::none);
-                Self::ConcreteRestyleDamage::rebuild_and_reflow()
+                RestyleDamage::rebuild_and_reflow()
             }
         }
     }
 
     unsafe fn cascade_node<'a, Ctx>(&self,
                                     context: &Ctx,
                                     mut data: AtomicRefMut<ElementData>,
                                     parent: Option<Self>,
@@ -778,36 +771,36 @@ pub trait MatchMethods : TElement {
 
     fn compute_damage_and_cascade_pseudos<'a, Ctx>(&self,
                                                    old_primary: Option<&Arc<ComputedValues>>,
                                                    mut old_pseudos: Option<&mut PseudoStyles>,
                                                    new_primary: &Arc<ComputedValues>,
                                                    new_pseudos: &mut PseudoStyles,
                                                    context: &Ctx,
                                                    applicable_declarations: &mut ApplicableDeclarations)
-                                                   -> Self::ConcreteRestyleDamage
+                                                   -> RestyleDamage
         where Ctx: StyleContext<'a>
     {
         // Here we optimise the case of the style changing but both the
         // previous and the new styles having display: none. In this
         // case, we can always optimize the traversal, regardless of the
         // restyle hint.
         let this_display = new_primary.get_box().clone_display();
         if this_display == display::T::none {
             let old_display = old_primary.map(|old| {
                 old.get_box().clone_display()
             });
 
             // If display passed from none to something, then we need to reflow,
             // otherwise, we don't do anything.
             let damage = match old_display {
                 Some(display) if display == this_display => {
-                    Self::ConcreteRestyleDamage::empty()
+                    RestyleDamage::empty()
                 }
-                _ => Self::ConcreteRestyleDamage::rebuild_and_reflow()
+                _ => RestyleDamage::rebuild_and_reflow()
             };
 
             debug!("Short-circuiting traversal: {:?} {:?} {:?}",
                    this_display, old_display, damage);
 
             return damage
         }
 
@@ -815,18 +808,17 @@ pub trait MatchMethods : TElement {
         let mut damage =
             self.compute_restyle_damage(old_primary, new_primary, None);
 
         // If the new style is display:none, we don't need pseudo-elements styles.
         if new_primary.get_box().clone_display() == display::T::none {
             return damage;
         }
 
-        let rebuild_and_reflow =
-            Self::ConcreteRestyleDamage::rebuild_and_reflow();
+        let rebuild_and_reflow = RestyleDamage::rebuild_and_reflow();
 
         debug_assert!(new_pseudos.is_empty());
         <Self as MatchAttr>::Impl::each_eagerly_cascaded_pseudo_element(|pseudo| {
             let mut applicable_declarations_for_this_pseudo =
                 applicable_declarations.per_pseudo.get_mut(&pseudo).unwrap();
 
             let has_declarations =
                 !applicable_declarations_for_this_pseudo.is_empty();
--- a/servo/components/style/restyle_hints.rs
+++ b/servo/components/style/restyle_hints.rs
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 //! Restyle hints: an optimization to avoid unnecessarily matching selectors.
 
 use Atom;
 use element_state::*;
 #[cfg(feature = "servo")]
 use heapsize::HeapSizeOf;
-use selector_impl::{AttrValue, ElementExt, NonTSPseudoClass, TheSelectorImpl};
+use selector_impl::{AttrValue, ElementExt, NonTSPseudoClass, Snapshot, TheSelectorImpl};
 use selectors::{Element, MatchAttr};
 use selectors::matching::{MatchingReason, StyleRelations};
 use selectors::matching::matches_complex_selector;
 use selectors::parser::{AttrSelector, Combinator, ComplexSelector, SelectorImpl, SimpleSelector};
 use std::clone::Clone;
 use std::sync::Arc;
 
 /// When the ElementState of an element (like IN_HOVER_STATE) changes, certain
@@ -80,27 +80,27 @@ pub trait ElementSnapshot : Sized + Matc
     fn each_class<F>(&self, F)
         where F: FnMut(&Atom);
 }
 
 struct ElementWrapper<'a, E>
     where E: ElementExt
 {
     element: E,
-    snapshot: Option<&'a E::Snapshot>,
+    snapshot: Option<&'a Snapshot>,
 }
 
 impl<'a, E> ElementWrapper<'a, E>
     where E: ElementExt
 {
     pub fn new(el: E) -> ElementWrapper<'a, E> {
         ElementWrapper { element: el, snapshot: None }
     }
 
-    pub fn new_with_snapshot(el: E, snapshot: &'a E::Snapshot) -> ElementWrapper<'a, E> {
+    pub fn new_with_snapshot(el: E, snapshot: &'a Snapshot) -> ElementWrapper<'a, E> {
         ElementWrapper { element: el, snapshot: Some(snapshot) }
     }
 }
 
 impl<'a, E> MatchAttr for ElementWrapper<'a, E>
     where E: ElementExt,
 {
     type Impl = TheSelectorImpl;
@@ -419,17 +419,17 @@ impl DependencySet {
 
     pub fn clear(&mut self) {
         self.common_deps.clear();
         self.attr_deps.clear();
         self.state_deps.clear();
     }
 
     pub fn compute_hint<E>(&self, el: &E,
-                           snapshot: &E::Snapshot,
+                           snapshot: &Snapshot,
                            current_state: ElementState)
                            -> RestyleHint
         where E: ElementExt + Clone
     {
         debug!("About to calculate restyle hint for element. Deps: {}",
                self.len());
 
         let state_changes = snapshot.state()
--- a/servo/components/style/selector_impl.rs
+++ b/servo/components/style/selector_impl.rs
@@ -1,32 +1,43 @@
 /* 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/. */
 
 //! The pseudo-classes and pseudo-elements supported by the style system.
 
 use matching::{common_style_affecting_attributes, CommonStyleAffectingAttributeMode};
-use restyle_hints;
 use selectors::Element;
 use selectors::parser::{AttrSelector, SelectorImpl};
 
 pub type AttrValue = <TheSelectorImpl as SelectorImpl>::AttrValue;
 
 #[cfg(feature = "servo")]
-pub use servo_selector_impl::*;
-
-#[cfg(feature = "servo")]
-pub use servo_selector_impl::{ServoSelectorImpl as TheSelectorImpl, ServoElementSnapshot as ElementSnapshot};
+pub use servo::selector_impl::*;
 
 #[cfg(feature = "gecko")]
 pub use gecko::selector_impl::*;
 
+#[cfg(feature = "servo")]
+pub use servo::selector_impl::ServoSelectorImpl as TheSelectorImpl;
+
 #[cfg(feature = "gecko")]
-pub use gecko::selector_impl::{GeckoSelectorImpl as TheSelectorImpl};
+pub use gecko::selector_impl::GeckoSelectorImpl as TheSelectorImpl;
+
+#[cfg(feature = "servo")]
+pub use servo::selector_impl::ServoElementSnapshot as Snapshot;
+
+#[cfg(feature = "gecko")]
+pub use gecko::snapshot::GeckoElementSnapshot as Snapshot;
+
+#[cfg(feature = "servo")]
+pub use servo::restyle_damage::ServoRestyleDamage as RestyleDamage;
+
+#[cfg(feature = "gecko")]
+pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage;
 
 /// This function determines if a pseudo-element is eagerly cascaded or not.
 ///
 /// Eagerly cascaded pseudo-elements are "normal" pseudo-elements (i.e.
 /// `::before` and `::after`). They inherit styles normally as another
 /// selector would do, and they're part of the cascade.
 ///
 /// Lazy pseudo-elements are affected by selector matching, but they're only
@@ -66,18 +77,16 @@ impl PseudoElementCascadeType {
 
     #[inline]
     pub fn is_precomputed(&self) -> bool {
         *self == PseudoElementCascadeType::Precomputed
     }
 }
 
 pub trait ElementExt: Element<Impl=TheSelectorImpl> {
-    type Snapshot: restyle_hints::ElementSnapshot + 'static;
-
     fn is_link(&self) -> bool;
 }
 
 impl TheSelectorImpl {
     #[inline]
     pub fn each_eagerly_cascaded_pseudo_element<F>(mut fun: F)
         where F: FnMut(PseudoElement)
     {
--- a/servo/components/style/selector_matching.rs
+++ b/servo/components/style/selector_matching.rs
@@ -11,17 +11,17 @@ use error_reporting::StdoutErrorReporter
 use keyframes::KeyframesAnimation;
 use media_queries::{Device, MediaType};
 use parking_lot::RwLock;
 use properties::{self, CascadeFlags, ComputedValues, INHERIT_ALL, Importance};
 use properties::{PropertyDeclaration, PropertyDeclarationBlock};
 use quickersort::sort_by;
 use restyle_hints::{RestyleHint, DependencySet};
 use rule_tree::{RuleTree, StrongRuleNode, StyleSource};
-use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement};
+use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement, Snapshot};
 use selectors::Element;
 use selectors::bloom::BloomFilter;
 use selectors::matching::{AFFECTED_BY_STYLE_ATTRIBUTE, AFFECTED_BY_PRESENTATIONAL_HINTS};
 use selectors::matching::{MatchingReason, StyleRelations, matches_complex_selector};
 use selectors::parser::{Selector, SimpleSelector, LocalName as LocalNameSelector, ComplexSelector};
 use sink::Push;
 use smallvec::VecLike;
 use std::borrow::Borrow;
@@ -606,17 +606,17 @@ impl Stylist {
                 return false;
             }
         }
 
         true
     }
 
     pub fn compute_restyle_hint<E>(&self, element: &E,
-                                   snapshot: &E::Snapshot,
+                                   snapshot: &Snapshot,
                                    // NB: We need to pass current_state as an argument because
                                    // selectors::Element doesn't provide access to ElementState
                                    // directly, and computing it from the ElementState would be
                                    // more expensive than getting it directly from the caller.
                                    current_state: ElementState)
                                    -> RestyleHint
         where E: ElementExt + Clone
     {
copy from servo/resources/shaders/debug_color.fs.glsl
copy to servo/components/style/servo/mod.rs
--- a/servo/resources/shaders/debug_color.fs.glsl
+++ b/servo/components/style/servo/mod.rs
@@ -1,8 +1,6 @@
 /* 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/. */
 
-void main(void)
-{
-    oFragColor = vColor;
-}
+pub mod restyle_damage;
+pub mod selector_impl;
rename from servo/components/script_layout_interface/restyle_damage.rs
rename to servo/components/style/servo/restyle_damage.rs
--- a/servo/components/script_layout_interface/restyle_damage.rs
+++ b/servo/components/style/servo/restyle_damage.rs
@@ -1,21 +1,21 @@
 /* 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 computed_values::display;
+use dom::TRestyleDamage;
+use properties::ServoComputedValues;
 use std::fmt;
 use std::sync::Arc;
-use style::computed_values::display;
-use style::dom::TRestyleDamage;
-use style::properties::ServoComputedValues;
 
 bitflags! {
     #[doc = "Individual layout actions that may be necessary after restyling."]
-    pub flags RestyleDamage: u8 {
+    pub flags ServoRestyleDamage: u8 {
         #[doc = "Repaint the node itself."]
         #[doc = "Currently unused; need to decide how this propagates."]
         const REPAINT = 0x01,
 
         #[doc = "The stacking-context-relative position of this node or its descendants has \
                  changed."]
         #[doc = "Propagates both up and down the flow tree."]
         const REPOSITION = 0x02,
@@ -43,60 +43,60 @@ bitflags! {
                  Propagates up the flow tree because the computation is inorder."]
         const RESOLVE_GENERATED_CONTENT = 0x40,
 
         #[doc = "The entire flow needs to be reconstructed."]
         const RECONSTRUCT_FLOW = 0x80
     }
 }
 
-impl TRestyleDamage for RestyleDamage {
+impl TRestyleDamage for ServoRestyleDamage {
     /// For Servo the style source is always the computed values.
     type PreExistingComputedValues = Arc<ServoComputedValues>;
 
     fn empty() -> Self {
-        RestyleDamage::empty()
+        ServoRestyleDamage::empty()
     }
 
     fn compute(old: &Arc<ServoComputedValues>,
-               new: &Arc<ServoComputedValues>) -> RestyleDamage {
+               new: &Arc<ServoComputedValues>) -> ServoRestyleDamage {
         compute_damage(old, new)
     }
 
     /// Returns a bitmask that represents a flow that needs to be rebuilt and
     /// reflowed.
     ///
-    /// Use this instead of `RestyleDamage::all()` because
-    /// `RestyleDamage::all()` will result in unnecessary sequential resolution
+    /// Use this instead of `ServoRestyleDamage::all()` because
+    /// `ServoRestyleDamage::all()` will result in unnecessary sequential resolution
     /// of generated content.
-    fn rebuild_and_reflow() -> RestyleDamage {
+    fn rebuild_and_reflow() -> ServoRestyleDamage {
         REPAINT | REPOSITION | STORE_OVERFLOW | BUBBLE_ISIZES | REFLOW_OUT_OF_FLOW | REFLOW |
             RECONSTRUCT_FLOW
     }
 }
 
-impl RestyleDamage {
+impl ServoRestyleDamage {
     /// Supposing a flow has the given `position` property and this damage,
     /// returns the damage that we should add to the *parent* of this flow.
-    pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> RestyleDamage {
+    pub fn damage_for_parent(self, child_is_absolutely_positioned: bool) -> ServoRestyleDamage {
         if child_is_absolutely_positioned {
             self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW_OUT_OF_FLOW |
                     RESOLVE_GENERATED_CONTENT)
         } else {
             self & (REPAINT | REPOSITION | STORE_OVERFLOW | REFLOW | REFLOW_OUT_OF_FLOW |
                     RESOLVE_GENERATED_CONTENT)
         }
     }
 
     /// Supposing the *parent* of a flow with the given `position` property has this damage,
     /// returns the damage that we should add to this flow.
     pub fn damage_for_child(self,
                             parent_is_absolutely_positioned: bool,
                             child_is_absolutely_positioned: bool)
-                            -> RestyleDamage {
+                            -> ServoRestyleDamage {
         match (parent_is_absolutely_positioned, child_is_absolutely_positioned) {
             (false, true) => {
                 // Absolute children are out-of-flow and therefore insulated from changes.
                 //
                 // FIXME(pcwalton): Au contraire, if the containing block dimensions change!
                 self & (REPAINT | REPOSITION)
             }
             (true, false) => {
@@ -111,17 +111,17 @@ impl RestyleDamage {
             _ => {
                 // TODO(pcwalton): Take floatedness into account.
                 self & (REPAINT | REPOSITION | REFLOW)
             }
         }
     }
 }
 
-impl fmt::Display for RestyleDamage {
+impl fmt::Display for ServoRestyleDamage {
     fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
         let mut first_elem = true;
 
         let to_iter =
             [ (REPAINT, "Repaint")
             , (REPOSITION, "Reposition")
             , (STORE_OVERFLOW, "StoreOverflow")
             , (BUBBLE_ISIZES, "BubbleISizes")
@@ -157,18 +157,18 @@ macro_rules! add_if_not_equal(
             $damage.insert($($effect)|*);
             true
         } else {
             false
         }
     })
 );
 
-fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> RestyleDamage {
-    let mut damage = RestyleDamage::empty();
+fn compute_damage(old: &ServoComputedValues, new: &ServoComputedValues) -> ServoRestyleDamage {
+    let mut damage = ServoRestyleDamage::empty();
 
     // This should check every CSS property, as enumerated in the fields of
     // http://doc.servo.org/style/properties/struct.ServoComputedValues.html
 
     // FIXME: Test somehow that every property is included.
 
     add_if_not_equal!(old, new, damage,
                       [REPAINT, REPOSITION, STORE_OVERFLOW, BUBBLE_ISIZES, REFLOW_OUT_OF_FLOW,
@@ -255,13 +255,13 @@ fn compute_damage(old: &ServoComputedVal
 
         // Note: May require REFLOW et al. if `visibility: collapse` is implemented.
         get_inheritedbox.visibility
     ]);
 
     // If the layer requirements of this flow have changed due to the value
     // of the transform, then reflow is required to rebuild the layers.
     if old.transform_requires_layer() != new.transform_requires_layer() {
-        damage.insert(RestyleDamage::rebuild_and_reflow());
+        damage.insert(ServoRestyleDamage::rebuild_and_reflow());
     }
 
     damage
 }
rename from servo/components/style/servo_selector_impl.rs
rename to servo/components/style/servo/selector_impl.rs
--- a/servo/components/style/servo_selector_impl.rs
+++ b/servo/components/style/servo/selector_impl.rs
@@ -379,14 +379,12 @@ impl MatchAttrGeneric for ServoElementSn
         match attr.namespace {
             NamespaceConstraint::Specific(ref ns) => self.get_attr(&ns.url, local_name),
             NamespaceConstraint::Any => self.get_attr_ignore_ns(local_name),
         }.map_or(false, |v| test(v))
     }
 }
 
 impl<E: Element<Impl=TheSelectorImpl>> ElementExt for E {
-    type Snapshot = ServoElementSnapshot;
-
     fn is_link(&self) -> bool {
         self.match_non_ts_pseudo_class(NonTSPseudoClass::AnyLink)
     }
 }