You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by no...@apache.org on 2012/01/25 09:21:03 UTC

svn commit: r1235672 - /pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/

Author: noelgrandin
Date: Wed Jan 25 08:21:03 2012
New Revision: 1235672

URL: http://svn.apache.org/viewvc?rev=1235672&view=rev
Log:
PIVOT-835 TextPane is unusable in 2.0.1 release
When the associated Document changes, we need to update the NodeView hierarchy
Also rename some methods to make their intent clearer.

Modified:
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBlockView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinComponentNodeView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinDocumentView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinElementView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinParagraphView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkin.java Wed Jan 25 08:21:03 2012
@@ -648,7 +648,7 @@ public class TextPaneSkin extends Contai
             this.wrapText = wrapText;
 
             if (documentView != null) {
-                documentView.invalidate();
+                documentView.invalidateUpTree();
             }
         }
     }
@@ -1165,6 +1165,10 @@ public class TextPaneSkin extends Contai
             int selectionStart = textPane.getSelectionStart();
 
             Bounds leadingSelectionBounds = getCharacterBounds(selectionStart);
+            // sanity check - this is where a lot of bugs show up
+            if (leadingSelectionBounds == null) {
+                throw new IllegalStateException("no bounds for selection " + selectionStart);
+            }
             caret = leadingSelectionBounds.toRectangle();
             caret.width = 1;
 
@@ -1236,7 +1240,7 @@ public class TextPaneSkin extends Contai
     }
 
     void invalidateNodeViewTree() {
-        this.documentView.invalidateTree();
+        this.documentView.invalidateDownTree();
         invalidateComponent();
     }
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBlockView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBlockView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBlockView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBlockView.java Wed Jan 25 08:21:03 2012
@@ -45,6 +45,6 @@ abstract class TextPaneSkinBlockView ext
 
     @Override
     public void horizontalAlignmentChanged(Block block, HorizontalAlignment previousHorizontalAlignment) {
-        invalidate();
+        invalidateUpTree();
     }
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinBulletedListView.java Wed Jan 25 08:21:03 2012
@@ -70,6 +70,6 @@ class TextPaneSkinBulletedListView exten
 
     @Override
     public void styleChanged(BulletedList bulletedList, BulletedList.Style previousStyle) {
-        invalidate();
+        invalidateUpTree();
     }
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinComponentNodeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinComponentNodeView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinComponentNodeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinComponentNodeView.java Wed Jan 25 08:21:03 2012
@@ -31,7 +31,7 @@ class TextPaneSkinComponentNodeView exte
     private final ComponentListener myComponentListener = new ComponentListener.Adapter() {
         @Override
         public void sizeChanged(Component component, int previousWidth, int previousHeight) {
-            invalidate();
+            invalidateUpTree();
         }
     };
 
@@ -143,7 +143,7 @@ class TextPaneSkinComponentNodeView exte
 
     @Override
     public void componentChanged(ComponentNode componentNode, Component previousComponent) {
-        invalidate();
+        invalidateUpTree();
 
         Component component = componentNode.getComponent();
         if (component != null) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinDocumentView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinDocumentView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinDocumentView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinDocumentView.java Wed Jan 25 08:21:03 2012
@@ -38,8 +38,8 @@ class TextPaneSkinDocumentView extends T
     }
 
     @Override
