diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-08-19 18:00:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-19 18:00:06 -0400 |
commit | 171a08270dc3f5eaa238570898d67f422519534b (patch) | |
tree | 1f91781f417f2ca1a088fafa2fb74e5f9f146e1e /components/script/webdriver_handlers.rs | |
parent | fb5a12159a2f7e84ac2470952078a4dafa3ce28e (diff) | |
parent | d3696baf27fb77d67b012a90403b6c699ca40484 (diff) | |
download | servo-171a08270dc3f5eaa238570898d67f422519534b.tar.gz servo-171a08270dc3f5eaa238570898d67f422519534b.zip |
Auto merge of #23943 - georgeroman:implement_take_element_screenshot_wd_command, r=jdm
Implement TakeElementScreenshot WebDriver command
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
<!-- Either: -->
- [X] There are tests for these changes
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23943)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r-- | components/script/webdriver_handlers.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs index 22d3e56fcaf..564dc7ceb4d 100644 --- a/components/script/webdriver_handlers.rs +++ b/components/script/webdriver_handlers.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::dom::bindings::codegen::Bindings::CSSStyleDeclarationBinding::CSSStyleDeclarationMethods; +use crate::dom::bindings::codegen::Bindings::DOMRectBinding::DOMRectMethods; use crate::dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods; use crate::dom::bindings::codegen::Bindings::ElementBinding::ElementMethods; use crate::dom::bindings::codegen::Bindings::HTMLElementBinding::HTMLElementMethods; @@ -776,6 +777,30 @@ pub fn handle_get_rect( .unwrap(); } +pub fn handle_get_bounding_client_rect( + documents: &Documents, + pipeline: PipelineId, + element_id: String, + reply: IpcSender<Result<Rect<f32>, ErrorStatus>>, +) { + reply + .send( + find_node_by_unique_id(documents, pipeline, element_id).and_then(|node| match node + .downcast::<Element>( + ) { + Some(element) => { + let rect = element.GetBoundingClientRect(); + Ok(Rect::new( + Point2D::new(rect.X() as f32, rect.Y() as f32), + Size2D::new(rect.Width() as f32, rect.Height() as f32), + )) + }, + None => Err(ErrorStatus::UnknownError), + }), + ) + .unwrap(); +} + pub fn handle_get_text( documents: &Documents, pipeline: PipelineId, |