mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Make the viewport module deny new undocumented code.
This commit is contained in:
parent
f37aa12927
commit
5e52184278
1 changed files with 17 additions and 4 deletions
|
@ -7,6 +7,8 @@
|
||||||
//! [at]: https://drafts.csswg.org/css-device-adapt/#atviewport-rule
|
//! [at]: https://drafts.csswg.org/css-device-adapt/#atviewport-rule
|
||||||
//! [meta]: https://drafts.csswg.org/css-device-adapt/#viewport-meta
|
//! [meta]: https://drafts.csswg.org/css-device-adapt/#viewport-meta
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
|
use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser, parse_important};
|
||||||
use cssparser::ToCss as ParserToCss;
|
use cssparser::ToCss as ParserToCss;
|
||||||
|
@ -60,6 +62,7 @@ macro_rules! declare_viewport_descriptor_inner {
|
||||||
) => {
|
) => {
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum ViewportDescriptor {
|
pub enum ViewportDescriptor {
|
||||||
$(
|
$(
|
||||||
$assigned_variant($assigned_data),
|
$assigned_variant($assigned_data),
|
||||||
|
@ -69,6 +72,7 @@ macro_rules! declare_viewport_descriptor_inner {
|
||||||
const VIEWPORT_DESCRIPTOR_VARIANTS: usize = $number_of_variants;
|
const VIEWPORT_DESCRIPTOR_VARIANTS: usize = $number_of_variants;
|
||||||
|
|
||||||
impl ViewportDescriptor {
|
impl ViewportDescriptor {
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub fn discriminant_value(&self) -> usize {
|
pub fn discriminant_value(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
$(
|
$(
|
||||||
|
@ -114,12 +118,13 @@ trait FromMeta: Sized {
|
||||||
fn from_meta(value: &str) -> Option<Self>;
|
fn from_meta(value: &str) -> Option<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ViewportLength is a length | percentage | auto | extend-to-zoom
|
/// ViewportLength is a length | percentage | auto | extend-to-zoom
|
||||||
// See:
|
/// See:
|
||||||
// * http://dev.w3.org/csswg/css-device-adapt/#min-max-width-desc
|
/// * http://dev.w3.org/csswg/css-device-adapt/#min-max-width-desc
|
||||||
// * http://dev.w3.org/csswg/css-device-adapt/#extend-to-zoom
|
/// * http://dev.w3.org/csswg/css-device-adapt/#extend-to-zoom
|
||||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub enum ViewportLength {
|
pub enum ViewportLength {
|
||||||
Specified(LengthOrPercentageOrAuto),
|
Specified(LengthOrPercentageOrAuto),
|
||||||
ExtendToZoom
|
ExtendToZoom
|
||||||
|
@ -209,6 +214,7 @@ struct ViewportRuleParser<'a, 'b: 'a> {
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub struct ViewportDescriptorDeclaration {
|
pub struct ViewportDescriptorDeclaration {
|
||||||
pub origin: Origin,
|
pub origin: Origin,
|
||||||
pub descriptor: ViewportDescriptor,
|
pub descriptor: ViewportDescriptor,
|
||||||
|
@ -216,6 +222,7 @@ pub struct ViewportDescriptorDeclaration {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewportDescriptorDeclaration {
|
impl ViewportDescriptorDeclaration {
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub fn new(origin: Origin,
|
pub fn new(origin: Origin,
|
||||||
descriptor: ViewportDescriptor,
|
descriptor: ViewportDescriptor,
|
||||||
important: bool) -> ViewportDescriptorDeclaration
|
important: bool) -> ViewportDescriptorDeclaration
|
||||||
|
@ -313,9 +320,11 @@ impl<'a, 'b> DeclarationParser for ViewportRuleParser<'a, 'b> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A `@viewport` rule.
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct ViewportRule {
|
pub struct ViewportRule {
|
||||||
|
/// The declarations contained in this @viewport rule.
|
||||||
pub declarations: Vec<ViewportDescriptorDeclaration>
|
pub declarations: Vec<ViewportDescriptorDeclaration>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +342,7 @@ fn is_whitespace_separator_or_equals(c: &char) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ViewportRule {
|
impl ViewportRule {
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub fn parse(input: &mut Parser, context: &ParserContext)
|
pub fn parse(input: &mut Parser, context: &ParserContext)
|
||||||
-> Result<ViewportRule, ()>
|
-> Result<ViewportRule, ()>
|
||||||
{
|
{
|
||||||
|
@ -358,6 +368,7 @@ impl ViewportRule {
|
||||||
Ok(ViewportRule { declarations: cascade.finish() })
|
Ok(ViewportRule { declarations: cascade.finish() })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub fn from_meta(content: &str) -> Option<ViewportRule> {
|
pub fn from_meta(content: &str) -> Option<ViewportRule> {
|
||||||
let mut declarations = vec![None; VIEWPORT_DESCRIPTOR_VARIANTS];
|
let mut declarations = vec![None; VIEWPORT_DESCRIPTOR_VARIANTS];
|
||||||
macro_rules! push_descriptor {
|
macro_rules! push_descriptor {
|
||||||
|
@ -531,11 +542,13 @@ impl ViewportDescriptorDeclaration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
pub struct Cascade {
|
pub struct Cascade {
|
||||||
declarations: Vec<Option<(usize, ViewportDescriptorDeclaration)>>,
|
declarations: Vec<Option<(usize, ViewportDescriptorDeclaration)>>,
|
||||||
count_so_far: usize,
|
count_so_far: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(missing_docs)]
|
||||||
impl Cascade {
|
impl Cascade {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Cascade {
|
Cascade {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue