Auto merge of #19465 - CYBAI:refcount-template-area, r=emilio

Implement GridTemplateAreas with reference counting

Use `Arc` to implement refcounting for `GridTemplateAreas`
r? emilio

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #19428
- [x] These changes do not require tests

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19465)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-01-31 07:28:04 -06:00 committed by GitHub
commit 12a596654b
4 changed files with 38 additions and 15 deletions

View file

@ -11,6 +11,7 @@ use cssparser::Parser;
use hash::FnvHashMap;
use parser::{Parse, ParserContext};
use selectors::parser::SelectorParseErrorKind;
use servo_arc::Arc;
use std::fmt::{self, Write};
use std::ops::Range;
use str::HTML_SPACE_CHARACTERS;
@ -624,6 +625,23 @@ impl Parse for TemplateAreas {
trivial_to_computed_value!(TemplateAreas);
/// Arc type for `Arc<TemplateAreas>`
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
pub struct TemplateAreasArc(#[ignore_malloc_size_of = "Arc"] pub Arc<TemplateAreas>);
impl Parse for TemplateAreasArc {
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
let parsed = TemplateAreas::parse(context, input)?;
Ok(TemplateAreasArc(Arc::new(parsed)))
}
}
trivial_to_computed_value!(TemplateAreasArc);
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Debug, PartialEq)]
/// Not associated with any particular grid item, but can
@ -673,7 +691,7 @@ fn is_name_code_point(c: char) -> bool {
/// The syntax of this property also provides a visualization of
/// the structure of the grid, making the overall layout of
/// the grid container easier to understand.
pub type GridTemplateAreas = Either<TemplateAreas, None_>;
pub type GridTemplateAreas = Either<TemplateAreasArc, None_>;
impl GridTemplateAreas {
#[inline]