Documentation
¶
Overview ¶
Package dom implements Kite's public DOM interfaces. It manages the logical tree, document adoption, connection callbacks, and element identity. Public traversal excludes the private subtrees used to implement built-in controls.
Index ¶
- func AdoptOuterTree(n dom.Node)
- func DefaultScroller(host dom.Element) event.Scrollable
- func IsOverlay(el dom.Element) bool
- func IsUANode(n dom.Node) bool
- func LayoutChildren(n dom.Node) iter.Seq[dom.Node]
- func Outer(n dom.Node) dom.Node
- func UARoot(el dom.Element) dom.Node
- type BaseNode
- func (b *BaseNode) AppendChild(child dom.Node) dom.Node
- func (b *BaseNode) ChildNeedsSync() bool
- func (b *BaseNode) ChildNodes() iter.Seq[dom.Node]
- func (b *BaseNode) ClearStyleFlags()
- func (b *BaseNode) ClearSyncFlags()
- func (b *BaseNode) CloneNode(deep bool) dom.Node
- func (b *BaseNode) Contains(descendant dom.Node) bool
- func (b *BaseNode) EventTarget() event.EventTarget
- func (b *BaseNode) FirstChild() dom.Node
- func (b *BaseNode) HasChildNodes() bool
- func (b *BaseNode) HasDirtyStyleChild() bool
- func (b *BaseNode) InsertBefore(newChild, ref dom.Node) dom.Node
- func (b *BaseNode) IsConnected() bool
- func (b *BaseNode) Kind() dom.Kind
- func (b *BaseNode) LastChild() dom.Node
- func (b *BaseNode) MarkNeedsScrollSync()
- func (b *BaseNode) MarkNeedsSync()
- func (b *BaseNode) MarkStyleChildDirty()
- func (b *BaseNode) NeedsScrollSync() bool
- func (b *BaseNode) NeedsSync() bool
- func (b *BaseNode) NextSibling() dom.Node
- func (b *BaseNode) NodeName() string
- func (b *BaseNode) OwnerDocument() dom.Document
- func (b *BaseNode) Parent() dom.Node
- func (b *BaseNode) ParentElement() dom.Element
- func (b *BaseNode) PreviousSibling() dom.Node
- func (b *BaseNode) RemoveChild(child dom.Node) dom.Node
- func (b *BaseNode) ReplaceChild(newChild, oldChild dom.Node) dom.Node
- func (b *BaseNode) TextContent() string
- func (b *BaseNode) Unwrap() dom.Node
- type DirtyElement
- type DirtyNode
- type Document
- func (d *Document) ActiveScope() *dom.FocusScope
- func (d *Document) Body() dom.Element
- func (d *Document) CreateElement(tag string, self dom.Node) dom.Element
- func (d *Document) CreateRange() dom.Range
- func (d *Document) CreateTextNode(data string, self dom.Node) dom.TextNode
- func (d *Document) CurrentFocus() dom.Element
- func (d *Document) DefaultView() dom.View
- func (d *Document) FindAnchor(name string) dom.Element
- func (d *Document) FindNodeAtByteOffset(root dom.Node, targetOffset int) (dom.Node, int)
- func (d *Document) Focus(el dom.Element)
- func (d *Document) GetElementByID(id string) dom.Element
- func (d *Document) HideOverlay(el dom.Element)
- func (d *Document) InvalidatePreorderCache()
- func (d *Document) InvalidateTextNodeCache()
- func (d *Document) IsFocused(el dom.Element) bool
- func (d *Document) MoveCaret(dir dom.Direction) bool
- func (d *Document) Mutating() bool
- func (d *Document) NavigateFocus(dir dom.Direction) bool
- func (d *Document) NextFocus() bool
- func (d *Document) NumOverlays() int
- func (d *Document) Overlays() iter.Seq[dom.Element]
- func (d *Document) PopScope()
- func (d *Document) PreorderOrders() map[any]render.NodeOrder
- func (d *Document) PreorderValid() bool
- func (d *Document) PreviousFocus() bool
- func (d *Document) PushScope(scope *dom.FocusScope)
- func (d *Document) QuerySelector(selector string) dom.Element
- func (d *Document) RegisterAnchor(name string, el dom.Element)
- func (d *Document) Selection() dom.Selection
- func (d *Document) SetDefaultView(v dom.View)
- func (d *Document) SetFocusHandle(handle dom.FocusHandle)
- func (d *Document) SetTerminal(t terminal.Terminal)
- func (d *Document) ShowOverlay(el dom.Element, zIndex int)
- func (d *Document) Terminal() terminal.Terminal
- func (d *Document) UnregisterAnchor(name string)
- type Element
- func (e *Element) AttachUARoot(root dom.Node)
- func (e *Element) Attribute(name string) (string, bool)
- func (e *Element) Blur()
- func (e *Element) Children() iter.Seq[dom.Node]
- func (e *Element) Class() string
- func (e *Element) ClearDirtyStyle()
- func (e *Element) ClearStyleFlags()
- func (e *Element) DefaultStyle() style.Style
- func (e *Element) EachAttribute(fn func(name, value string) bool)
- func (e *Element) Focus()
- func (e *Element) GetBoundingClientRect() (geom.Rect, bool)
- func (e *Element) HasAttribute(name string) bool
- func (e *Element) ID() string
- func (e *Element) IntrinsicStyle() style.Style
- func (e *Element) IsActive() bool
- func (e *Element) IsDirtyStyle() bool
- func (e *Element) IsFocusable() bool
- func (e *Element) IsHovered() bool
- func (e *Element) MarkStyleDirty()
- func (e *Element) ProvidesCursor() bool
- func (e *Element) QuerySelector(selector string) dom.Element
- func (e *Element) RawStyle() style.Style
- func (e *Element) RemoveAttribute(name string)
- func (e *Element) ReplaceWith(nodes ...dom.Node) dom.Element
- func (e *Element) Scroll() (x, y int)
- func (e *Element) ScrollBy(dx, dy int)
- func (e *Element) ScrollCursorIntoView()
- func (e *Element) ScrollTo(x, y int)
- func (e *Element) SetActive(v bool)
- func (e *Element) SetAttribute(name, value string)
- func (e *Element) SetClass(class string)
- func (e *Element) SetHovered(v bool)
- func (e *Element) SetID(id string)
- func (e *Element) SetTabIndex(index int)
- func (e *Element) TabIndex() int
- func (e *Element) TagName() string
- func (e *Element) UARoot() dom.Node
- type OverlayRecord
- type Range
- func (r *Range) Collapse(toStart bool)
- func (r *Range) EndContainer() dom.Node
- func (r *Range) EndOffset() int
- func (r *Range) IsCollapsed() bool
- func (r *Range) SetEnd(node dom.Node, offset int)
- func (r *Range) SetStart(node dom.Node, offset int)
- func (r *Range) StartContainer() dom.Node
- func (r *Range) StartOffset() int
- func (r *Range) String() string
- type ScrollState
- type Selection
- type TextNode
- type TextNodeRecord
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdoptOuterTree ¶
AdoptOuterTree runs an adoption walk over the subtree rooted at n. This is typically called by the engine during initial mount.
func DefaultScroller ¶
func DefaultScroller(host dom.Element) event.Scrollable
DefaultScroller returns a new Scrollable implementation for the given host.
func IsOverlay ¶
IsOverlay reports whether el is currently registered in its owner document's top layer.
func IsUANode ¶
IsUANode reports whether n is part of a UA shadow subtree. The check is O(1) because AttachUARoot stamps every node in the subtree with an inUASubtree flag at construction time.
func LayoutChildren ¶
LayoutChildren returns an iterator that yields the engine-visible children of n. For nodes that hold a UA shadow subtree (via AttachUARoot), the iterator yields the public child list followed by the children of the UA root.
LayoutChildren is the authoritative walker for the engine's Sync, Style, Layout, and Paint phases. It must never be exposed to author code; public author-facing traversal (ChildNodes, FirstChild, LastChild, Children) must remain UA-invisible.
Zero-allocation fast path: when n has no UA subtree the iterator degrades to a plain ChildNodes() walk with no additional overhead beyond the public iterator.
Types ¶
type BaseNode ¶
type BaseNode struct {
internalevent.Target
// contains filtered or unexported fields
}
func (*BaseNode) ChildNeedsSync ¶
func (*BaseNode) ClearStyleFlags ¶
func (b *BaseNode) ClearStyleFlags()
func (*BaseNode) ClearSyncFlags ¶
func (b *BaseNode) ClearSyncFlags()
func (*BaseNode) EventTarget ¶
func (b *BaseNode) EventTarget() event.EventTarget
func (*BaseNode) FirstChild ¶
func (*BaseNode) HasChildNodes ¶
func (*BaseNode) HasDirtyStyleChild ¶
func (*BaseNode) IsConnected ¶
func (*BaseNode) MarkNeedsScrollSync ¶
func (b *BaseNode) MarkNeedsScrollSync()
func (*BaseNode) MarkNeedsSync ¶
func (b *BaseNode) MarkNeedsSync()
func (*BaseNode) MarkStyleChildDirty ¶
func (b *BaseNode) MarkStyleChildDirty()
func (*BaseNode) NeedsScrollSync ¶
func (*BaseNode) NextSibling ¶
func (*BaseNode) OwnerDocument ¶
func (*BaseNode) ParentElement ¶
func (*BaseNode) PreviousSibling ¶
func (*BaseNode) ReplaceChild ¶
func (*BaseNode) TextContent ¶
type DirtyElement ¶
type DirtyElement interface {
DirtyNode
dom.Element
MarkStyleDirty()
IsDirtyStyle() bool
ClearDirtyStyle()
IsHovered() bool
SetHovered(bool)
IsActive() bool
SetActive(bool)
RawStyle() style.Style
DefaultStyle() style.Style
IntrinsicStyle() style.Style
}
DirtyElement defines the internal interface for tracking element-specific style properties and flags.
func AsDirtyElement ¶
func AsDirtyElement(n dom.Node) DirtyElement
AsDirtyElement returns the internal DirtyElement interface for the given element.
type DirtyNode ¶
type DirtyNode interface {
dom.Node
MarkNeedsSync()
NeedsSync() bool
ChildNeedsSync() bool
ClearSyncFlags()
MarkNeedsScrollSync()
NeedsScrollSync() bool
HasDirtyStyleChild() bool
MarkStyleChildDirty()
ClearStyleFlags()
}
DirtyNode defines the internal interface for tracking structural and style-propagation dirty state on any logical node.
type Document ¶
type Document struct {
BaseNode
// contains filtered or unexported fields
}
Document is the concrete, exported implementation of Document.
func NewDocument ¶
func NewDocument() *Document
NewDocument creates and returns a new, empty Document. The document itself is always connected.
func (*Document) ActiveScope ¶
func (d *Document) ActiveScope() *dom.FocusScope
func (*Document) CreateElement ¶
CreateElement returns a new, detached Element with the given tag name owned by this document.
func (*Document) CreateRange ¶
func (*Document) CreateTextNode ¶
CreateTextNode returns a new, detached TextNode with the given data owned by this document.
func (*Document) CurrentFocus ¶
func (*Document) DefaultView ¶
func (*Document) FindAnchor ¶
FindAnchor returns the Element registered under name in the anchor registry, or nil.
func (*Document) FindNodeAtByteOffset ¶
func (*Document) GetElementByID ¶
GetElementByID returns the Element whose ID equals id, or nil.
func (*Document) HideOverlay ¶
func (*Document) InvalidatePreorderCache ¶
func (d *Document) InvalidatePreorderCache()
func (*Document) InvalidateTextNodeCache ¶
func (d *Document) InvalidateTextNodeCache()
func (*Document) NumOverlays ¶
func (*Document) PreorderValid ¶
func (*Document) PreviousFocus ¶
func (*Document) PushScope ¶
func (d *Document) PushScope(scope *dom.FocusScope)
func (*Document) RegisterAnchor ¶
RegisterAnchor adds el to the anchor registry under name.
func (*Document) SetDefaultView ¶
func (*Document) SetFocusHandle ¶
func (d *Document) SetFocusHandle(handle dom.FocusHandle)
func (*Document) SetTerminal ¶
SetTerminal attaches the host environment to the document.
func (*Document) UnregisterAnchor ¶
UnregisterAnchor removes the entry for name from the anchor registry.
type Element ¶
type Element struct {
BaseNode
// contains filtered or unexported fields
}
Element is the concrete, exported implementation of Element.
func NewElement ¶
NewElement allocates an element with the given tag name and owner document. If self is nil, the element's self pointer defaults to itself.
func (*Element) AttachUARoot ¶
AttachUARoot attaches root as the closed UA shadow subtree for this host. See dom.Element.AttachUARoot for the full contract.
func (*Element) Children ¶
Children is a helper that returns only Element children. Deprecated: use ChildNodes() and filter by kind.
func (*Element) ClearDirtyStyle ¶
func (e *Element) ClearDirtyStyle()
func (*Element) ClearStyleFlags ¶
func (e *Element) ClearStyleFlags()
func (*Element) DefaultStyle ¶
func (*Element) EachAttribute ¶
func (*Element) HasAttribute ¶
func (*Element) IntrinsicStyle ¶
IntrinsicStyle returns the UA-mandated sparse style for this element. It delegates to the user-visible wrapper (outer) if it's a specialized implementation.
func (*Element) IsDirtyStyle ¶
func (*Element) IsFocusable ¶
func (*Element) MarkStyleDirty ¶
func (e *Element) MarkStyleDirty()
func (*Element) ProvidesCursor ¶
func (*Element) RemoveAttribute ¶
func (*Element) ReplaceWith ¶
ReplaceWith replaces this element with the given nodes.
func (*Element) ScrollCursorIntoView ¶
func (e *Element) ScrollCursorIntoView()
func (*Element) SetAttribute ¶
func (*Element) SetHovered ¶
func (*Element) SetID ¶
SetID sets the element's identifier. Registry maintenance when the node is disconnected only the stored id field is updated; the identity registry is touched only when the node is connected.
func (*Element) SetTabIndex ¶
type OverlayRecord ¶
type OverlayRecord struct {
// contains filtered or unexported fields
}
type Range ¶
type Range struct {
// contains filtered or unexported fields
}
func (*Range) EndContainer ¶
func (*Range) IsCollapsed ¶
func (*Range) StartContainer ¶
func (*Range) StartOffset ¶
type ScrollState ¶
type ScrollState struct {
X, Y int
}
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
func (*Selection) RangeCount ¶
func (*Selection) RemoveAllRanges ¶
func (s *Selection) RemoveAllRanges()
type TextNode ¶
type TextNode struct {
BaseNode
// contains filtered or unexported fields
}
TextNode is the concrete, exported implementation of TextNode.
func NewTextNode ¶
NewTextNode allocates a TextNode with the given data and owner document. If self is nil, the node's identity is itself.