docs
Loading...
Searching...
No Matches
CAPI_View.h
Go to the documentation of this file.
1///
2/// Copyright (C) 2026 Ultralight, Inc. All rights reserved.
3/// A license is required for commercial use. https://ultralig.ht
4///
5
6///
7/// @file CAPI_View.h
8///
9/// Web-page container rendered to an offscreen surface.
10///
11/// `#include <Ultralight/CAPI/CAPI_View.h>`
12///
13/// The View class is responsible for loading and rendering web-pages to an offscreen surface. It
14/// is completely isolated from the OS windowing system, you must forward all input events to it
15/// from your application.
16///
17/// ## Creating a View
18///
19/// You can create a View by calling ulCreateView():
20///
21/// ```
22/// // Create a ULViewConfig with default values
23/// ULViewConfig view_config = ulCreateViewConfig();
24///
25/// // Create a View, 500 by 500 pixels in size, using the default Session
26/// ULView view = ulCreateView(renderer, 500, 500, view_config, NULL);
27///
28/// // Clean up the ULViewConfig
29/// ulDestroyViewConfig(view_config);
30/// ```
31///
32/// @note When using ulCreateApp(), the library will automatically create a View for you when
33/// you call ulWindowAddPanel() (see `<AppCore/CAPI/CAPI_Layout.h>`).
34///
35/// ## Callbacks
36///
37/// Each ulViewSet*Callback() function holds one callback. Setting a callback replaces the previous
38/// one, and a NULL callback removes it.
39///
40/// Ownership of `user_data` transfers to the View. `destroy_user_data` (may be NULL) is invoked
41/// exactly once when the callback is replaced or the ULView handle is destroyed (never while the
42/// callback itself is running). If `view` is NULL, nothing is set and `destroy_user_data` runs
43/// right away.
44///
45/// Each setter owns its `user_data` separately, so a pointer registered with a destroy hook on two
46/// setters is released twice. Share one context by passing it with a NULL `destroy_user_data` to
47/// all but one setter, or give each setter its own allocation.
48///
49/// Callbacks belong to the ULView handle you set them on, and each callback receives that handle.
50/// A View delivers each group of callbacks to one handle: the load events (below), the download
51/// callbacks, the network-request callback, the editing callbacks (editable state and
52/// composition), and all the others. Setting a callback on a second handle for the same View (eg,
53/// another ulPanelGetView() result) moves its group to that handle, which turns off the first
54/// handle's callbacks in the group. Set all of a View's callbacks through one handle. Destroying a
55/// handle turns off only its own callbacks.
56///
57/// Callbacks run on the Renderer's thread.
58///
59/// ## Load Events
60///
61/// A page load calls these callbacks in order:
62///
63/// | Callback setter | When |
64/// |--------------------------------------|------------------------------------|
65/// | ulViewSetBeginLoadingCallback() | The load starts |
66/// | ulViewSetWindowObjectReadyCallback() | Before the page's scripts run |
67/// | ulViewSetDOMReadyCallback() | The document is parsed |
68/// | ulViewSetFinishLoadingCallback() | The load ends |
69/// | ulViewSetPageSettledCallback() | Loading and layout have gone quiet |
70///
71/// If the load fails, the fail-loading callback comes just before the finish-loading callback.
72///
73/// The window-object-ready and DOM-ready callbacks are called for every frame on the page (check
74/// `is_main_frame`). The begin, finish, and fail loading callbacks are called once per load for the
75/// frame that started it (usually the main frame).
76///
77/// @note The window-object-ready and DOM-ready callbacks aren't called when a page is restored
78/// from the back-forward cache.
79///
80#ifndef ULTRALIGHT_CAPI_VIEW_H
81#define ULTRALIGHT_CAPI_VIEW_H
82
87
88#ifdef __cplusplus
89extern "C" {
90#endif
91
92///
93/// The source of a console message.
94///
95/// @see ULAddConsoleMessageCallback
96///
117
118///
119/// The severity level of a console message.
120///
121/// @see ULAddConsoleMessageCallback
122///
130
131///
132/// Cursor types.
133///
134/// @see ULChangeCursorCallback
135///
182
183/******************************************************************************
184 * ViewConfig
185 *****************************************************************************/
186
187///
188/// Create view configuration with default values (see <Ultralight/View.h>).
189///
190/// @return Returns a new ULViewConfig instance. You must call ulDestroyViewConfig() when
191/// finished.
192///
194
195///
196/// Destroy a view configuration created by ulCreateViewConfig().
197///
198/// @param config The view configuration to destroy (can be NULL).
199///
201
202///
203/// Set a user-generated id of the display (monitor, TV, or screen) that the View will be shown on.
204///
205/// Animations are driven based on the physical refresh rate of the display. Multiple Views can
206/// share the same display.
207///
208/// @note This is automatically managed for you when ulCreateApp() is used.
209///
210/// @see ulRefreshDisplay()
211///
212ULExport void ulViewConfigSetDisplayId(ULViewConfig config, unsigned int display_id);
213
214///
215/// Set whether to render using the GPU renderer (accelerated) or the CPU renderer (unaccelerated).
216///
217/// This option is only valid if you're managing the Renderer yourself (eg, you've previously
218/// called ulCreateRenderer() instead of ulCreateApp()).
219///
220/// When true, the View will be rendered to an offscreen GPU texture using the GPU driver set in
221/// ulPlatformSetGPUDriver(). You can fetch details for the texture via ulViewGetRenderTarget().
222///
223/// When false (the default), the View will be rendered to an offscreen pixel buffer using the
224/// multithreaded CPU renderer. This pixel buffer can optionally be provided by the user--
225/// for more info see ulViewGetSurface().
226///
227/// @note You must set a GPU driver before creating an accelerated View (the process exits
228/// with an error otherwise).
229///
230ULExport void ulViewConfigSetIsAccelerated(ULViewConfig config, bool is_accelerated);
231
232///
233/// Set whether or not the View should support transparent backgrounds. (Default = False)
234///
235/// The page needs a transparent background too:
236///
237/// ```
238/// html, body { background: transparent; }
239/// ```
240///
241ULExport void ulViewConfigSetIsTransparent(ULViewConfig config, bool is_transparent);
242
243///
244/// Set the base background color the page renders on before any page styling applies, the color
245/// visible while a page loads and wherever the page itself paints nothing.
246/// (Default = unset, meaning opaque white)
247///
248/// Dark applications set a dark base so pages never flash white during load.
249///
250/// Transparent Views keep a fully transparent base regardless of this value. On opaque Views a
251/// translucent color is composited over white, so the View itself stays opaque.
252///
254
255///
256/// Set the color scheme the View reports to pages via the `prefers-color-scheme` CSS media
257/// feature. (Default = kColorScheme_Auto)
258///
259/// kColorScheme_Auto follows the system scheme set via ulRendererSetSystemColorScheme() (Light
260/// until it is fed a different value). Light or Dark pins the scheme for this View.
261///
262/// An out-of-range value logs a warning and leaves the config unchanged.
263///
264/// @note The scheme is only a signal to the page. Pages style themselves via media queries, and
265/// built-in UI (form controls, scrollbars, the default white canvas) keeps its light
266/// appearance under a dark scheme.
267///
268/// @see ulViewSetPreferredColorScheme()
269///
271
272///
273/// Set which pages may read the clipboard from script, eg, a page's own Paste button calling
274/// `document.execCommand('paste')`.
275/// (Default = kClipboardReadPolicy_AllowForAppContent)
276///
277/// The library only considers requests made during a user gesture (a click or key press);
278/// script running outside a gesture is always refused. Pastes the user performs directly
279/// (Ctrl+V, or ulEditorExecute with kEditorCommand_Paste) are never affected by this policy.
280///
281/// kClipboardReadPolicy_AllowForAppContent (the default) grants requests from your
282/// application's own content (local `file:///` pages and pages loaded from
283/// application-supplied data, eg, ulViewLoadHTML()) and refuses them from other pages.
284/// kClipboardReadPolicy_Allow grants requests from any page; kClipboardReadPolicy_Deny
285/// refuses them all.
286///
287/// An out-of-range value logs a warning and leaves the config unchanged.
288///
290
291///
292/// Set the initial device scale, ie. the amount to scale page units to screen pixels. This
293/// should be set to the scaling factor of the device that the View is displayed on.
294/// (Default = 1.0)
295///
296/// @note 1.0 is equal to 100% zoom (no scaling), 2.0 is equal to 200% zoom (2x scaling)
297///
298ULExport void ulViewConfigSetInitialDeviceScale(ULViewConfig config, double initial_device_scale);
299
300///
301/// Set whether or not the View should initially have input focus. (Default = True)
302///
304
305///
306/// Set whether images should be enabled (Default = True).
307///
309
310///
311/// Set whether JavaScript should be enabled (Default = True).
312///
314
315///
316/// Set whether text editing should follow the host OS's native conventions instead of the
317/// library's cross-platform behavior (Default = False).
318///
319/// When false, text selection and editing behave identically on every platform (a
320/// directionless selection is promoted to forward, the convention Windows browsers use).
321/// Set this to true for desktop applications that should feel native to each platform.
322///
323/// @note ulCreateApp() turns this on for the Views it creates for a panel added without a
324/// ViewConfig (see ulSettingsSetMatchNativeEditingBehavior() in <AppCore/CAPI.h>). A
325/// config you pass yourself keeps this value.
326///
328
329///
330/// Set the default font family, used for text that doesn't set one (Default = Times New Roman).
331///
333
334///
335/// Set the default monospace font family, eg, for `pre` and `code` (Default = Courier New).
336///
338
339///
340/// Set the default font family for the CSS `serif` generic (Default = Times New Roman).
341///
343
344///
345/// Set the default font family for the CSS `sans-serif` generic (Default = Arial).
346///
348
349///
350/// Set the default font family for the CSS `cursive` generic (Default = Comic Sans MS).
351///
353
354///
355/// Set the default font family for the CSS `fantasy` generic (Default = Impact).
356///
358
359///
360/// Set the default font family for the CSS `-webkit-pictograph` generic. Pass an empty string
361/// to use the standard font family (Default = empty).
362///
364
365///
366/// Set the default font size, in pixels (Default = 16).
367///
369
370///
371/// Set the default font size for monospace text, eg, `pre` and `code`, in pixels
372/// (Default = 13).
373///
374ULExport void ulViewConfigSetFontSizeFixed(ULViewConfig config, unsigned int size);
375
376///
377/// Set user agent string (See <Ultralight/platform/Config.h> for the default).
378///
380
381///
382/// Set whether or not compositing should be enabled. (Default = True)
383///
384/// When enabled, certain content (eg, 3D transforms, `will-change`, animated transforms or
385/// opacity, and video) paints into separate composited layers, making transform and opacity
386/// changes cheap to animate.
387///
389
390///
391/// Set whether or not to display compositor debug information. (Default = False)
392///
393/// @note Only valid when the compositor is enabled.
394///
396
397///
398/// Set whether or not the HTML5 Canvas Filters API (`CanvasRenderingContext2D.filter`) is
399/// enabled. (Default = True)
400///
402
403///
404/// Set whether to throttle JavaScript timers (setTimeout / setInterval) while the View is hidden
405/// (Default = False).
406///
407/// When enabled, repeating timers in a hidden View are aligned to roughly one-second boundaries
408/// (about 1 Hz) to reduce CPU usage for off-screen Views. They return to their normal rate once
409/// the View is shown again.
410///
411/// @note This does not affect requestAnimationFrame, which is always suspended while the View
412/// is hidden.
413///
414/// @see ulViewSetVisible()
415///
417
418///
419/// Set the maximum rate, in frames per second, at which the View advances its animations and
420/// repaints. (Default = 0, unthrottled)
421///
422/// This caps the View's whole frame loop (requestAnimationFrame, CSS and Web animations, smooth
423/// scrolling, and painting). A value of 0 leaves the View unthrottled, advancing at the display's
424/// refresh rate.
425///
426/// @note The View is always capped at your edition's maximum frame rate.
427///
428ULExport void ulViewConfigSetMaxRenderFps(ULViewConfig config, unsigned int fps);
429
430///
431/// Set whether or not a script can open a window with `window.open()` without a user gesture
432/// (Default = False).
433///
434/// When false, Ultralight behaves like a typical browser: a `window.open()` call succeeds only
435/// while the page is handling a user gesture, such as from a click handler. A call made on its
436/// own (on page load, or from a timer) is blocked as a popup. Set this to true to let scripts
437/// call `window.open()` at any time. The same gesture rule applies to a form submission that
438/// targets a new window.
439///
440/// @note Even when this is allowed, a window is only created if your create-child-view callback
441/// returns one; return NULL there to block it.
442///
443/// @see ulViewSetCreateChildViewCallback()
444///
446 bool enabled);
447
448///
449/// Set whether or not pages loaded from `file:///` URLs can access content from any origin
450/// (Default = True).
451///
452/// When true, a `file:///` page can read other frames' documents and make requests to any origin
453/// without cross-origin checks. Set this to false to give `file:///` pages the same cross-origin
454/// rules as web pages (they stay same-origin with other `file:///` pages).
455///
457
458/******************************************************************************
459 * View
460 *****************************************************************************/
461
462///
463/// Create a View with certain size (in pixels).
464///
465/// @param renderer The active renderer instance.
466///
467/// @param width The initial width, in pixels.
468///
469/// @param height The initial height, in pixels.
470///
471/// @param view_config Configuration details for the View. Pass NULL to use the default
472/// configuration.
473///
474/// @param session The session to store local data in. Pass NULL to use the default session.
475///
476/// @return Returns a new ULView instance. You must call ulDestroyView() when finished.
477///
478ULExport ULView ulCreateView(ULRenderer renderer, unsigned int width, unsigned int height,
479 ULViewConfig view_config, ULSession session);
480
481///
482/// Destroy a View previously created with ulCreateView().
483///
484/// @param view The View to destroy (can be NULL).
485///
487
488///
489/// Get current URL.
490///
491/// @note Don't destroy the returned string, it is owned by the View. This value is reset with
492/// every call-- if you want to retain it you should copy it via ulCreateStringFromCopy().
493///
495
496///
497/// Get current title.
498///
499/// @note Don't destroy the returned string, it is owned by the View. This value is reset with
500/// every call-- if you want to retain it you should copy it via ulCreateStringFromCopy().
501///
503
504///
505/// Get the width, in pixels.
506///
507ULExport unsigned int ulViewGetWidth(ULView view);
508
509///
510/// Get the height, in pixels.
511///
512ULExport unsigned int ulViewGetHeight(ULView view);
513
514///
515/// Get the display id of the View.
516///
518
519///
520/// Set the display id of the View.
521///
522/// You should call this when the View moves to another display.
523///
524/// @param view The View.
525///
526/// @param display_id The id of the new display (see ulViewConfigSetDisplayId()).
527///
528/// @note This is automatically managed for you for Views hosted in an AppCore window.
529///
530ULExport void ulViewSetDisplayId(ULView view, unsigned int display_id);
531
532///
533/// Get the device scale, ie. the amount to scale page units to screen pixels.
534///
535/// For example, a value of 1.0 is equivalent to 100% zoom. A value of 2.0 is 200% zoom.
536///
538
539///
540/// Set the device scale.
541///
542/// @param view The View.
543///
544/// @param scale The new device scale (see ulViewGetDeviceScale()).
545///
546/// @note To change the View's size at the same time, use ulViewResizeWithScale() instead,
547/// which applies both in one pass.
548///
549ULExport void ulViewSetDeviceScale(ULView view, double scale);
550
551///
552/// Whether or not the View is GPU-accelerated. If this is false, the page will be rendered
553/// via the CPU renderer.
554///
556
557///
558/// Whether or not the View supports transparent backgrounds.
559///
561
562///
563/// Check if the main frame of the page is currently loading.
564///
566
567///
568/// Check whether the page has settled after loading.
569///
570/// This is the queryable form of the page-settled callback. It flips true when that callback
571/// fires and resets to false on each new navigation.
572///
573/// @return Returns true once the page's network and layout activity have gone idle following
574/// the main frame's onload event, and false otherwise.
575///
576/// @see ulViewSetPageSettledCallback()
577///
579
580///
581/// Get the RenderTarget for the View.
582///
583/// @note Only valid if this View is GPU accelerated.
584///
585/// You can use this with your GPUDriver implementation to bind and display the
586/// corresponding texture in your application.
587///
589
590///
591/// Get the Surface for the View (native pixel buffer that the CPU renderer draws into).
592///
593/// @note This operation is only valid if you're managing the Renderer yourself (eg, you've
594/// previously called ulCreateRenderer() instead of ulCreateApp()).
595///
596/// This returns NULL if the View uses the GPU renderer.
597///
598/// The default Surface is BitmapSurface, but you can provide your own Surface
599/// implementation with ulPlatformSetSurfaceDefinition().
600///
601/// When using the default Surface, you can retrieve the underlying bitmap by casting
602/// ULSurface to ULBitmapSurface and calling ulBitmapSurfaceGetBitmap().
603///
605
606///
607/// Load a raw string of HTML, the View will navigate to it as a new page.
608///
609ULExport void ulViewLoadHTML(ULView view, ULString html_string);
610
611///
612/// Load a raw string of HTML with additional options.
613///
614/// @param view The View.
615///
616/// @param html_string The raw HTML string to load.
617///
618/// @param url An optional URL for this load (to make it appear as if the HTML was
619/// loaded from a certain URL). Can be used for resolving relative URLs
620/// and cross-origin rules. Pass an empty ULString to use no URL.
621///
622/// @param add_to_history Whether or not this load should be added to the session's history
623/// (eg, the back/forward list).
624///
626 bool add_to_history);
627
628///
629/// Load a URL, the View will navigate to it as a new page.
630///
631/// @param view The View.
632///
633/// @param url_string The URL to load.
634///
635/// @note You can use file URLs (eg, `file:///page.html`), but you must provide your own file
636/// system if you aren't using AppCore (see ulPlatformSetFileSystem()).
637///
638ULExport void ulViewLoadURL(ULView view, ULString url_string);
639
640///
641/// Resize view to a certain width and height (in pixels).
642///
643ULExport void ulViewResize(ULView view, unsigned int width, unsigned int height);
644
645///
646/// Resize view and apply a new device scale in the same pass.
647///
648/// Prefer this over separate ulViewSetDeviceScale() and ulViewResize() calls when both change at
649/// once, for example when a window moves to a display with a different DPI. Applying them
650/// together resizes the page once instead of twice.
651///
652/// @param view The View.
653///
654/// @param width The new width, in pixels.
655///
656/// @param height The new height, in pixels.
657///
658/// @param device_scale The new device scale (see ulViewSetDeviceScale()).
659///
660/// @see ulViewResize()
661///
662ULExport void ulViewResizeWithScale(ULView view, unsigned int width, unsigned int height,
663 double device_scale);
664
665///
666/// Acquire the page's JSContext for use with JavaScriptCore API.
667///
668/// \parblock
669/// @note This locks the JavaScript VM for the current thread. You should call
670/// ulViewUnlockJSContext() when you're done so other threads can use JavaScript.
671/// \endparblock
672///
673/// \parblock
674/// @note The lock is recursive, it's okay to call this multiple times as long as you call
675/// ulViewUnlockJSContext() the same number of times.
676/// \endparblock
677///
679
680///
681/// Unlock the page's JSContext after a previous call to ulViewLockJSContext().
682///
684
685///
686/// Evaluate a string of JavaScript and return result.
687///
688/// @param view The View.
689///
690/// @param js_string The string of JavaScript to evaluate.
691///
692/// @param exception The address of a ULString that receives the exception message if the
693/// script throws, or an empty string if it doesn't. Pass NULL to ignore this.
694/// Don't destroy the exception string returned, it's owned by the View.
695///
696/// \parblock
697/// @note Don't destroy the returned string, it's owned by the View. This value is reset with
698/// every call-- if you want to retain it you should copy the result to a new string via
699/// ulCreateStringFromCopy().
700/// \endparblock
701///
702/// \parblock
703/// @note The result is converted to a string (eg, `undefined` becomes "undefined"), or is empty
704/// if the page can't run scripts.
705/// \endparblock
706///
707/// ```
708/// ULString script = ulCreateString("1 + 1");
709/// ULString exception;
710/// ULString result = ulViewEvaluateScript(view, script, &exception);
711/// /* Use the result ("2") and exception description (if any) here. */
712/// ulDestroyString(script);
713/// ```
714///
716
717///
718/// Acquire the JSContext of a specific frame for use with JavaScriptCore API.
719///
720/// @param view The View.
721///
722/// @param frame The name of the frame to access. Pass an empty string for the main frame, or
723/// the name attribute of one of the main frame's iframes.
724///
725/// @return Returns the JSContextRef for the frame, or NULL if the frame doesn't exist or can't
726/// run scripts.
727///
728/// \parblock
729/// @note This locks the JavaScript VM for the current thread. You should call
730/// ulViewUnlockJSContextWithFrame() with the same frame name when you're done so other
731/// threads can use JavaScript.
732/// \endparblock
733///
734/// \parblock
735/// @note The lock is recursive, it's okay to call this multiple times as long as you call
736/// ulViewUnlockJSContextWithFrame() the same number of times.
737/// \endparblock
738///
740
741///
742/// Unlock the JSContext of a specific frame after a previous call to
743/// ulViewLockJSContextWithFrame().
744///
745/// @param view The View.
746///
747/// @param frame The frame name you passed to ulViewLockJSContextWithFrame().
748///
749/// @note Must be called the same number of times as ulViewLockJSContextWithFrame() for the same
750/// frame name (the lock is recursive).
751///
753
754///
755/// Get a ULJS handle to the main frame's JavaScript context.
756///
757/// Unlike ulViewLockJSContext(), the returned handle never keeps the page alive. When the page
758/// navigates away or the View is destroyed, the handle stops working and operations on it fail
759/// safely. Use it with the functions in `<Ultralight/CAPI/CAPI_JSValue.h>`.
760///
761/// @return Returns a new ULJSContext handle for the current page, or NULL if the main frame
762/// can't run scripts (eg, when ulViewConfigSetEnableJavaScript() disabled JavaScript,
763/// or the document is sandboxed against scripts). You must call ulDestroyJSContext()
764/// when finished.
765///
766/// @note Each page gets a fresh context. After a navigation, call this again to obtain a handle
767/// to the new page's context. The callbacks set via ulViewSetWindowObjectReadyCallback()
768/// and ulViewSetDOMReadyCallback() are good acquisition points.
769///
771
772///
773/// Get a handle to the internal JavaScriptCore VM for a specific frame.
774///
775/// @param view The View.
776///
777/// @param frame The name of the frame to access. Pass an empty string for the main frame, or
778/// the name attribute of one of the main frame's iframes.
779///
780/// @return Returns a pointer to the VM, or NULL if the frame doesn't exist or can't run
781/// scripts. Every frame and View shares one VM.
782///
784
785///
786/// Evaluate a string of JavaScript in a specific frame and return the result.
787///
788/// @param view The View.
789///
790/// @param js_string The string of JavaScript to evaluate.
791///
792/// @param exception The address of a ULString that receives the exception message if the
793/// script throws, or an empty string if it doesn't. Pass NULL to ignore this.
794/// Don't destroy the exception string returned, it's owned by the View.
795///
796/// @param frame The name of the frame to evaluate the script in. Pass an empty string for
797/// the main frame, or the name attribute of one of the main frame's iframes.
798///
799/// @return Returns the result converted to a string (eg, `undefined` becomes "undefined"), or
800/// an empty string if the frame doesn't exist or can't run scripts. Don't destroy the
801/// returned string, it's owned by the View. This value is reset with every call-- if
802/// you want to retain it you should copy it via ulCreateStringFromCopy().
803///
805 ULString* exception, ULString frame);
806
807///
808/// Whether or not the View can navigate back in history.
809///
811
812///
813/// Whether or not the View can navigate forward in history.
814///
816
817///
818/// Navigate backwards in history.
819///
821
822///
823/// Navigate forwards in history.
824///
826
827///
828/// Navigate to an arbitrary offset in history.
829///
830/// @param view The View.
831///
832/// @param offset The number of entries to move (negative goes back, positive goes forward).
833///
835
836///
837/// Reload current page.
838///
840
841///
842/// Stop all page loads.
843///
845
846///
847/// Give focus to the View.
848///
849/// You should call this to give visual indication that the View has input focus (changes active
850/// text selection colors, for example). The page gets a window `focus` event, and so does the
851/// element that had focus before ulViewUnfocus().
852///
854
855///
856/// Remove focus from the View.
857///
858/// You should call this to give visual indication that the View has lost input focus. The page
859/// gets a window `blur` event.
860///
861/// @note The page's focused element gets a blur event but stays focused in the document, and
862/// shows focus again the next time you call ulViewFocus().
863///
865
866///
867/// Whether or not the View has focus.
868///
870
871///
872/// Whether or not the View has an input element with visible keyboard focus (indicated by a
873/// blinking caret).
874///
875/// You can use this to decide whether or not the View should consume keyboard input events (useful
876/// in games with mixed UI and key handling).
877///
878/// @note This reports text-editing focus specifically: a focused text field, text area, or
879/// editable (contenteditable) region that can accept typed input. Focused elements that
880/// consume keys without editing text (eg, a select or checkbox) report false, as do
881/// read-only text fields, and so does everything while the View itself is unfocused
882/// (see ulViewUnfocus()).
883///
885
886///
887/// Fire a keyboard event.
888///
889/// @param view The View.
890///
891/// @param key_event The key event.
892///
893/// @note kKeyEventType_Char events insert text into input fields, and so does a legacy
894/// kKeyEventType_KeyDown that carries text. kKeyEventType_RawKeyDown never inserts text.
895///
897
898///
899/// Fire a mouse event.
900///
901/// @param view The View.
902///
903/// @param mouse_event The mouse event.
904///
906
907///
908/// Fire a scroll event.
909///
910/// @param view The View.
911///
912/// @param scroll_event The scroll event.
913///
915
916typedef void (*ULChangeTitleCallback)(void* user_data, ULView caller, ULString title);
917
918///
919/// Set callback for when the page title changes.
920///
922 void* user_data,
923 ULUserDataDestroyCallback destroy_user_data);
924
925typedef void (*ULChangeURLCallback)(void* user_data, ULView caller, ULString url);
926
927///
928/// Set callback for when the main frame loads a new page.
929///
931 void* user_data,
932 ULUserDataDestroyCallback destroy_user_data);
933
934typedef void (*ULChangeTooltipCallback)(void* user_data, ULView caller, ULString tooltip);
935
936///
937/// Set callback for when the tooltip under the mouse changes (the text is empty when there's no
938/// tooltip).
939///
940/// This is called as the mouse moves over the page, with the tooltip text of the element under
941/// the cursor (eg, its `title` attribute). It may repeat the same text on every move.
942///
943/// The library doesn't display tooltips (and neither does AppCore)-- you should draw the text
944/// yourself near the cursor and hide it when the text is empty.
945///
947 void* user_data,
948 ULUserDataDestroyCallback destroy_user_data);
949
950typedef void (*ULChangeCursorCallback)(void* user_data, ULView caller, ULCursor cursor);
951
952///
953/// Set callback for when the mouse cursor changes.
954///
956 void* user_data,
957 ULUserDataDestroyCallback destroy_user_data);
958
959typedef void (*ULChangeEditableStateCallback)(void* user_data, ULView caller,
960 ULEditableState state);
961
962///
963/// Set callback for when the editable state changes.
964///
965/// This happens when focus moves to or from an editable element, when the View gains or loses
966/// focus, and when the focused element's `inputmode` changes. Use the state to turn an input
967/// method or on-screen keyboard on or off (see ULEditableState).
968///
969/// @warning The callback can be called from inside your own ulViewFocus() or ulViewUnfocus()
970/// call. Don't change focus or content from the callback (wait until it returns).
971///
974 void* user_data,
975 ULUserDataDestroyCallback destroy_user_data);
976
977typedef void (*ULUpdateCompositionCallback)(void* user_data, ULView caller);
978
979///
980/// Set callback for after every change to the active composition.
981///
982/// Move the input method's candidate window from the callback (see
983/// ulEditorGetCompositionCharacterBounds()).
984///
987 void* user_data,
988 ULUserDataDestroyCallback destroy_user_data);
989
990typedef void (*ULDiscardCompositionCallback)(void* user_data, ULView caller);
991
992///
993/// Set callback for when the page ends the active composition on its own (eg, on navigation or
994/// when the selection moves away from it).
995///
996/// Cancel the input method's composition from the callback (on Windows, call ImmNotifyIME() with
997/// CPS_CANCEL). The composition's text stays in the page as final text, so don't insert it again.
998///
1001 void* user_data,
1002 ULUserDataDestroyCallback destroy_user_data);
1003
1004typedef void (*ULAddConsoleMessageCallback)(void* user_data, ULView caller, ULMessageSource source,
1005 ULMessageLevel level, ULString message,
1006 unsigned int line_number, unsigned int column_number,
1007 ULString source_id);
1008
1009///
1010/// Set callback for when the page adds a message to the console (useful for errors and
1011/// debugging).
1012///
1014 void* user_data,
1015 ULUserDataDestroyCallback destroy_user_data);
1016
1017typedef ULView (*ULCreateChildViewCallback)(void* user_data, ULView caller, ULString opener_url,
1018 ULString target_url, bool is_popup,
1019 ULIntRect popup_rect);
1020
1021///
1022/// Set callback for when the page wants to open a new window (a link with `target="_blank"` or a
1023/// call to `window.open()`).
1024///
1025/// Return a new View from the callback to allow the window or NULL to block it. The library loads
1026/// `target_url` into the View, and you display it. `popup_rect` is the position and size the page
1027/// asked for in `window.open()`.
1028///
1029/// @warning Don't destroy the View you return while its window is open.
1030///
1032 void* user_data,
1033 ULUserDataDestroyCallback destroy_user_data);
1034
1035typedef ULView (*ULCreateInspectorViewCallback)(void* user_data, ULView caller, bool is_local,
1036 ULString inspected_url);
1037
1038///
1039/// Set callback for when the inspector needs a View to display in (after
1040/// ulViewCreateLocalInspectorView() or when a remote inspector connects).
1041///
1042/// Return a new View from the callback or NULL to cancel. The library loads the inspector into the
1043/// View, and you display it.
1044///
1047 void* user_data,
1048 ULUserDataDestroyCallback destroy_user_data);
1049
1050typedef void (*ULBeginLoadingCallback)(void* user_data, ULView caller, unsigned long long frame_id,
1051 bool is_main_frame, ULString url);
1052
1053///
1054/// Set callback for when a load starts (see "Load Events" in the file description).
1055///
1057 void* user_data,
1058 ULUserDataDestroyCallback destroy_user_data);
1059
1060typedef void (*ULFinishLoadingCallback)(void* user_data, ULView caller, unsigned long long frame_id,
1061 bool is_main_frame, ULString url);
1062
1063///
1064/// Set callback for when a load ends (whether or not it succeeded).
1065///
1067 void* user_data,
1068 ULUserDataDestroyCallback destroy_user_data);
1069
1070typedef void (*ULFailLoadingCallback)(void* user_data, ULView caller, unsigned long long frame_id,
1071 bool is_main_frame, ULString url, ULString description,
1072 ULString error_domain, int error_code);
1073
1074///
1075/// Set callback for when a load fails (just before the finish-loading callback).
1076///
1077/// HTTP error responses count as failures (`error_domain` is "HTTPErrorDomain" and `error_code`
1078/// is the HTTP status code). Canceled loads aren't reported.
1079///
1081 void* user_data,
1082 ULUserDataDestroyCallback destroy_user_data);
1083
1084typedef void (*ULWindowObjectReadyCallback)(void* user_data, ULView caller,
1085 unsigned long long frame_id, bool is_main_frame,
1086 ULString url);
1087
1088///
1089/// Set callback for before a frame's scripts run.
1090///
1091/// Set up JavaScript state for the page from the callback (APIs you added with ulViewAttachJSAPI()
1092/// are already there). Use the DOM-ready callback for anything that needs the DOM.
1093///
1094/// @note Only called when JavaScript is enabled. A page with no scripts may never trigger it.
1095///
1097 void* user_data,
1098 ULUserDataDestroyCallback destroy_user_data);
1099
1100typedef void (*ULDOMReadyCallback)(void* user_data, ULView caller, unsigned long long frame_id,
1101 bool is_main_frame, ULString url);
1102
1103///
1104/// Set callback for when a frame's document has been parsed and the DOM is ready.
1105///
1106/// This is the best time to read or change the DOM. The page's own `DOMContentLoaded` event has
1107/// already fired. This is also called when JavaScript is disabled.
1108///
1110 ULUserDataDestroyCallback destroy_user_data);
1111
1112typedef void (*ULUpdateHistoryCallback)(void* user_data, ULView caller);
1113
1114///
1115/// Set callback for when the main frame's back-forward history changes.
1116///
1118 void* user_data,
1119 ULUserDataDestroyCallback destroy_user_data);
1120
1121typedef void (*ULPageSettledCallback)(void* user_data, ULView caller, ULString url);
1122
1123///
1124/// Set callback for when the page has settled and is ready to capture or display (resources have
1125/// loaded, initial scripts have run, and layout is stable).
1126///
1127/// This fires after the finish-loading callback once network and layout activity have stayed idle
1128/// for a short time (see ulConfigSetPageSettleDelay()).
1129///
1130/// @warning Pages with constant network or layout activity (ads, animated layouts, streaming
1131/// video) may never settle. Use a timeout.
1132///
1133/// \parblock
1134/// @note Animations that don't change layout (eg, a CSS transform or opacity transition) can
1135/// still be running when the page settles.
1136/// \endparblock
1137///
1138/// \parblock
1139/// @note You must call ulUpdate(), ulRefreshDisplay(), and ulRender() from your run loop for this
1140/// to fire (ulCreateApp() does this for you).
1141/// \endparblock
1142///
1144 void* user_data,
1145 ULUserDataDestroyCallback destroy_user_data);
1146
1147///
1148/// Set whether or not a view should be repainted during the next call to ulRender().
1149///
1150/// @param view The View.
1151///
1152/// @param needs_paint Whether or not the View needs a repaint.
1153///
1154/// @note The library sets this flag automatically when a repaint is due: after a
1155/// ulRefreshDisplay() call that produces animating or changed content, on resize, when the
1156/// View is shown, and when the page reacts to user input. You can also set it directly to
1157/// force a repaint (it still waits for the View's frame-rate cap).
1158///
1159ULExport void ulViewSetNeedsPaint(ULView view, bool needs_paint);
1160
1161///
1162/// Whether or not a view should be painted during the next call to ulRender().
1163///
1164/// When this returns false, rendering would reproduce the previous frame, so you can skip
1165/// rendering or presenting the view. This is always false while the View is hidden, and while
1166/// its frame-rate cap holds back its next frame.
1167///
1168/// When this returns true, the next call to ulRender() repaints the view. The resulting frame
1169/// may still be visually identical to the previous frame.
1170///
1171/// @note Continue calling ulRefreshDisplay() on every display refresh regardless of this flag.
1172/// A View whose only pending work is animation callbacks or CSS animations repaints only
1173/// after that call, and reports ulViewGetNeedsPaint() as true again from it.
1174///
1176
1177///
1178/// Set whether or not this View is visible. (Default = True)
1179///
1180/// Hiding a View (passing false) stops it from being painted during ulRender and pauses its
1181/// requestAnimationFrame callbacks and CSS animations (they stop advancing while hidden). The
1182/// page's `visibilitychange` event fires with `document.visibilityState` set to "hidden".
1183///
1184/// Showing a View again (passing true) resumes its animations and forces a repaint on the next
1185/// call to ulRender.
1186///
1187/// @param view The View.
1188///
1189/// @param visible Whether or not the View is visible.
1190///
1191/// @note JavaScript timers (setTimeout / setInterval) keep running while hidden unless
1192/// ulViewConfigSetEnableHiddenTimerThrottling() was set when the View was created.
1193///
1194ULExport void ulViewSetVisible(ULView view, bool visible);
1195
1196///
1197/// Whether or not this View is visible.
1198///
1200
1201///
1202/// Get the frame-rate cap (in FPS) set for the View, or 0 if none is set.
1203///
1205
1206///
1207/// Set the maximum rate, in frames per second, at which the View advances its animations and
1208/// repaints. (Default = 0, unthrottled)
1209///
1210/// This caps the View's whole frame loop (requestAnimationFrame, CSS and Web animations, smooth
1211/// scrolling, and painting).
1212///
1213/// @param view The View.
1214///
1215/// @param fps The frame-rate cap, or 0 to remove it (the View then advances at the display's
1216/// refresh rate).
1217///
1218ULExport void ulViewSetMaxRenderFps(ULView view, unsigned int fps);
1219
1220///
1221/// Set the color scheme this View reports to pages via the `prefers-color-scheme` CSS media
1222/// feature. (Default = kColorScheme_Auto)
1223///
1224/// Overrides the value set via ulViewConfigSetPreferredColorScheme(). A change re-evaluates
1225/// `prefers-color-scheme` media queries on the page. `matchMedia` change listeners fire and
1226/// styles recalculate, the same as an OS theme change.
1227///
1228/// An out-of-range value logs a warning and leaves the View unchanged.
1229///
1230/// @see ulRendererSetSystemColorScheme()
1231///
1233
1234///
1235/// Get the color scheme this View reports to pages.
1236///
1238
1239///
1240/// Create an Inspector View to inspect / debug this View locally.
1241///
1242/// This will only succeed if you have the inspector assets in your filesystem-- the inspector
1243/// will look for file:///inspector/Main.html when it first loads.
1244///
1245/// You must handle ulViewSetCreateInspectorViewCallback() so that the library has a View to display
1246/// the inspector in. This function will call the callback only if an inspector view is not
1247/// currently active.
1248///
1250
1251///
1252/// Set whether or not to display compositor debug information.
1253///
1254/// @param view The View.
1255///
1256/// @param enabled Whether or not to show the debug information.
1257///
1258/// @note Only valid when the compositor is enabled.
1259///
1261
1262///
1263/// Whether or not compositor debug information is enabled.
1264///
1266
1267/******************************************************************************
1268 * ViewListener: OnRequestClose
1269 *****************************************************************************/
1270
1271typedef void (*ULRequestCloseCallback)(void* user_data, ULView caller);
1272
1273///
1274/// Set callback for when the page asks to close (`window.close()` in a window that script
1275/// opened, or in one with a single page in its history).
1276///
1278 void* user_data,
1279 ULUserDataDestroyCallback destroy_user_data);
1280
1281/******************************************************************************
1282 * DownloadListener
1283 *****************************************************************************/
1284
1285///
1286/// Callback for when the View needs an ID for a new download.
1287///
1288/// A download starts when the page navigates to a file it can't display (eg, a response with
1289/// `Content-Disposition: attachment`). Downloads are ignored until you set the download
1290/// callbacks.
1291///
1292/// The library doesn't write anything to disk. You save the data yourself in these callbacks
1293/// (called in this order):
1294///
1295/// | Callback | What to do |
1296/// |-------------------------------|------------------------------------|
1297/// | ULDownloadNextIdCallback | Return a new ID |
1298/// | ULDownloadRequestCallback | Return true to accept the download |
1299/// | ULDownloadBeginCallback | Open a file |
1300/// | ULDownloadReceiveDataCallback | Write the data to the file |
1301/// | ULDownloadFinishCallback | Close the file |
1302/// | ULDownloadFailCallback | Close the file and delete it |
1303///
1304/// @return Return a new ID (a different one on every call, eg a counter starting at 0).
1305///
1306typedef unsigned int (*ULDownloadNextIdCallback)(void* user_data, ULView caller);
1307
1308///
1309/// Callback for when the page wants to download a file.
1310///
1311/// @return Return true to allow the download, or false to block it.
1312///
1313typedef bool (*ULDownloadRequestCallback)(void* user_data, ULView caller, unsigned int id,
1314 ULString url);
1315
1316///
1317/// Callback for when a download starts.
1318///
1319/// Open a file to write the data to here. `filename` is the suggested file name (from the server,
1320/// or the end of the URL).
1321///
1322typedef void (*ULDownloadBeginCallback)(void* user_data, ULView caller, unsigned int id,
1323 ULString url, ULString filename,
1324 long long expected_content_length);
1325
1326///
1327/// Callback for when a download receives data (usually several times per download).
1328///
1329/// Write the data to the file here.
1330///
1331/// @param data The data (only valid during this call, so copy it to keep it).
1332///
1333typedef void (*ULDownloadReceiveDataCallback)(void* user_data, ULView caller, unsigned int id,
1334 ULBuffer data);
1335
1336///
1337/// Callback for when a download finishes.
1338///
1339/// Close the file here.
1340///
1341typedef void (*ULDownloadFinishCallback)(void* user_data, ULView caller, unsigned int id);
1342
1343///
1344/// Callback for when a download fails.
1345///
1346/// Close the file and delete it here.
1347///
1348typedef void (*ULDownloadFailCallback)(void* user_data, ULView caller, unsigned int id);
1349
1350///
1351/// Set callback for generating unique download ids.
1352///
1354 void* user_data,
1355 ULUserDataDestroyCallback destroy_user_data);
1356
1357///
1358/// Set callback for when the View requests a download.
1359///
1361 void* user_data,
1362 ULUserDataDestroyCallback destroy_user_data);
1363
1364///
1365/// Set callback for when a download begins.
1366///
1368 void* user_data,
1369 ULUserDataDestroyCallback destroy_user_data);
1370
1371///
1372/// Set callback for when download data is received.
1373///
1376 void* user_data,
1377 ULUserDataDestroyCallback destroy_user_data);
1378
1379///
1380/// Set callback for when a download finishes.
1381///
1383 void* user_data,
1384 ULUserDataDestroyCallback destroy_user_data);
1385
1386///
1387/// Set callback for when a download fails.
1388///
1390 void* user_data,
1391 ULUserDataDestroyCallback destroy_user_data);
1392
1393///
1394/// Cancel an active download.
1395///
1396/// No more data arrives for the download, and the callback set with
1397/// ulViewSetDownloadFailCallback() is called for it during a later ulUpdate().
1398///
1399/// @param view The View.
1400///
1401/// @param id The download id to cancel.
1402///
1403ULExport void ulViewCancelDownload(ULView view, unsigned int id);
1404
1405/******************************************************************************
1406 * NetworkListener
1407 *****************************************************************************/
1408
1409///
1410/// Callback for before the View sends a network request.
1411///
1412/// @return Return true to allow the request, or false to block it.
1413///
1414/// @note `file:` and `data:` URLs and synchronous XMLHttpRequests don't go through here.
1415///
1416/// @pre Not available in the Free edition (the callback is never called there).
1417///
1418typedef bool (*ULNetworkRequestCallback)(void* user_data, ULView caller, ULString url);
1419
1420///
1421/// Set callback for when the View is about to begin a network request.
1422///
1424 void* user_data,
1425 ULUserDataDestroyCallback destroy_user_data);
1426
1427#ifdef __cplusplus
1428} // extern "C"
1429#endif
1430
1431#endif // ULTRALIGHT_CAPI_VIEW_H
An RGBA color value in a certain color space (with CSS parsing helpers).
struct C_JSContext * ULJSContext
Opaque handle to a JavaScript context (see <Ultralight/CAPI/CAPI_JSValue.h>).
Definition CAPI_DOMDocument.h:758
Text-editing interface for a View.
JavaScript context and value handles for interacting with page script in C.
void(*) ULChangeTooltipCallback(void *user_data, ULView caller, ULString tooltip)
Definition CAPI_View.h:934
void ulViewConfigSetEnableCompositorDebugInfo(ULViewConfig config, bool enabled)
Set whether or not to display compositor debug information.
void ulViewFireMouseEvent(ULView view, ULMouseEvent mouse_event)
Fire a mouse event.
ULMessageSource
The source of a console message.
Definition CAPI_View.h:97
@ kMessageSource_CSS
Definition CAPI_View.h:105
@ kMessageSource_JS
Definition CAPI_View.h:99
@ kMessageSource_Network
Definition CAPI_View.h:100
@ kMessageSource_Media
Definition CAPI_View.h:108
@ kMessageSource_PaymentRequest
Definition CAPI_View.h:113
@ kMessageSource_AppCache
Definition CAPI_View.h:103
@ kMessageSource_WebRTC
Definition CAPI_View.h:110
@ kMessageSource_ContentBlocker
Definition CAPI_View.h:107
@ kMessageSource_NativeAPI
Diagnostics from application-bound JavaScript APIs.
Definition CAPI_View.h:115
@ kMessageSource_MediaSource
Definition CAPI_View.h:109
@ kMessageSource_ITPDebug
Definition CAPI_View.h:111
@ kMessageSource_XML
Definition CAPI_View.h:98
@ kMessageSource_Rendering
Definition CAPI_View.h:104
@ kMessageSource_Security
Definition CAPI_View.h:106
@ kMessageSource_Storage
Definition CAPI_View.h:102
@ kMessageSource_ConsoleAPI
Definition CAPI_View.h:101
@ kMessageSource_Other
Definition CAPI_View.h:114
@ kMessageSource_PrivateClickMeasurement
Definition CAPI_View.h:112
void ulViewConfigSetInitialFocus(ULViewConfig config, bool is_focused)
Set whether or not the View should initially have input focus.
void ulViewConfigSetFontFamilyPictograph(ULViewConfig config, ULString font_name)
Set the default font family for the CSS -webkit-pictograph generic.
ULView ulCreateView(ULRenderer renderer, unsigned int width, unsigned int height, ULViewConfig view_config, ULSession session)
Create a View with certain size (in pixels).
void ulViewConfigSetIsTransparent(ULViewConfig config, bool is_transparent)
Set whether or not the View should support transparent backgrounds.
void ulViewCreateLocalInspectorView(ULView view)
Create an Inspector View to inspect / debug this View locally.
JSContextRef ulViewLockJSContext(ULView view)
Acquire the page's JSContext for use with JavaScriptCore API.
void ulViewReload(ULView view)
Reload current page.
void ulViewSetChangeEditableStateCallback(ULView view, ULChangeEditableStateCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the editable state changes.
void(*) ULChangeCursorCallback(void *user_data, ULView caller, ULCursor cursor)
Definition CAPI_View.h:950
void ulViewSetChangeCursorCallback(ULView view, ULChangeCursorCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the mouse cursor changes.
ULString ulViewGetTitle(ULView view)
Get current title.
void ulViewSetFinishLoadingCallback(ULView view, ULFinishLoadingCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when a load ends (whether or not it succeeded).
void ulViewConfigSetFontSizeDefault(ULViewConfig config, unsigned int size)
Set the default font size, in pixels (Default = 16).
void ulViewConfigSetFontFamilyFixed(ULViewConfig config, ULString font_name)
Set the default monospace font family, eg, for pre and code (Default = Courier New).
void ulViewSetMaxRenderFps(ULView view, unsigned int fps)
Set the maximum rate, in frames per second, at which the View advances its animations and repaints.
void ulViewSetDownloadNextIdCallback(ULView view, ULDownloadNextIdCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for generating unique download ids.
ULString ulViewGetURL(ULView view)
Get current URL.
void ulViewConfigSetJavaScriptCanOpenWindowsAutomatically(ULViewConfig config, bool enabled)
Set whether or not a script can open a window with window.open() without a user gesture (Default = Fa...
void ulViewConfigSetAllowUniversalAccessFromFileURLs(ULViewConfig config, bool enabled)
Set whether or not pages loaded from file:/// URLs can access content from any origin (Default = True...
void ulViewSetDownloadReceiveDataCallback(ULView view, ULDownloadReceiveDataCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when download data is received.
ULViewConfig ulCreateViewConfig(void)
Create view configuration with default values (see <Ultralight/View.h>).
bool ulViewHasFocus(ULView view)
Whether or not the View has focus.
ULRenderTarget ulViewGetRenderTarget(ULView view)
Get the RenderTarget for the View.
void ulViewSetPageSettledCallback(ULView view, ULPageSettledCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the page has settled and is ready to capture or display (resources have loaded,...
void * ulViewJavaScriptVMWithFrame(ULView view, ULString frame)
Get a handle to the internal JavaScriptCore VM for a specific frame.
void ulViewSetUpdateHistoryCallback(ULView view, ULUpdateHistoryCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the main frame's back-forward history changes.
void ulViewResizeWithScale(ULView view, unsigned int width, unsigned int height, double device_scale)
Resize view and apply a new device scale in the same pass.
void ulViewSetChangeURLCallback(ULView view, ULChangeURLCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the main frame loads a new page.
void(*) ULChangeTitleCallback(void *user_data, ULView caller, ULString title)
Definition CAPI_View.h:916
void(*) ULRequestCloseCallback(void *user_data, ULView caller)
Definition CAPI_View.h:1271
double ulViewGetDeviceScale(ULView view)
Get the device scale, ie.
void ulViewConfigSetEnableHiddenTimerThrottling(ULViewConfig config, bool enabled)
Set whether to throttle JavaScript timers (setTimeout / setInterval) while the View is hidden (Defaul...
bool ulViewGetNeedsPaint(ULView view)
Whether or not a view should be painted during the next call to ulRender().
JSContextRef ulViewLockJSContextWithFrame(ULView view, ULString frame)
Acquire the JSContext of a specific frame for use with JavaScriptCore API.
void(*) ULDOMReadyCallback(void *user_data, ULView caller, unsigned long long frame_id, bool is_main_frame, ULString url)
Definition CAPI_View.h:1100
bool(*) ULDownloadRequestCallback(void *user_data, ULView caller, unsigned int id, ULString url)
Callback for when the page wants to download a file.
Definition CAPI_View.h:1313
unsigned int(*) ULDownloadNextIdCallback(void *user_data, ULView caller)
Callback for when the View needs an ID for a new download.
Definition CAPI_View.h:1306
void ulViewGoForward(ULView view)
Navigate forwards in history.
void ulViewSetCreateInspectorViewCallback(ULView view, ULCreateInspectorViewCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the inspector needs a View to display in (after ulViewCreateLocalInspectorView(...
void ulViewSetCreateChildViewCallback(ULView view, ULCreateChildViewCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the page wants to open a new window (a link with target="_blank" or a call to w...
void ulDestroyViewConfig(ULViewConfig config)
Destroy a view configuration created by ulCreateViewConfig().
void ulViewCancelDownload(ULView view, unsigned int id)
Cancel an active download.
void(*) ULDiscardCompositionCallback(void *user_data, ULView caller)
Definition CAPI_View.h:990
bool ulViewIsVisible(ULView view)
Whether or not this View is visible.
void(*) ULDownloadReceiveDataCallback(void *user_data, ULView caller, unsigned int id, ULBuffer data)
Callback for when a download receives data (usually several times per download).
Definition CAPI_View.h:1333
ULMessageLevel
The severity level of a console message.
Definition CAPI_View.h:123
@ kMessageLevel_Debug
Definition CAPI_View.h:127
@ kMessageLevel_Warning
Definition CAPI_View.h:125
@ kMessageLevel_Info
Definition CAPI_View.h:128
@ kMessageLevel_Error
Definition CAPI_View.h:126
@ kMessageLevel_Log
Definition CAPI_View.h:124
ULSurface ulViewGetSurface(ULView view)
Get the Surface for the View (native pixel buffer that the CPU renderer draws into).
void ulViewSetNetworkRequestCallback(ULView view, ULNetworkRequestCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the View is about to begin a network request.
void ulViewConfigSetMaxRenderFps(ULViewConfig config, unsigned int fps)
Set the maximum rate, in frames per second, at which the View advances its animations and repaints.
void(*) ULUpdateHistoryCallback(void *user_data, ULView caller)
Definition CAPI_View.h:1112
ULCursor
Cursor types.
Definition CAPI_View.h:136
@ kCursor_NorthEastSouthWestResize
Definition CAPI_View.h:153
@ kCursor_NorthWestSouthEastResize
Definition CAPI_View.h:154
@ kCursor_Cell
Definition CAPI_View.h:168
@ kCursor_SouthWestPanning
Definition CAPI_View.h:164
@ kCursor_Cross
Definition CAPI_View.h:138
@ kCursor_Progress
Definition CAPI_View.h:171
@ kCursor_Copy
Definition CAPI_View.h:173
@ kCursor_SouthEastPanning
Definition CAPI_View.h:163
@ kCursor_ZoomIn
Definition CAPI_View.h:176
@ kCursor_SouthWestResize
Definition CAPI_View.h:149
@ kCursor_NorthWestResize
Definition CAPI_View.h:146
@ kCursor_MiddlePanning
Definition CAPI_View.h:157
@ kCursor_ContextMenu
Definition CAPI_View.h:169
@ kCursor_Hand
Definition CAPI_View.h:139
@ kCursor_ZoomOut
Definition CAPI_View.h:177
@ kCursor_Wait
Definition CAPI_View.h:141
@ kCursor_Grabbing
Definition CAPI_View.h:179
@ kCursor_NoDrop
Definition CAPI_View.h:172
@ kCursor_SouthPanning
Definition CAPI_View.h:162
@ kCursor_Grab
Definition CAPI_View.h:178
@ kCursor_VerticalText
Definition CAPI_View.h:167
@ kCursor_Move
Definition CAPI_View.h:166
@ kCursor_WestPanning
Definition CAPI_View.h:165
@ kCursor_SouthEastResize
Definition CAPI_View.h:148
@ kCursor_EastResize
Definition CAPI_View.h:143
@ kCursor_EastPanning
Definition CAPI_View.h:158
@ kCursor_None
Definition CAPI_View.h:174
@ kCursor_EastWestResize
Definition CAPI_View.h:152
@ kCursor_RowResize
Definition CAPI_View.h:156
@ kCursor_NorthEastPanning
Definition CAPI_View.h:160
@ kCursor_SouthResize
Definition CAPI_View.h:147
@ kCursor_ColumnResize
Definition CAPI_View.h:155
@ kCursor_NorthResize
Definition CAPI_View.h:144
@ kCursor_IBeam
Definition CAPI_View.h:140
@ kCursor_NorthEastResize
Definition CAPI_View.h:145
@ kCursor_WestResize
Definition CAPI_View.h:150
@ kCursor_NorthSouthResize
Definition CAPI_View.h:151
@ kCursor_Pointer
Definition CAPI_View.h:137
@ kCursor_NorthWestPanning
Definition CAPI_View.h:161
@ kCursor_Custom
Definition CAPI_View.h:180
@ kCursor_NotAllowed
Definition CAPI_View.h:175
@ kCursor_Alias
Definition CAPI_View.h:170
@ kCursor_NorthPanning
Definition CAPI_View.h:159
@ kCursor_Help
Definition CAPI_View.h:142
void ulViewGoToHistoryOffset(ULView view, int offset)
Navigate to an arbitrary offset in history.
void ulViewConfigSetUserAgent(ULViewConfig config, ULString agent_string)
Set user agent string (See <Ultralight/platform/Config.h> for the default).
unsigned int ulViewGetHeight(ULView view)
Get the height, in pixels.
void ulViewSetDOMReadyCallback(ULView view, ULDOMReadyCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when a frame's document has been parsed and the DOM is ready.
void ulViewSetDeviceScale(ULView view, double scale)
Set the device scale.
void ulViewFireScrollEvent(ULView view, ULScrollEvent scroll_event)
Fire a scroll event.
void ulViewFocus(ULView view)
Give focus to the View.
void ulViewLoadURL(ULView view, ULString url_string)
Load a URL, the View will navigate to it as a new page.
void ulViewSetRequestCloseCallback(ULView view, ULRequestCloseCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the page asks to close (window.close() in a window that script opened,...
void(*) ULChangeURLCallback(void *user_data, ULView caller, ULString url)
Definition CAPI_View.h:925
void ulViewConfigSetMatchNativeEditingBehavior(ULViewConfig config, bool enabled)
Set whether text editing should follow the host OS's native conventions instead of the library's cros...
void ulViewSetDownloadBeginCallback(ULView view, ULDownloadBeginCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when a download begins.
void ulViewSetDiscardCompositionCallback(ULView view, ULDiscardCompositionCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the page ends the active composition on its own (eg, on navigation or when the ...
void ulViewLoadHTML(ULView view, ULString html_string)
Load a raw string of HTML, the View will navigate to it as a new page.
bool ulViewIsLoading(ULView view)
Check if the main frame of the page is currently loading.
void ulViewSetNeedsPaint(ULView view, bool needs_paint)
Set whether or not a view should be repainted during the next call to ulRender().
void ulViewConfigSetFontFamilySerif(ULViewConfig config, ULString font_name)
Set the default font family for the CSS serif generic (Default = Times New Roman).
ULView(*) ULCreateChildViewCallback(void *user_data, ULView caller, ULString opener_url, ULString target_url, bool is_popup, ULIntRect popup_rect)
Definition CAPI_View.h:1017
ULString ulViewEvaluateScript(ULView view, ULString js_string, ULString *exception)
Evaluate a string of JavaScript and return result.
void ulViewUnfocus(ULView view)
Remove focus from the View.
void ulViewSetCompositorDebugInfoEnabled(ULView view, bool enabled)
Set whether or not to display compositor debug information.
bool ulViewIsTransparent(ULView view)
Whether or not the View supports transparent backgrounds.
void ulViewConfigSetIsAccelerated(ULViewConfig config, bool is_accelerated)
Set whether to render using the GPU renderer (accelerated) or the CPU renderer (unaccelerated).
void ulViewSetWindowObjectReadyCallback(ULView view, ULWindowObjectReadyCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for before a frame's scripts run.
void ulViewStop(ULView view)
Stop all page loads.
void ulViewConfigSetFontFamilyCursive(ULViewConfig config, ULString font_name)
Set the default font family for the CSS cursive generic (Default = Comic Sans MS).
void ulViewConfigSetEnableCompositor(ULViewConfig config, bool enabled)
Set whether or not compositing should be enabled.
bool ulViewCanGoForward(ULView view)
Whether or not the View can navigate forward in history.
unsigned int ulViewGetWidth(ULView view)
Get the width, in pixels.
void(*) ULDownloadBeginCallback(void *user_data, ULView caller, unsigned int id, ULString url, ULString filename, long long expected_content_length)
Callback for when a download starts.
Definition CAPI_View.h:1322
void(*) ULWindowObjectReadyCallback(void *user_data, ULView caller, unsigned long long frame_id, bool is_main_frame, ULString url)
Definition CAPI_View.h:1084
void(*) ULDownloadFailCallback(void *user_data, ULView caller, unsigned int id)
Callback for when a download fails.
Definition CAPI_View.h:1348
ULString ulViewEvaluateScriptWithFrame(ULView view, ULString js_string, ULString *exception, ULString frame)
Evaluate a string of JavaScript in a specific frame and return the result.
void ulViewSetFailLoadingCallback(ULView view, ULFailLoadingCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when a load fails (just before the finish-loading callback).
void ulViewConfigSetEnableCanvasFilters(ULViewConfig config, bool enabled)
Set whether or not the HTML5 Canvas Filters API (CanvasRenderingContext2D.filter) is enabled.
void ulViewConfigSetInitialDeviceScale(ULViewConfig config, double initial_device_scale)
Set the initial device scale, ie.
void ulViewSetDisplayId(ULView view, unsigned int display_id)
Set the display id of the View.
void ulViewConfigSetEnableImages(ULViewConfig config, bool enabled)
Set whether images should be enabled (Default = True).
ULColorScheme ulViewGetPreferredColorScheme(ULView view)
Get the color scheme this View reports to pages.
void ulViewConfigSetFontFamilySansSerif(ULViewConfig config, ULString font_name)
Set the default font family for the CSS sans-serif generic (Default = Arial).
void ulViewSetDownloadFinishCallback(ULView view, ULDownloadFinishCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when a download finishes.
bool ulViewCanGoBack(ULView view)
Whether or not the View can navigate back in history.
void ulViewSetPreferredColorScheme(ULView view, ULColorScheme scheme)
Set the color scheme this View reports to pages via the prefers-color-scheme CSS media feature.
bool(*) ULNetworkRequestCallback(void *user_data, ULView caller, ULString url)
Callback for before the View sends a network request.
Definition CAPI_View.h:1418
void ulViewLoadHTMLWithParams(ULView view, ULString html_string, ULString url, bool add_to_history)
Load a raw string of HTML with additional options.
void ulViewGoBack(ULView view)
Navigate backwards in history.
void ulViewSetAddConsoleMessageCallback(ULView view, ULAddConsoleMessageCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the page adds a message to the console (useful for errors and debugging).
void ulViewConfigSetPreferredColorScheme(ULViewConfig config, ULColorScheme scheme)
Set the color scheme the View reports to pages via the prefers-color-scheme CSS media feature.
void ulViewFireKeyEvent(ULView view, ULKeyEvent key_event)
Fire a keyboard event.
void ulViewSetDownloadRequestCallback(ULView view, ULDownloadRequestCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the View requests a download.
void(*) ULDownloadFinishCallback(void *user_data, ULView caller, unsigned int id)
Callback for when a download finishes.
Definition CAPI_View.h:1341
void ulViewConfigSetDisplayId(ULViewConfig config, unsigned int display_id)
Set a user-generated id of the display (monitor, TV, or screen) that the View will be shown on.
void ulViewUnlockJSContext(ULView view)
Unlock the page's JSContext after a previous call to ulViewLockJSContext().
void(*) ULUpdateCompositionCallback(void *user_data, ULView caller)
Definition CAPI_View.h:977
void ulViewConfigSetFontSizeFixed(ULViewConfig config, unsigned int size)
Set the default font size for monospace text, eg, pre and code, in pixels (Default = 13).
unsigned int ulViewGetDisplayId(ULView view)
Get the display id of the View.
bool ulViewIsAccelerated(ULView view)
Whether or not the View is GPU-accelerated.
ULJSContext ulViewGetJSContext(ULView view)
Get a ULJS handle to the main frame's JavaScript context.
void ulDestroyView(ULView view)
Destroy a View previously created with ulCreateView().
void(*) ULChangeEditableStateCallback(void *user_data, ULView caller, ULEditableState state)
Definition CAPI_View.h:959
void ulViewSetBeginLoadingCallback(ULView view, ULBeginLoadingCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when a load starts (see "Load Events" in the file description).
void ulViewConfigSetFontFamilyFantasy(ULViewConfig config, ULString font_name)
Set the default font family for the CSS fantasy generic (Default = Impact).
void(*) ULAddConsoleMessageCallback(void *user_data, ULView caller, ULMessageSource source, ULMessageLevel level, ULString message, unsigned int line_number, unsigned int column_number, ULString source_id)
Definition CAPI_View.h:1004
void ulViewConfigSetBackgroundColor(ULViewConfig config, ULColor color)
Set the base background color the page renders on before any page styling applies,...
void(*) ULFinishLoadingCallback(void *user_data, ULView caller, unsigned long long frame_id, bool is_main_frame, ULString url)
Definition CAPI_View.h:1060
void ulViewSetChangeTooltipCallback(ULView view, ULChangeTooltipCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the tooltip under the mouse changes (the text is empty when there's no tooltip)...
void ulViewConfigSetClipboardReadPolicy(ULViewConfig config, ULClipboardReadPolicy policy)
Set which pages may read the clipboard from script, eg, a page's own Paste button calling document....
void ulViewConfigSetFontFamilyStandard(ULViewConfig config, ULString font_name)
Set the default font family, used for text that doesn't set one (Default = Times New Roman).
void ulViewSetUpdateCompositionCallback(ULView view, ULUpdateCompositionCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for after every change to the active composition.
void ulViewUnlockJSContextWithFrame(ULView view, ULString frame)
Unlock the JSContext of a specific frame after a previous call to ulViewLockJSContextWithFrame().
bool ulViewIsSettled(ULView view)
Check whether the page has settled after loading.
void ulViewSetVisible(ULView view, bool visible)
Set whether or not this View is visible.
void(*) ULPageSettledCallback(void *user_data, ULView caller, ULString url)
Definition CAPI_View.h:1121
void ulViewSetChangeTitleCallback(ULView view, ULChangeTitleCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when the page title changes.
void ulViewConfigSetEnableJavaScript(ULViewConfig config, bool enabled)
Set whether JavaScript should be enabled (Default = True).
unsigned int ulViewGetMaxRenderFps(ULView view)
Get the frame-rate cap (in FPS) set for the View, or 0 if none is set.
bool ulViewGetCompositorDebugInfoEnabled(ULView view)
Whether or not compositor debug information is enabled.
void(*) ULBeginLoadingCallback(void *user_data, ULView caller, unsigned long long frame_id, bool is_main_frame, ULString url)
Definition CAPI_View.h:1050
bool ulViewHasInputFocus(ULView view)
Whether or not the View has an input element with visible keyboard focus (indicated by a blinking car...
void ulViewResize(ULView view, unsigned int width, unsigned int height)
Resize view to a certain width and height (in pixels).
void ulViewSetDownloadFailCallback(ULView view, ULDownloadFailCallback callback, void *user_data, ULUserDataDestroyCallback destroy_user_data)
Set callback for when a download fails.
void(*) ULFailLoadingCallback(void *user_data, ULView caller, unsigned long long frame_id, bool is_main_frame, ULString url, ULString description, ULString error_domain, int error_code)
Definition CAPI_View.h:1070
ULView(*) ULCreateInspectorViewCallback(void *user_data, ULView caller, bool is_local, ULString inspected_url)
Definition CAPI_View.h:1035
const struct OpaqueJSContext * JSContextRef
Definition JSBase.h:43
Various defines and utility functions for the C API.
struct C_View * ULView
Opaque handle to a View object.
Definition CAPI_Defines.h:87
struct C_String * ULString
Opaque handle to a String object.
Definition CAPI_Defines.h:96
struct C_Session * ULSession
Opaque handle to a Session object.
Definition CAPI_Defines.h:81
#define ULExport
Definition CAPI_Defines.h:42
struct C_Surface * ULSurface
Opaque handle to a Surface object.
Definition CAPI_Defines.h:122
ULClipboardReadPolicy
Policy governing script-initiated clipboard reads.
Definition CAPI_Defines.h:158
struct C_MouseEvent * ULMouseEvent
Opaque handle to a MouseEvent object.
Definition CAPI_Defines.h:107
struct C_ViewConfig * ULViewConfig
Opaque handle to a ViewConfig object.
Definition CAPI_Defines.h:84
void(*) ULUserDataDestroyCallback(void *user_data)
Callback invoked exactly once when the library finally drops a piece of user data.
Definition CAPI_Defines.h:139
struct C_ScrollEvent * ULScrollEvent
Opaque handle to a ScrollEvent object.
Definition CAPI_Defines.h:110
ULColorScheme
A page color scheme, as reported to pages via the prefers-color-scheme CSS media feature.
Definition CAPI_Defines.h:147
struct C_Buffer * ULBuffer
Opaque handle to a Buffer object.
Definition CAPI_Defines.h:99
struct C_Renderer * ULRenderer
Opaque handle to a Renderer object.
Definition CAPI_Defines.h:78
struct C_KeyEvent * ULKeyEvent
Opaque handle to a KeyEvent object.
Definition CAPI_Defines.h:104
A color value.
Definition CAPI_ColorTypes.h:45
The conditions that decide whether an input method should be active.
Definition CAPI_Editor.h:519
Integer rectangle defined by left, top, right, and bottom coordinates.
Definition CAPI_Defines.h:548
Offscreen render target, used when rendering Views via the GPU renderer.
Definition CAPI_Defines.h:564