Documentation
¶
Index ¶
- func CaretIndexForTextFragments(fragments []TextFragment, x float64) (int, bool)
- func CaretXForTextFragments(fragments []TextFragment, caret int) (float64, bool)
- func ScrollbarSize(computed *style.ComputedStyle) float64
- func UsedLineHeight(computed *style.ComputedStyle, face *font.Face) float64
- type Box
- func (b *Box) BorderBox() Rect
- func (b *Box) CachedPaintHash() (uint64, bool)
- func (b *Box) GeometryHash() uint64
- func (b *Box) InvalidatePaintHash()
- func (b *Box) MarginBox() Rect
- func (b *Box) OwnGeometryHash() uint64
- func (b *Box) PaddingBox() Rect
- func (box *Box) Restyle(styles style.Map)
- func (b *Box) ScrollportBox() Rect
- func (b *Box) SetCachedPaintHash(hash uint64)
- func (b *Box) UpdateInlineBackgrounds(styles style.Map)
- type Cache
- type ControlFragment
- type Edges
- type GlyphFragment
- type ImageFragment
- type InlineBackground
- type Rect
- type TextFragment
- type TextLayoutOptions
- type Work
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaretIndexForTextFragments ¶
func CaretIndexForTextFragments(fragments []TextFragment, x float64) (int, bool)
func CaretXForTextFragments ¶
func CaretXForTextFragments(fragments []TextFragment, caret int) (float64, bool)
func ScrollbarSize ¶
func ScrollbarSize(computed *style.ComputedStyle) float64
ScrollbarSize is shared by layout and painting so the gutter matches its bar.
func UsedLineHeight ¶
func UsedLineHeight(computed *style.ComputedStyle, face *font.Face) float64
UsedLineHeight resolves the used value of line-height for a shaped face. The computed style stores a 1.2 fallback for `normal`, but Chromium derives the normal value from the selected face metrics instead of that fallback.
Types ¶
type Box ¶
type Box struct {
Style *style.ComputedStyle
Parent *Box
Node *dom.Node
StableID string
ControlFragments []ControlFragment
InlineBackgrounds []InlineBackground
ImageFragments []ImageFragment
TextFragments []TextFragment
Children []*Box
Padding Edges
FlowMarginBox Rect
// ScrollbarGutter is reserved between the padding edge and border.
ScrollbarGutter Edges
Viewport Rect
Border Edges
Content Rect
Margin Edges
ScrollHeight float64
TextHeight float64
ScrollWidth float64
// contains filtered or unexported fields
}
func BuildWithFonts ¶
func BuildWithFonts(root *dom.Node, styles style.Map, face, boldFace *font.Face, viewportWidth, viewportHeight float64) (*Box, error)
BuildWithFonts lays out a document using separate regular and bold faces. The bold face is selected for text whose computed font weight is 600 or heavier, matching the font used when its visual is spawned.
func (*Box) CachedPaintHash ¶
func (*Box) GeometryHash ¶
func (*Box) InvalidatePaintHash ¶
func (b *Box) InvalidatePaintHash()
func (*Box) OwnGeometryHash ¶
func (*Box) PaddingBox ¶
func (*Box) ScrollportBox ¶
ScrollportBox excludes classic scrollbar gutters from the padding box.
func (*Box) SetCachedPaintHash ¶
func (*Box) UpdateInlineBackgrounds ¶
type Cache ¶
type Cache struct {
Root *Box
// Changed contains boxes needing render synchronization: reflowed or
// translated boxes, plus ancestors whose descendant bounds may have changed.
// Each box appears once per pass; callers can sort by current tree depth.
Changed []*Box
// Removed contains boxes retired by this topology pass.
Removed []*Box
// Reordered contains flex containers whose child order actually changed.
Reordered []*Box
Work Work
// ReserveScrollbarSpace selects classic scrollbars for this document.
ReserveScrollbarSpace bool
// contains filtered or unexported fields
}
Cache owns a retained layout tree and scratch storage for one document. Styles and DOM mutations are explicit inputs; callers must supply all nodes whose content or geometry changed, including inherited style changes.
func (*Cache) MaintainCache ¶
func (cache *Cache) MaintainCache()
MaintainCache releases historical workspace peaks after sustained underuse. It is also safe between updates, after consumers finish using Changed/Removed.
func (*Cache) Restyle ¶
Restyle repoints retained boxes and fragments at the instances the cascade chose for changed nodes. Interning can move a node to another pointer.
func (*Cache) Update ¶
func (cache *Cache) Update(root *dom.Node, styles style.Map, face, boldFace *font.Face, width, height float64, dirty, reordered []*dom.Node, topology, force bool) (*Box, error)
Update reconciles topology only when needed, then propagates changed layout inputs through the existing formatting algorithm. Force invalidates all geometry for environment/resource changes. Reordered nodes only require sorting their retained flex parent; topology handles DOM/display changes.
type ControlFragment ¶
type ControlFragment struct {
Node *dom.Node
Style *style.ComputedStyle
TextFragments []TextFragment
ImageFragments []ImageFragment
Rect Rect
Content Rect
Padding Edges
Border Edges
Line int
}
type GlyphFragment ¶
type GlyphFragment = font.PositionedGlyph
type ImageFragment ¶
type InlineBackground ¶
Inline backgrounds follow the fragments on each line, not the containing block. One run includes nested syntax spans and intervening whitespace.
type TextFragment ¶
type TextFragment struct {
Node *dom.Node
Style *style.ComputedStyle
Text string
Glyphs []GlyphFragment
Rect Rect
Line int
}
type TextLayoutOptions ¶
type TextLayoutOptions struct {
Context *layoutContext
Face *font.Face
StyleMap style.Map
Reuse *Box
InlineBoxes map[*dom.Node]*Box
Node *dom.Node
FlowBoxes []*Box
InlineBoxFragments []inlineBoxFragment
AbsoluteContaining Rect
Width float64
FlowHeight float64
ContentHeight float64
OriginY float64
OriginX float64
}