browser

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 57 Imported by: 0

Documentation

Overview

Package browser contains the state and navigation lifecycle of a Growse browser window.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFormValidation      = errors.New("form validation failed")
	ErrSubmissionPrevented = errors.New("form submission was prevented")
	ErrInvalidEngine       = errors.New("invalid runtime engine")
)
View Source
var (
	ErrTabIDExhausted  = errors.New("tab id space is exhausted")
	ErrTabBrowser      = errors.New("tab browser factory returned nil")
	ErrTabBrowserReuse = errors.New("tab browser factory reused an existing browser")
	ErrTabNotFound     = errors.New("tab was not found")
	ErrTabLimit        = errors.New("tab limit was reached")
	ErrTabURLTooLong   = errors.New("tab URL is too long")
	ErrTabTitle        = errors.New("tab title is invalid")
)
View Source
var ErrFormTarget = errors.New("form target is not supported")

Functions

func IsTrustedOrigin

func IsTrustedOrigin(u *url.URL) bool

IsTrustedOrigin reports whether automatic Go execution is permitted for u.

Types

type Browser

type Browser struct {
	// contains filtered or unexported fields
}

Browser owns the state for one browser window.

MVPでは1つのアクティブページ、線形の閲覧履歴、信頼済みページごとに 独立した1つのGo Runtimeを保持する。

func New

func New(client ResourceLoader) *Browser

New creates a browser with no page loaded.

func NewWithEngineFactory added in v0.13.0

func NewWithEngineFactory(client ResourceLoader, factory runtimemodel.EngineFactory) *Browser

NewWithEngineFactory はGo / JavaScriptを選択できるBrowserを生成する。

func NewWithEngineFactoryAndStorage added in v0.13.0

func NewWithEngineFactoryAndStorage(client ResourceLoader, factory runtimemodel.EngineFactory, manager *storagecore.Manager) *Browser

NewWithEngineFactoryAndStorage はEngine選択と注入Storage profileを使用するBrowserを生成する。

func NewWithEngineFactoryAndStorageAndServiceWorkers added in v0.14.0

func NewWithEngineFactoryAndStorageAndServiceWorkers(client ResourceLoader, factory runtimemodel.EngineFactory, manager *storagecore.Manager, serviceWorkers *serviceworker.Manager) *Browser

NewWithEngineFactoryAndStorageAndServiceWorkers injects shared profile state.

func NewWithRuntimeFactory

func NewWithRuntimeFactory(client ResourceLoader, factory runtimemodel.Factory) *Browser

NewWithRuntimeFactory は信頼済みページのスクリプトを実行するBrowserを生成する。

func NewWithRuntimeFactoryAndStorage added in v0.9.0

func NewWithRuntimeFactoryAndStorage(client ResourceLoader, factory runtimemodel.Factory, manager *storagecore.Manager) *Browser

NewWithRuntimeFactoryAndStorage は注入されたStorage profileを使用するBrowserを生成する。

func NewWithRuntimeFactoryAndStorageAndServiceWorkers added in v0.14.0

func NewWithRuntimeFactoryAndStorageAndServiceWorkers(client ResourceLoader, factory runtimemodel.Factory, manager *storagecore.Manager, serviceWorkers *serviceworker.Manager) *Browser

NewWithRuntimeFactoryAndStorageAndServiceWorkers injects shared profile state.

func (*Browser) ActivateCheckable added in v0.8.0

func (b *Browser) ActivateCheckable(nodeID dom.NodeID) bool

ActivateCheckable toggles a checkbox or selects one radio in its group.

func (*Browser) Back

func (b *Browser) Back(ctx context.Context) (*Page, error)

Back loads the previous successful navigation entry.

func (*Browser) CanBack

func (b *Browser) CanBack() bool

CanBack reports whether Back has a target entry.

func (*Browser) CanForward

func (b *Browser) CanForward() bool

CanForward reports whether Forward has a target entry.

func (*Browser) ClearHover

func (b *Browser) ClearHover() bool

ClearHover clears transient hover state from the active page.

func (*Browser) Close

func (b *Browser) Close() error

Close はアクティブページに属するRuntimeを停止する。

func (*Browser) CommitInputValue

func (b *Browser) CommitInputValue(nodeID dom.NodeID, value string) bool

CommitInputValue はテキストinputの編集確定をchangeイベントとして配信する。

func (*Browser) DispatchClick

func (b *Browser) DispatchClick(nodeID dom.NodeID, x, y float32) bool

DispatchClick はアクティブページの対象ノードへクリックを配信する。

func (*Browser) Engine added in v0.13.0

func (b *Browser) Engine() runtimemodel.Engine

Engine はこのTabが次のPage loadで使用するEngineを返す。

func (*Browser) Forward

func (b *Browser) Forward(ctx context.Context) (*Page, error)

Forward loads the next navigation entry after a successful Back.

func (*Browser) HasAnimationFrameCallbacks added in v0.9.0

func (b *Browser) HasAnimationFrameCallbacks() bool

HasAnimationFrameCallbacks reports whether WebGo requested another frame.

func (*Browser) InspectPage added in v0.9.0

func (b *Browser) InspectPage(inspect func(*Page) bool) bool

InspectPage runs a read-only inspection of the active Page on its serialized Page event queue. Callers should use it when WebGo callbacks may still mutate the DOM asynchronously.

func (*Browser) IsPageVisible added in v0.16.0

func (b *Browser) IsPageVisible(page *Page) bool

IsPageVisible reports whether page is still the selected generation of an active Tab. Renderers use it to reject stale invalidation requests.

func (*Browser) MoveFormFocus added in v0.8.0

func (b *Browser) MoveFormFocus(reverse bool) bool

MoveFormFocus advances focus through enabled controls in DOM order.

func (*Browser) Navigate

func (b *Browser) Navigate(ctx context.Context, rawURL string) (*Page, error)

Navigate retrieves an HTML document and makes it the active page. The current page is preserved if validation or loading fails.

func (*Browser) Page

func (b *Browser) Page() *Page

Page returns the currently active page, or nil before the first successful navigation.

func (*Browser) Reload

func (b *Browser) Reload(ctx context.Context) (*Page, error)

Reload refreshes the active page without adding a history entry.

func (*Browser) ReloadIgnoringCache added in v0.9.0

func (b *Browser) ReloadIgnoringCache(ctx context.Context) (*Page, error)

ReloadIgnoringCache refreshes the active page and its subresources while asking HTTP caches to revalidate them. It does not add a history entry.

func (*Browser) ResetForm added in v0.8.0

func (b *Browser) ResetForm(nodeID dom.NodeID) bool

ResetForm restores a form's controls to their HTML attribute defaults.

func (*Browser) RunAnimationFrame added in v0.9.0

func (b *Browser) RunAnimationFrame(current time.Time) bool

RunAnimationFrame delivers one Gio frame timestamp to the active WebGo runtime.

func (*Browser) SetAnimationClock

func (b *Browser) SetAnimationClock(clock animationmodel.Clock)

SetAnimationClock replaces the page animation clock. Tests can inject a controllable Clock before navigation; nil restores the production clock.

func (*Browser) SetDevToolsSession added in v0.12.0

func (b *Browser) SetDevToolsSession(session *devtools.SessionStore)

SetDevToolsSession shares the Network diagnostics budget across session tabs.

func (*Browser) SetEngine added in v0.13.0

func (b *Browser) SetEngine(ctx context.Context, engine runtimemodel.Engine) (*Page, error)

SetEngine は旧Runtimeを停止して現在Pageを選択Engineで完全reloadする。

func (*Browser) SetFetchLimiter added in v0.11.0

func (b *Browser) SetFetchLimiter(limiter *fetchapi.Limiter)

SetFetchLimiter sets the Browser Session shared WebGo Fetch limit.

func (*Browser) SetInputValue

func (b *Browser) SetInputValue(nodeID dom.NodeID, value string) bool

SetInputValue はユーザー入力をアクティブページの編集可能なText Controlへ反映する。

func (*Browser) SetOnMutation

func (b *Browser) SetOnMutation(callback func())

SetOnMutation はWebGoによるDOM変更後の通知先を設定する。

func (*Browser) SetPage

func (b *Browser) SetPage(page *Page)

