Documentation
¶
Overview ¶
Package browser contains the state and navigation lifecycle of a Growse browser window.
Index ¶
- func IsTrustedOrigin(u *url.URL) bool
- type Browser
- func (b *Browser) Back(ctx context.Context) (*Page, error)
- func (b *Browser) CanBack() bool
- func (b *Browser) CanForward() bool
- func (b *Browser) ClearHover() bool
- func (b *Browser) Close() error
- func (b *Browser) CommitInputValue(nodeID dom.NodeID, value string) bool
- func (b *Browser) DispatchClick(nodeID dom.NodeID, x, y float32) bool
- func (b *Browser) Forward(ctx context.Context) (*Page, error)
- func (b *Browser) Navigate(ctx context.Context, rawURL string) (*Page, error)
- func (b *Browser) Page() *Page
- func (b *Browser) Reload(ctx context.Context) (*Page, error)
- func (b *Browser) SetAnimationClock(clock animationmodel.Clock)
- func (b *Browser) SetInputValue(nodeID dom.NodeID, value string) bool
- func (b *Browser) SetOnMutation(callback func())
- func (b *Browser) SetPage(page *Page)
- func (b *Browser) SetReducedMotion(reduce bool) bool
- func (b *Browser) SubmitForm(nodeID dom.NodeID) bool
- func (b *Browser) UpdateFocus(nodeID dom.NodeID) bool
- func (b *Browser) UpdateHover(nodeID dom.NodeID, x, y float32) bool
- func (b *Browser) UpdateViewport(width, height float32) bool
- type Page
- type ResourceLoader
- type Script
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTrustedOrigin ¶
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 NewWithRuntimeFactory ¶
func NewWithRuntimeFactory(client ResourceLoader, factory runtimemodel.Factory) *Browser
NewWithRuntimeFactory は信頼済みページのスクリプトを実行するBrowserを生成する。
func (*Browser) CanForward ¶
CanForward reports whether Forward has a target entry.
func (*Browser) ClearHover ¶
ClearHover clears transient hover state from the active page.
func (*Browser) CommitInputValue ¶
CommitInputValue はテキストinputの編集確定をchangeイベントとして配信する。
func (*Browser) DispatchClick ¶
DispatchClick はアクティブページの対象ノードへクリックを配信する。
func (*Browser) Navigate ¶
Navigate retrieves an HTML document and makes it the active page. The current page is preserved if validation or loading fails.
func (*Browser) Page ¶
Page returns the currently active page, or nil before the first successful navigation.
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) SetInputValue ¶
SetInputValue はユーザー入力をアクティブページのテキストinputへ反映する。
func (*Browser) SetOnMutation ¶
func (b *Browser) SetOnMutation(callback func())
SetOnMutation はWebGoによるDOM変更後の通知先を設定する。
func (*Browser) SetReducedMotion ¶
SetReducedMotion updates the browser preference exposed through the prefers-reduced-motion media feature.
func (*Browser) SubmitForm ¶
SubmitForm はinputを含む最も近いformへsubmitイベントを配信する。
func (*Browser) UpdateFocus ¶
UpdateFocus updates the element which matches the :focus pseudo-class.
func (*Browser) UpdateHover ¶
UpdateHover updates the active page's hovered element path.
func (*Browser) UpdateViewport ¶
UpdateViewport recomputes viewport-relative values when the content area changes.
type Page ¶
type Page struct {
URL *url.URL
StatusCode int
ContentType string
Source []byte
Document *dom.Document
Events *events.Dispatcher
Stylesheet *css.Stylesheet
ComputedStyles style.Map
Animations *style.AnimationRegistry
Transitions *style.TransitionRegistry
BackgroundImages map[string]image.Image
BackgroundErrors []string
Scripts []Script
ScriptErrors []string
RuntimeStarted bool
RuntimeError string
HoverTarget dom.NodeID
HoverPath []dom.NodeID
FocusTarget dom.NodeID
ViewportWidth float32
ViewportHeight float32
ReducedMotion bool
StyleRevision uint64
}
Page holds the state of one loaded document.
Runtimeの状態はスクリプト取得エラーと分けて保持し、Goコードを実行できない場合も ページの表示を継続できるようにする。
func NewPage ¶
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) ActiveAnimations ¶
ActiveAnimations reports whether this page needs another animation frame.
func (*Page) AnimatedStyles ¶
AnimatedStyles samples this page's CSS Animations and Transitions at current without changing its underlying computed style map.
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.