Class HitTestResult

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class HitTestResult extends GObject

Result of a Hit Test.

A Hit Test is an operation to get context information about a given point in a WebKitWebView. WebKitHitTestResult represents the result of a Hit Test. It provides context information about what is at the coordinates of the Hit Test, such as if there's a link, an image or a media.

You can get the context of the HitTestResult with webkit_hit_test_result_get_context() that returns a bitmask of WebKitHitTestResultContext flags. You can also use webkit_hit_test_result_context_is_link(), webkit_hit_test_result_context_is_image() and webkit_hit_test_result_context_is_media() to determine whether there's a link, image or a media element at the coordinates of the Hit Test. Note that it's possible that several WebKitHitTestResultContext flags are active at the same time, for example if there's a link containing an image.

When the mouse is moved over a WebKitWebView a Hit Test is performed for the mouse coordinates and WebKitWebView::mouse-target-changed signal is emitted with a WebKitHitTestResult.

  • Constructor Details

    • HitTestResult

      public HitTestResult(MemorySegment address)
      Create a HitTestResult instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • HitTestResult

      public HitTestResult()
      Create a new HitTestResult.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the HitTestResult class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected HitTestResult asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • contextIsEditable

      public boolean contextIsEditable()
      Gets whether HitTestResultContext.EDITABLE flag is present in WebKitHitTestResult:context.
      Returns:
      true if there's an editable element at the coordinates of the hitTestResult, or false otherwise
    • contextIsImage

      public boolean contextIsImage()
      Gets whether HitTestResultContext.IMAGE flag is present in WebKitHitTestResult:context.
      Returns:
      true if there's an image element in the coordinates of the Hit Test, or false otherwise
    • contextIsLink

      public boolean contextIsLink()
      Gets whether HitTestResultContext.LINK flag is present in WebKitHitTestResult:context.
      Returns:
      true if there's a link element in the coordinates of the Hit Test, or false otherwise
    • contextIsMedia

      public boolean contextIsMedia()
      Gets whether HitTestResultContext.MEDIA flag is present in WebKitHitTestResult:context.
      Returns:
      true if there's a media element in the coordinates of the Hit Test, or false otherwise
    • contextIsScrollbar

      public boolean contextIsScrollbar()
      Gets whether HitTestResultContext.SCROLLBAR flag is present in WebKitHitTestResult:context.
      Returns:
      true if there's a scrollbar element at the coordinates of the hitTestResult, or false otherwise
    • contextIsSelection

      public boolean contextIsSelection()
      Gets whether HitTestResultContext.SELECTION flag is present in WebKitHitTestResult:context.
      Returns:
      true if there's a selected element at the coordinates of the hitTestResult, or false otherwise
      Since:
      2.8
    • getContext

      public int getContext()
      Gets the value of the WebKitHitTestResult:context property.
      Returns:
      a bitmask of WebKitHitTestResultContext flags
    • getImageUri

      public String getImageUri()
      Gets the value of the WebKitHitTestResult:image-uri property.
      Returns:
      the URI of the image element in the coordinates of the Hit Test, or null if there isn't an image element in this HitTestResult context
    • getLinkLabel

      public String getLinkLabel()
      Gets the value of the WebKitHitTestResult:link-label property.
      Returns:
      the label of the link element in the coordinates of the Hit Test, or null if there isn't a link element in this HitTestResult context or the link element doesn't have a label
    • getLinkTitle

      public String getLinkTitle()
      Gets the value of the WebKitHitTestResult:link-title property.
      Returns:
      the title of the link element in the coordinates of the Hit Test, or null if there isn't a link element in this HitTestResult context or the link element doesn't have a title
    • getLinkUri

      public String getLinkUri()
      Gets the value of the WebKitHitTestResult:link-uri property.
      Returns:
      the URI of the link element in the coordinates of the Hit Test, or null if there isn't a link element in this HitTestResult context
    • getMediaUri

      public String getMediaUri()
      Gets the value of the WebKitHitTestResult:media-uri property.
      Returns:
      the URI of the media element in the coordinates of the Hit Test, or null if there isn't a media element in this HitTestResult context
    • builder

      public static HitTestResult.Builder<? extends HitTestResult.Builder> builder()
      A HitTestResult.Builder object constructs a HitTestResult with the specified properties. Use the various set...() methods to set properties, and finish construction with HitTestResult.Builder.build().
      Returns:
      the builder object