SetPage replaces the active page. Passing nil clears the active page.

func (*Browser) SetReducedMotion

func (b *Browser) SetReducedMotion(reduce bool) bool

SetReducedMotion updates the browser preference exposed through the prefers-reduced-motion media feature.

func (*Browser) SetSelectValue added in v0.8.0

func (b *Browser) SetSelectValue(nodeID dom.NodeID, value string) bool

SetSelectValue changes a select to an enabled option and dispatches the input/change pair produced by a committed user selection.

func (*Browser) SetTabActive added in v0.10.0

func (b *Browser) SetTabActive(active bool)

SetTabActive controls whether frame-driven page work may run for this Browser.

func (*Browser) Submit added in v0.8.0

func (b *Browser) Submit(ctx context.Context, formID, submitterID dom.NodeID) (*Page, error)

Submit validates and dispatches a cancelable submit event before navigation.

func (*Browser) SubmitForm

func (b *Browser) SubmitForm(nodeID dom.NodeID) bool

SubmitForm はinputを含む最も近いformへsubmitイベントを配信する。

func (*Browser) SubmitGET added in v0.8.0

func (b *Browser) SubmitGET(ctx context.Context, formID, submitterID dom.NodeID) (*Page, error)

SubmitGET serializes a form into the action query and navigates with history.

func (*Browser) SubmitPOST added in v0.8.0

func (b *Browser) SubmitPOST(ctx context.Context, formID, submitterID dom.NodeID) (*Page, error)

SubmitPOST sends URL-encoded entries and navigates to the response document.

func (*Browser) UpdateFocus

func (b *Browser) UpdateFocus(nodeID dom.NodeID) bool

UpdateFocus updates the element which matches the :focus pseudo-class.

func (*Browser) UpdateHistoryScroll added in v0.9.0

func (b *Browser) UpdateHistoryScroll(first, offset int)

UpdateHistoryScroll はUIの現在scroll位置をactive History entryへ保存する。

func (*Browser) UpdateHover

func (b *Browser) UpdateHover(nodeID dom.NodeID, x, y float32) bool

UpdateHover updates the active page's hovered element path.

func (*Browser) UpdateViewport

func (b *Browser) UpdateViewport(width, height float32) bool

UpdateViewport recomputes viewport-relative values when the content area changes.

func (*Browser) ValidateForm added in v0.8.0

func (b *Browser) ValidateForm(nodeID dom.NodeID) bool

ValidateForm focuses the first invalid control and reports whether the form is valid.

type BrowserFactory added in v0.10.0

type BrowserFactory func() *Browser

BrowserFactory creates the isolated Browser owned by a new tab.

type CompatibilityProfile added in v0.16.0

type CompatibilityProfile string

CompatibilityProfile selects page-owned rendering and lifecycle behavior. It is fixed when a Page is built and never shared across Engine reloads.

const (
	CompatibilityProfileGo        CompatibilityProfile = "go"
	CompatibilityProfileModernWeb CompatibilityProfile = "modern-web"
)

type FontInvalidation added in v0.17.0

type FontInvalidation struct {
	Revision        uint64
	Runs            []GlyphRunInvalidation
	LayoutAncestors []dom.NodeID
}

FontInvalidation describes the bounded layout work caused by a web-font completion. Browser chrome and text using other families are never included.

type FontRange added in v0.15.0

type FontRange struct{ Start, End rune }

FontRange is one inclusive @font-face unicode-range interval.

type FontResource added in v0.15.0

type FontResource struct {
	Family, Style, Weight, Stretch string
	Display                        string
	UnicodeRanges                  []FontRange
	URL, FinalURL, Format          string
	Loaded, Decoded                bool
	Error                          string
	Face                           *textfont.Face
}

FontResource is one validated and decoded @font-face source.

type Frame added in v0.14.0

type Frame struct {
	ID         uint64
	ElementID  dom.NodeID
	ParentID   uint64
	Depth      int
	Generation uint64
	URL        *url.URL
	Page       *Page
	Viewport   FrameViewport
	ScrollX    float32
	ScrollY    float32
	LoadError  string
	Loaded     bool
	Closed     bool
	Sandbox    runtimemodel.FramePolicy
	// contains filtered or unexported fields
}

