mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Replace unsafe_blocks by unsafe_code.
This commit is contained in:
parent
4eb26065ac
commit
3479d3fa7f
53 changed files with 151 additions and 57 deletions
|
@ -246,6 +246,7 @@ impl<'a> AttrHelpers<'a> for JSRef<'a, Attr> {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait AttrHelpersForLayout {
|
||||
unsafe fn value_ref_forever(&self) -> &'static str;
|
||||
unsafe fn value_atom_forever(&self) -> Option<Atom>;
|
||||
|
@ -253,6 +254,7 @@ pub trait AttrHelpersForLayout {
|
|||
unsafe fn local_name_atom_forever(&self) -> Atom;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
impl AttrHelpersForLayout for Attr {
|
||||
#[inline]
|
||||
unsafe fn value_ref_forever(&self) -> &'static str {
|
||||
|
|
|
@ -27,6 +27,7 @@ impl<T> DOMRefCell<T> {
|
|||
/// Return a reference to the contents.
|
||||
///
|
||||
/// For use in the layout task only.
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_layout<'a>(&'a self) -> &'a T {
|
||||
debug_assert!(task_state::get().is_layout());
|
||||
&*self.value.as_unsafe_cell().get()
|
||||
|
@ -36,6 +37,7 @@ impl<T> DOMRefCell<T> {
|
|||
///
|
||||
/// This succeeds even if the object is mutably borrowed,
|
||||
/// so you have to be careful in trace code!
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_for_gc_trace<'a>(&'a self) -> &'a T {
|
||||
debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
|
||||
&*self.value.as_unsafe_cell().get()
|
||||
|
@ -43,6 +45,7 @@ impl<T> DOMRefCell<T> {
|
|||
|
||||
/// 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 {
|
||||
debug_assert!(task_state::get().contains(SCRIPT));
|
||||
&mut *self.value.as_unsafe_cell().get()
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
//! some sanity checks and [argument conversions](conversions/index.html), and
|
||||
//! calls into API implementation for the DOM object.
|
||||
|
||||
#![allow(unsafe_blocks)]
|
||||
#![allow(unsafe_code)]
|
||||
#![deny(missing_docs, non_snake_case)]
|
||||
|
||||
pub mod cell;
|
||||
|
|
|
@ -67,7 +67,7 @@ impl BrowserContext {
|
|||
self.window_proxy
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn create_window_proxy(&mut self) {
|
||||
let win = self.active_window().root();
|
||||
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>> {
|
||||
let index = get_array_index_from_id(cx, id);
|
||||
if let Some(index) = index {
|
||||
|
@ -116,6 +117,7 @@ unsafe fn GetSubframeWindow(cx: *mut JSContext, proxy: *mut JSObject, id: jsid)
|
|||
None
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, set: bool, desc: *mut JSPropertyDescriptor) -> bool {
|
||||
let window = GetSubframeWindow(cx, proxy, id);
|
||||
if let Some(window) = window {
|
||||
|
@ -142,7 +144,7 @@ unsafe extern fn getOwnPropertyDescriptor(cx: *mut JSContext, proxy: *mut JSObje
|
|||
true
|
||||
}
|
||||
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
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() {
|
||||
// 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
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern fn hasOwn(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, bp: *mut bool) -> bool {
|
||||
let window = GetSubframeWindow(cx, proxy, id);
|
||||
if window.is_some() {
|
||||
|
@ -174,6 +177,7 @@ unsafe extern fn hasOwn(cx: *mut JSContext, proxy: *mut JSObject, id: jsid, bp:
|
|||
return true;
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
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);
|
||||
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
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
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() {
|
||||
// Reject (which means throw if and only if strict) the set.
|
||||
|
@ -234,7 +239,7 @@ static PROXY_HANDLER: ProxyTraps = ProxyTraps {
|
|||
trace: None
|
||||
};
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
pub fn new_window_proxy_handler() -> WindowProxyHandler {
|
||||
unsafe {
|
||||
WindowProxyHandler(CreateWrapperProxyHandler(&PROXY_HANDLER))
|
||||
|
|
|
@ -78,10 +78,12 @@ impl CanvasRenderingContext2D {
|
|||
}
|
||||
|
||||
pub trait LayoutCanvasRenderingContext2DHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_renderer(&self) -> Sender<CanvasMsg>;
|
||||
}
|
||||
|
||||
impl LayoutCanvasRenderingContext2DHelpers for LayoutJS<CanvasRenderingContext2D> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_renderer(&self) -> Sender<CanvasMsg> {
|
||||
(*self.unsafe_get()).renderer.clone()
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ impl CharacterData {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn data_for_layout<'a>(&'a self) -> &'a str {
|
||||
self.data.borrow_for_layout().as_slice()
|
||||
}
|
||||
|
|
|
@ -689,12 +689,14 @@ pub enum DocumentSource {
|
|||
}
|
||||
|
||||
pub trait LayoutDocumentHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_html_document_for_layout(&self) -> bool;
|
||||
}
|
||||
|
||||
impl LayoutDocumentHelpers for LayoutJS<Document> {
|
||||
#[allow(unrooted_must_root)]
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_html_document_for_layout(&self) -> bool {
|
||||
(*self.unsafe_get()).is_html_document
|
||||
}
|
||||
|
|
|
@ -148,6 +148,7 @@ impl Element {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
pub trait RawLayoutElementHelpers {
|
||||
unsafe fn get_attr_val_for_layout<'a>(&'a self, namespace: &Namespace, name: &Atom)
|
||||
-> Option<&'a str>;
|
||||
|
@ -171,6 +172,7 @@ pub trait RawLayoutElementHelpers {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
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
|
||||
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 {
|
||||
#[inline]
|
||||
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 {
|
||||
#[allow(unsafe_code)]
|
||||
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;
|
||||
}
|
||||
|
||||
impl LayoutElementHelpers for LayoutJS<Element> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn html_element_in_html_document_for_layout(&self) -> bool {
|
||||
if (*self.unsafe_get()).namespace != ns!(HTML) {
|
||||
return false
|
||||
|
@ -408,6 +414,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
|||
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 {
|
||||
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> {
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str> {
|
||||
self.get_attribute(namespace.clone(), attr).root().map(|attr| {
|
||||
// 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()) }
|
||||
})
|
||||
}
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn get_attrs(self, attr: &Atom) -> Vec<&'a str> {
|
||||
self.get_attributes(attr).into_iter().map(|attr| attr.root()).map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
|
|
|
@ -191,7 +191,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
|||
}).map(|entry| entry.listener.get_listener()))
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn set_event_handler_uncompiled(self,
|
||||
cx: *mut JSContext,
|
||||
url: Url,
|
||||
|
|
|
@ -82,7 +82,7 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
|
|||
self.data.borrow_mut().remove(&name);
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn Get(self, name: DOMString) -> Option<FileOrString> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let data = self.data.borrow();
|
||||
|
|
|
@ -211,7 +211,7 @@ impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
|
|||
}
|
||||
|
||||
// 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) {
|
||||
let doc = document_from_node(*self).root();
|
||||
let node: JSRef<Node> = NodeCast::from_ref(doc.r());
|
||||
|
|
|
@ -63,21 +63,27 @@ impl HTMLCanvasElement {
|
|||
}
|
||||
|
||||
pub trait LayoutHTMLCanvasElementHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_canvas_width(&self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_canvas_height(&self) -> u32;
|
||||
}
|
||||
|
||||
impl LayoutHTMLCanvasElementHelpers for LayoutJS<HTMLCanvasElement> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_renderer(&self) -> Option<Sender<CanvasMsg>> {
|
||||
let context = (*self.unsafe_get()).context.get_inner_as_layout();
|
||||
context.map(|cx| cx.get_renderer())
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_canvas_width(&self) -> u32 {
|
||||
(*self.unsafe_get()).width.get()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_canvas_height(&self) -> u32 {
|
||||
(*self.unsafe_get()).height.get()
|
||||
}
|
||||
|
|
|
@ -86,10 +86,12 @@ impl HTMLImageElement {
|
|||
}
|
||||
|
||||
pub trait LayoutHTMLImageElementHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image(&self) -> Option<Url>;
|
||||
}
|
||||
|
||||
impl LayoutHTMLImageElementHelpers for LayoutJS<HTMLImageElement> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn image(&self) -> Option<Url> {
|
||||
(*self.unsafe_get()).image.borrow_for_layout().clone()
|
||||
}
|
||||
|
|
|
@ -129,23 +129,31 @@ impl HTMLInputElement {
|
|||
}
|
||||
|
||||
pub trait LayoutHTMLInputElementHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_value_for_layout(self) -> String;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_size_for_layout(self) -> u32;
|
||||
}
|
||||
|
||||
pub trait RawLayoutHTMLInputElementHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_checked_state_for_layout(&self) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_indeterminate_state_for_layout(&self) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_size_for_layout(&self) -> u32;
|
||||
}
|
||||
|
||||
impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_value_for_layout(self) -> String {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_raw_textinput_value(input: LayoutJS<HTMLInputElement>) -> String {
|
||||
(*input.unsafe_get()).textinput.borrow_for_layout().get_content()
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_raw_attr_value(input: LayoutJS<HTMLInputElement>) -> Option<String> {
|
||||
let elem: LayoutJS<Element> = input.transmute_copy();
|
||||
(*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(unsafe_code)]
|
||||
unsafe fn get_size_for_layout(self) -> u32 {
|
||||
(*self.unsafe_get()).get_size_for_layout()
|
||||
}
|
||||
|
@ -174,16 +183,19 @@ impl LayoutHTMLInputElementHelpers for LayoutJS<HTMLInputElement> {
|
|||
|
||||
impl RawLayoutHTMLInputElementHelpers for HTMLInputElement {
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_checked_state_for_layout(&self) -> bool {
|
||||
self.checked.get()
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_indeterminate_state_for_layout(&self) -> bool {
|
||||
self.indeterminate.get()
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_size_for_layout(&self) -> u32 {
|
||||
self.size.get()
|
||||
}
|
||||
|
@ -307,7 +319,7 @@ pub trait HTMLInputElementHelpers {
|
|||
fn reset(self);
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&str>) {
|
||||
//TODO: if not in document, use root ancestor instead of document
|
||||
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
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn pre_click_activation(&self) {
|
||||
let mut cache = self.activation_state.borrow_mut();
|
||||
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
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
|
||||
let doc = document_from_node(*self).root();
|
||||
let node: JSRef<Node> = NodeCast::from_ref(doc.r());
|
||||
|
|
|
@ -52,16 +52,20 @@ impl HTMLTextAreaElementDerived for EventTarget {
|
|||
}
|
||||
|
||||
pub trait LayoutHTMLTextAreaElementHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_value_for_layout(self) -> String;
|
||||
}
|
||||
|
||||
pub trait RawLayoutHTMLTextAreaElementHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_cols_for_layout(&self) -> u32;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_rows_for_layout(&self) -> u32;
|
||||
}
|
||||
|
||||
impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_value_for_layout(self) -> String {
|
||||
(*self.unsafe_get()).textinput.borrow_for_layout().get_content()
|
||||
}
|
||||
|
@ -69,11 +73,13 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutJS<HTMLTextAreaElement> {
|
|||
|
||||
impl RawLayoutHTMLTextAreaElementHelpers for HTMLTextAreaElement {
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_cols_for_layout(&self) -> u32 {
|
||||
self.cols.get()
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_rows_for_layout(&self) -> u32 {
|
||||
self.rows.get()
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ pub struct ImageData {
|
|||
}
|
||||
|
||||
impl ImageData {
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn new_inherited(width: u32, height: u32, data: Option<Vec<u8>>, global: GlobalRef) -> ImageData {
|
||||
unsafe {
|
||||
let cx = global.get_cx();
|
||||
|
@ -57,7 +57,7 @@ pub trait ImageDataHelpers {
|
|||
}
|
||||
|
||||
impl<'a> ImageDataHelpers for JSRef<'a, ImageData> {
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn get_data_array(self, global: &GlobalRef) -> Vec<u8> {
|
||||
unsafe {
|
||||
let cx = global.get_cx();
|
||||
|
|
|
@ -175,7 +175,7 @@ impl NodeFlags {
|
|||
|
||||
#[unsafe_destructor]
|
||||
impl Drop for Node {
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn drop(&mut self) {
|
||||
self.layout_data.dispose();
|
||||
}
|
||||
|
@ -203,6 +203,7 @@ pub struct LayoutData {
|
|||
_data: NonZero<*const ()>,
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe impl Send for LayoutData {}
|
||||
|
||||
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-
|
||||
/// safe layout data accessor.
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn borrow_unchecked(&self) -> *const Option<LayoutData> {
|
||||
mem::transmute(&self.data_cell)
|
||||
}
|
||||
|
@ -382,6 +384,7 @@ pub struct QuerySelectorIterator<'a> {
|
|||
}
|
||||
|
||||
impl<'a> QuerySelectorIterator<'a> {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn new(iter: TreeIterator<'a>, selectors: Vec<Selector>) -> QuerySelectorIterator<'a> {
|
||||
QuerySelectorIterator {
|
||||
selectors: selectors,
|
||||
|
@ -483,6 +486,7 @@ pub trait NodeHelpers<'a> {
|
|||
fn get_content_boxes(self) -> Vec<Rect<Au>>;
|
||||
|
||||
fn query_selector(self, selectors: DOMString) -> Fallible<Option<Temporary<Element>>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn query_selector_iter(self, selectors: DOMString) -> Fallible<QuerySelectorIterator<'a>>;
|
||||
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
|
||||
/// Be careful not to do anything which may manipulate the DOM tree whilst iterating, otherwise
|
||||
/// the iterator may be invalidated
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn query_selector_iter(self, selectors: DOMString)
|
||||
-> Fallible<QuerySelectorIterator<'a>> {
|
||||
// Step 1.
|
||||
|
@ -790,7 +795,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn query_selector_all(self, selectors: DOMString) -> Fallible<Temporary<NodeList>> {
|
||||
// Step 1.
|
||||
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,
|
||||
/// returns it.
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
pub fn from_untrusted_node_address(runtime: *mut JSRuntime, candidate: UntrustedNodeAddress)
|
||||
-> Temporary<Node> {
|
||||
unsafe {
|
||||
|
@ -923,68 +928,88 @@ pub fn from_untrusted_node_address(runtime: *mut JSRuntime, candidate: Untrusted
|
|||
}
|
||||
|
||||
pub trait LayoutNodeHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>>;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>>;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document>;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_element_for_layout(&self) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_flag(self, flag: NodeFlags) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn set_flag(self, flag: NodeFlags, value: bool);
|
||||
}
|
||||
|
||||
impl LayoutNodeHelpers for LayoutJS<Node> {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn type_id_for_layout(&self) -> NodeTypeId {
|
||||
(*self.unsafe_get()).type_id
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn is_element_for_layout(&self) -> bool {
|
||||
(*self.unsafe_get()).is_element()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn parent_node_ref(&self) -> Option<LayoutJS<Node>> {
|
||||
(*self.unsafe_get()).parent_node.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn first_child_ref(&self) -> Option<LayoutJS<Node>> {
|
||||
(*self.unsafe_get()).first_child.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn last_child_ref(&self) -> Option<LayoutJS<Node>> {
|
||||
(*self.unsafe_get()).last_child.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn prev_sibling_ref(&self) -> Option<LayoutJS<Node>> {
|
||||
(*self.unsafe_get()).prev_sibling.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn next_sibling_ref(&self) -> Option<LayoutJS<Node>> {
|
||||
(*self.unsafe_get()).next_sibling.get_inner_as_layout()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn owner_doc_for_layout(&self) -> LayoutJS<Document> {
|
||||
(*self.unsafe_get()).owner_doc.get_inner_as_layout().unwrap()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_flag(self, flag: NodeFlags) -> bool {
|
||||
(*self.unsafe_get()).flags.get().contains(flag)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn set_flag(self, flag: NodeFlags, value: bool) {
|
||||
let this = self.unsafe_get();
|
||||
let mut flags = (*this).flags.get();
|
||||
|
@ -1000,22 +1025,28 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
|
|||
}
|
||||
|
||||
pub trait RawLayoutNodeHelpers {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_hover_state_for_layout(&self) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_disabled_state_for_layout(&self) -> bool;
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_enabled_state_for_layout(&self) -> bool;
|
||||
fn type_id_for_layout(&self) -> NodeTypeId;
|
||||
}
|
||||
|
||||
impl RawLayoutNodeHelpers for Node {
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_hover_state_for_layout(&self) -> bool {
|
||||
self.flags.get().contains(IN_HOVER_STATE)
|
||||
}
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_disabled_state_for_layout(&self) -> bool {
|
||||
self.flags.get().contains(IN_DISABLED_STATE)
|
||||
}
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn get_enabled_state_for_layout(&self) -> bool {
|
||||
self.flags.get().contains(IN_ENABLED_STATE)
|
||||
}
|
||||
|
@ -1245,6 +1276,7 @@ impl Node {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
pub unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData> {
|
||||
self.layout_data.borrow_unchecked()
|
||||
}
|
||||
|
@ -2207,6 +2239,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
#[derive(Clone, PartialEq, Eq, Copy)]
|
||||
pub struct TrustedNodeAddress(pub *const c_void);
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe impl Send for TrustedNodeAddress {}
|
||||
|
||||
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() }
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn set_changed(self, value: bool) { self.set_has_changed(value) }
|
||||
|
||||
fn is_dirty(self) -> bool { self.get_is_dirty() }
|
||||
#[allow(unsafe_code)]
|
||||
unsafe fn set_dirty(self, value: bool) { self.set_is_dirty(value) }
|
||||
|
||||
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) }
|
||||
|
||||
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) }
|
||||
}
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ impl tree_builder::Tracer for Tracer {
|
|||
}
|
||||
|
||||
impl JSTraceable for ServoHTMLParser {
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn trace(&self, trc: *mut JSTracer) {
|
||||
self.reflector_.trace(trc);
|
||||
|
||||
|
|
|
@ -403,7 +403,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||
debug!("{}", message);
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn Gc(self) {
|
||||
unsafe {
|
||||
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, "")
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn evaluate_script_on_global_with_result(self, code: &str, filename: &str) -> JSVal {
|
||||
let this = self.reflector().get_jsobject();
|
||||
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;
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn clear_js_context_for_script_deallocation(self) {
|
||||
unsafe {
|
||||
*self.js_context.borrow_for_script_deallocation() = None;
|
||||
|
|
|
@ -208,7 +208,7 @@ impl XMLHttpRequest {
|
|||
xhr.r().process_partial_response(progress);
|
||||
}
|
||||
|
||||
#[allow(unsafe_blocks)]
|
||||
#[allow(unsafe_code)]
|
||||
fn fetch(fetch_type: &SyncOrAsync, resource_task: ResourceTask,
|
||||
mut load_data: LoadData, terminate_receiver: Receiver<TerminateReason>,
|
||||
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 {
|
||||
match self.response_type.get() {
|
||||
_empty | Text => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue