CSS::D...mitive(3pm)
π CSS::DOM::Value::Primitive β the CSSPrimitiveValue class for CSS::DOM π
okay bestie, welcome to the manual page for CSS::DOM::Value::Primitive β it's the CSSPrimitiveValue class for CSS::DOM, and it's from the User Contributed Perl Documentation, no cap. β¨
πΈ VERSION πΈ
Version 0.17 β she's giving established, she's giving stable, we love her for it. π
β¨ SYNOPSIS β¨
# ...
that's it. that's the synopsis. iconic minimalism, honestly. π«Ά
π¦ DESCRIPTION π¦
So like β this module makes objects that represent CSS primitive property values (as opposed to lists, which are a whole different girl). It implements the DOM CSSPrimitiveValue, Rect, and RGBColor interfaces. Three interfaces, one object, main character energy fr fr. π
π METHODS π
Okay so if you're looking for the constructor, it's down below the object methods, bestie β don't panic. Normally you don't even build one of these yourself; you'd get an object via CSS::DOM::Style's getPropertyCSSValue method.
π CSSValue Interface
cssTextβ Returns a string representation of the attribute. Pass an argument to set it. yes she's a getter AND a setter, versatile queen β¨cssValueTypeβ Returns"CSS::DOM::Value::CSS_PRIMITIVE_VALUE". That's the whole vibe check.
π CSSPrimitiveValue Interface
primitiveTypeβ Returns one of theCONSTANTSlisted below. βgetFloatValueβ Returns a number if the value is numeric. π’
The rest have still to be implemented. (she said "coming soon" and meant it π)
π Rect Interface
The four methods top, right, bottom and left each return another value object representing the individual value. four little baby value objects, one for each side, we stan a symmetrical household π«Ά
π§‘ RGBColor Interface
The four methods red, green, blue and alpha each return another value object representing the individual value. alpha included, because transparency is a lifestyle π
π₯ Constructor π₯
You probably don't need to call this, but here it is anyway, bestie:
$val = new CSS::DOM::Value::Primitive:: %args;
The hash-style arguments are as follows. Only type and value are required β everything else is a little extra seasoning. β¨
typeβ One of the constants listed below underCONSTANTS.valueβ The data stored inside the value object. The format expected depends on the type. See below. πcssβ CSS code used for serialisation. This will make readingcssTextfaster at least until the value is modified. (a little caching moment, we love efficiency)ownerβ The style object that owns this value; if this is omitted, then the value is read-only. The value object holds a weak reference to the owner. β οΈ no owner means no editing, so keep that in mind.propertyβ The name of the CSS property to which this value belongs.cssTextuses this to determine how to parse text passed to it. This does not apply to the sub-values of colours, counters and rects, but it does apply to individual elements of a list value.indexβ The index of this value within a list value (only applies to elements of a list, of course).formatβ This is used by sub-values of colours and rects. It determines how assignment tocssTextis handled. This uses the same syntax as the formats in CSS::DOM::PropertyParser.
π Here are the formats for the value argument, which depend on the type:
CSS_UNKNOWNβ A string of CSS code.CSS_NUMBER,CSS_PERCENTAGEβ A simple scalar containing a number.- Standard Dimensions β Also a simple scalar containing a number.
This applies to CSS_EMS, CSS_EXS, CSS_PX, CSS_CM, CSS_MM, CSS_IN, CSS_PT, CSS_PC, CSS_DEG, CSS_RAD, CSS_GRAD, CSS_MS, CSS_S, CSS_HZ and CSS_KHZ.
CSS_DIMENSIONβ An array ref:[$number, $unit_text]CSS_STRINGβ A simple scalar containing a string (not a CSS string literal; i.e., no quotes or escapes).CSS_URIβ The URL (not a CSS literal)CSS_IDENTβ A string (no escapes)CSS_ATTRβ A string containing the name of the attribute.CSS_COUNTERβ An array ref:[$name, $separator, $style]
$separator and $style may each be undef. If $separator is undef, the object represents a counter(...). Otherwise it represents counters(...). singular vs plural, the plot twist is real
CSS_RECTβ An array ref:[$top, $right, $bottom, $left]
The four elements are either CSSValue objects or array refs of arguments to be passed to the constructor. E.g.:
[
[type => CSS_PX, value => 20],
[type => CSS_PERCENTAGE, value => 50],
[type => CSS_PERCENTAGE, value => 50],
[type => CSS_PX, value => 50],
]
When these array refs are converted to objects, the format argument is supplied automatically, so you do not need to include it here. she handles that for you, bestie, no extra work required π«Ά
CSS_RGBCOLORβ A string beginning with'#', with no escapes (such as'#fff'or'#c0ffee'), a colour name (like red) or an array ref with three to four elements:
[$r, $g, $b]
[$r, $g, $b, $alpha]
The elements are either CSSValue objects or array refs of argument lists, as with CSS_RECT.
π CONSTANTS π
The following constants can be imported with use CSS::DOM::Value::Primitive ':all'. They represent the type of primitive value. twenty-six of them, and yes, we're listing every single one, because no constant gets left behind π
CSS_UNKNOWNCSS_NUMBERCSS_PERCENTAGECSS_EMSCSS_EXSCSS_PXCSS_CMCSS_MMCSS_INCSS_PTCSS_PCCSS_DEGCSS_RADCSS_GRADCSS_MSCSS_SCSS_HZCSS_KHZCSS_DIMENSIONCSS_STRINGCSS_URICSS_IDENTCSS_ATTRCSS_COUNTERCSS_RECTCSS_RGBCOLOR
π SEE ALSO π
CSS::DOMCSS::DOM::ValueCSS::DOM::Value::ListCSS::DOM::Style
go read those too, bestie, they're all part of the same friend group π¦
and that's the whole page, babes π This little love letter to primitive values came to you courtesy of perl v5.36.0, dated 2023-08-02, from the User Contributed Perl Documentation. mwah, stay slay, and may your cssText always parse on the first try π
β¨
π¦ where this page comes from
- debian trixie: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcss-dom-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms