Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Document.createElementNS() #1391

Closed
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b3aaa4b
Document.creatElementNS() and reftest
therealglazou Dec 12, 2013
6666929
merge upstream
therealglazou Feb 21, 2014
4f8acae
Merge remote-tracking branch 'upstream/master' into therealglazou/cre…
therealglazou Feb 21, 2014
28933b1
new version of Document.createElementNS
therealglazou Feb 21, 2014
9f0e696
De-@mut pipeline
larsbergstrom Feb 11, 2014
2ec9649
Shut down the profiler in headless compositing mode
pcwalton Feb 21, 2014
4fe305c
Prevent '&nbsp' from stripping as whitespace
june0cho Feb 21, 2014
26cd50d
Fix: whitespace is considered as spaces(U+0020), tabs(U+0009), and li…
june0cho Feb 21, 2014
735d826
De-@mut the FrameTree.
larsbergstrom Feb 14, 2014
d39f028
Update rust-layers submodule
larsbergstrom Feb 19, 2014
998a561
Remove commented-out parts of Document.webidl and HTMLDocument.webidl.
Ms2ger Feb 22, 2014
f345b69
Create a Line DisplayItem
ngsankha Feb 17, 2014
a8716ad
add Element::new
therealglazou Feb 24, 2014
b4d5184
trailing ws
therealglazou Feb 24, 2014
99f02d1
reuse get_attribute_parts
therealglazou Feb 24, 2014
d5a5fb6
no lowercasing for html element names
therealglazou Feb 24, 2014
0f764df
adding comment with spec URL
therealglazou Feb 24, 2014
77bd9b0
simplify match in CreateElementNS
therealglazou Feb 24, 2014
916c5d1
simplify match in CreateElementNS
therealglazou Feb 24, 2014
f1d60a7
simplify namespace error cases
therealglazou Feb 24, 2014
575c25e
simplify namespace error cases
therealglazou Feb 24, 2014
1308285
remove the ': Namesapce'
therealglazou Feb 24, 2014
3c28d06
better test
therealglazou Feb 24, 2014
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

merge upstream

  • Loading branch information
