mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
This reverts commit 8e15389cae
.
This commit is contained in:
parent
8e15389cae
commit
d6ae8dc112
152 changed files with 4622 additions and 5862 deletions
|
@ -27,7 +27,6 @@ serde = "1.0"
|
|||
servo_arc = { path = "../servo_arc" }
|
||||
servo_atoms = { path = "../atoms", optional = true }
|
||||
servo_url = { path = "../url", optional = true }
|
||||
size_of_test = { path = "../size_of_test" }
|
||||
to_shmem = { path = "../to_shmem" }
|
||||
to_shmem_derive = { path = "../to_shmem_derive" }
|
||||
webrender_api = { workspace = true, optional = true }
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
#![crate_type = "rlib"]
|
||||
#![deny(unsafe_code, missing_docs)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate size_of_test;
|
||||
|
||||
use bitflags::bitflags;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -84,11 +81,9 @@ pub use crate::values::{
|
|||
|
||||
/// The error type for all CSS parsing routines.
|
||||
pub type ParseError<'i> = cssparser::ParseError<'i, StyleParseErrorKind<'i>>;
|
||||
size_of_test!(ParseError, 64);
|
||||
|
||||
/// Error in property value parsing
|
||||
pub type ValueParseError<'i> = cssparser::ParseError<'i, ValueParseErrorKind<'i>>;
|
||||
size_of_test!(ValueParseError, 48);
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
/// Errors that can be encountered while parsing CSS values.
|
||||
|
@ -153,7 +148,6 @@ pub enum StyleParseErrorKind<'i> {
|
|||
/// The property is not allowed within a page rule.
|
||||
NotAllowedInPageRule,
|
||||
}
|
||||
size_of_test!(StyleParseErrorKind, 56);
|
||||
|
||||
impl<'i> From<ValueParseErrorKind<'i>> for StyleParseErrorKind<'i> {
|
||||
fn from(this: ValueParseErrorKind<'i>) -> Self {
|
||||
|
@ -175,7 +169,6 @@ pub enum ValueParseErrorKind<'i> {
|
|||
/// An invalid filter value was encountered.
|
||||
InvalidFilter(Token<'i>),
|
||||
}
|
||||
size_of_test!(ValueParseErrorKind, 40);
|
||||
|
||||
impl<'i> StyleParseErrorKind<'i> {
|
||||
/// Create an InvalidValue parse error
|
||||
|
|
|
@ -44,36 +44,6 @@ use std::fmt::{self, Write};
|
|||
/// * `#[css(represents_keyword)]` can be used on bool fields in order to
|
||||
/// serialize the field name if the field is true, or nothing otherwise. It
|
||||
/// also collects those keywords for `SpecifiedValueInfo`.
|
||||
/// * `#[css(bitflags(single="", mixed="", validate="", overlapping_bits)]` can
|
||||
/// be used to derive parse / serialize / etc on bitflags. The rules for parsing
|
||||
/// bitflags are the following:
|
||||
///
|
||||
/// * `single` flags can only appear on their own. It's common that bitflags
|
||||
/// properties at least have one such value like `none` or `auto`.
|
||||
/// * `mixed` properties can appear mixed together, but not along any other
|
||||
/// flag that shares a bit with itself. For example, if you have three
|
||||
/// bitflags like:
|
||||
///
|
||||
/// FOO = 1 << 0;
|
||||
/// BAR = 1 << 1;
|
||||
/// BAZ = 1 << 2;
|
||||
/// BAZZ = BAR | BAZ;
|
||||
///
|
||||
/// Then the following combinations won't be valid:
|
||||
///
|
||||
/// * foo foo: (every flag shares a bit with itself)
|
||||
/// * bar bazz: (bazz shares a bit with bar)
|
||||
///
|
||||
/// But `bar baz` will be valid, as they don't share bits, and so would
|
||||
/// `foo` with any other flag, or `bazz` on its own.
|
||||
/// * `overlapping_bits` enables some tracking during serialization of mixed
|
||||
/// flags to avoid serializing variants that can subsume other variants.
|
||||
/// In the example above, you could do:
|
||||
/// mixed="foo,bazz,bar,baz", overlapping_bits
|
||||
/// to ensure that if bazz is serialized, bar and baz aren't, even though
|
||||
/// their bits are set. Note that the serialization order is canonical,
|
||||
/// and thus depends on the order you specify the flags in.
|
||||
///
|
||||
/// * finally, one can put `#[css(derive_debug)]` on the whole type, to
|
||||
/// implement `Debug` by a single call to `ToCss::to_css`.
|
||||
pub trait ToCss {
|
||||
|
@ -587,8 +557,6 @@ pub mod specified {
|
|||
NonNegative,
|
||||
/// Allow only numeric values greater or equal to 1.0.
|
||||
AtLeastOne,
|
||||
/// Allow only numeric values from 0 to 1.0.
|
||||
ZeroToOne,
|
||||
}
|
||||
|
||||
impl Default for AllowedNumericType {
|
||||
|
@ -609,7 +577,6 @@ pub mod specified {
|
|||
AllowedNumericType::All => true,
|
||||
AllowedNumericType::NonNegative => val >= 0.0,
|
||||
AllowedNumericType::AtLeastOne => val >= 1.0,
|
||||
AllowedNumericType::ZeroToOne => val >= 0.0 && val <= 1.0,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -617,10 +584,9 @@ pub mod specified {
|
|||
#[inline]
|
||||
pub fn clamp(&self, val: f32) -> f32 {
|
||||
match *self {
|
||||
AllowedNumericType::All => val,
|
||||
AllowedNumericType::NonNegative => val.max(0.),
|
||||
AllowedNumericType::AtLeastOne => val.max(1.),
|
||||
AllowedNumericType::ZeroToOne => val.max(0.).min(1.),
|
||||
AllowedNumericType::NonNegative if val < 0. => 0.,
|
||||
AllowedNumericType::AtLeastOne if val < 1. => 1.,
|
||||
_ => val,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue