diff --git a/html5ever-2015-05-15/Cargo.toml b/html5ever-2015-05-15/Cargo.toml
deleted file mode 100644
index d5ddd9f51..000000000
--- a/html5ever-2015-05-15/Cargo.toml
+++ /dev/null
@@ -1,40 +0,0 @@
-[package]
-
-name = "html5ever"
-version = "0.0.0"
-authors = [ "The html5ever Project Developers" ]
-
-[lib]
-name = "html5ever"
-
-# https://github.com/rust-lang/cargo/issues/1512
-doctest = false
-
-[dependencies]
-time = "0"
-log = "0"
-phf = "0.7"
-phf_macros = "0.7"
-string_cache = "0.1.12"
-string_cache_plugin = { version = "0.1.7", optional = true }
-
-[dependencies.mac]
-git = "https://github.com/reem/rust-mac"
-
-[dependencies.html5ever_macros]
-path = "macros"
-
-[dev-dependencies]
-rustc-serialize = "0"
-
-[dev-dependencies.test_util]
-path = "test_util"
-
-[dev-dependencies.html5ever_dom_sink]
-path = "dom_sink"
-
-[profile.dev]
-debug = false
-
-[profile.test]
-debug = false
diff --git a/html5ever-2015-05-15/capi/Cargo.toml b/html5ever-2015-05-15/capi/Cargo.toml
deleted file mode 100644
index d665d7523..000000000
--- a/html5ever-2015-05-15/capi/Cargo.toml
+++ /dev/null
@@ -1,20 +0,0 @@
-[package]
-
-name = "html5ever_capi"
-version = "0.0.0"
-authors = [ "The html5ever Project Developers" ]
-
-[lib]
-name = "html5ever_capi"
-crate-type = ["staticlib"]
-
-[dependencies]
-libc = "0"
-
-[dependencies.html5ever]
-path = "../"
-
-[dependencies.string_cache]
-git = "https://github.com/servo/string-cache"
-[dependencies.string_cache_plugin]
-git = "https://github.com/servo/string-cache"
diff --git a/html5ever-2015-05-15/capi/include/html5ever.h b/html5ever-2015-05-15/capi/include/html5ever.h
deleted file mode 100644
index e6c674d1c..000000000
--- a/html5ever-2015-05-15/capi/include/html5ever.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2014 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#ifndef __HTML5EVER_H
-#define __HTML5EVER_H
-
-#include
-
-struct h5e_buf {
- unsigned char *data;
- size_t len;
-};
-
-struct h5e_buf h5e_buf_from_cstr(const char *str);
-
-struct h5e_token_ops {
- void (*do_doctype)(void *user, struct h5e_buf name,
- struct h5e_buf pub, struct h5e_buf sys, int force_quirks);
- void (*do_start_tag)(void *user, struct h5e_buf name,
- int self_closing, size_t num_attrs);
- void (*do_tag_attr)(void *user, struct h5e_buf name, struct h5e_buf value);
- void (*do_end_tag)(void *user, struct h5e_buf name);
- void (*do_comment)(void *user, struct h5e_buf text);
- void (*do_chars)(void *user, struct h5e_buf text);
- void (*do_null_char)(void *user);
- void (*do_eof)(void *user);
- void (*do_error)(void *user, struct h5e_buf message);
-};
-
-struct h5e_token_sink {
- struct h5e_token_ops *ops;
- void *user;
-};
-
-struct h5e_tokenizer;
-
-struct h5e_tokenizer *h5e_tokenizer_new(struct h5e_token_sink *sink);
-void h5e_tokenizer_free(struct h5e_tokenizer *tok);
-void h5e_tokenizer_feed(struct h5e_tokenizer *tok, struct h5e_buf buf);
-void h5e_tokenizer_end(struct h5e_tokenizer *tok);
-
-#endif
diff --git a/html5ever-2015-05-15/capi/src/lib.rs b/html5ever-2015-05-15/capi/src/lib.rs
deleted file mode 100644
index 2f1dbc621..000000000
--- a/html5ever-2015-05-15/capi/src/lib.rs
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2014-2015 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-extern crate libc;
-extern crate string_cache;
-extern crate html5ever;
-
-use std::{ptr, slice, str};
-use std::marker::PhantomData;
-use std::borrow::Cow;
-
-use libc::{size_t, c_int, c_char, strlen};
-
-use string_cache::Atom;
-
-#[repr(C)]
-pub struct h5e_buf {
- data: *const u8,
- len: size_t,
-}
-
-impl Copy for h5e_buf { }
-impl Clone for h5e_buf {
- fn clone(&self) -> h5e_buf {
- *self
- }
-}
-
-impl h5e_buf {
- pub fn null() -> h5e_buf {
- h5e_buf {
- data: ptr::null(),
- len: 0,
- }
- }
-
- pub unsafe fn as_slice(&self) -> &str {
- str::from_utf8_unchecked(slice::from_raw_parts(self.data, self.len as usize))
- }
-}
-
-pub struct LifetimeBuf<'a> {
- buf: h5e_buf,
- marker: PhantomData<&'a [u8]>,
-}
-
-impl<'a> LifetimeBuf<'a> {
- pub fn from_str(x: &'a str) -> LifetimeBuf<'a> {
- LifetimeBuf {
- buf: h5e_buf {
- data: x.as_bytes().as_ptr(),
- len: x.len() as size_t,
- },
- marker: PhantomData,
- }
- }
-
- pub fn null() -> LifetimeBuf<'a> {
- LifetimeBuf {
- buf: h5e_buf::null(),
- marker: PhantomData,
- }
- }
-
- #[inline]
- pub fn get(self) -> h5e_buf {
- self.buf
- }
-}
-
-// Or we could just make `LifetimeBuf::from_str` generic over ;
-// see rust-lang/rust#16738.
-pub trait AsLifetimeBuf {
- fn as_lifetime_buf<'a>(&'a self) -> LifetimeBuf<'a>;
-}
-
-impl AsLifetimeBuf for String {
- fn as_lifetime_buf<'a>(&'a self) -> LifetimeBuf<'a> {
- LifetimeBuf::from_str(self)
- }
-}
-
-impl AsLifetimeBuf for Atom {
- fn as_lifetime_buf<'a>(&'a self) -> LifetimeBuf<'a> {
- LifetimeBuf::from_str(self)
- }
-}
-
-impl<'b> AsLifetimeBuf for Cow<'b, str> {
- fn as_lifetime_buf<'a>(&'a self) -> LifetimeBuf<'a> {
- LifetimeBuf::from_str(self)
- }
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn h5e_buf_from_cstr(s: *const c_char) -> h5e_buf {
- h5e_buf {
- data: s as *const u8,
- len: strlen(s),
- }
-}
-
-pub fn c_bool(x: bool) -> c_int {
- match x {
- false => 0,
- true => 1,
- }
-}
diff --git a/html5ever-2015-05-15/capi/src/tokenizer.rs b/html5ever-2015-05-15/capi/src/tokenizer.rs
deleted file mode 100644
index d1fe7559b..000000000
--- a/html5ever-2015-05-15/capi/src/tokenizer.rs
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright 2014 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(non_camel_case_types)]
-
-use {LifetimeBuf, AsLifetimeBuf, h5e_buf, c_bool};
-
-use html5ever::tokenizer::{TokenSink, Token, Doctype, Tag, ParseError, DoctypeToken};
-use html5ever::tokenizer::{CommentToken, CharacterTokens, NullCharacterToken};
-use html5ever::tokenizer::{TagToken, StartTag, EndTag, EOFToken, Tokenizer};
-
-use std::mem;
-use std::default::Default;
-
-use libc::{c_void, c_int, size_t};
-
-#[repr(C)]
-pub struct h5e_token_ops {
- do_doctype: Option,
-
- do_start_tag: Option,
-
- do_tag_attr: Option,
- do_end_tag: Option,
- do_comment: Option,
- do_chars: Option,
- do_null_char: Option,
- do_eof: Option,
- do_error: Option,
-}
-
-impl Copy for h5e_token_ops { }
-impl Clone for h5e_token_ops {
- fn clone(&self) -> h5e_token_ops {
- *self
- }
-}
-
-#[repr(C)]
-pub struct h5e_token_sink {
- ops: *const h5e_token_ops,
- user: *mut c_void,
-}
-
-impl Copy for h5e_token_sink { }
-impl Clone for h5e_token_sink {
- fn clone(&self) -> h5e_token_sink {
- *self
- }
-}
-
-impl TokenSink for *mut h5e_token_sink {
- fn process_token(&mut self, token: Token) {
- macro_rules! call {
- ($name:ident, $($arg:expr),*) => (
- unsafe {
- match (*(**self).ops).$name {
- None => (),
- Some(f) => f((**self).user $(, $arg)*),
- }
- }
- );
- ($name:ident) => (call!($name,)); // bleh
- }
-
- fn opt_str_to_buf<'a>(s: &'a Option) -> LifetimeBuf<'a> {
- match *s {
- None => LifetimeBuf::null(),
- Some(ref s) => s.as_lifetime_buf(),
- }
- }
-
- match token {
- DoctypeToken(Doctype { name, public_id, system_id, force_quirks }) => {
- let name = opt_str_to_buf(&name);
- let public_id = opt_str_to_buf(&public_id);
- let system_id = opt_str_to_buf(&system_id);
- call!(do_doctype, name.get(), public_id.get(), system_id.get(),
- c_bool(force_quirks));
- }
-
- TagToken(Tag { kind, name, self_closing, attrs }) => {
- let name = name.as_lifetime_buf();
- match kind {
- StartTag => {
- call!(do_start_tag, name.get(), c_bool(self_closing),
- attrs.len() as size_t);
- for attr in attrs.into_iter() {
- // All attribute names from the tokenizer are local.
- assert!(attr.name.ns == ns!(""));
- let name = attr.name.local.as_lifetime_buf();
- let value = attr.value.as_lifetime_buf();
- call!(do_tag_attr, name.get(), value.get());
- }
- }
- EndTag => call!(do_end_tag, name.get()),
- }
- }
-
- CommentToken(text) => {
- let text = text.as_lifetime_buf();
- call!(do_comment, text.get());
- }
-
- CharacterTokens(text) => {
- let text = text.as_lifetime_buf();
- call!(do_chars, text.get());
- }
-
- NullCharacterToken => call!(do_null_char),
-
- EOFToken => call!(do_eof),
-
- ParseError(msg) => {
- let msg = msg.as_lifetime_buf();
- call!(do_error, msg.get());
- }
- }
- }
-}
-
-pub type h5e_tokenizer_ptr = *const ();
-
-#[no_mangle]
-pub unsafe extern "C" fn h5e_tokenizer_new(sink: *mut h5e_token_sink) -> h5e_tokenizer_ptr {
- let tok: Box>
- = box Tokenizer::new(sink, Default::default());
-
- mem::transmute(tok)
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn h5e_tokenizer_free(tok: h5e_tokenizer_ptr) {
- let _: Box> = mem::transmute(tok);
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn h5e_tokenizer_feed(tok: h5e_tokenizer_ptr, buf: h5e_buf) {
- let tok: &mut Tokenizer<*mut h5e_token_sink> = mem::transmute(tok);
- tok.feed(String::from_str(buf.as_slice()));
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn h5e_tokenizer_end(tok: h5e_tokenizer_ptr) {
- let tok: &mut Tokenizer<*mut h5e_token_sink> = mem::transmute(tok);
- tok.end();
-}
diff --git a/html5ever-2015-05-15/data/test/ignore b/html5ever-2015-05-15/data/test/ignore
deleted file mode 100644
index 5f84915c6..000000000
--- a/html5ever-2015-05-15/data/test/ignore
+++ /dev/null
@@ -1,105 +0,0 @@
-tb: isindex.dat-0
-tb: isindex.dat-1
-tb: isindex.dat-2
-tb: ruby.dat-0
-tb: ruby.dat-1
-tb: ruby.dat-10
-tb: ruby.dat-12
-tb: ruby.dat-13
-tb: ruby.dat-15
-tb: ruby.dat-17
-tb: ruby.dat-2
-tb: ruby.dat-20
-tb: ruby.dat-3
-tb: ruby.dat-5
-tb: ruby.dat-7
-tb: tests16.dat-181
-tb: tests16.dat-183
-tb: tests16.dat-185
-tb: tests16.dat-194
-tb: tests16.dat-84
-tb: tests16.dat-86
-tb: tests16.dat-88
-tb: tests19.dat-10
-tb: tests19.dat-11
-tb: tests19.dat-18
-tb: tests19.dat-21
-tb: tests19.dat-7
-tb: tests19.dat-8
-tb: tests19.dat-9
-tb: tests2.dat-44
-tb: tests26.dat-9
-tb: tests5.dat-16
-tb: webkit02.dat-2
-tb: foreign-fragment.dat-0
-tb: foreign-fragment.dat-1
-tb: foreign-fragment.dat-18
-tb: foreign-fragment.dat-19
-tb: foreign-fragment.dat-2
-tb: foreign-fragment.dat-22
-tb: foreign-fragment.dat-23
-tb: foreign-fragment.dat-26
-tb: foreign-fragment.dat-27
-tb: foreign-fragment.dat-3
-tb: foreign-fragment.dat-30
-tb: foreign-fragment.dat-31
-tb: foreign-fragment.dat-34
-tb: foreign-fragment.dat-35
-tb: foreign-fragment.dat-38
-tb: foreign-fragment.dat-39
-tb: foreign-fragment.dat-40
-tb: foreign-fragment.dat-41
-tb: foreign-fragment.dat-47
-tb: foreign-fragment.dat-48
-tb: domjs-unsafe.dat-0
-tb: domjs-unsafe.dat-1
-tb: domjs-unsafe.dat-2
-tb: domjs-unsafe.dat-46
-tb: domjs-unsafe.dat-47
-tb: plain-text-unsafe.dat-10
-tb: plain-text-unsafe.dat-13
-tb: plain-text-unsafe.dat-26
-tb: plain-text-unsafe.dat-27
-tb: plain-text-unsafe.dat-28
-tb: plain-text-unsafe.dat-29
-tb: plain-text-unsafe.dat-30
-tb: plain-text-unsafe.dat-31
-tb: plain-text-unsafe.dat-32
-tb: tests10.dat-30
-tb: tests10.dat-31
-tb: tests10.dat-34
-tb: tests10.dat-35
-tb: tests12.dat-0
-tb: tests19.dat-35
-tb: tests19.dat-36
-tb: tests19.dat-37
-tb: tests19.dat-38
-tb: tests19.dat-39
-tb: tests19.dat-87
-tb: tests20.dat-34
-tb: tests20.dat-35
-tb: tests20.dat-36
-tb: tests20.dat-37
-tb: tests21.dat-0
-tb: tests21.dat-1
-tb: tests21.dat-10
-tb: tests21.dat-11
-tb: tests21.dat-12
-tb: tests21.dat-13
-tb: tests21.dat-14
-tb: tests21.dat-16
-tb: tests21.dat-17
-tb: tests21.dat-18
-tb: tests21.dat-19
-tb: tests21.dat-20
-tb: tests21.dat-21
-tb: tests21.dat-22
-tb: tests21.dat-23
-tb: tests21.dat-24
-tb: tests21.dat-3
-tb: tests21.dat-4
-tb: tests21.dat-5
-tb: tests21.dat-6
-tb: tests21.dat-7
-tb: tests21.dat-8
-tb: tests21.dat-9
diff --git a/html5ever-2015-05-15/dom_sink/Cargo.toml b/html5ever-2015-05-15/dom_sink/Cargo.toml
deleted file mode 100644
index 10749c51f..000000000
--- a/html5ever-2015-05-15/dom_sink/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-name = "html5ever_dom_sink"
-version = "0.0.0"
-authors = [ "The html5ever Project Developers" ]
-
-[lib]
-name = "html5ever_dom_sink"
-
-[dependencies.html5ever]
-path = "../"
-
-[dependencies.mac]
-git = "https://github.com/reem/rust-mac"
-
-[dependencies.string_cache]
-git = "https://github.com/servo/string-cache"
diff --git a/html5ever-2015-05-15/dom_sink/src/common.rs b/html5ever-2015-05-15/dom_sink/src/common.rs
deleted file mode 100644
index 7fb1c6fec..000000000
--- a/html5ever-2015-05-15/dom_sink/src/common.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2014 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use html5ever::tokenizer::Attribute;
-
-use string_cache::QualName;
-
-pub use self::NodeEnum::{Document, Doctype, Text, Comment, Element};
-
-/// The different kinds of nodes in the DOM.
-#[derive(Debug)]
-pub enum NodeEnum {
- /// The `Document` itself.
- Document,
-
- /// A `DOCTYPE` with name, public id, and system id.
- Doctype(String, String, String),
-
- /// A text node.
- Text(String),
-
- /// A comment.
- Comment(String),
-
- /// An element with attributes.
- Element(QualName, Vec),
-}
diff --git a/html5ever-2015-05-15/dom_sink/src/lib.rs b/html5ever-2015-05-15/dom_sink/src/lib.rs
deleted file mode 100644
index 8194715f7..000000000
--- a/html5ever-2015-05-15/dom_sink/src/lib.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![crate_name="html5ever_dom_sink"]
-#![crate_type="dylib"]
-
-#![feature(alloc, box_syntax, collections)]
-
-extern crate html5ever;
-
-#[macro_use]
-extern crate string_cache;
-
-#[macro_use]
-extern crate mac;
-
-pub mod common;
-pub mod rcdom;
-pub mod owned_dom;
diff --git a/html5ever-2015-05-15/dom_sink/src/owned_dom.rs b/html5ever-2015-05-15/dom_sink/src/owned_dom.rs
deleted file mode 100644
index 9b4781658..000000000
--- a/html5ever-2015-05-15/dom_sink/src/owned_dom.rs
+++ /dev/null
@@ -1,388 +0,0 @@
-// Copyright 2014 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! A simple DOM where every node is owned by its parent.
-//!
-//! Since ownership is more complicated during parsing, we actually
-//! build a different type and then transmute to the public `Node`.
-//! This is believed to be memory safe, but if you want to be extra
-//! careful you can use `RcDom` instead.
-//!
-//! **Warning: Unstable.** This module uses unsafe code, has not
-//! been thoroughly audited, and the performance gains vs. RcDom
-//! have not been demonstrated.
-
-use common::{NodeEnum, Document, Doctype, Text, Comment, Element};
-
-use html5ever::tokenizer::Attribute;
-use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText};
-use html5ever::tree_builder;
-use html5ever::serialize::{Serializable, Serializer};
-use html5ever::serialize::TraversalScope;
-use html5ever::serialize::TraversalScope::{IncludeNode, ChildrenOnly};
-use html5ever::driver::ParseResult;
-
-use std::{mem, ptr};
-use std::cell::UnsafeCell;
-use std::default::Default;
-use std::mem::transmute;
-use std::borrow::Cow;
-use std::io::{self, Write};
-use std::collections::HashSet;
-use std::ops::{Deref, DerefMut};
-
-use string_cache::QualName;
-
-/// The internal type we use for nodes during parsing.
-pub struct SquishyNode {
- node: NodeEnum,
- parent: Handle,
- children: Vec,
-}
-
-impl SquishyNode {
- fn new(node: NodeEnum) -> SquishyNode {
- SquishyNode {
- node: node,
- parent: Handle::null(),
- children: vec!(),
- }
- }
-}
-
-pub struct Handle {
- ptr: *const UnsafeCell,
-}
-
-impl Handle {
- fn new(ptr: *const UnsafeCell) -> Handle {
- Handle {
- ptr: ptr,
- }
- }
-
- fn null() -> Handle {
- Handle::new(ptr::null())
- }
-
- fn is_null(&self) -> bool {
- self.ptr.is_null()
- }
-}
-
-impl PartialEq for Handle {
- fn eq(&self, other: &Handle) -> bool {
- self.ptr == other.ptr
- }
-}
-
-impl Eq for Handle { }
-
-impl Clone for Handle {
- fn clone(&self) -> Handle {
- Handle::new(self.ptr)
- }
-}
-
-impl Copy for Handle { }
-
-// The safety of `Deref` and `DerefMut` depends on the invariant that `Handle`s
-// can't escape the `Sink`, because nodes are deallocated by consuming the
-// `Sink`.
-
-impl DerefMut for Handle {
- fn deref_mut<'a>(&'a mut self) -> &'a mut SquishyNode {
- unsafe {
- transmute::<_, &'a mut SquishyNode>((*self.ptr).get())
- }
- }
-}
-
-impl Deref for Handle {
- type Target = SquishyNode;
- fn deref<'a>(&'a self) -> &'a SquishyNode {
- unsafe {
- transmute::<_, &'a SquishyNode>((*self.ptr).get())
- }
- }
-}
-
-fn append(mut new_parent: Handle, mut child: Handle) {
- new_parent.children.push(child);
- let parent = &mut child.parent;
- assert!(parent.is_null());
- *parent = new_parent
-}
-
-fn get_parent_and_index(child: Handle) -> Option<(Handle, usize)> {
- if child.parent.is_null() {
- return None;
- }
-
- let to_find = child;
- match child.parent.children.iter().enumerate().find(|&(_, n)| *n == to_find) {
- Some((i, _)) => Some((child.parent, i)),
- None => panic!("have parent but couldn't find in parent's children!"),
- }
-}
-
-fn append_to_existing_text(mut prev: Handle, text: &str) -> bool {
- match prev.deref_mut().node {
- Text(ref mut existing) => {
- existing.push_str(text);
- true
- }
- _ => false,
- }
-}
-
-pub struct Sink {
- nodes: Vec>>,
- document: Handle,
- errors: Vec>,
- quirks_mode: QuirksMode,
-}
-
-impl Default for Sink {
- fn default() -> Sink {
- let mut sink = Sink {
- nodes: vec!(),
- document: Handle::null(),
- errors: vec!(),
- quirks_mode: tree_builder::NoQuirks,
- };
- sink.document = sink.new_node(Document);
- sink
- }
-}
-
-impl Sink {
- fn new_node(&mut self, node: NodeEnum) -> Handle {
- self.nodes.push(box UnsafeCell::new(SquishyNode::new(node)));
- let ptr: *const UnsafeCell = &**self.nodes.last().unwrap();
- Handle::new(ptr)
- }
-
- // FIXME(rust-lang/rust#18296): This is separate from remove_from_parent so
- // we can call it.
- fn unparent(&mut self, mut target: Handle) {
- let (mut parent, i) = unwrap_or_return!(get_parent_and_index(target), ());
- parent.children.remove(i);
- target.parent = Handle::null();
- }
-}
-
-impl TreeSink for Sink {
- type Handle = Handle;
-
- fn parse_error(&mut self, msg: Cow<'static, str>) {
- self.errors.push(msg);
- }
-
- fn get_document(&mut self) -> Handle {
- self.document
- }
-
- fn set_quirks_mode(&mut self, mode: QuirksMode) {
- self.quirks_mode = mode;
- }
-
- fn same_node(&self, x: Handle, y: Handle) -> bool {
- x == y
- }
-
- fn elem_name(&self, target: Handle) -> QualName {
- match target.node {
- Element(ref name, _) => name.clone(),
- _ => panic!("not an element!"),
- }
- }
-
- fn create_element(&mut self, name: QualName, attrs: Vec) -> Handle {
- self.new_node(Element(name, attrs))
- }
-
- fn create_comment(&mut self, text: String) -> Handle {
- self.new_node(Comment(text))
- }
-
- fn append(&mut self, parent: Handle, child: NodeOrText) {
- // Append to an existing Text node if we have one.
- match child {
- AppendText(ref text) => match parent.children.last() {
- Some(h) => if append_to_existing_text(*h, &text) { return; },
- _ => (),
- },
- _ => (),
- }
-
- append(parent, match child {
- AppendText(text) => self.new_node(Text(text)),
- AppendNode(node) => node
- });
- }
-
- fn append_before_sibling(&mut self,
- sibling: Handle,
- child: NodeOrText) -> Result<(), NodeOrText> {
- let (mut parent, i) = unwrap_or_return!(get_parent_and_index(sibling), Err(child));
-
- let mut child = match (child, i) {
- // No previous node.
- (AppendText(text), 0) => self.new_node(Text(text)),
-
- // Look for a text node before the insertion point.
- (AppendText(text), i) => {
- let prev = parent.children[i-1];
- if append_to_existing_text(prev, &text) {
- return Ok(());
- }
- self.new_node(Text(text))
- }
-
- // The tree builder promises we won't have a text node after
- // the insertion point.
-
- // Any other kind of node.
- (AppendNode(node), _) => node,
- };
-
- if !child.parent.is_null() {
- self.unparent(child);
- }
-
- child.parent = parent;
- parent.children.insert(i, child);
- Ok(())
- }
-
- fn append_doctype_to_document(&mut self, name: String, public_id: String, system_id: String) {
- append(self.document, self.new_node(Doctype(name, public_id, system_id)));
- }
-
- fn add_attrs_if_missing(&mut self, mut target: Handle, mut attrs: Vec) {
- let existing = match target.deref_mut().node {
- Element(_, ref mut attrs) => attrs,
- _ => return,
- };
-
- // FIXME: quadratic time
- attrs.retain(|attr|
- !existing.iter().any(|e| e.name == attr.name));
- existing.extend(attrs.into_iter());
- }
-
- fn remove_from_parent(&mut self, target: Handle) {
- self.unparent(target);
- }
-
- fn reparent_children(&mut self, mut node: Handle, mut new_parent: Handle) {
- new_parent.children.append(&mut node.children);
- }
-
- fn mark_script_already_started(&mut self, _node: Handle) { }
-}
-
-pub struct Node {
- pub node: NodeEnum,
- _parent_not_accessible: usize,
- pub children: Vec>,
-}
-
-pub struct OwnedDom {
- pub document: Box,
- pub errors: Vec>,
- pub quirks_mode: QuirksMode,
-}
-
-impl ParseResult for OwnedDom {
- type Sink = Sink;
-
- fn get_result(sink: Sink) -> OwnedDom {
- fn walk(live: &mut HashSet, node: Handle) {
- live.insert(node.ptr as usize);
- for &child in node.deref().children.iter() {
- walk(live, child);
- }
- }
-
- // Collect addresses of all the nodes that made it into the final tree.
- let mut live = HashSet::new();
- walk(&mut live, sink.document);
-
- // Forget about the nodes in the final tree; they will be owned by
- // their parent. In the process of iterating we drop all nodes that
- // aren't in the tree.
- for node in sink.nodes.into_iter() {
- let ptr: *const UnsafeCell = &*node;
- if live.contains(&(ptr as usize)) {
- unsafe {
- mem::forget(node);
- }
- }
- }
-
- let old_addrs = addrs_of!(sink.document => node, parent, children);
-
- // Transmute the root to a Node, finalizing the transfer of ownership.
- let document = unsafe {
- mem::transmute::<*const UnsafeCell, Box>(sink.document.ptr)
- };
-
- // FIXME: do this assertion statically
- let new_addrs = addrs_of!(document => node, _parent_not_accessible, children);
- assert_eq!(old_addrs, new_addrs);
-
- OwnedDom {
- document: document,
- errors: sink.errors,
- quirks_mode: sink.quirks_mode,
- }
- }
-}
-
-impl Serializable for Node {
- fn serialize<'wr, Wr: Write>(&self,
- serializer: &mut Serializer<'wr, Wr>,
- traversal_scope: TraversalScope) -> io::Result<()> {
-
- match (traversal_scope, &self.node) {
- (_, &Element(ref name, ref attrs)) => {
- if traversal_scope == IncludeNode {
- try!(serializer.start_elem(name.clone(),
- attrs.iter().map(|at| (&at.name, &at.value[..]))));
- }
-
- for child in self.children.iter() {
- try!(child.serialize(serializer, IncludeNode));
- }
-
- if traversal_scope == IncludeNode {
- try!(serializer.end_elem(name.clone()));
- }
- Ok(())
- }
-
- (ChildrenOnly, &Document) => {
- for child in self.children.iter() {
- try!(child.serialize(serializer, IncludeNode));
- }
- Ok(())
- }
-
- (ChildrenOnly, _) => Ok(()),
-
- (IncludeNode, &Doctype(ref name, _, _)) => serializer.write_doctype(&name),
- (IncludeNode, &Text(ref text)) => serializer.write_text(&text),
- (IncludeNode, &Comment(ref text)) => serializer.write_comment(&text),
-
- (IncludeNode, &Document) => panic!("Can't serialize Document node itself"),
- }
- }
-}
diff --git a/html5ever-2015-05-15/macros/Cargo.toml b/html5ever-2015-05-15/macros/Cargo.toml
deleted file mode 100644
index 9bcecfbde..000000000
--- a/html5ever-2015-05-15/macros/Cargo.toml
+++ /dev/null
@@ -1,16 +0,0 @@
-[package]
-
-name = "html5ever_macros"
-version = "0.0.0"
-authors = [ "The html5ever Project Developers" ]
-
-[lib]
-
-name = "html5ever_macros"
-plugin = true
-
-[dependencies]
-rustc-serialize = "0"
-
-[dependencies.mac]
-git = "https://github.com/reem/rust-mac"
diff --git a/html5ever-2015-05-15/macros/src/named_entities.rs b/html5ever-2015-05-15/macros/src/named_entities.rs
deleted file mode 100644
index f31924d6d..000000000
--- a/html5ever-2015-05-15/macros/src/named_entities.rs
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2014 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-#![allow(unused_imports)] // for quotes
-
-use std::path::PathBuf;
-use std::fs;
-use std::str::FromStr;
-use std::collections::HashMap;
-use std::convert::From;
-
-use rustc_serialize::json;
-use rustc_serialize::json::Json;
-use rustc_serialize::Decodable;
-use syntax::codemap::Span;
-use syntax::ast::{Path, ExprLit, Lit_, TokenTree};
-use syntax::parse::token;
-use syntax::ext::base::{ExtCtxt, MacResult, MacEager};
-use syntax::ext::source_util::expand_file;
-
-// A struct matching the entries in entities.json.
-// Simplifies JSON parsing because we can use Decodable.
-#[derive(RustcDecodable)]
-struct CharRef {
- codepoints: Vec,
- //characters: String, // Present in the file but we don't need it
-}
-
-// Build the map from entity names (and their prefixes) to characters.
-fn build_map(js: Json) -> Option> {
- let mut map = HashMap::new();
- let json_map = match js {
- Json::Object(m) => m,
- _ => return None,
- };
-
- // Add every named entity to the map.
- for (k,v) in json_map.into_iter() {
- let mut decoder = json::Decoder::new(v);
- let CharRef { codepoints }: CharRef
- = Decodable::decode(&mut decoder).ok().expect("bad CharRef");
-
- assert!((codepoints.len() >= 1) && (codepoints.len() <= 2));
- let mut codepoint_pair = [0, 0];
- for (i,n) in codepoints.into_iter().enumerate() {
- codepoint_pair[i] = n;
- }
-
- // Slice off the initial '&'
- assert!(k.chars().next() == Some('&'));
- map.insert(k[1..].to_string(), codepoint_pair);
- }
-
- // Add every missing prefix of those keys, mapping to NULL characters.
- map.insert("".to_string(), [0, 0]);
- let keys: Vec = map.keys().map(|k| k.to_string()).collect();
- for k in keys.into_iter() {
- for n in 1 .. k.len() {
- let pfx = k[..n].to_string();
- if !map.contains_key(&pfx) {
- map.insert(pfx, [0, 0]);
- }
- }
- }
-
- Some(map)
-}
-
-// Expand named_entities!("path/to/entities.json") into an invocation of phf_map!().
-pub fn expand(cx: &mut ExtCtxt, sp: Span, tt: &[TokenTree]) -> Box {
- let usage = "Usage: named_entities!(\"path/to/entities.json\")";
-
- // Argument to the macro should be a single literal string: a path to
- // entities.json, relative to the file containing the macro invocation.
- let json_filename = match tt {
- [TokenTree::Token(_, token::Literal(token::Lit::Str_(s), _))] => s.as_str().to_string(),
- _ => ext_bail!(cx, sp, usage),
- };
-
- // Get the result of calling file!() in the same place as our macro.
- let mod_filename = ext_expect!(cx, sp, match expand_file(cx, sp, &[]).make_expr() {
- Some(e) => match e.node {
- ExprLit(ref s) => match s.node {
- Lit_::LitStr(ref s, _) => Some(s.to_string()),
- _ => None,
- },
- _ => None,
- },
- _ => None,
- }, "unexpected result from file!()");
-
- // Combine those to get an absolute path to entities.json.
- let mut path: PathBuf = From::from(&mod_filename);
- path.pop();
- path.push(&json_filename);
-
- // Open the JSON file, parse it, and build the map from names to characters.
- let mut json_file = ext_expect!(cx, sp, fs::File::open(&path).ok(),
- "can't open JSON file");
- let js = ext_expect!(cx, sp, Json::from_reader(&mut json_file).ok(),
- "can't parse JSON file");
- let map = ext_expect!(cx, sp, build_map(js),
- "JSON file does not match entities.json format");
-
- // Emit a macro invocation of the form
- //
- // phf_map!(k => v, k => v, ...)
- let toks: Vec<_> = map.into_iter().flat_map(|(k, [c0, c1])| {
- let k = &k[..];
- (quote_tokens!(&mut *cx, $k => [$c0, $c1],)).into_iter()
- }).collect();
- MacEager::expr(quote_expr!(&mut *cx, phf_map!($toks)))
-}
diff --git a/html5ever-2015-05-15/src/driver.rs b/html5ever-2015-05-15/src/driver.rs
deleted file mode 100644
index 6fb359ded..000000000
--- a/html5ever-2015-05-15/src/driver.rs
+++ /dev/null
@@ -1,153 +0,0 @@
-// Copyright 2014 The html5ever Project Developers. See the
-// COPYRIGHT file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 or the MIT license
-// , at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! High-level interface to the parser.
-
-use tokenizer::{TokenizerOpts, Tokenizer, TokenSink};
-use tree_builder::{TreeBuilderOpts, TreeBuilder, TreeSink};
-
-use std::option;
-use std::default::Default;
-
-use string_cache::{Atom, QualName};
-
-/// Convenience function to turn a single `String` into an iterator.
-pub fn one_input(x: String) -> option::IntoIter {
- Some(x).into_iter()
-}
-
-/// Tokenize and send results to a `TokenSink`.
-///
-/// ## Example
-///
-/// ```ignore
-/// let mut sink = MySink;
-/// tokenize_to(&mut sink, one_input(my_str), Default::default());
-/// ```
-pub fn tokenize_to<
- Sink: TokenSink,
- It: Iterator-
- >(
- sink: Sink,
- input: It,
- opts: TokenizerOpts) -> Sink {
-
- let mut tok = Tokenizer::new(sink, opts);
- for s in input {
- tok.feed(s);
- }
- tok.end();
- tok.unwrap()
-}
-
-/// All-encompassing options struct for the parser.
-#[derive(Clone, Default)]
-pub struct ParseOpts {
- /// Tokenizer options.
- pub tokenizer: TokenizerOpts,
-
- /// Tree builder options.
- pub tree_builder: TreeBuilderOpts,
-}
-
-/// Parse and send results to a `TreeSink`.
-///
-/// ## Example
-///
-/// ```ignore
-/// let mut sink = MySink;
-/// parse_to(&mut sink, one_input(my_str), Default::default());
-/// ```
-pub fn parse_to<
- Sink: TreeSink,
- It: Iterator
-
- >(
- sink: Sink,
- input: It,
- opts: ParseOpts) -> Sink {
-
- let tb = TreeBuilder::new(sink, opts.tree_builder);
- let mut tok = Tokenizer::new(tb, opts.tokenizer);
- for s in input {
- tok.feed(s);
- }
- tok.end();
- tok.unwrap().unwrap()
-}
-
-/// Parse an HTML fragment and send results to a `TreeSink`.
-///
-/// ## Example
-///
-/// ```ignore
-/// let mut sink = MySink;
-/// parse_fragment_to(&mut sink, one_input(my_str), context_token, Default::default());
-/// ```
-pub fn parse_fragment_to<
- Sink: TreeSink,
- It: Iterator
-
- >(
- sink: Sink,
- input: It,
- context: Atom,
- opts: ParseOpts) -> Sink {
-
- let mut sink = sink;
- let context_elem = sink.create_element(QualName::new(ns!(HTML), context), vec!());
- let tb = TreeBuilder::new_for_fragment(sink, context_elem, None, opts.tree_builder);
- let tok_opts = TokenizerOpts {
- initial_state: Some(tb.tokenizer_state_for_context_elem()),
- .. opts.tokenizer
- };
- let mut tok = Tokenizer::new(tb, tok_opts);
- for s in input {
- tok.feed(s);
- }
- tok.end();
- tok.unwrap().unwrap()
-}
-
-/// Results which can be extracted from a `TreeSink`.
-///
-/// Implement this for your parse tree data type so that it
-/// can be returned by `parse()`.
-pub trait ParseResult {
- type Sink: TreeSink + Default;
- fn get_result(sink: Self::Sink) -> Self;
-}
-
-/// Parse into a type which implements `ParseResult`.
-///
-/// ## Example
-///
-/// ```ignore
-/// let dom: RcDom = parse(one_input(my_str), Default::default());
-/// ```
-pub fn parse