mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Pass a Namespace to Element::get_attr.
This commit is contained in:
parent
e64ee3557e
commit
95913d1fed
8 changed files with 24 additions and 17 deletions
|
@ -15,6 +15,7 @@ use dom::event::{AbstractEvent, Event};
|
|||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::htmldocument::HTMLDocument;
|
||||
use dom::mouseevent::MouseEvent;
|
||||
use dom::namespace::Null;
|
||||
use dom::node::{AbstractNode, Node, ElementNodeTypeId, DocumentNodeTypeId};
|
||||
use dom::text::Text;
|
||||
use dom::uievent::UIEvent;
|
||||
|
@ -354,7 +355,7 @@ impl Document {
|
|||
|
||||
pub fn GetElementsByName(&self, name: DOMString) -> @mut HTMLCollection {
|
||||
self.createHTMLCollection(|elem|
|
||||
elem.get_attr(None, "name").is_some() && eq_slice(elem.get_attr(None, "name").unwrap(), name))
|
||||
elem.get_attr(Null, "name").is_some() && eq_slice(elem.get_attr(Null, "name").unwrap(), name))
|
||||
}
|
||||
|
||||
pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection {
|
||||
|
@ -434,7 +435,7 @@ fn foreach_ided_elements(root: &AbstractNode, callback: &fn(&DOMString, &Abstrac
|
|||
}
|
||||
|
||||
do node.with_imm_element |element| {
|
||||
match element.get_attr(None, "id") {
|
||||
match element.get_attr(Null, "id") {
|
||||
Some(id) => {
|
||||
callback(&id.to_str(), &node);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use dom::document::AbstractDocument;
|
|||
use dom::node::{AbstractNode, ElementNodeTypeId, Node};
|
||||
use dom::document;
|
||||
use dom::namespace;
|
||||
use dom::namespace::Namespace;
|
||||
use dom::namespace::{Namespace, Null};
|
||||
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
|
||||
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
|
||||
use layout_interface::{MatchSelectorsDocumentDamage};
|
||||
|
@ -161,8 +161,7 @@ impl<'self> Element {
|
|||
}
|
||||
|
||||
// FIXME(pcwalton): This is kind of confusingly named relative to the above...
|
||||
pub fn get_attr(&self, ns_url: Option<~str>, name: &str) -> Option<~str> {
|
||||
let namespace = Namespace::from_str(ns_url);
|
||||
pub fn get_attr(&self, namespace: Namespace, name: &str) -> Option<~str> {
|
||||
self.get_attribute(namespace, name).map(|attr| attr.value.clone())
|
||||
}
|
||||
|
||||
|
@ -287,7 +286,7 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn Id(&self, _abstract_self: AbstractNode) -> DOMString {
|
||||
match self.get_attr(None, "id") {
|
||||
match self.get_attr(Null, "id") {
|
||||
Some(x) => x,
|
||||
None => ~""
|
||||
}
|
||||
|
@ -310,7 +309,7 @@ impl Element {
|
|||
}
|
||||
|
||||
pub fn GetAttribute(&self, name: DOMString) -> Option<DOMString> {
|
||||
self.get_attr(None, name).map(|s| s.to_owned())
|
||||
self.get_attr(Null, name).map(|s| s.to_owned())
|
||||
}
|
||||
|
||||
pub fn GetAttributeNS(&self, namespace: Option<DOMString>, local_name: DOMString) -> Option<DOMString> {
|
||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::utils::{Reflectable, Reflector, Traceable};
|
|||
use dom::document::{AbstractDocument, Document, HTML};
|
||||
use dom::element::HTMLHeadElementTypeId;
|
||||
use dom::htmlcollection::HTMLCollection;
|
||||
use dom::namespace::Null;
|
||||
use dom::node::{AbstractNode, ElementNodeTypeId};
|
||||
use dom::window::Window;
|
||||
|
||||
|
@ -56,7 +57,7 @@ impl HTMLDocument {
|
|||
pub fn Links(&self) -> @mut HTMLCollection {
|
||||
self.parent.createHTMLCollection(|elem|
|
||||
(eq_slice(elem.tag_name, "a") || eq_slice(elem.tag_name, "area"))
|
||||
&& elem.get_attr(None, "href").is_some())
|
||||
&& elem.get_attr(Null, "href").is_some())
|
||||
}
|
||||
|
||||
pub fn Forms(&self) -> @mut HTMLCollection {
|
||||
|
@ -69,7 +70,7 @@ impl HTMLDocument {
|
|||
|
||||
pub fn Anchors(&self) -> @mut HTMLCollection {
|
||||
self.parent.createHTMLCollection(|elem|
|
||||
eq_slice(elem.tag_name, "a") && elem.get_attr(None, "name").is_some())
|
||||
eq_slice(elem.tag_name, "a") && elem.get_attr(Null, "name").is_some())
|
||||
}
|
||||
|
||||
pub fn Applets(&self) -> @mut HTMLCollection {
|
||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
|
|||
use dom::document::AbstractDocument;
|
||||
use dom::element::HTMLImageElementTypeId;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::namespace::Null;
|
||||
use dom::node::{AbstractNode, Node};
|
||||
use extra::url::Url;
|
||||
use servo_util::geometry::to_px;
|
||||
|
@ -40,7 +41,7 @@ impl HTMLImageElement {
|
|||
/// prefetching the image. This method must be called after `src` is changed.
|
||||
pub fn update_image(&mut self, image_cache: ImageCacheTask, url: Option<Url>) {
|
||||
let elem = &mut self.htmlelement.element;
|
||||
let src_opt = elem.get_attr(None, "src").map(|x| x.to_str());
|
||||
let src_opt = elem.get_attr(Null, "src").map(|x| x.to_str());
|
||||
match src_opt {
|
||||
None => {}
|
||||
Some(src) => {
|
||||
|
|
|
@ -7,6 +7,7 @@ use dom::bindings::utils::{DOMString, ErrorResult};
|
|||
use dom::document::AbstractDocument;
|
||||
use dom::element::HTMLScriptElementTypeId;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::namespace::Null;
|
||||
use dom::node::{AbstractNode, Node};
|
||||
use style::TElement;
|
||||
|
||||
|
@ -29,7 +30,7 @@ impl HTMLScriptElement {
|
|||
|
||||
impl HTMLScriptElement {
|
||||
pub fn Src(&self) -> DOMString {
|
||||
match self.htmlelement.element.get_attr(None, "src") {
|
||||
match self.htmlelement.element.get_attr(Null, "src") {
|
||||
Some(s) => s.to_owned(),
|
||||
None => ~""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue