Documentation
¶
Overview ¶
Package browser contains the state and navigation lifecycle of a Growse browser window.
Index ¶
- Variables
- func IsTrustedOrigin(u *url.URL) bool
- type Browser
- func (b *Browser) ActivateCheckable(nodeID dom.NodeID) bool
- 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) HasAnimationFrameCallbacks() bool
- func (b *Browser) InspectPage(inspect func(*Page) bool) bool
- func (b *Browser) MoveFormFocus(reverse bool) bool
- 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) ReloadIgnoringCache(ctx context.Context) (*Page, error)
- func (b *Browser) ResetForm(nodeID dom.NodeID) bool
- func (b *Browser) RunAnimationFrame(current time.Time) bool
- 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) SetSelectValue(nodeID dom.NodeID, value string) bool
- func (b *Browser) Submit(ctx context.Context, formID, submitterID dom.NodeID) (*Page, error)
- func (b *Browser) SubmitForm(nodeID dom.NodeID) bool
- func (b *Browser) SubmitGET(ctx context.Context, formID, submitterID dom.NodeID) (*Page, error)
- func (b *Browser) SubmitPOST(ctx context.Context, formID, submitterID dom.NodeID) (*Page, error)
- func (b *Browser) UpdateFocus(nodeID dom.NodeID) bool
- func (b *Browser) UpdateHistoryScroll(first, offset int)
- func (b *Browser) UpdateHover(nodeID dom.NodeID, x, y float32) bool
- func (b *Browser) UpdateViewport(width, height float32) bool
- func (b *Browser) ValidateForm(nodeID dom.NodeID) bool
- type Page
- type ResourceLoader
- type Script
Constants ¶
This section is empty.
Variables ¶
var ( ErrFormValidation = errors.New("form validation failed") ErrSubmissionPrevented = errors.New("form submission was prevented") )
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 NewWithRuntimeFactoryAndStorage ¶ added in v0.9.0
func NewWithRuntimeFactoryAndStorage(client ResourceLoader, factory runtimemodel.Factory, manager *storagecore.Manager) *Browser
NewWithRuntimeFactoryAndStorage は注入されたStorage profileを使用するBrowserを生成する。
func (*Browser) ActivateCheckable ¶ added in v0.8.0
ActivateCheckable toggles a checkbox or selects one radio in its group.
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) HasAnimationFrameCallbacks ¶ added in v0.9.0
HasAnimationFrameCallbacks reports whether WebGo requested another frame.
func (*Browser) InspectPage ¶ added in v0.9.0
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) MoveFormFocus ¶ added in v0.8.0
MoveFormFocus advances focus through enabled controls in DOM order.
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) ReloadIgnoringCache ¶ added in v0.9.0
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
ResetForm restores a form's controls to their HTML attribute defaults.
func (*Browser) RunAnimationFrame ¶ added in v0.9.0
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) SetInputValue ¶
SetInputValue はユーザー入力をアクティブページの編集可能なText Controlへ反映する。
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) SetSelectValue ¶ added in v0.8.0
SetSelectValue changes a select to an enabled option and dispatches the input/change pair produced by a committed user selection.
func (*Browser) Submit ¶ added in v0.8.0
Submit validates and dispatches a cancelable submit event before navigation.
func (*Browser) SubmitForm ¶
SubmitForm はinputを含む最も近いformへsubmitイベントを配信する。
func (*Browser) SubmitGET ¶ added in v0.8.0
SubmitGET serializes a form into the action query and navigates with history.
func (*Browser) SubmitPOST ¶ added in v0.8.0
SubmitPOST sends URL-encoded entries and navigates to the response document.
func (*Browser) UpdateFocus ¶
UpdateFocus updates the element which matches the :focus pseudo-class.
func (*Browser) UpdateHistoryScroll ¶ added in v0.9.0
UpdateHistoryScroll はUIの現在scroll位置をactive History entryへ保存する。
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 {
HistoryID uint64
HistoryState string
ScrollFirst int
ScrollOffset int
ScrollRevision uint64
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
Submitter 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.