Struct style::values::specified::percentage::Percentage
[−]
[src]
pub struct Percentage { /* fields omitted */ }
A percentage value.
Methods
impl Percentage
[src]
pub fn new(value: CSSFloat) -> Self
[src]
Creates a percentage from a numeric value.
pub fn zero() -> Self
[src]
0%
pub fn hundred() -> Self
[src]
100%
pub fn get(&self) -> CSSFloat
[src]
Gets the underlying value for this float.
pub fn is_calc(&self) -> bool
[src]
Returns whether this percentage is a calc()
value.
pub fn reverse(&mut self)
[src]
Reverses this percentage, preserving calc-ness.
For example: If it was 20%, convert it into 80%.
pub fn parse_with_clamping_mode<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
num_context: AllowedNumericType
) -> Result<Self, ParseError<'i>>
[src]
context: &ParserContext,
input: &mut Parser<'i, 't>,
num_context: AllowedNumericType
) -> Result<Self, ParseError<'i>>
Parses a specific kind of percentage.
pub fn parse_non_negative<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>>
[src]
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>>
Parses a percentage token, but rejects it if it's negative.
pub fn clamp_to_hundred(self) -> Self
[src]
Clamp to 100% if the value is over 100%.
Trait Implementations
impl From<Percentage> for LengthOrPercentage
[src]
fn from(pc: Percentage) -> Self
[src]
Performs the conversion.
impl Clone for Percentage
[src]
fn clone(&self) -> Percentage
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Copy for Percentage
[src]
impl Debug for Percentage
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Default for Percentage
[src]
fn default() -> Percentage
[src]
Returns the "default value" for a type. Read more
impl MallocSizeOf for Percentage
[src]
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
[src]
Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself. Read more
impl PartialEq for Percentage
[src]
fn eq(&self, __arg_0: &Percentage) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Percentage) -> bool
[src]
This method tests for !=
.
impl ToCss for Percentage
[src]
fn to_css<W>(&self, dest: &mut W) -> Result where
W: Write,
[src]
W: Write,
Serialize self
in CSS syntax, writing to dest
.
fn to_css_string(&self) -> String
[src]
Serialize self
in CSS syntax and return a string. Read more
impl Parse for Percentage
[src]
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>>
[src]
context: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Self, ParseError<'i>>
Parse a value of this type. Read more
impl ToComputedValue for Percentage
[src]
type ComputedValue = ComputedPercentage
The computed value type we're going to be converted to.
fn to_computed_value(&self, _: &Context) -> Self::ComputedValue
[src]
Convert a specified value to a computed value, using itself and the data inside the Context
. Read more
fn from_computed_value(computed: &Self::ComputedValue) -> Self
[src]
Convert a computed value to specified value form. Read more