Package com.google.gwt.dom.client

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


        caret = Point.inText(caret.getNodeAfter(), 0);
      } else {
        throw new RuntimeException("Unimplemented/Invalid");
      }
    }
    Text nodelet = caret.getContainer().cast();
    int offset = caret.getTextOffset() + distance;
    while (offset < 0) {
      nodelet = htmlView.getPreviousSibling(nodelet).cast();
      if (nodelet == null || !DomHelper.isTextNode(nodelet)) {
        throw new RuntimeException("Action ran off end of text node");
      }
      offset += nodelet.getLength();
    }
    while (offset > nodelet.getLength()) {
      offset -= nodelet.getLength();
      nodelet = htmlView.getPreviousSibling(nodelet).cast();
      if (nodelet == null || !DomHelper.isTextNode(nodelet)) {
        throw new RuntimeException("Action ran off end of text node");
      }
    }
View Full Code Here


   */
  public void somethingHappened(Point<Node> previousSelectionStart)
      throws HtmlMissing, HtmlInserted {
    Preconditions.checkNotNull(previousSelectionStart,
        "Typing extractor notified with null selection");
    Text node = previousSelectionStart.isInTextNode()
      ? previousSelectionStart.getContainer().<Text>cast()
      : null;

    // Attempt to associate our location with a node
    // This should be a last resort, ideally we should be given selections
    // in the correct text node, when the selection is at a text node boundary
    if (node == null) {
      HtmlView filteredHtml = filteredHtmlView;
      Node nodeBefore = Point.nodeBefore(filteredHtml, previousSelectionStart.asElementPoint());
      Node nodeAfter = previousSelectionStart.getNodeAfter();
      //TODO(danilatos): Usually we would want nodeBefore as a preference, but
      // not always...
      if (nodeBefore != null && DomHelper.isTextNode(nodeBefore)) {
        node = nodeBefore.cast();
        previousSelectionStart = Point.<Node>inText(node, 0);
      } else if (nodeAfter != null && DomHelper.isTextNode(nodeAfter)) {
        node = nodeAfter.cast();
        previousSelectionStart = Point.<Node>inText(node, node.getLength());
      }
    }

    TypingState t = findTypingState(previousSelectionStart);

View Full Code Here

    private boolean isPartOfThisState(Point<Node> point) {

      checkRangeIsValid();

      Text node = point.isInTextNode()
        ? point.getContainer().<Text>cast()
        : null;

      if (node == null) {
        // If we're not in a text node - i.e. we just started typing
View Full Code Here

     *   for text nodes, instead we'll assume they're new and part of this
     *   typing sequence.
     */
    private void startTypingSequence(Point.Tx<Node> previousSelectionStart)
        throws HtmlMissing, HtmlInserted {
      Text node = previousSelectionStart.getContainer().cast();
      ContentView renderedContent = renderedContentView;
      HtmlView filteredHtml = filteredHtmlView;
      try {
        // This might throw an exception
        ContentTextNode wrapper = manager.findTextWrapper(node, true);
View Full Code Here

        // Is this method slow? we need it often enough, but not in 95% of scenarios,
        // so there is room to optimise.

        // See if there are other text nodes we should check
        Text selNode = previousSelectionStart.getContainer().cast();
        int selOffset = previousSelectionStart.getTextOffset();

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

    /**
     * @return The current value of the text in the html, within our tracked range
     */
    private String calculateNewValue() {
      HtmlView filteredHtml = filteredHtmlView;
      Text fromIncl = htmlRange.getStartNode(filteredHtml).cast();
      Node toExcl = htmlRange.getPointAfter().getNodeAfter();

      return ContentTextNode.sumTextNodes(fromIncl, toExcl, filteredHtml);
    }
View Full Code Here

      assert firstWrapper != null;

      if (partOfMutatingRange(point.getContainer())) {
        // TODO(danilatos): check for mutatingNodeOwns duplicates a loop which
        // is done in getOffset
        Text toFind = point.getContainer().<Text>cast();
        HtmlView filteredHtml = filteredHtmlView;

        return ContentTextNode.getOffset(
            toFind,
            htmlRange.getStartNode(filteredHtml).<Text>cast(),
View Full Code Here

    // If it's inserting text
    if (DomHelper.isTextNode(signal.getTarget()) &&
        (signal.getType().equals(BrowserEvents.DOMCharacterDataModified) ||
         signal.getType().equals(BrowserEvents.DOMNodeInserted))) {

      Text textNode = signal.getTarget().cast();
      if (textNode.getLength() > 0) {
        Node e = textNode.getPreviousSibling();
        if (e != null && !DomHelper.isTextNode(e)
            && e.<Element>cast().getTagName().toLowerCase().equals("a")) {

          FocusedPointRange<Node> selection =  editorInteractor.getHtmlSelection();
          if (selection.isCollapsed() && selection.getFocus().getTextOffset() == 0) {
View Full Code Here

    if (node == null) {
      logEndNotFound("node is null");
      return;
    }
    if (DomHelper.isTextNode(node)) {
      Text textNode = node.cast();
      String text = textNode.getData();
      if (!text.isEmpty()) {
        if (leading) {
          if (text.charAt(0) == MARKER_CHAR) {
            textNode.setData(text.substring(1));
          }
        } else {
          if (text.charAt(text.length() - 1) == MARKER_CHAR) {
            textNode.setData(text.substring(0, text.length() - 1));
          } else {
            logEndNotFound("last character is not marker");
          }
        }
      } else {
        logEndNotFound("text node is empty");
      }
      if (textNode.getData().isEmpty()) {
        parent.removeChild(textNode);
      }
    } else {
      // In some cases, Safari will put the marker inside of a div, so this
      // traverses down the left or right side of the tree to find it.
View Full Code Here

    // the span with the metadata may get discarded.
    SpanElement trailingSpan = Document.get().createSpanElement();
    trailingSpan.setInnerHTML("&nbsp;");

    if (origEnd.isInTextNode()) {
      Text t = (Text) origEnd.getContainer();
      t.setData(t.getData().substring(0, origEnd.getTextOffset()));
      origEnd.getContainer().getParentElement().insertAfter(spanForXml, t);
      origEnd.getContainer().getParentElement().insertAfter(trailingSpan, spanForXml);
    } else {
      origEnd.getContainer().insertAfter(spanForXml, origEnd.getNodeAfter());
      origEnd.getContainer().insertAfter(trailingSpan, spanForXml);
View Full Code Here

TOP

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

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.