Ejemplo n.º 1
0
  @Test
  public void hasChildNodes() {
    // Pre-Assert
    assertFalse("New element should not have child nodes", n.hasChildNodes());

    // Arrange
    BaseElement be = Document.get().createBaseElement();
    n.appendChild(be);

    // Act & Assert
    assertTrue("Element should have a child node", n.hasChildNodes());
  }
Ejemplo n.º 2
0
 /**
  * @param container A block level element containing the start of the given range.
  * @param range A DOM range.
  * @return true if the start of the given range is at the beginning of its block level container.
  */
 protected boolean isAtStart(Node container, Range range) {
   if (!container.hasChildNodes()) {
     return true;
   }
   if (range.getStartOffset() > 0) {
     return false;
   }
   return domUtils.getFirstLeaf(container) == domUtils.getFirstLeaf(range.getStartContainer());
 }
Ejemplo n.º 3
0
 private void getEmptyPseudo(JsNodeArray previousMatch, JsNodeArray matchingElms) {
   Node previous;
   for (int q = 0, qlen = previousMatch.size(); q < qlen; q++) {
     previous = previousMatch.getNode(q);
     if (!previous.hasChildNodes()) {
       matchingElms.addNode(previous);
     }
   }
 }
Ejemplo n.º 4
0
 /** Improves splitter visibility. */
 private void tuneSplitter() {
   NodeList<Node> nodes = splitLayoutPanel.getElement().getChildNodes();
   for (int i = 0; i < nodes.getLength(); i++) {
     Node node = nodes.getItem(i);
     if (node.hasChildNodes()) {
       com.google.gwt.dom.client.Element el = node.getFirstChild().cast();
       if ("gwt-SplitLayoutPanel-HDragger".equals(el.getClassName())) {
         tuneSplitter(el);
         return;
       }
     }
   }
 }
  /**
   * Recursively walks the tree depth first and creates a list of affected nodes.
   *
   * @param curNode the (relative) root node to start with
   */
  private void walk(Node curNode) {

    // check if we're still within the affected subtree
    // and the current node has any taggable content
    if (!this.outOfAffectedSubtree
        && ((curNode.getNodeValue() == null) || !curNode.getNodeValue().trim().isEmpty())) {

      // all text nodes gets added, in case we get into the affected subtree with this
      // node or one of its children
      if (curNode.getNodeType() == Node.TEXT_NODE) {
        affectedNodes.push(curNode);
      }

      // we check for children and go down the subtrees
      if (curNode.hasChildNodes()) {
        for (int i = 0; i < curNode.getChildCount(); i++) {
          walk(curNode.getChild(i));
        }
      }
      // if we reach the outer left node
      // we're in the affacted subtree -> all parent nodes can stay on the stack
      else if (curNode.equals(outerLeftNode)) {
        this.inAffectedSubtree = true;
      }
      // if we reach the outer right node
      // we reject all the rest of the upcoming nodes
      else if (curNode.equals(outerRightNode)) {
        this.outOfAffectedSubtree = true;
      }
      // if the current node is a text node it has already been pushed onto the stack
      // and if we're not within the affected subtree, we're removing the current node from the
      // stack
      // (not being in the affected subtree means neither the current node nor one of its
      //  children is the outer left node)
      if (!inAffectedSubtree && (curNode.getNodeType() == Node.TEXT_NODE)) {
        affectedNodes.pop();
      }
    }
  }