mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
Upgrade remaining components to edition 2018
This commit is contained in:
parent
fd79367491
commit
9c2cc05a8e
48 changed files with 102 additions and 160 deletions
|
@ -3,6 +3,7 @@ name = "style_traits"
|
|||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
|
||||
//! A thin atomically-reference-counted slice.
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use serde::de::{Deserialize, Deserializer};
|
||||
use serde::ser::{Serialize, Serializer};
|
||||
use servo_arc::ThinArc;
|
||||
use std::ops::Deref;
|
||||
use std::ptr::NonNull;
|
||||
use std::{iter, mem};
|
||||
use to_shmem_derive::ToShmem;
|
||||
|
||||
/// A canary that we stash in ArcSlices.
|
||||
///
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
//! Types used to access the DOM from style calculation.
|
||||
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed
|
||||
/// back into a non-opaque representation. The only safe operation that can be
|
||||
/// performed on this node is to compare it to another opaque handle or to another
|
||||
|
|
|
@ -10,30 +10,9 @@
|
|||
#![crate_type = "rlib"]
|
||||
#![deny(unsafe_code, missing_docs)]
|
||||
|
||||
extern crate app_units;
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
#[macro_use]
|
||||
extern crate cssparser;
|
||||
extern crate euclid;
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate malloc_size_of;
|
||||
#[macro_use]
|
||||
extern crate malloc_size_of_derive;
|
||||
extern crate selectors;
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
extern crate servo_arc;
|
||||
#[cfg(feature = "servo")]
|
||||
extern crate servo_atoms;
|
||||
#[cfg(feature = "servo")]
|
||||
extern crate servo_url;
|
||||
extern crate to_shmem;
|
||||
#[macro_use]
|
||||
extern crate to_shmem_derive;
|
||||
#[cfg(feature = "servo")]
|
||||
extern crate webrender_api;
|
||||
use bitflags::bitflags;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "servo")]
|
||||
pub use webrender_api::units::DevicePixel;
|
||||
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
//! A replacement for `Box<str>` that has a defined layout for FFI.
|
||||
|
||||
use crate::owned_slice::OwnedSlice;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use std::fmt;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
use to_shmem_derive::ToShmem;
|
||||
|
||||
/// A struct that basically replaces a Box<str>, but with a defined layout,
|
||||
/// suitable for FFI.
|
||||
|
|
|
@ -348,7 +348,7 @@ impl Separator for Space {
|
|||
let mut results = vec![parse_one(input)?];
|
||||
loop {
|
||||
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
||||
if let Ok(item) = input.try(&mut parse_one) {
|
||||
if let Ok(item) = input.r#try(&mut parse_one) {
|
||||
results.push(item);
|
||||
} else {
|
||||
return Ok(results);
|
||||
|
@ -374,9 +374,9 @@ impl Separator for CommaWithSpace {
|
|||
loop {
|
||||
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
||||
let comma_location = input.current_source_location();
|
||||
let comma = input.try(|i| i.expect_comma()).is_ok();
|
||||
let comma = input.r#try(|i| i.expect_comma()).is_ok();
|
||||
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less.
|
||||
if let Ok(item) = input.try(&mut parse_one) {
|
||||
if let Ok(item) = input.r#try(&mut parse_one) {
|
||||
results.push(item);
|
||||
} else if comma {
|
||||
return Err(comma_location.new_unexpected_token_error(Token::Comma));
|
||||
|
@ -478,8 +478,9 @@ impl_to_css_for_predefined_type!(::cssparser::UnicodeRange);
|
|||
macro_rules! define_css_keyword_enum {
|
||||
(pub enum $name:ident { $($variant:ident = $css:expr,)+ }) => {
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)]
|
||||
#[cfg_attr(feature = "servo", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash,
|
||||
malloc_size_of_derive::MallocSizeOf, PartialEq, to_shmem_derive::ToShmem)]
|
||||
pub enum $name {
|
||||
$($variant),+
|
||||
}
|
||||
|
@ -506,7 +507,7 @@ macro_rules! define_css_keyword_enum {
|
|||
|
||||
/// Parse this property from an already-tokenized identifier.
|
||||
pub fn from_ident(ident: &str) -> Result<$name, ()> {
|
||||
match_ignore_ascii_case! { ident,
|
||||
cssparser::match_ignore_ascii_case! { ident,
|
||||
$($css => Ok($name::$variant),)+
|
||||
_ => Err(())
|
||||
}
|
||||
|
@ -532,11 +533,22 @@ macro_rules! define_css_keyword_enum {
|
|||
/// Helper types for the handling of specified values.
|
||||
pub mod specified {
|
||||
use crate::ParsingMode;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Whether to allow negative lengths or not.
|
||||
#[repr(u8)]
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, PartialOrd, Serialize, ToShmem,
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Deserialize,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
PartialOrd,
|
||||
Serialize,
|
||||
to_shmem_derive::ToShmem,
|
||||
)]
|
||||
pub enum AllowedNumericType {
|
||||
/// Allow all kind of numeric values.
|
||||
|
|
|
@ -5,9 +5,12 @@
|
|||
//! Helper types for the `@viewport` rule.
|
||||
|
||||
use crate::{CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss};
|
||||
use cssparser::Parser;
|
||||
use cssparser::*;
|
||||
use euclid::Size2D;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::{self, Write};
|
||||
use to_shmem_derive::ToShmem;
|
||||
|
||||
define_css_keyword_enum! {
|
||||
pub enum UserZoom {
|
||||
|
@ -114,7 +117,6 @@ impl Zoom {
|
|||
pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Zoom, ParseError<'i>> {
|
||||
use crate::values::specified::AllowedNumericType::NonNegative;
|
||||
use crate::ParsingMode;
|
||||
use cssparser::Token;
|
||||
|
||||
let location = input.current_source_location();
|
||||
match *input.next()? {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue