diff options
author | Christian Poveda <z1mvader@protonmail.com> | 2017-05-03 12:57:49 -0500 |
---|---|---|
committer | Christian Poveda <z1mvader@protonmail.com> | 2017-05-03 12:57:49 -0500 |
commit | 62821a69153441f36b8ff10050a29502dea71037 (patch) | |
tree | bb1560f8965520a1bded497d81c18f1dabfe57e8 /components | |
parent | 875e422fe67f68bdf57bd3635279e224b0c90996 (diff) | |
parent | 3905b5af1804ad912c6e1854a0bcdfe9bda79065 (diff) | |
download | servo-62821a69153441f36b8ff10050a29502dea71037.tar.gz servo-62821a69153441f36b8ff10050a29502dea71037.zip |
Solving merge conficts related to the html5ever_atoms -> html5ever change
Diffstat (limited to 'components')
170 files changed, 955 insertions, 638 deletions
diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index b1b9bbc6838..2e91e549611 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -21,6 +21,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use style::computed_values::{font_style, font_variant_caps}; use style::properties::style_structs; +use style::stylearc::Arc as StyleArc; use webrender_traits; static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h) @@ -109,7 +110,7 @@ impl FontContext { /// Create a group of fonts for use in layout calculations. May return /// a cached font if this font instance has already been used by /// this context. - pub fn layout_font_group_for_style(&mut self, style: Arc<style_structs::Font>) + pub fn layout_font_group_for_style(&mut self, style: StyleArc<style_structs::Font>) -> Rc<FontGroup> { self.expire_font_caches_if_necessary(); @@ -239,7 +240,7 @@ impl HeapSizeOf for FontContext { #[derive(Debug)] struct LayoutFontGroupCacheKey { - pointer: Arc<style_structs::Font>, + pointer: StyleArc<style_structs::Font>, size: Au, } diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml index cdeb2f09103..dee003a53b4 100644 --- a/components/layout/Cargo.toml +++ b/components/layout/Cargo.toml @@ -20,7 +20,7 @@ fnv = "1.0" gfx = {path = "../gfx"} gfx_traits = {path = "../gfx_traits"} heapsize = "0.3.0" -html5ever-atoms = "0.3" +html5ever = "0.16" ipc-channel = "0.7" libc = "0.2" log = "0.3.5" diff --git a/components/layout/block.rs b/components/layout/block.rs index 297bfcdc689..5e30c6f08ee 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -2134,7 +2134,7 @@ impl Flow for BlockFlow { self.build_display_list_for_block(state, BorderPaintingMode::Separate); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.fragment.repair_style(new_style) } diff --git a/components/layout/construct.rs b/components/layout/construct.rs index 089209551ac..2f24629b5e4 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -13,6 +13,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use block::BlockFlow; use context::{LayoutContext, with_thread_local_font_context}; @@ -107,7 +108,7 @@ pub enum ConstructionItem { /// Inline fragments and associated {ib} splits that have not yet found flows. InlineFragments(InlineFragmentsConstructionResult), /// Potentially ignorable whitespace. - Whitespace(OpaqueNode, PseudoElementType<()>, Arc<ServoComputedValues>, RestyleDamage), + Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage), /// TableColumn Fragment TableColumnFragment(Fragment), } @@ -675,7 +676,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode> fn create_fragments_for_node_text_content(&self, fragments: &mut IntermediateInlineFragments, node: &ConcreteThreadSafeLayoutNode, - style: &Arc<ServoComputedValues>) { + style: &StyleArc<ServoComputedValues>) { // Fast path: If there is no text content, return immediately. let text_content = node.text_content(); if text_content.is_empty() { @@ -1804,7 +1805,7 @@ pub fn strip_ignorable_whitespace_from_end(this: &mut LinkedList<Fragment>) { /// If the 'unicode-bidi' property has a value other than 'normal', return the bidi control codes /// to inject before and after the text content of the element. -fn bidi_control_chars(style: &Arc<ServoComputedValues>) -> Option<(&'static str, &'static str)> { +fn bidi_control_chars(style: &StyleArc<ServoComputedValues>) -> Option<(&'static str, &'static str)> { use style::computed_values::direction::T::*; use style::computed_values::unicode_bidi::T::*; diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index a2453067e1f..878b1220336 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -577,7 +577,7 @@ fn build_border_radius(abs_bounds: &Rect<Au>, /// Get the border radius for the rectangle inside of a rounded border. This is useful /// for building the clip for the content inside the border. fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>, - style: Arc<ServoComputedValues>) + style: ::StyleArc<ServoComputedValues>) -> BorderRadii<Au> { let mut radii = build_border_radius(&outer_rect, style.get_border()); if radii.is_square() { diff --git a/components/layout/flex.rs b/components/layout/flex.rs index cf77455afa8..dd990c61510 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -21,7 +21,6 @@ use model::{IntrinsicISizes, MaybeAuto, SizeConstraint}; use model::{specified, specified_or_none}; 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::logical_geometry::{Direction, LogicalSize}; @@ -970,7 +969,7 @@ impl Flow for FlexFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 27b5c291cc8..1944f0decbd 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -424,7 +424,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static { /// Attempts to perform incremental fixup of this flow by replacing its fragment's style with /// the new style. This can only succeed if the flow has exactly one fragment. - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>); + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>); /// Print any extra children (such as fragments) contained in this Flow /// for debugging purposes. Any items inserted into the tree will become @@ -561,7 +561,7 @@ pub trait MutableFlowUtils { /// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of /// calling them individually, since there is no reason not to perform both operations. - fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>); + fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>); } pub trait MutableOwnedFlowUtils { @@ -1361,7 +1361,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow { /// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of /// calling them individually, since there is no reason not to perform both operations. - fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>) { + fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>) { self.repair_style(style); self.bubble_inline_sizes(); } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 5c311ec3311..9f98ff318ec 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -6,6 +6,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use canvas_traits::CanvasMsg; use context::{LayoutContext, with_thread_local_font_context}; @@ -39,7 +40,6 @@ use std::borrow::ToOwned; use std::cmp::{Ordering, max, min}; use std::collections::LinkedList; 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_line, transform}; use style::computed_values::{transform_style, vertical_align, white_space, word_break}; @@ -95,10 +95,10 @@ pub struct Fragment { pub node: OpaqueNode, /// The CSS style of this fragment. - pub style: Arc<ServoComputedValues>, + pub style: StyleArc<ServoComputedValues>, /// The CSS style of this fragment when it's selected - pub selected_style: Arc<ServoComputedValues>, + pub selected_style: StyleArc<ServoComputedValues>, /// The position of this fragment relative to its owning flow. The size includes padding and /// border, but not margin. @@ -672,8 +672,8 @@ impl Fragment { /// Constructs a new `Fragment` instance from an opaque node. pub fn from_opaque_node_and_style(node: OpaqueNode, pseudo: PseudoElementType<()>, - style: Arc<ServoComputedValues>, - selected_style: Arc<ServoComputedValues>, + style: StyleArc<ServoComputedValues>, + selected_style: StyleArc<ServoComputedValues>, mut restyle_damage: RestyleDamage, specific: SpecificFragmentInfo) -> Fragment { @@ -702,7 +702,7 @@ impl Fragment { /// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to /// initial values. pub fn create_similar_anonymous_fragment(&self, - style: Arc<ServoComputedValues>, + style: StyleArc<ServoComputedValues>, specific: SpecificFragmentInfo) -> Fragment { let writing_mode = style.writing_mode; @@ -1846,7 +1846,7 @@ impl Fragment { match (&mut self.specific, &next_fragment.specific) { (&mut SpecificFragmentInfo::ScannedText(ref mut this_info), &SpecificFragmentInfo::ScannedText(ref other_info)) => { - debug_assert!(arc_ptr_eq(&this_info.run, &other_info.run)); + debug_assert!(::arc_ptr_eq(&this_info.run, &other_info.run)); this_info.range_end_including_stripped_whitespace = other_info.range_end_including_stripped_whitespace; if other_info.requires_line_break_afterward_if_wrapping_on_newlines() { @@ -2398,7 +2398,7 @@ impl Fragment { } } - pub fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + pub fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { self.style = (*new_style).clone() } diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index a23fd165ecf..5f6f9b1e706 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -16,7 +16,6 @@ use gfx::display_list::OpaqueNode; 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::properties::ServoComputedValues; @@ -369,7 +368,7 @@ impl Counter { layout_context: &LayoutContext, node: OpaqueNode, pseudo: PseudoElementType<()>, - style: Arc<ServoComputedValues>, + style: ::StyleArc<ServoComputedValues>, list_style_type: list_style_type::T, mode: RenderingMode) -> Option<SpecificFragmentInfo> { @@ -432,7 +431,7 @@ struct CounterValue { fn render_text(layout_context: &LayoutContext, node: OpaqueNode, pseudo: PseudoElementType<()>, - style: Arc<ServoComputedValues>, + style: ::StyleArc<ServoComputedValues>, string: String) -> Option<SpecificFragmentInfo> { let mut fragments = LinkedList::new(); diff --git a/components/layout/inline.rs b/components/layout/inline.rs index f28e583460f..d8cd4003ab3 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -4,6 +4,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use block::AbsoluteAssignBSizesTraversal; use context::LayoutContext; @@ -29,7 +30,6 @@ 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::{vertical_align, white_space}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; @@ -398,7 +398,7 @@ impl LineBreaker { result.border_padding.inline_end == Au(0) && candidate.border_padding.inline_start == Au(0) && result_info.selected() == candidate_info.selected() && - arc_ptr_eq(&result_info.run, &candidate_info.run) && + ::arc_ptr_eq(&result_info.run, &candidate_info.run) && inline_contexts_are_equal(&result.inline_context, &candidate.inline_context) } @@ -1657,7 +1657,7 @@ impl Flow for InlineFlow { self.build_display_list_for_inline(state); } - fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {} + fn repair_style(&mut self, _: &StyleArc<ServoComputedValues>) {} fn compute_overflow(&self) -> Overflow { let mut overflow = Overflow::new(); @@ -1746,8 +1746,8 @@ impl fmt::Debug for InlineFlow { #[derive(Clone)] pub struct InlineFragmentNodeInfo { pub address: OpaqueNode, - pub style: Arc<ServoComputedValues>, - pub selected_style: Arc<ServoComputedValues>, + pub style: StyleArc<ServoComputedValues>, + pub selected_style: StyleArc<ServoComputedValues>, pub pseudo: PseudoElementType<()>, pub flags: InlineFragmentNodeFlags, } diff --git a/components/layout/lib.rs b/components/layout/lib.rs index 4c5bd766e24..abdf6ff04c0 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -22,7 +22,7 @@ extern crate fnv; extern crate gfx; extern crate gfx_traits; extern crate heapsize; -#[macro_use] extern crate html5ever_atoms; +#[macro_use] extern crate html5ever; extern crate ipc_channel; extern crate libc; #[macro_use] @@ -93,3 +93,15 @@ pub mod wrapper; // For unit tests: pub use fragment::Fragment; pub use fragment::SpecificFragmentInfo; + +/// Returns whether the two arguments point to the same value. +/// +/// FIXME: Remove this and use Arc::ptr_eq once we require Rust 1.17 +#[inline] +pub fn arc_ptr_eq<T: 'static>(a: &::std::sync::Arc<T>, b: &::std::sync::Arc<T>) -> bool { + ::style::ptr_eq::<T>(&**a, &**b) +} + +// We can't use stylearc for everything in layout, because the Flow stuff uses +// weak references. +use style::stylearc::Arc as StyleArc; diff --git a/components/layout/list_item.rs b/components/layout/list_item.rs index cb260480cb9..8a79aaa40b7 100644 --- a/components/layout/list_item.rs +++ b/components/layout/list_item.rs @@ -18,7 +18,6 @@ use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedC use fragment::Overflow; use generated_content; use inline::InlineFlow; -use std::sync::Arc; use style::computed_values::{list_style_type, position}; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; @@ -148,7 +147,7 @@ impl Flow for ListItemFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 18cfe6409cb..b43a6eb17ff 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -6,6 +6,7 @@ #![deny(unsafe_code)] +use StyleArc; use app_units::Au; use block::BlockFlow; use context::LayoutContext; @@ -193,7 +194,7 @@ impl Flow for MulticolFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } @@ -275,7 +276,7 @@ impl Flow for MulticolColumnFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/query.rs b/components/layout/query.rs index 92c3a1525dd..6b594066963 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -55,7 +55,7 @@ pub struct LayoutThreadData { pub display_list: Option<Arc<DisplayList>>, /// Performs CSS selector matching and style resolution. - pub stylist: Arc<Stylist>, + pub stylist: ::StyleArc<Stylist>, /// A queued response for the union of the content boxes of a node. pub content_box_response: Option<Rect<Au>>, diff --git a/components/layout/table.rs b/components/layout/table.rs index b130b62bd04..c3ba52a305b 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -21,7 +21,6 @@ use layout_debug; use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto}; 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; @@ -507,7 +506,7 @@ impl Flow for TableFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_caption.rs b/components/layout/table_caption.rs index fe3eb5bf692..99d95fd9587 100644 --- a/components/layout/table_caption.rs +++ b/components/layout/table_caption.rs @@ -15,7 +15,6 @@ use flow::{Flow, FlowClass, OpaqueFlow}; use fragment::{Fragment, FragmentBorderBoxIterator, Overflow}; use gfx_traits::print_tree::PrintTree; use std::fmt; -use std::sync::Arc; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; @@ -84,7 +83,7 @@ impl Flow for TableCaptionFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index b40d25e936c..8c54297d4b5 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -19,7 +19,6 @@ use layout_debug; use model::MaybeAuto; use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode; use std::fmt; -use std::sync::Arc; use style::computed_values::{border_collapse, border_top_style, vertical_align}; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::properties::ServoComputedValues; @@ -264,7 +263,7 @@ impl Flow for TableCellFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 5603a02e3c9..85d5207646e 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -15,7 +15,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentIn use layout_debug; use std::cmp::max; use std::fmt; -use std::sync::Arc; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; use style::values::computed::LengthOrPercentageOrAuto; @@ -95,7 +94,7 @@ impl Flow for TableColGroupFlow { fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {} - fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {} + fn repair_style(&mut self, _: &::StyleArc<ServoComputedValues>) {} fn compute_overflow(&self) -> Overflow { Overflow::new() diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index d1c7146d247..8d074f59c52 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -22,7 +22,6 @@ 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::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; use style::properties::ServoComputedValues; @@ -483,7 +482,7 @@ impl Flow for TableRowFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_rowgroup.rs b/components/layout/table_rowgroup.rs index e4c4291bce4..7664796b082 100644 --- a/components/layout/table_rowgroup.rs +++ b/components/layout/table_rowgroup.rs @@ -18,7 +18,6 @@ use layout_debug; use serde::{Serialize, Serializer}; use std::fmt; use std::iter::{IntoIterator, Iterator, Peekable}; -use std::sync::Arc; use style::computed_values::{border_collapse, border_spacing}; use style::logical_geometry::LogicalSize; use style::properties::ServoComputedValues; @@ -186,7 +185,7 @@ impl Flow for TableRowGroupFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 64799a37e42..015f32a9762 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -27,7 +27,6 @@ use model::MaybeAuto; use std::cmp::{max, min}; use std::fmt; use std::ops::Add; -use std::sync::Arc; use style::computed_values::{border_collapse, position, table_layout}; use style::context::SharedStyleContext; use style::logical_geometry::{LogicalRect, LogicalSize}; @@ -467,7 +466,7 @@ impl Flow for TableWrapperFlow { self.block_flow.collect_stacking_contexts(state); } - fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) { + fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) { self.block_flow.repair_style(new_style) } diff --git a/components/layout/text.rs b/components/layout/text.rs index 5c9b93edee1..43b2fd086e7 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -435,7 +435,7 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode) /// /// `#[inline]` because often the caller only needs a few fields from the font metrics. #[inline] -pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<style_structs::Font>) +pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: ::StyleArc<style_structs::Font>) -> FontMetrics { let fontgroup = font_context.layout_font_group_for_style(font_style); // FIXME(https://github.com/rust-lang/rust/issues/23338) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 30d59180a3c..054d82397d5 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -115,6 +115,7 @@ use style::logical_geometry::LogicalPoint; use style::media_queries::{Device, MediaList, MediaType}; use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW}; use style::shared_lock::{SharedRwLock, SharedRwLockReadGuard, StylesheetGuards}; +use style::stylearc::Arc as StyleArc; use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets}; use style::stylist::{ExtraStyleData, Stylist}; use style::thread_state; @@ -192,10 +193,10 @@ pub struct LayoutThread { document_shared_lock: Option<SharedRwLock>, /// The list of currently-running animations. - running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>, + running_animations: StyleArc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>, /// The list of animations that have expired since the last style recalculation. - expired_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>, + expired_animations: StyleArc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>, /// A counter for epoch messages epoch: Epoch, @@ -412,7 +413,7 @@ impl LayoutThread { let font_cache_receiver = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_font_cache_receiver); - let stylist = Arc::new(Stylist::new(device)); + let stylist = StyleArc::new(Stylist::new(device)); let outstanding_web_fonts_counter = Arc::new(AtomicUsize::new(0)); let ua_stylesheets = &*UA_STYLESHEETS; let guard = ua_stylesheets.shared_lock.read(); @@ -448,8 +449,8 @@ impl LayoutThread { outstanding_web_fonts: outstanding_web_fonts_counter, root_flow: None, document_shared_lock: None, - running_animations: Arc::new(RwLock::new(HashMap::new())), - expired_animations: Arc::new(RwLock::new(HashMap::new())), + running_animations: StyleArc::new(RwLock::new(HashMap::new())), + expired_animations: StyleArc::new(RwLock::new(HashMap::new())), epoch: Epoch(0), viewport_size: Size2D::new(Au(0), Au(0)), webrender_api: webrender_api_sender.create_api(), @@ -741,7 +742,7 @@ impl LayoutThread { } fn handle_add_stylesheet<'a, 'b>(&self, - stylesheet: Arc<Stylesheet>, + stylesheet: StyleArc<Stylesheet>, possibly_locked_rw_data: &mut RwData<'a, 'b>) { // Find all font-face rules and notify the font cache of them. // GWTODO: Need to handle unloading web fonts. @@ -776,7 +777,7 @@ impl LayoutThread { possibly_locked_rw_data: &mut RwData<'a, 'b>, quirks_mode: QuirksMode) { let mut rw_data = possibly_locked_rw_data.lock(); - Arc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(quirks_mode); + StyleArc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(quirks_mode); possibly_locked_rw_data.block(rw_data); } @@ -1034,7 +1035,7 @@ impl LayoutThread { self.document_shared_lock = Some(document_shared_lock.clone()); let author_guard = document_shared_lock.read(); let device = Device::new(MediaType::Screen, initial_viewport); - Arc::get_mut(&mut rw_data.stylist).unwrap() + StyleArc::get_mut(&mut rw_data.stylist).unwrap() .set_device(device, &author_guard, &data.document_stylesheets); self.viewport_size = @@ -1088,7 +1089,7 @@ impl LayoutThread { let mut extra_data = ExtraStyleData { marker: PhantomData, }; - let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update( + let needs_dirtying = StyleArc::get_mut(&mut rw_data.stylist).unwrap().update( &data.document_stylesheets, &guards, Some(ua_stylesheets), diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index f145e8f65b0..76facbdc2ec 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -46,8 +46,7 @@ fnv = "1.0" gfx_traits = {path = "../gfx_traits"} heapsize = "0.3.6" heapsize_derive = "0.1" -html5ever = {version = "0.15", features = ["heap_size", "unstable"]} -html5ever-atoms = {version = "0.3", features = ["heap_size"]} +html5ever = {version = "0.16", features = ["heap_size", "unstable"]} hyper = "0.10" hyper_serde = "0.6" image = "0.12" @@ -88,7 +87,7 @@ time = "0.1.12" unicode-segmentation = "1.1.0" url = {version = "1.2", features = ["heap_size", "query_encoding"]} uuid = {version = "0.4", features = ["v4"]} -xml5ever = {version = "0.5", features = ["unstable"]} +xml5ever = {version = "0.6", features = ["unstable"]} webrender_traits = {git = "https://github.com/servo/webrender", features = ["ipc"]} webvr = {path = "../webvr"} webvr_traits = {path = "../webvr_traits"} diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 55f2adcfdb6..3c775ffdf57 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -13,7 +13,7 @@ use dom::element::{AttributeMutation, Element}; use dom::virtualmethods::vtable_for; use dom::window::Window; use dom_struct::dom_struct; -use html5ever_atoms::{Prefix, LocalName, Namespace}; +use html5ever::{Prefix, LocalName, Namespace}; use servo_atoms::Atom; use std::borrow::ToOwned; use std::cell::Ref; diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs index e75958d974a..6cb17fae4e3 100644 --- a/components/script/dom/bindings/str.rs +++ b/components/script/dom/bindings/str.rs @@ -4,7 +4,7 @@ //! The `ByteString` struct. -use html5ever_atoms::{LocalName, Namespace}; +use html5ever::{LocalName, Namespace}; use servo_atoms::Atom; use std::ascii::AsciiExt; use std::borrow::{Borrow, Cow, ToOwned}; diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 1bc9c165fb1..a0f26d12c23 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -47,8 +47,8 @@ use euclid::{Matrix2D, Matrix4D, Point2D}; use euclid::length::Length as EuclidLength; use euclid::rect::Rect; use euclid::size::Size2D; -use html5ever::tokenizer::buffer_queue::BufferQueue; -use html5ever_atoms::{Prefix, LocalName, Namespace, QualName}; +use html5ever::{Prefix, LocalName, Namespace, QualName}; +use html5ever::buffer_queue::BufferQueue; use hyper::header::Headers; use hyper::method::Method; use hyper::mime::Mime; @@ -99,6 +99,7 @@ use style::media_queries::MediaList; use style::properties::PropertyDeclarationBlock; use style::selector_parser::{PseudoElement, Snapshot}; use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocked}; +use style::stylearc::Arc as StyleArc; use style::stylesheets::{CssRules, FontFaceRule, KeyframesRule, MediaRule}; use style::stylesheets::{NamespaceRule, StyleRule, ImportRule, SupportsRule}; use style::values::specified::Length; @@ -166,6 +167,12 @@ unsafe impl<T: JSTraceable> JSTraceable for Arc<T> { } } +unsafe impl<T: JSTraceable> JSTraceable for StyleArc<T> { + unsafe fn trace(&self, trc: *mut JSTracer) { + (**self).trace(trc) + } +} + unsafe impl<T: JSTraceable + ?Sized> JSTraceable for Box<T> { unsafe fn trace(&self, trc: *mut JSTracer) { (**self).trace(trc) diff --git a/components/script/dom/bindings/xmlname.rs b/components/script/dom/bindings/xmlname.rs index 4522c9c4ac0..e688052fba8 100644 --- a/components/script/dom/bindings/xmlname.rs +++ b/components/script/dom/bindings/xmlname.rs @@ -6,7 +6,7 @@ use dom::bindings::error::{Error, ErrorResult, Fallible}; use dom::bindings::str::DOMString; -use html5ever_atoms::{Prefix, LocalName, Namespace}; +use html5ever::{Prefix, LocalName, Namespace}; /// Validate a qualified name. See https://dom.spec.whatwg.org/#validate for details. pub fn validate_qualified_name(qualified_name: &str) -> ErrorResult { diff --git a/components/script/dom/create.rs b/components/script/dom/create.rs index de20420d03f..91ea3e1e7da 100644 --- a/components/script/dom/create.rs +++ b/components/script/dom/create.rs @@ -76,7 +76,7 @@ use dom::htmlulistelement::HTMLUListElement; use dom::htmlunknownelement::HTMLUnknownElement; use dom::htmlvideoelement::HTMLVideoElement; use dom::svgsvgelement::SVGSVGElement; -use html5ever_atoms::{Prefix, QualName}; +use html5ever::{QualName, Prefix}; use servo_config::prefs::PREFS; fn create_svg_element(name: QualName, @@ -273,14 +273,10 @@ fn create_html_element(name: QualName, } pub fn create_element(name: QualName, - prefix: Option<Prefix>, document: &Document, creator: ElementCreator) -> Root<Element> { - // FIXME(ajeffrey): Convert directly from Prefix to DOMString. - - // let prefix = prefix.map(|p| DOMString::from(&*p)); - + let prefix = name.prefix.clone(); match name.ns { ns!(html) => create_html_element(name, prefix, document, creator), ns!(svg) => create_svg_element(name, prefix, document), diff --git a/components/script/dom/cssconditionrule.rs b/components/script/dom/cssconditionrule.rs index 8bf5dad6c93..1944c28c379 100644 --- a/components/script/dom/cssconditionrule.rs +++ b/components/script/dom/cssconditionrule.rs @@ -10,8 +10,8 @@ use dom::cssmediarule::CSSMediaRule; use dom::cssstylesheet::CSSStyleSheet; use dom::csssupportsrule::CSSSupportsRule; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::{SharedRwLock, Locked}; +use style::stylearc::Arc; use style::stylesheets::CssRules as StyleCssRules; #[dom_struct] diff --git a/components/script/dom/cssfontfacerule.rs b/components/script/dom/cssfontfacerule.rs index 1f247c25fdc..560722d2452 100644 --- a/components/script/dom/cssfontfacerule.rs +++ b/components/script/dom/cssfontfacerule.rs @@ -10,8 +10,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::stylesheets::FontFaceRule; #[dom_struct] diff --git a/components/script/dom/cssgroupingrule.rs b/components/script/dom/cssgroupingrule.rs index 249aaccd42e..4fd77b46a7c 100644 --- a/components/script/dom/cssgroupingrule.rs +++ b/components/script/dom/cssgroupingrule.rs @@ -12,8 +12,8 @@ use dom::cssrule::CSSRule; use dom::cssrulelist::{CSSRuleList, RulesSource}; use dom::cssstylesheet::CSSStyleSheet; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::{SharedRwLock, Locked}; +use style::stylearc::Arc; use style::stylesheets::CssRules as StyleCssRules; #[dom_struct] diff --git a/components/script/dom/cssimportrule.rs b/components/script/dom/cssimportrule.rs index 3c0eb7eb4aa..d9d867cbc19 100644 --- a/components/script/dom/cssimportrule.rs +++ b/components/script/dom/cssimportrule.rs @@ -10,8 +10,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::stylesheets::ImportRule; #[dom_struct] diff --git a/components/script/dom/csskeyframerule.rs b/components/script/dom/csskeyframerule.rs index d36e8988e04..46dac811d9f 100644 --- a/components/script/dom/csskeyframerule.rs +++ b/components/script/dom/csskeyframerule.rs @@ -12,9 +12,9 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::keyframes::Keyframe; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; #[dom_struct] pub struct CSSKeyframeRule { diff --git a/components/script/dom/csskeyframesrule.rs b/components/script/dom/csskeyframesrule.rs index a3715e914ed..f48abe60751 100644 --- a/components/script/dom/csskeyframesrule.rs +++ b/components/script/dom/csskeyframesrule.rs @@ -16,9 +16,9 @@ use dom::cssrulelist::{CSSRuleList, RulesSource}; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::keyframes::{Keyframe, KeyframeSelector}; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::stylesheets::KeyframesRule; use style::values::KeyframesName; diff --git a/components/script/dom/cssmediarule.rs b/components/script/dom/cssmediarule.rs index 45bf65b1adf..afc41d31be0 100644 --- a/components/script/dom/cssmediarule.rs +++ b/components/script/dom/cssmediarule.rs @@ -15,10 +15,10 @@ use dom::cssstylesheet::CSSStyleSheet; use dom::medialist::MediaList; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::media_queries::parse_media_query_list; use style::parser::{LengthParsingMode, ParserContext}; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::stylesheets::{CssRuleType, MediaRule}; use style_traits::ToCss; diff --git a/components/script/dom/cssnamespacerule.rs b/components/script/dom/cssnamespacerule.rs index 744a8020667..eafabf8a4a6 100644 --- a/components/script/dom/cssnamespacerule.rs +++ b/components/script/dom/cssnamespacerule.rs @@ -11,8 +11,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::stylesheets::NamespaceRule; #[dom_struct] diff --git a/components/script/dom/cssrulelist.rs b/components/script/dom/cssrulelist.rs index 67eac2beda2..d0dfe120410 100644 --- a/components/script/dom/cssrulelist.rs +++ b/components/script/dom/cssrulelist.rs @@ -13,8 +13,8 @@ use dom::cssrule::CSSRule; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::Locked; +use style::stylearc::Arc; use style::stylesheets::{CssRules, CssRulesHelpers, KeyframesRule, RulesMutateError}; #[allow(unsafe_code)] diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index d0996f04567..8b81201de77 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -16,13 +16,13 @@ use dom::window::Window; use dom_struct::dom_struct; use servo_url::ServoUrl; use std::ascii::AsciiExt; -use std::sync::Arc; use style::attr::AttrValue; use style::parser::LengthParsingMode; use style::properties::{Importance, PropertyDeclarationBlock, PropertyId, LonghandId, ShorthandId}; use style::properties::{parse_one_declaration, parse_style_attribute}; use style::selector_parser::PseudoElement; use style::shared_lock::Locked; +use style::stylearc::Arc; use style_traits::ToCss; // http://dev.w3.org/csswg/cssom/#the-cssstyledeclaration-interface diff --git a/components/script/dom/cssstylerule.rs b/components/script/dom/cssstylerule.rs index fed2b947f90..607f2cfb816 100644 --- a/components/script/dom/cssstylerule.rs +++ b/components/script/dom/cssstylerule.rs @@ -12,8 +12,8 @@ use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration, CSSSt use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::stylesheets::StyleRule; #[dom_struct] diff --git a/components/script/dom/cssstylesheet.rs b/components/script/dom/cssstylesheet.rs index ee097313c2e..cb378b2261a 100644 --- a/components/script/dom/cssstylesheet.rs +++ b/components/script/dom/cssstylesheet.rs @@ -15,8 +15,8 @@ use dom::stylesheet::StyleSheet; use dom::window::Window; use dom_struct::dom_struct; use std::cell::Cell; -use std::sync::Arc; use style::shared_lock::SharedRwLock; +use style::stylearc::Arc; use style::stylesheets::Stylesheet as StyleStyleSheet; #[dom_struct] diff --git a/components/script/dom/csssupportsrule.rs b/components/script/dom/csssupportsrule.rs index 86aedf10864..9a0743856d6 100644 --- a/components/script/dom/csssupportsrule.rs +++ b/components/script/dom/csssupportsrule.rs @@ -13,9 +13,9 @@ use dom::cssrule::SpecificCSSRule; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::parser::{LengthParsingMode, ParserContext}; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::stylesheets::{CssRuleType, SupportsRule}; use style::supports::SupportsCondition; use style_traits::ToCss; diff --git a/components/script/dom/cssviewportrule.rs b/components/script/dom/cssviewportrule.rs index 38abf909ff0..4438aabb53e 100644 --- a/components/script/dom/cssviewportrule.rs +++ b/components/script/dom/cssviewportrule.rs @@ -10,8 +10,8 @@ use dom::cssrule::{CSSRule, SpecificCSSRule}; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::shared_lock::{Locked, ToCssWithGuard}; +use style::stylearc::Arc; use style::viewport::ViewportRule; #[dom_struct] diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 06b8f7596cf..2043c4ed429 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -93,7 +93,7 @@ use dom_struct::dom_struct; use encoding::EncodingRef; use encoding::all::UTF_8; use euclid::point::Point2D; -use html5ever_atoms::{LocalName, QualName}; +use html5ever::{LocalName, QualName}; use hyper::header::{Header, SetCookie}; use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcSender}; @@ -128,7 +128,6 @@ 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::{QuirksMode, ReflowGoal}; @@ -136,6 +135,7 @@ use style::restyle_hints::{RestyleHint, RESTYLE_SELF, RESTYLE_STYLE_ATTRIBUTE}; use style::selector_parser::{RestyleDamage, Snapshot}; use style::shared_lock::SharedRwLock as StyleSharedRwLock; use style::str::{HTML_SPACE_CHARACTERS, split_html_space_chars, str_join}; +use style::stylearc::Arc; use style::stylesheets::Stylesheet; use task_source::TaskSource; use time; @@ -2733,7 +2733,7 @@ impl DocumentMethods for Document { -> Root<HTMLCollection> { let ns = namespace_from_domstring(maybe_ns); let local = LocalName::from(tag_name); - let qname = QualName::new(ns, local); + let qname = QualName::new(None, ns, local); match self.tagns_map.borrow_mut().entry(qname.clone()) { Occupied(entry) => Root::from_ref(entry.get()), Vacant(entry) => { @@ -2782,8 +2782,8 @@ impl DocumentMethods for Document { ns!() }; - let name = QualName::new(ns, LocalName::from(local_name)); - Ok(Element::create(name, None, self, ElementCreator::ScriptCreated)) + let name = QualName::new(None, ns, LocalName::from(local_name)); + Ok(Element::create(name, self, ElementCreator::ScriptCreated)) } // https://dom.spec.whatwg.org/#dom-document-createelementns @@ -2793,8 +2793,8 @@ impl DocumentMethods for Document { -> Fallible<Root<Element>> { let (namespace, prefix, local_name) = try!(validate_and_extract(namespace, &qualified_name)); - let name = QualName::new(namespace, local_name); - Ok(Element::create(name, prefix, self, ElementCreator::ScriptCreated)) + let name = QualName::new(prefix, namespace, local_name); + Ok(Element::create(name, self, ElementCreator::ScriptCreated)) } // https://dom.spec.whatwg.org/#dom-document-createattribute @@ -3047,8 +3047,8 @@ impl DocumentMethods for Document { match elem { Some(elem) => Root::upcast::<Node>(elem), None => { - let name = QualName::new(ns!(svg), local_name!("title")); - let elem = Element::create(name, None, self, ElementCreator::ScriptCreated); + let name = QualName::new(None, ns!(svg), local_name!("title")); + let elem = Element::create(name, self, ElementCreator::ScriptCreated); let parent = root.upcast::<Node>(); let child = elem.upcast::<Node>(); parent.InsertBefore(child, parent.GetFirstChild().r()) @@ -3064,9 +3064,8 @@ impl DocumentMethods for Document { None => { match self.GetHead() { Some(head) => { - let name = QualName::new(ns!(html), local_name!("title")); + let name = QualName::new(None, ns!(html), local_name!("title")); let elem = Element::create(name, - None, self, ElementCreator::ScriptCreated); head.upcast::<Node>() diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 28266709f67..b07a4357e83 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -12,7 +12,7 @@ use dom::bindings::str::DOMString; use dom::element::Element; use dom::node::window_from_node; use dom_struct::dom_struct; -use html5ever_atoms::LocalName; +use html5ever::LocalName; use servo_atoms::Atom; use style::str::HTML_SPACE_CHARACTERS; diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index c6e04424e3a..d54b79cdc28 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -75,11 +75,11 @@ use dom::validation::Validatable; use dom::virtualmethods::{VirtualMethods, vtable_for}; use dom::window::ReflowReason; use dom_struct::dom_struct; +use html5ever::{Prefix, LocalName, Namespace, QualName}; use html5ever::serialize; use html5ever::serialize::SerializeOpts; use html5ever::serialize::TraversalScope; use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; -use html5ever_atoms::{Prefix, LocalName, Namespace, QualName}; use js::jsapi::{HandleValue, JSAutoCompartment}; use net_traits::request::CorsSettings; use ref_filter_map::ref_filter_map; @@ -96,7 +96,6 @@ use std::convert::TryFrom; use std::default::Default; use std::fmt; use std::rc::Rc; -use std::sync::Arc; use style::attr::{AttrValue, LengthOrPercentageOrAuto}; use style::context::{QuirksMode, ReflowGoal}; use style::element_state::*; @@ -107,6 +106,7 @@ use style::rule_tree::CascadeLevel; use style::selector_parser::{NonTSPseudoClass, RestyleDamage, SelectorImpl, SelectorParser}; use style::shared_lock::{SharedRwLock, Locked}; use style::sink::Push; +use style::stylearc::Arc; use style::stylist::ApplicableDeclarationBlock; use style::thread_state; use style::values::CSSFloat; @@ -195,10 +195,10 @@ impl<'a> TryFrom<&'a str> for AdjacentPosition { // Element methods // impl Element { - pub fn create(name: QualName, prefix: Option<Prefix>, + pub fn create(name: QualName, document: &Document, creator: ElementCreator) -> Root<Element> { - create_element(name, prefix, document, creator) + create_element(name, document, creator) } pub fn new_inherited(local_name: LocalName, @@ -1955,8 +1955,8 @@ impl ElementMethods for Element { // Step 4. NodeTypeId::DocumentFragment => { - let body_elem = Element::create(QualName::new(ns!(html), local_name!("body")), - None, &context_document, + let body_elem = Element::create(QualName::new(None, ns!(html), local_name!("body")), + &context_document, ElementCreator::ScriptCreated); Root::upcast(body_elem) }, diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index af4c692e7d9..2d8657e3564 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -17,7 +17,7 @@ use dom::file::File; use dom::globalscope::GlobalScope; use dom::htmlformelement::{HTMLFormElement, FormDatumValue, FormDatum}; use dom_struct::dom_struct; -use html5ever_atoms::LocalName; +use html5ever::LocalName; use std::collections::HashMap; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::iter; diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index dad4002b104..aefa776531c 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -25,7 +25,7 @@ use dom::node::{Node, document_from_node}; use dom::urlhelper::UrlHelper; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use net_traits::ReferrerPolicy; use num_traits::ToPrimitive; use script_traits::MozBrowserEvent; diff --git a/components/script/dom/htmlappletelement.rs b/components/script/dom/htmlappletelement.rs index 68ae0c32c85..c8d07f48804 100644 --- a/components/script/dom/htmlappletelement.rs +++ b/components/script/dom/htmlappletelement.rs @@ -12,7 +12,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::attr::AttrValue; #[dom_struct] diff --git a/components/script/dom/htmlareaelement.rs b/components/script/dom/htmlareaelement.rs index 68f8c5cbfa3..548efbd43de 100644 --- a/components/script/dom/htmlareaelement.rs +++ b/components/script/dom/htmlareaelement.rs @@ -20,7 +20,7 @@ use dom::node::{Node, document_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use euclid::point::Point2D; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use net_traits::ReferrerPolicy; use std::default::Default; use std::f32; diff --git a/components/script/dom/htmlaudioelement.rs b/components/script/dom/htmlaudioelement.rs index e121ca6b47d..6d98e94209b 100644 --- a/components/script/dom/htmlaudioelement.rs +++ b/components/script/dom/htmlaudioelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlmediaelement::HTMLMediaElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLAudioElement { diff --git a/components/script/dom/htmlbaseelement.rs b/components/script/dom/htmlbaseelement.rs index 38c606f17ff..0b42265617d 100644 --- a/components/script/dom/htmlbaseelement.rs +++ b/components/script/dom/htmlbaseelement.rs @@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement; use dom::node::{Node, UnbindContext, document_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use servo_url::ServoUrl; use style::attr::AttrValue; diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 6dc742b880c..c5c03164a61 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -18,7 +18,7 @@ use dom::htmlelement::HTMLElement; use dom::node::{Node, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use script_traits::ScriptMsg as ConstellationMsg; use servo_url::ServoUrl; use style::attr::AttrValue; diff --git a/components/script/dom/htmlbrelement.rs b/components/script/dom/htmlbrelement.rs index a7f6f38abd3..dba06c52a0f 100644 --- a/components/script/dom/htmlbrelement.rs +++ b/components/script/dom/htmlbrelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLBRElement { diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index a697ec21b88..ee39f3a88c9 100755 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -24,7 +24,7 @@ use dom::validation::Validatable; use dom::validitystate::{ValidityState, ValidationFlags}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use std::cell::Cell; use std::default::Default; use style::element_state::*; diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index fbd00004af7..6dd10aa3c82 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -27,7 +27,7 @@ use dom::virtualmethods::VirtualMethods; use dom::webglrenderingcontext::{LayoutCanvasWebGLRenderingContextHelpers, WebGLRenderingContext}; use dom_struct::dom_struct; use euclid::size::Size2D; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use image::ColorType; use image::png::PNGEncoder; use ipc_channel::ipc::{self, IpcSender}; diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index 4e05de86922..aff4125a29f 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -14,7 +14,7 @@ use dom::element::Element; use dom::node::Node; use dom::window::Window; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, QualName}; +use html5ever::{LocalName, QualName}; use servo_atoms::Atom; use std::cell::Cell; use style::str::split_html_space_chars; @@ -164,7 +164,7 @@ impl HTMLCollection { maybe_ns: Option<DOMString>) -> Root<HTMLCollection> { let local = LocalName::from(tag); let ns = namespace_from_domstring(maybe_ns); - let qname = QualName::new(ns, local); + let qname = QualName::new(None, ns, local); HTMLCollection::by_qual_tag_name(window, root, qname) } diff --git a/components/script/dom/htmldataelement.rs b/components/script/dom/htmldataelement.rs index 2201d9b8c72..baf9c565b4d 100644 --- a/components/script/dom/htmldataelement.rs +++ b/components/script/dom/htmldataelement.rs @@ -10,7 +10,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLDataElement { diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs index 37a7b2f3a75..1603ac39bf7 100644 --- a/components/script/dom/htmldatalistelement.rs +++ b/components/script/dom/htmldatalistelement.rs @@ -13,7 +13,7 @@ use dom::htmlelement::HTMLElement; use dom::htmloptionelement::HTMLOptionElement; use dom::node::{Node, window_from_node}; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLDataListElement { diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index 9f0010b683f..6c44ad48fa9 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -15,7 +15,7 @@ use dom::htmlelement::HTMLElement; use dom::node::{Node, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use script_thread::Runnable; use std::cell::Cell; use task_source::TaskSource; diff --git a/components/script/dom/htmldialogelement.rs b/components/script/dom/htmldialogelement.rs index acb8b839d0f..15bbdbfe99e 100644 --- a/components/script/dom/htmldialogelement.rs +++ b/components/script/dom/htmldialogelement.rs @@ -14,7 +14,7 @@ use dom::eventtarget::EventTarget; use dom::htmlelement::HTMLElement; use dom::node::{Node, window_from_node}; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLDialogElement { diff --git a/components/script/dom/htmldirectoryelement.rs b/components/script/dom/htmldirectoryelement.rs index bea1c192960..67d1b567c52 100644 --- a/components/script/dom/htmldirectoryelement.rs +++ b/components/script/dom/htmldirectoryelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLDirectoryElement { diff --git a/components/script/dom/htmldivelement.rs b/components/script/dom/htmldivelement.rs index ea5d8f39f02..6e20b3796f5 100644 --- a/components/script/dom/htmldivelement.rs +++ b/components/script/dom/htmldivelement.rs @@ -9,7 +9,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLDivElement { diff --git a/components/script/dom/htmldlistelement.rs b/components/script/dom/htmldlistelement.rs index e3ac55598ab..796f104c240 100644 --- a/components/script/dom/htmldlistelement.rs +++ b/components/script/dom/htmldlistelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLDListElement { diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 1dc63b7c831..59846595166 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -30,7 +30,7 @@ use dom::node::{document_from_node, window_from_node}; use dom::nodelist::NodeList; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::default::Default; diff --git a/components/script/dom/htmlembedelement.rs b/components/script/dom/htmlembedelement.rs index db522158bbc..0b3c80b9bea 100644 --- a/components/script/dom/htmlembedelement.rs +++ b/components/script/dom/htmlembedelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLEmbedElement { diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index 1cc53e4ec7c..4deb3190340 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -17,7 +17,7 @@ use dom::node::{Node, window_from_node}; use dom::validitystate::ValidityState; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use std::default::Default; use style::element_state::*; diff --git a/components/script/dom/htmlfontelement.rs b/components/script/dom/htmlfontelement.rs index c8a8b683d10..618c0d62240 100644 --- a/components/script/dom/htmlfontelement.rs +++ b/components/script/dom/htmlfontelement.rs @@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use servo_atoms::Atom; use style::attr::AttrValue; use style::str::{HTML_SPACE_CHARACTERS, read_numbers}; diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 16555c1abe6..4397364f68f 100755 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -45,7 +45,7 @@ use dom_struct::dom_struct; use encoding::EncodingRef; use encoding::all::UTF_8; use encoding::label::encoding_from_whatwg_label; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use hyper::header::{Charset, ContentDisposition, ContentType, DispositionParam, DispositionType}; use hyper::method::Method; use msg::constellation_msg::PipelineId; diff --git a/components/script/dom/htmlframeelement.rs b/components/script/dom/htmlframeelement.rs index 0f57c586b4f..68cd8f8a405 100644 --- a/components/script/dom/htmlframeelement.rs +++ b/components/script/dom/htmlframeelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLFrameElement { diff --git a/components/script/dom/htmlframesetelement.rs b/components/script/dom/htmlframesetelement.rs index e653a2119d1..c8d4b440cf8 100644 --- a/components/script/dom/htmlframesetelement.rs +++ b/components/script/dom/htmlframesetelement.rs @@ -11,7 +11,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::{Node, document_from_node}; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLFrameSetElement { diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index 7c469b93488..5c14f110c8f 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -14,7 +14,7 @@ use dom::node::{Node, document_from_node}; use dom::userscripts::load_script; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLHeadElement { diff --git a/components/script/dom/htmlheadingelement.rs b/components/script/dom/htmlheadingelement.rs index a7ec1a8ec24..ca60441ac93 100644 --- a/components/script/dom/htmlheadingelement.rs +++ b/components/script/dom/htmlheadingelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[derive(JSTraceable, HeapSizeOf)] pub enum HeadingLevel { diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index cb1b90f4e17..85b160bb848 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -13,7 +13,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::attr::{AttrValue, LengthOrPercentageOrAuto}; #[dom_struct] diff --git a/components/script/dom/htmlhtmlelement.rs b/components/script/dom/htmlhtmlelement.rs index 07f17d366d1..47aa909035d 100644 --- a/components/script/dom/htmlhtmlelement.rs +++ b/components/script/dom/htmlhtmlelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLHtmlElement { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 3f410bdce54..e1a7fb7c672 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -36,7 +36,7 @@ use dom::node::{Node, NodeDamage, UnbindContext, document_from_node, window_from use dom::virtualmethods::VirtualMethods; use dom::window::{ReflowReason, Window}; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use ipc_channel::ipc; use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue}; use js::jsval::{NullValue, UndefinedValue}; diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 066f0ef6959..b706288a2cf 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -35,7 +35,7 @@ use dom::virtualmethods::VirtualMethods; use dom::window::Window; use dom_struct::dom_struct; use euclid::point::Point2D; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use net_traits::{FetchResponseListener, FetchMetadata, NetworkError, FetchResponseMsg}; diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 9da2f4be30a..fc20326b906 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -37,7 +37,7 @@ use dom::validation::Validatable; use dom::validitystate::ValidationFlags; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use ipc_channel::ipc::{self, IpcSender}; use mime_guess; use net_traits::{CoreResourceMsg, IpcSend}; diff --git a/components/script/dom/htmllabelelement.rs b/components/script/dom/htmllabelelement.rs index d1bde9cd957..cd5044fe4ed 100644 --- a/components/script/dom/htmllabelelement.rs +++ b/components/script/dom/htmllabelelement.rs @@ -18,7 +18,7 @@ use dom::htmlformelement::{FormControl, FormControlElementHelpers, HTMLFormEleme use dom::node::{document_from_node, Node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::attr::AttrValue; #[dom_struct] diff --git a/components/script/dom/htmllegendelement.rs b/components/script/dom/htmllegendelement.rs index f2e04fceea3..d527df711ef 100644 --- a/components/script/dom/htmllegendelement.rs +++ b/components/script/dom/htmllegendelement.rs @@ -15,7 +15,7 @@ use dom::htmlformelement::{HTMLFormElement, FormControl}; use dom::node::{Node, UnbindContext}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLLegendElement { diff --git a/components/script/dom/htmllielement.rs b/components/script/dom/htmllielement.rs index 6a39905ae99..9d949764a61 100644 --- a/components/script/dom/htmllielement.rs +++ b/components/script/dom/htmllielement.rs @@ -12,7 +12,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::attr::AttrValue; #[dom_struct] diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index b2c276ad292..09f24ace0d7 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -22,7 +22,7 @@ use dom::node::{Node, UnbindContext, document_from_node, window_from_node}; use dom::stylesheet::StyleSheet as DOMStyleSheet; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use net_traits::ReferrerPolicy; use script_layout_interface::message::Msg; use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg}; @@ -30,11 +30,11 @@ use std::ascii::AsciiExt; use std::borrow::ToOwned; use std::cell::Cell; use std::default::Default; -use std::sync::Arc; use style::attr::AttrValue; use style::media_queries::parse_media_query_list; use style::parser::{LengthParsingMode, ParserContext as CssParserContext}; use style::str::HTML_SPACE_CHARACTERS; +use style::stylearc::Arc; use style::stylesheets::{CssRuleType, Stylesheet}; use stylesheet_loader::{StylesheetLoader, StylesheetContextSource, StylesheetOwner}; diff --git a/components/script/dom/htmlmapelement.rs b/components/script/dom/htmlmapelement.rs index ce64f13edc2..e3ec4dc42eb 100644 --- a/components/script/dom/htmlmapelement.rs +++ b/components/script/dom/htmlmapelement.rs @@ -10,7 +10,7 @@ use dom::htmlareaelement::HTMLAreaElement; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLMapElement { diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index 30820cc5734..679294dae1a 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -28,7 +28,7 @@ use dom::mediaerror::MediaError; use dom::node::{window_from_node, document_from_node, Node, UnbindContext}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use net_traits::{FetchResponseListener, FetchMetadata, Metadata, NetworkError}; diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs index 878bf44d1c3..30bce19c299 100644 --- a/components/script/dom/htmlmetaelement.rs +++ b/components/script/dom/htmlmetaelement.rs @@ -18,14 +18,14 @@ use dom::htmlheadelement::HTMLHeadElement; use dom::node::{Node, UnbindContext, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use servo_config::prefs::PREFS; use std::ascii::AsciiExt; -use std::sync::Arc; use std::sync::atomic::AtomicBool; use style::attr::AttrValue; use style::media_queries::MediaList; use style::str::HTML_SPACE_CHARACTERS; +use style::stylearc::Arc; use style::stylesheets::{Stylesheet, CssRule, CssRules, Origin}; use style::viewport::ViewportRule; diff --git a/components/script/dom/htmlmeterelement.rs b/components/script/dom/htmlmeterelement.rs index 7eccf0a5ec2..ccf1e9a07bb 100644 --- a/components/script/dom/htmlmeterelement.rs +++ b/components/script/dom/htmlmeterelement.rs @@ -10,7 +10,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::nodelist::NodeList; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLMeterElement { diff --git a/components/script/dom/htmlmodelement.rs b/components/script/dom/htmlmodelement.rs index 07335e71cc5..fc3ac075242 100644 --- a/components/script/dom/htmlmodelement.rs +++ b/components/script/dom/htmlmodelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLModElement { diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index c2a3224d0d9..28ce00942cc 100755 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -18,10 +18,10 @@ use dom::validation::Validatable; use dom::validitystate::{ValidityState, ValidationFlags}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use net_traits::image::base::Image; use std::default::Default; -use std::sync::Arc; +use style::stylearc::Arc; #[dom_struct] pub struct HTMLObjectElement { diff --git a/components/script/dom/htmlolistelement.rs b/components/script/dom/htmlolistelement.rs index cb3dff65354..42351aea0ff 100644 --- a/components/script/dom/htmlolistelement.rs +++ b/components/script/dom/htmlolistelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLOListElement { diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index 8ba57318d77..d7a50906a76 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -14,7 +14,7 @@ use dom::htmloptionelement::HTMLOptionElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::element_state::*; #[dom_struct] diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index 0db31d89240..251bbc62a84 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -23,7 +23,7 @@ use dom::node::{Node, UnbindContext}; use dom::text::Text; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use std::cell::Cell; use style::element_state::*; use style::str::{split_html_space_chars, str_join}; diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index ad09228ab74..f0b9377e447 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -16,7 +16,7 @@ use dom::nodelist::NodeList; use dom::validitystate::ValidityState; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLOutputElement { diff --git a/components/script/dom/htmlparagraphelement.rs b/components/script/dom/htmlparagraphelement.rs index f946e8d64e3..f0b0e176152 100644 --- a/components/script/dom/htmlparagraphelement.rs +++ b/components/script/dom/htmlparagraphelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLParagraphElement { diff --git a/components/script/dom/htmlparamelement.rs b/components/script/dom/htmlparamelement.rs index f7c3079b4ae..46dd705ef3b 100644 --- a/components/script/dom/htmlparamelement.rs +++ b/components/script/dom/htmlparamelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLParamElement { diff --git a/components/script/dom/htmlpreelement.rs b/components/script/dom/htmlpreelement.rs index 96cfab5924d..76862160847 100644 --- a/components/script/dom/htmlpreelement.rs +++ b/components/script/dom/htmlpreelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLPreElement { diff --git a/components/script/dom/htmlprogresselement.rs b/components/script/dom/htmlprogresselement.rs index ce837906727..2ad3371da94 100644 --- a/components/script/dom/htmlprogresselement.rs +++ b/components/script/dom/htmlprogresselement.rs @@ -10,7 +10,7 @@ use dom::htmlelement::HTMLElement; use dom::node::Node; use dom::nodelist::NodeList; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLProgressElement { diff --git a/components/script/dom/htmlquoteelement.rs b/components/script/dom/htmlquoteelement.rs index da5756a4618..7ccb59b5e84 100644 --- a/components/script/dom/htmlquoteelement.rs +++ b/components/script/dom/htmlquoteelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLQuoteElement { diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 450c3e6c892..a29490ff5f4 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -26,7 +26,7 @@ use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; use encoding::label::encoding_from_whatwg_label; use encoding::types::{DecoderTrap, EncodingRef}; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use js::jsval::UndefinedValue; diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index a9adefc92fb..1f4f3c426bf 100755 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -31,7 +31,7 @@ use dom::validation::Validatable; use dom::validitystate::{ValidityState, ValidationFlags}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use std::default::Default; use std::iter; use style::attr::AttrValue; diff --git a/components/script/dom/htmlsourceelement.rs b/components/script/dom/htmlsourceelement.rs index ddc343c1e59..84adbc16548 100644 --- a/components/script/dom/htmlsourceelement.rs +++ b/components/script/dom/htmlsourceelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLSourceElement { diff --git a/components/script/dom/htmlspanelement.rs b/components/script/dom/htmlspanelement.rs index 5d98797260f..657b4aca17b 100644 --- a/components/script/dom/htmlspanelement.rs +++ b/components/script/dom/htmlspanelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLSpanElement { diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 531dc45ff2f..e96954efe26 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -18,13 +18,13 @@ use dom::node::{ChildrenMutation, Node, UnbindContext, document_from_node, windo use dom::stylesheet::StyleSheet as DOMStyleSheet; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use net_traits::ReferrerPolicy; use script_layout_interface::message::Msg; use std::cell::Cell; -use std::sync::Arc; use style::media_queries::parse_media_query_list; use style::parser::{LengthParsingMode, ParserContext as CssParserContext}; +use style::stylearc::Arc; use style::stylesheets::{CssRuleType, Stylesheet, Origin}; use stylesheet_loader::{StylesheetLoader, StylesheetOwner}; diff --git a/components/script/dom/htmltablecaptionelement.rs b/components/script/dom/htmltablecaptionelement.rs index 2dab17ee42a..b21a00bc190 100644 --- a/components/script/dom/htmltablecaptionelement.rs +++ b/components/script/dom/htmltablecaptionelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTableCaptionElement { diff --git a/components/script/dom/htmltablecellelement.rs b/components/script/dom/htmltablecellelement.rs index fd613d144e6..de0bab2ce9a 100644 --- a/components/script/dom/htmltablecellelement.rs +++ b/components/script/dom/htmltablecellelement.rs @@ -15,7 +15,7 @@ use dom::htmltablerowelement::HTMLTableRowElement; use dom::node::Node; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::attr::{AttrValue, LengthOrPercentageOrAuto}; const DEFAULT_COLSPAN: u32 = 1; diff --git a/components/script/dom/htmltablecolelement.rs b/components/script/dom/htmltablecolelement.rs index bf43f4ca3a7..875e6e696bd 100644 --- a/components/script/dom/htmltablecolelement.rs +++ b/components/script/dom/htmltablecolelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTableColElement { diff --git a/components/script/dom/htmltabledatacellelement.rs b/components/script/dom/htmltabledatacellelement.rs index e2430082c75..1c70ffbd8fb 100644 --- a/components/script/dom/htmltabledatacellelement.rs +++ b/components/script/dom/htmltabledatacellelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmltablecellelement::HTMLTableCellElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTableDataCellElement { diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index b1e928b292e..3e0310dad9a 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -23,7 +23,7 @@ use dom::htmltablesectionelement::HTMLTableSectionElement; use dom::node::{Node, document_from_node, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use std::cell::Cell; use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_unsigned_integer}; diff --git a/components/script/dom/htmltableheadercellelement.rs b/components/script/dom/htmltableheadercellelement.rs index a0607d9b3f6..7655db7ee77 100644 --- a/components/script/dom/htmltableheadercellelement.rs +++ b/components/script/dom/htmltableheadercellelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmltablecellelement::HTMLTableCellElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTableHeaderCellElement { diff --git a/components/script/dom/htmltablerowelement.rs b/components/script/dom/htmltablerowelement.rs index 5faf50cdae1..d18ef77f8d8 100644 --- a/components/script/dom/htmltablerowelement.rs +++ b/components/script/dom/htmltablerowelement.rs @@ -22,7 +22,7 @@ use dom::htmltablesectionelement::HTMLTableSectionElement; use dom::node::{Node, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::attr::AttrValue; #[derive(JSTraceable)] diff --git a/components/script/dom/htmltablesectionelement.rs b/components/script/dom/htmltablesectionelement.rs index 2da0f8b0843..66703305bc7 100644 --- a/components/script/dom/htmltablesectionelement.rs +++ b/components/script/dom/htmltablesectionelement.rs @@ -17,7 +17,7 @@ use dom::htmltablerowelement::HTMLTableRowElement; use dom::node::{Node, window_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::attr::AttrValue; #[dom_struct] diff --git a/components/script/dom/htmltemplateelement.rs b/components/script/dom/htmltemplateelement.rs index 4798cd6c46d..9b058607aff 100644 --- a/components/script/dom/htmltemplateelement.rs +++ b/components/script/dom/htmltemplateelement.rs @@ -14,7 +14,7 @@ use dom::htmlelement::HTMLElement; use dom::node::{CloneChildrenFlag, Node, document_from_node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTemplateElement { diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index c93fbc080a1..3033480b03d 100755 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -26,7 +26,7 @@ use dom::nodelist::NodeList; use dom::validation::Validatable; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use ipc_channel::ipc::IpcSender; use script_traits::ScriptMsg as ConstellationMsg; use std::cell::Cell; diff --git a/components/script/dom/htmltimeelement.rs b/components/script/dom/htmltimeelement.rs index 41846635df1..7fc3245ed41 100644 --- a/components/script/dom/htmltimeelement.rs +++ b/components/script/dom/htmltimeelement.rs @@ -10,7 +10,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTimeElement { diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index 092ec9d62ea..751f3c0ef2e 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -13,7 +13,7 @@ use dom::htmlelement::HTMLElement; use dom::node::{ChildrenMutation, Node}; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTitleElement { diff --git a/components/script/dom/htmltrackelement.rs b/components/script/dom/htmltrackelement.rs index 8339a49734a..eb9a5ecf80d 100644 --- a/components/script/dom/htmltrackelement.rs +++ b/components/script/dom/htmltrackelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLTrackElement { diff --git a/components/script/dom/htmlulistelement.rs b/components/script/dom/htmlulistelement.rs index 4275364b198..b40f4a1f8db 100644 --- a/components/script/dom/htmlulistelement.rs +++ b/components/script/dom/htmlulistelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLUListElement { diff --git a/components/script/dom/htmlunknownelement.rs b/components/script/dom/htmlunknownelement.rs index d9f533e1364..cb3db5be292 100644 --- a/components/script/dom/htmlunknownelement.rs +++ b/components/script/dom/htmlunknownelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLUnknownElement { diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs index f7602e860d5..00befe9a109 100644 --- a/components/script/dom/htmlvideoelement.rs +++ b/components/script/dom/htmlvideoelement.rs @@ -8,7 +8,7 @@ use dom::document::Document; use dom::htmlmediaelement::HTMLMediaElement; use dom::node::Node; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; #[dom_struct] pub struct HTMLVideoElement { diff --git a/components/script/dom/medialist.rs b/components/script/dom/medialist.rs index f2a2299d169..514bccecc4a 100644 --- a/components/script/dom/medialist.rs +++ b/components/script/dom/medialist.rs @@ -12,11 +12,11 @@ use dom::bindings::str::DOMString; use dom::cssstylesheet::CSSStyleSheet; use dom::window::Window; use dom_struct::dom_struct; -use std::sync::Arc; use style::media_queries::{MediaQuery, parse_media_query_list}; use style::media_queries::MediaList as StyleMediaList; use style::parser::{LengthParsingMode, ParserContext}; use style::shared_lock::{SharedRwLock, Locked}; +use style::stylearc::Arc; use style::stylesheets::CssRuleType; use style_traits::ToCss; diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs index 273b87c8d00..9d92bf11c2d 100644 --- a/components/script/dom/namednodemap.rs +++ b/components/script/dom/namednodemap.rs @@ -14,7 +14,7 @@ use dom::bindings::xmlname::namespace_from_domstring; use dom::element::Element; use dom::window::Window; use dom_struct::dom_struct; -use html5ever_atoms::LocalName; +use html5ever::LocalName; use std::ascii::AsciiExt; #[dom_struct] diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 0384c4ed19d..6f65faaed07 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -58,7 +58,7 @@ use euclid::point::Point2D; use euclid::rect::Rect; use euclid::size::Size2D; use heapsize::{HeapSizeOf, heap_size_of}; -use html5ever_atoms::{Prefix, Namespace, QualName}; +use html5ever::{Prefix, Namespace, QualName}; use js::jsapi::{JSContext, JSObject, JSRuntime}; use libc::{self, c_void, uintptr_t}; use msg::constellation_msg::PipelineId; @@ -78,10 +78,10 @@ use std::default::Default; use std::iter; use std::mem; use std::ops::Range; -use std::sync::Arc; use style::context::QuirksMode; use style::dom::OpaqueNode; use style::selector_parser::{SelectorImpl, SelectorParser}; +use style::stylearc::Arc; use style::stylesheets::Stylesheet; use style::thread_state; use uuid::Uuid; @@ -1749,11 +1749,11 @@ impl Node { NodeTypeId::Element(..) => { let element = node.downcast::<Element>().unwrap(); let name = QualName { + prefix: element.prefix().map(|p| Prefix::from(&**p)), ns: element.namespace().clone(), local: element.local_name().clone() }; let element = Element::create(name, - element.prefix().map(|p| Prefix::from(&**p)), &document, ElementCreator::ScriptCreated); Root::upcast::<Node>(element) }, diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs index 6142dba20f6..f25e95507e4 100644 --- a/components/script/dom/servoparser/html.rs +++ b/components/script/dom/servoparser/html.rs @@ -5,38 +5,28 @@ #![allow(unrooted_must_root)] use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; -use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::inheritance::{Castable, CharacterDataTypeId, NodeTypeId}; use dom::bindings::js::{JS, Root}; -use dom::bindings::str::DOMString; use dom::bindings::trace::JSTraceable; use dom::characterdata::CharacterData; -use dom::comment::Comment; use dom::document::Document; use dom::documenttype::DocumentType; -use dom::element::{Element, ElementCreator}; -use dom::htmlformelement::{FormControlElementHelpers, HTMLFormElement}; +use dom::element::Element; use dom::htmlscriptelement::HTMLScriptElement; use dom::htmltemplateelement::HTMLTemplateElement; use dom::node::Node; use dom::processinginstruction::ProcessingInstruction; -use dom::virtualmethods::vtable_for; -use html5ever::Attribute; +use dom::servoparser::Sink; use html5ever::QualName; -use html5ever::serialize::{AttrRef, Serializable, Serializer}; +use html5ever::buffer_queue::BufferQueue; +use html5ever::serialize::{AttrRef, Serialize, Serializer}; use html5ever::serialize::TraversalScope; use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; -use html5ever::tendril::StrTendril; use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts, TokenizerResult}; -use html5ever::tokenizer::buffer_queue::BufferQueue; -use html5ever::tree_builder::{NodeOrText, QuirksMode}; -use html5ever::tree_builder::{Tracer as HtmlTracer, TreeBuilder, TreeBuilderOpts, TreeSink}; +use html5ever::tree_builder::{Tracer as HtmlTracer, TreeBuilder, TreeBuilderOpts}; use js::jsapi::JSTracer; use servo_url::ServoUrl; -use std::ascii::AsciiExt; -use std::borrow::Cow; -use std::io::{self, Write}; -use style::context::QuirksMode as ServoQuirksMode; +use std::io; #[derive(HeapSizeOf, JSTraceable)] #[must_root] @@ -55,6 +45,7 @@ impl Tokenizer { base_url: url, document: JS::from_ref(document), current_line: 1, + script: Default::default(), }; let options = TreeBuilderOpts { @@ -124,179 +115,18 @@ unsafe impl JSTraceable for HtmlTokenizer<TreeBuilder<JS<Node>, Sink>> { } } -#[derive(JSTraceable, HeapSizeOf)] -#[must_root] -struct Sink { - base_url: ServoUrl, - document: JS<Document>, - current_line: u64, -} - -impl TreeSink for Sink { - type Output = Self; - fn finish(self) -> Self { self } - - type Handle = JS<Node>; - - fn get_document(&mut self) -> JS<Node> { - JS::from_ref(self.document.upcast()) - } - - fn get_template_contents(&mut self, target: JS<Node>) -> JS<Node> { - let template = target.downcast::<HTMLTemplateElement>() - .expect("tried to get template contents of non-HTMLTemplateElement in HTML parsing"); - JS::from_ref(template.Content().upcast()) - } - - fn same_node(&self, x: JS<Node>, y: JS<Node>) -> bool { - x == y - } - - fn elem_name(&self, target: JS<Node>) -> QualName { - let elem = target.downcast::<Element>() - .expect("tried to get name of non-Element in HTML parsing"); - QualName { - ns: elem.namespace().clone(), - local: elem.local_name().clone(), - } - } - - fn same_tree(&self, x: JS<Node>, y: JS<Node>) -> bool { - let x = x.downcast::<Element>().expect("Element node expected"); - let y = y.downcast::<Element>().expect("Element node expected"); - - x.is_in_same_home_subtree(y) - } - - fn create_element(&mut self, name: QualName, attrs: Vec<Attribute>) - -> JS<Node> { - let elem = Element::create(name, None, &*self.document, - ElementCreator::ParserCreated(self.current_line)); - - for attr in attrs { - elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None); - } - - JS::from_ref(elem.upcast()) - } - - fn create_comment(&mut self, text: StrTendril) -> JS<Node> { - let comment = Comment::new(DOMString::from(String::from(text)), &*self.document); - JS::from_ref(comment.upcast()) - } - - fn has_parent_node(&self, node: JS<Node>) -> bool { - node.GetParentNode().is_some() - } - - fn associate_with_form(&mut self, target: JS<Node>, form: JS<Node>) { - let node = target; - let form = Root::downcast::<HTMLFormElement>(Root::from_ref(&*form)) - .expect("Owner must be a form element"); - - let elem = node.downcast::<Element>(); - let control = elem.as_ref().and_then(|e| e.as_maybe_form_control()); - - if let Some(control) = control { - control.set_form_owner_from_parser(&form); - } else { - // TODO remove this code when keygen is implemented. - assert!(node.NodeName() == "KEYGEN", "Unknown form-associatable element"); - } - } - - fn append_before_sibling(&mut self, - sibling: JS<Node>, - new_node: NodeOrText<JS<Node>>) { - let parent = sibling.GetParentNode() - .expect("append_before_sibling called on node without parent"); - - super::insert(&parent, Some(&*sibling), new_node); - } - - fn parse_error(&mut self, msg: Cow<'static, str>) { - debug!("Parse error: {}", msg); - } - - fn set_quirks_mode(&mut self, mode: QuirksMode) { - let mode = match mode { - QuirksMode::Quirks => ServoQuirksMode::Quirks, - QuirksMode::LimitedQuirks => ServoQuirksMode::LimitedQuirks, - QuirksMode::NoQuirks => ServoQuirksMode::NoQuirks, - }; - self.document.set_quirks_mode(mode); - } - - fn append(&mut self, parent: JS<Node>, child: NodeOrText<JS<Node>>) { - super::insert(&parent, None, child); - } - - fn append_doctype_to_document(&mut self, name: StrTendril, public_id: StrTendril, - system_id: StrTendril) { - let doc = &*self.document; - let doctype = DocumentType::new( - DOMString::from(String::from(name)), Some(DOMString::from(String::from(public_id))), - Some(DOMString::from(String::from(system_id))), doc); - doc.upcast::<Node>().AppendChild(doctype.upcast()).expect("Appending failed"); - } - - fn add_attrs_if_missing(&mut self, target: JS<Node>, attrs: Vec<Attribute>) { - let elem = target.downcast::<Element>() - .expect("tried to set attrs on non-Element in HTML parsing"); - for attr in attrs { - elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None); - } - } - - fn remove_from_parent(&mut self, target: JS<Node>) { - if let Some(ref parent) = target.GetParentNode() { - parent.RemoveChild(&*target).unwrap(); - } - } - - fn mark_script_already_started(&mut self, node: JS<Node>) { - let script = node.downcast::<HTMLScriptElement>(); - script.map(|script| script.set_already_started(true)); - } - - fn reparent_children(&mut self, node: JS<Node>, new_parent: JS<Node>) { - while let Some(ref child) = node.GetFirstChild() { - new_parent.AppendChild(&child).unwrap(); - } - } - - /// https://html.spec.whatwg.org/multipage/#html-integration-point - /// Specifically, the <annotation-xml> cases. - fn is_mathml_annotation_xml_integration_point(&self, handle: JS<Node>) -> bool { - let elem = handle.downcast::<Element>().unwrap(); - elem.get_attribute(&ns!(), &local_name!("encoding")).map_or(false, |attr| { - attr.value().eq_ignore_ascii_case("text/html") - || attr.value().eq_ignore_ascii_case("application/xhtml+xml") - }) - } - - fn set_current_line(&mut self, line_number: u64) { - self.current_line = line_number; - } - - fn pop(&mut self, node: JS<Node>) { - let node = Root::from_ref(&*node); - vtable_for(&node).pop(); - } -} - -impl<'a> Serializable for &'a Node { - fn serialize<'wr, Wr: Write>(&self, serializer: &mut Serializer<'wr, Wr>, - traversal_scope: TraversalScope) -> io::Result<()> { +impl<'a> Serialize for &'a Node { + fn serialize<S: Serializer>(&self, serializer: &mut S, + traversal_scope: TraversalScope) -> io::Result<()> { let node = *self; match (traversal_scope, node.type_id()) { (_, NodeTypeId::Element(..)) => { let elem = node.downcast::<Element>().unwrap(); - let name = QualName::new(elem.namespace().clone(), + let name = QualName::new(None, elem.namespace().clone(), elem.local_name().clone()); if traversal_scope == IncludeNode { let attrs = elem.attrs().iter().map(|attr| { - let qname = QualName::new(attr.namespace().clone(), + let qname = QualName::new(None, attr.namespace().clone(), attr.local_name().clone()); let value = attr.value().clone(); (qname, value) diff --git a/components/script/dom/servoparser/mod.rs b/components/script/dom/servoparser/mod.rs index 3904910d3a3..39c199a34f7 100644 --- a/components/script/dom/servoparser/mod.rs +++ b/components/script/dom/servoparser/mod.rs @@ -6,27 +6,35 @@ use document_loader::{DocumentLoader, LoadType}; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState}; use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods; +use dom::bindings::codegen::Bindings::HTMLTemplateElementBinding::HTMLTemplateElementMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::ServoParserBinding; use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, Root, RootedReference}; +use dom::bindings::js::{JS, MutNullableJS, Root, RootedReference}; use dom::bindings::refcounted::Trusted; use dom::bindings::reflector::{Reflector, reflect_dom_object}; use dom::bindings::str::DOMString; use dom::characterdata::CharacterData; +use dom::comment::Comment; use dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument}; -use dom::element::Element; +use dom::documenttype::DocumentType; +use dom::element::{Element, ElementCreator}; use dom::globalscope::GlobalScope; -use dom::htmlformelement::HTMLFormElement; +use dom::htmlformelement::{FormControlElementHelpers, HTMLFormElement}; use dom::htmlimageelement::HTMLImageElement; use dom::htmlscriptelement::{HTMLScriptElement, ScriptResult}; +use dom::htmltemplateelement::HTMLTemplateElement; use dom::node::{Node, NodeSiblingIterator}; +use dom::processinginstruction::ProcessingInstruction; use dom::text::Text; +use dom::virtualmethods::vtable_for; use dom_struct::dom_struct; use encoding::all::UTF_8; use encoding::types::{DecoderTrap, Encoding}; -use html5ever::tokenizer::buffer_queue::BufferQueue; -use html5ever::tree_builder::NodeOrText; +use html5ever::{Attribute, QualName, ExpandedName}; +use html5ever::buffer_queue::BufferQueue; +use html5ever::tendril::StrTendril; +use html5ever::tree_builder::{NodeOrText, TreeSink, NextParserState, QuirksMode, ElementFlags}; use hyper::header::ContentType; use hyper::mime::{Mime, SubLevel, TopLevel}; use hyper_serde::Serde; @@ -40,8 +48,10 @@ use script_traits::DocumentActivity; use servo_config::resource_files::read_resource_file; use servo_url::ServoUrl; use std::ascii::AsciiExt; +use std::borrow::Cow; use std::cell::Cell; use std::mem; +use style::context::QuirksMode as ServoQuirksMode; mod html; mod xml; @@ -671,3 +681,183 @@ fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<JS<No }, } } + +#[derive(JSTraceable, HeapSizeOf)] +#[must_root] +pub struct Sink { + base_url: ServoUrl, + document: JS<Document>, + current_line: u64, + script: MutNullableJS<HTMLScriptElement>, +} + +#[allow(unrooted_must_root)] // FIXME: really? +impl TreeSink for Sink { + type Output = Self; + fn finish(self) -> Self { self } + + type Handle = JS<Node>; + + fn get_document(&mut self) -> JS<Node> { + JS::from_ref(self.document.upcast()) + } + + fn get_template_contents(&mut self, target: &JS<Node>) -> JS<Node> { + let template = target.downcast::<HTMLTemplateElement>() + .expect("tried to get template contents of non-HTMLTemplateElement in HTML parsing"); + JS::from_ref(template.Content().upcast()) + } + + fn same_node(&self, x: &JS<Node>, y: &JS<Node>) -> bool { + x == y + } + + fn elem_name<'a>(&self, target: &'a JS<Node>) -> ExpandedName<'a> { + let elem = target.downcast::<Element>() + .expect("tried to get name of non-Element in HTML parsing"); + ExpandedName { + ns: elem.namespace(), + local: elem.local_name(), + } + } + + fn same_tree(&self, x: &JS<Node>, y: &JS<Node>) -> bool { + let x = x.downcast::<Element>().expect("Element node expected"); + let y = y.downcast::<Element>().expect("Element node expected"); + + x.is_in_same_home_subtree(y) + } + + fn create_element(&mut self, name: QualName, attrs: Vec<Attribute>, _flags: ElementFlags) + -> JS<Node> { + let elem = Element::create(name, &*self.document, + ElementCreator::ParserCreated(self.current_line)); + + for attr in attrs { + elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None); + } + + JS::from_ref(elem.upcast()) + } + + fn create_comment(&mut self, text: StrTendril) -> JS<Node> { + let comment = Comment::new(DOMString::from(String::from(text)), &*self.document); + JS::from_ref(comment.upcast()) + } + + fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> JS<Node> { + let doc = &*self.document; + let pi = ProcessingInstruction::new( + DOMString::from(String::from(target)), DOMString::from(String::from(data)), + doc); + JS::from_ref(pi.upcast()) + } + + fn has_parent_node(&self, node: &JS<Node>) -> bool { + node.GetParentNode().is_some() + } + + fn associate_with_form(&mut self, target: &JS<Node>, form: &JS<Node>) { + let node = target; + let form = Root::downcast::<HTMLFormElement>(Root::from_ref(&**form)) + .expect("Owner must be a form element"); + + let elem = node.downcast::<Element>(); + let control = elem.and_then(|e| e.as_maybe_form_control()); + + if let Some(control) = control { + control.set_form_owner_from_parser(&form); + } else { + // TODO remove this code when keygen is implemented. + assert!(node.NodeName() == "KEYGEN", "Unknown form-associatable element"); + } + } + + fn append_before_sibling(&mut self, + sibling: &JS<Node>, + new_node: NodeOrText<JS<Node>>) { + let parent = sibling.GetParentNode() + .expect("append_before_sibling called on node without parent"); + + insert(&parent, Some(&*sibling), new_node); + } + + fn parse_error(&mut self, msg: Cow<'static, str>) { + debug!("Parse error: {}", msg); + } + + fn set_quirks_mode(&mut self, mode: QuirksMode) { + let mode = match mode { + QuirksMode::Quirks => ServoQuirksMode::Quirks, + QuirksMode::LimitedQuirks => ServoQuirksMode::LimitedQuirks, + QuirksMode::NoQuirks => ServoQuirksMode::NoQuirks, + }; + self.document.set_quirks_mode(mode); + } + + fn append(&mut self, parent: &JS<Node>, child: NodeOrText<JS<Node>>) { + insert(&parent, None, child); + } + + fn append_doctype_to_document(&mut self, name: StrTendril, public_id: StrTendril, + system_id: StrTendril) { + let doc = &*self.document; + let doctype = DocumentType::new( + DOMString::from(String::from(name)), Some(DOMString::from(String::from(public_id))), + Some(DOMString::from(String::from(system_id))), doc); + doc.upcast::<Node>().AppendChild(doctype.upcast()).expect("Appending failed"); + } + + fn add_attrs_if_missing(&mut self, target: &JS<Node>, attrs: Vec<Attribute>) { + let elem = target.downcast::<Element>() + .expect("tried to set attrs on non-Element in HTML parsing"); + for attr in attrs { + elem.set_attribute_from_parser(attr.name, DOMString::from(String::from(attr.value)), None); + } + } + + fn remove_from_parent(&mut self, target: &JS<Node>) { + if let Some(ref parent) = target.GetParentNode() { + parent.RemoveChild(&*target).unwrap(); + } + } + + fn mark_script_already_started(&mut self, node: &JS<Node>) { + let script = node.downcast::<HTMLScriptElement>(); + script.map(|script| script.set_already_started(true)); + } + + fn complete_script(&mut self, node: &JS<Node>) -> NextParserState { + if let Some(script) = node.downcast() { + self.script.set(Some(script)); + NextParserState::Suspend + } else { + NextParserState::Continue + } + } + + fn reparent_children(&mut self, node: &JS<Node>, new_parent: &JS<Node>) { + while let Some(ref child) = node.GetFirstChild() { + new_parent.AppendChild(&child).unwrap(); + } + } + + /// https://html.spec.whatwg.org/multipage/#html-integration-point + /// Specifically, the <annotation-xml> cases. + fn is_mathml_annotation_xml_integration_point(&self, handle: &JS<Node>) -> bool { + let elem = handle.downcast::<Element>().unwrap(); + elem.get_attribute(&ns!(), &local_name!("encoding")).map_or(false, |attr| { + attr.value().eq_ignore_ascii_case("text/html") + || attr.value().eq_ignore_ascii_case("application/xhtml+xml") + }) + } + + fn set_current_line(&mut self, line_number: u64) { + self.current_line = line_number; + } + + fn pop(&mut self, node: &JS<Node>) { + let node = Root::from_ref(&**node); + vtable_for(&node).pop(); + } +} diff --git a/components/script/dom/servoparser/xml.rs b/components/script/dom/servoparser/xml.rs index 1ef5f882db0..da5e1987253 100644 --- a/components/script/dom/servoparser/xml.rs +++ b/components/script/dom/servoparser/xml.rs @@ -4,29 +4,17 @@ #![allow(unrooted_must_root)] -use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; -use dom::bindings::inheritance::Castable; -use dom::bindings::js::{JS, MutNullableJS, Root}; -use dom::bindings::str::DOMString; +use dom::bindings::js::{JS, Root}; use dom::bindings::trace::JSTraceable; -use dom::comment::Comment; use dom::document::Document; -use dom::documenttype::DocumentType; -use dom::element::{Element, ElementCreator}; use dom::htmlscriptelement::HTMLScriptElement; use dom::node::Node; -use dom::processinginstruction::ProcessingInstruction; -use dom::virtualmethods::vtable_for; -use html5ever::tokenizer::buffer_queue::BufferQueue; -use html5ever::tree_builder::{NodeOrText as H5eNodeOrText}; -use html5ever_atoms::{Prefix, QualName}; +use dom::servoparser::Sink; use js::jsapi::JSTracer; use servo_url::ServoUrl; -use std::borrow::Cow; -use xml5ever::tendril::StrTendril; -use xml5ever::tokenizer::{Attribute, QName, XmlTokenizer}; -use xml5ever::tree_builder::{NextParserState, NodeOrText}; -use xml5ever::tree_builder::{Tracer as XmlTracer, TreeSink, XmlTreeBuilder}; +use xml5ever::buffer_queue::BufferQueue; +use xml5ever::tokenizer::XmlTokenizer; +use xml5ever::tree_builder::{Tracer as XmlTracer, XmlTreeBuilder}; #[derive(HeapSizeOf, JSTraceable)] #[must_root] @@ -40,6 +28,7 @@ impl Tokenizer { let sink = Sink { base_url: url, document: JS::from_ref(document), + current_line: 1, script: Default::default(), }; @@ -86,7 +75,7 @@ unsafe impl JSTraceable for XmlTokenizer<XmlTreeBuilder<JS<Node>, Sink>> { impl XmlTracer for Tracer { type Handle = JS<Node>; #[allow(unrooted_must_root)] - fn trace_handle(&self, node: JS<Node>) { + fn trace_handle(&self, node: &JS<Node>) { unsafe { node.trace(self.0); } } } @@ -96,111 +85,3 @@ unsafe impl JSTraceable for XmlTokenizer<XmlTreeBuilder<JS<Node>, Sink>> { tree_builder.sink().trace(trc); } } - -#[derive(JSTraceable, HeapSizeOf)] -#[must_root] -struct Sink { - base_url: ServoUrl, - document: JS<Document>, - script: MutNullableJS<HTMLScriptElement>, -} - -impl TreeSink for Sink { - type Output = Self; - type Handle = JS<Node>; - - fn finish(self) -> Self { - self - } - - fn parse_error(&mut self, msg: Cow<'static, str>) { - debug!("Parse error: {}", msg); - } - - fn get_document(&mut self) -> JS<Node> { - JS::from_ref(self.document.upcast()) - } - - fn elem_name(&self, target: &JS<Node>) -> QName { - let elem = target.downcast::<Element>() - .expect("tried to get name of non-Element in XML parsing"); - QName { - prefix: elem.prefix().map_or(namespace_prefix!(""), |p| Prefix::from(&**p)), - namespace_url: elem.namespace().clone(), - local: elem.local_name().clone(), - } - } - - fn create_element(&mut self, name: QName, attrs: Vec<Attribute>) - -> JS<Node> { - let prefix = if name.prefix == namespace_prefix!("") { None } else { Some(name.prefix) }; - let name = QualName { - ns: name.namespace_url, - local: name.local, - }; - //TODO: Add ability to track lines to API of xml5ever - let elem = Element::create(name, prefix, &*self.document, - ElementCreator::ParserCreated(1)); - - for attr in attrs { - let name = QualName { - ns: attr.name.namespace_url, - local: attr.name.local, - }; - elem.set_attribute_from_parser(name, DOMString::from(String::from(attr.value)), None); - } - - JS::from_ref(elem.upcast()) - } - - fn create_comment(&mut self, text: StrTendril) -> JS<Node> { - let comment = Comment::new(DOMString::from(String::from(text)), &*self.document); - JS::from_ref(comment.upcast()) - } - - fn append(&mut self, parent: JS<Node>, child: NodeOrText<JS<Node>>) { - let child = match child { - NodeOrText::AppendNode(n) => H5eNodeOrText::AppendNode(n), - NodeOrText::AppendText(s) => H5eNodeOrText::AppendText(s), - }; - super::insert(&*parent, None, child); - } - - fn append_doctype_to_document(&mut self, name: StrTendril, public_id: StrTendril, - system_id: StrTendril) { - let doc = &*self.document; - let doctype = DocumentType::new( - DOMString::from(String::from(name)), Some(DOMString::from(String::from(public_id))), - Some(DOMString::from(String::from(system_id))), doc); - doc.upcast::<Node>().AppendChild(doctype.upcast()).expect("Appending failed"); - } - - fn create_pi(&mut self, target: StrTendril, data: StrTendril) -> JS<Node> { - let doc = &*self.document; - let pi = ProcessingInstruction::new( - DOMString::from(String::from(target)), DOMString::from(String::from(data)), - doc); - JS::from_ref(pi.upcast()) - } - - fn mark_script_already_started(&mut self, node: Self::Handle) { - let script = node.downcast::<HTMLScriptElement>(); - if let Some(script) = script { - script.set_already_started(true); - } - } - - fn complete_script(&mut self, node: Self::Handle) -> NextParserState { - if let Some(script) = node.downcast() { - self.script.set(Some(script)); - NextParserState::Suspend - } else { - NextParserState::Continue - } - } - - fn pop(&mut self, node: Self::Handle) { - let node = Root::from_ref(&*node); - vtable_for(&node).pop(); - } -} diff --git a/components/script/dom/svgelement.rs b/components/script/dom/svgelement.rs index 022b04232db..2be5b9613f2 100644 --- a/components/script/dom/svgelement.rs +++ b/components/script/dom/svgelement.rs @@ -7,7 +7,7 @@ use dom::document::Document; use dom::element::Element; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::element_state::ElementState; #[dom_struct] diff --git a/components/script/dom/svggraphicselement.rs b/components/script/dom/svggraphicselement.rs index a25c4b169f6..4e4f6fadf65 100644 --- a/components/script/dom/svggraphicselement.rs +++ b/components/script/dom/svggraphicselement.rs @@ -7,7 +7,7 @@ use dom::document::Document; use dom::svgelement::SVGElement; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use style::element_state::ElementState; #[dom_struct] diff --git a/components/script/dom/svgsvgelement.rs b/components/script/dom/svgsvgelement.rs index e94001b2d51..90a272885a0 100644 --- a/components/script/dom/svgsvgelement.rs +++ b/components/script/dom/svgsvgelement.rs @@ -13,7 +13,7 @@ use dom::node::Node; use dom::svggraphicselement::SVGGraphicsElement; use dom::virtualmethods::VirtualMethods; use dom_struct::dom_struct; -use html5ever_atoms::{LocalName, Prefix}; +use html5ever::{LocalName, Prefix}; use script_layout_interface::SVGSVGData; use style::attr::AttrValue; diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index 8ff47f9ced5..ecb4d2ee559 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -51,7 +51,7 @@ use dom::htmltextareaelement::HTMLTextAreaElement; use dom::htmltitleelement::HTMLTitleElement; use dom::node::{ChildrenMutation, CloneChildrenFlag, Node, UnbindContext}; use dom::svgsvgelement::SVGSVGElement; -use html5ever_atoms::LocalName; +use html5ever::LocalName; use style::attr::AttrValue; /// Trait to allow DOM nodes to opt-in to overriding (or adding to) common diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index 3ddb1d2b5c9..86059a2d7c6 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -42,7 +42,7 @@ use dom::node::{CAN_BE_FRAGMENTED, DIRTY_ON_VIEWPORT_SIZE_CHANGE, HAS_DIRTY_DESC use dom::node::{LayoutNodeHelpers, Node}; use dom::text::Text; use gfx_traits::ByteIndex; -use html5ever_atoms::{LocalName, Namespace}; +use html5ever::{LocalName, Namespace}; use msg::constellation_msg::PipelineId; use range::Range; use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress}; @@ -58,7 +58,6 @@ use std::fmt::Debug; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; use std::mem::transmute; -use std::sync::Arc; use std::sync::atomic::Ordering; use style; use style::attr::AttrValue; @@ -74,6 +73,7 @@ use style::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl}; use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocked}; use style::sink::Push; use style::str::is_whitespace; +use style::stylearc::Arc; use style::stylist::ApplicableDeclarationBlock; #[derive(Copy, Clone)] diff --git a/components/script/lib.rs b/components/script/lib.rs index 678603ee60f..c1bd886b927 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -48,8 +48,7 @@ extern crate fnv; extern crate gfx_traits; extern crate heapsize; #[macro_use] extern crate heapsize_derive; -extern crate html5ever; -#[macro_use] extern crate html5ever_atoms; +#[macro_use] extern crate html5ever; #[macro_use] extern crate hyper; extern crate hyper_serde; diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs index 14b8c385e39..3143d8b34ad 100644 --- a/components/script/stylesheet_loader.rs +++ b/components/script/stylesheet_loader.rs @@ -24,9 +24,10 @@ use net_traits::request::{CorsSettings, CredentialsMode, Destination, RequestIni use network_listener::{NetworkListener, PreInvoke}; use servo_url::ServoUrl; use std::mem; -use std::sync::{Arc, Mutex}; +use std::sync::Mutex; use style::media_queries::MediaList; use style::shared_lock::Locked as StyleLocked; +use style::stylearc::Arc; use style::stylesheets::{ImportRule, Stylesheet, Origin}; use style::stylesheets::StylesheetLoader as StyleStylesheetLoader; @@ -207,7 +208,7 @@ impl<'a> StylesheetLoader<'a> { let document = document_from_node(self.elem); let gen = self.elem.downcast::<HTMLLinkElement>() .map(HTMLLinkElement::get_request_generation_id); - let context = Arc::new(Mutex::new(StylesheetContext { + let context = ::std::sync::Arc::new(Mutex::new(StylesheetContext { elem: Trusted::new(&*self.elem), source: source, url: url.clone(), diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml index 2df1a3f3205..03bb0df8436 100644 --- a/components/script_layout_interface/Cargo.toml +++ b/components/script_layout_interface/Cargo.toml @@ -18,7 +18,7 @@ euclid = "0.11" gfx_traits = {path = "../gfx_traits"} heapsize = "0.3.0" heapsize_derive = "0.1" -html5ever-atoms = "0.3" +html5ever = "0.16" ipc-channel = "0.7" libc = "0.2" log = "0.3.5" diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs index 98375e6a05a..46d9bf2aadc 100644 --- a/components/script_layout_interface/lib.rs +++ b/components/script_layout_interface/lib.rs @@ -19,7 +19,7 @@ extern crate euclid; extern crate gfx_traits; extern crate heapsize; #[macro_use] extern crate heapsize_derive; -#[macro_use] extern crate html5ever_atoms; +#[macro_use] extern crate html5ever; extern crate ipc_channel; extern crate libc; #[macro_use] diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index b94b6cd8d14..8b04a131404 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -25,7 +25,7 @@ use style::stylesheets::Stylesheet; /// Asynchronous messages that script can send to layout. pub enum Msg { /// Adds the given stylesheet to the document. - AddStylesheet(Arc<Stylesheet>), + AddStylesheet(::style::stylearc::Arc<Stylesheet>), /// Change the quirks mode. SetQuirksMode(QuirksMode), @@ -116,7 +116,7 @@ pub struct ScriptReflow { /// The document node. pub document: TrustedNodeAddress, /// The document's list of stylesheets. - pub document_stylesheets: Vec<Arc<Stylesheet>>, + pub document_stylesheets: Vec<::style::stylearc::Arc<Stylesheet>>, /// Whether the document's stylesheets have changed since the last script reflow. pub stylesheets_changed: bool, /// The current window size. diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index 4abc74bcac0..e39d27614c5 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -10,12 +10,11 @@ use OpaqueStyleAndLayoutData; use SVGSVGData; use atomic_refcell::AtomicRefCell; use gfx_traits::{ByteIndex, FragmentType, combine_id_with_fragment_type}; -use html5ever_atoms::{Namespace, LocalName}; +use html5ever::{Namespace, LocalName}; use msg::constellation_msg::PipelineId; use range::Range; use servo_url::ServoUrl; use std::fmt::Debug; -use std::sync::Arc; use style::computed_values::display; use style::context::SharedStyleContext; use style::data::ElementData; @@ -24,6 +23,7 @@ use style::dom::OpaqueNode; use style::font_metrics::ServoMetricsProvider; use style::properties::{CascadeFlags, ServoComputedValues}; use style::selector_parser::{PseudoElement, PseudoElementCascadeType, SelectorImpl}; +use style::stylearc::Arc; use webrender_traits::ClipId; #[derive(Copy, PartialEq, Clone, Debug)] diff --git a/components/selectors/Cargo.toml b/components/selectors/Cargo.toml index 9e5e9df6f35..22ee4e526c2 100644 --- a/components/selectors/Cargo.toml +++ b/components/selectors/Cargo.toml @@ -14,6 +14,8 @@ license = "MPL-2.0" [lib] name = "selectors" path = "lib.rs" +# https://github.com/servo/servo/issues/16710 +doctest = false [dependencies] bitflags = "0.7" diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 3f1aa94f750..a7e262ec322 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -16,7 +16,7 @@ doctest = false gecko = ["nsstring_vendor", "rayon/unstable", "num_cpus"] use_bindgen = ["bindgen", "regex"] servo = ["serde/unstable", "serde", "serde_derive", "heapsize", "heapsize_derive", - "style_traits/servo", "servo_atoms", "servo_config", "html5ever-atoms", + "style_traits/servo", "servo_atoms", "servo_config", "html5ever", "cssparser/heapsize", "cssparser/serde", "encoding", "smallvec/heapsizeof", "rayon/unstable", "servo_url"] testing = [] @@ -35,7 +35,7 @@ euclid = "0.11" fnv = "1.0" heapsize = {version = "0.3.0", optional = true} heapsize_derive = {version = "0.1", optional = true} -html5ever-atoms = {version = "0.3", optional = true} +html5ever = {version = "0.16", optional = true} lazy_static = "0.2" log = "0.3" matches = "0.1" diff --git a/components/style/animation.rs b/components/style/animation.rs index 941db59cc85..0a4c7cab345 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -19,8 +19,8 @@ use properties::longhands::animation_iteration_count::single_value::computed_val use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState; use properties::longhands::transition_timing_function::single_value::computed_value::StartEnd; use properties::longhands::transition_timing_function::single_value::computed_value::T as TransitionTimingFunction; -use std::sync::Arc; use std::sync::mpsc::Sender; +use stylearc::Arc; use timer::Timer; use values::computed::Time; diff --git a/components/style/attr.rs b/components/style/attr.rs index 1989816329d..101810212b7 100644 --- a/components/style/attr.rs +++ b/components/style/attr.rs @@ -16,10 +16,10 @@ use servo_url::ServoUrl; use shared_lock::Locked; use std::ascii::AsciiExt; use std::str::FromStr; -use std::sync::Arc; use str::{HTML_SPACE_CHARACTERS, read_exponent, read_fraction}; use str::{read_numbers, split_commas, split_html_space_chars}; use str::str_join; +use stylearc::Arc; use values::specified::Length; // Duplicated from script::dom::values. diff --git a/components/style/context.rs b/components/style/context.rs index 581a7c12cd3..1cdd8c00636 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -27,8 +27,9 @@ use std::collections::HashMap; #[cfg(not(feature = "servo"))] use std::env; use std::fmt; use std::ops::Add; -use std::sync::{Arc, Mutex}; +use std::sync::Mutex; use std::sync::mpsc::Sender; +use stylearc::Arc; use stylist::Stylist; use thread_state; use time; diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 95e43b46fdf..071efade790 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -14,8 +14,8 @@ use std::ascii::AsciiExt; use std::borrow::Cow; use std::collections::{HashMap, HashSet}; use std::fmt; -use std::sync::Arc; use style_traits::ToCss; +use stylearc::Arc; /// A custom property name is just an `Atom`. /// diff --git a/components/style/data.rs b/components/style/data.rs index 4052f0b30a3..651f003e4e9 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -16,7 +16,7 @@ use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage, Snapshot use std::fmt; #[cfg(feature = "servo")] use std::hash::BuildHasherDefault; use std::ops::Deref; -use std::sync::Arc; +use stylearc::Arc; use stylist::Stylist; use thread_state; use traversal::TraversalFlags; diff --git a/components/style/dom.rs b/components/style/dom.rs index ffc46b0cc94..7a4fe5d1003 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -26,7 +26,7 @@ use std::fmt; use std::fmt::Debug; use std::hash::Hash; use std::ops::Deref; -use std::sync::Arc; +use stylearc::Arc; use stylist::ApplicableDeclarationBlock; use thread_state; diff --git a/components/style/encoding_support.rs b/components/style/encoding_support.rs index 2775de54893..92620378b30 100644 --- a/components/style/encoding_support.rs +++ b/components/style/encoding_support.rs @@ -13,7 +13,7 @@ use media_queries::MediaList; use self::encoding::{EncodingRef, DecoderTrap}; use shared_lock::SharedRwLock; use std::str; -use std::sync::Arc; +use stylearc::Arc; use stylesheets::{Stylesheet, StylesheetLoader, Origin, UrlExtraData}; struct RustEncoding; diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index 7efad2a9fbe..2e1e17a2ebc 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -15,10 +15,10 @@ use parking_lot::RwLock; use properties::ComputedValues; use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard}; use std::collections::HashMap; -use std::sync::Arc; use std::sync::mpsc::{Receiver, Sender, channel}; +use stylearc::Arc; use stylesheet_set::StylesheetSet; -use stylesheets::{FontFaceRule, Origin}; +use stylesheets::{FontFaceRule, Origin, Stylesheet}; use stylist::{ExtraStyleData, Stylist}; /// The container for data that a Servo-backed Gecko document needs to style @@ -106,8 +106,9 @@ impl PerDocumentStyleDataImpl { }; let author_style_disabled = self.stylesheets.author_style_disabled(); - let stylesheets = self.stylesheets.flush(); - stylist.update(stylesheets, + let mut stylesheets = Vec::<Arc<Stylesheet>>::new(); + self.stylesheets.flush(&mut stylesheets); + stylist.update(stylesheets.as_slice(), &StylesheetGuards::same(guard), /* ua_sheets = */ None, /* stylesheets_changed = */ true, diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index a0aeaec2e5c..2444338f174 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -18,11 +18,11 @@ use media_queries::MediaType; use parser::ParserContext; use properties::{ComputedValues, StyleBuilder}; use std::fmt::{self, Write}; -use std::sync::Arc; use str::starts_with_ignore_ascii_case; use string_cache::Atom; use style_traits::ToCss; use style_traits::viewport::ViewportConstraints; +use stylearc::Arc; use values::{CSSFloat, specified}; use values::computed::{self, ToComputedValue}; diff --git a/components/style/gecko/restyle_damage.rs b/components/style/gecko/restyle_damage.rs index 4d6c1269eb8..39fdafebd5d 100644 --- a/components/style/gecko/restyle_damage.rs +++ b/components/style/gecko/restyle_damage.rs @@ -10,7 +10,7 @@ use gecko_bindings::structs::{nsChangeHint, nsStyleContext}; use gecko_bindings::sugar::ownership::FFIArcHelpers; use properties::ComputedValues; use std::ops::{BitAnd, BitOr, BitOrAssign, Not}; -use std::sync::Arc; +use stylearc::Arc; /// The representation of Gecko's restyle damage is just a wrapper over /// `nsChangeHint`. diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index 286094bcb0e..191ae082726 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -10,8 +10,8 @@ use gecko_bindings::sugar::refptr::RefPtr; use parser::ParserContext; use std::borrow::Cow; use std::fmt::{self, Write}; -use std::sync::Arc; use style_traits::ToCss; +use stylearc::Arc; /// A specified url() value for gecko. Gecko does not eagerly resolve SpecifiedUrls. #[derive(Clone, Debug, PartialEq)] diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 100830c0e0d..f71ef0a6c9c 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -71,8 +71,8 @@ use std::collections::HashMap; use std::fmt; use std::hash::{Hash, Hasher}; use std::ptr; -use std::sync::Arc; use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; +use stylearc::Arc; use stylesheets::UrlExtraData; use stylist::ApplicableDeclarationBlock; diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 36075707b5b..4099761c6c3 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -1075,10 +1075,6 @@ extern "C" { -> nscoord; } extern "C" { - pub fn Gecko_GetAppUnitsPerPhysicalInch(pres_context: RawGeckoPresContextBorrowed) - -> i32; -} -extern "C" { pub fn Gecko_CSSValue_GetKeyword(aCSSValue: nsCSSValueBorrowed) -> nsCSSKeyword; } @@ -1173,6 +1169,11 @@ extern "C" { -> GeckoFontMetrics; } extern "C" { + pub fn Gecko_GetAppUnitsPerPhysicalInch(pres_context: + RawGeckoPresContextBorrowed) + -> i32; +} +extern "C" { pub fn Gecko_GetMediaFeatures() -> *const nsMediaFeature; } extern "C" { @@ -1574,16 +1575,18 @@ extern "C" { extern "C" { pub fn Servo_StyleSet_AppendStyleSheet(set: RawServoStyleSetBorrowed, sheet: RawServoStyleSheetBorrowed, + unique_id: u32, flush: bool); } extern "C" { pub fn Servo_StyleSet_PrependStyleSheet(set: RawServoStyleSetBorrowed, sheet: RawServoStyleSheetBorrowed, + unique_id: u32, flush: bool); } extern "C" { pub fn Servo_StyleSet_RemoveStyleSheet(set: RawServoStyleSetBorrowed, - sheet: RawServoStyleSheetBorrowed, + unique_id: u32, flush: bool); } extern "C" { @@ -1591,8 +1594,8 @@ extern "C" { RawServoStyleSetBorrowed, sheet: RawServoStyleSheetBorrowed, - reference: - RawServoStyleSheetBorrowed, + unique_id: u32, + before_unique_id: u32, flush: bool); } extern "C" { @@ -1854,6 +1857,15 @@ extern "C" { -> RawServoDeclarationBlockStrong; } extern "C" { + pub fn Servo_AnimationValue_Compute(declarations: + RawServoDeclarationBlockBorrowed, + style: ServoComputedValuesBorrowed, + parent_style: + ServoComputedValuesBorrowedOrNull, + raw_data: RawServoStyleSetBorrowed) + -> RawServoAnimationValueStrong; +} +extern "C" { pub fn Servo_ParseStyleAttribute(data: *const nsACString, extra_data: *mut RawGeckoURLExtraData) -> RawServoDeclarationBlockStrong; diff --git a/components/style/gecko_bindings/sugar/ownership.rs b/components/style/gecko_bindings/sugar/ownership.rs index abcf5c65a8a..6c4746013b3 100644 --- a/components/style/gecko_bindings/sugar/ownership.rs +++ b/components/style/gecko_bindings/sugar/ownership.rs @@ -8,7 +8,7 @@ use std::marker::PhantomData; use std::mem::{forget, transmute}; use std::ops::{Deref, DerefMut}; use std::ptr; -use std::sync::Arc; +use stylearc::Arc; /// Indicates that a given Servo type has a corresponding Gecko FFI type. pub unsafe trait HasFFI : Sized { diff --git a/components/style/gecko_bindings/sugar/refptr.rs b/components/style/gecko_bindings/sugar/refptr.rs index 3c3dec9aee3..9ca1d3dc7b6 100644 --- a/components/style/gecko_bindings/sugar/refptr.rs +++ b/components/style/gecko_bindings/sugar/refptr.rs @@ -9,7 +9,7 @@ use gecko_bindings::sugar::ownership::HasArcFFI; use std::{mem, ptr}; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; -use std::sync::Arc; +use stylearc::Arc; /// Trait for all objects that have Addref() and Release /// methods and can be placed inside RefPtr<T> diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index 8113c06bb6c..3a80320bb52 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -17,8 +17,8 @@ use properties::animated_properties::TransitionProperty; use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction; use shared_lock::{SharedRwLock, SharedRwLockReadGuard, Locked, ToCssWithGuard}; use std::fmt; -use std::sync::Arc; use style_traits::ToCss; +use stylearc::Arc; use stylesheets::{CssRuleType, Stylesheet, VendorPrefix}; /// A number from 0 to 1, indicating the percentage of the animation when this diff --git a/components/style/lib.rs b/components/style/lib.rs index 7479279418d..8a21e15d648 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -50,7 +50,7 @@ extern crate fnv; #[cfg(feature = "gecko")] #[macro_use] pub mod gecko_string_cache; #[cfg(feature = "servo")] extern crate heapsize; #[cfg(feature = "servo")] #[macro_use] extern crate heapsize_derive; -#[cfg(feature = "servo")] #[macro_use] extern crate html5ever_atoms; +#[cfg(feature = "servo")] #[macro_use] extern crate html5ever; #[macro_use] extern crate lazy_static; #[macro_use] @@ -70,6 +70,7 @@ extern crate pdqsort; #[cfg(feature = "gecko")] extern crate precomputed_hash; extern crate rayon; extern crate selectors; +#[cfg(feature = "servo")] extern crate serde; #[cfg(feature = "servo")] #[macro_use] extern crate serde_derive; #[cfg(feature = "servo")] #[macro_use] extern crate servo_atoms; #[cfg(feature = "servo")] extern crate servo_config; @@ -118,6 +119,7 @@ pub mod sequential; pub mod sink; pub mod str; pub mod style_adjuster; +pub mod stylearc; pub mod stylesheet_set; pub mod stylesheets; pub mod supports; @@ -130,7 +132,6 @@ pub mod values; pub mod viewport; use std::fmt; -use std::sync::Arc; use style_traits::ToCss; #[cfg(feature = "gecko")] pub use gecko_string_cache as string_cache; @@ -140,9 +141,9 @@ use style_traits::ToCss; #[cfg(feature = "gecko")] pub use gecko_string_cache::Atom as LocalName; #[cfg(feature = "servo")] pub use servo_atoms::Atom; -#[cfg(feature = "servo")] pub use html5ever_atoms::Prefix; -#[cfg(feature = "servo")] pub use html5ever_atoms::LocalName; -#[cfg(feature = "servo")] pub use html5ever_atoms::Namespace; +#[cfg(feature = "servo")] pub use html5ever::Prefix; +#[cfg(feature = "servo")] pub use html5ever::LocalName; +#[cfg(feature = "servo")] pub use html5ever::Namespace; /// The CSS properties supported by the style system. /// Generated from the properties.mako.rs template by build.rs @@ -175,14 +176,6 @@ macro_rules! reexport_computed_values { } longhand_properties_idents!(reexport_computed_values); -/// Returns whether the two arguments point to the same value. -/// -/// FIXME: Remove this and use Arc::ptr_eq once we require Rust 1.17 -#[inline] -pub fn arc_ptr_eq<T: 'static>(a: &Arc<T>, b: &Arc<T>) -> bool { - ptr_eq::<T>(&**a, &**b) -} - /// Pointer equality /// /// FIXME: Remove this and use std::ptr::eq once we require Rust 1.17 diff --git a/components/style/matching.rs b/components/style/matching.rs index ca2db43c4b9..8da1192d4d3 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -27,7 +27,7 @@ use selectors::bloom::BloomFilter; use selectors::matching::{ElementSelectorFlags, StyleRelations}; use selectors::matching::AFFECTED_BY_PSEUDO_ELEMENTS; use sink::ForgetfulSink; -use std::sync::Arc; +use stylearc::Arc; use stylist::ApplicableDeclarationBlock; /// The way a style should be inherited. @@ -120,8 +120,8 @@ fn same_computed_values<E: TElement>(first: Option<E>, second: Option<E>) -> boo _ => return false, }; - let eq = ::arc_ptr_eq(a.borrow_data().unwrap().styles().primary.values(), - b.borrow_data().unwrap().styles().primary.values()); + let eq = Arc::ptr_eq(a.borrow_data().unwrap().styles().primary.values(), + b.borrow_data().unwrap().styles().primary.values()); eq } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 4643d176949..e6aab102506 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -61,7 +61,7 @@ use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarat use std::fmt::{self, Debug}; use std::mem::{forget, transmute, zeroed}; use std::ptr; -use std::sync::Arc; +use stylearc::Arc; use std::cmp; use values::computed::ToComputedValue; use values::{Either, Auto, KeyframesName}; @@ -1490,8 +1490,10 @@ fn static_assert() { /// This function will also handle scriptminsize and scriptlevel /// so should not be called when you just want the font sizes to be copied. /// Hence the different name. + /// + /// Returns true if the inherited keyword size was actually used pub fn inherit_font_size_from(&mut self, parent: &Self, - kw_inherited_size: Option<Au>) { + kw_inherited_size: Option<Au>) -> bool { let (adjusted_size, adjusted_unconstrained_size) = self.calculate_script_level_size(parent); if adjusted_size.0 != parent.gecko.mSize || @@ -1513,18 +1515,21 @@ fn static_assert() { self.gecko.mFont.size = adjusted_size.0; self.gecko.mSize = adjusted_size.0; self.gecko.mScriptUnconstrainedSize = adjusted_unconstrained_size.0; + false } else if let Some(size) = kw_inherited_size { // Parent element was a keyword-derived size. self.gecko.mFont.size = size.0; self.gecko.mSize = size.0; // MathML constraints didn't apply here, so we can ignore this. self.gecko.mScriptUnconstrainedSize = size.0; + true } else { // MathML isn't affecting us, and our parent element does not // have a keyword-derived size. Set things normally. self.gecko.mFont.size = parent.gecko.mFont.size; self.gecko.mSize = parent.gecko.mSize; self.gecko.mScriptUnconstrainedSize = parent.gecko.mScriptUnconstrainedSize; + false } } diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 4db19381e1f..3c3bb537320 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -252,7 +252,7 @@ use properties::{DeclaredValue, LonghandId, LonghandIdSet}; use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration}; use properties::style_structs; - use std::sync::Arc; + use stylearc::Arc; use values::computed::{Context, ToComputedValue}; use values::{computed, generics, specified}; use Atom; @@ -716,7 +716,7 @@ use properties::{PropertyDeclaration, ParsedDeclaration}; use properties::{ShorthandId, UnparsedValue, longhands}; use std::fmt; - use std::sync::Arc; + use stylearc::Arc; use style_traits::ToCss; pub struct Longhands { diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index e99b15dd9cf..842b3279d90 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -927,10 +927,14 @@ ${helpers.single_keyword_system("font-variant-caps", let kw_inherited_size = context.style().font_size_keyword.map(|(kw, ratio)| { SpecifiedValue::Keyword(kw, ratio).to_computed_value(context) }); - context.mutate_style().mutate_font() + let used_kw = context.mutate_style().mutate_font() .inherit_font_size_from(parent, kw_inherited_size); - context.mutate_style().font_size_keyword = - context.inherited_style.font_size_keyword; + if used_kw { + context.mutate_style().font_size_keyword = + context.inherited_style.font_size_keyword; + } else { + context.mutate_style().font_size_keyword = None; + } } pub fn cascade_initial_font_size(context: &mut Context) { diff --git a/components/style/properties/longhand/svg.mako.rs b/components/style/properties/longhand/svg.mako.rs index 7a764fbe9f5..45cb125bf33 100644 --- a/components/style/properties/longhand/svg.mako.rs +++ b/components/style/properties/longhand/svg.mako.rs @@ -197,7 +197,7 @@ ${helpers.single_keyword("mask-composite", spec="https://drafts.fxtf.org/css-masking/#propdef-mask-image"> use std::fmt; use style_traits::ToCss; - use std::sync::Arc; + use stylearc::Arc; use values::specified::Image; use values::specified::url::SpecifiedUrl; use values::HasViewportPercentage; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index aba24623855..b2a122adcbe 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -14,7 +14,7 @@ use std::borrow::Cow; use std::collections::HashSet; use std::fmt; use std::ops::Deref; -use std::sync::Arc; +use stylearc::Arc; use app_units::Au; #[cfg(feature = "servo")] use cssparser::{Color as CSSParserColor, RGBA}; @@ -178,7 +178,7 @@ pub mod shorthands { use cssparser::Parser; use parser::ParserContext; use properties::{ParsedDeclaration, ShorthandId, UnparsedValue}; - use std::sync::Arc; + use stylearc::Arc; pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<ParsedDeclaration, ()> { // This function is like the parse() that is generated by @@ -1569,8 +1569,9 @@ pub mod style_structs { /// (Servo does not handle MathML, so this just calls copy_font_size_from) pub fn inherit_font_size_from(&mut self, parent: &Self, - _: Option<Au>) { + _: Option<Au>) -> bool { self.copy_font_size_from(parent); + false } /// (Servo does not handle MathML, so this just calls set_font_size) pub fn apply_font_size(&mut self, @@ -2056,7 +2057,7 @@ pub enum StyleStructRef<'a, T: 'a> { /// A borrowed struct from the parent, for example, for inheriting style. Borrowed(&'a Arc<T>), /// An owned struct, that we've already mutated. - Owned(T), + Owned(Arc<T>), } impl<'a, T: 'a> StyleStructRef<'a, T> @@ -2066,11 +2067,11 @@ impl<'a, T: 'a> StyleStructRef<'a, T> /// borrowed value, or returning the owned one. pub fn mutate(&mut self) -> &mut T { if let StyleStructRef::Borrowed(v) = *self { - *self = StyleStructRef::Owned((**v).clone()); + *self = StyleStructRef::Owned(Arc::new((**v).clone())); } match *self { - StyleStructRef::Owned(ref mut v) => v, + StyleStructRef::Owned(ref mut v) => Arc::get_mut(v).unwrap(), StyleStructRef::Borrowed(..) => unreachable!(), } } @@ -2079,7 +2080,7 @@ impl<'a, T: 'a> StyleStructRef<'a, T> /// hasn't been mutated. pub fn get_if_mutated(&mut self) -> Option<<&mut T> { match *self { - StyleStructRef::Owned(ref mut v) => Some(v), + StyleStructRef::Owned(ref mut v) => Some(Arc::get_mut(v).unwrap()), StyleStructRef::Borrowed(..) => None, } } @@ -2088,7 +2089,7 @@ impl<'a, T: 'a> StyleStructRef<'a, T> /// appropriate. pub fn build(self) -> Arc<T> { match self { - StyleStructRef::Owned(v) => Arc::new(v), + StyleStructRef::Owned(v) => v, StyleStructRef::Borrowed(v) => v.clone(), } } @@ -2099,7 +2100,7 @@ impl<'a, T: 'a> Deref for StyleStructRef<'a, T> { fn deref(&self) -> &T { match *self { - StyleStructRef::Owned(ref v) => v, + StyleStructRef::Owned(ref v) => &**v, StyleStructRef::Borrowed(v) => &**v, } } @@ -2246,7 +2247,7 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES; #[allow(missing_docs)] mod lazy_static_module { use logical_geometry::WritingMode; - use std::sync::Arc; + use stylearc::Arc; use super::{ComputedValues, longhands, style_structs}; /// The initial values for all style structs as defined by the specification. diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs index 193b7e82a9d..0e7dcd19adc 100644 --- a/components/style/restyle_hints.rs +++ b/components/style/restyle_hints.rs @@ -431,8 +431,11 @@ fn combinator_to_restyle_hint(combinator: Option<Combinator>) -> RestyleHint { #[derive(Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -struct Sensitivities { +/// The aspects of an selector which are sensitive. +pub struct Sensitivities { + /// The states which are sensitive. pub states: ElementState, + /// Whether attributes are sensitive. pub attrs: bool, } @@ -469,11 +472,13 @@ impl Sensitivities { /// change may have on the style of elements in the document. #[derive(Debug)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -struct Dependency { +pub struct Dependency { #[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")] selector: SelectorInner<SelectorImpl>, - hint: RestyleHint, - sensitivities: Sensitivities, + /// The hint associated with this dependency. + pub hint: RestyleHint, + /// The sensitivities associated with this dependency. + pub sensitivities: Sensitivities, } @@ -681,27 +686,9 @@ impl DependencySet { } } } -} -#[test] -#[cfg(all(test, feature = "servo"))] -fn smoke_restyle_hints() { - use cssparser::Parser; - use selector_parser::SelectorParser; - use stylesheets::{Origin, Namespaces}; - let namespaces = Namespaces::default(); - let parser = SelectorParser { - stylesheet_origin: Origin::Author, - namespaces: &namespaces, - }; - - let mut dependencies = DependencySet::new(); - - let mut p = Parser::new(":not(:active) ~ label"); - let selector = ComplexSelector::parse(&parser, &mut p).unwrap(); - dependencies.note_selector(&selector); - assert_eq!(dependencies.len(), 1); - assert_eq!(dependencies.state_deps.len(), 1); - assert!(!dependencies.state_deps[0].sensitivities.states.is_empty()); - assert!(dependencies.state_deps[0].hint.contains(RESTYLE_LATER_SIBLINGS)); + /// Get the dependencies affected by state. + pub fn get_state_deps(&self) -> &[Dependency] { + &self.state_deps + } } diff --git a/components/style/rule_tree/mod.rs b/components/style/rule_tree/mod.rs index fa6acaa92b5..0947198e2da 100644 --- a/components/style/rule_tree/mod.rs +++ b/components/style/rule_tree/mod.rs @@ -6,15 +6,14 @@ //! The rule tree. -use arc_ptr_eq; #[cfg(feature = "servo")] use heapsize::HeapSizeOf; use properties::{Importance, PropertyDeclarationBlock}; use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard}; use std::io::{self, Write}; use std::ptr; -use std::sync::Arc; use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering}; +use stylearc::Arc; use stylesheets::StyleRule; use thread_state; @@ -65,8 +64,8 @@ impl StyleSource { fn ptr_equals(&self, other: &Self) -> bool { use self::StyleSource::*; match (self, other) { - (&Style(ref one), &Style(ref other)) => arc_ptr_eq(one, other), - (&Declarations(ref one), &Declarations(ref other)) => arc_ptr_eq(one, other), + (&Style(ref one), &Style(ref other)) => Arc::ptr_eq(one, other), + (&Declarations(ref one), &Declarations(ref other)) => Arc::ptr_eq(one, other), _ => false, } } @@ -203,7 +202,7 @@ impl RuleTree { // so let's skip it for now. let is_here_already = match current.get().source.as_ref() { Some(&StyleSource::Declarations(ref already_here)) => { - arc_ptr_eq(pdb, already_here) + Arc::ptr_eq(pdb, already_here) }, _ => unreachable!("Replacing non-declarations style?"), }; diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs index 0664483cbe7..0af60279af8 100644 --- a/components/style/selector_parser.rs +++ b/components/style/selector_parser.rs @@ -37,7 +37,7 @@ pub use gecko::restyle_damage::GeckoRestyleDamage as RestyleDamage; /// A type that represents the previous computed values needed for restyle /// damage calculation. #[cfg(feature = "servo")] -pub type PreExistingComputedValues = ::std::sync::Arc<::properties::ServoComputedValues>; +pub type PreExistingComputedValues = ::stylearc::Arc<::properties::ServoComputedValues>; /// A type that represents the previous computed values needed for restyle /// damage calculation. diff --git a/components/style/servo/restyle_damage.rs b/components/style/servo/restyle_damage.rs index 0ad934278c1..1fd7b38cae2 100644 --- a/components/style/servo/restyle_damage.rs +++ b/components/style/servo/restyle_damage.rs @@ -11,7 +11,7 @@ use computed_values::display; use heapsize::HeapSizeOf; use properties::ServoComputedValues; use std::fmt; -use std::sync::Arc; +use stylearc::Arc; bitflags! { #[doc = "Individual layout actions that may be necessary after restyling."] diff --git a/components/style/servo/url.rs b/components/style/servo/url.rs index c59c6bcb0b7..467f7a45715 100644 --- a/components/style/servo/url.rs +++ b/components/style/servo/url.rs @@ -9,6 +9,9 @@ use parser::ParserContext; use servo_url::ServoUrl; use std::borrow::Cow; use std::fmt::{self, Write}; +// Note: We use std::sync::Arc rather than stylearc::Arc here because the +// nonzero optimization is important in keeping the size of SpecifiedUrl below +// the threshold. use std::sync::Arc; use style_traits::ToCss; diff --git a/components/style/shared_lock.rs b/components/style/shared_lock.rs index 2dec153f342..360118d472e 100644 --- a/components/style/shared_lock.rs +++ b/components/style/shared_lock.rs @@ -10,7 +10,7 @@ use atomic_refcell::{AtomicRefCell, AtomicRef, AtomicRefMut}; use parking_lot::RwLock; use std::cell::UnsafeCell; use std::fmt; -use std::sync::Arc; +use stylearc::Arc; /// A shared read/write lock that can protect multiple objects. /// @@ -149,7 +149,7 @@ impl<T: fmt::Debug> fmt::Debug for Locked<T> { impl<T> Locked<T> { #[cfg(feature = "servo")] fn same_lock_as(&self, lock: &SharedRwLock) -> bool { - ::arc_ptr_eq(&self.shared_lock.arc, &lock.arc) + Arc::ptr_eq(&self.shared_lock.arc, &lock.arc) } #[cfg(feature = "gecko")] diff --git a/components/style/stylearc.rs b/components/style/stylearc.rs new file mode 100644 index 00000000000..01885dc481b --- /dev/null +++ b/components/style/stylearc.rs @@ -0,0 +1,380 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Fork of Arc for the style system. This has the following advantages over std::Arc: +//! * We don't waste storage on the weak reference count. +//! * We don't do extra RMU operations to handle the possibility of weak references. +//! * We can experiment with arena allocation (todo). +//! * We can add methods to support our custom use cases [1]. +//! +//! [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1360883 + +// The semantics of Arc are alread documented in the Rust docs, so we don't +// duplicate those here. +#![allow(missing_docs)] + +#[cfg(feature = "servo")] +use heapsize::HeapSizeOf; +#[cfg(feature = "servo")] +use serde::{Deserialize, Serialize}; +use std::{isize, usize}; +use std::borrow; +use std::cmp::Ordering; +use std::convert::From; +use std::fmt; +use std::hash::{Hash, Hasher}; +use std::mem; +use std::ops::Deref; +use std::sync::atomic; +use std::sync::atomic::Ordering::{Acquire, Relaxed, Release}; + +// Private macro to get the offset of a struct field in bytes from the address of the struct. +macro_rules! offset_of { + ($container:path, $field:ident) => {{ + // Make sure the field actually exists. This line ensures that a compile-time error is + // generated if $field is accessed through a Deref impl. + let $container { $field: _, .. }; + + // Create an (invalid) instance of the container and calculate the offset to its + // field. Using a null pointer might be UB if `&(*(0 as *const T)).field` is interpreted to + // be nullptr deref. + let invalid: $container = ::std::mem::uninitialized(); + let offset = &invalid.$field as *const _ as usize - &invalid as *const _ as usize; + + // Do not run destructors on the made up invalid instance. + ::std::mem::forget(invalid); + offset as isize + }}; +} + +/// A soft limit on the amount of references that may be made to an `Arc`. +/// +/// Going above this limit will abort your program (although not +/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references. +const MAX_REFCOUNT: usize = (isize::MAX) as usize; + +pub struct Arc<T: ?Sized> { + // FIXME(bholley): When NonZero/Shared/Unique are stabilized, we should use + // Shared here to get the NonZero optimization. Gankro is working on this. + // + // If we need a compact Option<Arc<T>> beforehand, we can make a helper + // class that wraps the result of Arc::into_raw. + // + // https://github.com/rust-lang/rust/issues/27730 + ptr: *mut ArcInner<T>, +} + +unsafe impl<T: ?Sized + Sync + Send> Send for Arc<T> {} +unsafe impl<T: ?Sized + Sync + Send> Sync for Arc<T> {} + +struct ArcInner<T: ?Sized> { + count: atomic::AtomicUsize, + data: T, +} + +unsafe impl<T: ?Sized + Sync + Send> Send for ArcInner<T> {} +unsafe impl<T: ?Sized + Sync + Send> Sync for ArcInner<T> {} + +impl<T> Arc<T> { + #[inline] + pub fn new(data: T) -> Self { + let x = Box::new(ArcInner { + count: atomic::AtomicUsize::new(1), + data: data, + }); + Arc { ptr: Box::into_raw(x) } + } + + pub fn into_raw(this: Self) -> *const T { + let ptr = unsafe { &((*this.ptr).data) as *const _ }; + mem::forget(this); + ptr + } + + pub unsafe fn from_raw(ptr: *const T) -> Self { + // To find the corresponding pointer to the `ArcInner` we need + // to subtract the offset of the `data` field from the pointer. + let ptr = (ptr as *const u8).offset(-offset_of!(ArcInner<T>, data)); + Arc { + ptr: ptr as *mut ArcInner<T>, + } + } +} + +impl<T: ?Sized> Arc<T> { + #[inline] + fn inner(&self) -> &ArcInner<T> { + // This unsafety is ok because while this arc is alive we're guaranteed + // that the inner pointer is valid. Furthermore, we know that the + // `ArcInner` structure itself is `Sync` because the inner data is + // `Sync` as well, so we're ok loaning out an immutable pointer to these + // contents. + unsafe { &*self.ptr } + } + + // Non-inlined part of `drop`. Just invokes the destructor. + #[inline(never)] + unsafe fn drop_slow(&mut self) { + let _ = Box::from_raw(self.ptr); + } + + + #[inline] + pub fn ptr_eq(this: &Self, other: &Self) -> bool { + this.ptr == other.ptr + } +} + +impl<T: ?Sized> Clone for Arc<T> { + #[inline] + fn clone(&self) -> Self { + // Using a relaxed ordering is alright here, as knowledge of the + // original reference prevents other threads from erroneously deleting + // the object. + // + // As explained in the [Boost documentation][1], Increasing the + // reference counter can always be done with memory_order_relaxed: New + // references to an object can only be formed from an existing + // reference, and passing an existing reference from one thread to + // another must already provide any required synchronization. + // + // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html) + let old_size = self.inner().count.fetch_add(1, Relaxed); + + // However we need to guard against massive refcounts in case someone + // is `mem::forget`ing Arcs. If we don't do this the count can overflow + // and users will use-after free. We racily saturate to `isize::MAX` on + // the assumption that there aren't ~2 billion threads incrementing + // the reference count at once. This branch will never be taken in + // any realistic program. + // + // We abort because such a program is incredibly degenerate, and we + // don't care to support it. + if old_size > MAX_REFCOUNT { + // Note: std::process::abort is stable in 1.17, which we don't yet + // require for Gecko. Panic is good enough in practice here (it will + // trigger an abort at least in Gecko, and this case is degenerate + // enough that Servo shouldn't have code that triggers it). + // + // We should fix this when we require 1.17. + panic!(); + } + + Arc { ptr: self.ptr } + } +} + +impl<T: ?Sized> Deref for Arc<T> { + type Target = T; + + #[inline] + fn deref(&self) -> &T { + &self.inner().data + } +} + +impl<T: Clone> Arc<T> { + #[inline] + pub fn make_mut(this: &mut Self) -> &mut T { + if !this.is_unique() { + // Another pointer exists; clone + *this = Arc::new((**this).clone()); + } + + unsafe { + // This unsafety is ok because we're guaranteed that the pointer + // returned is the *only* pointer that will ever be returned to T. Our + // reference count is guaranteed to be 1 at this point, and we required + // the Arc itself to be `mut`, so we're returning the only possible + // reference to the inner data. + &mut (*this.ptr).data + } + } +} + +impl<T: ?Sized> Arc<T> { + #[inline] + pub fn get_mut(this: &mut Self) -> Option<&mut T> { + if this.is_unique() { + unsafe { + // See make_mut() for documentation of the threadsafety here. + Some(&mut (*this.ptr).data) + } + } else { + None + } + } + + #[inline] + fn is_unique(&self) -> bool { + // We can use Relaxed here, but the justification is a bit subtle. + // + // The reason to use Acquire would be to synchronize with other threads + // that are modifying the refcount with Release, i.e. to ensure that + // their writes to memory guarded by this refcount are flushed. However, + // we know that threads only modify the contents of the Arc when they + // observe the refcount to be 1, and no other thread could observe that + // because we're holding one strong reference here. + self.inner().count.load(Relaxed) == 1 + } +} + +impl<T: ?Sized> Drop for Arc<T> { + #[inline] + fn drop(&mut self) { + // Because `fetch_sub` is already atomic, we do not need to synchronize + // with other threads unless we are going to delete the object. + if self.inner().count.fetch_sub(1, Release) != 1 { + return; + } + + // FIXME(bholley): Use the updated comment when [2] is merged. + // + // This load is needed to prevent reordering of use of the data and + // deletion of the data. Because it is marked `Release`, the decreasing + // of the reference count synchronizes with this `Acquire` load. This + // means that use of the data happens before decreasing the reference + // count, which happens before this load, which happens before the + // deletion of the data. + // + // As explained in the [Boost documentation][1], + // + // > It is important to enforce any possible access to the object in one + // > thread (through an existing reference) to *happen before* deleting + // > the object in a different thread. This is achieved by a "release" + // > operation after dropping a reference (any access to the object + // > through this reference must obviously happened before), and an + // > "acquire" operation before deleting the object. + // + // [1]: (www.boost.org/doc/libs/1_55_0/doc/html/atomic/usage_examples.html) + // [2]: https://github.com/rust-lang/rust/pull/41714 + self.inner().count.load(Acquire); + + unsafe { + self.drop_slow(); + } + } +} + +impl<T: ?Sized + PartialEq> PartialEq for Arc<T> { + fn eq(&self, other: &Arc<T>) -> bool { + *(*self) == *(*other) + } + + fn ne(&self, other: &Arc<T>) -> bool { + *(*self) != *(*other) + } +} +impl<T: ?Sized + PartialOrd> PartialOrd for Arc<T> { + fn partial_cmp(&self, other: &Arc<T>) -> Option<Ordering> { + (**self).partial_cmp(&**other) + } + + fn lt(&self, other: &Arc<T>) -> bool { + *(*self) < *(*other) + } + + fn le(&self, other: &Arc<T>) -> bool { + *(*self) <= *(*other) + } + + fn gt(&self, other: &Arc<T>) -> bool { + *(*self) > *(*other) + } + + fn ge(&self, other: &Arc<T>) -> bool { + *(*self) >= *(*other) + } +} +impl<T: ?Sized + Ord> Ord for Arc<T> { + fn cmp(&self, other: &Arc<T>) -> Ordering { + (**self).cmp(&**other) + } +} +impl<T: ?Sized + Eq> Eq for Arc<T> {} + +impl<T: ?Sized + fmt::Display> fmt::Display for Arc<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Display::fmt(&**self, f) + } +} + +impl<T: ?Sized + fmt::Debug> fmt::Debug for Arc<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(&**self, f) + } +} + +impl<T: ?Sized> fmt::Pointer for Arc<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&self.ptr, f) + } +} + +impl<T: Default> Default for Arc<T> { + fn default() -> Arc<T> { + Arc::new(Default::default()) + } +} + +impl<T: ?Sized + Hash> Hash for Arc<T> { + fn hash<H: Hasher>(&self, state: &mut H) { + (**self).hash(state) + } +} + +impl<T> From<T> for Arc<T> { + fn from(t: T) -> Self { + Arc::new(t) + } +} + +impl<T: ?Sized> borrow::Borrow<T> for Arc<T> { + fn borrow(&self) -> &T { + &**self + } +} + +impl<T: ?Sized> AsRef<T> for Arc<T> { + fn as_ref(&self) -> &T { + &**self + } +} + +// This is what the HeapSize crate does for regular arc, but is questionably +// sound. See https://github.com/servo/heapsize/issues/37 +#[cfg(feature = "servo")] +impl<T: HeapSizeOf> HeapSizeOf for Arc<T> { + fn heap_size_of_children(&self) -> usize { + (**self).heap_size_of_children() + } +} + +#[cfg(feature = "servo")] +impl<T: Deserialize> Deserialize for Arc<T> +{ + fn deserialize<D>(deserializer: D) -> Result<Arc<T>, D::Error> + where + D: ::serde::de::Deserializer, + { + T::deserialize(deserializer).map(Arc::new) + } +} + +#[cfg(feature = "servo")] +impl<T: Serialize> Serialize for Arc<T> +{ + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> + where + S: ::serde::ser::Serializer, + { + (**self).serialize(serializer) + } +} diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs index e1f782bbbbf..0cc6f4fbf51 100644 --- a/components/style/stylesheet_set.rs +++ b/components/style/stylesheet_set.rs @@ -4,19 +4,26 @@ //! A centralized set of stylesheets for a document. -use arc_ptr_eq; -use std::sync::Arc; +use stylearc::Arc; use stylesheets::Stylesheet; +/// Entry for a StylesheetSet. We don't bother creating a constructor, because +/// there's no sensible defaults for the member variables. +pub struct StylesheetSetEntry { + unique_id: u32, + sheet: Arc<Stylesheet>, +} + /// The set of stylesheets effective for a given document. pub struct StylesheetSet { - /// The actual list of all the stylesheets that apply to the given document. + /// The actual list of all the stylesheets that apply to the given document, + /// each stylesheet associated with a unique ID. /// /// This is only a list of top-level stylesheets, and as such it doesn't /// include recursive `@import` rules. - stylesheets: Vec<Arc<Stylesheet>>, + entries: Vec<StylesheetSetEntry>, - /// Whether the stylesheets list above has changed since the last restyle. + /// Whether the entries list above has changed since the last restyle. dirty: bool, /// Has author style been disabled? @@ -27,7 +34,7 @@ impl StylesheetSet { /// Create a new empty StylesheetSet. pub fn new() -> Self { StylesheetSet { - stylesheets: vec![], + entries: vec![], dirty: false, author_style_disabled: false, } @@ -39,39 +46,51 @@ impl StylesheetSet { self.author_style_disabled } - fn remove_stylesheet_if_present(&mut self, sheet: &Arc<Stylesheet>) { - self.stylesheets.retain(|x| !arc_ptr_eq(x, sheet)); + fn remove_stylesheet_if_present(&mut self, unique_id: u32) { + self.entries.retain(|x| x.unique_id != unique_id); } /// Appends a new stylesheet to the current set. - pub fn append_stylesheet(&mut self, sheet: &Arc<Stylesheet>) { - self.remove_stylesheet_if_present(sheet); - self.stylesheets.push(sheet.clone()); + pub fn append_stylesheet(&mut self, sheet: &Arc<Stylesheet>, + unique_id: u32) { + self.remove_stylesheet_if_present(unique_id); + self.entries.push(StylesheetSetEntry { + unique_id: unique_id, + sheet: sheet.clone(), + }); self.dirty = true; } /// Prepend a new stylesheet to the current set. - pub fn prepend_stylesheet(&mut self, sheet: &Arc<Stylesheet>) { - self.remove_stylesheet_if_present(sheet); - self.stylesheets.insert(0, sheet.clone()); + pub fn prepend_stylesheet(&mut self, sheet: &Arc<Stylesheet>, + unique_id: u32) { + self.remove_stylesheet_if_present(unique_id); + self.entries.insert(0, StylesheetSetEntry { + unique_id: unique_id, + sheet: sheet.clone(), + }); self.dirty = true; } /// Insert a given stylesheet before another stylesheet in the document. pub fn insert_stylesheet_before(&mut self, sheet: &Arc<Stylesheet>, - before: &Arc<Stylesheet>) { - self.remove_stylesheet_if_present(sheet); - let index = self.stylesheets.iter().position(|x| { - arc_ptr_eq(x, before) - }).expect("`before` stylesheet not found"); - self.stylesheets.insert(index, sheet.clone()); + unique_id: u32, + before_unique_id: u32) { + self.remove_stylesheet_if_present(unique_id); + let index = self.entries.iter().position(|x| { + x.unique_id == before_unique_id + }).expect("`before_unique_id` stylesheet not found"); + self.entries.insert(index, StylesheetSetEntry { + unique_id: unique_id, + sheet: sheet.clone(), + }); self.dirty = true; } /// Remove a given stylesheet from the set. - pub fn remove_stylesheet(&mut self, sheet: &Arc<Stylesheet>) { - self.remove_stylesheet_if_present(sheet); + pub fn remove_stylesheet(&mut self, unique_id: u32) { + self.remove_stylesheet_if_present(unique_id); self.dirty = true; } @@ -90,9 +109,11 @@ impl StylesheetSet { } /// Flush the current set, unmarking it as dirty. - pub fn flush(&mut self) -> &[Arc<Stylesheet>] { + pub fn flush(&mut self, sheets: &mut Vec<Arc<Stylesheet>>) { self.dirty = false; - &self.stylesheets + for entry in &self.entries { + sheets.push(entry.sheet.clone()) + } } /// Mark the stylesheets as dirty, because something external may have diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 97dfce4c51f..36e5a2a936e 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -36,10 +36,10 @@ use servo_url::ServoUrl; use shared_lock::{SharedRwLock, Locked, ToCssWithGuard, SharedRwLockReadGuard}; use std::cell::Cell; use std::fmt; -use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use str::starts_with_ignore_ascii_case; use style_traits::ToCss; +use stylearc::Arc; use stylist::FnvHashMap; use supports::SupportsCondition; use values::{CustomIdent, KeyframesName}; diff --git a/components/style/stylist.rs b/components/style/stylist.rs index cda795d559c..5dc3e807374 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -39,8 +39,8 @@ use std::fmt; use std::hash::Hash; #[cfg(feature = "servo")] use std::marker::PhantomData; -use std::sync::Arc; use style_traits::viewport::ViewportConstraints; +use stylearc::Arc; use stylesheets::{CssRule, FontFaceRule, Origin, StyleRule, Stylesheet, UserAgentStylesheets}; use thread_state; use viewport::{self, MaybeNew, ViewportRule}; |