Repository navigation
Implement GetElementRect webdriver command: #8623 - #9708
Conversation
| ServoExtensionCommand::ResetPrefs(ref x) => self.handle_reset_prefs(x), | ||
| } | ||
| } | ||
| }, |
There was a problem hiding this comment.
The comma here isn't necessary when the match-arm uses braces.
|
If we fixed #9651, GetBoundingClientRect would become inappropriate for this, I believe. |
Ah, I see... So would it be better to go back to the written out algorithm? |
|
I think so, yes. |
|
As stated in #9709, I think I'm wrong on my implementation of Review status: 0 of 4 files reviewed at latest revision, 2 unresolved discussions. components/script/webdriver_handlers.rs, line 227 [r2] (raw file): components/webdriver_server/lib.rs, line 837 [r1] (raw file): Comments from the review on Reviewable.io |
| let mut y: i32 = 0; | ||
| // Step 2 | ||
| let mut offset_parent = html_elem.GetOffsetParent(); | ||
| while offset_parent.is_some() { |
There was a problem hiding this comment.
This can be while let Some(element) = offset_parent {.
|
Review status: 0 of 4 files reviewed at latest revision, 4 unresolved discussions. components/script/webdriver_handlers.rs, line 210 [r2] (raw file): components/script/webdriver_handlers.rs, line 211 [r2] (raw file): Comments from the review on Reviewable.io |
|
Review status: 0 of 4 files reviewed at latest revision, 5 unresolved discussions. components/script/webdriver_handlers.rs, line 40 [r4] (raw file): Comments from the review on Reviewable.io |
| x += elem.OffsetLeft(); | ||
| y += elem.OffsetTop(); | ||
| elem.GetOffsetParent() | ||
| }).unwrap_or(None); |
There was a problem hiding this comment.
Why is an unwrap_or still necessary?
|
Review status: 0 of 4 files reviewed at latest revision, 6 unresolved discussions. components/script/webdriver_handlers.rs, line 209 [r4] (raw file): Also if you know a better way around this let me know! Comments from the review on Reviewable.io |
| } | ||
|
|
||
| #[derive(Clone, Copy, Deserialize, Serialize)] | ||
| pub struct WebDriverElementRect { |
There was a problem hiding this comment.
Why not a Rect from Euclid?
There was a problem hiding this comment.
Great point, didn't see that it impl'd Serialize. I'll make the change in the update.
| } | ||
| }, | ||
| None => Err(()) | ||
| }).unwrap() |
There was a problem hiding this comment.
This function doesn't look like it has a return value. Perhaps you're missing a semi-colon here?
| use dom::window::ScriptHelpers; | ||
| use euclid::point::Point2D; | ||
| use euclid::rect::Rect; | ||
| use euclid::size::Size2D; |
There was a problem hiding this comment.
Are these imports necessary?
8d2320a to
a640955
Compare
| // https://w3c.github.io/webdriver/webdriver-spec.html#dfn-calculate-the-absolute-position | ||
| match elem.downcast::<HTMLElement>() { | ||
| Some(html_elem) => { | ||
| // Step 1 |
There was a problem hiding this comment.
This will definitely confuse people as to which spec this step is following. I think this should only link to the absolute position spec.
Implement the webdriver Get Element Rect command
find_node_by_unique_id should use find instead of for-loop
|
@bors-servo r+ Thanks for working on this! |
|
📌 Commit cad3115 has been approved by |
|
⌛ Testing commit cad3115 with merge e5f3c5b... |
Implement GetElementRect webdriver command: #8623 Implement the webdriver Get Element Rect command. Originally I wrote out the algorithm for [Step 7](https://w3c.github.io/webdriver/webdriver-spec.html#dfn-calculate-the-absolute-position) and then I found `GetBoundingClientRect`, and i thought it was probably best to use it instead. As always, feedback is very welcomed! <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9708) <!-- Reviewable:end -->
|
☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-unit, mac-rel-css, mac-rel-wpt |
Implement the webdriver Get Element Rect command. Originally I wrote out the algorithm for Step 7 and then I found
GetBoundingClientRect, and i thought it was probably best to use it instead.As always, feedback is very welcomed!
#8623