aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/webdriver_handlers.rs
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-11-03 14:16:55 +0100
committerMs2ger <Ms2ger@gmail.com>2015-11-04 12:09:11 +0100
commit6b75078503f25a61084a3e9cae1b7d57de21772f (patch)
treeddfc15e73be407657f687f55d9c8b7bce5b9596c /components/script/webdriver_handlers.rs
parente6aa976462fad0aafb2d59d0a590b69a8c8b5ba9 (diff)
downloadservo-6b75078503f25a61084a3e9cae1b7d57de21772f.tar.gz
servo-6b75078503f25a61084a3e9cae1b7d57de21772f.zip
Make DOMString a newtype around String, rather than a typedef.
This should make it somewhat easier to experiment with alternative representations in the future. To reduce churn, this commit leaves the String field public, though. Also, this will allow us to use the default String type to represent the IDL USVString type, which explicitly forbids unpaired surrogates, ans as such is a better match to the Rust String type.
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r--components/script/webdriver_handlers.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index 6c74825af2d..3fcd6ef1d0c 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -24,6 +24,7 @@ use page::Page;
use script_task::get_page;
use std::rc::Rc;
use url::Url;
+use util::str::DOMString;
fn find_node_by_unique_id(page: &Rc<Page>, pipeline: PipelineId, node_id: String) -> Option<Root<Node>> {
let page = get_page(&*page, pipeline);
@@ -48,9 +49,8 @@ pub fn jsval_to_webdriver(cx: *mut JSContext, val: HandleValue) -> WebDriverJSRe
Ok(WebDriverJSValue::Number(FromJSValConvertible::from_jsval(cx, val, ()).unwrap()))
} else if val.get().is_string() {
//FIXME: use jsstring_to_str when jsval grows to_jsstring
- Ok(
- WebDriverJSValue::String(
- FromJSValConvertible::from_jsval(cx, val, StringificationBehavior::Default).unwrap()))
+ let string: DOMString = FromJSValConvertible::from_jsval(cx, val, StringificationBehavior::Default).unwrap();
+ Ok(WebDriverJSValue::String(string.0))
} else if val.get().is_null() {
Ok(WebDriverJSValue::Null)
} else {
@@ -115,7 +115,7 @@ pub fn handle_get_frame_id(page: &Rc<Page>,
pub fn handle_find_element_css(page: &Rc<Page>, _pipeline: PipelineId, selector: String,
reply: IpcSender<Result<Option<String>, ()>>) {
- reply.send(match page.document().QuerySelector(selector) {
+ reply.send(match page.document().QuerySelector(DOMString(selector)) {
Ok(node) => {
Ok(node.map(|x| x.upcast::<Node>().get_unique_id()))
}
@@ -127,7 +127,7 @@ pub fn handle_find_elements_css(page: &Rc<Page>,
_pipeline: PipelineId,
selector: String,
reply: IpcSender<Result<Vec<String>, ()>>) {
- reply.send(match page.document().QuerySelectorAll(selector) {
+ reply.send(match page.document().QuerySelectorAll(DOMString(selector)) {
Ok(ref nodes) => {
let mut result = Vec::with_capacity(nodes.Length() as usize);
for i in 0..nodes.Length() {
@@ -151,7 +151,7 @@ pub fn handle_get_active_element(page: &Rc<Page>,
}
pub fn handle_get_title(page: &Rc<Page>, _pipeline: PipelineId, reply: IpcSender<String>) {
- reply.send(page.document().Title()).unwrap();
+ reply.send(page.document().Title().0).unwrap();
}
pub fn handle_get_text(page: &Rc<Page>,
@@ -160,7 +160,7 @@ pub fn handle_get_text(page: &Rc<Page>,
reply: IpcSender<Result<String, ()>>) {
reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
Some(ref node) => {
- Ok(node.GetTextContent().unwrap_or("".to_owned()))
+ Ok(node.GetTextContent().map(|x| x.0).unwrap_or("".to_owned()))
},
None => Err(())
}).unwrap();
@@ -172,7 +172,7 @@ pub fn handle_get_name(page: &Rc<Page>,
reply: IpcSender<Result<String, ()>>) {
reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
Some(node) => {
- Ok(node.downcast::<Element>().unwrap().TagName())
+ Ok(node.downcast::<Element>().unwrap().TagName().0)
},
None => Err(())
}).unwrap();