Examples of ContentNode


Examples of org.waveprotocol.wave.client.editor.content.ContentNode

    ContentPoint contentPoint = event.getCaret();
    if (!contentPoint.isInTextNode() && contentPoint.getContainer() != element) {
      return true;
    }
    Point<ContentNode> point = contentPoint.asPoint();
    ContentNode nodeBefore = point.isInTextNode()
        ? point.getContainer() : Point.nodeBefore(FullContentView.INSTANCE, point.asElementPoint());
    Line line = Line.fromParagraph(element);

    // If user hits enter at the an empty list item - we de-indent or stop the list
    if (getBehaviour(element) == ParagraphBehaviour.LIST
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

        container.getContext();

      ContentElement element = child.asElement();
      if (element != null && isLineElement(element)) {
        Line line = new Line(cxt, element);
        ContentNode previousDirectSibling = child.getPreviousSibling();
        ContentNode previousPersistentSibling = container.getMutableDoc().getPreviousSibling(child);
        if (previousPersistentSibling == null) {
          insertAsFirstLine(container, line);
        } else {
          Line previousLine;
          if (element.getParentElement() == container) {
            // TODO(danilatos): Handle the case where this assertion fails.
            assert previousDirectSibling != null &&
                LineRendering.isLocalParagraph(previousDirectSibling);
            previousLine = Line.fromParagraph(previousDirectSibling.asElement());
          } else {
            previousLine = Line.fromParagraph(element.getParentElement());
          }

          // TODO(danilatos): Handle the case where this assertion fails too.
          assert previousLine != null;

          insertAfterLine(previousLine, line);
        }

        Line nextLine = line.next();
        ContentElement paragraph = line.getParagraph();

        if (element.getParentElement() != container) {
          cxt.annotatableContent().transparentMove(paragraph, paragraph.getNextSibling(),
              null, null);
          cxt.annotatableContent().transparentMove(container, paragraph, null,
              element.getParentElement().getNextSibling());
          cxt.annotatableContent().transparentMove(container, element, null,
              paragraph);
        }

      } else {
        ContentNode before = child.getPreviousSibling();
        ContentElement paragraph = before == null ? null : asParagraph(before);
        if (paragraph != null) {
          cxt.annotatableContent().transparentMove(paragraph, child, child.getNextSibling(), null);
        }
      }
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

   *
   * @param container
   * @return true if healthy, false otherwise
   */
  public static boolean containerIsHealthyStrong(ContentElement container) {
    ContentNode firstChild = container.getFirstChild();
    Line line = Line.getFirstLineOfContainer(container);
    if (line == null) {
      errorLogAndThrow("Empty container - must have at least one child");
      if (firstChild != null) {
        return false;
      } else {
        return true;
      }
    }
    if (line.previous() != null) {
      errorLogAndThrow("First line must have no previous sibling");
      return false;
    }
    if (!isLineElement(firstChild)) {
      errorLogAndThrow("First child not a line element");
      return false;
    }

    ContentElement element = firstChild.asElement();
    boolean first = true;

    while (true) {
      if (line.getParagraph().getPreviousSibling() != line.getLineElement()) {
        errorLogAndThrow("Junk between line token and its paragraph");
        return false;
      }

      ContentNode node;
      for (node = line.getParagraph().getFirstChild(); node != null; node = node.getNextSibling()) {

        ContentElement e = node.asElement();
        if (e != null) {
          if (isLineElement(e)) {
            errorLogAndThrow("Line element stuck inside rendering paragraph: " + e);
            return false;
          }
        }
      }

      node = line.getParagraph().getNextSibling();
      if (node == null) {
        if (line.next() != null) {
          errorLogAndThrow("Supposed to have another line, but no more nodes");
          return false;
        } else {
          return true;
        }
      }

      if (line.getParagraph().getImplNodelet() != null) {
        // Only check this when rendered.
        if (line.getParagraph().getImplNodelet().getNextSibling() !=
            line.next().getParagraph().getImplNodelet()) {
          errorLogAndThrow("Junk in html between paragraph nodelets");
          return false;
        }
      }

      if (!isLineElement(node)) {
        errorLogAndThrow("Junk after rendering paragraph "
            + line.getParagraph() + ", junk: " + node);
        return false;
      }

      element = node.asElement();
      Line nextLine = Line.fromLineElement(element);
      if (line.next() != nextLine) {
        errorLogAndThrow("Next line doesn't correspond to next line element");
        return false;
      }
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

      SelectionMatcher selectionMatcher) {

    Preconditions.checkArgument(firstItem instanceof ContentElement,
        "firstItem must be an instance of ContentElement ", firstItem.getClass());

    ContentNode prev = null;
    HtmlStack helper = new HtmlStack(destParent);

    for (ContentNode node = firstItem;
         node != null && node != stopAt;
         prev = node, node = view.getNextSibling(node)) {
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

    Point<ContentNode> point = mapper.locate(start);
    CMutableDocument doc = point.getContainer().getMutableDoc();
    LineContainers.checkNotParagraphDocument(doc);

    // get line element we are in:
    ContentNode first = LineContainers.getRelatedLineElement(doc, point);

    if (first == null) {
      return null;
    }

    // go through the lines one by one:
    return Line.fromLineElement(first.asElement());
  }
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

   * Rescans all gadget children to update the values stored in the gadget
   * object.
   */
  private void rescanGadgetXmlElements() {
    log("Rescanning elements");
    ContentNode childNode = element.getFirstChild();
    while (childNode != null) {
      processChild(GadgetElementChild.create(childNode));
      childNode = childNode.getNextSibling();
    }
  }
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

      SelectionMatcher selectionMatcher) {

    Preconditions.checkArgument(firstItem instanceof ContentElement,
        "firstItem must be an instance of ContentElement ", firstItem.getClass());

    ContentNode prev = null;
    HtmlStack helper = new HtmlStack(destParent);

    for (ContentNode node = firstItem;
         node != null && node != stopAt;
         prev = node, node = view.getNextSibling(node)) {
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

    Point<ContentNode> point = mapper.locate(start);
    CMutableDocument doc = point.getContainer().getMutableDoc();
    LineContainers.checkNotParagraphDocument(doc);

    // get line element we are in:
    ContentNode first = LineContainers.getRelatedLineElement(doc, point);

    if (first == null) {
      return null;
    }

    // go through the lines one by one:
    return Line.fromLineElement(first.asElement());
  }
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

    if (cp.getContainer().isTextNode()) {
      ContentTextNode textNode = (ContentTextNode) cp.getContainer();
      return cp.getTextOffset() <= textNode.getLength();
    } else {
      ContentNode nodeAfter = cp.getNodeAfter();
      return nodeAfter == null || cp.getContainer() == nodeAfter.getParentElement();
    }
  }
View Full Code Here

Examples of org.waveprotocol.wave.client.editor.content.ContentNode

    // Valid position for cursor, so stop where we are:
    if (!isKnownInvalidTopContainerForCursor(container)) {
      return point;
    }

    ContentNode nodeAfter = point.getNodeAfter();
    ContentNode newContainer;

    if (nodeAfter == null) {
      // place the cursor in the right-most valid child of the current container
      newContainer = validContainerView.getLastChild(container);
    } else {
      // we want to place the cursor at the end of the previous node
      newContainer = validContainerView.getVisibleNodePrevious(nodeAfter);
      if (newContainer != null) {
        // Special-case: if nodeAfter is already valid, find the previous valid point:
        if (newContainer.equals(nodeAfter)) {
          // Check to see if we've found ourselves before a visible, valid point:
          newContainer = validContainerView.getVisibleNodePrevious(nodeAfter.getParentElement());
          if (newContainer == nodeAfter.getParentElement()) {
            return Point.before(validContainerView, nodeAfter);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.