Package org.nordstjernen
Class RemoteBrowser
java.lang.Object
org.nordstjernen.RemoteBrowser
- All Implemented Interfaces:
AutoCloseable
A long-lived browser backed by a single
nordstjernen-renderer
process. Unlike RemotePage (one page, then the renderer exits),
this keeps the renderer alive so an interactive shell can navigate, scroll,
render viewports, and follow links — the model the GTK shell uses.
No native engine is loaded into the JVM.
Not thread-safe; drive one instance from a single thread (or serialise).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classResult of a find-in-page query: match count, the current 1-based index, and where to scroll.static final classResult of a render: the image plus any side-channel the page requested.static final classA hover probe: whether the frame changed, the link under the point, and the CSS cursor.static final classResult of a key event: any navigation it triggered, and whether the page consumed it.static final classA clickable media element resolved at a point: its URL, whether it is video, and if it streams. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Drain any bufferedconsole.*output the page produced, or null.Evaluate JavaScript in the page and return its result rendered as text.booleanRender the whole page topath(a.pdf→ PDF, else PNG); true on success.favicon()The current page's favicon as an image, or null if it has none.Findqueryin the page.hover(int x, int y) Probe the point under the pointer: moves the engine's hover state (firing:hover/mouseover), and reports the link there and the CSS cursor name so the shell can mirror the GTK status bar and pointer shape.Forward a key event to the focused element.linkAt(int x, int y) The link URL at a document-coordinate point, or null.mediaAt(int x, int y) The media element (audio/video URL) at a document-coordinate point, or null.booleanNavigate tourl; returns false if the page failed to open.intintA client-side redirect (meta refresh or JSlocation) that fired while the just-opened page settled, or null.press(int x, int y, int mods) Press at a document-coordinate point (then callrelease()).release()Release a pending press; returns a navigation URL if the click followed a link.render(int scrollX, int scrollY, int width, int height, double scale) Render a viewport region (document coordinates via scroll) to an image.voidresolveWebgl(String origin, boolean allow) Allow or block WebGL fororiginfor the rest of the session.voidrestart()Replace a dead renderer with a fresh process.select(int kind, int x, int y) Drive a text selection.voidsetViewport(int widthCss, int heightCss) Tell the engine the viewport changed (re-lays out, fires resize).title()url()
-
Field Details
-
MAX_W
public static final int MAX_WMaximum framebuffer the renderer is asked to allocate.- See Also:
-
MAX_H
public static final int MAX_H- See Also:
-
-
Constructor Details
-
RemoteBrowser
public RemoteBrowser()
-
-
Method Details
-
setViewport
public void setViewport(int widthCss, int heightCss) Tell the engine the viewport changed (re-lays out, fires resize). -
render
Render a viewport region (document coordinates via scroll) to an image. -
linkAt
The link URL at a document-coordinate point, or null. -
hover
Probe the point under the pointer: moves the engine's hover state (firing:hover/mouseover), and reports the link there and the CSS cursor name so the shell can mirror the GTK status bar and pointer shape. -
select
Drive a text selection.kindis 0 to anchor a new selection at the point, 1 to extend it, 3 to select the whole document, and 4 to return the currently selected text (the copy path). Returns the selected text forkind == 4, otherwise null. -
find
Findqueryin the page.directionis 0 to (re)search fromfromY, 1 for the next match, 2 for the previous. Returns the match count, the current match index, and the document Y to scroll the match into view. -
eval
Evaluate JavaScript in the page and return its result rendered as text. -
consoleDrain
Drain any bufferedconsole.*output the page produced, or null. -
mediaAt
The media element (audio/video URL) at a document-coordinate point, or null. -
export
Render the whole page topath(a.pdf→ PDF, else PNG); true on success. -
resolveWebgl
Allow or block WebGL fororiginfor the rest of the session. -
favicon
The current page's favicon as an image, or null if it has none. -
press
Press at a document-coordinate point (then callrelease()). -
release
Release a pending press; returns a navigation URL if the click followed a link. -
key
Forward a key event to the focused element.kindis 0 for keydown, 1 for keyup, 2 to insertkeyas text, 3 for keypress.keyandcodeare theKeyboardEvent.key/.codevalues. -
title
-
url
-
pageWidth
public int pageWidth() -
pageHeight
public int pageHeight() -
restart
public void restart()Replace a dead renderer with a fresh process. Call after a request throws (the child crashed or wedged); the caller must then re-navigate, since the new process starts with no page loaded. -
close
public void close()- Specified by:
closein interfaceAutoCloseable