Frame is one nested browsing context owned by a parent Page.

func (*Frame) AuthorizeFormSubmission added in v0.14.0

func (frame *Frame) AuthorizeFormSubmission() error

AuthorizeFormSubmission applies the sandbox form gate before any side effect.

func (*Frame) AuthorizePopup added in v0.14.0

func (frame *Frame) AuthorizePopup() error

AuthorizePopup applies the sandbox auxiliary-context gate before any side effect.

func (*Frame) AuthorizeTopNavigation added in v0.14.0

func (frame *Frame) AuthorizeTopNavigation(userActivated bool) error

AuthorizeTopNavigation applies the user-activation sandbox gate.

func (*Frame) Close added in v0.14.0

func (frame *Frame) Close() error

Close stops this Frame and every descendant exactly once.

func (*Frame) Navigate added in v0.14.0

func (frame *Frame) Navigate(ctx context.Context, rawURL string) error

Navigate loads a new independent Document into this Frame.

func (*Frame) Reload added in v0.14.0

func (frame *Frame) Reload(ctx context.Context) error

Reload reloads this Frame without replacing its parent element identity.

func (*Frame) SetScroll added in v0.14.0

func (frame *Frame) SetScroll(x, y float32)

SetScroll updates the child viewport scroll offset without escaping its document extent.

func (*Frame) SetViewport added in v0.14.0

func (frame *Frame) SetViewport(x, y, width, height float32)

SetViewport records the iframe border box and its mandatory clipping region.

type FramePlan added in v0.17.0

type FramePlan struct {
	Generation    uint64
	Styles        style.Map
	Damage        style.AnimationDamage
	Sources       FrameSource
	ImageNodes    []dom.NodeID
	ExecutedTasks int
	DroppedTasks  int
	Throttled     bool
	Stale         bool
}

type FrameRequest added in v0.17.0

type FrameRequest struct {
	Generation            uint64
	AnimationFramePending bool
	RunAnimationFrame     func()
	ScrollPending         bool
	Background            bool
	Tasks                 []FrameTask
}

type FrameSource added in v0.17.0

type FrameSource uint8

FrameSource is a bit set of work coalesced into one rendered frame.

const (
	FrameSourceCSSAnimation FrameSource = 1 << iota
	FrameSourceCSSTransition
	FrameSourceAnimationFrame
	FrameSourceAnimatedImage
	FrameSourceScroll
)

type FrameTask added in v0.17.0

type FrameTask struct {
	Priority FrameTaskPriority
	Cost     time.Duration
	Run      func()
}

type FrameTaskPriority added in v0.17.0

type FrameTaskPriority uint8
const (
	FrameTaskInput FrameTaskPriority = iota
	FrameTaskChrome
	FrameTaskPage
)

type FrameViewport added in v0.14.0

type FrameViewport struct {
	X, Y, Width, Height float32
	ClipX, ClipY        float32
	ClipWidth           float32
	ClipHeight          float32
}

FrameViewport is the iframe border box and its clipped child viewport.

type GlyphRunInvalidation added in v0.17.0

type GlyphRunInvalidation struct {
	TextNode  dom.NodeID
	RuneStart int
	RuneEnd   int
}

GlyphRunInvalidation identifies one contiguous rune range whose selected face changed. It intentionally contains no glyph or font payload.

type ImageInvalidation added in v0.17.0

type ImageInvalidation struct {
	Revision         uint64
	Target           dom.NodeID
	PaintNodes       []dom.NodeID
	LayoutAncestors  []dom.NodeID
	IntrinsicChanged bool
}

ImageInvalidation describes the bounded renderer work caused by the latest image completion without retaining resource bytes or decoded pixels.

type Page

