Fix match_refs and let_returns in layout, address review changes

This commit is contained in:
Manish Goregaokar 2015-09-04 10:51:24 +05:30
parent 5c24da3e2d
commit 8e2c37a542
12 changed files with 54 additions and 62 deletions

View file

@ -156,15 +156,14 @@ impl<'a> Iterator for CharacterSliceIterator<'a> {
impl<'a> TextRun {
pub fn new(font: &mut Font, text: String, options: &ShapingOptions, bidi_level: u8) -> TextRun {
let glyphs = TextRun::break_and_shape(font, &text, options);
let run = TextRun {
TextRun {
text: Arc::new(text),
font_metrics: font.metrics.clone(),
font_template: font.handle.template(),
actual_pt_size: font.actual_pt_size,
glyphs: Arc::new(glyphs),
bidi_level: bidi_level,
};
run
}
}
pub fn break_and_shape(font: &mut Font, text: &str, options: &ShapingOptions)

View file

@ -627,11 +627,11 @@ impl BlockFlow {
// Check if the transform matrix is 2D or 3D
if let Some(ref transform_list) = self.fragment.style().get_effects().transform.0 {
for transform in transform_list {
match transform {
&transform::ComputedOperation::Perspective(..) => {
match *transform {
transform::ComputedOperation::Perspective(..) => {
return true;
}
&transform::ComputedOperation::Matrix(m) => {
transform::ComputedOperation::Matrix(m) => {
// See http://dev.w3.org/csswg/css-transforms/#2d-matrix
if m.m31 != 0.0 || m.m32 != 0.0 ||
m.m13 != 0.0 || m.m23 != 0.0 ||

View file

@ -91,10 +91,10 @@ impl ConstructionResult {
}
pub fn debug_id(&self) -> usize {
match self {
&ConstructionResult::None => 0,
&ConstructionResult::ConstructionItem(_) => 0,
&ConstructionResult::Flow(ref flow_ref, _) => flow::base(&**flow_ref).debug_id(),
match *self {
ConstructionResult::None => 0,
ConstructionResult::ConstructionItem(_) => 0,
ConstructionResult::Flow(ref flow_ref, _) => flow::base(&**flow_ref).debug_id(),
}
}
}
@ -1315,9 +1315,9 @@ impl<'a> FlowConstructor<'a> {
let mut layout_data_ref = node.mutate_layout_data();
let layout_data = layout_data_ref.as_mut().expect("no layout data");
let damage = layout_data.data.restyle_damage;
match node.construction_result_mut(layout_data) {
&mut ConstructionResult::None => true,
&mut ConstructionResult::Flow(ref mut flow, _) => {
match *node.construction_result_mut(layout_data) {
ConstructionResult::None => true,
ConstructionResult::Flow(ref mut flow, _) => {
// The node's flow is of the same type and has the same set of children and can
// therefore be repaired by simply propagating damage and style to the flow.
if !flow.is_block_flow() {
@ -1328,7 +1328,7 @@ impl<'a> FlowConstructor<'a> {
flow.repair_style_and_bubble_inline_sizes(&style);
true
}
&mut ConstructionResult::ConstructionItem(ConstructionItem::InlineFragments(
ConstructionResult::ConstructionItem(ConstructionItem::InlineFragments(
ref mut inline_fragments_construction_result)) => {
if !inline_fragments_construction_result.splits.is_empty() {
return false
@ -1384,7 +1384,7 @@ impl<'a> FlowConstructor<'a> {
}
true
}
&mut ConstructionResult::ConstructionItem(_) => {
ConstructionResult::ConstructionItem(_) => {
false
}
}
@ -1558,8 +1558,7 @@ trait NodeUtils {
/// Returns true if this node doesn't render its kids and false otherwise.
fn is_replaced_content(&self) -> bool;
fn construction_result_mut<'a>(self, layout_data: &'a mut LayoutDataWrapper)
-> &'a mut ConstructionResult;
fn construction_result_mut(self, layout_data: &mut LayoutDataWrapper) -> &mut ConstructionResult;
/// Sets the construction result of a flow.
fn set_flow_construction_result(self, result: ConstructionResult);
@ -1589,7 +1588,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
}
}
fn construction_result_mut<'a>(self, layout_data: &'a mut LayoutDataWrapper) -> &'a mut ConstructionResult {
fn construction_result_mut(self, layout_data: &mut LayoutDataWrapper) -> &mut ConstructionResult {
match self.get_pseudo_element_type() {
PseudoElementType::Before(_) => &mut layout_data.data.before_flow_construction_result,
PseudoElementType::After (_) => &mut layout_data.data.after_flow_construction_result,

View file

@ -522,8 +522,8 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
let parent_layout_data: &Option<LayoutDataWrapper> = unsafe {
&*parent_node.borrow_layout_data_unchecked()
};
match parent_layout_data {
&Some(ref parent_layout_data_ref) => {
match *parent_layout_data {
Some(ref parent_layout_data_ref) => {
// Check parent style.
let parent_style = parent_layout_data_ref.shared_data.style.as_ref().unwrap();
if !arc_ptr_eq(parent_style, &candidate.parent_style) {
@ -678,9 +678,9 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
};
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&mut None => panic!("no layout data"),
&mut Some(ref mut layout_data) => {
match *layout_data_ref {
None => panic!("no layout data"),
Some(ref mut layout_data) => {
match self.type_id() {
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
// Text nodes get a copy of the parent style. This ensures

View file

@ -72,14 +72,14 @@ impl LayoutDataWrapper {
flow_ref.remove_compositor_layers(constellation_chan);
}
ConstructionResult::ConstructionItem(ref construction_item) => {
match construction_item {
&ConstructionItem::InlineFragments(ref inline_fragments) => {
match *construction_item {
ConstructionItem::InlineFragments(ref inline_fragments) => {
for fragment in &inline_fragments.fragments.fragments {
fragment.remove_compositor_layers(constellation_chan.clone());
}
}
&ConstructionItem::Whitespace(..) => {}
&ConstructionItem::TableColumnFragment(ref fragment) => {
ConstructionItem::Whitespace(..) => {}
ConstructionItem::TableColumnFragment(ref fragment) => {
fragment.remove_compositor_layers(constellation_chan.clone());
}
}

View file

@ -1202,27 +1202,27 @@ impl FragmentDisplayListBuilding for Fragment {
-transform_origin.z);
for operation in operations {
let matrix = match operation {
&transform::ComputedOperation::Rotate(ax, ay, az, theta) => {
let matrix = match *operation {
transform::ComputedOperation::Rotate(ax, ay, az, theta) => {
let theta = 2.0f32 * f32::consts::PI - theta.radians();
Matrix4::create_rotation(ax, ay, az, theta)
}
&transform::ComputedOperation::Perspective(d) => {
transform::ComputedOperation::Perspective(d) => {
Matrix4::create_perspective(d.to_f32_px())
}
&transform::ComputedOperation::Scale(sx, sy, sz) => {
transform::ComputedOperation::Scale(sx, sy, sz) => {
Matrix4::create_scale(sx, sy, sz)
}
&transform::ComputedOperation::Translate(tx, ty, tz) => {
transform::ComputedOperation::Translate(tx, ty, tz) => {
let tx = model::specified(tx, border_box.size.width).to_f32_px();
let ty = model::specified(ty, border_box.size.height).to_f32_px();
let tz = tz.to_f32_px();
Matrix4::create_translation(tx, ty, tz)
}
&transform::ComputedOperation::Matrix(m) => {
transform::ComputedOperation::Matrix(m) => {
m.to_gfx_matrix()
}
&transform::ComputedOperation::Skew(sx, sy) => {
transform::ComputedOperation::Skew(sx, sy) => {
Matrix4::create_skew(sx, sy)
}
};

View file

@ -87,12 +87,10 @@ impl FlexFlow {
flex_direction::T::column => Mode::Block
};
let this = FlexFlow {
FlexFlow {
block_flow: BlockFlow::from_fragment(fragment, flotation),
main_mode: main_mode
};
this
}
}
// TODO(zentner): This function should use flex-basis.

View file

@ -632,12 +632,10 @@ impl IframeFragmentInfo {
};
let containing_size = containing_size.unwrap_or(Au(0));
let size = clamp_size(computed_size,
clamp_size(computed_size,
style_min_size,
style_max_size,
containing_size);
size
containing_size)
}
}

View file

@ -63,13 +63,13 @@ struct State {
impl Scope {
pub fn new(name: String) -> Scope {
STATE_KEY.with(|ref r| {
match &mut *r.borrow_mut() {
&mut Some(ref mut state) => {
match *r.borrow_mut() {
Some(ref mut state) => {
let flow_trace = json::encode(&flow::base(&*state.flow_root)).unwrap();
let data = box ScopeData::new(name.clone(), flow_trace);
state.scope_stack.push(data);
}
&mut None => {}
None => {}
}
});
Scope
@ -80,14 +80,14 @@ impl Scope {
impl Drop for Scope {
fn drop(&mut self) {
STATE_KEY.with(|ref r| {
match &mut *r.borrow_mut() {
&mut Some(ref mut state) => {
match *r.borrow_mut() {
Some(ref mut state) => {
let mut current_scope = state.scope_stack.pop().unwrap();
current_scope.post = json::encode(&flow::base(&*state.flow_root)).unwrap();
let previous_scope = state.scope_stack.last_mut().unwrap();
previous_scope.children.push(current_scope);
}
&mut None => {}
None => {}
}
});
}

View file

@ -857,8 +857,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
/// Set the restyle damage field.
pub fn set_restyle_damage(self, damage: RestyleDamage) {
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&mut Some(ref mut layout_data) => layout_data.data.restyle_damage = damage,
match *layout_data_ref {
Some(ref mut layout_data) => layout_data.data.restyle_damage = damage,
_ => panic!("no layout data for this node"),
}
}
@ -876,8 +876,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
/// Adds the given flags to this node.
pub fn insert_flags(self, new_flags: LayoutDataFlags) {
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&mut Some(ref mut layout_data) => layout_data.data.flags.insert(new_flags),
match *layout_data_ref {
Some(ref mut layout_data) => layout_data.data.flags.insert(new_flags),
_ => panic!("no layout data for this node"),
}
}
@ -885,8 +885,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
/// Removes the given flags from this node.
pub fn remove_flags(self, flags: LayoutDataFlags) {
let mut layout_data_ref = self.mutate_layout_data();
match &mut *layout_data_ref {
&mut Some(ref mut layout_data) => layout_data.data.flags.remove(flags),
match *layout_data_ref {
Some(ref mut layout_data) => layout_data.data.flags.remove(flags),
_ => panic!("no layout data for this node"),
}
}

View file

@ -13,8 +13,7 @@ use dom::node::Node;
use dom::virtualmethods::vtable_for;
// See https://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
pub fn dispatch_event(target: &EventTarget,
pseudo_target: Option<&EventTarget>,
pub fn dispatch_event(target: &EventTarget, pseudo_target: Option<&EventTarget>,
event: &Event) -> bool {
assert!(!event.dispatching());
assert!(event.initialized());

View file

@ -356,8 +356,7 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&str>)
do_broadcast(doc_node, broadcaster, owner.r(), group)
}
fn in_same_group(other: &HTMLInputElement,
owner: Option<&HTMLFormElement>,
fn in_same_group(other: &HTMLInputElement, owner: Option<&HTMLFormElement>,
group: Option<&str>) -> bool {
let other_owner = other.form_owner();
let other_owner = other_owner.r();