1 module webkit2webextension.DOMRange; 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.DOMDocumentFragment; 8 private import webkit2webextension.DOMNode; 9 private import webkit2webextension.DOMObject; 10 private import webkit2webextension.c.functions; 11 public import webkit2webextension.c.types; 12 13 14 /** */ 15 public class DOMRange : DOMObject 16 { 17 /** the main Gtk struct */ 18 protected WebKitDOMRange* webKitDOMRange; 19 20 /** Get the main Gtk struct */ 21 public WebKitDOMRange* getDOMRangeStruct(bool transferOwnership = false) 22 { 23 if (transferOwnership) 24 ownedRef = false; 25 return webKitDOMRange; 26 } 27 28 /** the main Gtk struct as a void* */ 29 protected override void* getStruct() 30 { 31 return cast(void*)webKitDOMRange; 32 } 33 34 /** 35 * Sets our main struct and passes it to the parent class. 36 */ 37 public this (WebKitDOMRange* webKitDOMRange, bool ownedRef = false) 38 { 39 this.webKitDOMRange = webKitDOMRange; 40 super(cast(WebKitDOMObject*)webKitDOMRange, ownedRef); 41 } 42 43 44 /** */ 45 public static GType getType() 46 { 47 return webkit_dom_range_get_type(); 48 } 49 50 /** 51 * 52 * 53 * Deprecated: Use JavaScriptCore API instead 54 * 55 * Returns: A #WebKitDOMDocumentFragment 56 * 57 * Throws: GException on failure. 58 */ 59 public DOMDocumentFragment cloneContents() 60 { 61 GError* err = null; 62 63 auto __p = webkit_dom_range_clone_contents(webKitDOMRange, &err); 64 65 if (err !is null) 66 { 67 throw new GException( new ErrorG(err) ); 68 } 69 70 if(__p is null) 71 { 72 return null; 73 } 74 75 return ObjectG.getDObject!(DOMDocumentFragment)(cast(WebKitDOMDocumentFragment*) __p); 76 } 77 78 /** 79 * 80 * 81 * Deprecated: Use JavaScriptCore API instead 82 * 83 * Returns: A #WebKitDOMRange 84 * 85 * Throws: GException on failure. 86 */ 87 public DOMRange cloneRange() 88 { 89 GError* err = null; 90 91 auto __p = webkit_dom_range_clone_range(webKitDOMRange, &err); 92 93 if (err !is null) 94 { 95 throw new GException( new ErrorG(err) ); 96 } 97 98 if(__p is null) 99 { 100 return null; 101 } 102 103 return ObjectG.getDObject!(DOMRange)(cast(WebKitDOMRange*) __p, true); 104 } 105 106 /** 107 * 108 * 109 * Deprecated: Use JavaScriptCore API instead 110 * 111 * Params: 112 * toStart = A #gboolean 113 * 114 * Throws: GException on failure. 115 */ 116 public void collapse(bool toStart) 117 { 118 GError* err = null; 119 120 webkit_dom_range_collapse(webKitDOMRange, toStart, &err); 121 122 if (err !is null) 123 { 124 throw new GException( new ErrorG(err) ); 125 } 126 } 127 128 /** 129 * 130 * 131 * Deprecated: Use JavaScriptCore API instead 132 * 133 * Params: 134 * how = A #gushort 135 * sourceRange = A #WebKitDOMRange 136 * 137 * Returns: A #gshort 138 * 139 * Throws: GException on failure. 140 */ 141 public short compareBoundaryPoints(ushort how, DOMRange sourceRange) 142 { 143 GError* err = null; 144 145 auto __p = webkit_dom_range_compare_boundary_points(webKitDOMRange, how, (sourceRange is null) ? null : sourceRange.getDOMRangeStruct(), &err); 146 147 if (err !is null) 148 { 149 throw new GException( new ErrorG(err) ); 150 } 151 152 return __p; 153 } 154 155 /** 156 * 157 * 158 * Deprecated: Use JavaScriptCore API instead 159 * 160 * Params: 161 * refNode = A #WebKitDOMNode 162 * 163 * Returns: A #gshort 164 * 165 * Throws: GException on failure. 166 */ 167 public short compareNode(DOMNode refNode) 168 { 169 GError* err = null; 170 171 auto __p = webkit_dom_range_compare_node(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err); 172 173 if (err !is null) 174 { 175 throw new GException( new ErrorG(err) ); 176 } 177 178 return __p; 179 } 180 181 /** 182 * 183 * 184 * Deprecated: Use JavaScriptCore API instead 185 * 186 * Params: 187 * refNode = A #WebKitDOMNode 188 * offset = A #glong 189 * 190 * Returns: A #gshort 191 * 192 * Throws: GException on failure. 193 */ 194 public short comparePoint(DOMNode refNode, glong offset) 195 { 196 GError* err = null; 197 198 auto __p = webkit_dom_range_compare_point(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), offset, &err); 199 200 if (err !is null) 201 { 202 throw new GException( new ErrorG(err) ); 203 } 204 205 return __p; 206 } 207 208 /** 209 * 210 * 211 * Deprecated: Use JavaScriptCore API instead 212 * 213 * Params: 214 * html = A #gchar 215 * 216 * Returns: A #WebKitDOMDocumentFragment 217 * 218 * Throws: GException on failure. 219 */ 220 public DOMDocumentFragment createContextualFragment(string html) 221 { 222 GError* err = null; 223 224 auto __p = webkit_dom_range_create_contextual_fragment(webKitDOMRange, Str.toStringz(html), &err); 225 226 if (err !is null) 227 { 228 throw new GException( new ErrorG(err) ); 229 } 230 231 if(__p is null) 232 { 233 return null; 234 } 235 236 return ObjectG.getDObject!(DOMDocumentFragment)(cast(WebKitDOMDocumentFragment*) __p); 237 } 238 239 /** 240 * 241 * 242 * Deprecated: Use JavaScriptCore API instead 243 * 244 * Throws: GException on failure. 245 */ 246 public void deleteContents() 247 { 248 GError* err = null; 249 250 webkit_dom_range_delete_contents(webKitDOMRange, &err); 251 252 if (err !is null) 253 { 254 throw new GException( new ErrorG(err) ); 255 } 256 } 257 258 /** 259 * 260 * 261 * Deprecated: Use JavaScriptCore API instead 262 * 263 * Throws: GException on failure. 264 */ 265 public void detach() 266 { 267 GError* err = null; 268 269 webkit_dom_range_detach(webKitDOMRange, &err); 270 271 if (err !is null) 272 { 273 throw new GException( new ErrorG(err) ); 274 } 275 } 276 277 /** 278 * 279 * 280 * Deprecated: Use JavaScriptCore API instead 281 * 282 * Params: 283 * unit = A #gchar 284 * 285 * Since: 2.16 286 * 287 * Throws: GException on failure. 288 */ 289 public void expand(string unit) 290 { 291 GError* err = null; 292 293 webkit_dom_range_expand(webKitDOMRange, Str.toStringz(unit), &err); 294 295 if (err !is null) 296 { 297 throw new GException( new ErrorG(err) ); 298 } 299 } 300 301 /** 302 * 303 * 304 * Deprecated: Use JavaScriptCore API instead 305 * 306 * Returns: A #WebKitDOMDocumentFragment 307 * 308 * Throws: GException on failure. 309 */ 310 public DOMDocumentFragment extractContents() 311 { 312 GError* err = null; 313 314 auto __p = webkit_dom_range_extract_contents(webKitDOMRange, &err); 315 316 if (err !is null) 317 { 318 throw new GException( new ErrorG(err) ); 319 } 320 321 if(__p is null) 322 { 323 return null; 324 } 325 326 return ObjectG.getDObject!(DOMDocumentFragment)(cast(WebKitDOMDocumentFragment*) __p); 327 } 328 329 /** 330 * 331 * 332 * Deprecated: Use JavaScriptCore API instead 333 * 334 * Returns: A #gboolean 335 * 336 * Throws: GException on failure. 337 */ 338 public bool getCollapsed() 339 { 340 GError* err = null; 341 342 auto __p = webkit_dom_range_get_collapsed(webKitDOMRange, &err) != 0; 343 344 if (err !is null) 345 { 346 throw new GException( new ErrorG(err) ); 347 } 348 349 return __p; 350 } 351 352 /** 353 * 354 * 355 * Deprecated: Use JavaScriptCore API instead 356 * 357 * Returns: A #WebKitDOMNode 358 * 359 * Throws: GException on failure. 360 */ 361 public DOMNode getCommonAncestorContainer() 362 { 363 GError* err = null; 364 365 auto __p = webkit_dom_range_get_common_ancestor_container(webKitDOMRange, &err); 366 367 if (err !is null) 368 { 369 throw new GException( new ErrorG(err) ); 370 } 371 372 if(__p is null) 373 { 374 return null; 375 } 376 377 return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p); 378 } 379 380 /** 381 * 382 * 383 * Deprecated: Use JavaScriptCore API instead 384 * 385 * Returns: A #WebKitDOMNode 386 * 387 * Throws: GException on failure. 388 */ 389 public DOMNode getEndContainer() 390 { 391 GError* err = null; 392 393 auto __p = webkit_dom_range_get_end_container(webKitDOMRange, &err); 394 395 if (err !is null) 396 { 397 throw new GException( new ErrorG(err) ); 398 } 399 400 if(__p is null) 401 { 402 return null; 403 } 404 405 return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p); 406 } 407 408 /** 409 * 410 * 411 * Deprecated: Use JavaScriptCore API instead 412 * 413 * Returns: A #glong 414 * 415 * Throws: GException on failure. 416 */ 417 public glong getEndOffset() 418 { 419 GError* err = null; 420 421 auto __p = webkit_dom_range_get_end_offset(webKitDOMRange, &err); 422 423 if (err !is null) 424 { 425 throw new GException( new ErrorG(err) ); 426 } 427 428 return __p; 429 } 430 431 /** 432 * 433 * 434 * Deprecated: Use JavaScriptCore API instead 435 * 436 * Returns: A #WebKitDOMNode 437 * 438 * Throws: GException on failure. 439 */ 440 public DOMNode getStartContainer() 441 { 442 GError* err = null; 443 444 auto __p = webkit_dom_range_get_start_container(webKitDOMRange, &err); 445 446 if (err !is null) 447 { 448 throw new GException( new ErrorG(err) ); 449 } 450 451 if(__p is null) 452 { 453 return null; 454 } 455 456 return ObjectG.getDObject!(DOMNode)(cast(WebKitDOMNode*) __p); 457 } 458 459 /** 460 * 461 * 462 * Deprecated: Use JavaScriptCore API instead 463 * 464 * Returns: A #glong 465 * 466 * Throws: GException on failure. 467 */ 468 public glong getStartOffset() 469 { 470 GError* err = null; 471 472 auto __p = webkit_dom_range_get_start_offset(webKitDOMRange, &err); 473 474 if (err !is null) 475 { 476 throw new GException( new ErrorG(err) ); 477 } 478 479 return __p; 480 } 481 482 /** 483 * 484 * 485 * Deprecated: Use JavaScriptCore API instead 486 * 487 * Returns: A #gchar 488 */ 489 public string getText() 490 { 491 auto retStr = webkit_dom_range_get_text(webKitDOMRange); 492 493 scope(exit) Str.freeString(retStr); 494 return Str.toString(retStr); 495 } 496 497 /** 498 * 499 * 500 * Deprecated: Use JavaScriptCore API instead 501 * 502 * Params: 503 * newNode = A #WebKitDOMNode 504 * 505 * Throws: GException on failure. 506 */ 507 public void insertNode(DOMNode newNode) 508 { 509 GError* err = null; 510 511 webkit_dom_range_insert_node(webKitDOMRange, (newNode is null) ? null : newNode.getDOMNodeStruct(), &err); 512 513 if (err !is null) 514 { 515 throw new GException( new ErrorG(err) ); 516 } 517 } 518 519 /** 520 * 521 * 522 * Deprecated: Use JavaScriptCore API instead 523 * 524 * Params: 525 * refNode = A #WebKitDOMNode 526 * 527 * Returns: A #gboolean 528 * 529 * Throws: GException on failure. 530 */ 531 public bool intersectsNode(DOMNode refNode) 532 { 533 GError* err = null; 534 535 auto __p = webkit_dom_range_intersects_node(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err) != 0; 536 537 if (err !is null) 538 { 539 throw new GException( new ErrorG(err) ); 540 } 541 542 return __p; 543 } 544 545 /** 546 * 547 * 548 * Deprecated: Use JavaScriptCore API instead 549 * 550 * Params: 551 * refNode = A #WebKitDOMNode 552 * offset = A #glong 553 * 554 * Returns: A #gboolean 555 * 556 * Throws: GException on failure. 557 */ 558 public bool isPointInRange(DOMNode refNode, glong offset) 559 { 560 GError* err = null; 561 562 auto __p = webkit_dom_range_is_point_in_range(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), offset, &err) != 0; 563 564 if (err !is null) 565 { 566 throw new GException( new ErrorG(err) ); 567 } 568 569 return __p; 570 } 571 572 /** 573 * 574 * 575 * Deprecated: Use JavaScriptCore API instead 576 * 577 * Params: 578 * refNode = A #WebKitDOMNode 579 * 580 * Throws: GException on failure. 581 */ 582 public void selectNode(DOMNode refNode) 583 { 584 GError* err = null; 585 586 webkit_dom_range_select_node(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err); 587 588 if (err !is null) 589 { 590 throw new GException( new ErrorG(err) ); 591 } 592 } 593 594 /** 595 * 596 * 597 * Deprecated: Use JavaScriptCore API instead 598 * 599 * Params: 600 * refNode = A #WebKitDOMNode 601 * 602 * Throws: GException on failure. 603 */ 604 public void selectNodeContents(DOMNode refNode) 605 { 606 GError* err = null; 607 608 webkit_dom_range_select_node_contents(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err); 609 610 if (err !is null) 611 { 612 throw new GException( new ErrorG(err) ); 613 } 614 } 615 616 /** 617 * 618 * 619 * Deprecated: Use JavaScriptCore API instead 620 * 621 * Params: 622 * refNode = A #WebKitDOMNode 623 * offset = A #glong 624 * 625 * Throws: GException on failure. 626 */ 627 public void setEnd(DOMNode refNode, glong offset) 628 { 629 GError* err = null; 630 631 webkit_dom_range_set_end(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), offset, &err); 632 633 if (err !is null) 634 { 635 throw new GException( new ErrorG(err) ); 636 } 637 } 638 639 /** 640 * 641 * 642 * Deprecated: Use JavaScriptCore API instead 643 * 644 * Params: 645 * refNode = A #WebKitDOMNode 646 * 647 * Throws: GException on failure. 648 */ 649 public void setEndAfter(DOMNode refNode) 650 { 651 GError* err = null; 652 653 webkit_dom_range_set_end_after(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err); 654 655 if (err !is null) 656 { 657 throw new GException( new ErrorG(err) ); 658 } 659 } 660 661 /** 662 * 663 * 664 * Deprecated: Use JavaScriptCore API instead 665 * 666 * Params: 667 * refNode = A #WebKitDOMNode 668 * 669 * Throws: GException on failure. 670 */ 671 public void setEndBefore(DOMNode refNode) 672 { 673 GError* err = null; 674 675 webkit_dom_range_set_end_before(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err); 676 677 if (err !is null) 678 { 679 throw new GException( new ErrorG(err) ); 680 } 681 } 682 683 /** 684 * 685 * 686 * Deprecated: Use JavaScriptCore API instead 687 * 688 * Params: 689 * refNode = A #WebKitDOMNode 690 * offset = A #glong 691 * 692 * Throws: GException on failure. 693 */ 694 public void setStart(DOMNode refNode, glong offset) 695 { 696 GError* err = null; 697 698 webkit_dom_range_set_start(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), offset, &err); 699 700 if (err !is null) 701 { 702 throw new GException( new ErrorG(err) ); 703 } 704 } 705 706 /** 707 * 708 * 709 * Deprecated: Use JavaScriptCore API instead 710 * 711 * Params: 712 * refNode = A #WebKitDOMNode 713 * 714 * Throws: GException on failure. 715 */ 716 public void setStartAfter(DOMNode refNode) 717 { 718 GError* err = null; 719 720 webkit_dom_range_set_start_after(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err); 721 722 if (err !is null) 723 { 724 throw new GException( new ErrorG(err) ); 725 } 726 } 727 728 /** 729 * 730 * 731 * Deprecated: Use JavaScriptCore API instead 732 * 733 * Params: 734 * refNode = A #WebKitDOMNode 735 * 736 * Throws: GException on failure. 737 */ 738 public void setStartBefore(DOMNode refNode) 739 { 740 GError* err = null; 741 742 webkit_dom_range_set_start_before(webKitDOMRange, (refNode is null) ? null : refNode.getDOMNodeStruct(), &err); 743 744 if (err !is null) 745 { 746 throw new GException( new ErrorG(err) ); 747 } 748 } 749 750 /** 751 * 752 * 753 * Deprecated: Use JavaScriptCore API instead 754 * 755 * Params: 756 * newParent = A #WebKitDOMNode 757 * 758 * Throws: GException on failure. 759 */ 760 public void surroundContents(DOMNode newParent) 761 { 762 GError* err = null; 763 764 webkit_dom_range_surround_contents(webKitDOMRange, (newParent is null) ? null : newParent.getDOMNodeStruct(), &err); 765 766 if (err !is null) 767 { 768 throw new GException( new ErrorG(err) ); 769 } 770 } 771 772 /** 773 * 774 * 775 * Deprecated: Use JavaScriptCore API instead 776 * 777 * Returns: A #gchar 778 * 779 * Throws: GException on failure. 780 */ 781 public override string toString() 782 { 783 GError* err = null; 784 785 auto retStr = webkit_dom_range_to_string(webKitDOMRange, &err); 786 787 if (err !is null) 788 { 789 throw new GException( new ErrorG(err) ); 790 } 791 792 scope(exit) Str.freeString(retStr); 793 return Str.toString(retStr); 794 } 795 }