mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Fix match_refs and let_returns in layout, address review changes
This commit is contained in:
parent
5c24da3e2d
commit
8e2c37a542
12 changed files with 54 additions and 62 deletions
|
@ -156,15 +156,14 @@ impl<'a> Iterator for CharacterSliceIterator<'a> {
|
||||||
impl<'a> TextRun {
|
impl<'a> TextRun {
|
||||||
pub fn new(font: &mut Font, text: String, options: &ShapingOptions, bidi_level: u8) -> 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 glyphs = TextRun::break_and_shape(font, &text, options);
|
||||||
let run = TextRun {
|
TextRun {
|
||||||
text: Arc::new(text),
|
text: Arc::new(text),
|
||||||
font_metrics: font.metrics.clone(),
|
font_metrics: font.metrics.clone(),
|
||||||
font_template: font.handle.template(),
|
font_template: font.handle.template(),
|
||||||
actual_pt_size: font.actual_pt_size,
|
actual_pt_size: font.actual_pt_size,
|
||||||
glyphs: Arc::new(glyphs),
|
glyphs: Arc::new(glyphs),
|
||||||
bidi_level: bidi_level,
|
bidi_level: bidi_level,
|
||||||
};
|
}
|
||||||
run
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn break_and_shape(font: &mut Font, text: &str, options: &ShapingOptions)
|
pub fn break_and_shape(font: &mut Font, text: &str, options: &ShapingOptions)
|
||||||
|
|
|
@ -627,11 +627,11 @@ impl BlockFlow {
|
||||||
// Check if the transform matrix is 2D or 3D
|
// Check if the transform matrix is 2D or 3D
|
||||||
if let Some(ref transform_list) = self.fragment.style().get_effects().transform.0 {
|
if let Some(ref transform_list) = self.fragment.style().get_effects().transform.0 {
|
||||||
for transform in transform_list {
|
for transform in transform_list {
|
||||||
match transform {
|
match *transform {
|
||||||
&transform::ComputedOperation::Perspective(..) => {
|
transform::ComputedOperation::Perspective(..) => {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
&transform::ComputedOperation::Matrix(m) => {
|
transform::ComputedOperation::Matrix(m) => {
|
||||||
// See http://dev.w3.org/csswg/css-transforms/#2d-matrix
|
// See http://dev.w3.org/csswg/css-transforms/#2d-matrix
|
||||||
if m.m31 != 0.0 || m.m32 != 0.0 ||
|
if m.m31 != 0.0 || m.m32 != 0.0 ||
|
||||||
m.m13 != 0.0 || m.m23 != 0.0 ||
|
m.m13 != 0.0 || m.m23 != 0.0 ||
|
||||||
|
|
|
@ -91,10 +91,10 @@ impl ConstructionResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn debug_id(&self) -> usize {
|
pub fn debug_id(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&ConstructionResult::None => 0,
|
ConstructionResult::None => 0,
|
||||||
&ConstructionResult::ConstructionItem(_) => 0,
|
ConstructionResult::ConstructionItem(_) => 0,
|
||||||
&ConstructionResult::Flow(ref flow_ref, _) => flow::base(&**flow_ref).debug_id(),
|
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 mut layout_data_ref = node.mutate_layout_data();
|
||||||
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
let layout_data = layout_data_ref.as_mut().expect("no layout data");
|
||||||
let damage = layout_data.data.restyle_damage;
|
let damage = layout_data.data.restyle_damage;
|
||||||
match node.construction_result_mut(layout_data) {
|
match *node.construction_result_mut(layout_data) {
|
||||||
&mut ConstructionResult::None => true,
|
ConstructionResult::None => true,
|
||||||
&mut ConstructionResult::Flow(ref mut flow, _) => {
|
ConstructionResult::Flow(ref mut flow, _) => {
|
||||||
// The node's flow is of the same type and has the same set of children and can
|
// 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.
|
// therefore be repaired by simply propagating damage and style to the flow.
|
||||||
if !flow.is_block_flow() {
|
if !flow.is_block_flow() {
|
||||||
|
@ -1328,7 +1328,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
flow.repair_style_and_bubble_inline_sizes(&style);
|
flow.repair_style_and_bubble_inline_sizes(&style);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
&mut ConstructionResult::ConstructionItem(ConstructionItem::InlineFragments(
|
ConstructionResult::ConstructionItem(ConstructionItem::InlineFragments(
|
||||||
ref mut inline_fragments_construction_result)) => {
|
ref mut inline_fragments_construction_result)) => {
|
||||||
if !inline_fragments_construction_result.splits.is_empty() {
|
if !inline_fragments_construction_result.splits.is_empty() {
|
||||||
return false
|
return false
|
||||||
|
@ -1384,7 +1384,7 @@ impl<'a> FlowConstructor<'a> {
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
&mut ConstructionResult::ConstructionItem(_) => {
|
ConstructionResult::ConstructionItem(_) => {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1558,8 +1558,7 @@ trait NodeUtils {
|
||||||
/// Returns true if this node doesn't render its kids and false otherwise.
|
/// Returns true if this node doesn't render its kids and false otherwise.
|
||||||
fn is_replaced_content(&self) -> bool;
|
fn is_replaced_content(&self) -> bool;
|
||||||
|
|
||||||
fn construction_result_mut<'a>(self, layout_data: &'a mut LayoutDataWrapper)
|
fn construction_result_mut(self, layout_data: &mut LayoutDataWrapper) -> &mut ConstructionResult;
|
||||||
-> &'a mut ConstructionResult;
|
|
||||||
|
|
||||||
/// Sets the construction result of a flow.
|
/// Sets the construction result of a flow.
|
||||||
fn set_flow_construction_result(self, result: ConstructionResult);
|
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() {
|
match self.get_pseudo_element_type() {
|
||||||
PseudoElementType::Before(_) => &mut layout_data.data.before_flow_construction_result,
|
PseudoElementType::Before(_) => &mut layout_data.data.before_flow_construction_result,
|
||||||
PseudoElementType::After (_) => &mut layout_data.data.after_flow_construction_result,
|
PseudoElementType::After (_) => &mut layout_data.data.after_flow_construction_result,
|
||||||
|
|
|
@ -522,8 +522,8 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
|
||||||
let parent_layout_data: &Option<LayoutDataWrapper> = unsafe {
|
let parent_layout_data: &Option<LayoutDataWrapper> = unsafe {
|
||||||
&*parent_node.borrow_layout_data_unchecked()
|
&*parent_node.borrow_layout_data_unchecked()
|
||||||
};
|
};
|
||||||
match parent_layout_data {
|
match *parent_layout_data {
|
||||||
&Some(ref parent_layout_data_ref) => {
|
Some(ref parent_layout_data_ref) => {
|
||||||
// Check parent style.
|
// Check parent style.
|
||||||
let parent_style = parent_layout_data_ref.shared_data.style.as_ref().unwrap();
|
let parent_style = parent_layout_data_ref.shared_data.style.as_ref().unwrap();
|
||||||
if !arc_ptr_eq(parent_style, &candidate.parent_style) {
|
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();
|
let mut layout_data_ref = self.mutate_layout_data();
|
||||||
match &mut *layout_data_ref {
|
match *layout_data_ref {
|
||||||
&mut None => panic!("no layout data"),
|
None => panic!("no layout data"),
|
||||||
&mut Some(ref mut layout_data) => {
|
Some(ref mut layout_data) => {
|
||||||
match self.type_id() {
|
match self.type_id() {
|
||||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
NodeTypeId::CharacterData(CharacterDataTypeId::Text) => {
|
||||||
// Text nodes get a copy of the parent style. This ensures
|
// Text nodes get a copy of the parent style. This ensures
|
||||||
|
|
|
@ -72,14 +72,14 @@ impl LayoutDataWrapper {
|
||||||
flow_ref.remove_compositor_layers(constellation_chan);
|
flow_ref.remove_compositor_layers(constellation_chan);
|
||||||
}
|
}
|
||||||
ConstructionResult::ConstructionItem(ref construction_item) => {
|
ConstructionResult::ConstructionItem(ref construction_item) => {
|
||||||
match construction_item {
|
match *construction_item {
|
||||||
&ConstructionItem::InlineFragments(ref inline_fragments) => {
|
ConstructionItem::InlineFragments(ref inline_fragments) => {
|
||||||
for fragment in &inline_fragments.fragments.fragments {
|
for fragment in &inline_fragments.fragments.fragments {
|
||||||
fragment.remove_compositor_layers(constellation_chan.clone());
|
fragment.remove_compositor_layers(constellation_chan.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&ConstructionItem::Whitespace(..) => {}
|
ConstructionItem::Whitespace(..) => {}
|
||||||
&ConstructionItem::TableColumnFragment(ref fragment) => {
|
ConstructionItem::TableColumnFragment(ref fragment) => {
|
||||||
fragment.remove_compositor_layers(constellation_chan.clone());
|
fragment.remove_compositor_layers(constellation_chan.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1202,27 +1202,27 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
-transform_origin.z);
|
-transform_origin.z);
|
||||||
|
|
||||||
for operation in operations {
|
for operation in operations {
|
||||||
let matrix = match operation {
|
let matrix = match *operation {
|
||||||
&transform::ComputedOperation::Rotate(ax, ay, az, theta) => {
|
transform::ComputedOperation::Rotate(ax, ay, az, theta) => {
|
||||||
let theta = 2.0f32 * f32::consts::PI - theta.radians();
|
let theta = 2.0f32 * f32::consts::PI - theta.radians();
|
||||||
Matrix4::create_rotation(ax, ay, az, theta)
|
Matrix4::create_rotation(ax, ay, az, theta)
|
||||||
}
|
}
|
||||||
&transform::ComputedOperation::Perspective(d) => {
|
transform::ComputedOperation::Perspective(d) => {
|
||||||
Matrix4::create_perspective(d.to_f32_px())
|
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)
|
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 tx = model::specified(tx, border_box.size.width).to_f32_px();
|
||||||
let ty = model::specified(ty, border_box.size.height).to_f32_px();
|
let ty = model::specified(ty, border_box.size.height).to_f32_px();
|
||||||
let tz = tz.to_f32_px();
|
let tz = tz.to_f32_px();
|
||||||
Matrix4::create_translation(tx, ty, tz)
|
Matrix4::create_translation(tx, ty, tz)
|
||||||
}
|
}
|
||||||
&transform::ComputedOperation::Matrix(m) => {
|
transform::ComputedOperation::Matrix(m) => {
|
||||||
m.to_gfx_matrix()
|
m.to_gfx_matrix()
|
||||||
}
|
}
|
||||||
&transform::ComputedOperation::Skew(sx, sy) => {
|
transform::ComputedOperation::Skew(sx, sy) => {
|
||||||
Matrix4::create_skew(sx, sy)
|
Matrix4::create_skew(sx, sy)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -87,12 +87,10 @@ impl FlexFlow {
|
||||||
flex_direction::T::column => Mode::Block
|
flex_direction::T::column => Mode::Block
|
||||||
};
|
};
|
||||||
|
|
||||||
let this = FlexFlow {
|
FlexFlow {
|
||||||
block_flow: BlockFlow::from_fragment(fragment, flotation),
|
block_flow: BlockFlow::from_fragment(fragment, flotation),
|
||||||
main_mode: main_mode
|
main_mode: main_mode
|
||||||
};
|
}
|
||||||
|
|
||||||
this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(zentner): This function should use flex-basis.
|
// TODO(zentner): This function should use flex-basis.
|
||||||
|
|
|
@ -632,12 +632,10 @@ impl IframeFragmentInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
let containing_size = containing_size.unwrap_or(Au(0));
|
let containing_size = containing_size.unwrap_or(Au(0));
|
||||||
let size = clamp_size(computed_size,
|
clamp_size(computed_size,
|
||||||
style_min_size,
|
style_min_size,
|
||||||
style_max_size,
|
style_max_size,
|
||||||
containing_size);
|
containing_size)
|
||||||
|
|
||||||
size
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,13 +63,13 @@ struct State {
|
||||||
impl Scope {
|
impl Scope {
|
||||||
pub fn new(name: String) -> Scope {
|
pub fn new(name: String) -> Scope {
|
||||||
STATE_KEY.with(|ref r| {
|
STATE_KEY.with(|ref r| {
|
||||||
match &mut *r.borrow_mut() {
|
match *r.borrow_mut() {
|
||||||
&mut Some(ref mut state) => {
|
Some(ref mut state) => {
|
||||||
let flow_trace = json::encode(&flow::base(&*state.flow_root)).unwrap();
|
let flow_trace = json::encode(&flow::base(&*state.flow_root)).unwrap();
|
||||||
let data = box ScopeData::new(name.clone(), flow_trace);
|
let data = box ScopeData::new(name.clone(), flow_trace);
|
||||||
state.scope_stack.push(data);
|
state.scope_stack.push(data);
|
||||||
}
|
}
|
||||||
&mut None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Scope
|
Scope
|
||||||
|
@ -80,14 +80,14 @@ impl Scope {
|
||||||
impl Drop for Scope {
|
impl Drop for Scope {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
STATE_KEY.with(|ref r| {
|
STATE_KEY.with(|ref r| {
|
||||||
match &mut *r.borrow_mut() {
|
match *r.borrow_mut() {
|
||||||
&mut Some(ref mut state) => {
|
Some(ref mut state) => {
|
||||||
let mut current_scope = state.scope_stack.pop().unwrap();
|
let mut current_scope = state.scope_stack.pop().unwrap();
|
||||||
current_scope.post = json::encode(&flow::base(&*state.flow_root)).unwrap();
|
current_scope.post = json::encode(&flow::base(&*state.flow_root)).unwrap();
|
||||||
let previous_scope = state.scope_stack.last_mut().unwrap();
|
let previous_scope = state.scope_stack.last_mut().unwrap();
|
||||||
previous_scope.children.push(current_scope);
|
previous_scope.children.push(current_scope);
|
||||||
}
|
}
|
||||||
&mut None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -857,8 +857,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
/// Set the restyle damage field.
|
/// Set the restyle damage field.
|
||||||
pub fn set_restyle_damage(self, damage: RestyleDamage) {
|
pub fn set_restyle_damage(self, damage: RestyleDamage) {
|
||||||
let mut layout_data_ref = self.mutate_layout_data();
|
let mut layout_data_ref = self.mutate_layout_data();
|
||||||
match &mut *layout_data_ref {
|
match *layout_data_ref {
|
||||||
&mut Some(ref mut layout_data) => layout_data.data.restyle_damage = damage,
|
Some(ref mut layout_data) => layout_data.data.restyle_damage = damage,
|
||||||
_ => panic!("no layout data for this node"),
|
_ => panic!("no layout data for this node"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -876,8 +876,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
/// Adds the given flags to this node.
|
/// Adds the given flags to this node.
|
||||||
pub fn insert_flags(self, new_flags: LayoutDataFlags) {
|
pub fn insert_flags(self, new_flags: LayoutDataFlags) {
|
||||||
let mut layout_data_ref = self.mutate_layout_data();
|
let mut layout_data_ref = self.mutate_layout_data();
|
||||||
match &mut *layout_data_ref {
|
match *layout_data_ref {
|
||||||
&mut Some(ref mut layout_data) => layout_data.data.flags.insert(new_flags),
|
Some(ref mut layout_data) => layout_data.data.flags.insert(new_flags),
|
||||||
_ => panic!("no layout data for this node"),
|
_ => panic!("no layout data for this node"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -885,8 +885,8 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
/// Removes the given flags from this node.
|
/// Removes the given flags from this node.
|
||||||
pub fn remove_flags(self, flags: LayoutDataFlags) {
|
pub fn remove_flags(self, flags: LayoutDataFlags) {
|
||||||
let mut layout_data_ref = self.mutate_layout_data();
|
let mut layout_data_ref = self.mutate_layout_data();
|
||||||
match &mut *layout_data_ref {
|
match *layout_data_ref {
|
||||||
&mut Some(ref mut layout_data) => layout_data.data.flags.remove(flags),
|
Some(ref mut layout_data) => layout_data.data.flags.remove(flags),
|
||||||
_ => panic!("no layout data for this node"),
|
_ => panic!("no layout data for this node"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,8 @@ use dom::node::Node;
|
||||||
use dom::virtualmethods::vtable_for;
|
use dom::virtualmethods::vtable_for;
|
||||||
|
|
||||||
// See https://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
|
// See https://dom.spec.whatwg.org/#concept-event-dispatch for the full dispatch algorithm
|
||||||
pub fn dispatch_event(target: &EventTarget,
|
pub fn dispatch_event(target: &EventTarget, pseudo_target: Option<&EventTarget>,
|
||||||
pseudo_target: Option<&EventTarget>,
|
event: &Event) -> bool {
|
||||||
event: &Event) -> bool {
|
|
||||||
assert!(!event.dispatching());
|
assert!(!event.dispatching());
|
||||||
assert!(event.initialized());
|
assert!(event.initialized());
|
||||||
|
|
||||||
|
|
|
@ -356,9 +356,8 @@ fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&str>)
|
||||||
do_broadcast(doc_node, broadcaster, owner.r(), group)
|
do_broadcast(doc_node, broadcaster, owner.r(), group)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_same_group(other: &HTMLInputElement,
|
fn in_same_group(other: &HTMLInputElement, owner: Option<&HTMLFormElement>,
|
||||||
owner: Option<&HTMLFormElement>,
|
group: Option<&str>) -> bool {
|
||||||
group: Option<&str>) -> bool {
|
|
||||||
let other_owner = other.form_owner();
|
let other_owner = other.form_owner();
|
||||||
let other_owner = other_owner.r();
|
let other_owner = other_owner.r();
|
||||||
other.input_type.get() == InputType::InputRadio &&
|
other.input_type.get() == InputType::InputRadio &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue