1 /* 2 * Range.java 3 * 4 * Copyright (C) 2021 by RStudio, PBC 5 * 6 * Unless you have received this program directly from RStudio pursuant 7 * to the terms of a commercial license agreement with RStudio, then 8 * this program is licensed to you under the terms of version 3 of the 9 * GNU Affero General Public License. This program is distributed WITHOUT 10 * ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, 11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the 12 * AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. 13 * 14 */ 15 package org.rstudio.core.client.dom.impl; 16 17 import com.google.gwt.core.client.JavaScriptObject; 18 import com.google.gwt.dom.client.Document; 19 import com.google.gwt.dom.client.Node; 20 21 class Range extends JavaScriptObject 22 { Range()23 protected Range() 24 { 25 } 26 create(Document doc)27 public static native Range create(Document doc) /*-{ 28 return doc.createRange(); 29 }-*/; 30 isCollapsed()31 public final native boolean isCollapsed() /*-{ 32 return this.collapsed; 33 }-*/; 34 getCommonAncestorContainer()35 public final native Node getCommonAncestorContainer() /*-{ 36 return this.commonAncestorContainer; 37 }-*/; 38 getEndContainer()39 public final native Node getEndContainer() /*-{ 40 return this.endContainer; 41 }-*/; 42 getEndOffset()43 public final native int getEndOffset() /*-{ 44 return this.endOffset; 45 }-*/; 46 getStartContainer()47 public final native Node getStartContainer() /*-{ 48 return this.startContainer; 49 }-*/; 50 getStartOffset()51 public final native int getStartOffset() /*-{ 52 return this.startOffset; 53 }-*/; 54 cloneContents()55 public final native JavaScriptObject cloneContents() /*-{ 56 return this.cloneContents(); 57 }-*/; 58 cloneRange()59 public final native Range cloneRange() /*-{ 60 return this.cloneRange(); 61 }-*/; 62 collapse(boolean toStart)63 public final native void collapse(boolean toStart) /*-{ 64 return this.collapse(toStart); 65 }-*/; 66 compareBoundaryPoints(short how, Range sourceRange)67 public final native short compareBoundaryPoints(short how, 68 Range sourceRange) /*-{ 69 return this.compareBoundaryPoints(how, sourceRange); 70 }-*/; 71 deleteContents()72 public final native void deleteContents() /*-{ 73 return this.deleteContents(); 74 }-*/; 75 detach()76 public final native void detach() /*-{ 77 return this.detach(); 78 }-*/; 79 extractContents()80 public final native JavaScriptObject extractContents() /*-{ 81 return this.extractContents(); 82 }-*/; 83 insertNode(Node newNode)84 public final native void insertNode(Node newNode) /*-{ 85 return this.insertNode(newNode); 86 }-*/; 87 selectNode(Node refNode)88 public final native void selectNode(Node refNode) /*-{ 89 return this.selectNode(refNode); 90 }-*/; 91 selectNodeContents(Node refNode)92 public final native void selectNodeContents(Node refNode) /*-{ 93 return this.selectNodeContents(refNode); 94 }-*/; 95 setEnd(Node refNode, int offset)96 public final native void setEnd(Node refNode, int offset) /*-{ 97 return this.setEnd(refNode, offset); 98 }-*/; 99 setEndAfter(Node refNode)100 public final native void setEndAfter(Node refNode) /*-{ 101 return this.setEndAfter(refNode); 102 }-*/; 103 setEndBefore(Node refNode)104 public final native void setEndBefore(Node refNode) /*-{ 105 return this.setEndBefore(refNode); 106 }-*/; 107 setStart(Node refNode, int offset)108 public final native void setStart(Node refNode, int offset) /*-{ 109 return this.setStart(refNode, offset); 110 }-*/; 111 setStartAfter(Node refNode)112 public final native void setStartAfter(Node refNode) /*-{ 113 return this.setStartAfter(refNode); 114 }-*/; 115 setStartBefore(Node refNode)116 public final native void setStartBefore(Node refNode) /*-{ 117 return this.setStartBefore(refNode); 118 }-*/; 119 surroundContents(Node newParent)120 public final native void surroundContents(Node newParent) /*-{ 121 return this.surroundContents(newParent); 122 }-*/; 123 toStringJs()124 public final native String toStringJs() /*-{ 125 return this.toString(); 126 }-*/; 127 } 128