auto merge of #4584 : Ms2ger/servo/unsafe, r=jdm

As a first start, this allows them indiscriminately where used.
This commit is contained in:
bors-servo 2015-01-09 07:15:52 -07:00
commit f74d5360ba
14 changed files with 27 additions and 0 deletions

View file

@ -47,6 +47,7 @@ impl BrowserContext {
self.window_proxy self.window_proxy
} }
#[allow(unsafe_blocks)]
fn create_window_proxy(&mut self) { fn create_window_proxy(&mut self) {
let win = self.active_window().root(); let win = self.active_window().root();
let win = win.r(); let win = win.r();
@ -117,6 +118,7 @@ static PROXY_HANDLER: ProxyTraps = ProxyTraps {
trace: None trace: None
}; };
#[allow(unsafe_blocks)]
pub fn new_window_proxy_handler() -> WindowProxyHandler { pub fn new_window_proxy_handler() -> WindowProxyHandler {
unsafe { unsafe {
WindowProxyHandler(CreateWrapperProxyHandler(&PROXY_HANDLER)) WindowProxyHandler(CreateWrapperProxyHandler(&PROXY_HANDLER))

View file

@ -197,6 +197,7 @@ trait PrivateDedicatedWorkerGlobalScopeHelpers {
} }
impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerGlobalScope> { impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerGlobalScope> {
#[allow(unsafe_blocks)]
fn handle_event(self, msg: ScriptMsg) { fn handle_event(self, msg: ScriptMsg) {
match msg { match msg {
ScriptMsg::DOMMessage(data, nbytes) => { ScriptMsg::DOMMessage(data, nbytes) => {
@ -229,6 +230,7 @@ impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerG
} }
impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalScope> { impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalScope> {
#[allow(unsafe_blocks)]
fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult { fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult {
let mut data = ptr::null_mut(); let mut data = ptr::null_mut();
let mut nbytes = 0; let mut nbytes = 0;

View file

@ -1283,12 +1283,14 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
} }
impl<'a> style::TElement<'a> for JSRef<'a, Element> { impl<'a> style::TElement<'a> for JSRef<'a, Element> {
#[allow(unsafe_blocks)]
fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str> { fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str> {
self.get_attribute(namespace.clone(), attr).root().map(|attr| { self.get_attribute(namespace.clone(), attr).root().map(|attr| {
// This transmute is used to cheat the lifetime restriction. // This transmute is used to cheat the lifetime restriction.
unsafe { mem::transmute(attr.r().value().as_slice()) } unsafe { mem::transmute(attr.r().value().as_slice()) }
}) })
} }
#[allow(unsafe_blocks)]
fn get_attrs(self, attr: &Atom) -> Vec<&'a str> { fn get_attrs(self, attr: &Atom) -> Vec<&'a str> {
self.get_attributes(attr).into_iter().map(|attr| attr.root()).map(|attr| { self.get_attributes(attr).into_iter().map(|attr| attr.root()).map(|attr| {
// This transmute is used to cheat the lifetime restriction. // This transmute is used to cheat the lifetime restriction.

View file

@ -186,6 +186,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
}).map(|entry| entry.listener.get_listener())) }).map(|entry| entry.listener.get_listener()))
} }
#[allow(unsafe_blocks)]
fn set_event_handler_uncompiled(self, fn set_event_handler_uncompiled(self,
cx: *mut JSContext, cx: *mut JSContext,
url: Url, url: Url,

View file

@ -304,6 +304,7 @@ pub trait HTMLInputElementHelpers {
fn get_indeterminate_state(self) -> bool; fn get_indeterminate_state(self) -> bool;
} }
#[allow(unsafe_blocks)]
fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&str>) { fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&str>) {
//TODO: if not in document, use root ancestor instead of document //TODO: if not in document, use root ancestor instead of document
let owner = broadcaster.form_owner().root(); let owner = broadcaster.form_owner().root();
@ -606,6 +607,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
} }
// https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps // https://html.spec.whatwg.org/multipage/interaction.html#run-pre-click-activation-steps
#[allow(unsafe_blocks)]
fn pre_click_activation(&self) { fn pre_click_activation(&self) {
let mut cache = self.activation_state.borrow_mut(); let mut cache = self.activation_state.borrow_mut();
let ty = self.input_type.get(); let ty = self.input_type.get();
@ -758,6 +760,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
} }
// https://html.spec.whatwg.org/multipage/forms.html#implicit-submission // https://html.spec.whatwg.org/multipage/forms.html#implicit-submission
#[allow(unsafe_blocks)]
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) { fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
let doc = document_from_node(*self).root(); let doc = document_from_node(*self).root();
let node: JSRef<Node> = NodeCast::from_ref(doc.r()); let node: JSRef<Node> = NodeCast::from_ref(doc.r());

View file

@ -171,6 +171,7 @@ impl NodeFlags {
#[unsafe_destructor] #[unsafe_destructor]
impl Drop for Node { impl Drop for Node {
#[allow(unsafe_blocks)]
fn drop(&mut self) { fn drop(&mut self) {
unsafe { unsafe {
self.reap_layout_data(); self.reap_layout_data();
@ -779,6 +780,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
} }
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall // http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
#[allow(unsafe_blocks)]
fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>> { fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>> {
// Step 1. // Step 1.
unsafe { unsafe {
@ -878,6 +880,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
/// If the given untrusted node address represents a valid DOM node in the given runtime, /// If the given untrusted node address represents a valid DOM node in the given runtime,
/// returns it. /// returns it.
#[allow(unsafe_blocks)]
pub fn from_untrusted_node_address(runtime: *mut JSRuntime, candidate: UntrustedNodeAddress) pub fn from_untrusted_node_address(runtime: *mut JSRuntime, candidate: UntrustedNodeAddress)
-> Temporary<Node> { -> Temporary<Node> {
unsafe { unsafe {

View file

@ -99,6 +99,7 @@ impl tree_builder::Tracer<TrustedNodeAddress> for Tracer {
} }
impl JSTraceable for ServoHTMLParser { impl JSTraceable for ServoHTMLParser {
#[allow(unsafe_blocks)]
fn trace(&self, trc: *mut JSTracer) { fn trace(&self, trc: *mut JSTracer) {
self.reflector_.trace(trc); self.reflector_.trace(trc);

View file

@ -295,6 +295,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
debug!("{}", message); debug!("{}", message);
} }
#[allow(unsafe_blocks)]
fn Gc(self) { fn Gc(self) {
unsafe { unsafe {
JS_GC(JS_GetRuntime(self.get_cx())); JS_GC(JS_GetRuntime(self.get_cx()));
@ -328,6 +329,7 @@ impl<'a, T: Reflectable> ScriptHelpers for JSRef<'a, T> {
self.evaluate_script_on_global_with_result(code, "") self.evaluate_script_on_global_with_result(code, "")
} }
#[allow(unsafe_blocks)]
fn evaluate_script_on_global_with_result(self, code: &str, filename: &str) -> JSVal { fn evaluate_script_on_global_with_result(self, code: &str, filename: &str) -> JSVal {
let this = self.reflector().get_jsobject(); let this = self.reflector().get_jsobject();
let cx = global_object_for_js_object(this).root().r().get_cx(); let cx = global_object_for_js_object(this).root().r().get_cx();

View file

@ -80,6 +80,7 @@ impl Worker {
Ok(Temporary::from_rooted(worker.r())) Ok(Temporary::from_rooted(worker.r()))
} }
#[allow(unsafe_blocks)]
pub fn handle_message(address: TrustedWorkerAddress, pub fn handle_message(address: TrustedWorkerAddress,
data: *mut u64, nbytes: size_t) { data: *mut u64, nbytes: size_t) {
let worker = address.to_temporary().root(); let worker = address.to_temporary().root();
@ -100,6 +101,7 @@ impl Worker {
} }
impl<'a> WorkerMethods for JSRef<'a, Worker> { impl<'a> WorkerMethods for JSRef<'a, Worker> {
#[allow(unsafe_blocks)]
fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult { fn PostMessage(self, cx: *mut JSContext, message: JSVal) -> ErrorResult {
let mut data = ptr::null_mut(); let mut data = ptr::null_mut();
let mut nbytes = 0; let mut nbytes = 0;

View file

@ -206,6 +206,7 @@ impl XMLHttpRequest {
xhr.r().process_partial_response(progress); xhr.r().process_partial_response(progress);
} }
#[allow(unsafe_blocks)]
fn fetch(fetch_type: &SyncOrAsync, resource_task: ResourceTask, fn fetch(fetch_type: &SyncOrAsync, resource_task: ResourceTask,
mut load_data: LoadData, terminate_receiver: Receiver<TerminateReason>, mut load_data: LoadData, terminate_receiver: Receiver<TerminateReason>,
cors_request: Result<Option<CORSRequest>,()>, gen_id: GenerationId, cors_request: Result<Option<CORSRequest>,()>, gen_id: GenerationId,
@ -690,6 +691,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
} }
} }
} }
#[allow(unsafe_blocks)]
fn Response(self, cx: *mut JSContext) -> JSVal { fn Response(self, cx: *mut JSContext) -> JSVal {
match self.response_type.get() { match self.response_type.get() {
_empty | Text => { _empty | Text => {

View file

@ -4,6 +4,7 @@
#![feature(default_type_params, globs, macro_rules, phase, unsafe_destructor)] #![feature(default_type_params, globs, macro_rules, phase, unsafe_destructor)]
#![deny(unsafe_blocks)]
#![deny(unused_imports)] #![deny(unused_imports)]
#![deny(unused_variables)] #![deny(unused_variables)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
@ -51,6 +52,7 @@ pub mod dom {
pub mod macros; pub mod macros;
/// The code to expose the DOM to JavaScript through IDL bindings. /// The code to expose the DOM to JavaScript through IDL bindings.
#[allow(unsafe_blocks)]
pub mod bindings { pub mod bindings {
pub mod cell; pub mod cell;
pub mod global; pub mod global;

View file

@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![allow(unsafe_blocks)]
use dom::attr::AttrHelpers; use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, HTMLScriptElementCast}; use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, HTMLScriptElementCast};

View file

@ -5,6 +5,8 @@
//! The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing //! The script task is the task that owns the DOM in memory, runs JavaScript, and spawns parsing
//! and layout tasks. //! and layout tasks.
#![allow(unsafe_blocks)]
use dom::bindings::cell::DOMRefCell; use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState}; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
use dom::bindings::codegen::Bindings::EventBinding::EventMethods; use dom::bindings::codegen::Bindings::EventBinding::EventMethods;

View file

@ -105,6 +105,7 @@ impl TimerManager {
} }
} }
#[allow(unsafe_blocks)]
pub fn set_timeout_or_interval(&self, pub fn set_timeout_or_interval(&self,
callback: TimerCallback, callback: TimerCallback,
arguments: Vec<JSVal>, arguments: Vec<JSVal>,