1 module webkit2webextension.HitTestResult; 2 3 private import glib.Str; 4 private import gobject.ObjectG; 5 private import webkit2webextension.c.functions; 6 public import webkit2webextension.c.types; 7 8 9 /** 10 * A Hit Test is an operation to get context information about a given 11 * point in a #WebKitWebView. #WebKitHitTestResult represents the 12 * result of a Hit Test. It provides context information about what is 13 * at the coordinates of the Hit Test, such as if there's a link, 14 * an image or a media. 15 * 16 * You can get the context of the HitTestResult with 17 * webkit_hit_test_result_get_context() that returns a bitmask of 18 * #WebKitHitTestResultContext flags. You can also use 19 * webkit_hit_test_result_context_is_link(), webkit_hit_test_result_context_is_image() and 20 * webkit_hit_test_result_context_is_media() to determine whether there's 21 * a link, image or a media element at the coordinates of the Hit Test. 22 * Note that it's possible that several #WebKitHitTestResultContext flags 23 * are active at the same time, for example if there's a link containing an image. 24 * 25 * When the mouse is moved over a #WebKitWebView a Hit Test is performed 26 * for the mouse coordinates and #WebKitWebView::mouse-target-changed 27 * signal is emitted with a #WebKitHitTestResult. 28 */ 29 public class HitTestResult : ObjectG 30 { 31 /** the main Gtk struct */ 32 protected WebKitHitTestResult* webKitHitTestResult; 33 34 /** Get the main Gtk struct */ 35 public WebKitHitTestResult* getHitTestResultStruct(bool transferOwnership = false) 36 { 37 if (transferOwnership) 38 ownedRef = false; 39 return webKitHitTestResult; 40 } 41 42 /** the main Gtk struct as a void* */ 43 protected override void* getStruct() 44 { 45 return cast(void*)webKitHitTestResult; 46 } 47 48 /** 49 * Sets our main struct and passes it to the parent class. 50 */ 51 public this (WebKitHitTestResult* webKitHitTestResult, bool ownedRef = false) 52 { 53 this.webKitHitTestResult = webKitHitTestResult; 54 super(cast(GObject*)webKitHitTestResult, ownedRef); 55 } 56 57 58 /** */ 59 public static GType getType() 60 { 61 return webkit_hit_test_result_get_type(); 62 } 63 64 /** 65 * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_EDITABLE flag is present in 66 * #WebKitHitTestResult:context. 67 * 68 * Returns: %TRUE if there's an editable element at the coordinates of the @hit_test_result, 69 * or %FALSE otherwise 70 */ 71 public bool contextIsEditable() 72 { 73 return webkit_hit_test_result_context_is_editable(webKitHitTestResult) != 0; 74 } 75 76 /** 77 * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE flag is present in 78 * #WebKitHitTestResult:context. 79 * 80 * Returns: %TRUE if there's an image element in the coordinates of the Hit Test, 81 * or %FALSE otherwise 82 */ 83 public bool contextIsImage() 84 { 85 return webkit_hit_test_result_context_is_image(webKitHitTestResult) != 0; 86 } 87 88 /** 89 * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK flag is present in 90 * #WebKitHitTestResult:context. 91 * 92 * Returns: %TRUE if there's a link element in the coordinates of the Hit Test, 93 * or %FALSE otherwise 94 */ 95 public bool contextIsLink() 96 { 97 return webkit_hit_test_result_context_is_link(webKitHitTestResult) != 0; 98 } 99 100 /** 101 * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA flag is present in 102 * #WebKitHitTestResult:context. 103 * 104 * Returns: %TRUE if there's a media element in the coordinates of the Hit Test, 105 * or %FALSE otherwise 106 */ 107 public bool contextIsMedia() 108 { 109 return webkit_hit_test_result_context_is_media(webKitHitTestResult) != 0; 110 } 111 112 /** 113 * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_SCROLLBAR flag is present in 114 * #WebKitHitTestResult:context. 115 * 116 * Returns: %TRUE if there's a scrollbar element at the coordinates of the @hit_test_result, 117 * or %FALSE otherwise 118 */ 119 public bool contextIsScrollbar() 120 { 121 return webkit_hit_test_result_context_is_scrollbar(webKitHitTestResult) != 0; 122 } 123 124 /** 125 * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_SELECTION flag is present in 126 * #WebKitHitTestResult:context. 127 * 128 * Returns: %TRUE if there's a selected element at the coordinates of the @hit_test_result, 129 * or %FALSE otherwise 130 * 131 * Since: 2.8 132 */ 133 public bool contextIsSelection() 134 { 135 return webkit_hit_test_result_context_is_selection(webKitHitTestResult) != 0; 136 } 137 138 /** 139 * Gets the value of the #WebKitHitTestResult:context property. 140 * 141 * Returns: a bitmask of #WebKitHitTestResultContext flags 142 */ 143 public uint getContext() 144 { 145 return webkit_hit_test_result_get_context(webKitHitTestResult); 146 } 147 148 /** 149 * Gets the value of the #WebKitHitTestResult:image-uri property. 150 * 151 * Returns: the URI of the image element in the coordinates of the Hit Test, 152 * or %NULL if there isn't an image element in @hit_test_result context 153 */ 154 public string getImageUri() 155 { 156 return Str.toString(webkit_hit_test_result_get_image_uri(webKitHitTestResult)); 157 } 158 159 /** 160 * Gets the value of the #WebKitHitTestResult:link-label property. 161 * 162 * Returns: the label of the link element in the coordinates of the Hit Test, 163 * or %NULL if there isn't a link element in @hit_test_result context or the 164 * link element doesn't have a label 165 */ 166 public string getLinkLabel() 167 { 168 return Str.toString(webkit_hit_test_result_get_link_label(webKitHitTestResult)); 169 } 170 171 /** 172 * Gets the value of the #WebKitHitTestResult:link-title property. 173 * 174 * Returns: the title of the link element in the coordinates of the Hit Test, 175 * or %NULL if there isn't a link element in @hit_test_result context or the 176 * link element doesn't have a title 177 */ 178 public string getLinkTitle() 179 { 180 return Str.toString(webkit_hit_test_result_get_link_title(webKitHitTestResult)); 181 } 182 183 /** 184 * Gets the value of the #WebKitHitTestResult:link-uri property. 185 * 186 * Returns: the URI of the link element in the coordinates of the Hit Test, 187 * or %NULL if there isn't a link element in @hit_test_result context 188 */ 189 public string getLinkUri() 190 { 191 return Str.toString(webkit_hit_test_result_get_link_uri(webKitHitTestResult)); 192 } 193 194 /** 195 * Gets the value of the #WebKitHitTestResult:media-uri property. 196 * 197 * Returns: the URI of the media element in the coordinates of the Hit Test, 198 * or %NULL if there isn't a media element in @hit_test_result context 199 */ 200 public string getMediaUri() 201 { 202 return Str.toString(webkit_hit_test_result_get_media_uri(webKitHitTestResult)); 203 } 204 }