package css_ast
import "github.com/evanw/esbuild/internal/css_ast"
Index ¶
- Variables
- func ComplexSelectorsEqual(a []ComplexSelector, b []ComplexSelector, check *CrossFileEqualityCheck) bool
- func HashComplexSelectors(hash uint32, selectors []ComplexSelector) uint32
- func HashRules(hash uint32, rules []Rule) uint32
- func HashTokens(hash uint32, tokens []Token) uint32
- func MaybeCorrectDeclarationTypo(text string) (string, bool)
- func RulesEqual(a []Rule, b []Rule, check *CrossFileEqualityCheck) bool
- func TokensAreCommaSeparated(tokens []Token) bool
- func TokensEqual(a []Token, b []Token, check *CrossFileEqualityCheck) bool
- func TokensEqualIgnoringWhitespace(a []Token, b []Token) bool
- type AST
- type Combinator
- type ComplexSelector
- func (s ComplexSelector) Clone() ComplexSelector
- func (sel ComplexSelector) ContainsNestingCombinator() bool
- func (a ComplexSelector) Equal(b ComplexSelector, check *CrossFileEqualityCheck) bool
- func (sel ComplexSelector) IsRelative() bool
- func (sel ComplexSelector) UsesPseudoElement() bool
- type Composes
- type CompoundSelector
- func (sel CompoundSelector) Clone() CompoundSelector
- func (sel CompoundSelector) IsInvalidBecauseEmpty() bool
- func (sel CompoundSelector) IsSingleAmpersand() bool
- func (sel CompoundSelector) Range() (r logger.Range)
- type CrossFileEqualityCheck
- type D
- type ImportConditions
- type ImportedComposesName
- type KeyframeBlock
- type NameToken
- type NamespacedName
- func (n NamespacedName) Clone() NamespacedName
- func (a NamespacedName) Equal(b NamespacedName) bool
- func (n NamespacedName) Range() logger.Range
- type NthIndex
- type PercentageFlags
- type PseudoClassKind
- type R
- type RAtCharset
- func (a *RAtCharset) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RAtCharset) Hash() (uint32, bool)
- type RAtImport
- func (*RAtImport) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RAtImport) Hash() (uint32, bool)
- type RAtKeyframes
- func (a *RAtKeyframes) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RAtKeyframes) Hash() (uint32, bool)
- type RAtLayer
- func (a *RAtLayer) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RAtLayer) Hash() (uint32, bool)
- type RBadDeclaration
- func (a *RBadDeclaration) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RBadDeclaration) Hash() (uint32, bool)
- type RComment
- func (a *RComment) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RComment) Hash() (uint32, bool)
- type RDeclaration
- func (a *RDeclaration) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RDeclaration) Hash() (uint32, bool)
- type RKnownAt
- func (a *RKnownAt) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RKnownAt) Hash() (uint32, bool)
- type RQualified
- func (a *RQualified) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RQualified) Hash() (uint32, bool)
- type RSelector
- func (a *RSelector) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RSelector) Hash() (uint32, bool)
- type RUnknownAt
- func (a *RUnknownAt) Equal(rule R, check *CrossFileEqualityCheck) bool
- func (r *RUnknownAt) Hash() (uint32, bool)
- type Rule
- type SS
- type SSAttribute
- func (ss *SSAttribute) Clone() SS
- func (a *SSAttribute) Equal(ss SS, check *CrossFileEqualityCheck) bool
- func (ss *SSAttribute) Hash() uint32
- type SSClass
- func (ss *SSClass) Clone() SS
- func (a *SSClass) Equal(ss SS, check *CrossFileEqualityCheck) bool
- func (ss *SSClass) Hash() uint32
- type SSHash
- func (ss *SSHash) Clone() SS
- func (a *SSHash) Equal(ss SS, check *CrossFileEqualityCheck) bool
- func (ss *SSHash) Hash() uint32
- type SSPseudoClass
- func (ss *SSPseudoClass) Clone() SS
- func (a *SSPseudoClass) Equal(ss SS, check *CrossFileEqualityCheck) bool
- func (ss *SSPseudoClass) Hash() uint32
- type SSPseudoClassWithSelectorList
- func (ss *SSPseudoClassWithSelectorList) Clone() SS
- func (a *SSPseudoClassWithSelectorList) Equal(ss SS, check *CrossFileEqualityCheck) bool
- func (ss *SSPseudoClassWithSelectorList) Hash() uint32
- type SubclassSelector
- type Token
- func CloneTokensWithImportRecords( tokensIn []Token, importRecordsIn []ast.ImportRecord, tokensOut []Token, importRecordsOut []ast.ImportRecord, ) ([]Token, []ast.ImportRecord)
- func CloneTokensWithoutImportRecords(tokensIn []Token) (tokensOut []Token)
- func (t Token) ClampedFractionForPercentage() (float64, bool)
- func (t Token) DimensionUnit() string
- func (t Token) DimensionUnitIsSafeLength() bool
- func (t Token) DimensionValue() string
- func (a Token) Equal(b Token, check *CrossFileEqualityCheck) bool
- func (a Token) EqualIgnoringWhitespace(b Token) bool
- func (t Token) IsAngle() bool
- func (t Token) IsOne() bool
- func (t Token) IsZero() bool
- func (t Token) NumberOrFractionForPercentage(percentReferenceRange float64, flags PercentageFlags) (float64, bool)
- func (t Token) PercentageValue() string
- func (t *Token) TurnLengthIntoNumberIfZero() bool
- func (t *Token) TurnLengthOrPercentageIntoNumberIfZero() bool
- type WhitespaceFlags
Variables ¶
Functions ¶
func ComplexSelectorsEqual ¶
func ComplexSelectorsEqual(a []ComplexSelector, b []ComplexSelector, check *CrossFileEqualityCheck) bool
func HashComplexSelectors ¶
func HashComplexSelectors(hash uint32, selectors []ComplexSelector) uint32
func HashRules ¶
func HashTokens ¶
func MaybeCorrectDeclarationTypo ¶
func RulesEqual ¶
func RulesEqual(a []Rule, b []Rule, check *CrossFileEqualityCheck) bool
func TokensAreCommaSeparated ¶
func TokensEqual ¶
func TokensEqual(a []Token, b []Token, check *CrossFileEqualityCheck) bool
func TokensEqualIgnoringWhitespace ¶
Types ¶
type AST ¶
type AST struct { Symbols []ast.Symbol CharFreq *ast.CharFreq ImportRecords []ast.ImportRecord Rules []Rule SourceMapComment logger.Span ApproximateLineCount int32 LocalSymbols []ast.LocRef LocalScope map[string]ast.LocRef GlobalScope map[string]ast.LocRef Composes map[ast.Ref]*Composes // These contain all layer names in the file. It can be used to replace the // layer-related side effects of importing this file. They are split into two // groups (those before and after "@import" rules) so that the linker can put // them in the right places. LayersPreImport [][]string LayersPostImport [][]string }
type Combinator ¶
type ComplexSelector ¶
type ComplexSelector struct { Selectors []CompoundSelector }
func (ComplexSelector) Clone ¶
func (s ComplexSelector) Clone() ComplexSelector
func (ComplexSelector) ContainsNestingCombinator ¶
func (sel ComplexSelector) ContainsNestingCombinator() bool
func (ComplexSelector) Equal ¶
func (a ComplexSelector) Equal(b ComplexSelector, check *CrossFileEqualityCheck) bool
func (ComplexSelector) IsRelative ¶
func (sel ComplexSelector) IsRelative() bool
func (ComplexSelector) UsesPseudoElement ¶
func (sel ComplexSelector) UsesPseudoElement() bool
type Composes ¶
type Composes struct { // Note that each of these can be either local or global. Local examples: // // .foo { composes: bar } // .bar { color: red } // // Global examples: // // .foo { composes: bar from global } // .foo :global { composes: bar } // .foo { :global { composes: bar } } // :global .bar { color: red } // Names []ast.LocRef // Each of these is local in another file. For example: // // .foo { composes: bar from "bar.css" } // .foo { composes: bar from url(bar.css) } // ImportedNames []ImportedComposesName // This tracks what CSS properties each class uses so that we can warn when // "composes" is used incorrectly to compose two classes from separate files // that declare the same CSS properties. Properties map[string]logger.Loc }
type CompoundSelector ¶
type CompoundSelector struct { TypeSelector *NamespacedName SubclassSelectors []SubclassSelector NestingSelectorLocs []logger.Loc // "&" vs. "&&" is different specificity Combinator Combinator // Optional, may be 0 // If this is true, this is a "&" that was generated by a bare ":local" or ":global" WasEmptyFromLocalOrGlobal bool }
func (CompoundSelector) Clone ¶
func (sel CompoundSelector) Clone() CompoundSelector
func (CompoundSelector) IsInvalidBecauseEmpty ¶
func (sel CompoundSelector) IsInvalidBecauseEmpty() bool
func (CompoundSelector) IsSingleAmpersand ¶
func (sel CompoundSelector) IsSingleAmpersand() bool
func (CompoundSelector) Range ¶
func (sel CompoundSelector) Range() (r logger.Range)
type CrossFileEqualityCheck ¶
type CrossFileEqualityCheck struct { ImportRecordsA []ast.ImportRecord ImportRecordsB []ast.ImportRecord Symbols ast.SymbolMap SourceIndexA uint32 SourceIndexB uint32 }
This is necessary when comparing tokens between two different files
func (*CrossFileEqualityCheck) RefsAreEquivalent ¶
type D ¶
type D uint16
const ( DUnknown D = iota DAlignContent DAlignItems DAlignSelf DAlignmentBaseline DAll DAnimation DAnimationDelay DAnimationDirection DAnimationDuration DAnimationFillMode DAnimationIterationCount DAnimationName DAnimationPlayState DAnimationTimingFunction DAppearance DBackdropFilter DBackfaceVisibility DBackground DBackgroundAttachment DBackgroundClip DBackgroundColor DBackgroundImage DBackgroundOrigin DBackgroundPosition DBackgroundPositionX DBackgroundPositionY DBackgroundRepeat DBackgroundSize DBaselineShift DBlockSize DBorder DBorderBlockEnd DBorderBlockEndColor DBorderBlockEndStyle DBorderBlockEndWidth DBorderBlockStart DBorderBlockStartColor DBorderBlockStartStyle DBorderBlockStartWidth DBorderBottom DBorderBottomColor DBorderBottomLeftRadius DBorderBottomRightRadius DBorderBottomStyle DBorderBottomWidth DBorderCollapse DBorderColor DBorderImage DBorderImageOutset DBorderImageRepeat DBorderImageSlice DBorderImageSource DBorderImageWidth DBorderInlineEnd DBorderInlineEndColor DBorderInlineEndStyle DBorderInlineEndWidth DBorderInlineStart DBorderInlineStartColor DBorderInlineStartStyle DBorderInlineStartWidth DBorderLeft DBorderLeftColor DBorderLeftStyle DBorderLeftWidth DBorderRadius DBorderRight DBorderRightColor DBorderRightStyle DBorderRightWidth DBorderSpacing DBorderStyle DBorderTop DBorderTopColor DBorderTopLeftRadius DBorderTopRightRadius DBorderTopStyle DBorderTopWidth DBorderWidth DBottom DBoxDecorationBreak DBoxShadow DBoxSizing DBreakAfter DBreakBefore DBreakInside DCaptionSide DCaretColor DClear DClip DClipPath DClipRule DColor DColorInterpolation DColorInterpolationFilters DColumnCount DColumnFill DColumnGap DColumnRule DColumnRuleColor DColumnRuleStyle DColumnRuleWidth DColumnSpan DColumnWidth DColumns DComposes DContainer DContainerName DContainerType DContent DCounterIncrement DCounterReset DCssFloat DCssText DCursor DDirection DDisplay DDominantBaseline DEmptyCells DFill DFillOpacity DFillRule DFilter DFlex DFlexBasis DFlexDirection DFlexFlow DFlexGrow DFlexShrink DFlexWrap DFloat DFloodColor DFloodOpacity DFont DFontFamily DFontFeatureSettings DFontKerning DFontSize DFontSizeAdjust DFontStretch DFontStyle DFontSynthesis DFontVariant DFontVariantCaps DFontVariantEastAsian DFontVariantLigatures DFontVariantNumeric DFontVariantPosition DFontWeight DGap DGlyphOrientationVertical DGrid DGridArea DGridAutoColumns DGridAutoFlow DGridAutoRows DGridColumn DGridColumnEnd DGridColumnGap DGridColumnStart DGridGap DGridRow DGridRowEnd DGridRowGap DGridRowStart DGridTemplate DGridTemplateAreas DGridTemplateColumns DGridTemplateRows DHeight DHyphens DImageOrientation DImageRendering DInitialLetter DInlineSize DInset DJustifyContent DJustifyItems DJustifySelf DLeft DLetterSpacing DLightingColor DLineBreak DLineHeight DListStyle DListStyleImage DListStylePosition DListStyleType DMargin DMarginBlockEnd DMarginBlockStart DMarginBottom DMarginInlineEnd DMarginInlineStart DMarginLeft DMarginRight DMarginTop DMarker DMarkerEnd DMarkerMid DMarkerStart DMask DMaskComposite DMaskImage DMaskOrigin DMaskPosition DMaskRepeat DMaskSize DMaskType DMaxBlockSize DMaxHeight DMaxInlineSize DMaxWidth DMinBlockSize DMinHeight DMinInlineSize DMinWidth DObjectFit DObjectPosition DOpacity DOrder DOrphans DOutline DOutlineColor DOutlineOffset DOutlineStyle DOutlineWidth DOverflow DOverflowAnchor DOverflowWrap DOverflowX DOverflowY DOverscrollBehavior DOverscrollBehaviorBlock DOverscrollBehaviorInline DOverscrollBehaviorX DOverscrollBehaviorY DPadding DPaddingBlockEnd DPaddingBlockStart DPaddingBottom DPaddingInlineEnd DPaddingInlineStart DPaddingLeft DPaddingRight DPaddingTop DPageBreakAfter DPageBreakBefore DPageBreakInside DPaintOrder DPerspective DPerspectiveOrigin DPlaceContent DPlaceItems DPlaceSelf DPointerEvents DPosition DPrintColorAdjust DQuotes DResize DRight DRotate DRowGap DRubyAlign DRubyPosition DScale DScrollBehavior DShapeRendering DStopColor DStopOpacity DStroke DStrokeDasharray DStrokeDashoffset DStrokeLinecap DStrokeLinejoin DStrokeMiterlimit DStrokeOpacity DStrokeWidth DTabSize DTableLayout DTextAlign DTextAlignLast DTextAnchor DTextCombineUpright DTextDecoration DTextDecorationColor DTextDecorationLine DTextDecorationSkip DTextDecorationStyle DTextEmphasis DTextEmphasisColor DTextEmphasisPosition DTextEmphasisStyle DTextIndent DTextJustify DTextOrientation DTextOverflow DTextRendering DTextShadow DTextSizeAdjust DTextTransform DTextUnderlinePosition DTop DTouchAction DTransform DTransformBox DTransformOrigin DTransformStyle DTransition DTransitionDelay DTransitionDuration DTransitionProperty DTransitionTimingFunction DTranslate DUnicodeBidi DUserSelect DVerticalAlign DVisibility DWhiteSpace DWidows DWidth DWillChange DWordBreak DWordSpacing DWordWrap DWritingMode DZIndex DZoom )
type ImportConditions ¶
type ImportConditions struct { // The syntax for "@import" has been extended with optional conditions that // behave as if the imported file was wrapped in a "@layer", "@supports", // and/or "@media" rule. The possible syntax combinations are as follows: // // @import url(...); // @import url(...) layer; // @import url(...) layer(layer-name); // @import url(...) layer(layer-name) supports(supports-condition); // @import url(...) layer(layer-name) supports(supports-condition) list-of-media-queries; // @import url(...) layer(layer-name) list-of-media-queries; // @import url(...) supports(supports-condition); // @import url(...) supports(supports-condition) list-of-media-queries; // @import url(...) list-of-media-queries; // // From: https://developer.mozilla.org/en-US/docs/Web/CSS/@import#syntax Media []Token // These two fields will only ever have zero or one tokens. However, they are // implemented as arrays for convenience because most of esbuild's helper // functions that operate on tokens take arrays instead of individual tokens. Layers []Token Supports []Token }
func (*ImportConditions) CloneWithImportRecords ¶
func (c *ImportConditions) CloneWithImportRecords(importRecordsIn []ast.ImportRecord, importRecordsOut []ast.ImportRecord) (ImportConditions, []ast.ImportRecord)
type ImportedComposesName ¶
type KeyframeBlock ¶
type KeyframeBlock struct { Selectors []string Rules []Rule Loc logger.Loc CloseBraceLoc logger.Loc }
type NameToken ¶
func (NameToken) Equal ¶
type NamespacedName ¶
type NamespacedName struct { // If present, this is an identifier or "*" and is followed by a "|" character NamespacePrefix *NameToken // This is an identifier or "*" Name NameToken }
func (NamespacedName) Clone ¶
func (n NamespacedName) Clone() NamespacedName
func (NamespacedName) Equal ¶
func (a NamespacedName) Equal(b NamespacedName) bool
func (NamespacedName) Range ¶
func (n NamespacedName) Range() logger.Range
type NthIndex ¶
This is the "An+B" syntax
func (*NthIndex) Minify ¶
func (index *NthIndex) Minify()
type PercentageFlags ¶
type PercentageFlags uint8
const ( AllowPercentageBelow0 PercentageFlags = 1 << iota AllowPercentageAbove100 AllowAnyPercentage = AllowPercentageBelow0 | AllowPercentageAbove100 )
type PseudoClassKind ¶
type PseudoClassKind uint8
const ( PseudoClassGlobal PseudoClassKind = iota PseudoClassHas PseudoClassIs PseudoClassLocal PseudoClassNot PseudoClassNthChild PseudoClassNthLastChild PseudoClassNthLastOfType PseudoClassNthOfType PseudoClassWhere )
func (PseudoClassKind) HasNthIndex ¶
func (kind PseudoClassKind) HasNthIndex() bool
func (PseudoClassKind) String ¶
func (kind PseudoClassKind) String() string
type R ¶
type R interface { Equal(rule R, check *CrossFileEqualityCheck) bool Hash() (uint32, bool) }
type RAtCharset ¶
type RAtCharset struct { Encoding string }
func (*RAtCharset) Equal ¶
func (a *RAtCharset) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RAtCharset) Hash ¶
func (r *RAtCharset) Hash() (uint32, bool)
type RAtImport ¶
type RAtImport struct { ImportConditions *ImportConditions ImportRecordIndex uint32 }
func (*RAtImport) Equal ¶
func (*RAtImport) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RAtImport) Hash ¶
type RAtKeyframes ¶
type RAtKeyframes struct { AtToken string Name ast.LocRef Blocks []KeyframeBlock CloseBraceLoc logger.Loc }
func (*RAtKeyframes) Equal ¶
func (a *RAtKeyframes) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RAtKeyframes) Hash ¶
func (r *RAtKeyframes) Hash() (uint32, bool)
type RAtLayer ¶
func (*RAtLayer) Equal ¶
func (a *RAtLayer) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RAtLayer) Hash ¶
type RBadDeclaration ¶
type RBadDeclaration struct { Tokens []Token }
func (*RBadDeclaration) Equal ¶
func (a *RBadDeclaration) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RBadDeclaration) Hash ¶
func (r *RBadDeclaration) Hash() (uint32, bool)
type RComment ¶
type RComment struct { Text string }
func (*RComment) Equal ¶
func (a *RComment) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RComment) Hash ¶
type RDeclaration ¶
type RDeclaration struct { KeyText string Value []Token KeyRange logger.Range Key D // Compare using this instead of "Key" for speed Important bool }
func (*RDeclaration) Equal ¶
func (a *RDeclaration) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RDeclaration) Hash ¶
func (r *RDeclaration) Hash() (uint32, bool)
type RKnownAt ¶
func (*RKnownAt) Equal ¶
func (a *RKnownAt) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RKnownAt) Hash ¶
type RQualified ¶
func (*RQualified) Equal ¶
func (a *RQualified) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RQualified) Hash ¶
func (r *RQualified) Hash() (uint32, bool)
type RSelector ¶
type RSelector struct { Selectors []ComplexSelector Rules []Rule CloseBraceLoc logger.Loc }
func (*RSelector) Equal ¶
func (a *RSelector) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RSelector) Hash ¶
type RUnknownAt ¶
func (*RUnknownAt) Equal ¶
func (a *RUnknownAt) Equal(rule R, check *CrossFileEqualityCheck) bool
func (*RUnknownAt) Hash ¶
func (r *RUnknownAt) Hash() (uint32, bool)
type Rule ¶
type SS ¶
type SS interface { Equal(ss SS, check *CrossFileEqualityCheck) bool Hash() uint32 Clone() SS }
type SSAttribute ¶
type SSAttribute struct { MatcherOp string // Either "" or one of: "=" "~=" "|=" "^=" "$=" "*=" MatcherValue string NamespacedName NamespacedName MatcherModifier byte // Either 0 or one of: 'i' 'I' 's' 'S' }
func (*SSAttribute) Clone ¶
func (ss *SSAttribute) Clone() SS
func (*SSAttribute) Equal ¶
func (a *SSAttribute) Equal(ss SS, check *CrossFileEqualityCheck) bool
func (*SSAttribute) Hash ¶
func (ss *SSAttribute) Hash() uint32
type SSClass ¶
func (*SSClass) Clone ¶
func (*SSClass) Equal ¶
func (a *SSClass) Equal(ss SS, check *CrossFileEqualityCheck) bool
func (*SSClass) Hash ¶
type SSHash ¶
func (*SSHash) Clone ¶
func (*SSHash) Equal ¶
func (a *SSHash) Equal(ss SS, check *CrossFileEqualityCheck) bool
func (*SSHash) Hash ¶
type SSPseudoClass ¶
type SSPseudoClass struct { Name string Args []Token IsElement bool // If true, this is prefixed by "::" instead of ":" }
func (*SSPseudoClass) Clone ¶
func (ss *SSPseudoClass) Clone() SS
func (*SSPseudoClass) Equal ¶
func (a *SSPseudoClass) Equal(ss SS, check *CrossFileEqualityCheck) bool
func (*SSPseudoClass) Hash ¶
func (ss *SSPseudoClass) Hash() uint32
type SSPseudoClassWithSelectorList ¶
type SSPseudoClassWithSelectorList struct { Selectors []ComplexSelector Index NthIndex Kind PseudoClassKind }
See https://drafts.csswg.org/selectors/#grouping
func (*SSPseudoClassWithSelectorList) Clone ¶
func (ss *SSPseudoClassWithSelectorList) Clone() SS
func (*SSPseudoClassWithSelectorList) Equal ¶
func (a *SSPseudoClassWithSelectorList) Equal(ss SS, check *CrossFileEqualityCheck) bool
func (*SSPseudoClassWithSelectorList) Hash ¶
func (ss *SSPseudoClassWithSelectorList) Hash() uint32
type SubclassSelector ¶
type Token ¶
type Token struct { // Contains the child tokens for component values that are simple blocks. // These are either "(", "{", "[", or function tokens. The closing token is // implicit and is not stored. Children *[]Token // 8 bytes // This is the raw contents of the token most of the time. However, it // contains the decoded string contents for "TString" tokens. Text string // 16 bytes // The source location at the start of the token Loc logger.Loc // 4 bytes // URL tokens have an associated import record at the top-level of the AST. // This index points to that import record. // // Symbol tokens have an associated symbol. This index is the "InnerIndex" // of the "Ref" for this symbol. The "SourceIndex" for the "Ref" is just // the source index of the file for this AST. PayloadIndex uint32 // 4 bytes // The division between the number and the unit for "TDimension" tokens. UnitOffset uint16 // 2 bytes // This will never be "TWhitespace" because whitespace isn't stored as a // token directly. Instead it is stored in "HasWhitespaceAfter" on the // previous token. This is to make it easier to pattern-match against // tokens when handling CSS rules, since whitespace almost always doesn't // matter. That way you can pattern match against e.g. "rgb(r, g, b)" and // not have to handle all possible combinations of embedded whitespace // tokens. // // There is one exception to this: when in verbatim whitespace mode and // the token list is non-empty and is only whitespace tokens. In that case // a single whitespace token is emitted. This is because otherwise there // would be no tokens to attach the whitespace before/after flags to. Kind css_lexer.T // 1 byte // These flags indicate the presence of a "TWhitespace" token before or after // this token. There should be whitespace printed between two tokens if either // token indicates that there should be whitespace. Note that whitespace may // be altered by processing in certain situations (e.g. minification). Whitespace WhitespaceFlags // 1 byte }
We create a lot of tokens, so make sure this layout is memory-efficient. The layout here isn't optimal because it biases for convenience (e.g. "string" could be shorter) but at least the ordering of fields was deliberately chosen to minimize size.
func CloneTokensWithImportRecords ¶
func CloneTokensWithImportRecords( tokensIn []Token, importRecordsIn []ast.ImportRecord, tokensOut []Token, importRecordsOut []ast.ImportRecord, ) ([]Token, []ast.ImportRecord)
func CloneTokensWithoutImportRecords ¶
func (Token) ClampedFractionForPercentage ¶
func (Token) DimensionUnit ¶
func (Token) DimensionUnitIsSafeLength ¶
func (Token) DimensionValue ¶
func (Token) Equal ¶
func (a Token) Equal(b Token, check *CrossFileEqualityCheck) bool
func (Token) EqualIgnoringWhitespace ¶
func (Token) IsAngle ¶
func (Token) IsOne ¶
func (Token) IsZero ¶
func (Token) NumberOrFractionForPercentage ¶
func (t Token) NumberOrFractionForPercentage(percentReferenceRange float64, flags PercentageFlags) (float64, bool)
func (Token) PercentageValue ¶
func (*Token) TurnLengthIntoNumberIfZero ¶
https://drafts.csswg.org/css-values-3/#lengths For zero lengths the unit identifier is optional (i.e. can be syntactically represented as the <number> 0).
func (*Token) TurnLengthOrPercentageIntoNumberIfZero ¶
type WhitespaceFlags ¶
type WhitespaceFlags uint8
const ( WhitespaceBefore WhitespaceFlags = 1 << iota WhitespaceAfter )
Source Files ¶
- Version
- v0.25.0 (latest)
- Published
- Feb 8, 2025
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 4 days ago –
Tools for package owners.