type Page struct {
	HistoryID        uint64
	HistoryState     string
	ScrollFirst      int
	ScrollOffset     int
	ScrollRevision   uint64
	URL              *url.URL
	BaseURL          *url.URL
	StatusCode       int
	ContentType      string
	Source           []byte
	Document         *dom.Document
	Events           *events.Dispatcher
	Stylesheet       *css.Stylesheet
	ComputedStyles   style.Map
	StyleErrors      []string
	Animations       *style.AnimationRegistry
	Transitions      *style.TransitionRegistry
	BackgroundImages map[string]image.Image
	BackgroundErrors []string
	ImageResources   map[dom.NodeID]layoutmodel.ImageResource
	Images           map[string]image.Image
	AnimatedImages   map[dom.NodeID]*animatedImagePlayer
	ImageErrors      []string
	Fonts            []FontResource
	FontErrors       []string
	WebFonts         *layoutmodel.FontSet
	Engine           runtimemodel.Engine
	Compatibility    CompatibilityProfile
	Scripts          []Script
	ImportMap        map[string]string
	ScriptErrors     []string
	RuntimeStarted   bool
	RuntimeError     string
	Sandbox          runtimemodel.SandboxStatus
	HoverTarget      dom.NodeID
	HoverPath        []dom.NodeID
	FocusTarget      dom.NodeID
	FocusVisible     bool
	Submitter        dom.NodeID
	ViewportWidth    float32
	ViewportHeight   float32
	ReducedMotion    bool
	StyleRevision    uint64
	DevTools         *devtools.PageStore
	Frames           []*Frame
	FramePolicy      runtimemodel.FramePolicy
	// contains filtered or unexported fields
}

Page holds the state of one loaded document.

Runtimeの状態はスクリプト取得エラーと分けて保持し、Goコードを実行できない場合も ページの表示を継続できるようにする。

func NewPage

func NewPage(pageURL *url.URL) *Page

NewPage creates a page for pageURL. A nil URL is allowed for documents such as an in-memory error page that do not have a network location.

func (*Page) ActiveAnimatedImagesInViewport added in v0.17.0

func (p *Page) ActiveAnimatedImagesInViewport(tree *layout.Tree) bool

func (*Page) ActiveAnimations

func (p *Page) ActiveAnimations(current time.Time) bool

ActiveAnimations reports whether this page needs another animation frame.

func (*Page) ActiveAnimationsInViewport added in v0.16.0

func (p *Page) ActiveAnimationsInViewport(current time.Time, tree *layoutmodel.Tree) bool

ActiveAnimationsInViewport reports whether a live CSS animation can affect the visible viewport. Unknown geometry stays conservative and requests a frame; known offscreen or visibility:hidden elements do not.

func (*Page) AdvanceAnimatedImages added in v0.17.0

func (p *Page) AdvanceAnimatedImages(current time.Time, tree *layout.Tree) []dom.NodeID

AdvanceAnimatedImages advances only visible image candidates and returns the nodes requiring paint. Hidden/offscreen/reduced-motion players retain their current frame and resume from the same clock position.

func (*Page) AnimatedStyles

func (p *Page) AnimatedStyles(current time.Time) style.Map

AnimatedStyles samples this page's CSS Animations and Transitions at current without changing its underlying computed style map.

func (*Page) AnimationFrame added in v0.16.0

func (p *Page) AnimationFrame(current time.Time) (style.Map, style.AnimationDamage)

AnimationFrame samples the page animation state and classifies the most expensive renderer stage that must be updated for this frame.

func (*Page) BeginWebFontLoad added in v0.19.0

func (p *Page) BeginWebFontLoad() uint64

BeginWebFontLoad advances the page-owned generation used to reject a late completion from an older stylesheet or navigation state.

func (*Page) CommitWebFontCompletion added in v0.17.0

func (p *Page) CommitWebFontCompletion(resource FontResource) FontInvalidation

CommitWebFontCompletion installs a decoded face and marks only text spans covered by its family and unicode-range for re-shaping.

func (*Page) CommitWebFontCompletionForGeneration added in v0.19.0

func (p *Page) CommitWebFontCompletionForGeneration(generation uint64, resource FontResource) (FontInvalidation, bool)

CommitWebFontCompletionForGeneration installs a current decoded face and rejects stale asynchronous completion without changing page state.

func (*Page) FontInvalidationSnapshot added in v0.17.0

func (p *Page) FontInvalidationSnapshot() FontInvalidation

func (*Page) FrameByElement added in v0.14.0

