Skip to content

Commit

Permalink
merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan.prinja committed Nov 3, 2015
2 parents 7032a5d + 4f51710 commit 6e774ea
Show file tree
Hide file tree
Showing 1,044 changed files with 46,047 additions and 1,494 deletions.
22 changes: 15 additions & 7 deletions components/compositing/constellation.rs
Expand Up @@ -1203,6 +1203,21 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
for frame in self.current_frame_tree_iter(self.root_frame_id) {
let pipeline = self.pipeline(frame.current);

// Check to see if there are any webfonts still loading.
//
// If GetWebFontLoadState returns false, either there are no
// webfonts loading, or there's a WebFontLoaded message waiting in
// script_chan's message queue. Therefore, we need to check this
// before we check whether the document is ready; otherwise,
// there's a race condition where a webfont has finished loading,
// but hasn't yet notified the document.
let (sender, receiver) = ipc::channel().unwrap();
let msg = LayoutControlMsg::GetWebFontLoadState(sender);
pipeline.layout_chan.0.send(msg).unwrap();
if receiver.recv().unwrap() {
return false;
}

// Synchronously query the script task for this pipeline
// to see if it is idle.
let (sender, receiver) = channel();
Expand All @@ -1213,13 +1228,6 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
return false;
}

let (sender, receiver) = ipc::channel().unwrap();
let msg = LayoutControlMsg::GetWebFontLoadState(sender);
pipeline.layout_chan.0.send(msg).unwrap();
if receiver.recv().unwrap() {
return false;
}

