harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r565677 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/text/html/parser/Lexer.java test/api/java.injected/javax/swing/text/html/HTMLDocument_Reader_ActionsTest.java
Date Tue, 14 Aug 2007 09:41:43 GMT
Author: apetrenko
Date: Tue Aug 14 02:41:41 2007
New Revision: 565677

URL: http://svn.apache.org/viewvc?view=rev&rev=565677
Log:
Patch for HARMONY-4615 "[classlib][swing] HTML tags inside tag <pre> are handled incorrectly"

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Lexer.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLDocument_Reader_ActionsTest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Lexer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Lexer.java?view=diff&rev=565677&r1=565676&r2=565677
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Lexer.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/html/parser/Lexer.java
Tue Aug 14 02:41:41 2007
@@ -381,6 +381,8 @@
 	private int offsetCDATA=0;
 	
 	private LexerTextStateType textState = LexerTextStateType.DEFAULT;
+	
+	private int preEntryCounter;
 
 	/**
 	 * Decsribes whether a piece of text (no white space) was parsed.
@@ -635,7 +637,7 @@
 		textParsed = false;
 		terminatorSkipped = false;
 		lastWasLineTerminator = false;
-		textState = LexerTextStateType.DEFAULT;
+		
 		return textToken;
 	}
 
@@ -792,7 +794,13 @@
    * @param newState the new lexical state
    */
   public final void yybegin(int newState) {
-    zzLexicalState = newState;
+      if ((newState == ENDTAG) && isPreformatted(yytext().substring(2))) {
+          preEntryCounter --;
+          textState = (preEntryCounter == 0) ? LexerTextStateType.DEFAULT : 
+              LexerTextStateType.PREFORMATTED;
+      }
+      
+      zzLexicalState = newState;
   }
 
 
@@ -1451,6 +1459,7 @@
 			yybegin(TAG_IGNORE_ATTS);
 		} else {
 			if (isPreformatted(tagName)) {
+			    preEntryCounter ++;
 				textState = LexerTextStateType.PREFORMATTED;
 			}
 			currentCDATAClosingTag = null;

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLDocument_Reader_ActionsTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLDocument_Reader_ActionsTest.java?view=diff&rev=565677&r1=565676&r2=565677
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLDocument_Reader_ActionsTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/html/HTMLDocument_Reader_ActionsTest.java
Tue Aug 14 02:41:41 2007
@@ -582,6 +582,19 @@
         assertEquals(13, pre.getElement(1).getEndOffset());
     }
     
+    public void testHarmony_4615() throws Exception {
+        final HTMLDocument doc = new HTMLDocument();
+
+        new HTMLEditorKit().read(new StringReader("<html><body><pre>line1\n"
//$NON-NLS-1$
+                + "<font color='red'>line2 \n line3</font>" //$NON-NLS-1$
+                + "line3</pre>line4 \n line4</body></html>"), doc, 0);
//$NON-NLS-1$
+
+        assertEquals("line1\n", doc.getText(1, 6)); //$NON-NLS-1$
+        assertEquals("line2 \n line3", doc.getText(7, 13)); //$NON-NLS-1$
+        assertEquals("line3", doc.getText(20, 5)); //$NON-NLS-1$
+        assertEquals("line4 line4", doc.getText(26, 11)); //$NON-NLS-1$
+    }
+    
     public void testTag_ContentWhitespaces() {
         SimpleAttributeSet attr = new SimpleAttributeSet();
         attr.addAttribute("aaaa", "bbbb");



Mime
View raw message