jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java
changeset 21278 ef8a3a2a72f2
parent 21244 7c2ac5ca05a2
child 21982 fd6e5fe509df
equal deleted inserted replaced
21277:bd380b80f9ea 21278:ef8a3a2a72f2
  1009      * <p>Parameter <code>elem</code> must not be a leaf element,
  1009      * <p>Parameter <code>elem</code> must not be a leaf element,
  1010      * otherwise an <code>IllegalArgumentException</code> is thrown.
  1010      * otherwise an <code>IllegalArgumentException</code> is thrown.
  1011      * If either <code>elem</code> or <code>htmlText</code> parameter
  1011      * If either <code>elem</code> or <code>htmlText</code> parameter
  1012      * is <code>null</code>, no changes are made to the document.</p>
  1012      * is <code>null</code>, no changes are made to the document.</p>
  1013      *
  1013      *
  1014      * <p>For this to work correcty, the document must have an
  1014      * <p>For this to work correctly, the document must have an
  1015      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1015      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1016      * if the document was created from an HTMLEditorKit via the
  1016      * if the document was created from an HTMLEditorKit via the
  1017      * <code>createDefaultDocument</code> method.</p>
  1017      * <code>createDefaultDocument</code> method.</p>
  1018      *
  1018      *
  1019      * @param elem the branch element whose children will be replaced
  1019      * @param elem the branch element whose children will be replaced
  1051      *
  1051      *
  1052      * <p>When replacing a leaf this will attempt to make sure there is
  1052      * <p>When replacing a leaf this will attempt to make sure there is
  1053      * a newline present if one is needed. This may result in an additional
  1053      * a newline present if one is needed. This may result in an additional
  1054      * element being inserted. Consider, if you were to replace a character
  1054      * element being inserted. Consider, if you were to replace a character
  1055      * element that contained a newline with &lt;img&gt; this would create
  1055      * element that contained a newline with &lt;img&gt; this would create
  1056      * two elements, one for the image, ane one for the newline.</p>
  1056      * two elements, one for the image, and one for the newline.</p>
  1057      *
  1057      *
  1058      * <p>If you try to replace the element at length you will most
  1058      * <p>If you try to replace the element at length you will most
  1059      * likely end up with two elements, eg
  1059      * likely end up with two elements, eg
  1060      * <code>setOuterHTML(getCharacterElement (getLength()),
  1060      * <code>setOuterHTML(getCharacterElement (getLength()),
  1061      * "blah")</code> will result in two leaf elements at the end, one
  1061      * "blah")</code> will result in two leaf elements at the end, one
  1087      *
  1087      *
  1088      * <p>If either <code>elem</code> or <code>htmlText</code>
  1088      * <p>If either <code>elem</code> or <code>htmlText</code>
  1089      * parameter is <code>null</code>, no changes are made to the
  1089      * parameter is <code>null</code>, no changes are made to the
  1090      * document.</p>
  1090      * document.</p>
  1091      *
  1091      *
  1092      * <p>For this to work correcty, the document must have an
  1092      * <p>For this to work correctly, the document must have an
  1093      * HTMLEditorKit.Parser set. This will be the case if the document
  1093      * HTMLEditorKit.Parser set. This will be the case if the document
  1094      * was created from an HTMLEditorKit via the
  1094      * was created from an HTMLEditorKit via the
  1095      * <code>createDefaultDocument</code> method.</p>
  1095      * <code>createDefaultDocument</code> method.</p>
  1096      *
  1096      *
  1097      * @param elem the element to replace
  1097      * @param elem the element to replace
  1164      * <p>Parameter <code>elem</code> must not be a leaf element,
  1164      * <p>Parameter <code>elem</code> must not be a leaf element,
  1165      * otherwise an <code>IllegalArgumentException</code> is thrown.
  1165      * otherwise an <code>IllegalArgumentException</code> is thrown.
  1166      * If either <code>elem</code> or <code>htmlText</code> parameter
  1166      * If either <code>elem</code> or <code>htmlText</code> parameter
  1167      * is <code>null</code>, no changes are made to the document.</p>
  1167      * is <code>null</code>, no changes are made to the document.</p>
  1168      *
  1168      *
  1169      * <p>For this to work correcty, the document must have an
  1169      * <p>For this to work correctly, the document must have an
  1170      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1170      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1171      * if the document was created from an HTMLEditorKit via the
  1171      * if the document was created from an HTMLEditorKit via the
  1172      * <code>createDefaultDocument</code> method.</p>
  1172      * <code>createDefaultDocument</code> method.</p>
  1173      *
  1173      *
  1174      * @param elem the branch element to be the root for the new text
  1174      * @param elem the branch element to be the root for the new text
  1234      * <p>Parameter <code>elem</code> must not be a leaf element,
  1234      * <p>Parameter <code>elem</code> must not be a leaf element,
  1235      * otherwise an <code>IllegalArgumentException</code> is thrown.
  1235      * otherwise an <code>IllegalArgumentException</code> is thrown.
  1236      * If either <code>elem</code> or <code>htmlText</code> parameter
  1236      * If either <code>elem</code> or <code>htmlText</code> parameter
  1237      * is <code>null</code>, no changes are made to the document.</p>
  1237      * is <code>null</code>, no changes are made to the document.</p>
  1238      *
  1238      *
  1239      * <p>For this to work correcty, the document must have an
  1239      * <p>For this to work correctly, the document must have an
  1240      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1240      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1241      * if the document was created from an HTMLEditorKit via the
  1241      * if the document was created from an HTMLEditorKit via the
  1242      * <code>createDefaultDocument</code> method.</p>
  1242      * <code>createDefaultDocument</code> method.</p>
  1243      *
  1243      *
  1244      * @param elem the element to be the root for the new text
  1244      * @param elem the element to be the root for the new text
  1298      *
  1298      *
  1299      * <p>If either <code>elem</code> or <code>htmlText</code>
  1299      * <p>If either <code>elem</code> or <code>htmlText</code>
  1300      * parameter is <code>null</code>, no changes are made to the
  1300      * parameter is <code>null</code>, no changes are made to the
  1301      * document.</p>
  1301      * document.</p>
  1302      *
  1302      *
  1303      * <p>For this to work correcty, the document must have an
  1303      * <p>For this to work correctly, the document must have an
  1304      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1304      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1305      * if the document was created from an HTMLEditorKit via the
  1305      * if the document was created from an HTMLEditorKit via the
  1306      * <code>createDefaultDocument</code> method.</p>
  1306      * <code>createDefaultDocument</code> method.</p>
  1307      *
  1307      *
  1308      * @param elem the element the content is inserted before
  1308      * @param elem the element the content is inserted before
  1356      *
  1356      *
  1357      * <p>If either <code>elem</code> or <code>htmlText</code>
  1357      * <p>If either <code>elem</code> or <code>htmlText</code>
  1358      * parameter is <code>null</code>, no changes are made to the
  1358      * parameter is <code>null</code>, no changes are made to the
  1359      * document.</p>
  1359      * document.</p>
  1360      *
  1360      *
  1361      * <p>For this to work correcty, the document must have an
  1361      * <p>For this to work correctly, the document must have an
  1362      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1362      * <code>HTMLEditorKit.Parser</code> set. This will be the case
  1363      * if the document was created from an HTMLEditorKit via the
  1363      * if the document was created from an HTMLEditorKit via the
  1364      * <code>createDefaultDocument</code> method.</p>
  1364      * <code>createDefaultDocument</code> method.</p>
  1365      *
  1365      *
  1366      * @param elem the element the content is inserted after
  1366      * @param elem the element the content is inserted after
  3342             public void start(HTML.Tag t, MutableAttributeSet attr) {
  3342             public void start(HTML.Tag t, MutableAttributeSet attr) {
  3343                 if (t == HTML.Tag.INPUT) {
  3343                 if (t == HTML.Tag.INPUT) {
  3344                     String type = (String)
  3344                     String type = (String)
  3345                         attr.getAttribute(HTML.Attribute.TYPE);
  3345                         attr.getAttribute(HTML.Attribute.TYPE);
  3346                     /*
  3346                     /*
  3347                      * if type is not defined teh default is
  3347                      * if type is not defined the default is
  3348                      * assumed to be text.
  3348                      * assumed to be text.
  3349                      */
  3349                      */
  3350                     if (type == null) {
  3350                     if (type == null) {
  3351                         type = "text";
  3351                         type = "text";
  3352                         attr.addAttribute(HTML.Attribute.TYPE, "text");
  3352                         attr.addAttribute(HTML.Attribute.TYPE, "text");
  3732          */
  3732          */
  3733         private void adjustEndSpecsForPartialInsert() {
  3733         private void adjustEndSpecsForPartialInsert() {
  3734             int size = parseBuffer.size();
  3734             int size = parseBuffer.size();
  3735             if (insertTagDepthDelta < 0) {
  3735             if (insertTagDepthDelta < 0) {
  3736                 // When inserting via an insertTag, the depths (of the tree
  3736                 // When inserting via an insertTag, the depths (of the tree
  3737                 // being read in, and existing hiearchy) may not match up.
  3737                 // being read in, and existing hierarchy) may not match up.
  3738                 // This attemps to clean it up.
  3738                 // This attemps to clean it up.
  3739                 int removeCounter = insertTagDepthDelta;
  3739                 int removeCounter = insertTagDepthDelta;
  3740                 while (removeCounter < 0 && size >= 0 &&
  3740                 while (removeCounter < 0 && size >= 0 &&
  3741                         parseBuffer.elementAt(size - 1).
  3741                         parseBuffer.elementAt(size - 1).
  3742                        getType() == ElementSpec.EndTagType) {
  3742                        getType() == ElementSpec.EndTagType) {
  3971          * This is set to true when and end is invoked for <html>.
  3971          * This is set to true when and end is invoked for <html>.
  3972          */
  3972          */
  3973         private boolean receivedEndHTML;
  3973         private boolean receivedEndHTML;
  3974         /** Number of times <code>flushBuffer</code> has been invoked. */
  3974         /** Number of times <code>flushBuffer</code> has been invoked. */
  3975         private int flushCount;
  3975         private int flushCount;
  3976         /** If true, behavior is similiar to insertTag, but instead of
  3976         /** If true, behavior is similar to insertTag, but instead of
  3977          * waiting for insertTag will wait for first Element without
  3977          * waiting for insertTag will wait for first Element without
  3978          * an 'implied' attribute and begin inserting then. */
  3978          * an 'implied' attribute and begin inserting then. */
  3979         private boolean insertAfterImplied;
  3979         private boolean insertAfterImplied;
  3980         /** This is only used if insertAfterImplied is true. If false, only
  3980         /** This is only used if insertAfterImplied is true. If false, only
  3981          * inserting content, and there is a trailing newline it is removed. */
  3981          * inserting content, and there is a trailing newline it is removed. */