// Check the visible rectangle for this pipeline. If the constellation has received a
// size for the pipeline, then its painting should be up to date. If the constellation
// *hasn't* received a size, it could be that the layer was hidden by script before the
Expand Down
19 changes: 9 additions & 10 deletions components/layout/block.rs
Expand Up @@ -340,6 +340,10 @@ impl CandidateBSizeIterator {
(LengthOrPercentageOrNone::Percentage(percent), Some(block_container_block_size)) => {
Some(block_container_block_size.scale_by(percent))
}
(LengthOrPercentageOrNone::Calc(calc), Some(block_container_block_size)) => {
Some(block_container_block_size.scale_by(calc.percentage()) + calc.length())
}
(LengthOrPercentageOrNone::Calc(_), _) |
(LengthOrPercentageOrNone::Percentage(_), None) |
(LengthOrPercentageOrNone::None, _) => None,
(LengthOrPercentageOrNone::Length(length), _) => Some(length),
Expand Down Expand Up @@ -1024,17 +1028,12 @@ impl BlockFlow {
let mut candidate_block_size_iterator = CandidateBSizeIterator::new(
&self.fragment,
self.base.block_container_explicit_block_size);
loop {
match candidate_block_size_iterator.next() {
Some(candidate_block_size) => {
candidate_block_size_iterator.candidate_value =
match candidate_block_size {
MaybeAuto::Auto => block_size,
MaybeAuto::Specified(value) => value
}
while let Some(candidate_block_size) = candidate_block_size_iterator.next() {
candidate_block_size_iterator.candidate_value =
match candidate_block_size {
MaybeAuto::Auto => block_size,
MaybeAuto::Specified(value) => value
}
None => break,
}
}

// Adjust `cur_b` as necessary to account for the explicitly-specified block-size.
Expand Down
7 changes: 4 additions & 3 deletions components/layout/inline.rs
Expand Up @@ -27,6 +27,7 @@ use std::{fmt, isize, mem};
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
use style::computed_values::{text_overflow, vertical_align, white_space};
use style::properties::ComputedValues;
use style::values::computed::LengthOrPercentage;
use text;
use unicode_bidi;
use util;
Expand Down Expand Up @@ -953,15 +954,15 @@ impl InlineFlow {
offset_from_baseline = offset_from_baseline - *depth_below_baseline
}
},
vertical_align::T::Length(length) => {
vertical_align::T::LengthOrPercentage(LengthOrPercentage::Length(length)) => {
offset_from_baseline = offset_from_baseline - length
}
vertical_align::T::Percentage(p) => {
vertical_align::T::LengthOrPercentage(LengthOrPercentage::Percentage(p)) => {
let line_height = fragment.calculate_line_height(layout_context);
let percent_offset = line_height.scale_by(p);
offset_from_baseline = offset_from_baseline - percent_offset
}
vertical_align::T::Calc(calc) => {
vertical_align::T::LengthOrPercentage(LengthOrPercentage::Calc(calc)) => {
let line_height = fragment.calculate_line_height(layout_context);
let percent_offset = line_height.scale_by(calc.percentage());
offset_from_baseline = offset_from_baseline - percent_offset - calc.length()
Expand Down
47 changes: 16 additions & 31 deletions components/layout/layout_task.rs
Expand Up @@ -51,9 +51,7 @@ use profile_traits::time::{self, ProfilerMetadata, profile};
use query::{LayoutRPCImpl, process_content_box_request, process_content_boxes_request};
use query::{MarginPadding, MarginRetrievingFragmentBorderBoxIterator, PositionProperty};
use query::{PositionRetrievingFragmentBorderBoxIterator, Side};
use script::dom::bindings::js::LayoutJS;
use script::dom::document::Document;
use script::dom::node::{LayoutData, Node};
use script::dom::node::LayoutData;
use script::layout_interface::Animation;
use script::layout_interface::{LayoutChan, LayoutRPC, OffsetParentResponse};
use script::layout_interface::{Msg, NewLayoutTaskInfo, Reflow, ReflowGoal, ReflowQueryType};
Expand Down Expand Up @@ -90,7 +88,7 @@ use util::opts;
use util::task::spawn_named_with_send_on_failure;
use util::task_state;
use util::workqueue::WorkQueue;
use wrapper::{LayoutDocument, LayoutNode, ThreadSafeLayoutNode};
use wrapper::{LayoutNode, ThreadSafeLayoutNode};

/// The number of screens of data we're allowed to generate display lists for in each direction.
pub const DISPLAY_PORT_SIZE_FACTOR: i32 = 8;
Expand Down Expand Up @@ -595,7 +593,7 @@ impl LayoutTask {
profile(time::ProfilerCategory::LayoutPerform,
self.profiler_metadata(),
self.time_profiler_chan.clone(),
|| self.handle_reflow(&*data, possibly_locked_rw_data));
|| self.handle_reflow(&data, possibly_locked_rw_data));
},
Msg::TickAnimations => self.tick_all_animations(possibly_locked_rw_data),
Msg::ReflowWithNewlyLoadedWebFont => {
Expand Down Expand Up @@ -892,17 +890,9 @@ impl LayoutTask {
property: &Atom,
layout_root: &mut FlowRef)
-> Option<String> {
// FIXME: Isolate this transmutation into a "bridge" module.
// FIXME(rust#16366): The following line had to be moved because of a
// rustc bug. It should be in the next unsafe block.
let node: LayoutJS<Node> = unsafe {
LayoutJS::from_trusted_node_address(requested_node)
};
let node: &LayoutNode = unsafe {
transmute(&node)
};
let node = unsafe { LayoutNode::new(&requested_node) };

let layout_node = ThreadSafeLayoutNode::new(node);
let layout_node = ThreadSafeLayoutNode::new(&node);
let layout_node = match pseudo {
&Some(PseudoElement::Before) => layout_node.get_before_pseudo(),
&Some(PseudoElement::After) => layout_node.get_after_pseudo(),
Expand Down Expand Up @@ -1133,15 +1123,9 @@ impl LayoutTask {
};
let _ajst = AutoJoinScriptTask { data: data };

// FIXME: Isolate this transmutation into a "bridge" module.
let mut doc: LayoutJS<Document> = unsafe {
LayoutJS::from_trusted_node_address(data.document).downcast::<Document>().unwrap()
};
let doc: &mut LayoutDocument = unsafe {
transmute(&mut doc)
};

let mut node: LayoutNode = match doc.root_node() {
let document = unsafe { LayoutNode::new(&data.document) };
let document = document.as_document().unwrap();
let node: LayoutNode = match document.root_node() {
None => return,
Some(x) => x,
};
Expand Down Expand Up @@ -1187,7 +1171,7 @@ impl LayoutTask {
let needs_reflow = screen_size_changed && !needs_dirtying;
unsafe {
if needs_dirtying {
LayoutTask::dirty_all_nodes(&mut node);
LayoutTask::dirty_all_nodes(node);
}
}
if needs_reflow {
Expand All @@ -1196,11 +1180,12 @@ impl LayoutTask {
}
}

let event_state_changes = doc.drain_event_state_changes();
let state_changes = document.drain_element_state_changes();
if !needs_dirtying {
for &(el, state) in event_state_changes.iter() {
assert!(!state.is_empty());
el.note_event_state_change();
for &(el, state_change) in state_changes.iter() {
debug_assert!(!state_change.is_empty());
let hint = rw_data.stylist.restyle_hint_for_state_change(&el, el.get_state(), state_change);
el.note_restyle_hint(hint);
}
}

Expand Down Expand Up @@ -1229,7 +1214,7 @@ impl LayoutTask {
});

// Retrieve the (possibly rebuilt) root flow.
rw_data.root_flow = self.try_get_layout_root(node.clone());
rw_data.root_flow = self.try_get_layout_root(node);
}

// Send new canvas renderers to the paint task
Expand Down Expand Up @@ -1459,7 +1444,7 @@ impl LayoutTask {
}
}

unsafe fn dirty_all_nodes(node: &mut LayoutNode) {
unsafe fn dirty_all_nodes(node: LayoutNode) {
for node in node.traverse_preorder() {
// TODO(cgaebel): mark nodes which are sensitive to media queries as
// "changed":
Expand Down
2 changes: 1 addition & 1 deletion components/layout/lib.rs
Expand Up @@ -47,7 +47,7 @@ extern crate net_traits;
extern crate rustc_serialize;
extern crate script;
extern crate script_traits;
extern crate selectors;
#[macro_use(state_pseudo_classes)] extern crate selectors;
extern crate serde;
extern crate serde_json;
extern crate smallvec;
Expand Down
2 changes: 2 additions & 0 deletions components/layout/model.rs
Expand Up @@ -411,6 +411,8 @@ pub fn specified_or_none(length: LengthOrPercentageOrNone, containing_length: Au
match length {
LengthOrPercentageOrNone::None => None,
LengthOrPercentageOrNone::Percentage(percent) => Some(containing_length.scale_by(percent)),
LengthOrPercentageOrNone::Calc(calc) =>
Some(containing_length.scale_by(calc.percentage()) + calc.length()),
LengthOrPercentageOrNone::Length(length) => Some(length),
}
}
Expand Down

0 comments on commit 6e774ea

Please sign in to comment.