-    public void invalidate() {
-        super.invalidate();
+    public void invalidateUpTree() {
+        super.invalidateUpTree();
         textPaneSkin.invalidateComponent();
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinElementView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinElementView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinElementView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinElementView.java Wed Jan 25 08:21:03 2012
@@ -72,10 +72,10 @@ abstract class TextPaneSkinElementView e
     }
 
     @Override
-    public void invalidateTree() {
-        super.invalidateTree();
+    public void invalidateDownTree() {
+        super.invalidateDownTree();
         for (TextPaneSkinNodeView child : this) {
-            child.invalidateTree();
+            child.invalidateDownTree();
         }
     }
 
@@ -252,17 +252,20 @@ abstract class TextPaneSkinElementView e
 
     @Override
     public void nodeInserted(Element element, int index) {
-        invalidate();
+        insert(getTextPaneSkin().createNodeView(element.get(index)), index);
+        invalidateUpTree();
     }
 
     @Override
     public void nodesRemoved(Element element, int index, Sequence<Node> nodes) {
-        invalidate();
+        remove(index, nodes.getLength());
+        invalidateUpTree();
     }
 
     @Override
     public void fontChanged(Element element, Font previousFont) {
         // because children may depend on parents for their style information, we need to invalidate the whole tree
+        // TODO, we don't need to invalidate the whole tree, just the sub-tree from here down
         getTextPaneSkin().invalidateNodeViewTree();
     }
 
@@ -273,19 +276,22 @@ abstract class TextPaneSkinElementView e
 
     @Override
     public void foregroundColorChanged(Element element, Color previousForegroundColor) {
-        // because children may depend on parents for their style information, we need to invalidate the whole tree
+        // Because children may depend on parents for their style information, we need to invalidate the whole tree.
+        // TODO we don't need to invalidate the whole tree, just the sub-tree from here down.
         getTextPaneSkin().invalidateNodeViewTree();
     }
 
     @Override
     public void underlineChanged(Element element) {
-        // because children may depend on parents for their style information, we need to invalidate the whole tree
+        // Because children may depend on parents for their style information, we need to invalidate the whole tree.
+        // TODO we don't need to invalidate the whole tree, just the sub-tree from here down.
         getTextPaneSkin().invalidateNodeViewTree();
     }
 
     @Override
     public void strikethroughChanged(Element element) {
-        // because children may depend on parents for their style information, we need to invalidate the whole tree
+        // Because children may depend on parents for their style information, we need to invalidate the whole tree.
+        // TODO we don't need to invalidate the whole tree, just the sub-tree from here down.
         getTextPaneSkin().invalidateNodeViewTree();
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinImageNodeView.java Wed Jan 25 08:21:03 2012
@@ -131,7 +131,7 @@ class TextPaneSkinImageNodeView extends 
 
     @Override
     public void imageChanged(ImageNode imageNode, Image previousImage) {
-        invalidate();
+        invalidateUpTree();
 
         Image image = imageNode.getImage();
         if (image != null) {
@@ -145,7 +145,7 @@ class TextPaneSkinImageNodeView extends 
 
     @Override
     public void sizeChanged(Image image, int previousWidth, int previousHeight) {
-        invalidate();
+        invalidateUpTree();
     }
 
     @Override

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinListItemView.java Wed Jan 25 08:21:03 2012
@@ -44,7 +44,7 @@ class TextPaneSkinListItemView extends T
 
     public void setIndexText(String indexText) {
         indexTextNode.setText(indexText);
-        indexTextNodeView.invalidate();
+        indexTextNodeView.invalidateUpTree();
     }
 
     @Override

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNodeView.java Wed Jan 25 08:21:03 2012
@@ -153,15 +153,15 @@ abstract class TextPaneSkinNodeView impl
         return valid;
     }
 
-    public void invalidate() {
+    public void invalidateUpTree() {
         valid = false;
 
         if (parent != null) {
-            parent.invalidate();
+            parent.invalidateUpTree();
         }
     }
 
-    public void invalidateTree() {
+    public void invalidateDownTree() {
         valid = false;
     }
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinNumberedListView.java Wed Jan 25 08:21:03 2012
@@ -129,6 +129,6 @@ class TextPaneSkinNumberedListView exten
 
     @Override
     public void styleChanged(NumberedList numberedList, Style previousStyle) {
-        invalidate();
+        invalidateUpTree();
     }
 }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinParagraphView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinParagraphView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinParagraphView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinParagraphView.java Wed Jan 25 08:21:03 2012
@@ -58,8 +58,8 @@ class TextPaneSkinParagraphView extends 
     }
 
     @Override
-    public void invalidate() {
-        super.invalidate();
+    public void invalidateUpTree() {
+        super.invalidateUpTree();
         terminatorBounds = null;
     }
 
@@ -233,7 +233,7 @@ class TextPaneSkinParagraphView extends 
         return new Dimensions(layouter.paragraphWidth, height);
     }
 
-    private TextPaneSkinNodeView getNext(TextPaneSkinNodeView child) {
+    private static TextPaneSkinNodeView getNext(TextPaneSkinNodeView child) {
         // Using instanceof checks because there is no nice place in the hierarchy
         // to put an abstract method
         if (child instanceof TextPaneSkinSpanView) {

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinSpanView.java Wed Jan 25 08:21:03 2012
@@ -16,11 +16,8 @@
  */
 package org.apache.pivot.wtk.skin;
 
-import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.wtk.Dimensions;
 import org.apache.pivot.wtk.TextPane;
-import org.apache.pivot.wtk.text.Element;
-import org.apache.pivot.wtk.text.Node;
 import org.apache.pivot.wtk.text.TextSpan;
 
 /**
@@ -133,18 +130,4 @@ class TextPaneSkinSpanView extends TextP
         }
     }
 
-    @Override
-    public void nodeInserted(Element element, int index) {
-        super.nodeInserted(element, index);
-
-        TextSpan span = (TextSpan)getNode();
-        insert(getTextPaneSkin().createNodeView(span.get(index)), index);
-    }
-
-    @Override
-    public void nodesRemoved(Element element, int index, Sequence<Node> nodes) {
-        remove(index, nodes.getLength());
-
-        super.nodesRemoved(element, index, nodes);
-    }
 }
\ No newline at end of file

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinTextNodeView.java Wed Jan 25 08:21:03 2012
@@ -73,12 +73,12 @@ class TextPaneSkinTextNodeView extends T
     }
 
     @Override
-    public void invalidate() {
+    public void invalidateUpTree() {
         length = 0;
         next = null;
         glyphVector = null;
 
-        super.invalidate();
+        super.invalidateUpTree();
     }
 
     @Override
@@ -477,12 +477,12 @@ class TextPaneSkinTextNodeView extends T
 
     @Override
     public void charactersInserted(TextNode textNode, int index, int count) {
-        invalidate();
+        invalidateUpTree();
     }
 
     @Override
     public void charactersRemoved(TextNode textNode, int index, int count) {
-        invalidate();
+        invalidateUpTree();
     }
 
     @Override

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java?rev=1235672&r1=1235671&r2=1235672&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextPaneSkinVerticalElementView.java Wed Jan 25 08:21:03 2012
@@ -16,12 +16,10 @@
  */
 package org.apache.pivot.wtk.skin;
 
-import org.apache.pivot.collections.Sequence;
 import org.apache.pivot.wtk.Bounds;
 import org.apache.pivot.wtk.Dimensions;
 import org.apache.pivot.wtk.TextPane;
 import org.apache.pivot.wtk.text.Element;
-import org.apache.pivot.wtk.text.Node;
 
 /**
  * Some of the classes in the text hierarchy are very similar in layout ie. they lay their children out vertically. This class groups that functionality.
@@ -33,11 +31,6 @@ abstract class TextPaneSkinVerticalEleme
     }
 
     @Override
-    protected void attach() {
-        super.attach();
-    }
-
-    @Override
     protected void childLayout(int breakWidth) {
         // TODO At some point, we may want to optimize this method by deferring layout of
         // non-visible views. If so, we should not recycle views but rather recreate them
@@ -197,18 +190,4 @@ abstract class TextPaneSkinVerticalEleme
 
         return rowCount;
     }
-
-    @Override
-    public void nodeInserted(Element element, int index) {
-        super.nodeInserted(element, index);
-
-        insert(getTextPaneSkin().createNodeView(element.get(index)), index);
-    }
-
-    @Override
-    public void nodesRemoved(Element element, int index, Sequence<Node> nodes) {
-        remove(index, nodes.getLength());
-
-        super.nodesRemoved(element, index, nodes);
-    }
 }