Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8358667

HTMLDocument.getIterator() Returns Null for Block-Level Elements

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      The HTMLDocument.getIterator(HTML.Tag) method contains incomplete implementation for block-level elements. When called with any block-level tag (where tag.isBlock() returns true), the method immediately returns null due to a "TBD" (To Be Done) comment in the source code, rather than providing the expected iterator functionality.

          public Iterator getIterator(HTML.Tag t) {
              if (t.isBlock()) {
                  // TBD
                  return null;
              }
              return new LeafIterator(t, this);
          }


      ---------- BEGIN SOURCE ----------
      import javax.swing.JTextPane;
      import javax.swing.text.html.HTML;
      import javax.swing.text.html.HTMLDocument;

      public class IteratorTest {
          private static JTextPane editor;

          public static void main(String[] args) {
              editor = new JTextPane();
              editor.setContentType("text/html");
              HTMLDocument doc = (HTMLDocument) editor.getDocument();
              HTMLDocument.Iterator bodyIt = doc.getIterator(HTML.Tag.BODY);
              if (bodyIt == null) {
                  throw new RuntimeException("Test Failed: Iterator for BODY tag is null");
              }
          }
      }

      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: