Documentation
¶
Index ¶
- Constants
- Variables
- func CopyAnimatedProperties(dst *AnimationValue, src AnimationValue, properties AnimatedProperties)
- func EqualExceptOpacity(a, b *ComputedStyle) bool
- func HasContainerQueries(stylesheet *css.Stylesheet) bool
- func InterpolateAnimatedProperty(dst *AnimationValue, a, b AnimationValue, property AnimatedProperties, ...)
- func IsLength(value Value) bool
- func RecomputeInputStateInPlaceWithImpact(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, ChangeImpact, error)
- func RecomputeInputStateInPlaceWithImpactAndQueries(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, ChangeImpact, error)
- func RecomputeInputStateWithCache(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, ChangeImpact, error)
- func RecomputeInputStateWithChanges(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, ChangeImpact, error)
- func RecomputeSubtreesInPlaceWithImpact(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, ChangeImpact, error)
- func RecomputeSubtreesInPlaceWithImpactAndQueries(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, ChangeImpact, error)
- func ResolveAnimatedTranslation(value AnimationValue, width, height float64) (float64, float64)
- func ResolveLength(value Value, base float64) float64
- func SameAnimatedProperty(a, b AnimationValue, property AnimatedProperties) bool
- func ViewportAffectsStyles(root *uinode.Node, sheet *css.Stylesheet, before, after Viewport) bool
- type AnimatedProperties
- type AnimationColor
- type AnimationPoint
- type AnimationTrack
- type AnimationValue
- type BackgroundLayer
- type CSSAnimation
- type ChangeImpact
- type Color
- type ComputedStyle
- func (computed *ComputedStyle) Animations() []CSSAnimation
- func (computed *ComputedStyle) BackgroundLayer(index int) *BackgroundLayer
- func (computed *ComputedStyle) BackgroundLayerCount() int
- func (computed *ComputedStyle) HasMotion() bool
- func (computed *ComputedStyle) TransitionFor(index int) TransformTransition
- type ContainerMetrics
- type Corners
- type Cursor
- type Edges
- type Filter
- type FilterKind
- type FontStyle
- type Map
- func Compute(root *uinode.Node, stylesheet *css.Stylesheet) (Map, error)
- func ComputeWithCache(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, error)
- func ComputeWithState(root *uinode.Node, stylesheet *css.Stylesheet, input *css.State) (Map, error)
- func ComputeWithViewport(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport) (Map, error)
- func ComputeWithViewportAndState(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, error)
- func ComputeWithViewportAndStateAndQueries(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, error)
- func RecomputeSubtreesInPlaceWithViewportAndStateAndQueries(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, ...) (Map, error)
- type MutationCache
- type NodeChange
- type QueryEnvironment
- type Radius
- type Shadow
- type TimingFunction
- type TransformEasing
- type TransformTransition
- type Value
- type ValueKind
- type Viewport
Constants ¶
const ( AnimationForeground = iota AnimationBackground AnimationBorderTop AnimationBorderRight AnimationBorderBottom AnimationBorderLeft AnimatedColorCount )
const AnimatedBorders = AnimatedColors &^ (AnimatedColor | AnimatedBackgroundColor)
const AnimatedColors = AnimatedColor | AnimatedBackgroundColor | AnimatedBorderTopColor | AnimatedBorderRightColor | AnimatedBorderBottomColor | AnimatedBorderLeftColor
const AnimatedPropertyCount = 2 + AnimatedColorCount
Variables ¶
var AnimatedPropertyList = [...]AnimatedProperties{AnimatedTransform, AnimatedOpacity, AnimatedColor, AnimatedBackgroundColor, AnimatedBorderTopColor, AnimatedBorderRightColor, AnimatedBorderBottomColor, AnimatedBorderLeftColor}
Functions ¶
func CopyAnimatedProperties ¶
func CopyAnimatedProperties(dst *AnimationValue, src AnimationValue, properties AnimatedProperties)
func EqualExceptOpacity ¶
func EqualExceptOpacity(a, b *ComputedStyle) bool
EqualExceptOpacity identifies changes that can be applied to a composited group at draw time without repainting its contents.
func HasContainerQueries ¶
func HasContainerQueries(stylesheet *css.Stylesheet) bool
HasContainerQueries reports whether a stylesheet contains rules whose result depends on a laid-out ancestor. Callers can use it to avoid a second style/layout pass for ordinary media-only documents.
func InterpolateAnimatedProperty ¶
func InterpolateAnimatedProperty(dst *AnimationValue, a, b AnimationValue, property AnimatedProperties, t float64)
func RecomputeInputStateInPlaceWithImpact ¶
func RecomputeInputStateInPlaceWithImpact(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, previous, current *css.State, styles Map) (Map, ChangeImpact, error)
RecomputeInputStateInPlaceWithImpact visits the document once, recomputing only branches whose selector matches changed. Recomputing each affected branch also propagates inherited values to its descendants.
func RecomputeInputStateInPlaceWithImpactAndQueries ¶
func RecomputeInputStateInPlaceWithImpactAndQueries(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, previous, current *css.State, styles Map, queries *QueryEnvironment) (Map, ChangeImpact, error)
func RecomputeInputStateWithCache ¶
func RecomputeInputStateWithCache(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, previous, current *css.State, styles Map, cache *MutationCache) (Map, ChangeImpact, error)
RecomputeInputStateWithCache shares immutable styles with full and mutation cascades, so toggling back to a previous input state reuses its values.
func RecomputeInputStateWithChanges ¶
func RecomputeInputStateWithChanges(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, previous, current *css.State, styles Map, changes *[]NodeChange, cache *MutationCache) (Map, ChangeImpact, error)
RecomputeInputStateWithChanges emits changed styles during the input cascade. The caller owns and reuses the output slice, as with subtree mutations.
func RecomputeSubtreesInPlaceWithImpact ¶
func RecomputeSubtreesInPlaceWithImpact(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, input *css.State, queries *QueryEnvironment, previousStyles Map, roots []*uinode.Node) (Map, ChangeImpact, error)
func RecomputeSubtreesInPlaceWithImpactAndQueries ¶
func RecomputeSubtreesInPlaceWithImpactAndQueries(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, input *css.State, queries *QueryEnvironment, previousStyles Map, roots []*uinode.Node) (Map, ChangeImpact, error)
func ResolveAnimatedTranslation ¶
func ResolveAnimatedTranslation(value AnimationValue, width, height float64) (float64, float64)
func ResolveLength ¶
func SameAnimatedProperty ¶
func SameAnimatedProperty(a, b AnimationValue, property AnimatedProperties) bool
func ViewportAffectsStyles ¶ added in v0.1.8
ViewportAffectsStyles reports whether resizing can change the cascade or animation endpoints. Relative lengths only depend on their own viewport axis.
Types ¶
type AnimatedProperties ¶
type AnimatedProperties uint8
const ( AnimatedTransform AnimatedProperties = 1 << iota AnimatedOpacity AnimatedColor AnimatedBackgroundColor AnimatedBorderTopColor AnimatedBorderRightColor AnimatedBorderBottomColor AnimatedBorderLeftColor )
func AnimatedProperty ¶
func AnimatedProperty(name string) AnimatedProperties
type AnimationColor ¶
type AnimationColor struct {
R, G, B, A, Current float64
}
AnimationColor stores premultiplied, gamma-encoded sRGB. Current retains a currentcolor/inheritance contribution until the element's used color is known.
func ColorForAnimation ¶
func ColorForAnimation(value Value) AnimationColor
func (AnimationColor) Color ¶
func (c AnimationColor) Color() Color
func (AnimationColor) RGBA ¶
func (c AnimationColor) RGBA() (r, g, b, a float64)
func (AnimationColor) Resolve ¶
func (c AnimationColor) Resolve(reference AnimationColor) AnimationColor
type AnimationPoint ¶
type AnimationPoint struct {
Timing TimingFunction
Value AnimationValue
Offset float64
Properties AnimatedProperties
HasTiming bool
}
type AnimationTrack ¶
type AnimationTrack struct {
Points []AnimationPoint
Definition CSSAnimation
Properties AnimatedProperties
}
func CompileAnimationTracks ¶
func CompileAnimationTracks(node *uinode.Node, computed *ComputedStyle, stylesheet *css.Stylesheet, queries *QueryEnvironment) []AnimationTrack
CompileAnimationTracks resolves lengths once, outside the per-frame path. Tracks contain separate endpoints per property; omitted endpoints use the underlying style.
func (*AnimationTrack) Sample ¶
func (track *AnimationTrack) Sample(progress float64, base AnimationValue, before bool) AnimationValue
type AnimationValue ¶
type AnimationValue struct {
TranslateX, TranslateY Value
Colors [AnimatedColorCount]AnimationColor
Rotation float64
ScaleX, ScaleY float64
SkewX, TranslateCrossX, TranslateCrossY float64
Opacity float64
}
func BaseAnimationValue ¶
func BaseAnimationValue(computed *ComputedStyle) AnimationValue
type BackgroundLayer ¶
type CSSAnimation ¶
type CSSAnimation struct {
Name string
Direction, Fill string
Timing TimingFunction
Duration, Delay, Iterations float64
Paused bool
}
type ChangeImpact ¶
type ChangeImpact uint8
const ( ChangeNone ChangeImpact = iota ChangePaint // ChangeVisual changes generated paint primitives without changing geometry. ChangeVisual ChangeRebuild )
func RecomputeSubtreesWithChanges ¶
func RecomputeSubtreesWithChanges(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, input *css.State, styles Map, roots []*uinode.Node, changes *[]NodeChange, cache *MutationCache) (ChangeImpact, int, error)
RecomputeSubtreesWithChanges updates retained styles and emits changes during the same traversal. Roots must be disjoint and belong to the document.
type Color ¶
func ParseColor ¶
ParseColor parses an absolute CSS color. color-mix() currently supports the sRGB interpolation space; currentcolor requires an element's paint context.
type ComputedStyle ¶
type ComputedStyle struct {
// ExtraBackgroundLayers follows the primary inline Background layer.
ExtraBackgroundLayers []BackgroundLayer
BoxShadow []Shadow
Filters []Filter
// contains filtered or unexported fields
}
func (*ComputedStyle) Animations ¶
func (computed *ComputedStyle) Animations() []CSSAnimation
Animations returns immutable animation definitions shared by computed styles.
func (*ComputedStyle) BackgroundLayer ¶
func (computed *ComputedStyle) BackgroundLayer(index int) *BackgroundLayer
BackgroundLayer returns a borrowed layer. Interned styles must not be mutated.
func (*ComputedStyle) BackgroundLayerCount ¶
func (computed *ComputedStyle) BackgroundLayerCount() int
BackgroundLayerCount includes the primary layer, whose image may be none.
func (*ComputedStyle) HasMotion ¶
func (computed *ComputedStyle) HasMotion() bool
func (*ComputedStyle) TransitionFor ¶
func (computed *ComputedStyle) TransitionFor(index int) TransformTransition
type ContainerMetrics ¶
type Cursor ¶ added in v0.1.4
type Cursor uint8
Cursor stores a computed CSS keyword in one byte rather than a full Value. The first keyword is the initial value, auto.
type Filter ¶
type Filter struct {
Shadow Shadow
Matrix [20]float64
Kind FilterKind
Amount float64
}
type FilterKind ¶
type FilterKind int
const ( FilterBlur FilterKind = iota FilterBrightness FilterOpacity FilterContrast FilterGrayscale FilterSaturate FilterSepia FilterInvert FilterHueRotate FilterColorMatrix FilterDropShadow )
type FontStyle ¶
type FontStyle uint8
FontStyle is compact because every computed style stores this inherited value.
type Map ¶
type Map map[*uinode.Node]*ComputedStyle
Map stores one computed style per node. ComputedStyle is a large (~5.5KB) struct, so it is shared by pointer: layout boxes and paint fragments reference the same instance instead of copying it per node. The cascade interns equal instances, so many nodes point at one allocation.
func ComputeWithCache ¶
func ComputeWithCache(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, input *css.State, styles Map, cache *MutationCache) (Map, error)
ComputeWithCache replaces the complete node map while retaining its storage and a bounded index of immutable styles. Equal values can be shared even after DOM nodes are replaced. The caller must invalidate filter definitions when their content changes, as for partial recomputation.
func ComputeWithState ¶
func ComputeWithViewport ¶
func ComputeWithViewportAndStateAndQueries ¶
func ComputeWithViewportAndStateAndQueries(root *uinode.Node, stylesheet *css.Stylesheet, viewport Viewport, input *css.State, queries *QueryEnvironment) (Map, error)
type MutationCache ¶
type MutationCache struct {
ContainerMetrics map[*uinode.Node]ContainerMetrics
// contains filtered or unexported fields
}
MutationCache retains document resources across full and partial updates. DOM content/attribute changes other than class/style must invalidate definitions.
func (*MutationCache) InvalidateDefinitions ¶
func (cache *MutationCache) InvalidateDefinitions()
func (*MutationCache) NeedsDocumentStyle ¶
func (cache *MutationCache) NeedsDocumentStyle(stylesheet *css.Stylesheet) bool
NeedsDocumentStyle reports dependencies which cannot be bounded to a changed attribute's descendant branch. Unknown pseudo classes are deliberately conservative so extending the selector engine cannot silently stale styles.
func (*MutationCache) NeedsSiblingStyle ¶
func (cache *MutationCache) NeedsSiblingStyle(stylesheet *css.Stylesheet) bool
type NodeChange ¶
type NodeChange struct {
Node *uinode.Node
// Tree changes box membership, order or positioning dependencies.
Tree bool
// Reorder means order is the only changed tree property; other non-tree
// style changes may be present and still require normal layout/paint work.
Reorder bool
Impact ChangeImpact
}
NodeChange records the result of the cascade, rather than the mutation that triggered it. The caller owns and reuses the output slice.
type QueryEnvironment ¶
type QueryEnvironment struct {
ContainerMetrics map[*uinode.Node]ContainerMetrics
Styles Map
Viewport Viewport
}
type TimingFunction ¶
type TimingFunction struct {
Jump string
X1, Y1, X2, Y2 float64
Steps int
Kind TransformEasing
}
TimingFunction is a compiled CSS easing function. Sampling allocates nothing.
func ParseTimingFunction ¶
func ParseTimingFunction(input string) (TimingFunction, bool)
type TransformEasing ¶
type TransformEasing uint8
const ( TransformEase TransformEasing = iota TransformLinear TransformEaseIn TransformEaseOut TransformEaseInOut )
const ( TransformCubicBezier TransformEasing = TransformEaseInOut + 1 + iota TransformSteps )
type TransformTransition ¶
type TransformTransition struct {
Timing TimingFunction
Duration float64
Delay float64
Enabled bool
}
type Value ¶
type Value struct {
Keyword string
LengthPx float64
Percent float64
Number float64
Color Color
Kind ValueKind
}