Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d.

This commit is contained in:
Ms2ger 2014-12-17 10:42:52 +01:00 committed by Josh Matthews
parent b8900782b0
commit 466faac2a5
223 changed files with 4414 additions and 4105 deletions

View file

@ -5,8 +5,8 @@
//! Element nodes.
use dom::activation::Activatable;
use dom::attr::{Attr, ReplacedAttr, FirstSetAttr, AttrHelpers, AttrHelpersForLayout};
use dom::attr::{AttrValue, StringAttrValue, UIntAttrValue, AtomAttrValue};
use dom::attr::{Attr, AttrSettingType, AttrHelpers, AttrHelpersForLayout};
use dom::attr::AttrValue;
use dom::namednodemap::NamedNodeMap;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::AttrBinding::AttrMethods;
@ -21,18 +21,20 @@ use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLTableEle
use dom::bindings::codegen::InheritTypes::{HTMLTableElementDerived, HTMLTableCellElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementDerived, HTMLTextAreaElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLTableSectionElementDerived, NodeCast};
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{NamespaceError, InvalidCharacter, Syntax};
use dom::bindings::js::{MutNullableJS, JS, JSRef, Temporary, TemporaryPushable};
use dom::bindings::js::{OptionalRootable, Root};
use dom::bindings::utils::{Reflectable, Reflector};
use dom::bindings::error::{ErrorResult, Fallible, NamespaceError, InvalidCharacter, Syntax};
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
use dom::bindings::utils::xml_name_type;
use dom::bindings::utils::XMLName::{QName, Name, InvalidXMLName};
use dom::create::create_element;
use dom::domrect::DOMRect;
use dom::domrectlist::DOMRectList;
use dom::document::{Document, DocumentHelpers, LayoutDocumentHelpers};
use dom::domtokenlist::DOMTokenList;
use dom::event::Event;
use dom::eventtarget::{EventTarget, NodeTargetTypeId, EventTargetHelpers};
use dom::eventtarget::{EventTarget, EventTargetTypeId, EventTargetHelpers};
use dom::htmlbodyelement::{HTMLBodyElement, HTMLBodyElementHelpers};
use dom::htmlcollection::HTMLCollection;
use dom::htmlinputelement::{HTMLInputElement, RawLayoutHTMLInputElementHelpers, HTMLInputElementHelpers};
@ -42,16 +44,14 @@ use dom::htmltablecellelement::{HTMLTableCellElement, HTMLTableCellElementHelper
use dom::htmltablerowelement::{HTMLTableRowElement, HTMLTableRowElementHelpers};
use dom::htmltablesectionelement::{HTMLTableSectionElement, HTMLTableSectionElementHelpers};
use dom::htmltextareaelement::{HTMLTextAreaElement, RawLayoutHTMLTextAreaElementHelpers};
use dom::node::{CLICK_IN_PROGRESS, ElementNodeTypeId, LayoutNodeHelpers, Node, NodeHelpers};
use dom::node::{NodeIterator, NodeStyleDamaged, OtherNodeDamage, document_from_node};
use dom::node::{CLICK_IN_PROGRESS, LayoutNodeHelpers, Node, NodeHelpers, NodeTypeId};
use dom::node::{NodeIterator, document_from_node, NodeDamage};
use dom::node::{window_from_node};
use dom::nodelist::NodeList;
use dom::virtualmethods::{VirtualMethods, vtable_for};
use devtools_traits::AttrInfo;
use style::{mod, AuthorOrigin, BgColorSimpleColorAttribute, BorderUnsignedIntegerAttribute};
use style::{ColSpanUnsignedIntegerAttribute, IntegerAttribute, LengthAttribute, ParserContext};
use style::{SimpleColorAttribute, SizeIntegerAttribute, ColsIntegerAttribute, RowsIntegerAttribute};
use style::{UnsignedIntegerAttribute, WidthLengthAttribute, matches};
use style::{mod, StylesheetOrigin, SimpleColorAttribute, UnsignedIntegerAttribute};
use style::{IntegerAttribute, LengthAttribute, ParserContext, matches};
use servo_util::namespace;
use servo_util::str::{DOMString, LengthOrPercentageOrAuto};
@ -79,7 +79,7 @@ impl ElementDerived for EventTarget {
#[inline]
fn is_element(&self) -> bool {
match *self.type_id() {
NodeTargetTypeId(ElementNodeTypeId(_)) => true,
EventTargetTypeId::Node(NodeTypeId::Element(_)) => true,
_ => false
}
}
@ -94,75 +94,75 @@ impl Reflectable for Element {
#[deriving(PartialEq, Show)]
#[jstraceable]
pub enum ElementTypeId {
HTMLElementTypeId,
HTMLAnchorElementTypeId,
HTMLAppletElementTypeId,
HTMLAreaElementTypeId,
HTMLAudioElementTypeId,
HTMLBaseElementTypeId,
HTMLBRElementTypeId,
HTMLBodyElementTypeId,
HTMLButtonElementTypeId,
HTMLCanvasElementTypeId,
HTMLDataElementTypeId,
HTMLDataListElementTypeId,
HTMLDirectoryElementTypeId,
HTMLDListElementTypeId,
HTMLDivElementTypeId,
HTMLEmbedElementTypeId,
HTMLFieldSetElementTypeId,
HTMLFontElementTypeId,
HTMLFormElementTypeId,
HTMLFrameElementTypeId,
HTMLFrameSetElementTypeId,
HTMLHRElementTypeId,
HTMLHeadElementTypeId,
HTMLHeadingElementTypeId,
HTMLHtmlElementTypeId,
HTMLIFrameElementTypeId,
HTMLImageElementTypeId,
HTMLInputElementTypeId,
HTMLLabelElementTypeId,
HTMLLegendElementTypeId,
HTMLLinkElementTypeId,
HTMLLIElementTypeId,
HTMLMapElementTypeId,
HTMLMediaElementTypeId,
HTMLMetaElementTypeId,
HTMLMeterElementTypeId,
HTMLModElementTypeId,
HTMLObjectElementTypeId,
HTMLOListElementTypeId,
HTMLOptGroupElementTypeId,
HTMLOptionElementTypeId,
HTMLOutputElementTypeId,
HTMLParagraphElementTypeId,
HTMLParamElementTypeId,
HTMLPreElementTypeId,
HTMLProgressElementTypeId,
HTMLQuoteElementTypeId,
HTMLScriptElementTypeId,
HTMLSelectElementTypeId,
HTMLSourceElementTypeId,
HTMLSpanElementTypeId,
HTMLStyleElementTypeId,
HTMLTableElementTypeId,
HTMLTableCaptionElementTypeId,
HTMLTableDataCellElementTypeId,
HTMLTableHeaderCellElementTypeId,
HTMLTableColElementTypeId,
HTMLTableRowElementTypeId,
HTMLTableSectionElementTypeId,
HTMLTemplateElementTypeId,
HTMLTextAreaElementTypeId,
HTMLTimeElementTypeId,
HTMLTitleElementTypeId,
HTMLTrackElementTypeId,
HTMLUListElementTypeId,
HTMLVideoElementTypeId,
HTMLUnknownElementTypeId,
HTMLElement,
HTMLAnchorElement,
HTMLAppletElement,
HTMLAreaElement,
HTMLAudioElement,
HTMLBaseElement,
HTMLBRElement,
HTMLBodyElement,
HTMLButtonElement,
HTMLCanvasElement,
HTMLDataElement,
HTMLDataListElement,
HTMLDirectoryElement,
HTMLDListElement,
HTMLDivElement,
HTMLEmbedElement,
HTMLFieldSetElement,
HTMLFontElement,
HTMLFormElement,
HTMLFrameElement,
HTMLFrameSetElement,
HTMLHRElement,
HTMLHeadElement,
HTMLHeadingElement,
HTMLHtmlElement,
HTMLIFrameElement,
HTMLImageElement,
HTMLInputElement,
HTMLLabelElement,
HTMLLegendElement,
HTMLLinkElement,
HTMLLIElement,
HTMLMapElement,
HTMLMediaElement,
HTMLMetaElement,
HTMLMeterElement,
HTMLModElement,
HTMLObjectElement,
HTMLOListElement,
HTMLOptGroupElement,
HTMLOptionElement,
HTMLOutputElement,
HTMLParagraphElement,
HTMLParamElement,
HTMLPreElement,
HTMLProgressElement,
HTMLQuoteElement,
HTMLScriptElement,
HTMLSelectElement,
HTMLSourceElement,
HTMLSpanElement,
HTMLStyleElement,
HTMLTableElement,
HTMLTableCaptionElement,
HTMLTableDataCellElement,
HTMLTableHeaderCellElement,
HTMLTableColElement,
HTMLTableRowElement,
HTMLTableSectionElement,
HTMLTemplateElement,
HTMLTextAreaElement,
HTMLTimeElement,
HTMLTitleElement,
HTMLTrackElement,
HTMLUListElement,
HTMLVideoElement,
HTMLUnknownElement,
ElementTypeId_,
Element,
}
#[deriving(PartialEq)]
@ -183,7 +183,7 @@ impl Element {
pub fn new_inherited(type_id: ElementTypeId, local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: JSRef<Document>) -> Element {
Element {
node: Node::new_inherited(ElementNodeTypeId(type_id), document),
node: Node::new_inherited(NodeTypeId::Element(type_id), document),
local_name: Atom::from_slice(local_name.as_slice()),
namespace: namespace,
prefix: prefix,
@ -195,7 +195,7 @@ impl Element {
}
pub fn new(local_name: DOMString, namespace: Namespace, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<Element> {
Node::reflect_node(box Element::new_inherited(ElementTypeId_, local_name, namespace, prefix, document),
Node::reflect_node(box Element::new_inherited(ElementTypeId::Element, local_name, namespace, prefix, document),
document, ElementBinding::Wrap)
}
}
@ -300,7 +300,7 @@ impl RawLayoutElementHelpers for Element {
unsafe fn get_length_attribute_for_layout(&self, length_attribute: LengthAttribute)
-> LengthOrPercentageOrAuto {
match length_attribute {
WidthLengthAttribute => {
LengthAttribute::Width => {
if self.is_htmltableelement() {
let this: &HTMLTableElement = mem::transmute(self);
this.get_width()
@ -318,21 +318,21 @@ impl RawLayoutElementHelpers for Element {
unsafe fn get_integer_attribute_for_layout(&self, integer_attribute: IntegerAttribute)
-> Option<i32> {
match integer_attribute {
SizeIntegerAttribute => {
IntegerAttribute::Size => {
if !self.is_htmlinputelement() {
panic!("I'm not a form input!")
}
let this: &HTMLInputElement = mem::transmute(self);
Some(this.get_size_for_layout() as i32)
}
ColsIntegerAttribute => {
IntegerAttribute::Cols => {
if !self.is_htmltextareaelement() {
panic!("I'm not a textarea element!")
}
let this: &HTMLTextAreaElement = mem::transmute(self);
Some(this.get_cols_for_layout() as i32)
}
RowsIntegerAttribute => {
IntegerAttribute::Rows => {
if !self.is_htmltextareaelement() {
panic!("I'm not a textarea element!")
}
@ -369,7 +369,7 @@ impl RawLayoutElementHelpers for Element {
attribute: UnsignedIntegerAttribute)
-> Option<u32> {
match attribute {
BorderUnsignedIntegerAttribute => {
UnsignedIntegerAttribute::BorderUnsignedIntegerAttribute => {
if self.is_htmltableelement() {
let this: &HTMLTableElement = mem::transmute(self);
this.get_border()
@ -379,7 +379,7 @@ impl RawLayoutElementHelpers for Element {
None
}
}
ColSpanUnsignedIntegerAttribute => {
UnsignedIntegerAttribute::ColSpanUnsignedIntegerAttribute => {
if self.is_htmltablecellelement() {
let this: &HTMLTableCellElement = mem::transmute(self);
this.get_colspan()
@ -397,7 +397,7 @@ impl RawLayoutElementHelpers for Element {
unsafe fn get_simple_color_attribute_for_layout(&self, attribute: SimpleColorAttribute)
-> Option<RGBA> {
match attribute {
BgColorSimpleColorAttribute => {
SimpleColorAttribute::BgColorSimpleColorAttribute => {
if self.is_htmlbodyelement() {
let this: &HTMLBodyElement = mem::transmute(self);
this.get_background_color()
@ -612,13 +612,13 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
.map(|attr| attr.root())
.position(|attr| cb(*attr));
let (idx, set_type) = match idx {
Some(idx) => (idx, ReplacedAttr),
Some(idx) => (idx, AttrSettingType::ReplacedAttr),
None => {
let window = window_from_node(self).root();
let attr = Attr::new(*window, local_name, value.clone(),
name, namespace.clone(), prefix, Some(self));
self.attrs.borrow_mut().push_unrooted(&attr);
(self.attrs.borrow().len() - 1, FirstSetAttr)
(self.attrs.borrow().len() - 1, AttrSettingType::FirstSetAttr)
}
};
@ -631,7 +631,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
vtable_for(&NodeCast::from_ref(self))
.parse_plain_attribute(local_name, value)
} else {
StringAttrValue(value)
AttrValue::String(value)
}
}
@ -657,9 +657,9 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
if node.is_in_doc() {
let document = document_from_node(self).root();
if local_name == atom!("style") {
document.content_changed(node, NodeStyleDamaged);
document.content_changed(node, NodeDamage::NodeStyleDamaged);
} else {
document.content_changed(node, OtherNodeDamage);
document.content_changed(node, NodeDamage::OtherNodeDamage);
}
}
}
@ -725,7 +725,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
fn set_string_attribute(self, name: &Atom, value: DOMString) {
assert!(name.as_slice() == name.as_slice().to_ascii_lower().as_slice());
self.set_attribute(name, StringAttrValue(value));
self.set_attribute(name, AttrValue::String(value));
}
fn set_tokenlist_attribute(self, name: &Atom, value: DOMString) {
@ -741,8 +741,8 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
match attribute {
Some(attribute) => {
match *attribute.value() {
UIntAttrValue(_, value) => value,
_ => panic!("Expected a UIntAttrValue: \
AttrValue::UInt(_, value) => value,
_ => panic!("Expected an AttrValue::UInt: \
implement parse_plain_attribute"),
}
}
@ -751,7 +751,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
}
fn set_uint_attribute(self, name: &Atom, value: u32) {
assert!(name.as_slice() == name.as_slice().to_ascii_lower().as_slice());
self.set_attribute(name, UIntAttrValue(value.to_string(), value));
self.set_attribute(name, AttrValue::UInt(value.to_string(), value));
}
}
@ -1049,7 +1049,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
// http://dom.spec.whatwg.org/#dom-element-matches
fn Matches(self, selectors: DOMString) -> Fallible<bool> {
let parser_context = ParserContext {
origin: AuthorOrigin,
origin: StylesheetOrigin::Author,
};
match style::parse_selector_list_from_str(&parser_context, selectors.as_slice()) {
Err(()) => Err(Syntax),
@ -1097,7 +1097,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
*self.style_attribute.borrow_mut() = style;
if node.is_in_doc() {
doc.content_changed(node, NodeStyleDamaged);
doc.content_changed(node, NodeDamage::NodeStyleDamaged);
}
}
&atom!("class") => {
@ -1105,7 +1105,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() {
let document = document_from_node(*self).root();
document.content_changed(node, NodeStyleDamaged);
document.content_changed(node, NodeDamage::NodeStyleDamaged);
}
}
&atom!("id") => {
@ -1118,7 +1118,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
let value = Atom::from_slice(value.as_slice());
doc.register_named_element(*self, value);
}
doc.content_changed(node, NodeStyleDamaged);
doc.content_changed(node, NodeDamage::NodeStyleDamaged);
}
}
_ => {
@ -1126,7 +1126,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() {
let document = document_from_node(*self).root();
document.content_changed(node, OtherNodeDamage);
document.content_changed(node, NodeDamage::OtherNodeDamage);
}
}
}
@ -1146,7 +1146,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() {
let doc = document_from_node(*self).root();
doc.content_changed(node, NodeStyleDamaged);
doc.content_changed(node, NodeDamage::NodeStyleDamaged);
}
}
&atom!("id") => {
@ -1159,7 +1159,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
let value = Atom::from_slice(value.as_slice());
doc.unregister_named_element(*self, value);
}
doc.content_changed(node, NodeStyleDamaged);
doc.content_changed(node, NodeDamage::NodeStyleDamaged);
}
}
&atom!("class") => {
@ -1167,7 +1167,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() {
let document = document_from_node(*self).root();
document.content_changed(node, NodeStyleDamaged);
document.content_changed(node, NodeDamage::NodeStyleDamaged);
}
}
_ => {
@ -1175,7 +1175,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
if node.is_in_doc() {
let doc = document_from_node(*self).root();
doc.content_changed(node, OtherNodeDamage);
doc.content_changed(node, NodeDamage::OtherNodeDamage);
}
}
}
@ -1251,9 +1251,9 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
match node.type_id() {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
// selector-link
ElementNodeTypeId(HTMLAnchorElementTypeId) |
ElementNodeTypeId(HTMLAreaElementTypeId) |
ElementNodeTypeId(HTMLLinkElementTypeId) => self.get_attr(&ns!(""), &atom!("href")),
NodeTypeId::Element(ElementTypeId::HTMLAnchorElement) |
NodeTypeId::Element(ElementTypeId::HTMLAreaElement) |
NodeTypeId::Element(ElementTypeId::HTMLLinkElement) => self.get_attr(&ns!(""), &atom!("href")),
_ => None,
}
}
@ -1283,8 +1283,8 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
self.get_attribute(ns!(""), &atom!("id")).map(|attr| {
let attr = attr.root();
match *attr.value() {
AtomAttrValue(ref val) => val.clone(),
_ => panic!("`id` attribute should be AtomAttrValue"),
AttrValue::Atom(ref val) => val.clone(),
_ => panic!("`id` attribute should be AttrValue::Atom"),
}
})
}
@ -1357,7 +1357,7 @@ impl<'a> ActivationElementHelpers<'a> for JSRef<'a, Element> {
fn as_maybe_activatable(&'a self) -> Option<&'a Activatable + 'a> {
let node: JSRef<Node> = NodeCast::from_ref(*self);
match node.type_id() {
ElementNodeTypeId(HTMLInputElementTypeId) => {
NodeTypeId::Element(ElementTypeId::HTMLInputElement) => {
let element: &'a JSRef<'a, HTMLInputElement> = HTMLInputElementCast::to_borrowed_ref(self).unwrap();
Some(element as &'a Activatable + 'a)
},