Documentation
¶
Overview ¶
Package style matches CSS rules and computes values for DOM elements.
Index ¶
- Constants
- func ApplyColorFilters(color uint32, filters []Filter) uint32
- func BlendColors(source, backdrop uint32, mode BlendMode) uint32
- func FilterSurfaceAllowed(width, height float32) bool
- func InterpolateColor(from, to uint32, progress float64) uint32
- func InterpolateOpacity(from, to float32, progress float64) float32
- func MatchesMediaQueryList(queries []css.MediaQuery, environment Environment) bool
- func MatchesSelector(node *dom.Node, selector css.Selector, state InteractionState) bool
- type Align
- type AnimatedValues
- type AnimationDamage
- type AnimationDirection
- type AnimationFillMode
- type AnimationPlayState
- type AnimationRegistry
- func (registry *AnimationRegistry) Active(current time.Time) bool
- func (registry *AnimationRegistry) ActiveNodes(current time.Time) []dom.NodeID
- func (registry *AnimationRegistry) AnimatedStyles(underlying Map, stylesheet *css.Stylesheet, current time.Time) Map
- func (registry *AnimationRegistry) Clear()
- func (registry *AnimationRegistry) Count(nodeID dom.NodeID) int
- func (registry *AnimationRegistry) Reconcile(styles Map, current time.Time)
- func (registry *AnimationRegistry) Sample(nodeID dom.NodeID, current time.Time) []SampledAnimation
- func (registry *AnimationRegistry) Total() int
- type AnimationSample
- type AnimationStack
- type Appearance
- type AutoEdges
- type BackgroundBox
- type BackgroundImage
- type BackgroundImageKind
- type BackgroundLayer
- type BackgroundPosition
- type BackgroundRepeat
- type BackgroundSize
- type BackgroundSizeKind
- type BlendMode
- type BorderCollapse
- type BorderRadii
- type BorderSide
- type BorderStyle
- type Borders
- type BoxSizing
- type CSSAnimation
- type CaptionSide
- type Clear
- type ColumnFill
- type ColumnSpan
- type ComputedStyle
- type ContainerSize
- type ContainerType
- type Cursor
- type Direction
- type Display
- type Edges
- type Environment
- type Filter
- type FilterKind
- type FlexBasis
- type FlexBasisKind
- type FlexDirection
- type FlexWrap
- type Float
- type FragmentBreak
- type GradientStop
- type GridArea
- type GridAutoFlow
- type GridAutoRepeat
- type GridLine
- type GridPlacement
- type GridTrackKind
- type GridTrackSize
- type Insets
- type InteractionState
- type JustifyContent
- type LengthContext
- type LengthPercentage
- type ListStylePosition
- type ListStyleType
- type Map
- type Matrix
- type ObjectFit
- type Overflow
- type OverflowAlignment
- type OverflowWrap
- type Position
- type RadiusValue
- type RunningAnimation
- type RunningTransition
- type SampledAnimation
- type Shadow
- type SizeKind
- type SizeValue
- type StartedTransition
- type TableLayout
- type TextAlign
- type TextDecorationLine
- type TextOverflow
- type TextTransform
- type TransformFunction
- type TransformFunctionKind
- type Transition
- type TransitionRegistry
- func (registry *TransitionRegistry) Active(current time.Time) bool
- func (registry *TransitionRegistry) ActiveNodes(current time.Time) []dom.NodeID
- func (registry *TransitionRegistry) Apply(styles Map, current time.Time) Map
- func (registry *TransitionRegistry) Clear()
- func (registry *TransitionRegistry) Count(nodeID dom.NodeID) int
- func (registry *TransitionRegistry) Reconcile(previous, next Map, current time.Time)
- type TransitionValue
- type TransitionValueKind
- type VerticalAlign
- type VerticalAlignKind
- type Visibility
- type WhiteSpace
- type WordBreak
- type WritingMode
Constants ¶
const ( // MaxAnimationsPerElement bounds comma-list work and retained state. MaxAnimationsPerElement = 32 // MaxActiveAnimations bounds running Animation state for one page. MaxActiveAnimations = 4096 )
const ( MaxFilterFunctions = 16 MaxFilterRadius = float32(100) MaxFilterSurface = float32(16 * 1024 * 1024) )
const BrowserUAStylesheetVersion = "growse-browser-ua-v1"
BrowserUAStylesheetVersion is recorded separately from application CSS so a visual baseline can identify exactly which defaults participated in Cascade.
Variables ¶
This section is empty.
Functions ¶
func ApplyColorFilters ¶ added in v0.15.0
ApplyColorFilters applies the color-only portion of a filter chain to a solid paint color. Geometry filters remain on the display command.
func BlendColors ¶ added in v0.15.0
BlendColors composites a solid source against a solid backdrop using the supported mix-blend-mode subset. It is also used by deterministic tests and the renderer fallback when no offscreen backend is available.
func FilterSurfaceAllowed ¶ added in v0.15.0
FilterSurfaceAllowed is shared by layout and paint to avoid allocating or requesting unbounded offscreen surfaces.
func InterpolateColor ¶
InterpolateColor blends packed RRGGBBAA colors in premultiplied sRGB space.
func InterpolateOpacity ¶
InterpolateOpacity returns the linear interpolation of two computed opacity values. The used value remains in opacity's valid range even when an easing function produces an overshooting progress value.
func MatchesMediaQueryList ¶ added in v0.15.0
func MatchesMediaQueryList(queries []css.MediaQuery, environment Environment) bool
MatchesMediaQueryList evaluates one comma-separated query list.
func MatchesSelector ¶ added in v0.15.0
MatchesSelector exposes the style engine's selector semantics to DOM APIs.
Types ¶
type Align ¶
type Align uint8
Align controls cross-axis alignment. AlignAuto is only valid for align-self.
type AnimatedValues ¶
type AnimatedValues map[string]TransitionValue
AnimatedValues stores sampled values by CSS property name.
type AnimationDamage ¶ added in v0.16.0
type AnimationDamage uint8
AnimationDamage classifies the most expensive rendering stage that a sampled animation frame must update.
const ( AnimationDamageNone AnimationDamage = iota AnimationDamageComposite AnimationDamagePaint AnimationDamageLayout )
func ClassifyAnimationDamage ¶ added in v0.16.0
func ClassifyAnimationDamage(underlying, sampled Map) AnimationDamage
ClassifyAnimationDamage compares immutable computed styles with one sampled frame. Transform and opacity can be composited over cached geometry, colors need paint-command updates, and every other computed change requires layout.
type AnimationDirection ¶
type AnimationDirection uint8
AnimationDirection controls iteration playback direction.
const ( AnimationNormal AnimationDirection = iota AnimationReverse AnimationAlternate AnimationAlternateReverse )
type AnimationFillMode ¶
type AnimationFillMode uint8
AnimationFillMode controls the effect before and after active time.
const ( AnimationFillNone AnimationFillMode = iota AnimationFillForwards AnimationFillBackwards AnimationFillBoth )
type AnimationPlayState ¶
type AnimationPlayState uint8
AnimationPlayState controls whether an animation advances.
const ( AnimationRunning AnimationPlayState = iota AnimationPaused )
type AnimationRegistry ¶
type AnimationRegistry struct {
// contains filtered or unexported fields
}
AnimationRegistry owns the running animation list for every styled element. Reconcile is called after style recalculation so DOM and interaction changes update animation definitions without restarting an unchanged animation.
func NewAnimationRegistry ¶
func NewAnimationRegistry() *AnimationRegistry
NewAnimationRegistry creates an empty element animation registry.
func (*AnimationRegistry) Active ¶
func (registry *AnimationRegistry) Active(current time.Time) bool
Active reports whether an animation can change on a future frame.
func (*AnimationRegistry) ActiveNodes ¶ added in v0.16.0
func (registry *AnimationRegistry) ActiveNodes(current time.Time) []dom.NodeID
ActiveNodes returns elements whose animation can change on a future frame. The result is bounded even if a corrupted registry bypasses reconciliation.
func (*AnimationRegistry) AnimatedStyles ¶
func (registry *AnimationRegistry) AnimatedStyles(underlying Map, stylesheet *css.Stylesheet, current time.Time) Map
AnimatedStyles samples all registered keyframe animations and composites them over the immutable underlying computed styles.
func (*AnimationRegistry) Clear ¶
func (registry *AnimationRegistry) Clear()
Clear discards every running animation owned by the page.
func (*AnimationRegistry) Count ¶
func (registry *AnimationRegistry) Count(nodeID dom.NodeID) int
Count reports the executable animation count for one element.
func (*AnimationRegistry) Reconcile ¶
func (registry *AnimationRegistry) Reconcile(styles Map, current time.Time)
Reconcile updates running animations from newly computed styles.
func (*AnimationRegistry) Sample ¶
func (registry *AnimationRegistry) Sample(nodeID dom.NodeID, current time.Time) []SampledAnimation
Sample evaluates the animations attached to one element.
func (*AnimationRegistry) Total ¶
func (registry *AnimationRegistry) Total() int
Total reports the number of running animations retained for the page.
type AnimationSample ¶
type AnimationSample struct {
Phase animationmodel.Phase
Progress float64
Iteration uint64
Applies bool
}
AnimationSample is one CSS animation's directed and eased progress.
type AnimationStack ¶
type AnimationStack struct {
// contains filtered or unexported fields
}
AnimationStack executes the comma-separated animation list of one element in source order. Later entries remain later in the returned samples so they can override earlier entries for the same property.
func NewAnimationStack ¶
func NewAnimationStack(animations []CSSAnimation, start time.Time) *AnimationStack
NewAnimationStack starts every named animation on one shared timestamp.
func (*AnimationStack) Len ¶
func (stack *AnimationStack) Len() int
Len reports the number of executable named animations.
func (*AnimationStack) Sample ¶
func (stack *AnimationStack) Sample(current time.Time) []SampledAnimation
Sample evaluates every animation using the same timestamp and preserves comma-list order.
type Appearance ¶ added in v0.15.0
type Appearance uint8
Appearance controls native form-control chrome.
const ( AppearanceAuto Appearance = iota AppearanceNone )
type AutoEdges ¶
type AutoEdges struct {
Top, Right, Bottom, Left bool
}
AutoEdges records which margins have the auto keyword.
type BackgroundBox ¶ added in v0.17.0
type BackgroundBox uint8
BackgroundBox selects the border, padding, or content box used by a layer.
const ( BackgroundBoxBorder BackgroundBox = iota BackgroundBoxPadding BackgroundBoxContent )
type BackgroundImage ¶
type BackgroundImage struct {
Kind BackgroundImageKind
URL string
GradientAngle float32
GradientStops []GradientStop
GradientCenter BackgroundPosition
RadialCircle bool
}
BackgroundImage is either one URL image or one linear gradient.
type BackgroundImageKind ¶
type BackgroundImageKind uint8
BackgroundImageKind identifies the single background layer supported by Growse.
const ( BackgroundImageNone BackgroundImageKind = iota BackgroundImageURL BackgroundImageLinearGradient BackgroundImageRadialGradient BackgroundImageConicGradient )
type BackgroundLayer ¶
type BackgroundLayer struct {
Image BackgroundImage
Repeat BackgroundRepeat
Position BackgroundPosition
Size BackgroundSize
Origin BackgroundBox
Clip BackgroundBox
}
BackgroundLayer groups one image with its layer-specific placement values.
type BackgroundPosition ¶
type BackgroundPosition struct {
X LengthPercentage
Y LengthPercentage
}
BackgroundPosition is a position inside the background positioning area.
type BackgroundRepeat ¶
BackgroundRepeat stores repetition independently for each axis.
type BackgroundSize ¶
type BackgroundSize struct {
Kind BackgroundSizeKind
Width SizeValue
Height SizeValue
}
BackgroundSize contains the size of the single background layer.
type BackgroundSizeKind ¶
type BackgroundSizeKind uint8
BackgroundSizeKind identifies automatic, intrinsic-ratio, or explicit sizing.
const ( BackgroundSizeAuto BackgroundSizeKind = iota BackgroundSizeCover BackgroundSizeContain BackgroundSizeExplicit )
type BlendMode ¶ added in v0.15.0
type BlendMode uint8
BlendMode is the fixture-supported mix-blend-mode subset.
type BorderCollapse ¶ added in v0.19.0
type BorderCollapse uint8
BorderCollapse selects separated or shared table cell borders.
const ( BorderCollapseSeparate BorderCollapse = iota BorderCollapseCollapse )
type BorderRadii ¶
type BorderRadii struct {
TopLeft RadiusValue
TopRight RadiusValue
BottomRight RadiusValue
BottomLeft RadiusValue
}
BorderRadii contains corner radii in clockwise order.
type BorderSide ¶
type BorderSide struct {
Width float32
Style BorderStyle
Color uint32
}
BorderSide contains the computed width, style and color of one side.
type BorderStyle ¶
type BorderStyle uint8
BorderStyle is the line style of one border side.
const ( BorderNone BorderStyle = iota BorderSolid BorderDotted BorderDashed BorderDouble )
type Borders ¶
type Borders struct {
Top BorderSide
Right BorderSide
Bottom BorderSide
Left BorderSide
}
Borders contains border sides in CSS clockwise order.
type BoxSizing ¶
type BoxSizing uint8
BoxSizing controls whether declared sizes include padding and border.
type CSSAnimation ¶
type CSSAnimation struct {
Name string
Timing animation.Timing
Iterations float64
Direction AnimationDirection
FillMode AnimationFillMode
PlayState AnimationPlayState
}
CSSAnimation is one computed entry from the animation property lists.
func (CSSAnimation) Sample ¶
func (item CSSAnimation) Sample(start, current time.Time) AnimationSample
Sample evaluates delay, iteration count, direction, fill mode, and easing.
type CaptionSide ¶ added in v0.19.0
type CaptionSide uint8
CaptionSide places a table caption before or after the row grid.
const ( CaptionSideTop CaptionSide = iota CaptionSideBottom )
type Clear ¶ added in v0.17.0
type Clear uint8
Clear moves a box below preceding floats on the selected side.
type ColumnFill ¶ added in v0.19.0
type ColumnFill uint8
ColumnFill selects sequential or balanced multi-column fragmentation.
const ( ColumnFillBalance ColumnFill = iota ColumnFillAuto )
type ColumnSpan ¶ added in v0.19.0
type ColumnSpan uint8
ColumnSpan controls whether an in-flow block interrupts every column.
const ( ColumnSpanNone ColumnSpan = iota ColumnSpanAll )
type ComputedStyle ¶
type ComputedStyle struct {
// BrowserDefaults marks styles computed with the JavaScript-only browser
// compatibility UA profile. Layout uses it to select the initial
// containing-block behavior without changing the Go Engine defaults.
BrowserDefaults bool
Color uint32
BackgroundColor uint32
BackgroundImage BackgroundImage
BackgroundRepeat BackgroundRepeat
BackgroundPos BackgroundPosition
BackgroundSize BackgroundSize
BackgroundLayers []BackgroundLayer
BackgroundOrigin BackgroundBox
BackgroundClip BackgroundBox
FontSize float32
FontWeight int
FontFamilies []string
FontStyle string
FontStretch string
FontFaceIndex int
LineHeight float32
LineHeightNumber float32
LineHeightUnitless bool
WhiteSpace WhiteSpace
WritingMode WritingMode
Direction Direction
TextAlign TextAlign
TextTransform TextTransform
TextIndent LengthPercentage
LetterSpacing float32
WordSpacing float32
WordBreak WordBreak
OverflowWrap OverflowWrap
VerticalAlign VerticalAlign
TextOverflow TextOverflow
ObjectFit ObjectFit
ObjectPosition BackgroundPosition
ListStyleType ListStyleType
ListStylePosition ListStylePosition
ListStyleImage string
Appearance Appearance
AccentColor uint32
AccentColorAuto bool
Cursor Cursor
Filters []Filter
BackdropFilters []Filter
MixBlendMode BlendMode
OverflowX Overflow
OverflowY Overflow
Display Display
TableLayout TableLayout
BorderCollapse BorderCollapse
BorderSpacingX float32
BorderSpacingY float32
CaptionSide CaptionSide
Float Float
Clear Clear
ContainerType ContainerType
ContainerName string
Visibility Visibility
FlexDirection FlexDirection
FlexWrap FlexWrap
JustifyContent JustifyContent
JustifyContentSafety OverflowAlignment
AlignItems Align
AlignItemsSafety OverflowAlignment
JustifyItems Align
JustifyItemsSafety OverflowAlignment
AlignContent Align
AlignContentSafety OverflowAlignment
Order int
FlexGrow float32
FlexShrink float32
FlexBasis FlexBasis
AlignSelf Align
AlignSelfSafety OverflowAlignment
JustifySelf Align
JustifySelfSafety OverflowAlignment
RowGap LengthPercentage
RowGapNormal bool
ColumnGap LengthPercentage
ColumnGapNormal bool
ColumnCount int
ColumnWidth SizeValue
ColumnRule BorderSide
ColumnFill ColumnFill
ColumnSpan ColumnSpan
BreakBefore FragmentBreak
BreakAfter FragmentBreak
BreakInside FragmentBreak
Widows int
Orphans int
GridTemplateColumns []GridTrackSize
GridTemplateRows []GridTrackSize
GridColumnsSubgrid bool
GridRowsSubgrid bool
GridAutoColumns []GridTrackSize
GridAutoRows []GridTrackSize
GridColumnLines map[string][]int
GridRowLines map[string][]int
GridTemplateAreas map[string]GridArea
GridColumn GridPlacement
GridRow GridPlacement
GridAreaName string
GridAutoFlow GridAutoFlow
Position Position
Inset Insets
ZIndex int
ZIndexAuto bool
BoxShadows []Shadow
TextShadows []Shadow
Outline BorderSide
OutlineOffset float32
Transform []TransformFunction
TransformOrigin BackgroundPosition
AspectRatio float32
BoxSizing BoxSizing
Width SizeValue
Height SizeValue
MinWidth SizeValue
MinHeight SizeValue
MaxWidth SizeValue
MaxHeight SizeValue
Margin Edges
MarginAuto AutoEdges
Padding Edges
Border Borders
BorderRadius BorderRadii
TextDecoration TextDecorationLine
DecorationColor uint32
Opacity float32
Transitions []Transition
Animations []CSSAnimation
ImportantProperties map[string]bool
BeforeContent string
AfterContent string
CustomProperties map[string]string
}
ComputedStyle contains the MVP properties consumed by layout and paint.
func ApplyAnimatedCascade ¶
func ApplyAnimatedCascade(underlying ComputedStyle, animations, transitions AnimatedValues) ComputedStyle
ApplyAnimatedCascade composites sampled CSS Animation and Transition values over an underlying computed style. CSS Animations override normal author declarations, author !important overrides Animations, and Transitions override both. The underlying style is not modified.
func ApplyAnimationSample ¶
func ApplyAnimationSample(underlying ComputedStyle, values AnimatedValues, sample AnimationSample) ComputedStyle
ApplyAnimationSample applies an animation effect only while its timing and fill mode say the effect participates in the cascade.
func (ComputedStyle) Bold ¶
func (s ComputedStyle) Bold() bool
Bold reports whether the computed weight should use a bold face.
func (ComputedStyle) Important ¶
func (s ComputedStyle) Important(property string) bool
Important reports whether the winning author declaration for property was marked !important.
type ContainerSize ¶ added in v0.15.0
type ContainerSize struct{ Width, Height float32 }
ContainerSize is the previous layout iteration's content-box size.
type ContainerType ¶ added in v0.15.0
type ContainerType uint8
ContainerType identifies size containment exposed to @container queries.
const ( ContainerTypeNormal ContainerType = iota ContainerTypeInlineSize )
type Display ¶
type Display uint8
Display controls whether an element participates in block or inline layout.
const ( DisplayInline Display = iota DisplayBlock DisplayInlineBlock DisplayNone DisplayFlex DisplayInlineFlex DisplayGrid DisplayInlineGrid DisplayContents DisplayTable DisplayTableRowGroup DisplayTableRow DisplayTableCell DisplayTableCaption DisplayTableColumnGroup DisplayTableColumn DisplayFlowRoot )
type Environment ¶
type Environment struct {
ViewportWidth float32
ViewportHeight float32
RootFontSize float32
ResolutionDPI float32
ColorScheme string
Hover bool
Pointer string
ReducedMotion bool
ContainerSizes map[dom.NodeID]ContainerSize
ContainerWidth float32
ContainerHeight float32
// BrowserDefaults enables the versioned browser-compatible UA stylesheet.
// Browser callers only set this for an explicitly selected JavaScript Engine.
BrowserDefaults bool
}
Environment contains rendering metrics needed during value computation.
type Filter ¶ added in v0.15.0
type Filter struct {
Kind FilterKind
Amount float32
Angle float32
Radius float32
Shadow Shadow
}
Filter is one validated filter function. Amount is a normalized scalar, Angle uses degrees, Radius uses CSS px, and Shadow is used by drop-shadow.
type FilterKind ¶ added in v0.15.0
type FilterKind uint8
FilterKind identifies a supported bounded CSS filter function.
const ( FilterBlur FilterKind = iota FilterBrightness FilterContrast FilterGrayscale FilterHueRotate FilterInvert FilterOpacity FilterSaturate FilterSepia FilterDropShadow )
type FlexBasis ¶
type FlexBasis struct {
Kind FlexBasisKind
Value LengthPercentage
}
FlexBasis retains percentages until the flex container size is known.
type FlexBasisKind ¶
type FlexBasisKind uint8
FlexBasisKind identifies an automatic, content-based, or sized flex basis.
const ( FlexBasisAuto FlexBasisKind = iota FlexBasisContent FlexBasisLength )
type FlexDirection ¶
type FlexDirection uint8
FlexDirection defines the main axis and its direction.
const ( FlexDirectionRow FlexDirection = iota FlexDirectionRowReverse FlexDirectionColumn FlexDirectionColumnReverse )
type Float ¶ added in v0.17.0
type Float uint8
Float places a box at a side of the current block formatting context.
type FragmentBreak ¶ added in v0.19.0
type FragmentBreak uint8
FragmentBreak is the bounded screen-fragmentation subset shared by the break-before, break-after, and break-inside properties.
const ( FragmentBreakAuto FragmentBreak = iota FragmentBreakAvoid FragmentBreakColumn FragmentBreakAvoidColumn )
type GradientStop ¶
GradientStop is one color stop in a linear gradient. Position is normalized to the [0, 1] range after omitted stops have been distributed.
type GridArea ¶
type GridArea struct {
RowStart, RowEnd, ColumnStart, ColumnEnd int
}
GridArea is a zero-based half-open rectangle derived from grid-template-areas.
type GridAutoFlow ¶
GridAutoFlow selects the auto-placement major axis and optional backfilling.
type GridAutoRepeat ¶
type GridAutoRepeat uint8
GridAutoRepeat identifies repeat(auto-fill, ...) and repeat(auto-fit, ...).
const ( GridAutoRepeatNone GridAutoRepeat = iota GridAutoRepeatFill GridAutoRepeatFit )
type GridPlacement ¶
GridPlacement stores the two edges of one grid axis.
type GridTrackKind ¶
type GridTrackKind uint8
GridTrackKind identifies the sizing function used by one grid track.
const ( GridTrackAuto GridTrackKind = iota GridTrackLength GridTrackFraction GridTrackMinContent GridTrackMaxContent GridTrackAutoRepeat )
type GridTrackSize ¶
type GridTrackSize struct {
Kind GridTrackKind
Value LengthPercentage
Flex float32
MinKind GridTrackKind
MinValue LengthPercentage
MinSet bool
FitLimit *LengthPercentage
AutoRepeat GridAutoRepeat
RepeatPattern []GridTrackSize
}
GridTrackSize retains track sizing values until the grid container is laid out.
type Insets ¶
type Insets struct {
Top, Right, Bottom, Left SizeValue
}
Insets stores the four computed inset properties; SizeAuto means auto.
type InteractionState ¶
type InteractionState struct {
Hovered map[dom.NodeID]bool
Focused dom.NodeID
FocusVisible bool
Scope dom.NodeID
Document *dom.Document
}
InteractionState contains transient browser state used by selector matching.
type JustifyContent ¶
type JustifyContent uint8
JustifyContent distributes free space on the main axis.
const ( JustifyFlexStart JustifyContent = iota JustifyFlexEnd JustifyStart JustifyEnd JustifyLeft JustifyRight JustifyCenter JustifySpaceBetween JustifySpaceAround JustifySpaceEvenly )
type LengthContext ¶
type LengthContext struct {
FontSize float32
RootFontSize float32
ViewportWidth float32
ViewportHeight float32
PercentageBase float32
ContainerWidth float32
ContainerHeight float32
}
LengthContext contains the bases needed to resolve CSS length units.
type LengthPercentage ¶
LengthPercentage preserves the percentage component until a basis is known.
func ResolveLength ¶
func ResolveLength(value string, context LengthContext) (LengthPercentage, bool)
ResolveLength parses and resolves a CSS3 length or percentage.
func (LengthPercentage) Resolve ¶
func (value LengthPercentage) Resolve(percentageBase float32) float32
Resolve converts a length-percentage to CSS pixels for a concrete basis.
type ListStylePosition ¶ added in v0.15.0
type ListStylePosition uint8
ListStylePosition controls whether a marker is inside or outside the item.
const ( ListStyleOutside ListStylePosition = iota ListStyleInside )
type ListStyleType ¶ added in v0.15.0
type ListStyleType uint8
ListStyleType is the bounded marker subset used by framework fixtures.
const ( ListStyleDisc ListStyleType = iota ListStyleCircle ListStyleSquare ListStyleDecimal ListStyleNone )
type Map ¶
type Map map[dom.NodeID]ComputedStyle
Map stores computed styles by DOM NodeID.
func Compute ¶
func Compute(document *dom.Document, stylesheet *css.Stylesheet) Map
Compute applies UA defaults, inheritance, selector matching and cascade.
func ComputeWithEnvironment ¶
func ComputeWithEnvironment(document *dom.Document, stylesheet *css.Stylesheet, state InteractionState, environment Environment) Map
ComputeWithEnvironment applies styles using interaction and viewport state.
func ComputeWithState ¶
func ComputeWithState(document *dom.Document, stylesheet *css.Stylesheet, state InteractionState) Map
ComputeWithState applies styles using transient browser interaction state.
type Matrix ¶
type Matrix struct {
A, B, C, D, E, F float32
}
Matrix is a CSS 2D affine matrix [A C E; B D F; 0 0 1].
func IdentityMatrix ¶
func IdentityMatrix() Matrix
func ResolveTransform ¶
func ResolveTransform(functions []TransformFunction, width, height float32) Matrix
type ObjectFit ¶ added in v0.15.0
type ObjectFit uint8
ObjectFit selects how replaced content maps into its content box.
type Overflow ¶
type Overflow uint8
Overflow controls clipping and scroll-container creation on one axis.
type OverflowAlignment ¶ added in v0.19.0
type OverflowAlignment uint8
OverflowAlignment selects fallback behavior when the alignment subject is larger than its alignment container.
const ( OverflowAlignmentDefault OverflowAlignment = iota OverflowAlignmentSafe OverflowAlignmentUnsafe )
type OverflowWrap ¶ added in v0.15.0
type OverflowWrap uint8
OverflowWrap controls whether an otherwise unbreakable word may wrap.
const ( OverflowWrapNormal OverflowWrap = iota OverflowWrapBreakWord OverflowWrapAnywhere )
type Position ¶
type Position uint8
Position selects normal, offset, out-of-flow, viewport, or sticky positioning.
type RadiusValue ¶
type RadiusValue struct {
X LengthPercentage
Y LengthPercentage
}
RadiusValue is one possibly elliptical corner radius.
type RunningAnimation ¶
type RunningAnimation struct {
Animation CSSAnimation
StartTime time.Time
// contains filtered or unexported fields
}
RunningAnimation tracks pause time separately from the CSS timing values.
func NewRunningAnimation ¶
func NewRunningAnimation(animation CSSAnimation, start time.Time) *RunningAnimation
NewRunningAnimation creates an animation whose timeline begins at start.
func (*RunningAnimation) Pause ¶
func (running *RunningAnimation) Pause(current time.Time)
Pause holds the current progress. Repeated calls have no effect.
func (*RunningAnimation) Paused ¶
func (running *RunningAnimation) Paused() bool
Paused reports whether timeline progress is currently held.
func (*RunningAnimation) Resume ¶
func (running *RunningAnimation) Resume(current time.Time)
Resume continues from the held progress. Repeated calls have no effect.
func (*RunningAnimation) Sample ¶
func (running *RunningAnimation) Sample(current time.Time) AnimationSample
Sample returns progress without advancing time while paused.
type RunningTransition ¶
type RunningTransition struct {
StartedTransition
StartTime time.Time
Current TransitionValue
ReversingAdjustedStart TransitionValue
ReversingShorteningFactor float64
}
RunningTransition retains the state needed to sample and interrupt one CSS transition without writing animated values back to author style.
func NewRunningTransition ¶
func NewRunningTransition(started StartedTransition, frameTime time.Time) *RunningTransition
NewRunningTransition starts a transition at frameTime.
func (*RunningTransition) Advance ¶
func (running *RunningTransition) Advance(frameTime time.Time) (TransitionValue, bool)
Advance samples the current value and reports whether the transition remains active.
func (*RunningTransition) Interrupt ¶
func (running *RunningTransition) Interrupt(frameTime time.Time, target TransitionValue, timing animation.Timing)
Interrupt starts a replacement transition from the currently displayed value. Returning to the reversing-adjusted start shortens the new duration.
type SampledAnimation ¶
type SampledAnimation struct {
Name string
Sample AnimationSample
}
SampledAnimation associates a named list entry with its current sample.
type SizeKind ¶
type SizeKind uint8
SizeKind identifies auto, a length-percentage, or an unbounded maximum.
type SizeValue ¶
type SizeValue struct {
Kind SizeKind
Value LengthPercentage
}
SizeValue is a computed sizing property which still may contain a percentage.
type StartedTransition ¶
type StartedTransition struct {
NodeID dom.NodeID
Property string
From TransitionValue
To TransitionValue
Timing animation.Timing
}
StartedTransition describes a transition created by a computed-style change.
func StartTransitions ¶
func StartTransitions(previous, next Map) []StartedTransition
StartTransitions compares two computed-style snapshots and creates the transitions selected by the new snapshot. It does not mutate either map.
type TableLayout ¶ added in v0.19.0
type TableLayout uint8
TableLayout selects the automatic or first-row fixed table sizing algorithm.
const ( TableLayoutAuto TableLayout = iota TableLayoutFixed )
type TextAlign ¶ added in v0.15.0
type TextAlign uint8
TextAlign controls inline content alignment in a line box.
type TextDecorationLine ¶
type TextDecorationLine uint8
TextDecorationLine is a bit set of line decorations.
const ( TextDecorationNone TextDecorationLine = 0 TextDecorationUnderline TextDecorationLine = 1 << 0 TextDecorationOverline TextDecorationLine = 1 << 1 TextDecorationLineThrough TextDecorationLine = 1 << 2 )
type TextOverflow ¶ added in v0.15.0
type TextOverflow uint8
TextOverflow controls the marker painted for clipped single-line text.
const ( TextOverflowClip TextOverflow = iota TextOverflowEllipsis )
type TextTransform ¶ added in v0.15.0
type TextTransform uint8
TextTransform controls the case transformation applied before shaping.
const ( TextTransformNone TextTransform = iota TextTransformUppercase TextTransformLowercase TextTransformCapitalize )
type TransformFunction ¶
type TransformFunction struct {
Kind TransformFunctionKind
X, Y LengthPercentage
A, B, C, D, E, F float32
}
TransformFunction retains percentage translations until box geometry is known.
func InterpolateTransform ¶
func InterpolateTransform(from, to []TransformFunction, progress float64, width, height float32) []TransformFunction
InterpolateTransform interpolates two computed 2D transform lists. Missing functions are padded with the corresponding identity function. When the function kinds differ, the remaining suffixes are resolved and interpolated through decomposed affine matrices.
type TransformFunctionKind ¶
type TransformFunctionKind uint8
TransformFunctionKind identifies a parsed CSS 2D transform function.
const ( TransformTranslate TransformFunctionKind = iota TransformScale TransformRotate TransformSkew TransformMatrix )
type Transition ¶
Transition is one computed CSS transition matched to a property.
type TransitionRegistry ¶
type TransitionRegistry struct {
// contains filtered or unexported fields
}
TransitionRegistry owns the transitions started by computed-style changes on one page. Author styles remain immutable while sampled values are composited at frame time.
func NewTransitionRegistry ¶
func NewTransitionRegistry() *TransitionRegistry
NewTransitionRegistry creates an empty page transition registry.
func (*TransitionRegistry) Active ¶
func (registry *TransitionRegistry) Active(current time.Time) bool
Active reports whether a transition can change on a future frame.
func (*TransitionRegistry) ActiveNodes ¶ added in v0.16.0
func (registry *TransitionRegistry) ActiveNodes(current time.Time) []dom.NodeID
ActiveNodes returns elements with a transition that can change later.
func (*TransitionRegistry) Apply ¶
func (registry *TransitionRegistry) Apply(styles Map, current time.Time) Map
Apply samples transitions and composites them after CSS Animations.
func (*TransitionRegistry) Clear ¶
func (registry *TransitionRegistry) Clear()
Clear discards every running transition owned by the page.
type TransitionValue ¶
type TransitionValue struct {
Kind TransitionValueKind
Number float32
Color uint32
Transform []TransformFunction
Length LengthPercentage
}
TransitionValue is one supported computed value captured at a style change.
type TransitionValueKind ¶
type TransitionValueKind uint8
TransitionValueKind identifies the representation used for interpolation.
const ( TransitionNumber TransitionValueKind = iota TransitionColor TransitionTransform TransitionLength )
type VerticalAlign ¶ added in v0.15.0
type VerticalAlign struct {
Kind VerticalAlignKind
Value float32
}
VerticalAlign stores either a keyword or a computed length. Positive lengths raise the inline box, as defined by CSS vertical-align.
type VerticalAlignKind ¶ added in v0.15.0
type VerticalAlignKind uint8
VerticalAlignKind identifies the inline-axis alignment mode.
const ( VerticalAlignBaseline VerticalAlignKind = iota VerticalAlignSub VerticalAlignSuper VerticalAlignMiddle VerticalAlignTextTop VerticalAlignTextBottom VerticalAlignTop VerticalAlignBottom VerticalAlignLength )
type Visibility ¶
type Visibility uint8
Visibility controls painting and hit testing while preserving layout.
const ( VisibilityVisible Visibility = iota VisibilityHidden )
type WhiteSpace ¶
type WhiteSpace uint8
WhiteSpace controls collapsing, newline preservation and wrapping.
const ( WhiteSpaceNormal WhiteSpace = iota WhiteSpaceNowrap WhiteSpacePre WhiteSpacePreWrap WhiteSpacePreLine )
type WordBreak ¶ added in v0.15.0
type WordBreak uint8
WordBreak controls emergency break opportunities inside words.
type WritingMode ¶ added in v0.19.0
type WritingMode uint8
WritingMode defines the physical direction of the inline and block axes.
const ( WritingModeHorizontalTB WritingMode = iota WritingModeVerticalRL WritingModeVerticalLR )
Source Files
¶
- animation.go
- animation_damage.go
- background.go
- browser_ua.go
- calc.go
- cascade.go
- color.go
- columns.go
- computed.go
- container.go
- effects.go
- engine.go
- flex.go
- font.go
- grid.go
- interpolation.go
- keyframe_effect.go
- length.go
- logical.go
- media.go
- position.go
- supports.go
- table.go
- transform.go
- transition.go
- transition_registry.go
- typography.go
- visual.go
- writing.go