Remove usage of unstable feature conservative_impl_trait in layout

This commit is contained in:
Simon Sapin 2017-10-12 18:00:44 +02:00
parent c2d660037a
commit 4727b92754
3 changed files with 30 additions and 5 deletions

View file

@ -32,7 +32,7 @@ use display_list_builder::{DisplayListBuildState, StackingContextCollectionState
use euclid::{Transform3D, Point2D, Vector2D, Rect, Size2D};
use flex::FlexFlow;
use floats::{Floats, SpeculatedFloatPlacement};
use flow_list::{FlowList, MutFlowListIterator};
use flow_list::{FlowList, FlowListIterator, MutFlowListIterator};
use flow_ref::{FlowRef, WeakFlowRef};
use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, Overflow};
use gfx_traits::StackingContextId;
@ -459,7 +459,7 @@ pub fn base<T: ?Sized + Flow>(this: &T) -> &BaseFlow {
}
/// Iterates over the children of this immutable flow.
pub fn child_iter<'a>(flow: &'a Flow) -> impl Iterator<Item = &'a Flow> {
pub fn child_iter<'a>(flow: &'a Flow) -> FlowListIterator {
base(flow).children.iter()
}

View file

@ -7,6 +7,7 @@ use flow_ref::FlowRef;
use serde::ser::{Serialize, SerializeSeq, Serializer};
use serde_json::{Map, Value, to_value};
use std::collections::{LinkedList, linked_list};
use std::ops::Deref;
use std::sync::Arc;
/// This needs to be reworked now that we have dynamically-sized types in Rust.
@ -53,6 +54,10 @@ pub struct MutFlowListIterator<'a> {
it: linked_list::IterMut<'a, FlowRef>,
}
pub struct FlowListIterator<'a> {
it: linked_list::Iter<'a, FlowRef>,
}
impl FlowList {
/// Add an element last in the list
///
@ -101,8 +106,10 @@ impl FlowList {
/// SECURITY-NOTE(pcwalton): This does not hand out `FlowRef`s by design. Do not add a method
/// to do so! See the comment above in `FlowList`.
#[inline]
pub fn iter<'a>(&'a self) -> impl DoubleEndedIterator<Item = &'a Flow> {
self.flows.iter().map(|flow| &**flow)
pub fn iter<'a>(&'a self) -> FlowListIterator {
FlowListIterator {
it: self.flows.iter(),
}
}
/// Provide a forward iterator with mutable references
@ -150,12 +157,31 @@ impl FlowList {
}
}
impl<'a> DoubleEndedIterator for FlowListIterator<'a> {
fn next_back(&mut self) -> Option<&'a Flow> {
self.it.next_back().map(Deref::deref)
}
}
impl<'a> DoubleEndedIterator for MutFlowListIterator<'a> {
fn next_back(&mut self) -> Option<&'a mut Flow> {
self.it.next_back().map(FlowRef::deref_mut)
}
}
impl<'a> Iterator for FlowListIterator<'a> {
type Item = &'a Flow;
#[inline]
fn next(&mut self) -> Option<&'a Flow> {
self.it.next().map(Deref::deref)
}
#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
self.it.size_hint()
}
}
impl<'a> Iterator for MutFlowListIterator<'a> {
type Item = &'a mut Flow;
#[inline]

View file

@ -4,7 +4,6 @@
#![deny(unsafe_code)]
#![feature(box_patterns)]
#![feature(conservative_impl_trait)]
#![feature(raw)]
extern crate app_units;