Java Code Examples for com.google.gwt.dom.client.Element#getNextSibling()

The following examples show how to use com.google.gwt.dom.client.Element#getNextSibling() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectionImplIE.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Search for node by pasting that element at a textRange and locating that
 * element directly using getElementById. This is a huge shortcut when there
 * are many nodes in parent. However, use with caution as it can fragment text
 * nodes.
 *
 * NOTE(user): The text node fragmentation is a real issue, it causes repairs
 * to happen. The constant splitting and repairing can also have performance
 * issues that needs to be investigated. We should repair the damage here,
 * when its clear how to fix the problem.
 *
 * @param target
 * @param parent
 * @return Point
 */
@SuppressWarnings("unused") // NOTE(user): Use later for nodes with many siblings.
private Point<Node> searchForRangeUsingPaste(JsTextRangeIE target, Element parent) {
  Element elem = null;
  try {
    target.pasteHTML("<b id='__paste_target__'>X</b>");
    elem = Document.get().getElementById("__paste_target__");
    Node nextSibling = elem.getNextSibling();
    if (DomHelper.isTextNode(nextSibling)) {
      return Point.inText(nextSibling, 0);
    } else {
      return Point.inElement(parent, nextSibling);
    }
  } finally {
    if (elem != null) {
      elem.removeFromParent();
    }
  }
}
 
Example 2
Source File: SelectionImplIE.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Search for node by pasting that element at a textRange and locating that
 * element directly using getElementById. This is a huge shortcut when there
 * are many nodes in parent. However, use with caution as it can fragment text
 * nodes.
 *
 * NOTE(user): The text node fragmentation is a real issue, it causes repairs
 * to happen. The constant splitting and repairing can also have performance
 * issues that needs to be investigated. We should repair the damage here,
 * when its clear how to fix the problem.
 *
 * @param target
 * @param parent
 * @return Point
 */
@SuppressWarnings("unused") // NOTE(user): Use later for nodes with many siblings.
private Point<Node> searchForRangeUsingPaste(JsTextRangeIE target, Element parent) {
  Element elem = null;
  try {
    target.pasteHTML("<b id='__paste_target__'>X</b>");
    elem = Document.get().getElementById("__paste_target__");
    Node nextSibling = elem.getNextSibling();
    if (DomHelper.isTextNode(nextSibling)) {
      return Point.inText(nextSibling, 0);
    } else {
      return Point.inElement(parent, nextSibling);
    }
  } finally {
    if (elem != null) {
      elem.removeFromParent();
    }
  }
}
 
Example 3
Source File: SelectionImplIE.java    From swellrt with Apache License 2.0 5 votes vote down vote up
/**
 * @param range
 * @param element
 * @return input range collapsed after element
 */
@SuppressWarnings("unused")  // TODO(zdwang): Dead code. Left here, as it may be useful later.
private JsTextRangeIE collapseAfterElement(JsTextRangeIE range, Element element) {
  Node next = element.getNextSibling();
  return (next != null) ?
      collapseBeforeNode(range, next) :
        collapseAtEnd(range, element.getParentElement());
}
 
Example 4
Source File: SelectionImplIE.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
/**
 * @param range
 * @param element
 * @return input range collapsed after element
 */
@SuppressWarnings("unused")  // TODO(zdwang): Dead code. Left here, as it may be useful later.
private JsTextRangeIE collapseAfterElement(JsTextRangeIE range, Element element) {
  Node next = element.getNextSibling();
  return (next != null) ?
      collapseBeforeNode(range, next) :
        collapseAtEnd(range, element.getParentElement());
}