mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
auto merge of #3837 : pcwalton/servo/layout-formatting-cleanups, r=metajack
These should have no effect on functionality. r? @metajack
This commit is contained in:
commit
4bdd9a5ec0
8 changed files with 147 additions and 108 deletions
|
@ -436,7 +436,7 @@ impl<'a> PreorderFlowTraversal for AbsoluteAssignBSizesTraversal<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let AbsoluteAssignBSizesTraversal(ref ctx) = *self;
|
let AbsoluteAssignBSizesTraversal(ref ctx) = *self;
|
||||||
block_flow.calculate_abs_block_size_and_margins(*ctx);
|
block_flow.calculate_absolute_block_size_and_margins(*ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -631,7 +631,7 @@ impl BlockFlow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute the used value of inline-size for this Block.
|
/// Compute the actual inline size and position for this block.
|
||||||
pub fn compute_used_inline_size(&mut self,
|
pub fn compute_used_inline_size(&mut self,
|
||||||
ctx: &LayoutContext,
|
ctx: &LayoutContext,
|
||||||
containing_block_inline_size: Au) {
|
containing_block_inline_size: Au) {
|
||||||
|
@ -686,7 +686,7 @@ impl BlockFlow {
|
||||||
/// reference the CB.
|
/// reference the CB.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn containing_block_size(&mut self, viewport_size: Size2D<Au>) -> LogicalSize<Au> {
|
pub fn containing_block_size(&mut self, viewport_size: Size2D<Au>) -> LogicalSize<Au> {
|
||||||
assert!(self.is_absolutely_positioned());
|
debug_assert!(self.is_absolutely_positioned());
|
||||||
if self.is_fixed() {
|
if self.is_fixed() {
|
||||||
// Initial containing block is the CB for the root
|
// Initial containing block is the CB for the root
|
||||||
LogicalSize::from_physical(self.base.writing_mode, viewport_size)
|
LogicalSize::from_physical(self.base.writing_mode, viewport_size)
|
||||||
|
@ -1062,6 +1062,7 @@ impl BlockFlow {
|
||||||
let margin_offset = LogicalPoint::new(writing_mode,
|
let margin_offset = LogicalPoint::new(writing_mode,
|
||||||
Au(0),
|
Au(0),
|
||||||
self.fragment.margin.block_start);
|
self.fragment.margin.block_start);
|
||||||
|
|
||||||
self.base.position = self.base.position.translate(&float_offset).translate(&margin_offset);
|
self.base.position = self.base.position.translate(&float_offset).translate(&margin_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,9 +1072,9 @@ impl BlockFlow {
|
||||||
/// The layout for its in-flow children has been done during normal layout.
|
/// The layout for its in-flow children has been done during normal layout.
|
||||||
/// This is just the calculation of:
|
/// This is just the calculation of:
|
||||||
/// + block-size for the flow
|
/// + block-size for the flow
|
||||||
/// + y-coordinate of the flow wrt its Containing Block.
|
/// + position in the block direction of the flow with respect to its Containing Block.
|
||||||
/// + block-size, vertical margins, and y-coordinate for the flow's box.
|
/// + block-size, vertical margins, and y-coordinate for the flow's box.
|
||||||
fn calculate_abs_block_size_and_margins(&mut self, ctx: &LayoutContext) {
|
fn calculate_absolute_block_size_and_margins(&mut self, ctx: &LayoutContext) {
|
||||||
let containing_block_block_size = self.containing_block_size(ctx.shared.screen_size).block;
|
let containing_block_block_size = self.containing_block_size(ctx.shared.screen_size).block;
|
||||||
let static_b_offset = self.static_b_offset;
|
let static_b_offset = self.static_b_offset;
|
||||||
|
|
||||||
|
@ -1098,11 +1099,13 @@ impl BlockFlow {
|
||||||
let block_end;
|
let block_end;
|
||||||
{
|
{
|
||||||
let position = self.fragment.style().logical_position();
|
let position = self.fragment.style().logical_position();
|
||||||
block_start = MaybeAuto::from_style(position.block_start, containing_block_block_size);
|
block_start = MaybeAuto::from_style(position.block_start,
|
||||||
|
containing_block_block_size);
|
||||||
block_end = MaybeAuto::from_style(position.block_end, containing_block_block_size);
|
block_end = MaybeAuto::from_style(position.block_end, containing_block_block_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
let available_block_size = containing_block_block_size - self.fragment.border_padding.block_start_end();
|
let available_block_size = containing_block_block_size -
|
||||||
|
self.fragment.border_padding.block_start_end();
|
||||||
if self.is_replaced_content() {
|
if self.is_replaced_content() {
|
||||||
// Calculate used value of block-size just like we do for inline replaced elements.
|
// Calculate used value of block-size just like we do for inline replaced elements.
|
||||||
// TODO: Pass in the containing block block-size when Fragment's
|
// TODO: Pass in the containing block block-size when Fragment's
|
||||||
|
@ -1348,6 +1351,8 @@ impl BlockFlow {
|
||||||
/// on the floats we could see at the time of inline-size assignment. The job of this function,
|
/// on the floats we could see at the time of inline-size assignment. The job of this function,
|
||||||
/// therefore, is not only to assign the final size but also to perform the layout again for
|
/// therefore, is not only to assign the final size but also to perform the layout again for
|
||||||
/// this block formatting context if our speculation was wrong.
|
/// this block formatting context if our speculation was wrong.
|
||||||
|
///
|
||||||
|
/// FIXME(pcwalton): This code is not incremental-reflow-safe (i.e. not idempotent).
|
||||||
fn assign_inline_position_for_formatting_context(&mut self) {
|
fn assign_inline_position_for_formatting_context(&mut self) {
|
||||||
debug_assert!(self.formatting_context_type() != NonformattingContext);
|
debug_assert!(self.formatting_context_type() != NonformattingContext);
|
||||||
|
|
||||||
|
@ -1611,19 +1616,18 @@ impl Flow for BlockFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.is_absolutely_positioned() {
|
if self.is_absolutely_positioned() {
|
||||||
let position_start = self.base.position.start.to_physical(
|
let position_start = self.base.position.start.to_physical(self.base.writing_mode,
|
||||||
self.base.writing_mode, container_size);
|
container_size);
|
||||||
self.base
|
self.base.absolute_position_info.absolute_containing_block_position =
|
||||||
.absolute_position_info
|
if self.is_fixed() {
|
||||||
.absolute_containing_block_position = if self.is_fixed() {
|
// The viewport is initially at (0, 0).
|
||||||
// The viewport is initially at (0, 0).
|
position_start
|
||||||
position_start
|
} else {
|
||||||
} else {
|
// Absolute position of the containing block + position of absolute
|
||||||
// Absolute position of the containing block + position of absolute flow w/r/t the
|
// flow w.r.t. the containing block.
|
||||||
// containing block.
|
self.base.absolute_position_info.absolute_containing_block_position
|
||||||
self.base.absolute_position_info.absolute_containing_block_position
|
+ position_start
|
||||||
+ position_start
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// Set the absolute position, which will be passed down later as part
|
// Set the absolute position, which will be passed down later as part
|
||||||
// of containing block details for absolute descendants.
|
// of containing block details for absolute descendants.
|
||||||
|
@ -1929,9 +1933,9 @@ pub trait ISizeAndMarginsComputer {
|
||||||
|
|
||||||
/// Solve the inline-size and margins constraints for this block flow.
|
/// Solve the inline-size and margins constraints for this block flow.
|
||||||
fn solve_inline_size_constraints(&self,
|
fn solve_inline_size_constraints(&self,
|
||||||
block: &mut BlockFlow,
|
block: &mut BlockFlow,
|
||||||
input: &ISizeConstraintInput)
|
input: &ISizeConstraintInput)
|
||||||
-> ISizeConstraintSolution;
|
-> ISizeConstraintSolution;
|
||||||
|
|
||||||
fn initial_computed_inline_size(&self,
|
fn initial_computed_inline_size(&self,
|
||||||
block: &mut BlockFlow,
|
block: &mut BlockFlow,
|
||||||
|
@ -1957,16 +1961,14 @@ pub trait ISizeAndMarginsComputer {
|
||||||
/// CSS Section 10.4: Minimum and Maximum inline-sizes
|
/// CSS Section 10.4: Minimum and Maximum inline-sizes
|
||||||
fn compute_used_inline_size(&self,
|
fn compute_used_inline_size(&self,
|
||||||
block: &mut BlockFlow,
|
block: &mut BlockFlow,
|
||||||
ctx: &LayoutContext,
|
layout_context: &LayoutContext,
|
||||||
parent_flow_inline_size: Au) {
|
parent_flow_inline_size: Au) {
|
||||||
let mut input = self.compute_inline_size_constraint_inputs(block,
|
let mut input = self.compute_inline_size_constraint_inputs(block,
|
||||||
parent_flow_inline_size,
|
parent_flow_inline_size,
|
||||||
ctx);
|
layout_context);
|
||||||
|
|
||||||
let containing_block_inline_size = self.containing_block_inline_size(
|
let containing_block_inline_size =
|
||||||
block,
|
self.containing_block_inline_size(block, parent_flow_inline_size, layout_context);
|
||||||
parent_flow_inline_size,
|
|
||||||
ctx);
|
|
||||||
|
|
||||||
let mut solution = self.solve_inline_size_constraints(block, &input);
|
let mut solution = self.solve_inline_size_constraints(block, &input);
|
||||||
|
|
||||||
|
@ -2005,9 +2007,9 @@ pub trait ISizeAndMarginsComputer {
|
||||||
/// available_inline-size
|
/// available_inline-size
|
||||||
/// where available_inline-size = CB inline-size - (horizontal border + padding)
|
/// where available_inline-size = CB inline-size - (horizontal border + padding)
|
||||||
fn solve_block_inline_size_constraints(&self,
|
fn solve_block_inline_size_constraints(&self,
|
||||||
_: &mut BlockFlow,
|
_: &mut BlockFlow,
|
||||||
input: &ISizeConstraintInput)
|
input: &ISizeConstraintInput)
|
||||||
-> ISizeConstraintSolution {
|
-> ISizeConstraintSolution {
|
||||||
let (computed_inline_size, inline_start_margin, inline_end_margin, available_inline_size) =
|
let (computed_inline_size, inline_start_margin, inline_end_margin, available_inline_size) =
|
||||||
(input.computed_inline_size,
|
(input.computed_inline_size,
|
||||||
input.inline_start_margin,
|
input.inline_start_margin,
|
||||||
|
|
|
@ -1192,11 +1192,11 @@ pub trait FlowConstructionUtils {
|
||||||
fn add_new_child(&mut self, new_child: FlowRef);
|
fn add_new_child(&mut self, new_child: FlowRef);
|
||||||
|
|
||||||
/// Finishes a flow. Once a flow is finished, no more child flows or boxes may be added to it.
|
/// Finishes a flow. Once a flow is finished, no more child flows or boxes may be added to it.
|
||||||
/// This will normally run the bubble-inline-sizes (minimum and preferred -- i.e. intrinsic -- inline-size)
|
/// This will normally run the bubble-inline-sizes (minimum and preferred -- i.e. intrinsic --
|
||||||
/// calculation, unless the global `bubble_inline-sizes_separately` flag is on.
|
/// inline-size) calculation, unless the global `bubble_inline-sizes_separately` flag is on.
|
||||||
///
|
///
|
||||||
/// All flows must be finished at some point, or they will not have their intrinsic inline-sizes
|
/// All flows must be finished at some point, or they will not have their intrinsic inline-
|
||||||
/// properly computed. (This is not, however, a memory safety problem.)
|
/// sizes properly computed. (This is not, however, a memory safety problem.)
|
||||||
fn finish(&mut self);
|
fn finish(&mut self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1217,8 +1217,8 @@ impl FlowConstructionUtils for FlowRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Finishes a flow. Once a flow is finished, no more child flows or fragments may be added to
|
/// Finishes a flow. Once a flow is finished, no more child flows or fragments may be added to
|
||||||
/// it. This will normally run the bubble-inline-sizes (minimum and preferred -- i.e. intrinsic --
|
/// it. This will normally run the bubble-inline-sizes (minimum and preferred -- i.e. intrinsic
|
||||||
/// inline-size) calculation, unless the global `bubble_inline-sizes_separately` flag is on.
|
/// -- inline-size) calculation, unless the global `bubble_inline-sizes_separately` flag is on.
|
||||||
///
|
///
|
||||||
/// All flows must be finished at some point, or they will not have their intrinsic inline-sizes
|
/// All flows must be finished at some point, or they will not have their intrinsic inline-sizes
|
||||||
/// properly computed. (This is not, however, a memory safety problem.)
|
/// properly computed. (This is not, however, a memory safety problem.)
|
||||||
|
|
|
@ -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/. */
|
||||||
|
|
||||||
// High-level interface to CSS selector matching.
|
//! High-level interface to CSS selector matching.
|
||||||
|
|
||||||
use css::node_style::StyledNode;
|
use css::node_style::StyledNode;
|
||||||
use util::{LayoutDataAccess, LayoutDataWrapper};
|
use util::{LayoutDataAccess, LayoutDataWrapper};
|
||||||
|
@ -550,20 +550,20 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
||||||
applicable_declarations_cache,
|
applicable_declarations_cache,
|
||||||
applicable_declarations.normal_shareable);
|
applicable_declarations.normal_shareable);
|
||||||
if applicable_declarations.before.len() > 0 {
|
if applicable_declarations.before.len() > 0 {
|
||||||
self.cascade_node_pseudo_element(
|
self.cascade_node_pseudo_element(
|
||||||
Some(layout_data.shared_data.style.as_ref().unwrap()),
|
Some(layout_data.shared_data.style.as_ref().unwrap()),
|
||||||
applicable_declarations.before.as_slice(),
|
applicable_declarations.before.as_slice(),
|
||||||
&mut layout_data.data.before_style,
|
&mut layout_data.data.before_style,
|
||||||
applicable_declarations_cache,
|
applicable_declarations_cache,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
if applicable_declarations.after.len() > 0 {
|
if applicable_declarations.after.len() > 0 {
|
||||||
self.cascade_node_pseudo_element(
|
self.cascade_node_pseudo_element(
|
||||||
Some(layout_data.shared_data.style.as_ref().unwrap()),
|
Some(layout_data.shared_data.style.as_ref().unwrap()),
|
||||||
applicable_declarations.after.as_slice(),
|
applicable_declarations.after.as_slice(),
|
||||||
&mut layout_data.data.after_style,
|
&mut layout_data.data.after_style,
|
||||||
applicable_declarations_cache,
|
applicable_declarations_cache,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use incremental::RestyleDamage;
|
||||||
use util::LayoutDataAccess;
|
use util::LayoutDataAccess;
|
||||||
use wrapper::ThreadSafeLayoutNode;
|
use wrapper::ThreadSafeLayoutNode;
|
||||||
use wrapper::{After, Before, Normal};
|
use wrapper::{After, Before, Normal};
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use style::ComputedValues;
|
use style::ComputedValues;
|
||||||
use sync::Arc;
|
use sync::Arc;
|
||||||
|
|
|
@ -216,7 +216,7 @@ impl Floats {
|
||||||
let mut r_block_start = None;
|
let mut r_block_start = None;
|
||||||
let mut r_block_end = None;
|
let mut r_block_end = None;
|
||||||
|
|
||||||
// Find the float collisions for the given vertical range.
|
// Find the float collisions for the given range in the block direction.
|
||||||
for float in list.floats.iter() {
|
for float in list.floats.iter() {
|
||||||
debug!("available_rect: Checking for collision against float");
|
debug!("available_rect: Checking for collision against float");
|
||||||
let float_pos = float.bounds.start;
|
let float_pos = float.bounds.start;
|
||||||
|
|
|
@ -765,10 +765,11 @@ pub struct BaseFlow {
|
||||||
/// Any layers that we're bubbling up, in a linked list.
|
/// Any layers that we're bubbling up, in a linked list.
|
||||||
pub layers: DList<RenderLayer>,
|
pub layers: DList<RenderLayer>,
|
||||||
|
|
||||||
|
/// The writing mode for this flow.
|
||||||
|
pub writing_mode: WritingMode,
|
||||||
|
|
||||||
/// Various flags for flows, tightly packed to save space.
|
/// Various flags for flows, tightly packed to save space.
|
||||||
pub flags: FlowFlags,
|
pub flags: FlowFlags,
|
||||||
|
|
||||||
pub writing_mode: WritingMode,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Show for BaseFlow {
|
impl fmt::Show for BaseFlow {
|
||||||
|
@ -824,9 +825,7 @@ impl BaseFlow {
|
||||||
intrinsic_inline_sizes: IntrinsicISizes::new(),
|
intrinsic_inline_sizes: IntrinsicISizes::new(),
|
||||||
position: LogicalRect::zero(writing_mode),
|
position: LogicalRect::zero(writing_mode),
|
||||||
overflow: LogicalRect::zero(writing_mode),
|
overflow: LogicalRect::zero(writing_mode),
|
||||||
|
|
||||||
parallel: FlowParallelInfo::new(),
|
parallel: FlowParallelInfo::new(),
|
||||||
|
|
||||||
floats: Floats::new(writing_mode),
|
floats: Floats::new(writing_mode),
|
||||||
collapsible_margins: CollapsibleMargins::new(),
|
collapsible_margins: CollapsibleMargins::new(),
|
||||||
abs_position: Zero::zero(),
|
abs_position: Zero::zero(),
|
||||||
|
|
|
@ -250,7 +250,8 @@ impl LayoutTask {
|
||||||
font_cache_task: FontCacheTask,
|
font_cache_task: FontCacheTask,
|
||||||
time_profiler_chan: TimeProfilerChan)
|
time_profiler_chan: TimeProfilerChan)
|
||||||
-> LayoutTask {
|
-> LayoutTask {
|
||||||
let local_image_cache = Arc::new(Mutex::new(LocalImageCache::new(image_cache_task.clone())));
|
let local_image_cache =
|
||||||
|
Arc::new(Mutex::new(LocalImageCache::new(image_cache_task.clone())));
|
||||||
let screen_size = Size2D(Au(0), Au(0));
|
let screen_size = Size2D(Au(0), Au(0));
|
||||||
let device = Device::new(Screen, opts::get().initial_window_size.as_f32());
|
let device = Device::new(Screen, opts::get().initial_window_size.as_f32());
|
||||||
let parallel_traversal = if opts::get().layout_threads != 1 {
|
let parallel_traversal = if opts::get().layout_threads != 1 {
|
||||||
|
@ -297,12 +298,11 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a layout context for use in building display lists, hit testing, &c.
|
// Create a layout context for use in building display lists, hit testing, &c.
|
||||||
fn build_shared_layout_context(
|
fn build_shared_layout_context(&self,
|
||||||
&self,
|
rw_data: &LayoutTaskData,
|
||||||
rw_data: &LayoutTaskData,
|
reflow_root: &LayoutNode,
|
||||||
reflow_root: &LayoutNode,
|
url: &Url)
|
||||||
url: &Url)
|
-> SharedLayoutContext {
|
||||||
-> SharedLayoutContext {
|
|
||||||
SharedLayoutContext {
|
SharedLayoutContext {
|
||||||
image_cache: rw_data.local_image_cache.clone(),
|
image_cache: rw_data.local_image_cache.clone(),
|
||||||
screen_size: rw_data.screen_size.clone(),
|
screen_size: rw_data.screen_size.clone(),
|
||||||
|
@ -318,7 +318,9 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receives and dispatches messages from the script and constellation tasks
|
/// Receives and dispatches messages from the script and constellation tasks
|
||||||
fn handle_request<'a>(&'a self, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) -> bool {
|
fn handle_request<'a>(&'a self,
|
||||||
|
possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>)
|
||||||
|
-> bool {
|
||||||
enum PortToRead {
|
enum PortToRead {
|
||||||
Pipeline,
|
Pipeline,
|
||||||
Script,
|
Script,
|
||||||
|
@ -343,8 +345,12 @@ impl LayoutTask {
|
||||||
};
|
};
|
||||||
|
|
||||||
match port_to_read {
|
match port_to_read {
|
||||||
Pipeline => match self.pipeline_port.recv() {
|
Pipeline => {
|
||||||
layout_traits::ExitNowMsg => self.handle_script_request(ExitNowMsg, possibly_locked_rw_data),
|
match self.pipeline_port.recv() {
|
||||||
|
layout_traits::ExitNowMsg => {
|
||||||
|
self.handle_script_request(ExitNowMsg, possibly_locked_rw_data)
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
Script => {
|
Script => {
|
||||||
let msg = self.port.recv();
|
let msg = self.port.recv();
|
||||||
|
@ -359,17 +365,20 @@ impl LayoutTask {
|
||||||
/// If you do not wish RPCs to remain blocked, just drop the `RWGuard`
|
/// If you do not wish RPCs to remain blocked, just drop the `RWGuard`
|
||||||
/// returned from this function. If you _do_ wish for them to remain blocked,
|
/// returned from this function. If you _do_ wish for them to remain blocked,
|
||||||
/// use `return_rw_data`.
|
/// use `return_rw_data`.
|
||||||
fn lock_rw_data<'a>(&'a self, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) -> RWGuard<'a> {
|
fn lock_rw_data<'a>(&'a self,
|
||||||
|
possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>)
|
||||||
|
-> RWGuard<'a> {
|
||||||
match possibly_locked_rw_data.take() {
|
match possibly_locked_rw_data.take() {
|
||||||
None => Used(self.rw_data.lock()),
|
None => Used(self.rw_data.lock()),
|
||||||
Some(x) => Held(x),
|
Some(x) => Held(x),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If no reflow has ever been trigger, this will keep the lock, locked
|
/// If no reflow has ever been triggered, this will keep the lock, locked
|
||||||
/// (and saved in `possibly_locked_rw_data`). If it has been, the lock will
|
/// (and saved in `possibly_locked_rw_data`). If it has been, the lock will
|
||||||
/// be unlocked.
|
/// be unlocked.
|
||||||
fn return_rw_data<'a>(possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>, rw_data: RWGuard<'a>) {
|
fn return_rw_data<'a>(possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>,
|
||||||
|
rw_data: RWGuard<'a>) {
|
||||||
match rw_data {
|
match rw_data {
|
||||||
Used(x) => drop(x),
|
Used(x) => drop(x),
|
||||||
Held(x) => *possibly_locked_rw_data = Some(x),
|
Held(x) => *possibly_locked_rw_data = Some(x),
|
||||||
|
@ -377,20 +386,23 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Receives and dispatches messages from the script task.
|
/// Receives and dispatches messages from the script task.
|
||||||
fn handle_script_request<'a>(&'a self, request: Msg, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) -> bool {
|
fn handle_script_request<'a>(&'a self,
|
||||||
|
request: Msg,
|
||||||
|
possibly_locked_rw_data: &mut Option<MutexGuard<'a,
|
||||||
|
LayoutTaskData>>)
|
||||||
|
-> bool {
|
||||||
match request {
|
match request {
|
||||||
AddStylesheetMsg(sheet) => self.handle_add_stylesheet(sheet, possibly_locked_rw_data),
|
AddStylesheetMsg(sheet) => self.handle_add_stylesheet(sheet, possibly_locked_rw_data),
|
||||||
LoadStylesheetMsg(url) => self.handle_load_stylesheet(url, possibly_locked_rw_data),
|
LoadStylesheetMsg(url) => self.handle_load_stylesheet(url, possibly_locked_rw_data),
|
||||||
GetRPCMsg(response_chan) => {
|
GetRPCMsg(response_chan) => {
|
||||||
response_chan.send(
|
response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as
|
||||||
box LayoutRPCImpl(
|
Box<LayoutRPC + Send>);
|
||||||
self.rw_data.clone()) as Box<LayoutRPC + Send>);
|
|
||||||
},
|
},
|
||||||
ReflowMsg(data) => {
|
ReflowMsg(data) => {
|
||||||
profile(time::LayoutPerformCategory, Some((&data.url, data.iframe, self.first_reflow.get())),
|
profile(time::LayoutPerformCategory,
|
||||||
self.time_profiler_chan.clone(), || {
|
Some((&data.url, data.iframe, self.first_reflow.get())),
|
||||||
self.handle_reflow(&*data, possibly_locked_rw_data);
|
self.time_profiler_chan.clone(),
|
||||||
});
|
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|
||||||
},
|
},
|
||||||
ReapLayoutDataMsg(dead_layout_data) => {
|
ReapLayoutDataMsg(dead_layout_data) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -415,7 +427,9 @@ impl LayoutTask {
|
||||||
/// Enters a quiescent state in which no new messages except for `ReapLayoutDataMsg` will be
|
/// Enters a quiescent state in which no new messages except for `ReapLayoutDataMsg` will be
|
||||||
/// processed until an `ExitNowMsg` is received. A pong is immediately sent on the given
|
/// processed until an `ExitNowMsg` is received. A pong is immediately sent on the given
|
||||||
/// response channel.
|
/// response channel.
|
||||||
fn prepare_to_exit<'a>(&'a self, response_chan: Sender<()>, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
fn prepare_to_exit<'a>(&'a self,
|
||||||
|
response_chan: Sender<()>,
|
||||||
|
possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
||||||
response_chan.send(());
|
response_chan.send(());
|
||||||
loop {
|
loop {
|
||||||
match self.port.recv() {
|
match self.port.recv() {
|
||||||
|
@ -455,7 +469,10 @@ impl LayoutTask {
|
||||||
response_port.recv()
|
response_port.recv()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_load_stylesheet<'a>(&'a self, url: Url, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
fn handle_load_stylesheet<'a>(&'a self,
|
||||||
|
url: Url,
|
||||||
|
possibly_locked_rw_data:
|
||||||
|
&mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
||||||
// TODO: Get the actual value. http://dev.w3.org/csswg/css-syntax/#environment-encoding
|
// TODO: Get the actual value. http://dev.w3.org/csswg/css-syntax/#environment-encoding
|
||||||
let environment_encoding = UTF_8 as EncodingRef;
|
let environment_encoding = UTF_8 as EncodingRef;
|
||||||
|
|
||||||
|
@ -463,11 +480,17 @@ impl LayoutTask {
|
||||||
let protocol_encoding_label = metadata.charset.as_ref().map(|s| s.as_slice());
|
let protocol_encoding_label = metadata.charset.as_ref().map(|s| s.as_slice());
|
||||||
let final_url = metadata.final_url;
|
let final_url = metadata.final_url;
|
||||||
|
|
||||||
let sheet = Stylesheet::from_bytes_iter(iter, final_url, protocol_encoding_label, Some(environment_encoding));
|
let sheet = Stylesheet::from_bytes_iter(iter,
|
||||||
|
final_url,
|
||||||
|
protocol_encoding_label,
|
||||||
|
Some(environment_encoding));
|
||||||
self.handle_add_stylesheet(sheet, possibly_locked_rw_data);
|
self.handle_add_stylesheet(sheet, possibly_locked_rw_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_add_stylesheet<'a>(&'a self, sheet: Stylesheet, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
fn handle_add_stylesheet<'a>(&'a self,
|
||||||
|
sheet: Stylesheet,
|
||||||
|
possibly_locked_rw_data:
|
||||||
|
&mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
||||||
// Find all font-face rules and notify the font cache of them.
|
// Find all font-face rules and notify the font cache of them.
|
||||||
// GWTODO: Need to handle unloading web fonts (when we handle unloading stylesheets!)
|
// GWTODO: Need to handle unloading web fonts (when we handle unloading stylesheets!)
|
||||||
iter_font_face_rules(&sheet, &self.device, |family, src| {
|
iter_font_face_rules(&sheet, &self.device, |family, src| {
|
||||||
|
@ -566,11 +589,15 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The high-level routine that performs layout tasks.
|
/// The high-level routine that performs layout tasks.
|
||||||
fn handle_reflow<'a>(&'a self, data: &Reflow, possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
fn handle_reflow<'a>(&'a self,
|
||||||
|
data: &Reflow,
|
||||||
|
possibly_locked_rw_data: &mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
||||||
// FIXME: Isolate this transmutation into a "bridge" module.
|
// FIXME: Isolate this transmutation into a "bridge" module.
|
||||||
// FIXME(rust#16366): The following line had to be moved because of a
|
// FIXME(rust#16366): The following line had to be moved because of a
|
||||||
// rustc bug. It should be in the next unsafe block.
|
// rustc bug. It should be in the next unsafe block.
|
||||||
let mut node: JS<Node> = unsafe { JS::from_trusted_node_address(data.document_root) };
|
let mut node: JS<Node> = unsafe {
|
||||||
|
JS::from_trusted_node_address(data.document_root)
|
||||||
|
};
|
||||||
let node: &mut LayoutNode = unsafe {
|
let node: &mut LayoutNode = unsafe {
|
||||||
mem::transmute(&mut node)
|
mem::transmute(&mut node)
|
||||||
};
|
};
|
||||||
|
@ -599,11 +626,9 @@ impl LayoutTask {
|
||||||
rw_data.screen_size = current_screen_size;
|
rw_data.screen_size = current_screen_size;
|
||||||
|
|
||||||
// Create a layout context for use throughout the following passes.
|
// Create a layout context for use throughout the following passes.
|
||||||
let mut shared_layout_ctx =
|
let mut shared_layout_ctx = self.build_shared_layout_context(rw_data.deref(),
|
||||||
self.build_shared_layout_context(
|
node,
|
||||||
rw_data.deref(),
|
&data.url);
|
||||||
node,
|
|
||||||
&data.url);
|
|
||||||
|
|
||||||
// Handle conditions where the entire flow tree is invalid.
|
// Handle conditions where the entire flow tree is invalid.
|
||||||
let needs_dirtying = rw_data.stylesheet_dirty;
|
let needs_dirtying = rw_data.stylesheet_dirty;
|
||||||
|
@ -664,8 +689,10 @@ impl LayoutTask {
|
||||||
|
|
||||||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||||
// the boxes.
|
// the boxes.
|
||||||
profile(time::LayoutMainCategory, Some((&data.url, data.iframe, self.first_reflow.get())),
|
profile(time::LayoutMainCategory,
|
||||||
self.time_profiler_chan.clone(), || {
|
Some((&data.url, data.iframe, self.first_reflow.get())),
|
||||||
|
self.time_profiler_chan.clone(),
|
||||||
|
|| {
|
||||||
let rw_data = rw_data.deref_mut();
|
let rw_data = rw_data.deref_mut();
|
||||||
match rw_data.parallel_traversal {
|
match rw_data.parallel_traversal {
|
||||||
None => {
|
None => {
|
||||||
|
@ -674,7 +701,10 @@ impl LayoutTask {
|
||||||
}
|
}
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
// Parallel mode.
|
// Parallel mode.
|
||||||
self.solve_constraints_parallel(data, rw_data, &mut layout_root, &mut shared_layout_ctx)
|
self.solve_constraints_parallel(data,
|
||||||
|
rw_data,
|
||||||
|
&mut layout_root,
|
||||||
|
&mut shared_layout_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -682,28 +712,31 @@ impl LayoutTask {
|
||||||
// Build the display list if necessary, and send it to the renderer.
|
// Build the display list if necessary, and send it to the renderer.
|
||||||
if data.goal == ReflowForDisplay {
|
if data.goal == ReflowForDisplay {
|
||||||
let writing_mode = flow::base(layout_root.deref()).writing_mode;
|
let writing_mode = flow::base(layout_root.deref()).writing_mode;
|
||||||
profile(time::LayoutDispListBuildCategory, Some((&data.url, data.iframe, self.first_reflow.get())), self.time_profiler_chan.clone(), || {
|
profile(time::LayoutDispListBuildCategory,
|
||||||
shared_layout_ctx.dirty = flow::base(layout_root.deref()).position.to_physical(
|
Some((&data.url, data.iframe, self.first_reflow.get())),
|
||||||
writing_mode, rw_data.screen_size);
|
self.time_profiler_chan.clone(),
|
||||||
|
|| {
|
||||||
|
shared_layout_ctx.dirty =
|
||||||
|
flow::base(layout_root.deref()).position.to_physical(writing_mode,
|
||||||
|
rw_data.screen_size);
|
||||||
flow::mut_base(layout_root.deref_mut()).abs_position =
|
flow::mut_base(layout_root.deref_mut()).abs_position =
|
||||||
LogicalPoint::zero(writing_mode).to_physical(writing_mode, rw_data.screen_size);
|
LogicalPoint::zero(writing_mode).to_physical(writing_mode,
|
||||||
|
rw_data.screen_size);
|
||||||
|
|
||||||
let rw_data = rw_data.deref_mut();
|
let rw_data = rw_data.deref_mut();
|
||||||
match rw_data.parallel_traversal {
|
match rw_data.parallel_traversal {
|
||||||
None => {
|
None => {
|
||||||
sequential::build_display_list_for_subtree(
|
sequential::build_display_list_for_subtree(&mut layout_root,
|
||||||
&mut layout_root,
|
&shared_layout_ctx);
|
||||||
&shared_layout_ctx);
|
|
||||||
}
|
}
|
||||||
Some(ref mut traversal) => {
|
Some(ref mut traversal) => {
|
||||||
parallel::build_display_list_for_subtree(
|
parallel::build_display_list_for_subtree(&mut layout_root,
|
||||||
&mut layout_root,
|
&data.url,
|
||||||
&data.url,
|
data.iframe,
|
||||||
data.iframe,
|
self.first_reflow.get(),
|
||||||
self.first_reflow.get(),
|
self.time_profiler_chan.clone(),
|
||||||
self.time_profiler_chan.clone(),
|
&shared_layout_ctx,
|
||||||
&shared_layout_ctx,
|
traversal);
|
||||||
traversal);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,9 @@ pub fn traverse_dom_preorder(root: LayoutNode,
|
||||||
|
|
||||||
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
shared_layout_context: &SharedLayoutContext) {
|
shared_layout_context: &SharedLayoutContext) {
|
||||||
fn doit(flow: &mut Flow, assign_inline_sizes: AssignISizes, assign_block_sizes: AssignBSizesAndStoreOverflow) {
|
fn doit(flow: &mut Flow,
|
||||||
|
assign_inline_sizes: AssignISizes,
|
||||||
|
assign_block_sizes: AssignBSizesAndStoreOverflow) {
|
||||||
if assign_inline_sizes.should_process(flow) {
|
if assign_inline_sizes.should_process(flow) {
|
||||||
assign_inline_sizes.process(flow);
|
assign_inline_sizes.process(flow);
|
||||||
}
|
}
|
||||||
|
@ -68,7 +70,9 @@ pub fn traverse_flow_tree_preorder(root: &mut FlowRef,
|
||||||
|
|
||||||
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
pub fn build_display_list_for_subtree(root: &mut FlowRef,
|
||||||
shared_layout_context: &SharedLayoutContext) {
|
shared_layout_context: &SharedLayoutContext) {
|
||||||
fn doit(flow: &mut Flow, compute_absolute_positions: ComputeAbsolutePositions, build_display_list: BuildDisplayList) {
|
fn doit(flow: &mut Flow,
|
||||||
|
compute_absolute_positions: ComputeAbsolutePositions,
|
||||||
|
build_display_list: BuildDisplayList) {
|
||||||
if compute_absolute_positions.should_process(flow) {
|
if compute_absolute_positions.should_process(flow) {
|
||||||
compute_absolute_positions.process(flow);
|
compute_absolute_positions.process(flow);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue