/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Specified types for SVG properties.
usecrate::parser::{Parse, ParserContext}; usecrate::values::generics::svg as generic; usecrate::values::specified::color::Color; usecrate::values::specified::url::SpecifiedUrl; usecrate::values::specified::AllowQuirks; usecrate::values::specified::LengthPercentage; usecrate::values::specified::SVGPathData; usecrate::values::specified::{NonNegativeLengthPercentage, Opacity}; usecrate::values::CustomIdent; use cssparser::{Parser, Token}; use std::fmt::{self, Write}; use style_traits::{CommaWithSpace, CssWriter, ParseError, Separator}; use style_traits::{StyleParseErrorKind, ToCss};
/// Specified SVG Paint value pubtype SVGPaint = generic::GenericSVGPaint<Color, SpecifiedUrl>;
/// The specified value for a single CSS paint-order property. #[repr(u8)] #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd, ToCss)] pubenum PaintOrder { /// `normal` variant
Normal = 0, /// `fill` variant
Fill = 1, /// `stroke` variant
Stroke = 2, /// `markers` variant
Markers = 3,
}
/// Number of non-normal components pubconst PAINT_ORDER_COUNT: u8 = 3;
/// Number of bits for each component pubconst PAINT_ORDER_SHIFT: u8 = 2;
/// Mask with above bits set pubconst PAINT_ORDER_MASK: u8 = 0b11;
/// The specified value is tree `PaintOrder` values packed into the /// bitfields below, as a six-bit field, of 3 two-bit pairs /// /// Each pair can be set to FILL, STROKE, or MARKERS /// Lowest significant bit pairs are highest priority. /// `normal` is the empty bitfield. The three pairs are /// never zero in any case other than `normal`. /// /// Higher priority values, i.e. the values specified first, /// will be painted first (and may be covered by paintings of lower priority) #[derive(
Clone,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] #[repr(transparent)] pubstruct SVGPaintOrder(pub u8);
impl SVGPaintOrder { /// Get default `paint-order` with `0` pubfn normal() -> Self {
SVGPaintOrder(0)
}
match result {
Ok(val) => { if (seen & (1 << val as u8)) != 0 { // don't parse the same ident twice return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
value |= (val as u8) << (pos * PAINT_ORDER_SHIFT);
seen |= 1 << (val as u8);
pos += 1;
},
Err(_) => break,
}
}
if value == 0 { // Couldn't find any keyword return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
// fill in rest for i in pos..PAINT_ORDER_COUNT { for paint in1..(PAINT_ORDER_COUNT + 1) { // if not seen, set bit at position, mark as seen if (seen & (1 << paint)) == 0 {
seen |= 1 << paint;
value |= paint << (i * PAINT_ORDER_SHIFT); break;
}
}
}
letmut last_pos_to_serialize = 0; for i in (1..PAINT_ORDER_COUNT).rev() { let component = self.order_at(i); let earlier_component = self.order_at(i - 1); if component < earlier_component {
last_pos_to_serialize = i - 1; break;
}
}
for pos in0..last_pos_to_serialize + 1 { if pos != 0 {
dest.write_char(' ')?
} self.order_at(pos).to_css(dest)?;
}
Ok(())
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.