Skip to content

Commit

Permalink
Take the prefix from createElementNS into account for HTML elements
Browse files Browse the repository at this point in the history
Fixes #3139
  • Loading branch information
gilles-leblanc committed Oct 7, 2014
1 parent 0549ed3 commit 3a5a66d
Show file tree
Hide file tree
Showing 73 changed files with 406 additions and 478 deletions.
7 changes: 4 additions & 3 deletions components/script/dom/document.rs
Expand Up @@ -486,7 +486,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
return Err(InvalidCharacter);
}
let local_name = local_name.as_slice().to_ascii_lower();
Ok(build_element_from_tag(local_name, ns!(HTML), self))
Ok(build_element_from_tag(local_name, ns!(HTML), None, self))
}

// http://dom.spec.whatwg.org/#dom-document-createelementns
Expand Down Expand Up @@ -530,7 +530,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
}

if ns == ns!(HTML) {
Ok(build_element_from_tag(local_name_from_qname.to_string(), ns, self))
Ok(build_element_from_tag(local_name_from_qname.to_string(), ns,
prefix_from_qname.map(|s| s.to_string()), self))
} else {
Ok(Element::new(local_name_from_qname.to_string(), ns,
prefix_from_qname.map(|s| s.to_string()), self))
Expand Down Expand Up @@ -679,7 +680,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
}
},
None => {
let new_title = HTMLTitleElement::new("title".to_string(), self).root();
let new_title = HTMLTitleElement::new("title".to_string(), None, self).root();
let new_title: JSRef<Node> = NodeCast::from_ref(*new_title);

if !title.is_empty() {
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/domimplementation.rs
Expand Up @@ -131,13 +131,13 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {

{
// Step 4.
let doc_html: Root<Node> = NodeCast::from_temporary(HTMLHtmlElement::new("html".to_string(), *doc)).root();
let doc_html: Root<Node> = NodeCast::from_temporary(HTMLHtmlElement::new("html".to_string(), None, *doc)).root();
let doc_html = doc_html.deref();
assert!(doc_node.AppendChild(*doc_html).is_ok());

{
// Step 5.
let doc_head: Root<Node> = NodeCast::from_temporary(HTMLHeadElement::new("head".to_string(), *doc)).root();
let doc_head: Root<Node> = NodeCast::from_temporary(HTMLHeadElement::new("head".to_string(), None, *doc)).root();
let doc_head = doc_head.deref();
assert!(doc_html.AppendChild(*doc_head).is_ok());

Expand All @@ -146,7 +146,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
None => (),
Some(title_str) => {
// Step 6.1.
let doc_title: Root<Node> = NodeCast::from_temporary(HTMLTitleElement::new("title".to_string(), *doc)).root();
let doc_title: Root<Node> = NodeCast::from_temporary(HTMLTitleElement::new("title".to_string(), None, *doc)).root();
let doc_title = doc_title.deref();
assert!(doc_head.AppendChild(*doc_title).is_ok());

Expand All @@ -159,7 +159,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
}

// Step 7.
let doc_body: Root<HTMLBodyElement> = HTMLBodyElement::new("body".to_string(), *doc).root();
let doc_body: Root<HTMLBodyElement> = HTMLBodyElement::new("body".to_string(), None, *doc).root();
let doc_body = doc_body.deref();
assert!(doc_html.AppendChild(NodeCast::from_ref(*doc_body)).is_ok());
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlanchorelement.rs
Expand Up @@ -34,15 +34,15 @@ impl HTMLAnchorElementDerived for EventTarget {
}

impl HTMLAnchorElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAnchorElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLAnchorElement {
HTMLAnchorElement {
htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLAnchorElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAnchorElement> {
let element = HTMLAnchorElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLAnchorElement> {
let element = HTMLAnchorElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLAnchorElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlappletelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLAppletElementDerived for EventTarget {
}

impl HTMLAppletElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAppletElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLAppletElement {
HTMLAppletElement {
htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLAppletElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAppletElement> {
let element = HTMLAppletElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLAppletElement> {
let element = HTMLAppletElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLAppletElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlareaelement.rs
Expand Up @@ -27,15 +27,15 @@ impl HTMLAreaElementDerived for EventTarget {
}

impl HTMLAreaElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAreaElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLAreaElement {
HTMLAreaElement {
htmlelement: HTMLElement::new_inherited(HTMLAreaElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLAreaElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAreaElement> {
let element = HTMLAreaElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLAreaElement> {
let element = HTMLAreaElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLAreaElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlaudioelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLAudioElementDerived for EventTarget {
}

impl HTMLAudioElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLAudioElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLAudioElement {
HTMLAudioElement {
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLAudioElementTypeId, localName, document)
htmlmediaelement: HTMLMediaElement::new_inherited(HTMLAudioElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLAudioElement> {
let element = HTMLAudioElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLAudioElement> {
let element = HTMLAudioElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLAudioElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlbaseelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLBaseElementDerived for EventTarget {
}

impl HTMLBaseElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBaseElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLBaseElement {
HTMLBaseElement {
htmlelement: HTMLElement::new_inherited(HTMLBaseElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLBaseElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLBaseElement> {
let element = HTMLBaseElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBaseElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlbodyelement.rs
Expand Up @@ -33,15 +33,15 @@ impl HTMLBodyElementDerived for EventTarget {
}

impl HTMLBodyElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBodyElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLBodyElement {
HTMLBodyElement {
htmlelement: HTMLElement::new_inherited(HTMLBodyElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLBodyElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLBodyElement> {
let element = HTMLBodyElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLBodyElement> {
let element = HTMLBodyElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBodyElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlbrelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLBRElementDerived for EventTarget {
}

impl HTMLBRElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLBRElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLBRElement {
HTMLBRElement {
htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLBRElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLBRElement> {
let element = HTMLBRElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLBRElement> {
let element = HTMLBRElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLBRElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlbuttonelement.rs
Expand Up @@ -32,15 +32,15 @@ impl HTMLButtonElementDerived for EventTarget {
}

impl HTMLButtonElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLButtonElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLButtonElement {
HTMLButtonElement {
htmlelement: HTMLElement::new_inherited(HTMLButtonElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLButtonElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLButtonElement> {
let element = HTMLButtonElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLButtonElement> {
let element = HTMLButtonElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLButtonElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlcanvaselement.rs
Expand Up @@ -44,18 +44,18 @@ impl HTMLCanvasElementDerived for EventTarget {
}

impl HTMLCanvasElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLCanvasElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLCanvasElement {
HTMLCanvasElement {
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, document),
htmlelement: HTMLElement::new_inherited(HTMLCanvasElementTypeId, localName, prefix, document),
context: Default::default(),
width: Cell::new(DefaultWidth),
height: Cell::new(DefaultHeight),
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLCanvasElement> {
let element = HTMLCanvasElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLCanvasElement> {
let element = HTMLCanvasElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLCanvasElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmldataelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLDataElementDerived for EventTarget {
}

impl HTMLDataElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDataElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLDataElement {
HTMLDataElement {
htmlelement: HTMLElement::new_inherited(HTMLDataElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLDataElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDataElement> {
let element = HTMLDataElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLDataElement> {
let element = HTMLDataElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLDataElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmldatalistelement.rs
Expand Up @@ -29,15 +29,15 @@ impl HTMLDataListElementDerived for EventTarget {
}

impl HTMLDataListElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDataListElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLDataListElement {
HTMLDataListElement {
htmlelement: HTMLElement::new_inherited(HTMLDataListElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLDataListElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDataListElement> {
let element = HTMLDataListElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLDataListElement> {
let element = HTMLDataListElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLDataListElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmldirectoryelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLDirectoryElementDerived for EventTarget {
}

impl HTMLDirectoryElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDirectoryElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLDirectoryElement {
HTMLDirectoryElement {
htmlelement: HTMLElement::new_inherited(HTMLDirectoryElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLDirectoryElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDirectoryElement> {
let element = HTMLDirectoryElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLDirectoryElement> {
let element = HTMLDirectoryElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLDirectoryElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmldivelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLDivElementDerived for EventTarget {
}

impl HTMLDivElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDivElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLDivElement {
HTMLDivElement {
htmlelement: HTMLElement::new_inherited(HTMLDivElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLDivElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDivElement> {
let element = HTMLDivElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLDivElement> {
let element = HTMLDivElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLDivElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmldlistelement.rs
Expand Up @@ -26,15 +26,15 @@ impl HTMLDListElementDerived for EventTarget {
}

impl HTMLDListElement {
fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLDListElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLDListElement {
HTMLDListElement {
htmlelement: HTMLElement::new_inherited(HTMLDListElementTypeId, localName, document)
htmlelement: HTMLElement::new_inherited(HTMLDListElementTypeId, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLDListElement> {
let element = HTMLDListElement::new_inherited(localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLDListElement> {
let element = HTMLDListElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLDListElementBinding::Wrap)
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/htmlelement.rs
Expand Up @@ -37,15 +37,15 @@ impl HTMLElementDerived for EventTarget {
}

impl HTMLElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, document: JSRef<Document>) -> HTMLElement {
pub fn new_inherited(type_id: ElementTypeId, tag_name: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLElement {
HTMLElement {
element: Element::new_inherited(type_id, tag_name, ns!(HTML), None, document)
element: Element::new_inherited(type_id, tag_name, ns!(HTML), prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLElement> {
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, document);
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLElement> {
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, prefix, document);
Node::reflect_node(box element, document, HTMLElementBinding::Wrap)
}
}
Expand Down

5 comments on commit 3a5a66d

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from Ms2ger
at gilles-leblanc@3a5a66d

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging gilles-leblanc/servo/issue-3139 = 3a5a66d into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gilles-leblanc/servo/issue-3139 = 3a5a66d merged ok, testing candidate = a4b4147

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = a4b4147

Please sign in to comment.