Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.Node


      JsTextRangeIE attempt = JsTextRangeIE.create();
      int low = 0;
      int high = parent.getChildCount() - 1;
      while (low <= high) {
        int mid = (low + high) >>> 1;
        Node node = parent.getChild(mid);
        node.getParentNode().insertBefore(setter, node);
        attempt.moveToElementText(setter).collapse(false);
        int cmp = attempt.compareEndPoints(CompareMode.StartToEnd, target);

        if (cmp == 0) {
          if (DomHelper.isTextNode(node)) {
            return Point.inText(node, 0);
          } else {
            return Point.inElement(parent, node);
          }
        } else if (cmp > 0) {
          high = mid - 1;
        } else {
          if (DomHelper.isTextNode(node)) {
            JsTextRangeIE dup = attempt.duplicate();
            dup.setEndPoint(EndToEnd, target);
            if (dup.getText().length() <= node.<Text> cast().getLength()) {
              return Point.inText(node, dup.getText().length());
            }
          } else {
            attempt.moveToElementText(node.<Element> cast()).collapse(false);
            if (attempt.compareEndPoints(StartToStart, target) >= 0) {
              return Point.inElement(parent, node);
            }

          }
View Full Code Here


   * @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());
  }
View Full Code Here

      JsTextRangeIE collapsed = collapseBeforeNode(range, point.getContainer());
      collapsed.move(character, point.getTextOffset());
      return collapsed;
    } else {
      Element element = point.getContainer().cast();
      Node child = point.getNodeAfter();
      return child != null ?
          collapseBeforeNode(range, child) :
            collapseAtEnd(range, element);
    }
  }
View Full Code Here

    if (selection == null) {
      // NOTE(danilatos): This seems to happen very rarely with FF.
      // I wonder what the reproducible cause is.
      return null;
    }
    Node anchorNode = selection.anchorNode();
    Node focusNode = selection.focusNode();
    return focusNode == null ? null : constructRange(
        anchorNode, selection.anchorOffset(),
        focusNode, selection.focusOffset());
  }
View Full Code Here

    JsRange jsRange = getSelectionRange();
    if (jsRange == null) {
      return true;
    }
    SelectionW3CNative selection = SelectionW3CNative.getSelectionGuarded();
    Node anchorNode = selection.anchorNode();
    int anchorOffset = selection.anchorOffset();
    boolean ret = anchorNode == jsRange.startContainer() && anchorOffset == jsRange.startOffset();

    // check that if the anchor doesn't match the start, then the focus does.
    assert ret || focusIsAtStart(selection, jsRange);
View Full Code Here

    return ret;
  }

  boolean focusIsAtStart(SelectionW3CNative selection, JsRange jsRange) {
    Node focusNode = selection.focusNode();
    int focusOffset = selection.focusOffset();
    return focusNode == jsRange.startContainer() && focusOffset == jsRange.startOffset();
  }
View Full Code Here

    int anchorOffset;
    int focusOffset;
    JsRange range = JsRange.create();

    Node anchorNode = anchor.getContainer();
    Node focusNode = focus.getContainer();

    assert anchorNode != null : "Anchor node must not be null.";
    assert focusNode != null : "Focus node must not be null.";

    if (anchor.isInTextNode()) {
      anchorOffset = anchor.getTextOffset();
    } else if (anchor.getNodeAfter() == null) {
      anchorOffset = anchorNode.getChildCount();
    } else {
      anchorNode = anchor.getNodeAfter().getParentElement();
      range.setStartBefore(anchor.getNodeAfter());
      anchorOffset = range.startOffset();
    }

    if (focus.isInTextNode()) {
      focusOffset = focus.getTextOffset();
    } else {
      Node focusNodeAfter = focus.getNodeAfter();
      if (focusNodeAfter == null) {
        focusOffset = focusNode.getChildCount();
      } else {
        focusNode = focusNodeAfter.getParentElement();
        assert focusNode != null : "focus node must not be null";
        range.setStartBefore(focusNodeAfter);
        focusOffset = range.startOffset();
      }
    }
View Full Code Here

    int anchorOffset;
    int focusOffset;
    JsRange range = JsRange.create();

    Node focusNode = focus.getContainer();

    if (focus.isInTextNode()) {
      focusOffset = focus.getTextOffset();
    } else if (focus.getNodeAfter() == null) {
      focusOffset = focusNode.getChildCount();
    } else {
      range.setStartBefore(focus.getNodeAfter());
      focusOffset = range.startOffset();
    }
View Full Code Here

  @Override
  public void assertHealthy(ContentElement paragraph) {
    ContentView renderedContent = paragraph.getRenderedContentView();
    if (renderedContent.getFirstChild(paragraph) != null) {
      Element nodelet = paragraph.getImplNodelet();
      Node last = nodelet.getLastChild();
      assert isSpacer(last) : "Last nodelet child should be spacer";
      Node child = nodelet.getFirstChild();
      while (child != null && !child.equals(last)) {
        assert !isSpacer(child) : "Only last nodelet child should be spacer";
        child = child.getNextSibling();
      }
    }
    super.assertHealthy(paragraph);
  }
View Full Code Here

    return e.getTagName().toLowerCase().equals("br") && !NodeManager.hasBackReference(e);
  }

  @Override
  public Node getEndingNodelet(Element paragraph) {
    Node maybeSpacer = paragraph.getLastChild();
    return isSpacer(maybeSpacer) ? maybeSpacer : null;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.