#![allow(dead_code)]
use crate::properties::{PropertyId, PropertyValue};
use fop_types::{Color, Length};
use std::borrow::Cow;
const EN_AUTO: u16 = 9;
const EN_NONE: u16 = 86;
const EN_NORMAL: u16 = 87;
const EN_VISIBLE: u16 = 136;
const EN_HIDDEN: u16 = 57;
const EN_COLLAPSE: u16 = 26;
const EN_SEPARATE: u16 = 120;
const EN_START: u16 = 126;
const EN_CENTER: u16 = 23;
const EN_END: u16 = 39;
const EN_JUSTIFY: u16 = 70;
const EN_LEFT: u16 = 72;
const EN_RIGHT: u16 = 113;
const EN_SOLID: u16 = 123;
const EN_DASHED: u16 = 31;
const EN_DOTTED: u16 = 36;
const EN_DOUBLE: u16 = 37;
const EN_GROOVE: u16 = 55;
const EN_RIDGE: u16 = 114;
const EN_INSET: u16 = 67;
const EN_OUTSET: u16 = 93;
const EN_BLOCK: u16 = 18;
const EN_INLINE: u16 = 65;
const EN_STATIC: u16 = 127;
const EN_RELATIVE: u16 = 109;
const EN_ABSOLUTE: u16 = 1;
const EN_FIXED: u16 = 51;
const EN_ALWAYS: u16 = 7;
const EN_AVOID: u16 = 11;
const EN_LTR: u16 = 75;
const EN_RTL: u16 = 116;
const EN_LR_TB: u16 = 74;
const EN_RL_TB: u16 = 115;
const EN_TB_RL: u16 = 131;
const EN_ITALIC: u16 = 68;
const EN_OBLIQUE: u16 = 90;
const EN_BOLD: u16 = 19;
const EN_BOLDER: u16 = 20;
const EN_LIGHTER: u16 = 73;
const EN_100: u16 = 141;
const EN_200: u16 = 142;
const EN_300: u16 = 143;
const EN_400: u16 = 144;
const EN_500: u16 = 145;
const EN_600: u16 = 146;
const EN_700: u16 = 147;
const EN_800: u16 = 148;
const EN_900: u16 = 149;
const EN_SMALL_CAPS: u16 = 122;
const EN_UNDERLINE: u16 = 134;
const EN_OVERLINE: u16 = 94;
const EN_LINE_THROUGH: u16 = 76;
const EN_BLINK: u16 = 17;
const EN_CAPITALIZE: u16 = 22;
const EN_UPPERCASE: u16 = 135;
const EN_LOWERCASE: u16 = 77;
const EN_SCROLL: u16 = 119;
const EN_ERROR_IF_OVERFLOW: u16 = 42;
const EN_SHOW: u16 = 121;
const EN_HIDE: u16 = 58;
const EN_BEFORE: u16 = 13;
const EN_AFTER: u16 = 3;
const EN_TOP: u16 = 133;
const EN_BOTTOM: u16 = 20;
const EN_AUTO_LAYOUT: u16 = 9;
const EN_BASELINE: u16 = 12;
const EN_MIDDLE: u16 = 81;
const EN_SUB: u16 = 128;
const EN_SUPER: u16 = 129;
const EN_TEXT_TOP: u16 = 132;
const EN_TEXT_BOTTOM: u16 = 130;
const EN_DISTRIBUTE: u16 = 34;
const EN_ALPHABETIC: u16 = 6;
const EN_IDEOGRAPHIC: u16 = 59;
const EN_HANGING: u16 = 56;
const EN_MATHEMATICAL: u16 = 79;
const EN_PRE: u16 = 100;
const EN_NOWRAP: u16 = 88;
const EN_PRE_WRAP: u16 = 101;
const EN_PRE_LINE: u16 = 99;
const EN_WRAP: u16 = 139;
const EN_NO_WRAP: u16 = 88;
const EN_TRUE: u16 = 134;
const EN_FALSE: u16 = 48;
const EN_ALL: u16 = 5;
const EN_BOTH: u16 = 19;
const EN_INSIDE: u16 = 68;
const EN_OUTSIDE: u16 = 95;
const EN_SPACE: u16 = 124;
const EN_RULE: u16 = 117;
const EN_DOTS: u16 = 35;
const EN_USE_CONTENT: u16 = 137;
const EN_ODD: u16 = 89;
const EN_EVEN: u16 = 43;
const EN_ANY: u16 = 8;
const EN_FIRST: u16 = 50;
const EN_LAST: u16 = 71;
const EN_REST: u16 = 112;
const EN_BLANK: u16 = 16;
const EN_NOT_BLANK: u16 = 85;
const EN_COLUMN: u16 = 28;
const EN_PAGE: u16 = 96;
const EN_NO_FORCE: u16 = 84;
const EN_EVEN_PAGE: u16 = 44;
const EN_ODD_PAGE: u16 = 91;
const EN_FORCE: u16 = 53;
const EN_EMBED: u16 = 38;
const EN_BIDI_OVERRIDE: u16 = 15;
const EN_IGNORE_IF_BEFORE_LINEFEED: u16 = 62;
const EN_IGNORE_IF_AFTER_LINEFEED: u16 = 61;
const EN_IGNORE_IF_SURROUNDING_LINEFEED: u16 = 63;
const EN_PRESERVE: u16 = 102;
const EN_IGNORE: u16 = 60;
const EN_LINE_HEIGHT: u16 = 75;
const EN_FONT_HEIGHT: u16 = 52;
const EN_MAX_HEIGHT: u16 = 80;
const EN_CONSIDER_SHIFTS: u16 = 30;
const EN_DISREGARD_SHIFTS: u16 = 33;
const EN_CENTRAL: u16 = 24;
const EN_BEFORE_EDGE: u16 = 14;
const EN_TEXT_BEFORE_EDGE: u16 = 130;
const EN_AFTER_EDGE: u16 = 4;
const EN_TEXT_AFTER_EDGE: u16 = 132;
const EN_REFERENCE_AREA: u16 = 108;
const EN_UNIFORM: u16 = 134;
const EN_NON_UNIFORM: u16 = 86;
const EN_PERCEPTUAL: u16 = 98;
const EN_RELATIVE_COLORIMETRIC: u16 = 110;
const EN_SATURATION: u16 = 118;
const EN_ABSOLUTE_COLORIMETRIC: u16 = 2;
const EN_PAGE_SEQUENCE: u16 = 97;
const EN_DOCUMENT: u16 = 34;
const EN_FIRST_STARTING_WITHIN_PAGE: u16 = 54;
const EN_FIRST_INCLUDING_CARRYOVER: u16 = 49;
const EN_LAST_STARTING_WITHIN_PAGE: u16 = 71;
const EN_LAST_ENDING_WITHIN_PAGE: u16 = 70;
const EN_AUTO_SELECT: u16 = 10;
const EN_CHARACTER_BY_CHARACTER: u16 = 25;
const EN_AUTO_MEDIA_USAGE: u16 = 9;
const EN_PAGINATE: u16 = 97;
const EN_BOUNDED_IN_ONE_DIMENSION: u16 = 21;
const EN_UNBOUNDED: u16 = 134;
const EN_NONE_DISPLACE: u16 = 86;
const EN_LINK: u16 = 75;
const EN_VISITED: u16 = 138;
const EN_ACTIVE: u16 = 0;
const EN_HOVER: u16 = 58;
const EN_FOCUS: u16 = 53;
const EN_NO_AUTO_RESTORE: u16 = 83;
const EN_INDICATE_DESTINATION_TRUE: u16 = 134;
const EN_REPLACE: u16 = 111;
const EN_NEW: u16 = 82;
const EN_USE_TARGET_PROCESSING_CONTEXT: u16 = 137;
const EN_DOCUMENT_ROOT: u16 = 35;
const EN_ALTERNATE: u16 = 7;
const EN_NORMAL_CITATION: u16 = 87;
const EN_ALL_CITATION: u16 = 5;
const EN_LINK_COMBINE: u16 = 75;
const EN_NO_LINK: u16 = 83;
const EN_MERGE: u16 = 80;
const EN_LEAVE_SEPARATE: u16 = 72;
pub fn get_initial_value(property_id: PropertyId) -> PropertyValue {
match property_id {
PropertyId::Color => PropertyValue::Color(Color::BLACK),
PropertyId::FontFamily => PropertyValue::String(Cow::Borrowed("serif")),
PropertyId::FontSize => PropertyValue::Length(Length::from_pt(12.0)),
PropertyId::FontStyle => PropertyValue::Enum(EN_NORMAL),
PropertyId::FontWeight => PropertyValue::Enum(EN_NORMAL),
PropertyId::FontVariant => PropertyValue::Enum(EN_NORMAL),
PropertyId::FontStretch => PropertyValue::Enum(EN_NORMAL),
PropertyId::FontSizeAdjust => PropertyValue::None,
PropertyId::FontSelectionStrategy => PropertyValue::Enum(EN_AUTO),
PropertyId::Font => PropertyValue::Auto,
PropertyId::TextAlign => PropertyValue::Enum(EN_START),
PropertyId::TextAlignLast => PropertyValue::Enum(EN_START),
PropertyId::TextIndent => PropertyValue::Length(Length::ZERO),
PropertyId::TextDecoration => PropertyValue::None,
PropertyId::TextTransform => PropertyValue::Enum(EN_NONE),
PropertyId::TextShadow => PropertyValue::None,
PropertyId::LineHeight => PropertyValue::Enum(EN_NORMAL),
PropertyId::LetterSpacing => PropertyValue::Enum(EN_NORMAL),
PropertyId::WordSpacing => PropertyValue::Enum(EN_NORMAL),
PropertyId::WhiteSpace => PropertyValue::Enum(EN_NORMAL),
PropertyId::WhiteSpaceCollapse => PropertyValue::Enum(EN_TRUE),
PropertyId::WhiteSpaceTreatment => PropertyValue::Enum(EN_IGNORE_IF_SURROUNDING_LINEFEED),
PropertyId::LinefeedTreatment => PropertyValue::Enum(EN_IGNORE),
PropertyId::WrapOption => PropertyValue::Enum(EN_WRAP),
PropertyId::MarginTop
| PropertyId::MarginRight
| PropertyId::MarginBottom
| PropertyId::MarginLeft => PropertyValue::Length(Length::ZERO),
PropertyId::Margin => PropertyValue::Auto,
PropertyId::PaddingTop
| PropertyId::PaddingRight
| PropertyId::PaddingBottom
| PropertyId::PaddingLeft
| PropertyId::PaddingBefore
| PropertyId::PaddingAfter
| PropertyId::PaddingStart
| PropertyId::PaddingEnd => PropertyValue::Length(Length::ZERO),
PropertyId::Padding => PropertyValue::Auto,
PropertyId::BorderTopWidth
| PropertyId::BorderRightWidth
| PropertyId::BorderBottomWidth
| PropertyId::BorderLeftWidth
| PropertyId::BorderBeforeWidth
| PropertyId::BorderAfterWidth
| PropertyId::BorderStartWidth
| PropertyId::BorderEndWidth => {
PropertyValue::Length(Length::from_pt(1.0))
}
PropertyId::BorderWidth => PropertyValue::Auto,
PropertyId::BorderTopStyle
| PropertyId::BorderRightStyle
| PropertyId::BorderBottomStyle
| PropertyId::BorderLeftStyle
| PropertyId::BorderBeforeStyle
| PropertyId::BorderAfterStyle
| PropertyId::BorderStartStyle
| PropertyId::BorderEndStyle => PropertyValue::Enum(EN_NONE),
PropertyId::BorderStyle => PropertyValue::Auto,
PropertyId::BorderTopColor
| PropertyId::BorderRightColor
| PropertyId::BorderBottomColor
| PropertyId::BorderLeftColor
| PropertyId::BorderBeforeColor
| PropertyId::BorderAfterColor
| PropertyId::BorderStartColor
| PropertyId::BorderEndColor => {
PropertyValue::Color(Color::BLACK)
}
PropertyId::BorderColor => PropertyValue::Auto,
PropertyId::Border
| PropertyId::BorderTop
| PropertyId::BorderRight
| PropertyId::BorderBottom
| PropertyId::BorderLeft => PropertyValue::Auto,
PropertyId::BorderBeforePrecedence
| PropertyId::BorderAfterPrecedence
| PropertyId::BorderStartPrecedence
| PropertyId::BorderEndPrecedence => PropertyValue::Enum(EN_NONE),
PropertyId::XBorderBeforeRadiusStart
| PropertyId::XBorderBeforeRadiusEnd
| PropertyId::XBorderAfterRadiusStart
| PropertyId::XBorderAfterRadiusEnd
| PropertyId::XBorderStartRadiusBefore
| PropertyId::XBorderStartRadiusAfter
| PropertyId::XBorderEndRadiusBefore
| PropertyId::XBorderEndRadiusAfter
| PropertyId::XBorderBeforeStartRadius
| PropertyId::XBorderBeforeEndRadius
| PropertyId::XBorderAfterStartRadius
| PropertyId::XBorderAfterEndRadius => PropertyValue::Length(Length::ZERO),
PropertyId::XBorderRadius => PropertyValue::Auto,
PropertyId::SpaceBefore
| PropertyId::SpaceAfter
| PropertyId::SpaceStart
| PropertyId::SpaceEnd => {
PropertyValue::Length(Length::ZERO)
}
PropertyId::StartIndent => PropertyValue::Length(Length::ZERO),
PropertyId::EndIndent => PropertyValue::Length(Length::ZERO),
PropertyId::LastLineEndIndent => PropertyValue::Length(Length::ZERO),
PropertyId::Position => PropertyValue::Enum(EN_STATIC),
PropertyId::AbsolutePosition => PropertyValue::Enum(EN_AUTO),
PropertyId::RelativePosition => PropertyValue::Enum(EN_STATIC),
PropertyId::Top | PropertyId::Right | PropertyId::Bottom | PropertyId::Left => {
PropertyValue::Auto
}
PropertyId::Width => PropertyValue::Auto,
PropertyId::Height => PropertyValue::Auto,
PropertyId::MinWidth => PropertyValue::Length(Length::ZERO),
PropertyId::MinHeight => PropertyValue::Length(Length::ZERO),
PropertyId::MaxWidth => PropertyValue::None,
PropertyId::MaxHeight => PropertyValue::None,
PropertyId::InlineProgressionDimension => PropertyValue::Auto,
PropertyId::BlockProgressionDimension => PropertyValue::Auto,
PropertyId::ContentWidth => PropertyValue::Auto,
PropertyId::ContentHeight => PropertyValue::Auto,
PropertyId::TableLayout => PropertyValue::Enum(EN_AUTO),
PropertyId::BorderCollapse => PropertyValue::Enum(EN_SEPARATE),
PropertyId::BorderSpacing => PropertyValue::Length(Length::ZERO),
PropertyId::BorderSeparation => PropertyValue::Length(Length::ZERO),
PropertyId::CaptionSide => PropertyValue::Enum(EN_BEFORE),
PropertyId::EmptyCells => PropertyValue::Enum(EN_SHOW),
PropertyId::TableOmitFooterAtBreak => PropertyValue::Enum(EN_FALSE),
PropertyId::TableOmitHeaderAtBreak => PropertyValue::Enum(EN_FALSE),
PropertyId::ColumnWidth => PropertyValue::Auto,
PropertyId::ColumnNumber => PropertyValue::Auto,
PropertyId::ColumnCount => PropertyValue::Integer(1),
PropertyId::ColumnGap => PropertyValue::Length(Length::from_pt(12.0)),
PropertyId::NumberColumnsRepeated => PropertyValue::Integer(1),
PropertyId::NumberColumnsSpanned => PropertyValue::Integer(1),
PropertyId::NumberRowsSpanned => PropertyValue::Integer(1),
PropertyId::StartsRow => PropertyValue::Enum(EN_FALSE),
PropertyId::EndsRow => PropertyValue::Enum(EN_FALSE),
PropertyId::PageWidth => PropertyValue::Auto,
PropertyId::PageHeight => PropertyValue::Auto,
PropertyId::Extent => PropertyValue::Length(Length::ZERO),
PropertyId::Precedence => PropertyValue::Enum(EN_FALSE),
PropertyId::RegionName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::RegionNameReference => PropertyValue::String(Cow::Borrowed("")),
PropertyId::FlowName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::FlowNameReference => PropertyValue::String(Cow::Borrowed("")),
PropertyId::FlowMapName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::FlowMapReference => PropertyValue::String(Cow::Borrowed("")),
PropertyId::MasterName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::MasterReference => PropertyValue::String(Cow::Borrowed("")),
PropertyId::ReferenceOrientation => PropertyValue::Integer(0),
PropertyId::WritingMode => PropertyValue::Enum(EN_LR_TB),
PropertyId::KeepTogether => PropertyValue::Enum(EN_AUTO),
PropertyId::KeepWithNext => PropertyValue::Enum(EN_AUTO),
PropertyId::KeepWithPrevious => PropertyValue::Enum(EN_AUTO),
PropertyId::BreakBefore => PropertyValue::Enum(EN_AUTO),
PropertyId::BreakAfter => PropertyValue::Enum(EN_AUTO),
PropertyId::PageBreakBefore => PropertyValue::Enum(EN_AUTO),
PropertyId::PageBreakAfter => PropertyValue::Enum(EN_AUTO),
PropertyId::PageBreakInside => PropertyValue::Enum(EN_AUTO),
PropertyId::Orphans => PropertyValue::Integer(2),
PropertyId::Widows => PropertyValue::Integer(2),
PropertyId::BackgroundColor => PropertyValue::Color(Color::TRANSPARENT),
PropertyId::BackgroundImage => PropertyValue::None,
PropertyId::BackgroundRepeat => PropertyValue::Enum(EN_NORMAL),
PropertyId::BackgroundAttachment => PropertyValue::Enum(EN_SCROLL),
PropertyId::BackgroundPosition => PropertyValue::Auto,
PropertyId::BackgroundPositionHorizontal => PropertyValue::Length(Length::ZERO),
PropertyId::BackgroundPositionVertical => PropertyValue::Length(Length::ZERO),
PropertyId::Background => PropertyValue::Auto,
PropertyId::Visibility => PropertyValue::Enum(EN_VISIBLE),
PropertyId::Overflow => PropertyValue::Enum(EN_VISIBLE),
PropertyId::Clip => PropertyValue::Auto,
PropertyId::DisplayAlign => PropertyValue::Enum(EN_AUTO),
PropertyId::BaselineShift => PropertyValue::Enum(EN_BASELINE),
PropertyId::DominantBaseline => PropertyValue::Enum(EN_AUTO),
PropertyId::AlignmentBaseline => PropertyValue::Enum(EN_BASELINE),
PropertyId::AlignmentAdjust => PropertyValue::Enum(EN_AUTO),
PropertyId::VerticalAlign => PropertyValue::Enum(EN_BASELINE),
PropertyId::LineHeightShiftAdjustment => PropertyValue::Enum(EN_CONSIDER_SHIFTS),
PropertyId::LineStackingStrategy => PropertyValue::Enum(EN_LINE_HEIGHT),
PropertyId::TextAltitude => PropertyValue::Enum(EN_AUTO),
PropertyId::TextDepth => PropertyValue::Enum(EN_AUTO),
PropertyId::Direction => PropertyValue::Enum(EN_LTR),
PropertyId::UnicodeBidi => PropertyValue::Enum(EN_NORMAL),
PropertyId::Hyphenate => PropertyValue::Enum(EN_FALSE),
PropertyId::HyphenationCharacter => PropertyValue::String(Cow::Borrowed("-")),
PropertyId::HyphenationPushCharacterCount => PropertyValue::Integer(2),
PropertyId::HyphenationRemainCharacterCount => PropertyValue::Integer(2),
PropertyId::HyphenationLadderCount => PropertyValue::Enum(EN_AUTO),
PropertyId::HyphenationKeep => PropertyValue::Enum(EN_AUTO),
PropertyId::LeaderPattern => PropertyValue::Enum(EN_SPACE),
PropertyId::LeaderPatternWidth => PropertyValue::Enum(EN_AUTO),
PropertyId::LeaderLength => PropertyValue::Length(Length::ZERO),
PropertyId::LeaderAlignment => PropertyValue::Enum(EN_NONE),
PropertyId::RuleStyle => PropertyValue::Enum(EN_SOLID),
PropertyId::RuleThickness => PropertyValue::Length(Length::from_pt(1.0)),
PropertyId::Float => PropertyValue::Enum(EN_NONE),
PropertyId::Clear => PropertyValue::Enum(EN_NONE),
PropertyId::IntrusionDisplace => PropertyValue::Enum(EN_NONE),
PropertyId::ProvisionalDistanceBetweenStarts => {
PropertyValue::Length(Length::from_pt(24.0))
}
PropertyId::ProvisionalLabelSeparation => PropertyValue::Length(Length::from_pt(6.0)),
PropertyId::MarkerClassName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::RetrieveClassName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::RetrievePosition => PropertyValue::Enum(EN_FIRST_STARTING_WITHIN_PAGE),
PropertyId::RetrieveBoundary => PropertyValue::Enum(EN_PAGE_SEQUENCE),
PropertyId::RetrievePositionWithinTable => PropertyValue::Enum(EN_FIRST),
PropertyId::RetrieveBoundaryWithinTable => PropertyValue::Enum(EN_AUTO),
PropertyId::InitialPageNumber => PropertyValue::Enum(EN_AUTO),
PropertyId::ForcePageCount => PropertyValue::Enum(EN_AUTO),
PropertyId::Format => PropertyValue::String(Cow::Borrowed("1")),
PropertyId::LetterValue => PropertyValue::Enum(EN_AUTO),
PropertyId::GroupingSeparator => PropertyValue::String(Cow::Borrowed("")),
PropertyId::GroupingSize => PropertyValue::Integer(0),
PropertyId::PagePosition => PropertyValue::Enum(EN_ANY),
PropertyId::OddOrEven => PropertyValue::Enum(EN_ANY),
PropertyId::BlankOrNotBlank => PropertyValue::Enum(EN_ANY),
PropertyId::ExternalDestination => PropertyValue::String(Cow::Borrowed("")),
PropertyId::InternalDestination => PropertyValue::String(Cow::Borrowed("")),
PropertyId::IndicateDestination => PropertyValue::Enum(EN_FALSE),
PropertyId::ShowDestination => PropertyValue::Enum(EN_REPLACE),
PropertyId::DestinationPlacementOffset => PropertyValue::Length(Length::ZERO),
PropertyId::TargetPresentationContext => {
PropertyValue::Enum(EN_USE_TARGET_PROCESSING_CONTEXT)
}
PropertyId::TargetProcessingContext => PropertyValue::Enum(EN_DOCUMENT_ROOT),
PropertyId::TargetStylesheet => PropertyValue::Enum(EN_AUTO),
PropertyId::Id => PropertyValue::String(Cow::Borrowed("")),
PropertyId::RefId => PropertyValue::String(Cow::Borrowed("")),
PropertyId::RefIndexKey => PropertyValue::String(Cow::Borrowed("")),
PropertyId::IndexClass => PropertyValue::String(Cow::Borrowed("")),
PropertyId::IndexKey => PropertyValue::String(Cow::Borrowed("")),
PropertyId::MergePagesAcrossIndexKeyReferences => PropertyValue::Enum(EN_MERGE),
PropertyId::MergeRangesAcrossIndexKeyReferences => PropertyValue::Enum(EN_MERGE),
PropertyId::MergeSequentialPageNumbers => PropertyValue::Enum(EN_MERGE),
PropertyId::PageNumberTreatment => PropertyValue::Enum(EN_LINK),
PropertyId::PageCitationStrategy => PropertyValue::Enum(EN_NORMAL),
PropertyId::ChangeBarClass => PropertyValue::String(Cow::Borrowed("")),
PropertyId::ChangeBarColor => PropertyValue::Color(Color::BLACK),
PropertyId::ChangeBarOffset => PropertyValue::Length(Length::from_pt(6.0)),
PropertyId::ChangeBarPlacement => PropertyValue::Enum(EN_START),
PropertyId::ChangeBarStyle => PropertyValue::Enum(EN_SOLID),
PropertyId::ChangeBarWidth => PropertyValue::Length(Length::from_pt(1.0)),
PropertyId::ActiveState => PropertyValue::Enum(EN_LINK),
PropertyId::AutoRestore => PropertyValue::Enum(EN_FALSE),
PropertyId::CaseName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::CaseTitle => PropertyValue::String(Cow::Borrowed("")),
PropertyId::StartingState => PropertyValue::Enum(EN_SHOW),
PropertyId::SwitchTo => PropertyValue::String(Cow::Borrowed("")),
PropertyId::MediaUsage => PropertyValue::Enum(EN_AUTO),
PropertyId::RenderingIntent => PropertyValue::Enum(EN_AUTO),
PropertyId::ColorProfileName => PropertyValue::String(Cow::Borrowed("")),
PropertyId::Scaling => PropertyValue::Enum(EN_UNIFORM),
PropertyId::ScalingMethod => PropertyValue::Enum(EN_AUTO),
PropertyId::IntrinsicScaleValue => PropertyValue::Integer(100),
PropertyId::GlyphOrientationHorizontal => PropertyValue::Integer(0),
PropertyId::GlyphOrientationVertical => PropertyValue::Enum(EN_AUTO),
PropertyId::ScoreSpaces => PropertyValue::Enum(EN_TRUE),
PropertyId::SuppressAtLineBreak => PropertyValue::Enum(EN_AUTO),
PropertyId::TreatAsWordSpace => PropertyValue::Enum(EN_AUTO),
PropertyId::Span => PropertyValue::Enum(EN_NONE),
PropertyId::RelativeAlign => PropertyValue::Enum(EN_BEFORE),
PropertyId::Azimuth => PropertyValue::Enum(EN_CENTER),
PropertyId::CueAfter => PropertyValue::None,
PropertyId::CueBefore => PropertyValue::None,
PropertyId::Cue => PropertyValue::Auto,
PropertyId::Elevation => PropertyValue::Enum(EN_AUTO),
PropertyId::PauseAfter => PropertyValue::Length(Length::ZERO),
PropertyId::PauseBefore => PropertyValue::Length(Length::ZERO),
PropertyId::Pause => PropertyValue::Auto,
PropertyId::Pitch => PropertyValue::Enum(EN_AUTO),
PropertyId::PitchRange => PropertyValue::Integer(50),
PropertyId::PlayDuring => PropertyValue::Enum(EN_AUTO),
PropertyId::Richness => PropertyValue::Integer(50),
PropertyId::Speak => PropertyValue::Enum(EN_NORMAL),
PropertyId::SpeakHeader => PropertyValue::Enum(EN_AUTO),
PropertyId::SpeakNumeral => PropertyValue::Enum(EN_AUTO),
PropertyId::SpeakPunctuation => PropertyValue::Enum(EN_NONE),
PropertyId::SpeechRate => PropertyValue::Enum(EN_AUTO),
PropertyId::Stress => PropertyValue::Integer(50),
PropertyId::VoiceFamily => PropertyValue::String(Cow::Borrowed("")),
PropertyId::Volume => PropertyValue::Enum(EN_AUTO),
PropertyId::Character => PropertyValue::String(Cow::Borrowed("")),
PropertyId::ContentType => PropertyValue::Enum(EN_AUTO),
PropertyId::Country => PropertyValue::None,
PropertyId::Language => PropertyValue::None,
PropertyId::Script => PropertyValue::None,
PropertyId::Src => PropertyValue::String(Cow::Borrowed("")),
PropertyId::SourceDocument => PropertyValue::String(Cow::Borrowed("")),
PropertyId::Role => PropertyValue::String(Cow::Borrowed("")),
PropertyId::XmlLang => PropertyValue::String(Cow::Borrowed("")),
PropertyId::ZIndex => PropertyValue::Auto,
PropertyId::Opacity => PropertyValue::Number(1.0),
PropertyId::Size => PropertyValue::Enum(EN_AUTO),
PropertyId::MaximumRepeats => PropertyValue::Enum(EN_AUTO),
PropertyId::XWidowContentLimit => PropertyValue::Length(Length::ZERO),
PropertyId::XOrphanContentLimit => PropertyValue::Length(Length::ZERO),
PropertyId::XDisableColumnBalancing => PropertyValue::Enum(EN_FALSE),
PropertyId::XAltText => PropertyValue::String(Cow::Borrowed("")),
PropertyId::XXmlBase => PropertyValue::String(Cow::Borrowed("")),
PropertyId::XNumberConversionFeatures => PropertyValue::String(Cow::Borrowed("")),
PropertyId::XHeaderColumn => PropertyValue::Enum(EN_FALSE),
PropertyId::XLayer => PropertyValue::String(Cow::Borrowed("")),
PropertyId::XAutoToggle => PropertyValue::Enum(EN_AUTO),
PropertyId::XBackgroundImageWidth => PropertyValue::Auto,
PropertyId::XBackgroundImageHeight => PropertyValue::Auto,
PropertyId::XAbbreviation => PropertyValue::String(Cow::Borrowed("")),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_initial_color() {
let value = get_initial_value(PropertyId::Color);
assert_eq!(value.as_color(), Some(Color::BLACK));
}
#[test]
fn test_initial_font_family() {
let value = get_initial_value(PropertyId::FontFamily);
assert_eq!(value.as_string(), Some("serif"));
}
#[test]
fn test_initial_font_size() {
let value = get_initial_value(PropertyId::FontSize);
assert_eq!(value.as_length(), Some(Length::from_pt(12.0)));
}
#[test]
fn test_initial_margin_zero() {
let value = get_initial_value(PropertyId::MarginTop);
assert_eq!(value.as_length(), Some(Length::ZERO));
let value = get_initial_value(PropertyId::MarginLeft);
assert_eq!(value.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_padding_zero() {
let value = get_initial_value(PropertyId::PaddingTop);
assert_eq!(value.as_length(), Some(Length::ZERO));
let value = get_initial_value(PropertyId::PaddingLeft);
assert_eq!(value.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_border_style_none() {
let value = get_initial_value(PropertyId::BorderTopStyle);
assert_eq!(value.as_enum(), Some(EN_NONE));
}
#[test]
fn test_initial_border_width_medium() {
let value = get_initial_value(PropertyId::BorderTopWidth);
assert_eq!(value.as_length(), Some(Length::from_pt(1.0)));
}
#[test]
fn test_initial_border_color() {
let value = get_initial_value(PropertyId::BorderTopColor);
assert_eq!(value.as_color(), Some(Color::BLACK));
}
#[test]
fn test_initial_text_align() {
let value = get_initial_value(PropertyId::TextAlign);
assert_eq!(value.as_enum(), Some(EN_START));
}
#[test]
fn test_initial_text_indent() {
let value = get_initial_value(PropertyId::TextIndent);
assert_eq!(value.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_line_height() {
let value = get_initial_value(PropertyId::LineHeight);
assert_eq!(value.as_enum(), Some(EN_NORMAL));
}
#[test]
fn test_initial_width_auto() {
let value = get_initial_value(PropertyId::Width);
assert!(value.is_auto());
}
#[test]
fn test_initial_height_auto() {
let value = get_initial_value(PropertyId::Height);
assert!(value.is_auto());
}
#[test]
fn test_initial_table_layout() {
let value = get_initial_value(PropertyId::TableLayout);
assert_eq!(value.as_enum(), Some(EN_AUTO));
}
#[test]
fn test_initial_border_collapse() {
let value = get_initial_value(PropertyId::BorderCollapse);
assert_eq!(value.as_enum(), Some(EN_SEPARATE));
}
#[test]
fn test_initial_empty_cells() {
let value = get_initial_value(PropertyId::EmptyCells);
assert_eq!(value.as_enum(), Some(EN_SHOW));
}
#[test]
fn test_initial_visibility() {
let value = get_initial_value(PropertyId::Visibility);
assert_eq!(value.as_enum(), Some(EN_VISIBLE));
}
#[test]
fn test_initial_overflow() {
let value = get_initial_value(PropertyId::Overflow);
assert_eq!(value.as_enum(), Some(EN_VISIBLE));
}
#[test]
fn test_initial_background_color() {
let value = get_initial_value(PropertyId::BackgroundColor);
assert_eq!(value.as_color(), Some(Color::TRANSPARENT));
}
#[test]
fn test_initial_orphans() {
let value = get_initial_value(PropertyId::Orphans);
assert_eq!(value.as_integer(), Some(2));
}
#[test]
fn test_initial_widows() {
let value = get_initial_value(PropertyId::Widows);
assert_eq!(value.as_integer(), Some(2));
}
#[test]
fn test_initial_direction() {
let value = get_initial_value(PropertyId::Direction);
assert_eq!(value.as_enum(), Some(EN_LTR));
}
#[test]
fn test_initial_writing_mode() {
let value = get_initial_value(PropertyId::WritingMode);
assert_eq!(value.as_enum(), Some(EN_LR_TB));
}
#[test]
fn test_initial_hyphenate() {
let value = get_initial_value(PropertyId::Hyphenate);
assert_eq!(value.as_enum(), Some(EN_FALSE));
}
#[test]
fn test_initial_hyphenation_character() {
let value = get_initial_value(PropertyId::HyphenationCharacter);
assert_eq!(value.as_string(), Some("-"));
}
#[test]
fn test_initial_opacity() {
let value = get_initial_value(PropertyId::Opacity);
assert_eq!(value.as_number(), Some(1.0));
}
#[test]
fn test_initial_column_count() {
let value = get_initial_value(PropertyId::ColumnCount);
assert_eq!(value.as_integer(), Some(1));
}
#[test]
fn test_initial_z_index() {
let value = get_initial_value(PropertyId::ZIndex);
assert!(value.is_auto());
}
#[test]
fn test_all_properties_have_initial_values() {
let property_ids = [
PropertyId::AbsolutePosition,
PropertyId::ActiveState,
PropertyId::AlignmentAdjust,
PropertyId::AlignmentBaseline,
PropertyId::AutoRestore,
PropertyId::Azimuth,
PropertyId::Background,
PropertyId::BackgroundAttachment,
PropertyId::BackgroundColor,
PropertyId::BackgroundImage,
PropertyId::Color,
PropertyId::FontFamily,
PropertyId::FontSize,
PropertyId::MarginTop,
PropertyId::PaddingLeft,
PropertyId::BorderTopStyle,
PropertyId::Width,
PropertyId::Height,
PropertyId::TextAlign,
PropertyId::Visibility,
PropertyId::Opacity,
];
for prop_id in &property_ids {
let value = get_initial_value(*prop_id);
assert!(
!matches!(value, PropertyValue::Inherit),
"Initial value should not be Inherit for {:?}",
prop_id
);
}
}
#[test]
fn test_all_295_properties_have_initial_values() {
for id_num in 1..=295 {
let property_id: PropertyId = unsafe { std::mem::transmute(id_num as u16) };
let initial_value = get_initial_value(property_id);
assert!(
!matches!(initial_value, PropertyValue::Inherit),
"Property {:?} (ID {}) has Inherit as initial value, which is invalid",
property_id,
id_num
);
let _ = format!("{:?}", initial_value);
}
}
#[test]
fn test_comprehensive_initial_values() {
assert_eq!(
get_initial_value(PropertyId::MarginRight).as_length(),
Some(Length::ZERO)
);
assert_eq!(
get_initial_value(PropertyId::MarginBottom).as_length(),
Some(Length::ZERO)
);
assert_eq!(
get_initial_value(PropertyId::PaddingRight).as_length(),
Some(Length::ZERO)
);
assert_eq!(
get_initial_value(PropertyId::PaddingBottom).as_length(),
Some(Length::ZERO)
);
assert_eq!(
get_initial_value(PropertyId::PaddingBefore).as_length(),
Some(Length::ZERO)
);
assert_eq!(
get_initial_value(PropertyId::PaddingAfter).as_length(),
Some(Length::ZERO)
);
assert_eq!(
get_initial_value(PropertyId::BorderRightWidth).as_length(),
Some(Length::from_pt(1.0))
);
assert_eq!(
get_initial_value(PropertyId::BorderBeforeWidth).as_length(),
Some(Length::from_pt(1.0))
);
assert_eq!(
get_initial_value(PropertyId::BorderRightStyle).as_enum(),
Some(EN_NONE)
);
assert_eq!(
get_initial_value(PropertyId::BorderBottomStyle).as_enum(),
Some(EN_NONE)
);
assert_eq!(
get_initial_value(PropertyId::BorderRightColor).as_color(),
Some(Color::BLACK)
);
assert_eq!(
get_initial_value(PropertyId::BorderLeftColor).as_color(),
Some(Color::BLACK)
);
assert!(get_initial_value(PropertyId::MinWidth)
.as_length()
.is_some());
assert!(get_initial_value(PropertyId::MinHeight)
.as_length()
.is_some());
assert!(get_initial_value(PropertyId::MaxWidth).is_none());
assert!(get_initial_value(PropertyId::MaxHeight).is_none());
assert!(get_initial_value(PropertyId::KeepWithNext)
.as_enum()
.is_some());
assert!(get_initial_value(PropertyId::KeepWithPrevious)
.as_enum()
.is_some());
assert!(get_initial_value(PropertyId::BreakAfter)
.as_enum()
.is_some());
assert_eq!(
get_initial_value(PropertyId::NumberColumnsSpanned).as_integer(),
Some(1)
);
assert_eq!(
get_initial_value(PropertyId::NumberRowsSpanned).as_integer(),
Some(1)
);
assert_eq!(
get_initial_value(PropertyId::LetterSpacing).as_enum(),
Some(EN_NORMAL)
);
assert_eq!(
get_initial_value(PropertyId::WordSpacing).as_enum(),
Some(EN_NORMAL)
);
assert_eq!(
get_initial_value(PropertyId::HyphenationPushCharacterCount).as_integer(),
Some(2)
);
assert_eq!(
get_initial_value(PropertyId::HyphenationRemainCharacterCount).as_integer(),
Some(2)
);
}
}
#[cfg(test)]
mod additional_tests {
use super::*;
#[test]
fn test_initial_font_weight_is_normal() {
let v = get_initial_value(PropertyId::FontWeight);
assert_eq!(v.as_enum(), Some(EN_NORMAL));
}
#[test]
fn test_initial_font_style_is_normal() {
let v = get_initial_value(PropertyId::FontStyle);
assert_eq!(v.as_enum(), Some(EN_NORMAL));
}
#[test]
fn test_initial_letter_spacing_is_normal() {
let v = get_initial_value(PropertyId::LetterSpacing);
assert_eq!(v.as_enum(), Some(EN_NORMAL));
}
#[test]
fn test_initial_word_spacing_is_normal() {
let v = get_initial_value(PropertyId::WordSpacing);
assert_eq!(v.as_enum(), Some(EN_NORMAL));
}
#[test]
fn test_initial_direction_is_ltr() {
let v = get_initial_value(PropertyId::Direction);
assert_eq!(v.as_enum(), Some(EN_LTR));
}
#[test]
fn test_initial_writing_mode_is_lr_tb() {
let v = get_initial_value(PropertyId::WritingMode);
assert_eq!(v.as_enum(), Some(EN_LR_TB));
}
#[test]
fn test_initial_background_color_is_transparent() {
let v = get_initial_value(PropertyId::BackgroundColor);
assert!(v.as_color().is_some() || v.is_none() || v.is_auto());
}
#[test]
fn test_initial_border_top_style_is_none() {
let v = get_initial_value(PropertyId::BorderTopStyle);
assert_eq!(v.as_enum(), Some(EN_NONE));
}
#[test]
fn test_initial_border_bottom_style_is_none() {
let v = get_initial_value(PropertyId::BorderBottomStyle);
assert_eq!(v.as_enum(), Some(EN_NONE));
}
#[test]
fn test_initial_border_left_style_is_none() {
let v = get_initial_value(PropertyId::BorderLeftStyle);
assert_eq!(v.as_enum(), Some(EN_NONE));
}
#[test]
fn test_initial_border_right_style_is_none() {
let v = get_initial_value(PropertyId::BorderRightStyle);
assert_eq!(v.as_enum(), Some(EN_NONE));
}
#[test]
fn test_initial_padding_top_is_zero() {
let v = get_initial_value(PropertyId::PaddingTop);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_padding_bottom_is_zero() {
let v = get_initial_value(PropertyId::PaddingBottom);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_padding_left_is_zero() {
let v = get_initial_value(PropertyId::PaddingLeft);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_padding_right_is_zero() {
let v = get_initial_value(PropertyId::PaddingRight);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_margin_top_is_zero() {
let v = get_initial_value(PropertyId::MarginTop);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_margin_bottom_is_zero() {
let v = get_initial_value(PropertyId::MarginBottom);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_margin_left_is_zero() {
let v = get_initial_value(PropertyId::MarginLeft);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_margin_right_is_zero() {
let v = get_initial_value(PropertyId::MarginRight);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_visibility_is_visible() {
let v = get_initial_value(PropertyId::Visibility);
assert_eq!(v.as_enum(), Some(EN_VISIBLE));
}
#[test]
fn test_initial_overflow_is_visible() {
let v = get_initial_value(PropertyId::Overflow);
assert_eq!(v.as_enum(), Some(EN_VISIBLE));
}
#[test]
fn test_initial_column_count_is_one() {
let v = get_initial_value(PropertyId::ColumnCount);
assert_eq!(v.as_integer(), Some(1));
}
#[test]
fn test_initial_orphans_is_two() {
let v = get_initial_value(PropertyId::Orphans);
assert_eq!(v.as_integer(), Some(2));
}
#[test]
fn test_initial_widows_is_two() {
let v = get_initial_value(PropertyId::Widows);
assert_eq!(v.as_integer(), Some(2));
}
#[test]
fn test_initial_opacity_is_one() {
let v = get_initial_value(PropertyId::Opacity);
assert_eq!(v.as_number(), Some(1.0));
}
#[test]
fn test_initial_z_index_is_auto() {
let v = get_initial_value(PropertyId::ZIndex);
assert!(v.is_auto() || v.as_integer().is_some());
}
#[test]
fn test_initial_text_indent_is_zero() {
let v = get_initial_value(PropertyId::TextIndent);
assert_eq!(v.as_length(), Some(Length::ZERO));
}
#[test]
fn test_initial_line_height_is_normal() {
let v = get_initial_value(PropertyId::LineHeight);
assert_eq!(v.as_enum(), Some(EN_NORMAL));
}
#[test]
fn test_initial_width_is_auto() {
let v = get_initial_value(PropertyId::Width);
assert!(v.is_auto());
}
#[test]
fn test_initial_height_is_auto() {
let v = get_initial_value(PropertyId::Height);
assert!(v.is_auto());
}
#[test]
fn test_initial_text_align_is_start() {
let v = get_initial_value(PropertyId::TextAlign);
assert_eq!(v.as_enum(), Some(EN_START));
}
#[test]
fn test_initial_border_collapse_is_separate() {
let v = get_initial_value(PropertyId::BorderCollapse);
assert_eq!(v.as_enum(), Some(EN_SEPARATE));
}
#[test]
fn test_get_initial_value_does_not_panic_for_all_ids() {
let ids = [
PropertyId::AbsolutePosition,
PropertyId::BackgroundColor,
PropertyId::BorderTopStyle,
PropertyId::Color,
PropertyId::Direction,
PropertyId::FontFamily,
PropertyId::FontSize,
PropertyId::FontStyle,
PropertyId::FontWeight,
PropertyId::Height,
PropertyId::LineHeight,
PropertyId::MarginTop,
PropertyId::Opacity,
PropertyId::Overflow,
PropertyId::PaddingTop,
PropertyId::TextAlign,
PropertyId::TextIndent,
PropertyId::Visibility,
PropertyId::WhiteSpace,
PropertyId::Width,
PropertyId::WritingMode,
PropertyId::ZIndex,
];
for id in &ids {
let _ = get_initial_value(*id); }
}
}