1 module webkit2webextension.DOMDOMSelection;
2 
3 private import glib.ErrorG;
4 private import glib.GException;
5 private import glib.Str;
6 private import gobject.ObjectG;
7 private import webkit2webextension.DOMNode;
8 private import webkit2webextension.DOMObject;
9 private import webkit2webextension.DOMRange;
10 private import webkit2webextension.c.functions;
11 public  import webkit2webextension.c.types;
12 
13 
14 /** */
15 public class DOMDOMSelection : DOMObject
16 {
17 	/** the main Gtk struct */
18 	protected WebKitDOMDOMSelection* webKitDOMDOMSelection;
19 
20 	/** Get the main Gtk struct */
21 	public WebKitDOMDOMSelection* getDOMDOMSelectionStruct(bool transferOwnership = false)
22 	{
23 		if (transferOwnership)
24 			ownedRef = false;
25 		return webKitDOMDOMSelection;
26 	}
27 
28 	/** the main Gtk struct as a void* */
29 	protected override void* getStruct()
30 	{
31 		return cast(void*)webKitDOMDOMSelection;
32 	}
33 
34 	/**
35 	 * Sets our main struct and passes it to the parent class.
36 	 */
37 	public this (WebKitDOMDOMSelection* webKitDOMDOMSelection, bool ownedRef = false)
38 	{
39 		this.webKitDOMDOMSelection = webKitDOMDOMSelection;
40 		super(cast(WebKitDOMObject*)webKitDOMDOMSelection, ownedRef);
41 	}
42 
43 
44 	/** */
45 	public static GType getType()
46 	{
47 		return webkit_dom_dom_selection_get_type();
48 	}
49 
50 	/**
51 	 *
52 	 *
53 	 * Deprecated: Use JavaScriptCore API instead
54 	 *
55 	 * Params:
56 	 *     range = A #WebKitDOMRange
57 	 *
58 	 * Since: 2.16
59 	 */
60 	public void addRange(DOMRange range)
61 	{
62 		webkit_dom_dom_selection_add_range(webKitDOMDOMSelection, (range is null) ? null : range.getDOMRangeStruct());
63 	}
64 
65 	/**
66 	 *
67 	 *
68 	 * Deprecated: Use JavaScriptCore API instead
69 	 *
70 	 * Params:
71 	 *     node = A #WebKitDOMNode
72 	 *     offset = A #gulong
73 	 *
74 	 * Since: 2.16
75 	 */
76 	public void collapse(DOMNode node, gulong offset)
77 	{
78 		webkit_dom_dom_selection_collapse(webKitDOMDOMSelection, (node is null) ? null : node.getDOMNodeStruct(), offset);
79 	}
80 
81 	/**
82 	 *
83 	 *
84 	 * Deprecated: Use JavaScriptCore API instead
85 	 *
86 	 * Since: 2.16
87 	 *
88 	 * Throws: GException on failure.
89 	 */
90 	public void collapseToEnd()
91 	{
92 		GError* err = null;
93 
94 		webkit_dom_dom_selection_collapse_to_end(webKitDOMDOMSelection, &err);
95 
96 		if (err !is null)
97 		{
98 			throw new GException( new ErrorG(err) );
99 		}
100 	}
101 
102 	/**
103 	 *
104 	 *
105 	 * Deprecated: Use JavaScriptCore API instead
106 	 *
107 	 * Since: 2.16
108 	 *
109 	 * Throws: GException on failure.
110 	 */
111 	public void collapseToStart()
112 	{
113 		GError* err = null;
114 
115 		webkit_dom_dom_selection_collapse_to_start(webKitDOMDOMSelection, &err);
116 
117 		if (err !is null)
118 		{
119 			throw new GException( new ErrorG(err) );
120 		}
121 	}
122 
123 	/**
124 	 *
125 	 *
126 	 * Deprecated: Use JavaScriptCore API instead
127 	 *
128 	 * Params:
129 	 *     node = A #WebKitDOMNode
130 	 *     allowPartial = A #gboolean
131 	 *
132 	 * Returns: A #gboolean
133 	 *
134 	 * Since: 2.16
135 	 */
136 	public bool containsNode(DOMNode node, bool allowPartial)
137 	{
138 		return webkit_dom_dom_selection_contains_node(webKitDOMDOMSelection, (node is null) ? null : node.getDOMNodeStruct(), allowPartial) != 0;
139 	}
140 
141 	/**
142 	 *
143 	 *
144 	 * Deprecated: Use JavaScriptCore API instead
145 	 *
146 	 * Since: 2.16
147 	 */
148 	public void deleteFromDocument()
149 	{
150 		webkit_dom_dom_selection_delete_from_document(webKitDOMDOMSelection);
151 	}
152 
153 	/**
154 	 *
155 	 *
156 	 * Deprecated: Use JavaScriptCore API instead
157 	 *
158 	 * Since: 2.16
159 	 */
160 	public void empty()
161 	{
162 		webkit_dom_dom_selection_empty(webKitDOMDOMSelection);
163 	}
164 
165 	/**
166 	 *
167 	 *
168 	 * Deprecated: Use JavaScriptCore API instead
169 	 *
170 	 * Params:
171 	 *     node = A #WebKitDOMNode
172 	 *     offset = A #gulong
173 	 *
174 	 * Since: 2.16
175 	 *
176 	 * Throws: GException on failure.
177 	 */
178 	public void extend(DOMNode node, gulong offset)
179 	{
180 		GError* err = null;
181 
182 		webkit_dom_dom_selection_extend(webKitDOMDOMSelection, (node is null) ? null : node.getDOMNodeStruct(), offset, &err);
183 
184 		if (err !is null)
185 		{
186 			throw new GException( new ErrorG(err) );
187 		}
188 	}
189 
190 	/**
191 	 *
192 	 *
193 	 * Deprecated: Use JavaScriptCore API instead
194 	 *
195 	 * Returns: A #WebKitDOMNode
196 	 *
197 	 * Since: 2.16
198 	 */
199 	public DOMNode getAnchorNode()
200 	{
201 		auto __p = webkit_dom_dom_selection_get_anchor_node(webKitDOMDOMSelection);
202 
203 		if(__p is null)
204 		{
205 			return null;
206 		}
207 
208 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
209 	}
210 
211 	/**
212 	 *
213 	 *
214 	 * Deprecated: Use JavaScriptCore API instead
215 	 *
216 	 * Returns: A #gulong
217 	 *
218 	 * Since: 2.16
219 	 */
220 	public gulong getAnchorOffset()
221 	{
222 		return webkit_dom_dom_selection_get_anchor_offset(webKitDOMDOMSelection);
223 	}
224 
225 	/**
226 	 *
227 	 *
228 	 * Deprecated: Use JavaScriptCore API instead
229 	 *
230 	 * Returns: A #WebKitDOMNode
231 	 *
232 	 * Since: 2.16
233 	 */
234 	public DOMNode getBaseNode()
235 	{
236 		auto __p = webkit_dom_dom_selection_get_base_node(webKitDOMDOMSelection);
237 
238 		if(__p is null)
239 		{
240 			return null;
241 		}
242 
243 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
244 	}
245 
246 	/**
247 	 *
248 	 *
249 	 * Deprecated: Use JavaScriptCore API instead
250 	 *
251 	 * Returns: A #gulong
252 	 *
253 	 * Since: 2.16
254 	 */
255 	public gulong getBaseOffset()
256 	{
257 		return webkit_dom_dom_selection_get_base_offset(webKitDOMDOMSelection);
258 	}
259 
260 	/**
261 	 *
262 	 *
263 	 * Deprecated: Use JavaScriptCore API instead
264 	 *
265 	 * Returns: A #WebKitDOMNode
266 	 *
267 	 * Since: 2.16
268 	 */
269 	public DOMNode getExtentNode()
270 	{
271 		auto __p = webkit_dom_dom_selection_get_extent_node(webKitDOMDOMSelection);
272 
273 		if(__p is null)
274 		{
275 			return null;
276 		}
277 
278 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
279 	}
280 
281 	/**
282 	 *
283 	 *
284 	 * Deprecated: Use JavaScriptCore API instead
285 	 *
286 	 * Returns: A #gulong
287 	 *
288 	 * Since: 2.16
289 	 */
290 	public gulong getExtentOffset()
291 	{
292 		return webkit_dom_dom_selection_get_extent_offset(webKitDOMDOMSelection);
293 	}
294 
295 	/**
296 	 *
297 	 *
298 	 * Deprecated: Use JavaScriptCore API instead
299 	 *
300 	 * Returns: A #WebKitDOMNode
301 	 *
302 	 * Since: 2.16
303 	 */
304 	public DOMNode getFocusNode()
305 	{
306 		auto __p = webkit_dom_dom_selection_get_focus_node(webKitDOMDOMSelection);
307 
308 		if(__p is null)
309 		{
310 			return null;
311 		}
312 
313 		return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p);
314 	}
315 
316 	/**
317 	 *
318 	 *
319 	 * Deprecated: Use JavaScriptCore API instead
320 	 *
321 	 * Returns: A #gulong
322 	 *
323 	 * Since: 2.16
324 	 */
325 	public gulong getFocusOffset()
326 	{
327 		return webkit_dom_dom_selection_get_focus_offset(webKitDOMDOMSelection);
328 	}
329 
330 	/**
331 	 *
332 	 *
333 	 * Deprecated: Use JavaScriptCore API instead
334 	 *
335 	 * Returns: A #gboolean
336 	 *
337 	 * Since: 2.16
338 	 */
339 	public bool getIsCollapsed()
340 	{
341 		return webkit_dom_dom_selection_get_is_collapsed(webKitDOMDOMSelection) != 0;
342 	}
343 
344 	/**
345 	 *
346 	 *
347 	 * Deprecated: Use JavaScriptCore API instead
348 	 *
349 	 * Params:
350 	 *     index = A #gulong
351 	 *
352 	 * Returns: A #WebKitDOMRange
353 	 *
354 	 * Since: 2.16
355 	 *
356 	 * Throws: GException on failure.
357 	 */
358 	public DOMRange getRangeAt(gulong index)
359 	{
360 		GError* err = null;
361 
362 		auto __p = webkit_dom_dom_selection_get_range_at(webKitDOMDOMSelection, index, &err);
363 
364 		if (err !is null)
365 		{
366 			throw new GException( new ErrorG(err) );
367 		}
368 
369 		if(__p is null)
370 		{
371 			return null;
372 		}
373 
374 		return ObjectG.getDObject!(DOMRange)(cast(WebKitDOMRange*) __p, true);
375 	}
376 
377 	/**
378 	 *
379 	 *
380 	 * Deprecated: Use JavaScriptCore API instead
381 	 *
382 	 * Returns: A #gulong
383 	 *
384 	 * Since: 2.16
385 	 */
386 	public gulong getRangeCount()
387 	{
388 		return webkit_dom_dom_selection_get_range_count(webKitDOMDOMSelection);
389 	}
390 
391 	/**
392 	 *
393 	 *
394 	 * Deprecated: Use JavaScriptCore API instead
395 	 *
396 	 * Returns: A #gchar
397 	 *
398 	 * Since: 2.16
399 	 */
400 	public string getSelectionType()
401 	{
402 		auto retStr = webkit_dom_dom_selection_get_selection_type(webKitDOMDOMSelection);
403 
404 		scope(exit) Str.freeString(retStr);
405 		return Str.toString(retStr);
406 	}
407 
408 	/**
409 	 *
410 	 *
411 	 * Deprecated: Use JavaScriptCore API instead
412 	 *
413 	 * Params:
414 	 *     alter = A #gchar
415 	 *     direction = A #gchar
416 	 *     granularity = A #gchar
417 	 *
418 	 * Since: 2.16
419 	 */
420 	public void modify(string alter, string direction, string granularity)
421 	{
422 		webkit_dom_dom_selection_modify(webKitDOMDOMSelection, Str.toStringz(alter), Str.toStringz(direction), Str.toStringz(granularity));
423 	}
424 
425 	/**
426 	 *
427 	 *
428 	 * Deprecated: Use JavaScriptCore API instead
429 	 *
430 	 * Since: 2.16
431 	 */
432 	public void removeAllRanges()
433 	{
434 		webkit_dom_dom_selection_remove_all_ranges(webKitDOMDOMSelection);
435 	}
436 
437 	/**
438 	 *
439 	 *
440 	 * Deprecated: Use JavaScriptCore API instead
441 	 *
442 	 * Params:
443 	 *     node = A #WebKitDOMNode
444 	 *
445 	 * Since: 2.16
446 	 */
447 	public void selectAllChildren(DOMNode node)
448 	{
449 		webkit_dom_dom_selection_select_all_children(webKitDOMDOMSelection, (node is null) ? null : node.getDOMNodeStruct());
450 	}
451 
452 	/**
453 	 *
454 	 *
455 	 * Deprecated: Use JavaScriptCore API instead
456 	 *
457 	 * Params:
458 	 *     baseNode = A #WebKitDOMNode
459 	 *     baseOffset = A #gulong
460 	 *     extentNode = A #WebKitDOMNode
461 	 *     extentOffset = A #gulong
462 	 *
463 	 * Since: 2.16
464 	 */
465 	public void setBaseAndExtent(DOMNode baseNode, gulong baseOffset, DOMNode extentNode, gulong extentOffset)
466 	{
467 		webkit_dom_dom_selection_set_base_and_extent(webKitDOMDOMSelection, (baseNode is null) ? null : baseNode.getDOMNodeStruct(), baseOffset, (extentNode is null) ? null : extentNode.getDOMNodeStruct(), extentOffset);
468 	}
469 
470 	/**
471 	 *
472 	 *
473 	 * Deprecated: Use JavaScriptCore API instead
474 	 *
475 	 * Params:
476 	 *     node = A #WebKitDOMNode
477 	 *     offset = A #gulong
478 	 *
479 	 * Since: 2.16
480 	 */
481 	public void setPosition(DOMNode node, gulong offset)
482 	{
483 		webkit_dom_dom_selection_set_position(webKitDOMDOMSelection, (node is null) ? null : node.getDOMNodeStruct(), offset);
484 	}
485 }