Examples of ContentNode


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

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

  /** {@inheritDoc} */
  public Point<ContentNode> getFirstValidSelectionPoint() {
    ContentElement root = renderedContentView.getDocumentElement();
    // Must use filtered view, because of assertion in findOrCreateValidSelectionPoint
    ContentNode first = renderedContentView.getFirstChild(root);

    // assert there's no transparent wrapper, which would render the point invalid
    // for many uses
    assert first == null || first.getParentElement() == root;

    Point<ContentNode> point = findOrCreateValidSelectionPoint(Point.inElement(root, first));
    if (point == null) {
      throw new RuntimeException("Could not create a valid selection point!");
    }
View Full Code Here

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

    HtmlView filteredHtml = filteredHtmlView;

    // The element before all previous text node siblings of target,
    // or null if no such element
    Node nodeletBeforeTextNodes;
    ContentNode wrapperBeforeTextNodes;

    // Our cursors
    Text current = target;
    ContentNode possibleOwnerNode;

    // Go leftwards to find the start of the text nodelet sequence
    for (nodeletBeforeTextNodes = filteredHtml.getPreviousSibling(target);
         nodeletBeforeTextNodes != null;
         nodeletBeforeTextNodes = filteredHtml.getPreviousSibling(nodeletBeforeTextNodes)) {
      Text maybeText = filteredHtml.asText(nodeletBeforeTextNodes);
      if (maybeText == null) {
        break;
      }
      current = maybeText;
    }

    Element parentNodelet = filteredHtml.getParentElement(target);
    if (parentNodelet == null) {
      throw new RuntimeException(
          "Somehow we are asking for the wrapper of something not in the editor??");
    }
    ContentElement parentElement = NodeManager.getBackReference(parentNodelet);

    // Find our foothold in wrapper land
    if (nodeletBeforeTextNodes == null) {
      // reached the beginning
      wrapperBeforeTextNodes = null;
      possibleOwnerNode = renderedContent.getFirstChild(parentElement);
    } else {
      // reached an element
      wrapperBeforeTextNodes = NodeManager.getBackReference(
          nodeletBeforeTextNodes.<Element>cast());
      possibleOwnerNode = renderedContent.getNextSibling(wrapperBeforeTextNodes);
    }

    // Scan to find a matching pair
    while (true) {
      // TODO(danilatos): Clarify and possibly reorganise this loop
      // TODO(danilatos): Write more unit tests to thoroughly cover all scenarios

      if (possibleOwnerNode == null) {
        // Scenario (D)
        throw new HtmlInserted(
              Point.inElement(parentElement, (ContentNode) null),
              Point.start(filteredHtml, parentNodelet)
            );
      }

      ContentTextNode possibleOwner;
      try {
        possibleOwner = (ContentTextNode) possibleOwnerNode;
      } catch (ClassCastException e) {
        if (possibleOwnerNode.isImplAttached()) {
          // Scenario (C)
          throw new HtmlInserted(
                Point.inElement(parentElement, possibleOwnerNode),
                Point.inElementReverse(filteredHtml, parentNodelet, nodeletBeforeTextNodes)
              );
        } else {
          // Scenario (A)
          // Not minor, an element has gone missing
          throw new HtmlMissing(possibleOwnerNode, parentNodelet);
        }
      }

      ContentNode nextNode = renderedContent.getNextSibling(possibleOwner);
      if (nextNode != null && !nextNode.isImplAttached()) {
        // Scenario (E)
        throw new HtmlMissing(nextNode, parentNodelet);
      }

      if (current != possibleOwner.getImplNodelet()) {
        // Scenario (B)
        if (attemptRepair) {
          possibleOwner.setTextNodelet(current);
          return nullifyIfWrongDocument(possibleOwner);
        } else {
          // TODO(danilatos): Ensure repairs handle nodes on either
          // side, as this is kind of a "replace" error
          throw new HtmlInserted(
              Point.inElement(parentElement, possibleOwner),
              Point.inElement(parentNodelet, current));
        }
      }

      Node nextNodelet = nextNode == null ? null : nextNode.getImplNodelet();

      while (current != nextNodelet && current != null) {
        // TODO(danilatos): Fix up every where in the code to use .equals
        // for GWT DOM.
        if (current == target) {
View Full Code Here

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

        DocHelper.transparentSlice(location, cxt),
        cxt.annotatableContent(), cxt.textNodeOrganiser());

    // NOTE(danilatos): Needed as a workaround to bug 2152316
    ContentElement container = point.getContainer().asElement();
    ContentNode nodeAfter = point.getNodeAfter();
    if (nodeAfter != null) {
      container = nodeAfter.getParentElement();
    }
    ////

    wrapper = cxt.annotatableContent().transparentCreate(
        WRAPPER_TAGNAME, Collections.<String, String>emptyMap(),
View Full Code Here

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

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

        // 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

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

    }

    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

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

  }

  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

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

    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

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

  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
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.