當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.getParentElement方法代碼示例

本文整理匯總了Java中com.google.gwt.dom.client.Node.getParentElement方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getParentElement方法的具體用法?Java Node.getParentElement怎麽用?Java Node.getParentElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.dom.client.Node的用法示例。


在下文中一共展示了Node.getParentElement方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setOnlyChild

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
/**
 * Ensures the given container contains exactly one child, the given one.
 * Provides the important property that if the container is already the parent
 * of the given child, then the child is not removed and re-added, it is left
 * there; any siblings, if present, are removed.
 *
 * @param container
 * @param child
 */
public static void setOnlyChild(Element container, Node child) {
  if (child.getParentElement() != container) {
    // simple case
    emptyElement(container);
    container.appendChild(child);
  } else {
    // tricky case - avoid removing then re-appending the same child
    while (child.getNextSibling() != null) {
      child.getNextSibling().removeFromParent();
    }
    while (child.getPreviousSibling() != null) {
      child.getPreviousSibling().removeFromParent();
    }
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:25,代碼來源:DomHelper.java

示例2: setFocusElement

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
/**
 * Ensure that the rendered content view's DOM has focus
 *
 * NOTE(patcoleman): Fixes firefox bug that causes invalid selections while
 * mutating DOM that doesn't have focus - fixed by finding the next parent element directly
 * editable, and forcing this to have the focus.
 */
private static void setFocusElement(Node node) {
  if (UserAgent.isFirefox()) {
    // adjust to parent if node is a text node
    Element toFocus;
    if (DomHelper.isTextNode(node)) {
      toFocus = node.getParentElement();
    } else {
      toFocus = node.<Element>cast();
    }

    // traverse up until we have a concretely editable element:
    while (toFocus != null &&
        DomHelper.getContentEditability(toFocus) != ElementEditability.EDITABLE) {
      toFocus = toFocus.getParentElement();
    }
    // then focus it:
    if (toFocus != null) {
      DomHelper.focus(toFocus);
    }
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:29,代碼來源:SelectionW3CNative.java

示例3: reattachImplChildren

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
private void reattachImplChildren(Node parentNodelet, Node nodeletBefore, Node nodeletAfter,
    ContentNode first, ContentNode last) {
  // TODO(danilatos): Replace this hairy code with pre-order traversal
  // getters, once they exist
  while (true) {
    Node nodelet = nodeletBefore == null
        ? strippingView.getFirstChild(parentNodelet)
        : strippingView.getNextSibling(nodeletBefore);

    if (nodelet == null || nodelet == nodeletAfter) {
      break;
    }

    if (nodelet.getParentElement() != null) {
      nodelet.removeFromParent();
    }
  }

  for (ContentNode node = first; node != last; node = renderedView.getNextSibling(node)) {
    parentNodelet.insertBefore(node.getImplNodelet(), nodeletAfter);
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:23,代碼來源:Repairer.java

示例4: getNearestElementPosition

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
private OffsetPosition getNearestElementPosition(Node focusNode, int focusOffset) {
  Node startContainer;
  if (focusNode == null) {
    return null;
  }

  Element e =
    DomHelper.isTextNode(focusNode) ? focusNode.getParentElement() : focusNode.<Element>cast();
  return e == null ? null
      : new OffsetPosition(e.getOffsetLeft(), e.getOffsetTop(), e.getOffsetParent());
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:12,代碼來源:SelectionCoordinatesHelperW3C.java

示例5: getPosition

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
private OffsetPosition getPosition(Node focusNode, int focusOffset) {
  if (focusNode == null || focusNode.getParentElement() == null) {
    // Return null if cannot get selection, or selection is inside an
    // "unattached" node.
    return null;
  }

  if (DomHelper.isTextNode(focusNode)) {
    // We don't want to split the existing child text node, so we just add
    // duplicate the string up to the offset.
    Node txt =
        Document.get().createTextNode(
            focusNode.getNodeValue().substring(0, focusOffset));
    try {
      mutationListener.startTransientMutations();
      focusNode.getParentNode().insertBefore(txt, focusNode);
      txt.getParentNode().insertAfter(SPAN, txt);
      OffsetPosition ret =
          new OffsetPosition(SPAN.getOffsetLeft(), SPAN.getOffsetTop(), SPAN.getOffsetParent());

      return ret;
    } finally {
      SPAN.removeFromParent();
      txt.removeFromParent();
      mutationListener.endTransientMutations();
    }
  } else {
    Element e = focusNode.cast();
    return new OffsetPosition(e.getOffsetLeft(), e.getOffsetTop(), e.getOffsetParent());
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:32,代碼來源:SelectionCoordinatesHelperW3C.java

示例6: getBounds

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
private IntRange getBounds(Node node, int offset) {
  if (node == null || node.getParentElement() == null) {
    // Return null if cannot get selection, or selection is inside an
    // "unattached" node.
    return null;
  }

  if (DomHelper.isTextNode(node)) {
    Element parentElement = node.getParentElement();
    return new IntRange(parentElement.getAbsoluteTop(), parentElement.getAbsoluteBottom());
  } else {
    Element e = node.<Element>cast();
    return new IntRange(e.getAbsoluteTop(), e.getAbsoluteBottom());
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:16,代碼來源:SelectionCoordinatesHelperW3C.java

示例7: isInChildEditor

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
private boolean isInChildEditor(Point<Node> point) {
  // The editable doc is marked by an attribute EDITABLE_DOC_MARKER, if
  // an element is found with that attribute, and is not the element of this
  // editor's doc element, then it must be a child's doc element.
  Node n = point.getContainer();
  Element e = DomHelper.isTextNode(n) ? n.getParentElement() : (Element) n;
  while (e != null && e != doc) {
    if (e.hasAttribute(EditorImpl.EDITABLE_DOC_MARKER)) {
      return true;
    }
    e = e.getParentElement();
  }
  return false;
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:15,代碼來源:HtmlSelectionHelperImpl.java

示例8: getVisibleNode

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public Node getVisibleNode(Node node) {
  Node next;
  while (true) {
    next = node.getParentElement();
    if (maybeStrip(node) == false) {
      return node;
    }
    node = next;
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:13,代碼來源:StrippingHtmlView.java

示例9: elementNodeToWrapperPoint

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
private Point<ContentNode> elementNodeToWrapperPoint(Element container, Node nodeAfter)
    throws HtmlInserted, HtmlMissing {
  HtmlView filteredHtml = filteredHtmlView;
  // TODO(danilatos): Generalise/abstract this idiom
  if (filteredHtml.getVisibleNode(nodeAfter) != nodeAfter) {
    nodeAfter = filteredHtml.getNextSibling(nodeAfter);
    if (nodeAfter != null) {
      container = nodeAfter.getParentElement();
    }
  }
  return Point.inElement(findElementWrapper(container), findNodeWrapper(nodeAfter));
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:13,代碼來源:NodeManager.java

示例10: getNextOrPrevNodeDepthFirst

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
@Override
protected Node getNextOrPrevNodeDepthFirst(ReadableDomDocument<Node, Element, Text> doc,
    Node start, Node stopAt, boolean enter, boolean rightwards) {

  if (!DomHelper.isTextNode(start) && start.<Element>cast().getPropertyBoolean(
      ContentElement.COMPLEX_IMPLEMENTATION_MARKER)) {

    // If the nodelet is marked as part of a complex implementation structure
    // (e.g. a part of an image thumbnail's implementation), then we find the
    // next html node by instead popping up into the filtered content view,
    // getting the next node from there, and popping back down into html land.
    // This should be both faster and more accurate than doing a depth first
    // search through the impl dom of an arbitrarily complex doodad.

    // Go upwards to find the backreference to the doodad wrapper
    Element e = start.cast();
    while (!NodeManager.hasBackReference(e)) {
      e = e.getParentElement();
    }

    // This must be true, otherwise we could get into an infinite loop
    assert (start == stopAt || !start.isOrHasChild(stopAt));

    // Try to get a wrapper for stopAt as well.
    // TODO(danilatos): How robust is this?
    // What are the chances that it would ever fail in practice anyway?
    ContentNode stopAtWrapper = null;
    for (int tries = 1; tries <= 3; tries++) {
      try {
        stopAtWrapper = nodeManager.findNodeWrapper(stopAt);
        break;
      } catch (InconsistencyException ex) {
        stopAt = stopAt.getParentElement();
      }
    }

    // Do a depth first next-node-find in the content view
    ContentNode next = DocHelper.getNextOrPrevNodeDepthFirst(renderedContentView,
        NodeManager.getBackReference(e),
        stopAtWrapper, enter, rightwards);

    // return the impl nodelet
    return next != null ? next.getImplNodelet() : null;
  } else {

    // In other cases, just do the default.
    return super.getNextOrPrevNodeDepthFirst(doc, start, stopAt, enter, rightwards);
  }
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:50,代碼來源:ContentDocument.java

示例11: getParentElement

import com.google.gwt.dom.client.Node; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public Element getParentElement(Node node) {
  return node.getParentElement();
}
 
開發者ID:jorkey,項目名稱:Wiab.pro,代碼行數:6,代碼來源:HtmlViewImpl.java


注:本文中的com.google.gwt.dom.client.Node.getParentElement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。