Fix up script and layout.

This commit is contained in:
Bobby Holley 2017-05-02 16:22:10 -07:00
parent d78ca4c4f9
commit 7b0679848b
49 changed files with 99 additions and 85 deletions

View file

@ -2134,7 +2134,7 @@ impl Flow for BlockFlow {
self.build_display_list_for_block(state, BorderPaintingMode::Separate);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.fragment.repair_style(new_style)
}

View file

@ -13,6 +13,7 @@
#![deny(unsafe_code)]
use StyleArc;
use app_units::Au;
use block::BlockFlow;
use context::{LayoutContext, with_thread_local_font_context};
@ -107,7 +108,7 @@ pub enum ConstructionItem {
/// Inline fragments and associated {ib} splits that have not yet found flows.
InlineFragments(InlineFragmentsConstructionResult),
/// Potentially ignorable whitespace.
Whitespace(OpaqueNode, PseudoElementType<()>, Arc<ServoComputedValues>, RestyleDamage),
Whitespace(OpaqueNode, PseudoElementType<()>, StyleArc<ServoComputedValues>, RestyleDamage),
/// TableColumn Fragment
TableColumnFragment(Fragment),
}
@ -675,7 +676,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
fn create_fragments_for_node_text_content(&self,
fragments: &mut IntermediateInlineFragments,
node: &ConcreteThreadSafeLayoutNode,
style: &Arc<ServoComputedValues>) {
style: &StyleArc<ServoComputedValues>) {
// Fast path: If there is no text content, return immediately.
let text_content = node.text_content();
if text_content.is_empty() {
@ -1804,7 +1805,7 @@ pub fn strip_ignorable_whitespace_from_end(this: &mut LinkedList<Fragment>) {
/// If the 'unicode-bidi' property has a value other than 'normal', return the bidi control codes
/// to inject before and after the text content of the element.
fn bidi_control_chars(style: &Arc<ServoComputedValues>) -> Option<(&'static str, &'static str)> {
fn bidi_control_chars(style: &StyleArc<ServoComputedValues>) -> Option<(&'static str, &'static str)> {
use style::computed_values::direction::T::*;
use style::computed_values::unicode_bidi::T::*;

View file

@ -577,7 +577,7 @@ fn build_border_radius(abs_bounds: &Rect<Au>,
/// Get the border radius for the rectangle inside of a rounded border. This is useful
/// for building the clip for the content inside the border.
fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>,
style: Arc<ServoComputedValues>)
style: ::StyleArc<ServoComputedValues>)
-> BorderRadii<Au> {
let mut radii = build_border_radius(&outer_rect, style.get_border());
if radii.is_square() {

View file

@ -21,7 +21,6 @@ use model::{IntrinsicISizes, MaybeAuto, SizeConstraint};
use model::{specified, specified_or_none};
use std::cmp::{max, min};
use std::ops::Range;
use std::sync::Arc;
use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content};
use style::computed_values::border_collapse;
use style::logical_geometry::{Direction, LogicalSize};
@ -970,7 +969,7 @@ impl Flow for FlexFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -424,7 +424,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {
/// Attempts to perform incremental fixup of this flow by replacing its fragment's style with
/// the new style. This can only succeed if the flow has exactly one fragment.
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>);
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>);
/// Print any extra children (such as fragments) contained in this Flow
/// for debugging purposes. Any items inserted into the tree will become
@ -561,7 +561,7 @@ pub trait MutableFlowUtils {
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
/// calling them individually, since there is no reason not to perform both operations.
fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>);
fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>);
}
pub trait MutableOwnedFlowUtils {
@ -1361,7 +1361,7 @@ impl<'a> MutableFlowUtils for &'a mut Flow {
/// Calls `repair_style` and `bubble_inline_sizes`. You should use this method instead of
/// calling them individually, since there is no reason not to perform both operations.
fn repair_style_and_bubble_inline_sizes(self, style: &Arc<ServoComputedValues>) {
fn repair_style_and_bubble_inline_sizes(self, style: &::StyleArc<ServoComputedValues>) {
self.repair_style(style);
self.bubble_inline_sizes();
}

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)]
use StyleArc;
use app_units::Au;
use canvas_traits::CanvasMsg;
use context::{LayoutContext, with_thread_local_font_context};
@ -39,7 +40,6 @@ use std::borrow::ToOwned;
use std::cmp::{Ordering, max, min};
use std::collections::LinkedList;
use std::sync::{Arc, Mutex};
use style::arc_ptr_eq;
use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode};
use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration_line, transform};
use style::computed_values::{transform_style, vertical_align, white_space, word_break};
@ -95,10 +95,10 @@ pub struct Fragment {
pub node: OpaqueNode,
/// The CSS style of this fragment.
pub style: Arc<ServoComputedValues>,
pub style: StyleArc<ServoComputedValues>,
/// The CSS style of this fragment when it's selected
pub selected_style: Arc<ServoComputedValues>,
pub selected_style: StyleArc<ServoComputedValues>,
/// The position of this fragment relative to its owning flow. The size includes padding and
/// border, but not margin.
@ -672,8 +672,8 @@ impl Fragment {
/// Constructs a new `Fragment` instance from an opaque node.
pub fn from_opaque_node_and_style(node: OpaqueNode,
pseudo: PseudoElementType<()>,
style: Arc<ServoComputedValues>,
selected_style: Arc<ServoComputedValues>,
style: StyleArc<ServoComputedValues>,
selected_style: StyleArc<ServoComputedValues>,
mut restyle_damage: RestyleDamage,
specific: SpecificFragmentInfo)
-> Fragment {
@ -702,7 +702,7 @@ impl Fragment {
/// type. For the new anonymous fragment, layout-related values (border box, etc.) are reset to
/// initial values.
pub fn create_similar_anonymous_fragment(&self,
style: Arc<ServoComputedValues>,
style: StyleArc<ServoComputedValues>,
specific: SpecificFragmentInfo)
-> Fragment {
let writing_mode = style.writing_mode;
@ -1846,7 +1846,7 @@ impl Fragment {
match (&mut self.specific, &next_fragment.specific) {
(&mut SpecificFragmentInfo::ScannedText(ref mut this_info),
&SpecificFragmentInfo::ScannedText(ref other_info)) => {
debug_assert!(arc_ptr_eq(&this_info.run, &other_info.run));
debug_assert!(::arc_ptr_eq(&this_info.run, &other_info.run));
this_info.range_end_including_stripped_whitespace =
other_info.range_end_including_stripped_whitespace;
if other_info.requires_line_break_afterward_if_wrapping_on_newlines() {
@ -2398,7 +2398,7 @@ impl Fragment {
}
}
pub fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
pub fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
self.style = (*new_style).clone()
}

View file

@ -16,7 +16,6 @@ use gfx::display_list::OpaqueNode;
use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList};
use std::sync::Arc;
use style::computed_values::{display, list_style_type};
use style::computed_values::content::ContentItem;
use style::properties::ServoComputedValues;
@ -369,7 +368,7 @@ impl Counter {
layout_context: &LayoutContext,
node: OpaqueNode,
pseudo: PseudoElementType<()>,
style: Arc<ServoComputedValues>,
style: ::StyleArc<ServoComputedValues>,
list_style_type: list_style_type::T,
mode: RenderingMode)
-> Option<SpecificFragmentInfo> {
@ -432,7 +431,7 @@ struct CounterValue {
fn render_text(layout_context: &LayoutContext,
node: OpaqueNode,
pseudo: PseudoElementType<()>,
style: Arc<ServoComputedValues>,
style: ::StyleArc<ServoComputedValues>,
string: String)
-> Option<SpecificFragmentInfo> {
let mut fragments = LinkedList::new();

View file

@ -4,6 +4,7 @@
#![deny(unsafe_code)]
use StyleArc;
use app_units::Au;
use block::AbsoluteAssignBSizesTraversal;
use context::LayoutContext;
@ -29,7 +30,6 @@ use std::{fmt, i32, isize, mem};
use std::cmp::max;
use std::collections::VecDeque;
use std::sync::Arc;
use style::arc_ptr_eq;
use style::computed_values::{display, overflow_x, position, text_align, text_justify};
use style::computed_values::{vertical_align, white_space};
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
@ -398,7 +398,7 @@ impl LineBreaker {
result.border_padding.inline_end == Au(0) &&
candidate.border_padding.inline_start == Au(0) &&
result_info.selected() == candidate_info.selected() &&
arc_ptr_eq(&result_info.run, &candidate_info.run) &&
::arc_ptr_eq(&result_info.run, &candidate_info.run) &&
inline_contexts_are_equal(&result.inline_context,
&candidate.inline_context)
}
@ -1657,7 +1657,7 @@ impl Flow for InlineFlow {
self.build_display_list_for_inline(state);
}
fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {}
fn repair_style(&mut self, _: &StyleArc<ServoComputedValues>) {}
fn compute_overflow(&self) -> Overflow {
let mut overflow = Overflow::new();
@ -1746,8 +1746,8 @@ impl fmt::Debug for InlineFlow {
#[derive(Clone)]
pub struct InlineFragmentNodeInfo {
pub address: OpaqueNode,
pub style: Arc<ServoComputedValues>,
pub selected_style: Arc<ServoComputedValues>,
pub style: StyleArc<ServoComputedValues>,
pub selected_style: StyleArc<ServoComputedValues>,
pub pseudo: PseudoElementType<()>,
pub flags: InlineFragmentNodeFlags,
}

View file

@ -93,3 +93,15 @@ pub mod wrapper;
// For unit tests:
pub use fragment::Fragment;
pub use fragment::SpecificFragmentInfo;
/// Returns whether the two arguments point to the same value.
///
/// FIXME: Remove this and use Arc::ptr_eq once we require Rust 1.17
#[inline]
pub fn arc_ptr_eq<T: 'static>(a: &::std::sync::Arc<T>, b: &::std::sync::Arc<T>) -> bool {
::style::ptr_eq::<T>(&**a, &**b)
}
// We can't use stylearc for everything in layout, because the Flow stuff uses
// weak references.
use style::stylearc::Arc as StyleArc;

View file

@ -18,7 +18,6 @@ use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedC
use fragment::Overflow;
use generated_content;
use inline::InlineFlow;
use std::sync::Arc;
use style::computed_values::{list_style_type, position};
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
@ -148,7 +147,7 @@ impl Flow for ListItemFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -6,6 +6,7 @@
#![deny(unsafe_code)]
use StyleArc;
use app_units::Au;
use block::BlockFlow;
use context::LayoutContext;
@ -193,7 +194,7 @@ impl Flow for MulticolFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}
@ -275,7 +276,7 @@ impl Flow for MulticolColumnFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -55,7 +55,7 @@ pub struct LayoutThreadData {
pub display_list: Option<Arc<DisplayList>>,
/// Performs CSS selector matching and style resolution.
pub stylist: Arc<Stylist>,
pub stylist: ::StyleArc<Stylist>,
/// A queued response for the union of the content boxes of a node.
pub content_box_response: Option<Rect<Au>>,

View file

@ -21,7 +21,6 @@ use layout_debug;
use model::{IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto};
use std::cmp;
use std::fmt;
use std::sync::Arc;
use style::computed_values::{border_collapse, border_spacing, table_layout};
use style::context::SharedStyleContext;
use style::logical_geometry::LogicalSize;
@ -507,7 +506,7 @@ impl Flow for TableFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -15,7 +15,6 @@ use flow::{Flow, FlowClass, OpaqueFlow};
use fragment::{Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::print_tree::PrintTree;
use std::fmt;
use std::sync::Arc;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
@ -84,7 +83,7 @@ impl Flow for TableCaptionFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -19,7 +19,6 @@ use layout_debug;
use model::MaybeAuto;
use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
use std::fmt;
use std::sync::Arc;
use style::computed_values::{border_collapse, border_top_style, vertical_align};
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues;
@ -264,7 +263,7 @@ impl Flow for TableCellFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -15,7 +15,6 @@ use fragment::{Fragment, FragmentBorderBoxIterator, Overflow, SpecificFragmentIn
use layout_debug;
use std::cmp::max;
use std::fmt;
use std::sync::Arc;
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
use style::values::computed::LengthOrPercentageOrAuto;
@ -95,7 +94,7 @@ impl Flow for TableColGroupFlow {
fn collect_stacking_contexts(&mut self, _: &mut DisplayListBuildState) {}
fn repair_style(&mut self, _: &Arc<ServoComputedValues>) {}
fn repair_style(&mut self, _: &::StyleArc<ServoComputedValues>) {}
fn compute_overflow(&self) -> Overflow {
Overflow::new()

View file

@ -22,7 +22,6 @@ use serde::{Serialize, Serializer};
use std::cmp::max;
use std::fmt;
use std::iter::{Enumerate, IntoIterator, Peekable};
use std::sync::Arc;
use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
use style::properties::ServoComputedValues;
@ -483,7 +482,7 @@ impl Flow for TableRowFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -18,7 +18,6 @@ use layout_debug;
use serde::{Serialize, Serializer};
use std::fmt;
use std::iter::{IntoIterator, Iterator, Peekable};
use std::sync::Arc;
use style::computed_values::{border_collapse, border_spacing};
use style::logical_geometry::LogicalSize;
use style::properties::ServoComputedValues;
@ -186,7 +185,7 @@ impl Flow for TableRowGroupFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -27,7 +27,6 @@ use model::MaybeAuto;
use std::cmp::{max, min};
use std::fmt;
use std::ops::Add;
use std::sync::Arc;
use style::computed_values::{border_collapse, position, table_layout};
use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize};
@ -467,7 +466,7 @@ impl Flow for TableWrapperFlow {
self.block_flow.collect_stacking_contexts(state);
}
fn repair_style(&mut self, new_style: &Arc<ServoComputedValues>) {
fn repair_style(&mut self, new_style: &::StyleArc<ServoComputedValues>) {
self.block_flow.repair_style(new_style)
}

View file

@ -435,7 +435,7 @@ fn bounding_box_for_run_metrics(metrics: &RunMetrics, writing_mode: WritingMode)
///
/// `#[inline]` because often the caller only needs a few fields from the font metrics.
#[inline]
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: Arc<style_structs::Font>)
pub fn font_metrics_for_style(font_context: &mut FontContext, font_style: ::StyleArc<style_structs::Font>)
-> FontMetrics {
let fontgroup = font_context.layout_font_group_for_style(font_style);
// FIXME(https://github.com/rust-lang/rust/issues/23338)