{"action":"created","issue":{"url":"https://api.github.com/repos/servo/servo/issues/8932","labels_url":"https://api.github.com/repos/servo/servo/issues/8932/labels{/name}","comments_url":"https://api.github.com/repos/servo/servo/issues/8932/comments","events_url":"https://api.github.com/repos/servo/servo/issues/8932/events","html_url":"https://github.com/servo/servo/pull/8932","id":121677577,"number":8932,"title":"Implement Document#elementFromPoint","user":{"login":"rilut","id":1331389,"avatar_url":"https://avatars.githubusercontent.com/u/1331389?v=3","gravatar_id":"","url":"https://api.github.com/users/rilut","html_url":"https://github.com/rilut","followers_url":"https://api.github.com/users/rilut/followers","following_url":"https://api.github.com/users/rilut/following{/other_user}","gists_url":"https://api.github.com/users/rilut/gists{/gist_id}","starred_url":"https://api.github.com/users/rilut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rilut/subscriptions","organizations_url":"https://api.github.com/users/rilut/orgs","repos_url":"https://api.github.com/users/rilut/repos","events_url":"https://api.github.com/users/rilut/events{/privacy}","received_events_url":"https://api.github.com/users/rilut/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/servo/servo/labels/S-needs-code-changes","name":"S-needs-code-changes","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"login":"nox","id":123095,"avatar_url":"https://avatars.githubusercontent.com/u/123095?v=3","gravatar_id":"","url":"https://api.github.com/users/nox","html_url":"https://github.com/nox","followers_url":"https://api.github.com/users/nox/followers","following_url":"https://api.github.com/users/nox/following{/other_user}","gists_url":"https://api.github.com/users/nox/gists{/gist_id}","starred_url":"https://api.github.com/users/nox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nox/subscriptions","organizations_url":"https://api.github.com/users/nox/orgs","repos_url":"https://api.github.com/users/nox/repos","events_url":"https://api.github.com/users/nox/events{/privacy}","received_events_url":"https://api.github.com/users/nox/received_events","type":"User","site_admin":false},"milestone":null,"comments":17,"created_at":"2015-12-11T10:09:40Z","updated_at":"2015-12-14T06:26:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/servo/servo/pulls/8932","html_url":"https://github.com/servo/servo/pull/8932","diff_url":"https://github.com/servo/servo/pull/8932.diff","patch_url":"https://github.com/servo/servo/pull/8932.patch"},"body":"Related to #8666. I haven't implemented elementsFromPoint, because from my past discussion with jdm, [it's not good yet](https://github.com/rilut/servo/commit/dbfa25214b2888dda7527d62b5df1bb61f1ab047#commitcomment-14668959) to implement elementsFromPoint because it may cause GC hazards (but I have no idea about the status now, I'm sorry).\r\n\r\nBy the way, I also have to include the test for this, right? I've found this [1]. So, is all I have to do is just to put this into `tests/wpt/web-platform-tests/cssom-view/elementFromPoint.html`?\r\n\r\n[1] http://test.csswg.org/suites/cssom-view-1_dev/nightly-unstable/html/elementFromPosition.htm\n\n<!-- Reviewable:start -->\n[<img src=\"https://reviewable.io/review_button.png\" height=40 alt=\"Review on Reviewable\"/>](https://reviewable.io/reviews/servo/servo/8932)\n<!-- Reviewable:end -->\n"},"comment":{"url":"https://api.github.com/repos/servo/servo/issues/comments/164356498","html_url":"https://github.com/servo/servo/pull/8932#issuecomment-164356498","issue_url":"https://api.github.com/repos/servo/servo/issues/8932","id":164356498,"user":{"login":"rilut","id":1331389,"avatar_url":"https://avatars.githubusercontent.com/u/1331389?v=3","gravatar_id":"","url":"https://api.github.com/users/rilut","html_url":"https://github.com/rilut","followers_url":"https://api.github.com/users/rilut/followers","following_url":"https://api.github.com/users/rilut/following{/other_user}","gists_url":"https://api.github.com/users/rilut/gists{/gist_id}","starred_url":"https://api.github.com/users/rilut/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rilut/subscriptions","organizations_url":"https://api.github.com/users/rilut/orgs","repos_url":"https://api.github.com/users/rilut/repos","events_url":"https://api.github.com/users/rilut/events{/privacy}","received_events_url":"https://api.github.com/users/rilut/received_events","type":"User","site_admin":false},"created_at":"2015-12-14T06:26:59Z","updated_at":"2015-12-14T06:26:59Z","body":"```\nfn ElementFromPoint(&self, x: Finite<f64>, y: Finite<f64>) -> Option<Root<Element>> {\n    let x = *x as f32;\n    let y = *y as f32;\n    let point = &Point2D { x: x, y: y };\n    let window = window_from_node(self);\n    let viewport = window.window_size().unwrap().visible_viewport;\n\n    if x < 0.0 || y < 0.0 || x > viewport.width.get() || y > viewport.height.get() {\n        return None;\n    }\n\n    let js_runtime = unsafe { JS_GetRuntime(window.get_cx()) };\n\n    match self.hit_test(point) {\n        Some(untrusted_node_address) => {\n            let rootnode =\n                node::from_untrusted_node_address(js_runtime, untrusted_node_address);\n\n            rootnode.downcast::<Element>().map(Root::from_ref)\n        },\n        None => None,\n    }\n}\n```\n\nis this okay?\n\n---\n\n\n\n\n\n\n\n*Comments from the [review on Reviewable.io](https://reviewable.io:443/reviews/servo/servo/8932#-:-K5U9hDsT-bDkH5MLquf:-863079521)*\n<!-- Sent from Reviewable.io -->\n"}}