aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/webdriver_handlers.rs
diff options
context:
space:
mode:
authorJames Graham <james@hoppipolla.co.uk>2015-10-23 00:48:55 +0100
committerJames Graham <james@hoppipolla.co.uk>2015-11-20 13:23:38 +0000
commitf7258e4fccf9b7f8efc4b3a33203cacfe47d647a (patch)
tree32a54e8f5a8e4df247c36747a5af077807e86ad6 /components/script/webdriver_handlers.rs
parent0146751bb227e577f54c4c0574ae36236e2bcdce (diff)
downloadservo-f7258e4fccf9b7f8efc4b3a33203cacfe47d647a.tar.gz
servo-f7258e4fccf9b7f8efc4b3a33203cacfe47d647a.zip
Add support for getting an element's computed style through WebDriver.
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r--components/script/webdriver_handlers.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index 0bf2ede1aeb..818ad20abf9 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -2,12 +2,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
use dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods;
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding::HTMLIFrameElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods;
+use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
@@ -217,6 +219,21 @@ pub fn handle_get_attribute(page: &Rc<Page>,
}).unwrap();
}
+pub fn handle_get_css(page: &Rc<Page>,
+ pipeline: PipelineId,
+ node_id: String,
+ name: String,
+ reply: IpcSender<Result<String, ()>>) {
+ reply.send(match find_node_by_unique_id(&*page, pipeline, node_id) {
+ Some(node) => {
+ let window = page.window();
+ let elem = node.downcast::<Element>().unwrap();
+ Ok(String::from(
+ window.GetComputedStyle(&elem, None).GetPropertyValue(DOMString::from(name))))
+ },
+ None => Err(())
+ }).unwrap();
+}
pub fn handle_get_url(page: &Rc<Page>,
_pipeline: PipelineId,