You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/05/22 03:05:40 UTC

svn commit: r658960 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/resources/org/apache/tapestry5/tapestry.js test/java/org/apache/tapestry5/integration/app1/services/AppModule.java

Author: hlship
Date: Wed May 21 18:05:40 2008
New Revision: 658960

URL: http://svn.apache.org/viewvc?rev=658960&view=rev
Log:
TAPESTRY-2424: Validation occasionally triggers Stack Overflow Javascript Error in IE

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=658960&r1=658959&r2=658960&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js Wed May 21 18:05:40 2008
@@ -219,6 +219,29 @@
         if (manager == undefined) manager = new Tapestry.FieldEventManager(field);
 
         return manager;
+    },
+
+    /**
+     * Used with validation to see if an element is visible: i.e., it and all of its containers, up to the
+     * containing form, are all visible. Only deeply visible elements are subject to validation.
+     */
+    isDeepVisible : function(element)
+    {
+        // This started as a recursively defined method attach to Element, but was converted
+        // to a stand-alone as part of TAPESTRY-2424.
+
+        var current = $(element);
+
+        while (true)
+        {
+            if (! current.visible()) return false;
+
+            if (current.tagName == "FORM") break;
+
+            current = $(current.parentNode)
+        }
+
+        return true;
     }
 };
 
@@ -369,22 +392,6 @@
     removeDecorations : function(element)
     {
         Tapestry.getFieldEventManager(element).removeDecorations();
-    },
-
-    // Checks to see if an element is truly visible, meaning the receiver and all
-    // its anscestors (up to the containing form), are visible.
-
-    isDeepVisible : function(element)
-    {
-        element = $(element);
-
-        if (! element.visible()) return false;
-
-        // Stop at a form, which is sufficient for validation purposes.
-
-        if (element.tagName == "FORM") return true;
-
-        return $(element.parentNode).isDeepVisible();
     }
 };
 
@@ -755,7 +762,7 @@
     {
         if (this.field.disabled) return;
 
-        if (! this.field.isDeepVisible()) return;
+        if (! Tapestry.isDeepVisible(this.field)) return;
 
         var value = $F(event.field);
         var isBlank = (value == '');
@@ -879,7 +886,7 @@
 
         $(this.hidden.form).observe(Tapestry.FORM_PREPARE_FOR_SUBMIT_EVENT, function()
         {
-            this.hidden.value = this.element.isDeepVisible();
+            this.hidden.value = Tapestry.isDeepVisible(this.element);
         }.bind(this));
     },
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java?rev=658960&r1=658959&r2=658960&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/services/AppModule.java Wed May 21 18:05:40 2008
@@ -82,7 +82,7 @@
         {
             public boolean service(Request request, Response response, RequestHandler handler) throws IOException
             {
-                long startTime = System.currentTimeMillis();
+                long startTime = System.nanoTime();
 
                 try
                 {
@@ -90,9 +90,9 @@
                 }
                 finally
                 {
-                    long elapsed = System.currentTimeMillis() - startTime;
+                    long elapsed = System.nanoTime() - startTime;
 
-                    log.info(String.format("Request time: %d ms", elapsed));
+                    log.info(String.format("Request time: %5.2f s (%s)", elapsed * 10E-9d, request.getPath()));
                 }
             }
         };