therealglazou committed Feb 21, 2014
commit 666692991284ff5ec509d8dde4740bea03f4a5e3
@@ -154,7 +154,6 @@ DOMInterfaces = {
'createComment',
'createDocumentFragment',
'createElement',
'createElementNS',
'createTextNode',
'title',
],
@@ -310,7 +309,6 @@ DOMInterfaces = {
'appendChild',
'nodeName',
'nodeValue',
'namespaceURI',
'removeChild',
'textContent',
'childNodes'
@@ -42,8 +42,8 @@ interface Document : Node {

[Creator, Throws]
Element createElement(DOMString localName);
[Creator, Throws]
Element createElementNS(DOMString? namespace, DOMString qualifiedName);
// [Creator, Throws]
// Element createElementNS(DOMString? namespace, DOMString qualifiedName);
[Creator]
DocumentFragment createDocumentFragment();
[Creator]
@@ -3,21 +3,18 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use dom::comment::Comment;
use dom::bindings::codegen::ElementBinding;
use dom::bindings::codegen::DocumentBinding;
use dom::bindings::utils::{Reflectable, Reflector, Traceable, reflect_dom_object};
use dom::bindings::utils::{ErrorResult, Fallible, NotSupported, InvalidCharacter, NamespaceError};
use dom::bindings::utils::{ErrorResult, Fallible, NotSupported, InvalidCharacter};
use dom::bindings::utils::DOMString;
use dom::bindings::utils::{xml_name_type, InvalidXMLName, Name, QName};
use dom::bindings::utils::{xml_name_type, InvalidXMLName};
use dom::documentfragment::DocumentFragment;
use dom::element::{Element};
use dom::element::{HTMLHeadElementTypeId, HTMLTitleElementTypeId, nonHTMLTypeId};
use dom::element::{HTMLHeadElementTypeId, HTMLTitleElementTypeId};
use dom::event::{AbstractEvent, Event};
use dom::htmlcollection::HTMLCollection;
use dom::htmldocument::HTMLDocument;
use dom::mouseevent::MouseEvent;
use dom::namespace;
use dom::namespace::Namespace;
use dom::node::{AbstractNode, ScriptView, Node, ElementNodeTypeId, DocumentNodeTypeId};
use dom::text::Text;
use dom::uievent::UIEvent;
@@ -204,56 +201,6 @@ impl Document {
Ok(build_element_from_tag(local_name, abstract_self))
}

pub fn CreateElementNS(&self, abstract_self: AbstractDocument, namespace: Option<DOMString>, qualified_name: DOMString) -> Fallible<AbstractNode<ScriptView>> {
let ns: Namespace = Namespace::from_str(namespace);
let mut local_name;
match xml_name_type(qualified_name) {
InvalidXMLName => {
debug!("Not a valid element name");
return Err(InvalidCharacter);
},
Name => {
debug!("Not a valid qualified element name");
return Err(NamespaceError);
},
QName => {
let (prefix_from_qname, local_name_from_qname) = if qualified_name.contains(":") {
let parts: ~[&str] = qualified_name.splitn_iter(':', 1).collect();
(Some(parts[0].to_owned()), parts[1].to_owned())
} else {
(None, qualified_name.clone())
};
match (ns.clone(), prefix_from_qname, local_name_from_qname.clone()) {
(namespace::Null, None, _) => {},
(namespace::Null, _, _) => {
debug!("Namespace can't be null with a non-null prefix");
return Err(NamespaceError);
},
(namespace::XML, Some(~"xml"), _) => {},
(namespace::XML, _, _) => {
debug!("Namespace must be the xml namespace if the prefix is 'xml'");
return Err(NamespaceError);
},
(namespace::XMLNS, Some(~"xmlns"), _) | (namespace::XMLNS, _, ~"xmlns") => {},
(_, Some(~"xmlns"), _) | (_, _, ~"xmlns") => {
debug!("Namespace must be the xmlns namespace if the prefix or the qualified name is 'xmlns'");
return Err(NamespaceError);
},
_ => {}
}
local_name = local_name_from_qname;
}
}

if ns == namespace::HTML {
local_name = local_name.to_ascii_lower();
Ok(build_element_from_tag(local_name, abstract_self))
} else {
let element = Element::new(nonHTMLTypeId, local_name, ns, abstract_self);
Ok(Node::reflect_node(@mut element, abstract_self, ElementBinding::Wrap))
}
}

pub fn CreateDocumentFragment(&self, abstract_self: AbstractDocument) -> AbstractNode<ScriptView> {
DocumentFragment::new(abstract_self)
}
@@ -117,8 +117,6 @@ pub enum ElementTypeId {
HTMLUListElementTypeId,
HTMLVideoElementTypeId,
HTMLUnknownElementTypeId,

nonHTMLTypeId,
}

//
@@ -21,7 +21,7 @@ use dom::text::Text;

use js::jsapi::{JSObject, JSContext};
use servo_util::slot::{MutSlotRef, Slot, SlotRef};
use servo_util::tree::{TreeNode, TreeNodeRef, TreeNodeRefAsElement, ElementLike};
use servo_util::tree::{TreeNode, TreeNodeRef, TreeNodeRefAsElement};
use std::cast::transmute;
use std::cast;
use std::unstable::raw::Box;
@@ -1177,19 +1177,8 @@ impl Node<ScriptView> {
false
}

pub fn GetNamespaceURI(&self, abstract_self: AbstractNode<ScriptView>) -> Option<DOMString> {
match self.type_id {
ElementNodeTypeId(*) => {
do abstract_self.with_imm_element_like |element| {
Some(element.get_namespace())
}
}
CommentNodeTypeId |
TextNodeTypeId |
DocumentFragmentNodeTypeId |
DoctypeNodeTypeId |
DocumentNodeTypeId(_) => None
}
pub fn GetNamespaceURI(&self) -> Option<DOMString> {
None
}

pub fn GetPrefix(&self) -> Option<DOMString> {
@@ -13,4 +13,3 @@
== last_of_type_pseudo_a.html last_of_type_pseudo_b.html
== only_of_type_pseudo_a.html only_of_type_pseudo_b.html
== visibility_hidden.html visibility_hidden_ref.html
== dom_createelementns_a.html dom_createelementns_b.html

This file was deleted.

This file was deleted.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.