Documentation
¶
Overview ¶
Package layout builds a simple visual tree from the Growse DOM.
Index ¶
- func ApplyAnimatedStyles(tree *Tree, styles stylemodel.Map)
- func HitTest(tree *Tree, x, y float32) (dom.NodeID, bool)
- type BorderRadii
- type Box
- type ClipRegion
- type CornerRadius
- type Decoration
- type Hit
- type PaintEntry
- type Rect
- type StackingContext
- type TextRun
- type Tree
- func Build(document *dom.Document, computed stylemodel.Map, viewportWidth float32) *Tree
- func BuildAtRevision(document *dom.Document, computed stylemodel.Map, viewportWidth float32, ...) *Tree
- func BuildWithScroll(document *dom.Document, computed stylemodel.Map, ...) *Tree
- func BuildWithScrollAtRevision(document *dom.Document, computed stylemodel.Map, ...) *Tree
- func BuildWithViewport(document *dom.Document, computed stylemodel.Map, ...) *Tree
- func Clone(tree *Tree) *Tree
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyAnimatedStyles ¶
func ApplyAnimatedStyles(tree *Tree, styles stylemodel.Map)
ApplyAnimatedStyles applies paint and hit-test state to an existing layout tree without changing its geometry. Paint.Build and HitTest consequently observe the exact same transform matrix.
Types ¶
type BorderRadii ¶
type BorderRadii struct {
TopLeft, TopRight, BottomRight, BottomLeft CornerRadius
}
BorderRadii contains resolved radii in clockwise order.
type Box ¶
type Box struct {
Order int
StackingID int
NodeID dom.NodeID
Tag string
Text string
Input bool
Multiline bool
Select bool
Options []forms.Option
Selected int
Checkable bool
Checked bool
InputType string
Disabled bool
ReadOnly bool
Button bool
X float32
Y float32
Width float32
Height float32
Baseline float32
Clip *Rect
Clips []ClipRegion
Opacity float32
FontSize float32
Bold bool
Color uint32
Background uint32
Decoration stylemodel.TextDecorationLine
DecorationColor uint32
TextShadows []stylemodel.Shadow
Transform stylemodel.Matrix
Hidden bool
Runs []TextRun
}
Box is one line of visible page content.
type ClipRegion ¶
type ClipRegion struct {
Rect
Radius BorderRadii
}
ClipRegion is one nested rectangular or rounded clipping boundary.
type CornerRadius ¶
type CornerRadius struct{ X, Y float32 }
CornerRadius is one resolved elliptical radius in CSS pixels.
type Decoration ¶
type Decoration struct {
Order int
StackingID int
NodeID dom.NodeID
Rect
Background uint32
Image stylemodel.BackgroundImage
Layers []stylemodel.BackgroundLayer
Repeat stylemodel.BackgroundRepeat
Position stylemodel.BackgroundPosition
Size stylemodel.BackgroundSize
Border stylemodel.Borders
Radius BorderRadii
Opacity float32
Clip *Rect
Clips []ClipRegion
BoxShadows []stylemodel.Shadow
Outline stylemodel.BorderSide
OutlineOffset float32
Transform stylemodel.Matrix
Hidden bool
}
Decoration is the border-box visual of one element. It is kept separately from line boxes so backgrounds can be painted before descendant content.
type PaintEntry ¶
PaintEntry references one visual in final forward paint order.
type Rect ¶
type Rect struct {
X, Y, Width, Height float32
}
Rect is a document-coordinate clipping rectangle.
type StackingContext ¶
type StackingContext struct {
Parent int
NodeID dom.NodeID
ZIndex int
Order int
Opacity float32
Offscreen bool
}
StackingContext records atomic paint-order ownership.
type TextRun ¶
type TextRun struct {
NodeID dom.NodeID
Tag string
Text string
Width float32
FontSize float32
Bold bool
Color uint32
Background uint32
Baseline float32
Decoration stylemodel.TextDecorationLine
DecorationColor uint32
Opacity float32
TextShadows []stylemodel.Shadow
}
TextRun is a continuously styled fragment inside one line box.
type Tree ¶
type Tree struct {
Revision uint64
Width float32
Height float32
Background uint32
Decorations []Decoration
Boxes []Box
ScrollWidth float32
ScrollHeight float32
StackingContexts []StackingContext
Parents map[dom.NodeID]dom.NodeID
Bounds map[dom.NodeID]Rect
}
Tree is the result of laying out one document at a specific viewport width.
func BuildAtRevision ¶ added in v0.14.0
func BuildAtRevision(document *dom.Document, computed stylemodel.Map, viewportWidth float32, revision uint64) *Tree
BuildAtRevision lays out one immutable DOM/style revision.
func BuildWithScroll ¶
func BuildWithScroll(document *dom.Document, computed stylemodel.Map, viewportWidth, viewportHeight, scrollX, scrollY float32) *Tree
BuildWithScroll lays out viewport-attached and sticky elements at a scroll offset.
func BuildWithScrollAtRevision ¶ added in v0.14.0
func BuildWithScrollAtRevision(document *dom.Document, computed stylemodel.Map, viewportWidth, viewportHeight, scrollX, scrollY float32, revision uint64) *Tree
BuildWithScrollAtRevision lays out one immutable DOM/style revision at a scroll offset.
func BuildWithViewport ¶
func BuildWithViewport(document *dom.Document, computed stylemodel.Map, viewportWidth, viewportHeight float32) *Tree
BuildWithViewport lays out a document with definite viewport dimensions.
func Clone ¶
Clone returns a frame-local copy of a layout tree. Geometry can be cached while ApplyAnimatedStyles mutates paint and hit-test state on the copy.
func (*Tree) OrderedPaintEntries ¶
func (t *Tree) OrderedPaintEntries() []PaintEntry
OrderedPaintEntries returns the shared paint and hit-test ordering.