func (p *Page) FrameByElement(elementID dom.NodeID) (*Frame, bool)

FrameByElement returns the live top-level Frame hosted by elementID.

func (*Page) FrameGeneration added in v0.17.0

func (p *Page) FrameGeneration() uint64

FrameGeneration returns the token accepted by the current Page lifecycle.

func (*Page) ImageInvalidationSnapshot added in v0.17.0

func (p *Page) ImageInvalidationSnapshot() ImageInvalidation

ImageInvalidationSnapshot returns a payload-free copy suitable for the UI renderer and DevTools. Unrelated siblings are never included.

func (*Page) LinkDestination added in v0.10.0

func (p *Page) LinkDestination(nodeID dom.NodeID) (*url.URL, string, bool)

LinkDestination resolves the nearest anchor URL and normalized target.

func (*Page) LinkURL

func (p *Page) LinkURL(nodeID dom.NodeID) (*url.URL, bool)

LinkURL resolves the nearest anchor at nodeID against the document base URL.

func (*Page) RecordCompositorSnapshot added in v0.17.0

func (p *Page) RecordCompositorSnapshot(dirtyNodes, layers, damageRegions int)

RecordCompositorSnapshot publishes bounded, payload-free diagnostics for the latest frame. Values are snapshots rather than cumulative counters.

func (*Page) RecordComputedStyleChanges added in v0.17.0

func (p *Page) RecordComputedStyleChanges(previous, current style.Map) RenderInvalidation

RecordComputedStyleChanges classifies changed nodes without propagating dirtiness to unrelated siblings or the entire document.

func (*Page) RecordDOMMutation added in v0.18.0

func (p *Page) RecordDOMMutation(rootID dom.NodeID) RenderInvalidation

RecordDOMMutation forces layout and paint data derived from node content to be rebuilt even when the computed CSS values themselves did not change.

func (*Page) RecordRenderEvent added in v0.16.0

func (p *Page) RecordRenderEvent(event RenderEvent)

RecordRenderEvent records UI-owned work without retaining DOM or resource payloads. Overflow saturates instead of wrapping diagnostics.

func (*Page) RecordRenderRebuild added in v0.16.0

func (p *Page) RecordRenderRebuild(reason RenderRebuildReason)

RecordRenderRebuild records one cache miss without retaining its input.

func (*Page) RecordRenderReuse added in v0.17.0

func (p *Page) RecordRenderReuse(fragments, commands int)

RecordRenderReuse counts stable fragments and commands retained across one incremental revision. Values saturate to keep diagnostics monotonic.

func (*Page) RenderInvalidationSnapshot added in v0.17.0

func (p *Page) RenderInvalidationSnapshot() RenderInvalidation

func (*Page) RenderMetricsSnapshot added in v0.16.0

func (p *Page) RenderMetricsSnapshot() RenderMetrics

RenderMetricsSnapshot returns current Page and resource-cache counters.

func (*Page) RuntimeDiagnostics added in v0.14.0

func (page *Page) RuntimeDiagnostics() []devtools.RuntimeContext

RuntimeDiagnostics returns bounded, secret-free Page, Frame, and Service Worker metadata.

func (*Page) ScheduleFrame added in v0.17.0

func (p *Page) ScheduleFrame(current time.Time, tree *layout.Tree, request FrameRequest) FramePlan

ScheduleFrame samples all frame-producing subsystems at one timestamp and returns one coalesced renderer plan.

func (*Page) SyncFrameViewports added in v0.14.0

func (p *Page) SyncFrameViewports(tree *layoutmodel.Tree)

SyncFrameViewports maps the parent layout geometry into clipped child viewports.

func (*Page) UsesModernWebCompatibility added in v0.16.0

func (p *Page) UsesModernWebCompatibility() bool

UsesModernWebCompatibility reports whether JS-only real-site rendering and lifecycle features may run for this Page generation.

type RenderDamage added in v0.17.0

type RenderDamage uint8

RenderDamage is the least expensive renderer stage affected by a mutation.

const (
	RenderDamageNone RenderDamage = iota
	RenderDamageStyle
	RenderDamageComposite
	RenderDamagePaint
	RenderDamageLayout
)

