mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
auto merge of #4869 : Ms2ger/servo/layout-unsafe, r=jdm
This commit is contained in:
commit
1a47f176ff
12 changed files with 30 additions and 15 deletions
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
//! Data needed by the layout task.
|
//! Data needed by the layout task.
|
||||||
|
|
||||||
|
#![allow(unsafe_blocks)]
|
||||||
|
|
||||||
use css::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
|
use css::matching::{ApplicableDeclarationsCache, StyleSharingCandidateCache};
|
||||||
|
|
||||||
use geom::{Rect, Size2D};
|
use geom::{Rect, Size2D};
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
//! High-level interface to CSS selector matching.
|
//! High-level interface to CSS selector matching.
|
||||||
|
|
||||||
|
#![allow(unsafe_blocks)]
|
||||||
|
|
||||||
use css::node_style::StyledNode;
|
use css::node_style::StyledNode;
|
||||||
use incremental::{self, RestyleDamage};
|
use incremental::{self, RestyleDamage};
|
||||||
use util::{LayoutDataAccess, LayoutDataWrapper};
|
use util::{LayoutDataAccess, LayoutDataWrapper};
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub trait StyledNode {
|
||||||
|
|
||||||
impl<'ln> StyledNode for ThreadSafeLayoutNode<'ln> {
|
impl<'ln> StyledNode for ThreadSafeLayoutNode<'ln> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[allow(unsafe_blocks)]
|
||||||
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();
|
||||||
|
|
|
@ -294,6 +294,7 @@ pub trait Flow: fmt::Show + Sync {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a layer ID for the given fragment.
|
/// Returns a layer ID for the given fragment.
|
||||||
|
#[allow(unsafe_blocks)]
|
||||||
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);
|
||||||
|
@ -310,6 +311,7 @@ pub trait Flow: fmt::Show + Sync {
|
||||||
// Base access
|
// Base access
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
#[allow(unsafe_blocks)]
|
||||||
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);
|
||||||
|
@ -323,6 +325,7 @@ pub fn imm_child_iter<'a>(flow: &'a Flow) -> FlowListIterator<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
#[allow(unsafe_blocks)]
|
||||||
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);
|
||||||
|
|
|
@ -2,9 +2,11 @@
|
||||||
* 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/. */
|
||||||
|
|
||||||
/// Reference-counted pointers to flows.
|
//! Reference-counted pointers to flows.
|
||||||
///
|
//!
|
||||||
/// Eventually, with dynamically sized types in Rust, much of this code will be superfluous.
|
//! Eventually, with dynamically sized types in Rust, much of this code will be superfluous.
|
||||||
|
|
||||||
|
#![allow(unsafe_blocks)]
|
||||||
|
|
||||||
use flow::Flow;
|
use flow::Flow;
|
||||||
use flow;
|
use flow;
|
||||||
|
|
|
@ -95,6 +95,7 @@ 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 }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
//! 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)]
|
||||||
|
|
||||||
use css::node_style::StyledNode;
|
use css::node_style::StyledNode;
|
||||||
use construct::ConstructionResult;
|
use construct::ConstructionResult;
|
||||||
use context::{SharedLayoutContext, SharedLayoutContextWrapper};
|
use context::{SharedLayoutContext, SharedLayoutContextWrapper};
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#![feature(thread_local, unsafe_destructor, box_syntax, plugin, int_uint)]
|
#![feature(thread_local, unsafe_destructor, box_syntax, plugin, int_uint)]
|
||||||
|
|
||||||
|
#![deny(unsafe_blocks)]
|
||||||
#![deny(unused_imports)]
|
#![deny(unused_imports)]
|
||||||
#![deny(unused_variables)]
|
#![deny(unused_variables)]
|
||||||
#![allow(unrooted_must_root)]
|
#![allow(unrooted_must_root)]
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
//!
|
//!
|
||||||
//! 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)]
|
||||||
|
|
||||||
use context::{LayoutContext, SharedLayoutContextWrapper, SharedLayoutContext};
|
use context::{LayoutContext, SharedLayoutContextWrapper, SharedLayoutContext};
|
||||||
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};
|
use flow::{Flow, MutableFlowUtils, PreorderFlowTraversal, PostorderFlowTraversal};
|
||||||
use flow;
|
use flow;
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
//! 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)]
|
||||||
|
|
||||||
use css::node_style::StyledNode;
|
use css::node_style::StyledNode;
|
||||||
use css::matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult};
|
use css::matching::{ApplicableDeclarations, MatchMethods, StyleSharingResult};
|
||||||
use construct::FlowConstructor;
|
use construct::FlowConstructor;
|
||||||
|
@ -91,11 +93,9 @@ fn take_task_local_bloom_filter(parent_node: Option<LayoutNode>, layout_context:
|
||||||
fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
|
fn put_task_local_bloom_filter(bf: Box<BloomFilter>,
|
||||||
unsafe_node: &UnsafeLayoutNode,
|
unsafe_node: &UnsafeLayoutNode,
|
||||||
layout_context: &LayoutContext) {
|
layout_context: &LayoutContext) {
|
||||||
let bf: *mut BloomFilter = unsafe { mem::transmute(bf) };
|
STYLE_BLOOM.with(move |style_bloom| {
|
||||||
STYLE_BLOOM.with(|style_bloom| {
|
|
||||||
assert!(style_bloom.borrow().is_none(),
|
assert!(style_bloom.borrow().is_none(),
|
||||||
"Putting into a never-taken task-local bloom filter");
|
"Putting into a never-taken task-local bloom filter");
|
||||||
let bf: Box<BloomFilter> = unsafe { mem::transmute(bf) };
|
|
||||||
*style_bloom.borrow_mut() = Some((bf, *unsafe_node, layout_context.shared.generation));
|
*style_bloom.borrow_mut() = Some((bf, *unsafe_node, layout_context.shared.generation));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 construct::ConstructionResult;
|
use construct::ConstructionResult;
|
||||||
use incremental::RestyleDamage;
|
use incremental::RestyleDamage;
|
||||||
use parallel::DomParallelInfo;
|
use parallel::DomParallelInfo;
|
||||||
|
@ -9,7 +11,7 @@ use wrapper::{LayoutNode, TLayoutNode, ThreadSafeLayoutNode};
|
||||||
|
|
||||||
use gfx::display_list::OpaqueNode;
|
use gfx::display_list::OpaqueNode;
|
||||||
use gfx;
|
use gfx;
|
||||||
use libc::uintptr_t;
|
use libc::{c_void, uintptr_t};
|
||||||
use script::dom::bindings::js::LayoutJS;
|
use script::dom::bindings::js::LayoutJS;
|
||||||
use script::dom::node::{Node, SharedLayoutData};
|
use script::dom::node::{Node, SharedLayoutData};
|
||||||
use script::layout_interface::{LayoutChan, TrustedNodeAddress};
|
use script::layout_interface::{LayoutChan, TrustedNodeAddress};
|
||||||
|
@ -141,9 +143,7 @@ impl OpaqueNodeMethods for OpaqueNode {
|
||||||
|
|
||||||
fn from_thread_safe_layout_node(node: &ThreadSafeLayoutNode) -> OpaqueNode {
|
fn from_thread_safe_layout_node(node: &ThreadSafeLayoutNode) -> OpaqueNode {
|
||||||
unsafe {
|
unsafe {
|
||||||
let abstract_node = node.get_jsmanaged();
|
OpaqueNodeMethods::from_jsmanaged(node.get_jsmanaged())
|
||||||
let ptr: uintptr_t = abstract_node.get_jsobject() as uintptr_t;
|
|
||||||
OpaqueNode(ptr)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,11 +161,8 @@ impl OpaqueNodeMethods for OpaqueNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress {
|
fn to_untrusted_node_address(&self) -> UntrustedNodeAddress {
|
||||||
unsafe {
|
let OpaqueNode(addr) = *self;
|
||||||
let OpaqueNode(addr) = *self;
|
UntrustedNodeAddress(addr as *const c_void)
|
||||||
let addr: UntrustedNodeAddress = mem::transmute(addr);
|
|
||||||
addr
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
//! 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)]
|
||||||
|
|
||||||
use canvas::canvas_paint_task::CanvasMsg;
|
use canvas::canvas_paint_task::CanvasMsg;
|
||||||
use context::SharedLayoutContext;
|
use context::SharedLayoutContext;
|
||||||
use css::node_style::StyledNode;
|
use css::node_style::StyledNode;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue