Re: [cp-patches] HTMLWriter
Hi Roman, Can you commit this patch after you fix p-implied? This patch removes all the CP specific sections. Thanks! David Fu. Hi David, Thanks for checking the file in! The IMPLIED tag in the RI is implemented as a p-implied Tag with a NameAttribute of HTML.Tag.IMPLIED. GNU CP implements it as a p Tag with a NameAttribute of HTML.Tag.P, with a tag attribute of _implied_=true. We should fix that. It sounds easy enough. The other difference is that since the RI is using HTML.Tag.IMPLIED, it is recognized as a Synthetic Tag. Whereas the implementation of CP using HTML.Tag.P is not recognized as a Synthetic Tag. Indeed. Yeah, it would be great if GNU CP can finally claim to be Mauve 1.4 Wink Wink compatitble(MDK 1.4 perhaps?)! Yeah. We actually have almost everything there. The few missing pieces seem to be quite rarely used, maybe with the exception of the html package. Which is beeing worked on. It will be able to statisfy many application developers(me included) enough to give CP a try. I will probably to hop over to the IRC this weekend ;) I'll be around! Cheers, Roman --- /home/work/classpath_work/classpath/javax/swing/text/html/HTMLWriter.java 2006-10-31 20:30:24.0 +0900 +++ /home/work/classpath_work/my_work/src/javax/swing/text/html/HTMLWriter.java 2006-11-10 11:20:52.0 +0900 @@ -608,28 +608,8 @@ closeOutUnwantedEmbeddedTags(attrSet); -// NOTE: 20061030 - fchoong - GNU CP uses a different implimentation of -// the IMPLIED tag. -boolean fg_gnu_cp_implied_tag = false; - -if (matchNameAttribute(attrSet, HTML.Tag.P)) - { -//writeAllAttributes(attrSet); - -Enumeration attrNameEnum = attrSet.getAttributeNames(); - -while (attrNameEnum.hasMoreElements()) - { -Object key = attrNameEnum.nextElement(); -Object value = attrSet.getAttribute(key); - -if (key.equals(_implied_) value.toString().equals(true)) - fg_gnu_cp_implied_tag = true; - } // while(attrNameEnum.hasMoreElements()) - } // if(matchNameAttribute(attrSet, HTML.Tag.P)) - // handle the tag -if (synthesizedElement(paramElem) || fg_gnu_cp_implied_tag) +if (synthesizedElement(paramElem)) { if (matchNameAttribute(attrSet, HTML.Tag.CONTENT)) { @@ -640,8 +620,7 @@ { comment(currElem); } // else if(matchNameAttribute(attrSet, HTML.Tag.COMMENT)) -else if (matchNameAttribute(attrSet, HTML.Tag.IMPLIED) - || fg_gnu_cp_implied_tag) // NOTE: GNU CP specific +else if (matchNameAttribute(attrSet, HTML.Tag.IMPLIED)) { int child_elem_count = currElem.getElementCount(); @@ -782,28 +761,8 @@ if (fg_is_fragment_parent_elem || (fg_pass_start_elem fg_pass_end_elem == false) || fg_is_start_and_end_elem) { - // NOTE: 20061030 - fchoong - GNU CP uses a different implimentation of - // the IMPLIED tag. - boolean fg_gnu_cp_implied_tag = false; - - if (matchNameAttribute(attrSet, HTML.Tag.P)) -{ - //writeAllAttributes(attrSet); - - Enumeration attrNameEnum = attrSet.getAttributeNames(); - - while (attrNameEnum.hasMoreElements()) -{ - Object key = attrNameEnum.nextElement(); - Object value = attrSet.getAttribute(key); - - if (key.equals(_implied_) value.toString().equals(true)) -fg_gnu_cp_implied_tag = true; -} // while(attrNameEnum.hasMoreElements()) -} // if(matchNameAttribute(attrSet, HTML.Tag.P)) - // handle the tag - if (synthesizedElement(paramElem) || fg_gnu_cp_implied_tag) + if (synthesizedElement(paramElem)) { if (matchNameAttribute(attrSet, HTML.Tag.CONTENT)) { @@ -862,8 +821,7 @@ { comment(currElem); } // else if(matchNameAttribute(attrSet, HTML.Tag.COMMENT)) - else if (matchNameAttribute(attrSet, HTML.Tag.IMPLIED) -|| fg_gnu_cp_implied_tag) // NOTE: GNU CP specific + else if (matchNameAttribute(attrSet, HTML.Tag.IMPLIED)) { int child_elem_count = currElem.getElementCount();
[cp-patches] FYI: HTML table rendering
This adds support for relative column widths (percent width attribute values) for HTML tables. It also fixes a whole bunch of smaller layout problems. Many tables should now be rendered reasonable well, like the following: http://kennke.org/~roman/google2.png 2006-11-10 Roman Kennke [EMAIL PROTECTED] * javax/swing/text/ParagraphView.java (Row.getMaximumSize): Removed. This method is not necessary. * javax/swing/text/html/TableView.java (CellView): Moved attribute init to setPropertiesFromAttributes(). (setPropertiesFromAttributes): Fetch attributes here. (RowView.RowView): Documented. (RowView.getMaximumSpan): Overridden to restrict the max span in the Y direction. (RowView.layoutMajorAxis): Correctly layout the spans. (columnWidths): New field. Stores the width attributes of the columns. (calculateColumnRequirements): Added support for relative (== percent) width attributes. (calculateMajorAxisRequirements): Removed. (calculateMinorAxisRequirements): Removed unnecessary code. (getMaximumSpan): Overridden to restrict the table's width. (layoutColumns): Documented. Implement more clever table layout, i.e. for relative columns etc. (layoutMinorAxis): Don't mark rows invalid. (updateGrid): Added docs. Initialize column widths. Cheers, Roman Index: javax/swing/text/ParagraphView.java === RCS file: /cvsroot/classpath/classpath/javax/swing/text/ParagraphView.java,v retrieving revision 1.13 diff -u -1 -5 -r1.13 ParagraphView.java --- javax/swing/text/ParagraphView.java 12 Oct 2006 15:12:56 - 1.13 +++ javax/swing/text/ParagraphView.java 10 Nov 2006 14:46:28 - @@ -26,30 +26,33 @@ As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package javax.swing.text; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Rectangle; import java.awt.Shape; import javax.swing.SizeRequirements; import javax.swing.event.DocumentEvent; /** * A [EMAIL PROTECTED] FlowView} that flows it's children horizontally and boxes the rows * vertically. * * @author Roman Kennke ([EMAIL PROTECTED]) */ public class ParagraphView extends FlowView implements TabExpander { /** * A specialized horizontal codeBoxView/code that represents exactly @@ -92,43 +95,30 @@ break; case StyleConstants.ALIGN_CENTER: case StyleConstants.ALIGN_JUSTIFIED: align = 0.5F; break; case StyleConstants.ALIGN_LEFT: default: align = 0.0F; } else align = super.getAlignment(axis); return align; } /** - * Allows rows to span the whole parent view. - */ -public float getMaximumSpan(int axis) -{ - float max; - if (axis == X_AXIS) -max = Float.MAX_VALUE; - else -max = super.getMaximumSpan(axis); - return max; -} - -/** * Overridden because child views are not necessarily laid out in model * order. */ protected int getViewIndexAtPosition(int pos) { int index = -1; if (pos = getStartOffset() pos getEndOffset()) { int nviews = getViewCount(); for (int i = 0; i nviews index == -1; i++) { View child = getView(i); if (pos = child.getStartOffset() pos child.getEndOffset()) index = i; } Index: javax/swing/text/html/TableView.java === RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/TableView.java,v retrieving revision 1.3 diff -u -1 -5 -r1.3 TableView.java --- javax/swing/text/html/TableView.java 8 Nov 2006 11:09:31 - 1.3 +++ javax/swing/text/html/TableView.java 10 Nov 2006 14:46:28 - @@ -51,115 +51,143 @@ /** * A view implementation that renders HTML tables. * * This is basically a vertical BoxView that contains the rows of the table * and the rows are horizontal BoxViews that contain the actual columns. */ class TableView extends BoxView implements ViewFactory { /** * Represents a
Re: [cp-patches] HTMLWriter
Hi Roman, I tried it just now, and your fix works with the new patch, as the implied tag is now recognized as a HTML.Tag.IMPLIED Tag! So the implied tags for CP and the RI behave the same now! David Fu. Hi David, Am Freitag, den 10.11.2006, 17:16 +0900 schrieb [EMAIL PROTECTED]: Hi Roman, Can you commit this patch after you fix p-implied? This patch removes all the CP specific sections. Thanks! Sure. Can you tell me what is different in Classpath ATM? I think I still don't understand completely. Does my HTMLDocument fix from a couple of days ago solve it by any chance? I fiddled a bit with the IMPLIED tag. /Roman
Re: [cp-patches] HTMLWriter
Hi David, I tried it just now, and your fix works with the new patch, as the implied tag is now recognized as a HTML.Tag.IMPLIED Tag! So the implied tags for CP and the RI behave the same now! Very good. I checked in your patch (attached again). 2006-11-10 David Fu [EMAIL PROTECTED] * javax/swing/text/html/HTMLWriter.java (traverse): Removed Classpath specific handling of implied tags. (traverseHtmlFragment): Removed Classpath specific handling of implied tags. /Roman Index: javax/swing/text/html/HTMLWriter.java === RCS file: /cvsroot/classpath/classpath/javax/swing/text/html/HTMLWriter.java,v retrieving revision 1.1 diff -u -1 -5 -r1.1 HTMLWriter.java --- javax/swing/text/html/HTMLWriter.java 31 Oct 2006 11:30:24 - 1.1 +++ javax/swing/text/html/HTMLWriter.java 10 Nov 2006 16:28:21 - @@ -596,64 +596,43 @@ * The main method used to traverse through the elements. * * @param paramElem element to traverse * * @throws IOException on any I/O exceptions */ private void traverse(Element paramElem) throws IOException, BadLocationException { Element currElem = paramElem; AttributeSet attrSet = currElem.getAttributes(); closeOutUnwantedEmbeddedTags(attrSet); -// NOTE: 20061030 - fchoong - GNU CP uses a different implimentation of -// the IMPLIED tag. -boolean fg_gnu_cp_implied_tag = false; - -if (matchNameAttribute(attrSet, HTML.Tag.P)) - { -//writeAllAttributes(attrSet); - -Enumeration attrNameEnum = attrSet.getAttributeNames(); - -while (attrNameEnum.hasMoreElements()) - { -Object key = attrNameEnum.nextElement(); -Object value = attrSet.getAttribute(key); - -if (key.equals(_implied_) value.toString().equals(true)) - fg_gnu_cp_implied_tag = true; - } // while(attrNameEnum.hasMoreElements()) - } // if(matchNameAttribute(attrSet, HTML.Tag.P)) - // handle the tag -if (synthesizedElement(paramElem) || fg_gnu_cp_implied_tag) +if (synthesizedElement(paramElem)) { if (matchNameAttribute(attrSet, HTML.Tag.CONTENT)) { writeEmbeddedTags(attrSet); text(currElem); } // if(matchNameAttribute(attrSet, HTML.Tag.CONTENT)) else if (matchNameAttribute(attrSet, HTML.Tag.COMMENT)) { comment(currElem); } // else if(matchNameAttribute(attrSet, HTML.Tag.COMMENT)) -else if (matchNameAttribute(attrSet, HTML.Tag.IMPLIED) - || fg_gnu_cp_implied_tag) // NOTE: GNU CP specific +else if (matchNameAttribute(attrSet, HTML.Tag.IMPLIED)) { int child_elem_count = currElem.getElementCount(); if (child_elem_count 0) { for (int i = 0; i child_elem_count; i++) { Element childElem = paramElem.getElement(i); traverse(childElem); } // for(int i = 0; i child_elem_count; i++) } // if(child_elem_count 0) } // else if(matchNameAttribute(attrSet, HTML.Tag.IMPLIED)) } // if(synthesizedElement(paramElem)) @@ -770,52 +749,32 @@ fg_is_fragment_parent_elem = true; if (paramElem == startElem) fg_pass_start_elem = true; if (paramElem == startElem paramElem == endElem) fg_is_start_and_end_elem = true; AttributeSet attrSet = currElem.getAttributes(); closeOutUnwantedEmbeddedTags(attrSet); if (fg_is_fragment_parent_elem || (fg_pass_start_elem fg_pass_end_elem == false) || fg_is_start_and_end_elem) { - // NOTE: 20061030 - fchoong - GNU CP uses a different implimentation of - // the IMPLIED tag. - boolean fg_gnu_cp_implied_tag = false; - - if (matchNameAttribute(attrSet, HTML.Tag.P)) -{ - //writeAllAttributes(attrSet); - - Enumeration attrNameEnum = attrSet.getAttributeNames(); - - while (attrNameEnum.hasMoreElements()) -{ - Object key = attrNameEnum.nextElement(); - Object value = attrSet.getAttribute(key); - - if (key.equals(_implied_) value.toString().equals(true)) -fg_gnu_cp_implied_tag = true; -} // while(attrNameEnum.hasMoreElements()) -} // if(matchNameAttribute(attrSet, HTML.Tag.P)) - // handle the tag - if (synthesizedElement(paramElem) || fg_gnu_cp_implied_tag) + if (synthesizedElement(paramElem)) { if (matchNameAttribute(attrSet, HTML.Tag.CONTENT)) { writeEmbeddedTags(attrSet); int content_offset = paramElem.getStartOffset(); int content_length = currElem.getEndOffset() - content_offset; if
[cp-patches] FYI: Collections.java - minor API doc addition
This patch (committed) adds info about null arguments to the API docs for the Collections.sort() methods: 2006-11-10 David Gilbert [EMAIL PROTECTED] * java/util/Collections.java (sort(List)): Minor API doc addition, (sort(List, Comparator)): Likewise. Regards, Dave
Re: [cp-patches] FYI: Collections.java - minor API doc addition
David Gilbert wrote: This patch (committed) adds info about null arguments to the API docs for the Collections.sort() methods: 2006-11-10 David Gilbert [EMAIL PROTECTED] * java/util/Collections.java (sort(List)): Minor API doc addition, (sort(List, Comparator)): Likewise. Regards, Dave THIS patch. Regards, Dave Index: java/util/Collections.java === RCS file: /sources/classpath/classpath/java/util/Collections.java,v retrieving revision 1.42 diff -u -r1.42 Collections.java --- java/util/Collections.java 9 Jun 2006 17:02:32 - 1.42 +++ java/util/Collections.java 10 Nov 2006 16:35:21 - @@ -1903,10 +1903,11 @@ * sorts the array, and then iterates over the list setting each element from * the array. * - * @param l the List to sort + * @param l the List to sort (codenull/code not permitted) * @throws ClassCastException if some items are not mutually comparable * @throws UnsupportedOperationException if the List is not modifiable - * @throws NullPointerException if some element is null + * @throws NullPointerException if the list is codenull/code, or contains + * some element that is codenull/code. * @see Arrays#sort(Object[]) */ public static void sort(List l) @@ -1922,13 +1923,15 @@ * sorts the array, and then iterates over the list setting each element from * the array. * - * @param l the List to sort + * @param l the List to sort (codenull/code not permitted) * @param c the Comparator specifying the ordering for the elements, or - *null for natural ordering + *codenull/code for natural ordering * @throws ClassCastException if c will not compare some pair of items * @throws UnsupportedOperationException if the List is not modifiable - * @throws NullPointerException if null is compared by natural ordering - *(only possible when c is null) + * @throws NullPointerException if the List is codenull/code or + * codenull/code is compared by natural ordering (only possible + * when c is codenull/code) + * * @see Arrays#sort(Object[], Comparator) */ public static void sort(List l, Comparator c)
[cp-patches] QName
I'd like some feedback on a change I'd like to make to a small part of the JAXP implementation. The API in question is the javax.xml.namespace.QName class, which is a common cause of developer error as its constructor uses plain Strings and you have to remember which order the arguments go in: QName(String namespaceUri, String localPart) but QName(String localPart) seems to confuse people a lot, and you often find something like new QName(foo, http://bar.com/my/namespace;) or worse, the arguments are variable names new QName(el, un) - difficult to spot and debug. The attached patch does some simple validation to ensure the consistency of its arguments at runtime. It should help to tie down exactly where a bogus QName is constructed, even if it doesn't catch every possible case. Note that it doesn't do exhaustive testing of the localPart or prefix arguments as the exact criteria depend on the version of XML the author intends. Note that this is contentious, because Sun's QName *doesn't do any validation* of its input. However, I still think it's the right thing to do, and I'm not alone: http://cafe.elharo.com/java/why-methods-should-check-their-arguments/ Anyway, see below for the patch. -- 犬 Chris Burdess They that can give up essential liberty to obtain a little safety deserve neither liberty nor safety. - Benjamin Franklin patch Description: Binary data PGP.sig Description: This is a digitally signed message part
[cp-patches] FYI: Swing text performance fix
This should significantly improve performance in Swing text components. Before we always called repaint() on _the whole component_ for each and every little insert/remove/change operation. With this fix, this is going down to the actual views which can calculate a much better repaint region. 2006-11-10 Roman Kennke [EMAIL PROTECTED] * javax/swing/text/View.java (updateLayout): Only repaint when needed. /Roman Index: javax/swing/text/View.java === RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v retrieving revision 1.37 diff -u -1 -5 -r1.37 View.java --- javax/swing/text/View.java 6 Nov 2006 16:02:54 - 1.37 +++ javax/swing/text/View.java 10 Nov 2006 20:22:40 - @@ -613,34 +613,36 @@ } /** * Updates the layout. * * @param ec the ElementChange that describes the changes to the element * @param ev the DocumentEvent that describes the changes to the model * @param shape the current allocation for this view * * @since 1.3 */ protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent ev, Shape shape) { if (ec != null shape != null) - preferenceChanged(null, true, true); -Container c = getContainer(); -if (c != null) - c.repaint(); + {System.err.println(ec: + ec); +preferenceChanged(null, true, true); +Container c = getContainer(); +if (c != null) + c.repaint(); + } } /** * Maps a position in the document into the coordinate space of the View. * The output rectangle usually reflects the font height but has a width * of zero. * * @param pos the position of the character in the model * @param a the area that is occupied by the view * @param b either [EMAIL PROTECTED] Position.Bias#Forward} or *[EMAIL PROTECTED] Position.Bias#Backward} depending on the preferred *direction bias. If codenull/code this defaults to *codePosition.Bias.Forward/code * * @return a rectangle that gives the location of the document position
RE: [cp-patches] QName
Chris Burdess wrote: I'd like some feedback on a change I'd like to make to a small part of the JAXP implementation. [...] Note that this is contentious, because Sun's QName *doesn't do any validation* of its input. However, I still think it's the right thing to do, and I'm not alone: The Sun docs explicitly say that they don't validate: The Namespace URI is not validated as a URI reference. The local part is not validated as a NCName as specified in Namespaces in XML. Besides, I don't see how you can validate an anyURI, since it can be absolute or relative. Regards, Jeroen
[cp-patches] FYI: BeanContextSupport.getChildBeanContextChild() implemented
This patch (committed) implements a missing method in the BeanContextSupport class: 2006-11-11 David Gilbert [EMAIL PROTECTED] * java/beans/beancontext/BeanContextSupport.java (getChildBeanContextChild): Implemented. I already committed a Mauve test to back this up. Regards, Dave Index: java/beans/beancontext/BeanContextSupport.java === RCS file: /sources/classpath/classpath/java/beans/beancontext/BeanContextSupport.java,v retrieving revision 1.15 diff -u -r1.15 BeanContextSupport.java --- java/beans/beancontext/BeanContextSupport.java 9 Nov 2006 17:35:55 - 1.15 +++ java/beans/beancontext/BeanContextSupport.java 11 Nov 2006 06:09:55 - @@ -478,10 +478,28 @@ return (BeanContext) beanContextChildPeer; } - protected static final BeanContextChild getChildBeanContextChild (Object child) -throws NotImplementedException + /** + * Returns the [EMAIL PROTECTED] BeanContextChild} implementation for the given child. + * + * @param child the child (codenull/code permitted). + * + * @return The bean context child. + * + * @throws IllegalArgumentException if codechild/code implements both + * the [EMAIL PROTECTED] BeanContextChild} and [EMAIL PROTECTED] BeanContextProxy} interfaces. + */ + protected static final BeanContextChild getChildBeanContextChild(Object child) { -throw new Error (Not implemented); +if (child == null) + return null; +if (child instanceof BeanContextChild child instanceof BeanContextProxy) + throw new IllegalArgumentException(Child cannot implement + + BeanContextChild and BeanContextProxy simultaneously.); +if (child instanceof BeanContextChild) + return (BeanContextChild) child; +if (child instanceof BeanContextProxy) + return ((BeanContextProxy) child).getBeanContextProxy(); +return null; } protected static final BeanContextMembershipListener getChildBeanContextMembershipListener (Object child)