Package org.waveprotocol.wave.client.editor.content

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


        // Ensure methods we call on the text node operate on the same view as us
        assert wrapper.getFilteredHtmlView() == filteredHtml;

        Node htmlNodeBefore = filteredHtml.getPreviousSibling(firstWrapper.getImplNodelet());
        Element htmlParent = filteredHtml.getParentElement(node);
        ContentNode cnodeAfter = contentRange.getNodeAfter();
        Node htmlNodeAfter = cnodeAfter == null ? null : cnodeAfter.getImplNodelet();
        htmlRange = RestrictedRange.between(
            htmlNodeBefore, Point.inElement(htmlParent, htmlNodeAfter));

        if (partOfMutatingRange(filteredHtml.asText(previousSelectionStart.getContainer()))) {
          // This must be true if getWrapper worked correctly. Program error
View Full Code Here


        // TODO(patcoleman): see if being zero here is actually a problem.
        // assert selNode.getLength() > 0;

        if (selOffset == 0 && firstWrapper.getImplNodelet() == selNode) {
          // if we are at beginning of mutating node
          ContentNode prev = renderedContent.getPreviousSibling(firstWrapper);
          if (prev != null && prev.isTextNode()) {
            firstWrapper = (ContentTextNode)prev;
          }
        } else {
          ContentNode nextNode = renderedContent.getNextSibling(lastWrapper);
          Node nextNodelet = nextNode != null ? nextNode.getImplNodelet() : null;
          if (selOffset == selNode.getLength() &&
              filteredHtml.getNextSibling(selNode) == nextNodelet) {
            // if we are at end of mutating node
            if (nextNode != null && nextNode.isTextNode()) {
              lastWrapper = (ContentTextNode)nextNode;
            }
          }
        }
      } finally {
View Full Code Here

    }

    if (keySignalType == KeySignalType.DELETE) {
      refreshEditorWithCaret(event);
      caret = cachedSelection.getFocus();
      ContentNode node = caret.getContainer();

      editorInteractor.checkpoint(new FocusedContentRange(caret));

      switch (EventWrapper.getKeyCombo(event)) {
        case BACKSPACE:
View Full Code Here

  }

  private boolean handleNavigationKeyEvents(EditorEvent event) {
    editorInteractor.checkpoint(null);
    editorInteractor.clearCaretAnnotations();
    ContentNode node = cachedSelection.getFocus().getContainer();
    logger.trace().log("Navigation event");

    // Not using key combo, because we want to handle left key with
    // any modifiers also applying.
    // TODO(danilatos): MoveUnit, and holding down shift for selection.
View Full Code Here

    Point<ContentNode> first = contentSelection.getFirst();
    Point<ContentNode> second = contentSelection.getSecond();
    SelectionMatcher selectionMatcher =
        new SelectionMatcher(first, second);

    ContentNode commonAncestor =
        DocHelper.nearestCommonAncestor(renderedContent, first
            .getContainer(), second.getContainer());

    Node fragment = PASTE_FORMAT_RENDERER.renderTree(renderedContent, commonAncestor,
        selectionMatcher);
View Full Code Here

  boolean isEmptyLine(ContentElement e) {
    // The line containing element e is considered empty if its line element is the last
    // element or if it is followed by another line element
    ContentElement lineElement = Line.fromParagraph(e).getLineElement();
    CMutableDocument doc = lineElement.getMutableDoc();
    ContentNode next = doc.getNextSibling(lineElement);
    return next == null
        || (next.asElement() != null && LineRendering.isLineElement(next.asElement()));
  }
View Full Code Here

    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

        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

   *
   * @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

      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

TOP

Related Classes of org.waveprotocol.wave.client.editor.content.ContentNode

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.