Replace unsafe_blocks by unsafe_code.

This commit is contained in:
Manish Goregaokar 2015-03-19 07:40:22 +05:30 committed by Ms2ger
parent 4eb26065ac
commit 3479d3fa7f
53 changed files with 151 additions and 57 deletions

View file

@ -25,7 +25,7 @@
//! //!
//! http://dev.w3.org/csswg/css-sizing/ //! http://dev.w3.org/csswg/css-sizing/
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use context::LayoutContext; use context::LayoutContext;
use css::node_style::StyledNode; use css::node_style::StyledNode;

View file

@ -11,7 +11,7 @@
//! maybe it's an absolute or fixed position thing that hasn't found its containing block yet. //! maybe it's an absolute or fixed position thing that hasn't found its containing block yet.
//! Construction items bubble up the tree from children to parents until they find their homes. //! Construction items bubble up the tree from children to parents until they find their homes.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;

View file

@ -4,7 +4,7 @@
//! Data needed by the layout task. //! Data needed by the layout task.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
use css::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache}; use css::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};

View file

@ -4,7 +4,7 @@
//! High-level interface to CSS selector matching. //! High-level interface to CSS selector matching.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
use context::SharedLayoutContext; use context::SharedLayoutContext;
use css::node_style::StyledNode; use css::node_style::StyledNode;

View file

