Interface CefriumRenderHandler


public interface CefriumRenderHandler
Callback interface for receiving rendered frames from a CefriumBrowser. Frames are delivered as BGRA pixel buffers on the UI thread.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    onFocusedNodeChanged(boolean editable, String value, String placeholder, String type)
    Called (OSR) when the focused editable node changes, carrying the field's current value, placeholder and type read from the DOM in the renderer.
    default void
    onImeCompositionRangeChanged(int x, int y, int width, int height)
    The IME composition rectangle (bounds of the first composed character, in view pixels) changed — use it to position an IME overlay.
    void
    onPaint(int width, int height, ByteBuffer pixels)
    Called when a new frame has been rendered.
    default void
    onPopupPaint(int x, int y, int width, int height, ByteBuffer pixels)
    Paints an OSR popup widget (e.g.
    default void
    onPopupShow(boolean show)
    An OSR popup widget was shown (true) or hidden (false).
    default void
    onPopupSize(int x, int y, int width, int height)
    The OSR popup widget's geometry (view pixels).
    default void
    onQuickMenu(int x, int y, int width, int height, int editFlags, CefriumBrowser.QuickMenuCallback callback)
    Called (OSR) when the text-selection quick menu (Cut / Copy / Paste) should be shown -- e.g.
    default void
    onScrollOffsetChanged(double x, double y)
    The page scroll offset changed (CSS pixels).
    default void
    The selected text changed (empty when the selection is cleared).
    default void
    onTouchHandleStateChanged(int orientation, int x, int y, boolean enabled)
    Called (OSR) when a text-selection handle's state changes.
    default void
    Called when the focused editable node changes and the on-screen keyboard should be shown or hidden (OSR mode).
  • Method Details

    • onPaint

      void onPaint(int width, int height, ByteBuffer pixels)
      Called when a new frame has been rendered.
      Parameters:
      width - Frame width in pixels.
      height - Frame height in pixels.
      pixels - Direct ByteBuffer containing BGRA pixel data (width * height * 4 bytes). Valid only during this call.
    • onVirtualKeyboardRequested

      default void onVirtualKeyboardRequested(int inputMode)
      Called when the focused editable node changes and the on-screen keyboard should be shown or hidden (OSR mode). Mirrors CEF's CefRenderHandler::OnVirtualKeyboardRequested.

      Use this to drive InputMethodManager: show the soft keyboard (and request focus on the hosting View) when an editable is focused, hide it otherwise. Pair it with a custom InputConnection that forwards composing and committed text to CefriumBrowser.imeSetComposition(String, int, int), CefriumBrowser.imeCommitText(String, int), CefriumBrowser.imeFinishComposingText(boolean) and CefriumBrowser.imeCancelComposition().

      Delivered on the Android main thread.

      Parameters:
      inputMode - The requested text input mode, matching CEF's cef_text_input_mode_t (see the CefriumBrowser.TEXT_INPUT_MODE_* constants). Hide the keyboard when this equals CefriumBrowser.TEXT_INPUT_MODE_NONE (1); any other value (including CefriumBrowser.TEXT_INPUT_MODE_DEFAULT, which is 0) means an editable is focused and the keyboard should be shown. The specific value also indicates the preferred keyboard flavour (numeric, email, ...).
    • onFocusedNodeChanged

      default void onFocusedNodeChanged(boolean editable, String value, String placeholder, String type)
      Called (OSR) when the focused editable node changes, carrying the field's current value, placeholder and type read from the DOM in the renderer. Pairs with onVirtualKeyboardRequested(int): use this to populate a native input overlay that mirrors the focused web field.

      Delivered on the Android main thread.

      Parameters:
      editable - True if an editable field is focused; false on blur (in which case value/placeholder/type are empty).
      value - The field's current value (already-typed text).
      placeholder - The field's placeholder attribute, or "".
      type - The input type attribute (e.g. "text", "password", "email"), or the tag name for non-input editables (e.g. "textarea"), or "".
    • onQuickMenu

      default void onQuickMenu(int x, int y, int width, int height, int editFlags, CefriumBrowser.QuickMenuCallback callback)
      Called (OSR) when the text-selection quick menu (Cut / Copy / Paste) should be shown -- e.g. after long-pressing a word. Draw a small menu over your OSR view at (x,y) offering the items enabled in editFlags (bitmask of CefriumBrowser.QM_CAN_CUT, CefriumBrowser.QM_CAN_COPY, CefriumBrowser.QM_CAN_PASTE), then call exactly one of callback.cut()/copy()/paste(), or callback.cancel() to dismiss. CEF performs the edit itself.

      Without handling this, OSR text selection has no copy/paste menu. Delivered on the Android main thread.

      Parameters:
      x - Menu anchor x, in view pixels.
      y - Menu anchor y, in view pixels.
      width - Selection/anchor width.
      height - Selection/anchor height.
      editFlags - Bitmask of available items (QM_CAN_*).
      callback - Result callback (call exactly one method once).
    • onTouchHandleStateChanged

      default void onTouchHandleStateChanged(int orientation, int x, int y, boolean enabled)
      Called (OSR) when a text-selection handle's state changes. Optional: draw draggable selection handles over your OSR view at (x,y). The quick menu (onQuickMenu) works without drawing these.
      Parameters:
      orientation - Handle orientation (cef_horizontal_alignment_t).
      x - Handle origin x, view pixels.
      y - Handle origin y, view pixels.
      enabled - Whether the handle is enabled/visible.
    • onPopupPaint

      default void onPopupPaint(int x, int y, int width, int height, ByteBuffer pixels)
      Paints an OSR popup widget (e.g. an HTML <select> dropdown). Draw these pixels over the main view at (x, y); without this, dropdowns are invisible in off-screen mode. The buffer is BGRA, valid only during this call.
      Parameters:
      x - Popup left, in view pixels.
      y - Popup top, in view pixels.
      width - Popup width in pixels.
      height - Popup height in pixels.
      pixels - BGRA pixel data (width * height * 4 bytes).
    • onPopupShow

      default void onPopupShow(boolean show)
      An OSR popup widget was shown (true) or hidden (false).
    • onPopupSize

      default void onPopupSize(int x, int y, int width, int height)
      The OSR popup widget's geometry (view pixels).
    • onImeCompositionRangeChanged

      default void onImeCompositionRangeChanged(int x, int y, int width, int height)
      The IME composition rectangle (bounds of the first composed character, in view pixels) changed — use it to position an IME overlay. Pairs with the OSR IME input path.
    • onTextSelectionChanged

      default void onTextSelectionChanged(String selectedText)
      The selected text changed (empty when the selection is cleared).
    • onScrollOffsetChanged

      default void onScrollOffsetChanged(double x, double y)
      The page scroll offset changed (CSS pixels).