public static String computePrintedText(RenderBox renderBox) {
    StringBuilder b = new StringBuilder();
    RenderNode lineChild = renderBox.getFirstChild();

    while (lineChild != null) {
      if (lineChild instanceof RenderableText) {
        RenderableText text = (RenderableText) lineChild;
        b.append(text.getRawText());
      } else if (lineChild instanceof SpacerRenderNode) {
        SpacerRenderNode spacer = (SpacerRenderNode) lineChild;
        for (int i = 0; i < spacer.getSpaceCount(); i += 1) b.append(' ');
      } else if (lineChild instanceof RenderBox) {
        b.append(computePrintedText((RenderBox) lineChild));
      }

      lineChild = lineChild.getNext();
    }
    return b.toString();
  }
 private void debugPrintText(final RenderNode[] elementsByNodeType) {
   for (int i = 0; i < elementsByNodeType.length; i++) {
     final RenderableText renderNode = (RenderableText) elementsByNodeType[i];
     DebugLog.log(renderNode.getRawText());
   }
 }