Package com.google.gwt.dom.client

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


  /**
   * @return the calculated character data in the html
   * @throws HtmlMissing
   */
  public String getImplData() throws HtmlMissing {
    Node next = checkNodeAndNeighbourReturnImpl(this);
    HtmlView filteredHtml = getFilteredHtmlView();

    return sumTextNodes(getImplNodelet(), next, filteredHtml);
  }
View Full Code Here


  /**
   * @return length of character data in the html
   * @throws HtmlMissing
   */
  public int getImplDataLength() throws HtmlMissing {
    Node next = checkNodeAndNeighbourReturnImpl(this);
    HtmlView filteredHtml = getFilteredHtmlView();

    return sumTextNodesLength(getImplNodelet(), next, filteredHtml);
  }
View Full Code Here

    ContentNode next = checkNodeAndNeighbour(this);
    HtmlView filteredHtml = getFilteredHtmlView();

    //String sum = "";
    Node nextImpl = (next == null) ? null : next.getImplNodelet();
    for (Text nodelet = first; nodelet != nextImpl && nodelet != null;
        nodelet = filteredHtml.getNextSibling(first).cast()) {
      //sum += nodelet.getData();
      if (nodelet != first) {
        getExtendedContext().editing().textNodeletAffected(
View Full Code Here

   */
  public boolean owns(Text textNodelet) throws HtmlMissing {
    ContentNode next = checkNodeAndNeighbour(this);
    HtmlView filteredHtml = getFilteredHtmlView();

    Node nextImpl = (next == null) ? null : next.getImplNodelet();
    for (Text nodelet = getImplNodelet(); nodelet != nextImpl;
        nodelet = filteredHtml.getNextSibling(nodelet).cast()) {
      if (nodelet == textNodelet) {
        return true;
      }
View Full Code Here

  public void onRepair(ContentElement paragraph) {
    ensureSpacerIfDoesntEndWithText(paragraph.getImplNodelet());
  }

  private void ensureSpacerIfDoesntEndWithText(Element paragraph) {
    Node last = paragraph.getLastChild();
    BRElement spacer = getSpacer(paragraph);
    if (last == spacer) {
      last = last.getPreviousSibling();
    }
    if (last == null || DomHelper.isElement(last)) {
      paragraph.appendChild(spacer);
    } else {
      spacer.removeFromParent();
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public void onRemovingChild(Node child, Element paragraph) {
    Node first = paragraph.getFirstChild();
    BRElement spacer = getSpacer(paragraph);
    if (first == null) {
      appendSpacer(paragraph);
    } else if (first != spacer) {
      spacer.removeFromParent();
View Full Code Here

   */
  @Override
  public void assertHealthy(ContentElement paragraph) {
    ContentView renderedContent = paragraph.getRenderedContentView();
    if (renderedContent.getFirstChild(paragraph) != null) {
      Node child =
        paragraph.getImplNodelet().getFirstChild();
      while (child != null) {
        assert !isSpacer(child) : "Non-empty paragraph should not have spacer";
        child = child.getNextSibling();
      }
    }
    super.assertHealthy(paragraph);
  }
View Full Code Here

  private boolean isValid(Point<Node> p) {
    if (p.isInTextNode()) {
      return true;
    } else {
      Node nodeAfter = p.getNodeAfter();
      return nodeAfter == null || p.getContainer().equals(p.getNodeAfter().getParentElement());
    }
  }
View Full Code Here

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

  private Point<Node> linearSearchForRange(JsTextRangeIE target, Element parent) {
    try {
      // We'll iterate through the parent's children while moving
      // a new collapsed range, attempt, through the points before
      // each child.
      Node child = parent.getFirstChild();
      // Start attempt at beginning of parent
      JsTextRangeIE attempt = JsTextRangeIE.create().moveToElementText(parent).collapse(true);
      while (child != null) {
        // Treat text node children separately
        if (DomHelper.isTextNode(child)) {
          // Move attempt to end of the text node
          int len = child.<Text> cast().getLength();
          attempt.move(character, len);
          // Test if attempt is now at or past target
          if (attempt.compareEndPoints(StartToStart, target) >= 0) {
            // Target is in this text node. Compute the offset by creating a new
            // text range from target to attempt and measuring the length of the
            // text in that range
            JsTextRangeIE dup =
                attempt.duplicate().setEndPoint(StartToStart, target)
                    .setEndPoint(EndToEnd, attempt);
            return Point.inText(child, len - dup.getText().length());
          }
        } else {
          // Child is an element. Move attempt before child, and test
          // if attempt is at or past range
          attempt.moveToElementText(child.<Element> cast()).collapse(true);
          if (attempt.compareEndPoints(StartToStart, target) >= 0) {
            // Return the point before child
            return Point.inElement(parent, child);
          } else {
            // Move attempt past child
            // We use our inline, non-empty marker element to do this.
            // We also leave it in the dom for max reliability until it's needed
            // later, or gets taken out in the finally clause at the end of this method
            child.getParentNode().insertAfter(setter, child);
            // skip pass the setter.
            child = child.getNextSibling();

            attempt.moveToElementText(setter).collapse(false);
          }
        }
        // Move to next child
        child = child.getNextSibling();
      }

      // We didn't find target before or in children; return point at end of
      // parent
      return Point.<Node> end(parent);
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.