@ -23,7 +23,7 @@ pub trait StyledNode {
impl<'ln> StyledNode for ThreadSafeLayoutNode<'ln> { impl<'ln> StyledNode for ThreadSafeLayoutNode<'ln> {
#[inline] #[inline]
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn style<'a>(&'a self) -> &'a Arc<ComputedValues> { fn style<'a>(&'a self) -> &'a Arc<ComputedValues> {
unsafe { unsafe {
let layout_data_ref = self.borrow_layout_data(); let layout_data_ref = self.borrow_layout_data();

View file

@ -2,7 +2,7 @@
* 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)] #![allow(unsafe_code)]
use construct::{ConstructionItem, ConstructionResult}; use construct::{ConstructionItem, ConstructionResult};
use incremental::RestyleDamage; use incremental::RestyleDamage;

View file

@ -8,7 +8,7 @@
//! list building, as the actual painting does not happen here—only deciding *what* we're going to //! list building, as the actual painting does not happen here—only deciding *what* we're going to
//! paint. //! paint.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use azure::azure_hl::Color; use azure::azure_hl::Color;
use block::BlockFlow; use block::BlockFlow;

View file

@ -310,7 +310,7 @@ pub trait Flow: fmt::Debug + Sync {
} }
/// Returns a layer ID for the given fragment. /// Returns a layer ID for the given fragment.
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn layer_id(&self, fragment_id: uint) -> LayerId { fn layer_id(&self, fragment_id: uint) -> LayerId {
unsafe { unsafe {
let obj = mem::transmute::<&&Self, &raw::TraitObject>(&self); let obj = mem::transmute::<&&Self, &raw::TraitObject>(&self);
@ -330,7 +330,7 @@ pub trait Flow: fmt::Debug + Sync {
// Base access // Base access
#[inline(always)] #[inline(always)]
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
pub fn base<'a, T: ?Sized + Flow>(this: &'a T) -> &'a BaseFlow { pub fn base<'a, T: ?Sized + Flow>(this: &'a T) -> &'a BaseFlow {
unsafe { unsafe {
let obj = mem::transmute::<&&'a T, &'a raw::TraitObject>(&this); let obj = mem::transmute::<&&'a T, &'a raw::TraitObject>(&this);
@ -344,7 +344,7 @@ pub fn imm_child_iter<'a>(flow: &'a Flow) -> FlowListIterator<'a> {
} }
#[inline(always)] #[inline(always)]
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
pub fn mut_base<'a, T: ?Sized + Flow>(this: &'a mut T) -> &'a mut BaseFlow { pub fn mut_base<'a, T: ?Sized + Flow>(this: &'a mut T) -> &'a mut BaseFlow {
unsafe { unsafe {
let obj = mem::transmute::<&&'a mut T, &'a raw::TraitObject>(&this); let obj = mem::transmute::<&&'a mut T, &'a raw::TraitObject>(&this);
@ -832,7 +832,9 @@ pub struct BaseFlow {
pub flags: FlowFlags, pub flags: FlowFlags,
} }
#[allow(unsafe_code)]
unsafe impl Send for BaseFlow {} unsafe impl Send for BaseFlow {}
#[allow(unsafe_code)]
unsafe impl Sync for BaseFlow {} unsafe impl Sync for BaseFlow {}
impl fmt::Debug for BaseFlow { impl fmt::Debug for BaseFlow {
@ -982,10 +984,12 @@ impl BaseFlow {
self.children.iter_mut() self.children.iter_mut()
} }
#[allow(unsafe_code)]
pub unsafe fn strong_ref_count<'a>(&'a self) -> &'a AtomicUsize { pub unsafe fn strong_ref_count<'a>(&'a self) -> &'a AtomicUsize {
&self.strong_ref_count &self.strong_ref_count
} }
#[allow(unsafe_code)]
pub unsafe fn weak_ref_count<'a>(&'a self) -> &'a AtomicUsize { pub unsafe fn weak_ref_count<'a>(&'a self) -> &'a AtomicUsize {
&self.weak_ref_count &self.weak_ref_count
} }
@ -1355,6 +1359,7 @@ impl ContainingBlockLink {
self.link = Some(link.downgrade()) self.link = Some(link.downgrade())
} }
#[allow(unsafe_code)]
pub unsafe fn get<'a>(&'a mut self) -> &'a mut Option<WeakFlowRef> { pub unsafe fn get<'a>(&'a mut self) -> &'a mut Option<WeakFlowRef> {
&mut self.link &mut self.link
} }

View file

@ -31,6 +31,7 @@ impl FlowList {
/// Provide a mutable reference to the front element, or None if the list is empty /// Provide a mutable reference to the front element, or None if the list is empty
#[inline] #[inline]
#[allow(unsafe_code)]
pub unsafe fn front_mut<'a>(&'a mut self) -> Option<&'a mut Flow> { pub unsafe fn front_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
self.flows.front_mut().map(|head| &mut **head) self.flows.front_mut().map(|head| &mut **head)
} }
@ -43,6 +44,7 @@ impl FlowList {
/// Provide a mutable reference to the back element, or None if the list is empty /// Provide a mutable reference to the back element, or None if the list is empty
#[inline] #[inline]
#[allow(unsafe_code)]
pub unsafe fn back_mut<'a>(&'a mut self) -> Option<&'a mut Flow> { pub unsafe fn back_mut<'a>(&'a mut self) -> Option<&'a mut Flow> {
self.flows.back_mut().map(|tail| &mut **tail) self.flows.back_mut().map(|tail| &mut **tail)
} }

View file

@ -8,7 +8,7 @@
//! be superfluous. This design is largely duplicating logic of Arc<T> and //! be superfluous. This design is largely duplicating logic of Arc<T> and
//! Weak<T>; please see comments there for details. //! Weak<T>; please see comments there for details.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
use flow::Flow; use flow::Flow;
use flow; use flow;

View file

@ -4,7 +4,7 @@
//! The `Fragment` type, which represents the leaves of the layout tree. //! The `Fragment` type, which represents the leaves of the layout tree.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use canvas::canvas_paint_task::CanvasMsg; use canvas::canvas_paint_task::CanvasMsg;
use css::node_style::StyledNode; use css::node_style::StyledNode;
@ -118,7 +118,9 @@ pub struct Fragment {
pub debug_id: u16, pub debug_id: u16,
} }
#[allow(unsafe_code)]
unsafe impl Send for Fragment {} unsafe impl Send for Fragment {}
#[allow(unsafe_code)]
unsafe impl Sync for Fragment {} unsafe impl Sync for Fragment {}
impl Encodable for Fragment { impl Encodable for Fragment {

View file

@ -2,7 +2,7 @@
* 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/. */
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use css::node_style::StyledNode; use css::node_style::StyledNode;
use context::LayoutContext; use context::LayoutContext;

View file

@ -6,6 +6,7 @@
//! that can be viewed by an external tool to make layout debugging easier. //! that can be viewed by an external tool to make layout debugging easier.
#![macro_use] #![macro_use]
#![allow(unsafe_code)] // thread_local!() defines an unsafe function on Android
use flow_ref::FlowRef; use flow_ref::FlowRef;
use flow; use flow;
@ -95,7 +96,6 @@ impl Drop for Scope {
/// Generate a unique ID. This is used for items such as Fragment /// Generate a unique ID. This is used for items such as Fragment
/// which are often reallocated but represent essentially the /// which are often reallocated but represent essentially the
/// same data. /// same data.
#[allow(unsafe_blocks)]
pub fn generate_unique_debug_id() -> u16 { pub fn generate_unique_debug_id() -> u16 {
unsafe { DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16 } unsafe { DEBUG_ID_COUNTER.fetch_add(1, Ordering::SeqCst) as u16 }
} }

View file

@ -5,7 +5,7 @@
//! The layout task. Performs layout on the DOM, builds display lists and sends them to be //! The layout task. Performs layout on the DOM, builds display lists and sends them to be
//! painted. //! painted.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
use construct::ConstructionResult; use construct::ConstructionResult;
use context::{SharedLayoutContext, SharedLayoutContextWrapper}; use context::{SharedLayoutContext, SharedLayoutContextWrapper};

View file

@ -17,7 +17,7 @@
#![feature(unsafe_destructor)] #![feature(unsafe_destructor)]
#![feature(unsafe_no_drop_flag)] #![feature(unsafe_no_drop_flag)]
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
#![allow(unrooted_must_root)] #![allow(unrooted_must_root)]
#![plugin(string_cache_plugin)] #![plugin(string_cache_plugin)]

View file

@ -5,7 +5,7 @@
//! Layout for elements with a CSS `display` property of `list-item`. These elements consist of a //! Layout for elements with a CSS `display` property of `list-item`. These elements consist of a
//! block and an extra inline fragment for the marker. //! block and an extra inline fragment for the marker.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;

View file

@ -4,7 +4,7 @@
//! Borders, padding, and margins. //! Borders, padding, and margins.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use fragment::Fragment; use fragment::Fragment;

View file

@ -2,7 +2,7 @@
* 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)] #![allow(unsafe_code)]
use gfx::display_list::OpaqueNode; use gfx::display_list::OpaqueNode;
use libc::{c_void, uintptr_t}; use libc::{c_void, uintptr_t};

View file

@ -6,7 +6,7 @@
//! //!
//! This code is highly unsafe. Keep this file small and easy to audit. //! This code is highly unsafe. Keep this file small and easy to audit.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
use context::{LayoutContext, SharedLayoutContextWrapper, SharedLayoutContext}; use context::{LayoutContext, SharedLayoutContextWrapper, SharedLayoutContext};
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal}; use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};

View file

@ -4,7 +4,7 @@
//! CSS table formatting contexts. //! CSS table formatting contexts.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::{self, BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer}; use block::{self, BlockFlow, CandidateBSizeIterator, ISizeAndMarginsComputer};
use block::{ISizeConstraintInput, ISizeConstraintSolution}; use block::{ISizeConstraintInput, ISizeConstraintSolution};

View file

@ -4,7 +4,7 @@
//! CSS table formatting contexts. //! CSS table formatting contexts.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::BlockFlow; use block::BlockFlow;
use context::LayoutContext; use context::LayoutContext;

View file

@ -4,7 +4,7 @@
//! CSS table formatting contexts. //! CSS table formatting contexts.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag}; use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag};
use context::LayoutContext; use context::LayoutContext;

View file

@ -4,7 +4,7 @@
//! CSS table formatting contexts. //! CSS table formatting contexts.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use context::LayoutContext; use context::LayoutContext;
use css::node_style::StyledNode; use css::node_style::StyledNode;

View file

@ -4,7 +4,7 @@
//! CSS table formatting contexts. //! CSS table formatting contexts.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::BlockFlow; use block::BlockFlow;
use block::ISizeAndMarginsComputer; use block::ISizeAndMarginsComputer;

View file

@ -4,7 +4,7 @@
//! CSS table formatting contexts. //! CSS table formatting contexts.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::{BlockFlow, ISizeAndMarginsComputer}; use block::{BlockFlow, ISizeAndMarginsComputer};
use context::LayoutContext; use context::LayoutContext;

View file

@ -11,7 +11,7 @@
//! //!
//! Hereafter this document is referred to as INTRINSIC. //! Hereafter this document is referred to as INTRINSIC.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use block::{BlockFlow, BlockNonReplaced, FloatNonReplaced, ISizeAndMarginsComputer}; use block::{BlockFlow, BlockNonReplaced, FloatNonReplaced, ISizeAndMarginsComputer};
use block::{MarginsMayCollapseFlag}; use block::{MarginsMayCollapseFlag};

View file

@ -4,7 +4,7 @@
//! Text layout. //! Text layout.
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
use fragment::{Fragment, SpecificFragmentInfo, ScannedTextFragmentInfo}; use fragment::{Fragment, SpecificFragmentInfo, ScannedTextFragmentInfo};
use inline::InlineFragments; use inline::InlineFragments;

View file

@ -4,7 +4,7 @@
//! Traversals over the DOM and flow trees, running the layout computations. //! Traversals over the DOM and flow trees, running the layout computations.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
use css::node_style::StyledNode; use css::node_style::StyledNode;
use css::matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult}; use css::matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult};

View file

@ -30,7 +30,7 @@
//! o Instead of `html_element_in_html_document()`, use //! o Instead of `html_element_in_html_document()`, use
//! `html_element_in_html_document_for_layout()`. //! `html_element_in_html_document_for_layout()`.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
use canvas::canvas_paint_task::CanvasMsg; use canvas::canvas_paint_task::CanvasMsg;
use context::SharedLayoutContext; use context::SharedLayoutContext;

View file

@ -246,6 +246,7 @@ impl<'a> AttrHelpers<'a> for JSRef<'a, Attr> {
} }
} }
#[allow(unsafe_code)]
pub trait AttrHelpersForLayout { pub trait AttrHelpersForLayout {
unsafe fn value_ref_forever(&self) -> &'static str; unsafe fn value_ref_forever(&self) -> &'static str;
unsafe fn value_atom_forever(&self) -> Option<Atom>; unsafe fn value_atom_forever(&self) -> Option<Atom>;
@ -253,6 +254,7 @@ pub trait AttrHelpersForLayout {
unsafe fn local_name_atom_forever(&self) -> Atom; unsafe fn local_name_atom_forever(&self) -> Atom;
} }
#[allow(unsafe_code)]
impl AttrHelpersForLayout for Attr { impl AttrHelpersForLayout for Attr {
#[inline] #[inline]
unsafe fn value_ref_forever(&self) -> &'static str { unsafe fn value_ref_forever(&self) -> &'static str {

View file

@ -27,6 +27,7 @@ impl<T> DOMRefCell<T> {
/// Return a reference to the contents. /// Return a reference to the contents.
/// ///
/// For use in the layout task only. /// For use in the layout task only.
#[allow(unsafe_code)]
pub unsafe fn borrow_for_layout<'a>(&'a self) -> &'a T { pub unsafe fn borrow_for_layout<'a>(&'a self) -> &'a T {
debug_assert!(task_state::get().is_layout()); debug_assert!(task_state::get().is_layout());
&*self.value.as_unsafe_cell().get() &*self.value.as_unsafe_cell().get()
@ -36,6 +37,7 @@ impl<T> DOMRefCell<T> {
/// ///
/// This succeeds even if the object is mutably borrowed, /// This succeeds even if the object is mutably borrowed,
/// so you have to be careful in trace code! /// so you have to be careful in trace code!
#[allow(unsafe_code)]
pub unsafe fn borrow_for_gc_trace<'a>(&'a self) -> &'a T { pub unsafe fn borrow_for_gc_trace<'a>(&'a self) -> &'a T {
debug_assert!(task_state::get().contains(SCRIPT | IN_GC)); debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
&*self.value.as_unsafe_cell().get() &*self.value.as_unsafe_cell().get()
@ -43,6 +45,7 @@ impl<T> DOMRefCell<T> {
/// Borrow the contents for the purpose of script deallocation. /// Borrow the contents for the purpose of script deallocation.
/// ///
#[allow(unsafe_code)]
pub unsafe fn borrow_for_script_deallocation<'a>(&'a self) -> &'a mut T { pub unsafe fn borrow_for_script_deallocation<'a>(&'a self) -> &'a mut T {
debug_assert!(task_state::get().contains(SCRIPT)); debug_assert!(task_state::get().contains(SCRIPT));
&mut *self.value.as_unsafe_cell().get() &mut *self.value.as_unsafe_cell().get()

View file

@ -25,7 +25,7 @@
//! some sanity checks and [argument conversions](conversions/index.html), and //! some sanity checks and [argument conversions](conversions/index.html), and
//! calls into API implementation for the DOM object. //! calls into API implementation for the DOM object.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
#![deny(missing_docs, non_snake_case)] #![deny(missing_docs, non_snake_case)]
pub mod cell; pub mod cell;

View file

@ -67,7 +67,7 @@ impl BrowserContext {
self.window_proxy self.window_proxy
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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();
@ -104,6 +104,7 @@ impl SessionHistoryEntry {
} }
} }
#[allow(unsafe_code)]
unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> Option<Temporary<Window>> { unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: *mut JSObject, id: jsid) -> Option<Temporary<Window>> {
let index = get_array_index_from_id(cx, id); let index = get_array_index_from_id(cx, id);
if let Some(index) = index { if let Some(index) = index {
@ -116,6 +117,7 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: *mut JSObject, id: jsid)
None None
} }
#[allow(unsafe_code)]
unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, set: bool, desc: *mut JSPropertyDescriptor) -> bool { unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, set: bool, desc: *mut JSPropertyDescriptor) -> bool {
let window = GetSubframeWindow(cx, proxy, id); let window = GetSubframeWindow(cx, proxy, id);
if let Some(window) = window { if let Some(window) = window {
@ -142,7 +144,7 @@ unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObje
true true
} }
#[allow(unsafe_code)]
unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, desc: *mut JSPropertyDescriptor) -> bool { unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, desc: *mut JSPropertyDescriptor) -> bool {
if get_array_index_from_id(cx, id).is_some() { if get_array_index_from_id(cx, id).is_some() {
// Spec says to Reject whether this is a supported index or not, // Spec says to Reject whether this is a supported index or not,
@ -157,6 +159,7 @@ unsafe extern fn defineProperty(cx: *mut JSContext, proxy: *mut JSObject, id: js
(*desc).setter, (*desc).attrs) != 0 (*desc).setter, (*desc).attrs) != 0
} }
#[allow(unsafe_code)]
unsafe extern fn hasOwn(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, bp: *mut bool) -> bool { unsafe extern fn hasOwn(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, bp: *mut bool) -> bool {
let window = GetSubframeWindow(cx, proxy, id); let window = GetSubframeWindow(cx, proxy, id);
if window.is_some() { if window.is_some() {
@ -174,6 +177,7 @@ unsafe extern fn hasOwn(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, bp:
return true; return true;
} }
#[allow(unsafe_code)]
unsafe extern fn get(cx: *mut JSContext, proxy: *mut JSObject, receiver: *mut JSObject, id: jsid, vp: *mut JSVal) -> bool { unsafe extern fn get(cx: *mut JSContext, proxy: *mut JSObject, receiver: *mut JSObject, id: jsid, vp: *mut JSVal) -> bool {
let window = GetSubframeWindow(cx, proxy, id); let window = GetSubframeWindow(cx, proxy, id);
if let Some(window) = window { if let Some(window) = window {
@ -186,6 +190,7 @@ unsafe extern fn get(cx: *mut JSContext, proxy: *mut JSObject, receiver: *mut JS
JS_ForwardGetPropertyTo(cx, target, id, receiver, vp) != 0 JS_ForwardGetPropertyTo(cx, target, id, receiver, vp) != 0
} }
#[allow(unsafe_code)]
unsafe extern fn set(cx: *mut JSContext, proxy: *mut JSObject, _receiver: *mut JSObject, id: jsid, _strict: bool, vp: *mut JSVal) -> bool { unsafe extern fn set(cx: *mut JSContext, proxy: *mut JSObject, _receiver: *mut JSObject, id: jsid, _strict: bool, vp: *mut JSVal) -> bool {
if get_array_index_from_id(cx, id).is_some() { if get_array_index_from_id(cx, id).is_some() {
// Reject (which means throw if and only if strict) the set. // Reject (which means throw if and only if strict) the set.
@ -234,7 +239,7 @@ static PROXY_HANDLER: ProxyTraps = ProxyTraps {
trace: None trace: None
}; };
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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

@ -78,10 +78,12 @@ impl CanvasRenderingContext2D {
} }
pub trait LayoutCanvasRenderingContext2DHelpers { pub trait LayoutCanvasRenderingContext2DHelpers {
#[allow(unsafe_code)]
unsafe fn get_renderer(&self) -> Sender<CanvasMsg>; unsafe fn get_renderer(&self) -> Sender<CanvasMsg>;
} }
impl LayoutCanvasRenderingContext2DHelpers for LayoutJS<CanvasRenderingContext2D> { impl LayoutCanvasRenderingContext2DHelpers for LayoutJS<CanvasRenderingContext2D> {
#[allow(unsafe_code)]
unsafe fn get_renderer(&self) -> Sender<CanvasMsg> { unsafe fn get_renderer(&self) -> Sender<CanvasMsg> {
(*self.unsafe_get()).renderer.clone() (*self.unsafe_get()).renderer.clone()
} }

View file

@ -60,6 +60,7 @@ impl CharacterData {
} }
#[inline] #[inline]
#[allow(unsafe_code)]
pub unsafe fn data_for_layout<'a>(&'a self) -> &'a str { pub unsafe fn data_for_layout<'a>(&'a self) -> &'a str {
self.data.borrow_for_layout().as_slice() self.data.borrow_for_layout().as_slice()
} }

View file

@ -689,12 +689,14 @@ pub enum DocumentSource {
} }
pub trait LayoutDocumentHelpers { pub trait LayoutDocumentHelpers {
#[allow(unsafe_code)]
unsafe fn is_html_document_for_layout(&self) -> bool; unsafe fn is_html_document_for_layout(&self) -> bool;
} }
impl LayoutDocumentHelpers for LayoutJS<Document> { impl LayoutDocumentHelpers for LayoutJS<Document> {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn is_html_document_for_layout(&self) -> bool { unsafe fn is_html_document_for_layout(&self) -> bool {
(*self.unsafe_get()).is_html_document (*self.unsafe_get()).is_html_document
} }

View file

@ -148,6 +148,7 @@ impl Element {
} }
} }
#[allow(unsafe_code)]
pub trait RawLayoutElementHelpers { pub trait RawLayoutElementHelpers {
unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom) unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
-> Option<&'a str>; -> Option<&'a str>;
@ -171,6 +172,7 @@ pub trait RawLayoutElementHelpers {
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &Atom) -> Option<&'a JS<Attr>> { unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name: &Atom) -> Option<&'a JS<Attr>> {
// cast to point to T in RefCell<T> directly // cast to point to T in RefCell<T> directly
let attrs = elem.attrs.borrow_for_layout(); let attrs = elem.attrs.borrow_for_layout();
@ -181,6 +183,7 @@ unsafe fn get_attr_for_layout<'a>(elem: &'a Element, namespace: &Namespace, name
}) })
} }
#[allow(unsafe_code)]
impl RawLayoutElementHelpers for Element { impl RawLayoutElementHelpers for Element {
#[inline] #[inline]
unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom) unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
@ -394,12 +397,15 @@ impl RawLayoutElementHelpers for Element {
} }
pub trait LayoutElementHelpers { pub trait LayoutElementHelpers {
#[allow(unsafe_code)]
unsafe fn html_element_in_html_document_for_layout(&self) -> bool; unsafe fn html_element_in_html_document_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool; unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool;
} }
impl LayoutElementHelpers for LayoutJS<Element> { impl LayoutElementHelpers for LayoutJS<Element> {
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn html_element_in_html_document_for_layout(&self) -> bool { unsafe fn html_element_in_html_document_for_layout(&self) -> bool {
if (*self.unsafe_get()).namespace != ns!(HTML) { if (*self.unsafe_get()).namespace != ns!(HTML) {
return false return false
@ -408,6 +414,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
node.owner_doc_for_layout().is_html_document_for_layout() node.owner_doc_for_layout().is_html_document_for_layout()
} }
#[allow(unsafe_code)]
unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool { unsafe fn has_attr_for_layout(&self, namespace: &Namespace, name: &Atom) -> bool {
get_attr_for_layout(&*self.unsafe_get(), namespace, name).is_some() get_attr_for_layout(&*self.unsafe_get(), namespace, name).is_some()
} }
@ -1425,7 +1432,7 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
} }
impl<'a> style::node::TElement<'a> for JSRef<'a, Element> { impl<'a> style::node::TElement<'a> for JSRef<'a, Element> {
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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.
@ -1435,7 +1442,7 @@ impl<'a> style::node::TElement<'a> for JSRef<'a, Element> {
unsafe { mem::transmute(value.as_slice()) } unsafe { mem::transmute(value.as_slice()) }
}) })
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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| {
// FIXME(https://github.com/rust-lang/rust/issues/23338) // FIXME(https://github.com/rust-lang/rust/issues/23338)

View file

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

View file

@ -82,7 +82,7 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
self.data.borrow_mut().remove(&name); self.data.borrow_mut().remove(&name);
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn Get(self, name: DOMString) -> Option<FileOrString> { fn Get(self, name: DOMString) -> Option<FileOrString> {
// FIXME(https://github.com/rust-lang/rust/issues/23338) // FIXME(https://github.com/rust-lang/rust/issues/23338)
let data = self.data.borrow(); let data = self.data.borrow();

View file

@ -211,7 +211,7 @@ impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
} }
// https://html.spec.whatwg.org/multipage/forms.html#implicit-submission // https://html.spec.whatwg.org/multipage/forms.html#implicit-submission
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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

@ -63,21 +63,27 @@ impl HTMLCanvasElement {
} }
pub trait LayoutHTMLCanvasElementHelpers { pub trait LayoutHTMLCanvasElementHelpers {
#[allow(unsafe_code)]
unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>>; unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>>;
#[allow(unsafe_code)]
unsafe fn get_canvas_width(&self) -> u32; unsafe fn get_canvas_width(&self) -> u32;
#[allow(unsafe_code)]
unsafe fn get_canvas_height(&self) -> u32; unsafe fn get_canvas_height(&self) -> u32;
} }
impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> { impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> {
#[allow(unsafe_code)]
unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>> { unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>> {
let context = (*self.unsafe_get()).context.get_inner_as_layout(); let context = (*self.unsafe_get()).context.get_inner_as_layout();
context.map(|cx| cx.get_renderer()) context.map(|cx| cx.get_renderer())
} }
#[allow(unsafe_code)]
unsafe fn get_canvas_width(&self) -> u32 { unsafe fn get_canvas_width(&self) -> u32 {
(*self.unsafe_get()).width.get() (*self.unsafe_get()).width.get()
} }
#[allow(unsafe_code)]
unsafe fn get_canvas_height(&self) -> u32 { unsafe fn get_canvas_height(&self) -> u32 {
(*self.unsafe_get()).height.get() (*self.unsafe_get()).height.get()
} }

View file

@ -86,10 +86,12 @@ impl HTMLImageElement {
} }
pub trait LayoutHTMLImageElementHelpers { pub trait LayoutHTMLImageElementHelpers {
#[allow(unsafe_code)]
unsafe fn image(&self) -> Option<Url>; unsafe fn image(&self) -> Option<Url>;
} }
impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> { impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> {
#[allow(unsafe_code)]
unsafe fn image(&self) -> Option<Url> { unsafe fn image(&self) -> Option<Url> {
(*self.unsafe_get()).image.borrow_for_layout().clone() (*self.unsafe_get()).image.borrow_for_layout().clone()
} }

View file

@ -129,23 +129,31 @@ impl HTMLInputElement {
} }
pub trait LayoutHTMLInputElementHelpers { pub trait LayoutHTMLInputElementHelpers {
#[allow(unsafe_code)]
unsafe fn get_value_for_layout(self) -> String; unsafe fn get_value_for_layout(self) -> String;
#[allow(unsafe_code)]
unsafe fn get_size_for_layout(self) -> u32; unsafe fn get_size_for_layout(self) -> u32;
} }
pub trait RawLayoutHTMLInputElementHelpers { pub trait RawLayoutHTMLInputElementHelpers {
#[allow(unsafe_code)]
unsafe fn get_checked_state_for_layout(&self) -> bool; unsafe fn get_checked_state_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_indeterminate_state_for_layout(&self) -> bool; unsafe fn get_indeterminate_state_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_size_for_layout(&self) -> u32; unsafe fn get_size_for_layout(&self) -> u32;
} }
impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> { impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_value_for_layout(self) -> String { unsafe fn get_value_for_layout(self) -> String {
#[allow(unsafe_code)]
unsafe fn get_raw_textinput_value(input: LayoutJS<HTMLInputElement>) -> String { unsafe fn get_raw_textinput_value(input: LayoutJS<HTMLInputElement>) -> String {
(*input.unsafe_get()).textinput.borrow_for_layout().get_content() (*input.unsafe_get()).textinput.borrow_for_layout().get_content()
} }
#[allow(unsafe_code)]
unsafe fn get_raw_attr_value(input: LayoutJS<HTMLInputElement>) -> Option<String> { unsafe fn get_raw_attr_value(input: LayoutJS<HTMLInputElement>) -> Option<String> {
let elem: LayoutJS<Element> = input.transmute_copy(); let elem: LayoutJS<Element> = input.transmute_copy();
(*elem.unsafe_get()).get_attr_val_for_layout(&ns!(""), &atom!("value")) (*elem.unsafe_get()).get_attr_val_for_layout(&ns!(""), &atom!("value"))
@ -167,6 +175,7 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_size_for_layout(self) -> u32 { unsafe fn get_size_for_layout(self) -> u32 {
(*self.unsafe_get()).get_size_for_layout() (*self.unsafe_get()).get_size_for_layout()
} }
@ -174,16 +183,19 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
impl RawLayoutHTMLInputElementHelpers for HTMLInputElement { impl RawLayoutHTMLInputElementHelpers for HTMLInputElement {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_checked_state_for_layout(&self) -> bool { unsafe fn get_checked_state_for_layout(&self) -> bool {
self.checked.get() self.checked.get()
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_indeterminate_state_for_layout(&self) -> bool { unsafe fn get_indeterminate_state_for_layout(&self) -> bool {
self.indeterminate.get() self.indeterminate.get()
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_size_for_layout(&self) -> u32 { unsafe fn get_size_for_layout(&self) -> u32 {
self.size.get() self.size.get()
} }
@ -307,7 +319,7 @@ pub trait HTMLInputElementHelpers {
fn reset(self); fn reset(self);
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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();
@ -614,7 +626,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)] #[allow(unsafe_code)]
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();
@ -765,7 +777,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)] #[allow(unsafe_code)]
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

@ -52,16 +52,20 @@ impl HTMLTextAreaElementDerived for EventTarget {
} }
pub trait LayoutHTMLTextAreaElementHelpers { pub trait LayoutHTMLTextAreaElementHelpers {
#[allow(unsafe_code)]
unsafe fn get_value_for_layout(self) -> String; unsafe fn get_value_for_layout(self) -> String;
} }
pub trait RawLayoutHTMLTextAreaElementHelpers { pub trait RawLayoutHTMLTextAreaElementHelpers {
#[allow(unsafe_code)]
unsafe fn get_cols_for_layout(&self) -> u32; unsafe fn get_cols_for_layout(&self) -> u32;
#[allow(unsafe_code)]
unsafe fn get_rows_for_layout(&self) -> u32; unsafe fn get_rows_for_layout(&self) -> u32;
} }
impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> { impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_value_for_layout(self) -> String { unsafe fn get_value_for_layout(self) -> String {
(*self.unsafe_get()).textinput.borrow_for_layout().get_content() (*self.unsafe_get()).textinput.borrow_for_layout().get_content()
} }
@ -69,11 +73,13 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
impl RawLayoutHTMLTextAreaElementHelpers for HTMLTextAreaElement { impl RawLayoutHTMLTextAreaElementHelpers for HTMLTextAreaElement {
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_cols_for_layout(&self) -> u32 { unsafe fn get_cols_for_layout(&self) -> u32 {
self.cols.get() self.cols.get()
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]
#[allow(unsafe_code)]
unsafe fn get_rows_for_layout(&self) -> u32 { unsafe fn get_rows_for_layout(&self) -> u32 {
self.rows.get() self.rows.get()
} }

View file

@ -25,7 +25,7 @@ pub struct ImageData {
} }
impl ImageData { impl ImageData {
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn new_inherited(width: u32, height: u32, data: Option<Vec<u8>>, global: GlobalRef) -> ImageData { fn new_inherited(width: u32, height: u32, data: Option<Vec<u8>>, global: GlobalRef) -> ImageData {
unsafe { unsafe {
let cx = global.get_cx(); let cx = global.get_cx();
@ -57,7 +57,7 @@ pub trait ImageDataHelpers {
} }
impl<'a> ImageDataHelpers for JSRef<'a, ImageData> { impl<'a> ImageDataHelpers for JSRef<'a, ImageData> {
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn get_data_array(self, global: &GlobalRef) -> Vec<u8> { fn get_data_array(self, global: &GlobalRef) -> Vec<u8> {
unsafe { unsafe {
let cx = global.get_cx(); let cx = global.get_cx();

View file

@ -175,7 +175,7 @@ impl NodeFlags {
#[unsafe_destructor] #[unsafe_destructor]
impl Drop for Node { impl Drop for Node {
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn drop(&mut self) { fn drop(&mut self) {
self.layout_data.dispose(); self.layout_data.dispose();
} }
@ -203,6 +203,7 @@ pub struct LayoutData {
_data: NonZero<*const ()>, _data: NonZero<*const ()>,
} }
#[allow(unsafe_code)]
unsafe impl Send for LayoutData {} unsafe impl Send for LayoutData {}
pub struct LayoutDataRef { pub struct LayoutDataRef {
@ -236,6 +237,7 @@ impl LayoutDataRef {
/// happen if you try to mutate the layout data while this is held. This is the only thread- /// happen if you try to mutate the layout data while this is held. This is the only thread-
/// safe layout data accessor. /// safe layout data accessor.
#[inline] #[inline]
#[allow(unsafe_code)]
pub unsafe fn borrow_unchecked(&self) -> *const Option<LayoutData> { pub unsafe fn borrow_unchecked(&self) -> *const Option<LayoutData> {
mem::transmute(&self.data_cell) mem::transmute(&self.data_cell)
} }
@ -382,6 +384,7 @@ pub struct QuerySelectorIterator<'a> {
} }
impl<'a> QuerySelectorIterator<'a> { impl<'a> QuerySelectorIterator<'a> {
#[allow(unsafe_code)]
unsafe fn new(iter: TreeIterator<'a>, selectors: Vec<Selector>) -> QuerySelectorIterator<'a> { unsafe fn new(iter: TreeIterator<'a>, selectors: Vec<Selector>) -> QuerySelectorIterator<'a> {
QuerySelectorIterator { QuerySelectorIterator {
selectors: selectors, selectors: selectors,
@ -483,6 +486,7 @@ pub trait NodeHelpers<'a> {
fn get_content_boxes(self) -> Vec<Rect<Au>>; fn get_content_boxes(self) -> Vec<Rect<Au>>;
fn query_selector(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>>; fn query_selector(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>>;
#[allow(unsafe_code)]
unsafe fn query_selector_iter(self, selectors: DOMString) -> Fallible<QuerySelectorIterator<'a>>; unsafe fn query_selector_iter(self, selectors: DOMString) -> Fallible<QuerySelectorIterator<'a>>;
fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>>; fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>>;
@ -773,6 +777,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
/// Get an iterator over all nodes which match a set of selectors /// Get an iterator over all nodes which match a set of selectors
/// Be careful not to do anything which may manipulate the DOM tree whilst iterating, otherwise /// Be careful not to do anything which may manipulate the DOM tree whilst iterating, otherwise
/// the iterator may be invalidated /// the iterator may be invalidated
#[allow(unsafe_code)]
unsafe fn query_selector_iter(self, selectors: DOMString) unsafe fn query_selector_iter(self, selectors: DOMString)
-> Fallible<QuerySelectorIterator<'a>> { -> Fallible<QuerySelectorIterator<'a>> {
// Step 1. // Step 1.
@ -790,7 +795,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)] #[allow(unsafe_code)]
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 {
@ -907,7 +912,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)] #[allow(unsafe_code)]
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 {
@ -923,68 +928,88 @@ pub fn from_untrusted_node_address(runtime: *mut JSRuntime, candidate: Untrusted
} }
pub trait LayoutNodeHelpers { pub trait LayoutNodeHelpers {
#[allow(unsafe_code)]
unsafe fn type_id_for_layout(&self) -> NodeTypeId; unsafe fn type_id_for_layout(&self) -> NodeTypeId;
#[allow(unsafe_code)]
unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>>; unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>>;
#[allow(unsafe_code)]
unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>>; unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>>;
#[allow(unsafe_code)]
unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>>; unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>>;
#[allow(unsafe_code)]
unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>>; unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>>;
#[allow(unsafe_code)]
unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>>; unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>>;
#[allow(unsafe_code)]
unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document>; unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document>;
#[allow(unsafe_code)]
unsafe fn is_element_for_layout(&self) -> bool; unsafe fn is_element_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_flag(self, flag: NodeFlags) -> bool; unsafe fn get_flag(self, flag: NodeFlags) -> bool;
#[allow(unsafe_code)]
unsafe fn set_flag(self, flag: NodeFlags, value: bool); unsafe fn set_flag(self, flag: NodeFlags, value: bool);
} }
impl LayoutNodeHelpers for LayoutJS<Node> { impl LayoutNodeHelpers for LayoutJS<Node> {
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn type_id_for_layout(&self) -> NodeTypeId { unsafe fn type_id_for_layout(&self) -> NodeTypeId {
(*self.unsafe_get()).type_id (*self.unsafe_get()).type_id
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn is_element_for_layout(&self) -> bool { unsafe fn is_element_for_layout(&self) -> bool {
(*self.unsafe_get()).is_element() (*self.unsafe_get()).is_element()
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>> { unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>> {
(*self.unsafe_get()).parent_node.get_inner_as_layout() (*self.unsafe_get()).parent_node.get_inner_as_layout()
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>> { unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>> {
(*self.unsafe_get()).first_child.get_inner_as_layout() (*self.unsafe_get()).first_child.get_inner_as_layout()
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>> { unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>> {
(*self.unsafe_get()).last_child.get_inner_as_layout() (*self.unsafe_get()).last_child.get_inner_as_layout()
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>> { unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>> {
(*self.unsafe_get()).prev_sibling.get_inner_as_layout() (*self.unsafe_get()).prev_sibling.get_inner_as_layout()
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>> { unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>> {
(*self.unsafe_get()).next_sibling.get_inner_as_layout() (*self.unsafe_get()).next_sibling.get_inner_as_layout()
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document> { unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document> {
(*self.unsafe_get()).owner_doc.get_inner_as_layout().unwrap() (*self.unsafe_get()).owner_doc.get_inner_as_layout().unwrap()
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn get_flag(self, flag: NodeFlags) -> bool { unsafe fn get_flag(self, flag: NodeFlags) -> bool {
(*self.unsafe_get()).flags.get().contains(flag) (*self.unsafe_get()).flags.get().contains(flag)
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn set_flag(self, flag: NodeFlags, value: bool) { unsafe fn set_flag(self, flag: NodeFlags, value: bool) {
let this = self.unsafe_get(); let this = self.unsafe_get();
let mut flags = (*this).flags.get(); let mut flags = (*this).flags.get();
@ -1000,22 +1025,28 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
} }
pub trait RawLayoutNodeHelpers { pub trait RawLayoutNodeHelpers {
#[allow(unsafe_code)]
unsafe fn get_hover_state_for_layout(&self) -> bool; unsafe fn get_hover_state_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_disabled_state_for_layout(&self) -> bool; unsafe fn get_disabled_state_for_layout(&self) -> bool;
#[allow(unsafe_code)]
unsafe fn get_enabled_state_for_layout(&self) -> bool; unsafe fn get_enabled_state_for_layout(&self) -> bool;
fn type_id_for_layout(&self) -> NodeTypeId; fn type_id_for_layout(&self) -> NodeTypeId;
} }
impl RawLayoutNodeHelpers for Node { impl RawLayoutNodeHelpers for Node {
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn get_hover_state_for_layout(&self) -> bool { unsafe fn get_hover_state_for_layout(&self) -> bool {
self.flags.get().contains(IN_HOVER_STATE) self.flags.get().contains(IN_HOVER_STATE)
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn get_disabled_state_for_layout(&self) -> bool { unsafe fn get_disabled_state_for_layout(&self) -> bool {
self.flags.get().contains(IN_DISABLED_STATE) self.flags.get().contains(IN_DISABLED_STATE)
} }
#[inline] #[inline]
#[allow(unsafe_code)]
unsafe fn get_enabled_state_for_layout(&self) -> bool { unsafe fn get_enabled_state_for_layout(&self) -> bool {
self.flags.get().contains(IN_ENABLED_STATE) self.flags.get().contains(IN_ENABLED_STATE)
} }
@ -1245,6 +1276,7 @@ impl Node {
} }
#[inline] #[inline]
#[allow(unsafe_code)]
pub unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData> { pub unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData> {
self.layout_data.borrow_unchecked() self.layout_data.borrow_unchecked()
} }
@ -2207,6 +2239,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
#[derive(Clone, PartialEq, Eq, Copy)] #[derive(Clone, PartialEq, Eq, Copy)]
pub struct TrustedNodeAddress(pub *const c_void); pub struct TrustedNodeAddress(pub *const c_void);
#[allow(unsafe_code)]
unsafe impl Send for TrustedNodeAddress {} unsafe impl Send for TrustedNodeAddress {}
pub fn document_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Document> { pub fn document_from_node<T: NodeBase+Reflectable>(derived: JSRef<T>) -> Temporary<Document> {
@ -2341,15 +2374,19 @@ impl<'a> style::node::TNode<'a> for JSRef<'a, Node> {
} }
fn has_changed(self) -> bool { self.get_has_changed() } fn has_changed(self) -> bool { self.get_has_changed() }
#[allow(unsafe_code)]
unsafe fn set_changed(self, value: bool) { self.set_has_changed(value) } unsafe fn set_changed(self, value: bool) { self.set_has_changed(value) }
fn is_dirty(self) -> bool { self.get_is_dirty() } fn is_dirty(self) -> bool { self.get_is_dirty() }
#[allow(unsafe_code)]
unsafe fn set_dirty(self, value: bool) { self.set_is_dirty(value) } unsafe fn set_dirty(self, value: bool) { self.set_is_dirty(value) }
fn has_dirty_siblings(self) -> bool { self.get_has_dirty_siblings() } fn has_dirty_siblings(self) -> bool { self.get_has_dirty_siblings() }
#[allow(unsafe_code)]
unsafe fn set_dirty_siblings(self, value: bool) { self.set_has_dirty_siblings(value) } unsafe fn set_dirty_siblings(self, value: bool) { self.set_has_dirty_siblings(value) }
fn has_dirty_descendants(self) -> bool { self.get_has_dirty_descendants() } fn has_dirty_descendants(self) -> bool { self.get_has_dirty_descendants() }
#[allow(unsafe_code)]
unsafe fn set_dirty_descendants(self, value: bool) { self.set_has_dirty_descendants(value) } unsafe fn set_dirty_descendants(self, value: bool) { self.set_has_dirty_descendants(value) }
} }

View file

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

View file

@ -403,7 +403,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
debug!("{}", message); debug!("{}", message);
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn Gc(self) { fn Gc(self) {
unsafe { unsafe {
JS_GC(JS_GetRuntime(self.get_cx())); JS_GC(JS_GetRuntime(self.get_cx()));
@ -463,7 +463,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)] #[allow(unsafe_code)]
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();
@ -495,7 +495,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> {
*self.browser_context.borrow_mut() = None; *self.browser_context.borrow_mut() = None;
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
fn clear_js_context_for_script_deallocation(self) { fn clear_js_context_for_script_deallocation(self) {
unsafe { unsafe {
*self.js_context.borrow_for_script_deallocation() = None; *self.js_context.borrow_for_script_deallocation() = None;

View file

@ -208,7 +208,7 @@ impl XMLHttpRequest {
xhr.r().process_partial_response(progress); xhr.r().process_partial_response(progress);
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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,
@ -711,7 +711,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
} }
} }
} }
#[allow(unsafe_blocks)] #[allow(unsafe_code)]
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

@ -15,7 +15,7 @@
#![feature(unsafe_destructor)] #![feature(unsafe_destructor)]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![deny(unsafe_blocks)] #![deny(unsafe_code)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
#![doc="The script crate contains all matters DOM."] #![doc="The script crate contains all matters DOM."]

View file

@ -2,7 +2,7 @@
* 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, unrooted_must_root)] #![allow(unsafe_code, unrooted_must_root)]
use dom::attr::AttrHelpers; use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;

View file

@ -17,7 +17,7 @@
//! a page runs its course and the script task returns to processing events in the main event //! a page runs its course and the script task returns to processing events in the main event
//! loop. //! loop.
#![allow(unsafe_blocks)] #![allow(unsafe_code)]
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};

View file

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