Classes | |
| struct | ViewportMapping |
| Maps CSS pixels — the unit every browser pointer event reports — to root-view coordinates. More... | |
| struct | BackingStore |
| Canvas backing-store size and the scale factor handed to the Skia surface. More... | |
| struct | BrowserModifiers |
| struct | BrowserPointerEvent |
| struct | BrowserWheelEvent |
| struct | BrowserKeyEvent |
| class | WebInputRouter |
| Routes translated browser events into a live View tree. More... | |
Enumerations | |
| enum class | BrowserPointerPhase : uint8_t { down , move , up , cancel } |
| W3C PointerEvent phase. More... | |
| enum class | BrowserPointerType : uint8_t { mouse , touch , pen } |
| W3C PointerEvent.pointerType. More... | |
| enum class | BrowserDeltaMode : uint8_t { pixel = 0 , line = 1 , page = 2 } |
| W3C WheelEvent.deltaMode. More... | |
Functions | |
| Point | css_to_root (const ViewportMapping &mapping, Point css) |
| CSS-pixel point → root-view point. Identity without a design viewport. | |
| Point | root_to_css (const ViewportMapping &mapping, Point root) |
| Root-view point → CSS-pixel point. The exact inverse of css_to_root(). | |
| BackingStore | compute_backing_store (float css_width, float css_height, float device_pixel_ratio) |
| The one place the HiDPI factor is applied. | |
| uint16_t | translate_modifiers (const BrowserModifiers &mods) |
| metaKey is Command on a Mac browser and the Super/Windows key elsewhere, so it sets both kModMeta and kModCmd. | |
| MouseButton | translate_button (int w3c_button) |
| PointerType | translate_pointer_type (BrowserPointerType type) |
| MouseEvent | translate_pointer (const BrowserPointerEvent &event, const ViewportMapping &mapping) |
| Browser pointer event → Pulp MouseEvent in ROOT coordinates. | |
| MouseEvent | translate_wheel (const BrowserWheelEvent &event, const ViewportMapping &mapping) |
| Browser wheel event → Pulp wheel MouseEvent in ROOT coordinates. | |
| KeyCode | translate_key_code (const std::string &key) |
| KeyboardEvent.key → KeyCode. | |
| KeyEvent | translate_key (const BrowserKeyEvent &event) |
| std::string | text_for_key (const BrowserKeyEvent &event) |
| The text a key-down should also deliver as a TextInputEvent, or "" when the key produces no character. | |
| void | install_browser_window_host (std::string canvas_selector="#canvas") |
| Register the Emscripten BrowserWindowHost factory so WindowHost::create() returns a canvas-backed host. | |
| void | install_web_input_listeners (const std::string &canvas_selector, WebInputRouter &router) |
| Attach/detach the DOM listeners (pointer, wheel, key, resize) that feed router. | |
| void | remove_web_input_listeners (const std::string &canvas_selector) |
| void | notify_browser_host_resized (float css_width, float css_height) |
| The canvas element's CSS size changed. | |
| bool | browser_host_gpu_available () |
| Is the live browser host's GPU surface renderable RIGHT NOW? | |
| float | device_pixel_ratio () |
| Current devicePixelRatio, and the canvas element's CSS size. Emscripten only. | |
| bool | canvas_css_size (const std::string &canvas_selector, float &css_width, float &css_height) |
| void | set_canvas_size (const std::string &canvas_selector, const BackingStore &backing, float css_width, float css_height) |
| Size the canvas element: backing store in device pixels, CSS box in CSS pixels. | |
| void | set_canvas_visible (const std::string &canvas_selector, bool visible) |
| Show/hide the canvas element (style.display). Emscripten only. | |
Variables | |
| constexpr float | kWheelLinePixels = 16.0f |
| A wheel line is one text line; a wheel page falls back to this when the mapping carries no CSS height. | |
| constexpr float | kWheelPageFallbackPixels = 400.0f |
|
strong |
|
strong |
|
strong |
| bool pulp::view::web::browser_host_gpu_available | ( | ) |
Is the live browser host's GPU surface renderable RIGHT NOW?
False while the WebGL context is lost — the browser can revoke it at any time (context-cap eviction, GPU-process crash, backgrounded mobile tab), and the Ganesh surface then abandons its Skia context and refuses to paint until webglcontextrestored arrives. Exposed so a host page (and the browser pixel fixture) can observe and assert that recovery instead of guessing from a frozen canvas. False when no host is installed. Emscripten only.
| bool pulp::view::web::canvas_css_size | ( | const std::string & | canvas_selector, |
| float & | css_width, | ||
| float & | css_height ) |
|
inline |
The one place the HiDPI factor is applied.
canvas.style.{width,height} stay at the CSS size, canvas.{width,height} become the returned device size, and scale_factor is the ratio — so paint scales up while input coordinates stay in CSS pixels.
|
inline |
CSS-pixel point → root-view point. Identity without a design viewport.
| float pulp::view::web::device_pixel_ratio | ( | ) |
Current devicePixelRatio, and the canvas element's CSS size. Emscripten only.
| void pulp::view::web::install_browser_window_host | ( | std::string | canvas_selector = "#canvas" | ) |
Register the Emscripten BrowserWindowHost factory so WindowHost::create() returns a canvas-backed host.
canvas_selector is a CSS selector for the target HTMLCanvasElement. Defined in platform/web/window_host_web.cpp, which is compiled only for Emscripten targets.
| void pulp::view::web::install_web_input_listeners | ( | const std::string & | canvas_selector, |
| WebInputRouter & | router ) |
Attach/detach the DOM listeners (pointer, wheel, key, resize) that feed router.
Defined in platform/web/web_input.cpp — Emscripten only.
| void pulp::view::web::notify_browser_host_resized | ( | float | css_width, |
| float | css_height ) |
The canvas element's CSS size changed.
Called by the resize listener in web_input.cpp; handled by the live host in window_host_web.cpp.
| void pulp::view::web::remove_web_input_listeners | ( | const std::string & | canvas_selector | ) |
|
inline |
Root-view point → CSS-pixel point. The exact inverse of css_to_root().
| void pulp::view::web::set_canvas_size | ( | const std::string & | canvas_selector, |
| const BackingStore & | backing, | ||
| float | css_width, | ||
| float | css_height ) |
Size the canvas element: backing store in device pixels, CSS box in CSS pixels.
Emscripten only.
| void pulp::view::web::set_canvas_visible | ( | const std::string & | canvas_selector, |
| bool | visible ) |
Show/hide the canvas element (style.display). Emscripten only.
|
inline |
The text a key-down should also deliver as a TextInputEvent, or "" when the key produces no character.
KeyboardEvent.key is the printable character itself for character keys and a multi-character NAME ("Enter", "ArrowLeft") otherwise; a non-ASCII character is a multi-byte UTF-8 string whose first byte has the high bit set, which is how it stays distinguishable from a name. Ctrl/Meta chords are commands, not text.
|
inline |
|
inline |
|
inline |
KeyboardEvent.key → KeyCode.
Unmapped names (modifier keys, media keys, …) return KeyCode::unknown, which still reaches the view tree as a KeyEvent so a widget can observe the modifier state.
|
inline |
metaKey is Command on a Mac browser and the Super/Windows key elsewhere, so it sets both kModMeta and kModCmd.
A wasm build is not __APPLE__, so is_main_modifier() resolves to Ctrl there — a shortcut that must follow the host OS reads isCmdDown()/isCtrlDown() explicitly.
|
inline |
Browser pointer event → Pulp MouseEvent in ROOT coordinates.
Both position and window_position carry the root point. The host overwrites position with the hit view's local coordinates before dispatch (the macOS host's convention), which it can only do once hit-testing has picked a target.
|
inline |
|
inline |
Browser wheel event → Pulp wheel MouseEvent in ROOT coordinates.
Sign is preserved: WheelEvent.deltaY is positive when the content scrolls DOWN, and Pulp's scroll_delta_y is positive-is-down too (ScrollView adds it straight onto its scroll offset). Non-pixel delta modes are normalized to CSS pixels.
|
inlineconstexpr |
A wheel line is one text line; a wheel page falls back to this when the mapping carries no CSS height.
|
inlineconstexpr |