type RenderEvent added in v0.16.0

type RenderEvent uint8

RenderEvent identifies one bounded rendering-pipeline counter update.

const (
	RenderImagePaintHit RenderEvent = iota
	RenderImagePaintMiss
	RenderImagePaintEviction
	RenderLayoutBuild
	RenderDisplayListBuild
	RenderDisplayListReuse
	RenderCompositeFrame
	RenderPaintFrame
	RenderLayoutFrame
)

type RenderInvalidation added in v0.17.0

type RenderInvalidation struct {
	Revision       uint64
	Damage         RenderDamage
	StyleNodes     []dom.NodeID
	LayoutRoots    []dom.NodeID
	PaintNodes     []dom.NodeID
	CompositeNodes []dom.NodeID
}

RenderInvalidation is a payload-free, bounded mutation summary. LayoutRoots identify subtree roots rather than expanding every descendant.

type RenderMetrics added in v0.16.0

type RenderMetrics struct {
	ImageResourceHits      uint64
	ImageResourceMisses    uint64
	ImageResourceEvictions uint64
	ImageResourceDecodes   uint64
	ImageSurfaceResizes    uint64
	ImageResourceCoalesced uint64
	ImageResourceCanceled  uint64
	ImageResourceRejected  uint64
	ImagePaintHits         uint64
	ImagePaintMisses       uint64
	ImagePaintEvictions    uint64
	LayoutBuilds           uint64
	DisplayListBuilds      uint64
	DisplayListReuses      uint64
	LayoutFragmentReuses   uint64
	DisplayCommandReuses   uint64
	CompositeFrames        uint64
	PaintFrames            uint64
	LayoutFrames           uint64
	InitialRebuilds        uint64
	PageRebuilds           uint64
	StyleRebuilds          uint64
	ViewportRebuilds       uint64
	ScrollRebuilds         uint64
	AnimationRebuilds      uint64
	ScheduledFrames        uint64
	CoalescedFrames        uint64
	ThrottledFrames        uint64
	InputTasks             uint64
	ChromeTasks            uint64
	PageTasks              uint64
	DroppedTasks           uint64
	DirtyNodes             uint64
	CompositingLayers      uint64
	DamageRegions          uint64
}

RenderMetrics is a payload-free snapshot for performance regression tests and DevTools. Counters are monotonic within one Page generation.

type RenderRebuildReason added in v0.16.0

type RenderRebuildReason uint8

RenderRebuildReason classifies why the cached layout/display list could not be reused. Values are deliberately fixed-size so diagnostics never retain a DOM node, stylesheet, or animation payload.

const (
	RenderRebuildInitial RenderRebuildReason = iota
	RenderRebuildPage
	RenderRebuildStyle
	RenderRebuildViewport
	RenderRebuildScroll
	RenderRebuildAnimation
)

type ResourceLoader

type ResourceLoader interface {
	Get(ctx context.Context, resourceURL *url.URL) (*network.Response, error)
}

ResourceLoader retrieves a resource for navigation.

type Script

type Script = runtimemodel.Script

Script is one Go source discovered in document order.

type Session added in v0.10.0

type Session struct {
	// contains filtered or unexported fields
}

Session owns an ordered collection of tabs and at most one active tab.

func NewSession added in v0.10.0

func NewSession(factory ...BrowserFactory) *Session

NewSession creates an empty browser session.

func NewSessionWithPolicy added in v0.10.0

func NewSessionWithPolicy(factory BrowserFactory, policy SessionPolicy) *Session

NewSessionWithPolicy creates an empty browser session with explicit limits.

func (*Session) ActiveBrowser added in v0.10.0

func (s *Session) ActiveBrowser() (*Browser, bool)

ActiveBrowser returns the Browser currently selected by browser chrome. Callers keep the returned pointer to pin an operation to this tab even if another tab becomes active before the operation completes.

func (*Session) ActiveBrowserTarget added in v0.10.0

func (s *Session) ActiveBrowserTarget() (TabID, *Browser, bool)

ActiveBrowserTarget atomically returns the ID and Browser selected at the start of a chrome operation.

func (*Session) ActiveTab added in v0.10.0

