Java Code Examples for com.google.gwt.dom.client.Element#getLastChild()

The following examples show how to use com.google.gwt.dom.client.Element#getLastChild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParagraphHelperBr.java    From swellrt with Apache License 2.0 6 votes vote down vote up
/**
 * Get the spacer for the given paragraph.
 * Lazily creates & registers one if not present.
 * If there's one that the browser created, registers it as our own.
 * If the browser put a different one in to the one that we were already
 * using, replace ours with the browser's.
 * @param paragraph
 * @return The spacer
 */
protected BRElement getSpacer(Element paragraph) {
  Node last = paragraph.getLastChild();
  BRElement spacer = paragraph.getPropertyJSO(BR_REF).cast();
  if (spacer == null) {
    // Register our spacer, using one the browser put in if present
    spacer = isSpacer(last) ? last.<BRElement>cast() : Document.get().createBRElement();
    setupSpacer(paragraph, spacer);
  } else if (isSpacer(last) && last != spacer) {
    // The browser put a different one in by itself, so let's use that one
    if (spacer.hasParentElement()) {
      spacer.removeFromParent();
    }
    spacer = last.<BRElement>cast();
    setupSpacer(paragraph, spacer);
  }
  return spacer;
}
 
Example 2
Source File: ParagraphHelperBr.java    From incubator-retired-wave with Apache License 2.0 6 votes vote down vote up
/**
 * Get the spacer for the given paragraph.
 * Lazily creates & registers one if not present.
 * If there's one that the browser created, registers it as our own.
 * If the browser put a different one in to the one that we were already
 * using, replace ours with the browser's.
 * @param paragraph
 * @return The spacer
 */
protected BRElement getSpacer(Element paragraph) {
  Node last = paragraph.getLastChild();
  BRElement spacer = paragraph.getPropertyJSO(BR_REF).cast();
  if (spacer == null) {
    // Register our spacer, using one the browser put in if present
    spacer = isSpacer(last) ? last.<BRElement>cast() : Document.get().createBRElement();
    setupSpacer(paragraph, spacer);
  } else if (isSpacer(last) && last != spacer) {
    // The browser put a different one in by itself, so let's use that one
    if (spacer.hasParentElement()) {
      spacer.removeFromParent();
    }
    spacer = last.<BRElement>cast();
    setupSpacer(paragraph, spacer);
  }
  return spacer;
}
 
Example 3
Source File: ParagraphHelperWebkit.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private void ensureSpacerIfDoesntEndWithText(Element paragraph) {
  Node last = paragraph.getLastChild();
  BRElement spacer = getSpacer(paragraph);
  if (last == spacer) {
    last = last.getPreviousSibling();
  }
  if (last == null || DomHelper.isElement(last)) {
    paragraph.appendChild(spacer);
  } else {
    spacer.removeFromParent();
  }
}
 
Example 4
Source File: ParagraphHelperWebkit.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private void ensureSpacerIfDoesntEndWithText(Element paragraph) {
  Node last = paragraph.getLastChild();
  BRElement spacer = getSpacer(paragraph);
  if (last == spacer) {
    last = last.getPreviousSibling();
  }
  if (last == null || DomHelper.isElement(last)) {
    paragraph.appendChild(spacer);
  } else {
    spacer.removeFromParent();
  }
}
 
Example 5
Source File: ParagraphHelperBr.java    From swellrt with Apache License 2.0 4 votes vote down vote up
@Override
public Node getEndingNodelet(Element paragraph) {
  Node maybeSpacer = paragraph.getLastChild();
  return isSpacer(maybeSpacer) ? maybeSpacer : null;
}
 
Example 6
Source File: ParagraphHelperBr.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
@Override
public Node getEndingNodelet(Element paragraph) {
  Node maybeSpacer = paragraph.getLastChild();
  return isSpacer(maybeSpacer) ? maybeSpacer : null;
}