aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/webdriver_handlers.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-07-24 11:54:47 -0400
committerGitHub <noreply@github.com>2019-07-24 11:54:47 -0400
commit9b14bbdc98ea078a4f868abee1b7c7244161f46d (patch)
treec3061b4cc48e42c8fa247d43cdd0f263e70be0df /components/script/webdriver_handlers.rs
parent410c8e5085b45d5d0628159cecc3df05f82ac87d (diff)
parent88cacfb0098e20be70c27bfde6b74cd3290f1fe4 (diff)
downloadservo-9b14bbdc98ea078a4f868abee1b7c7244161f46d.tar.gz
servo-9b14bbdc98ea078a4f868abee1b7c7244161f46d.zip
Auto merge of #23816 - marmeladema:issue-20377, r=jdm
Wrapping unsafe raw JSContext pointers in a safe struct. Part 1. Wrapping unsafe raw JSContext pointers in a safe struct. Issue #20377. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] create a struct JSContext(*mut jsapi::JSContext) type - [x] implement Deref for this new type so it's easy to obtain the inner context pointer - [x] add an unsafe from_ptr static method that returns a new instance of the type - [x] start by changing various Argument uses in CodegenRust.py for python classes that inherit from CGAbstractMethod - [x] convert the python code that interacts with CGClass (CGCallback, CGCallbackFunction, CGCallbackFunctionImpl, CGCallbackInterface) and any rust code that interacts with it - [x] update CGDictionary and any rust code that interacts with it - [x] make the code generator declare trait methods that accept the new type instead of *mut JSContext (CGInterfaceTrait) - [x] modify GlobalScope::get_cx to return a SafeJSContext <!-- 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/23816) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/webdriver_handlers.rs')
-rw-r--r--components/script/webdriver_handlers.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/components/script/webdriver_handlers.rs b/components/script/webdriver_handlers.rs
index ab08c0efe7d..c8aad9a6b4c 100644
--- a/components/script/webdriver_handlers.rs
+++ b/components/script/webdriver_handlers.rs
@@ -145,11 +145,11 @@ pub fn handle_execute_script(
Some(window) => {
let result = unsafe {
let cx = window.get_cx();
- rooted!(in(cx) let mut rval = UndefinedValue());
+ rooted!(in(*cx) let mut rval = UndefinedValue());
window
.upcast::<GlobalScope>()
.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
- jsval_to_webdriver(cx, rval.handle())
+ jsval_to_webdriver(*cx, rval.handle())
};
reply.send(result).unwrap();
@@ -171,7 +171,7 @@ pub fn handle_execute_async_script(
Some(window) => {
let cx = window.get_cx();
window.set_webdriver_script_chan(Some(reply));
- rooted!(in(cx) let mut rval = UndefinedValue());
+ rooted!(in(*cx) let mut rval = UndefinedValue());
window
.upcast::<GlobalScope>()
.evaluate_js_on_global_with_result(&eval, rval.handle_mut());
@@ -725,21 +725,21 @@ pub fn handle_get_property(
Some(node) => {
let cx = documents.find_document(pipeline).unwrap().window().get_cx();
- rooted!(in(cx) let mut property = UndefinedValue());
+ rooted!(in(*cx) let mut property = UndefinedValue());
match unsafe {
get_property_jsval(
- cx,
+ *cx,
node.reflector().get_jsobject(),
&name,
property.handle_mut(),
)
} {
- Ok(_) => match unsafe { jsval_to_webdriver(cx, property.handle()) } {
+ Ok(_) => match unsafe { jsval_to_webdriver(*cx, property.handle()) } {
Ok(property) => Ok(property),
Err(_) => Ok(WebDriverJSValue::Undefined),
},
Err(error) => {
- unsafe { throw_dom_exception(cx, &node.reflector().global(), error) };
+ unsafe { throw_dom_exception(*cx, &node.reflector().global(), error) };
Ok(WebDriverJSValue::Undefined)
},
}