func (s *Session) ActiveTab() (TabSnapshot, bool)

ActiveTab returns the active tab without exposing mutable session state.

func (*Session) BeginTabNavigation added in v0.10.0

func (s *Session) BeginTabNavigation(id TabID) (TabSnapshot, error)

BeginTabNavigation marks one tab as loading without changing selection.

func (*Session) Close added in v0.10.0

func (s *Session) Close() error

Close transitions every tab to closed and releases each owned Browser.

func (*Session) CloseTab added in v0.10.0

func (s *Session) CloseTab(id TabID) (TabCloseResult, error)

CloseTab removes a tab and deterministically selects its right neighbor or, when there is no right neighbor, its left neighbor.

func (*Session) FinishTabNavigation added in v0.10.0

func (s *Session) FinishTabNavigation(id TabID, failed bool) (TabSnapshot, error)

FinishTabNavigation publishes a result to its target tab without selecting it.

func (*Session) NewTab added in v0.10.0

func (s *Session) NewTab(initialURL *url.URL) (TabSnapshot, error)

NewTab adds an empty tab or a tab with a requested initial URL. Navigation is performed separately so callers can control its context and lifecycle.

func (*Session) SelectNext added in v0.10.0

func (s *Session) SelectNext() (TabSnapshot, error)

SelectNext selects the next live tab, wrapping at the end.

func (*Session) SelectPrevious added in v0.10.0

func (s *Session) SelectPrevious() (TabSnapshot, error)

SelectPrevious selects the previous live tab, wrapping at the beginning.

func (*Session) SelectTab added in v0.10.0

func (s *Session) SelectTab(id TabID) (TabSnapshot, error)

SelectTab makes the identified live tab active.

func (*Session) SelectTabAt added in v0.10.0

func (s *Session) SelectTabAt(position int) (TabSnapshot, error)

SelectTabAt makes the live tab at position active.

func (*Session) SetOnActiveMutation added in v0.10.0

func (s *Session) SetOnActiveMutation(callback func())

SetOnActiveMutation registers the Browser Window invalidation callback.

func (*Session) SetTabTitle added in v0.10.0

func (s *Session) SetTabTitle(id TabID, title string) (TabSnapshot, error)

SetTabTitle stores a validated document title for browser chrome.

func (*Session) SubmitFormToNewTab added in v0.10.0

func (s *Session) SubmitFormToNewTab(ctx context.Context, sourceID TabID, formID, submitterID dom.NodeID) (TabSnapshot, *Page, error)

SubmitFormToNewTab validates a _blank form submission and executes it in an isolated, newly-active tab.

func (*Session) Tabs added in v0.10.0

func (s *Session) Tabs() []TabSnapshot

Tabs returns the tabs in their display order.

type SessionPolicy added in v0.10.0

type SessionPolicy struct {
	MaxTabs       int
	MaxTabID      uint64
	MaxTitleBytes int
	MaxURLBytes   int
	MaxFetches    int
}

SessionPolicy bounds tab-owned state before memory or identifiers are consumed.

func DefaultSessionPolicy added in v0.10.0

func DefaultSessionPolicy() SessionPolicy

DefaultSessionPolicy returns the production safety limits.

type Tab added in v0.10.0

type Tab struct {
	// contains filtered or unexported fields
}

Tab is one top-level page owned by a browser session.

type TabCloseResult added in v0.10.0

type TabCloseResult struct {
	Closed    TabID
	Active    TabSnapshot
	HasActive bool
}

TabCloseResult reports the active tab selected after a close operation.

type TabID added in v0.10.0

type TabID uint64

TabID identifies one tab for the lifetime of a browser session.

type TabSnapshot added in v0.10.0

type TabSnapshot struct {
	ID            TabID
	Position      int
	State         TabState
	Active        bool
	URL           string
	Title         string
	Loading       bool
	Error         bool
	PendingUpdate bool
	Status        string
}

TabSnapshot is an immutable view of a tab suitable for browser chrome.

type TabState added in v0.10.0

type TabState uint8

TabState describes whether a tab can still receive page work.

const (
	TabActive TabState = iota
	TabBackground
	TabClosing
	TabClosed
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL