aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2015-11-21 11:09:50 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2015-11-21 11:09:50 +0530
commit585d2d5c8c4e59be20ab9660dab75fc55438e247 (patch)
tree87ad7d13d6b4a2979ac8b24e38536f502758ed8f /components/script
parent18ee6bc30a90855beb7574a5e7627b436e12c193 (diff)
parentf7258e4fccf9b7f8efc4b3a33203cacfe47d647a (diff)
downloadservo-585d2d5c8c4e59be20ab9660dab75fc55438e247.tar.gz
servo-585d2d5c8c4e59be20ab9660dab75fc55438e247.zip
Auto merge of #8621 - jgraham:webdriver_css, r=jdm
Add support for getting an element's computed style through WebDriver. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8621) <!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r--components/script/script_task.rs2
-rw-r--r--components/script/webdriver_handlers.rs17
2 files changed, 19 insertions, 0 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 043c0574be1..86e1493409c 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -1108,6 +1108,8 @@ impl ScriptTask {
webdriver_handlers::handle_get_name(&page, pipeline_id, node_id, reply),
WebDriverScriptCommand::GetElementAttribute(node_id, name, reply) =>
webdriver_handlers::handle_get_attribute(&page, pipeline_id, node_id, name, reply),
+ WebDriverScriptCommand::GetElementCSS(node_id, name, reply) =>
+ webdriver_handlers::handle_get_css(&page, pipeline_id, node_id, name, reply),
WebDriverScriptCommand::GetElementText(node_id, reply) =>
webdriver_handlers::handle_get_text(&page, pipeline_id, node_id, reply),
WebDriverScriptCommand::GetFrameId(frame_id, reply) =>
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,