Author: ptw
Date: 2007-12-04 20:23:05 -0800 (Tue, 04 Dec 2007)
New Revision: 7448
Modified:
openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
openlaszlo/trunk/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/ScriptLimits.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
Log:
Change 20071204-ptw-z by [EMAIL PROTECTED] on 2007-12-04 17:04:11 EST
in /Users/ptw/OpenLaszlo/ringding-2
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Implement scriptlimits for SWF runtime
New Features: The canvas tag has a new attribute, swflimits which is
of type css, which can be used to override the default recursion (256)
and timeout (15s) limits. To do so you say:
<canvas scriptlimits="timeout: 30">
or to override both limits
<canvas scriptlimits="recursion: 300; timeout: 30">
Bugs Fixed:
Technical Reviewer: [EMAIL PROTECTED] (message://<[EMAIL PROTECTED]>)
QA Reviewer: [EMAIL PROTECTED] (pending)
Doc Reviewer: [EMAIL PROTECTED] (pending)
Documentation:
See "New Features". For complete example demonstration, see the test
case attached to the bug.
Details:
schema/lfc: add scriptlimits attribute to canvas
CanvasCompiler: parse scriptlimits and store in environment
SWFWriter: Don't try to write scriptlimits immediately. When
closing the file, if the limits have been set (are non-zero) add
them.
ScriptLimits: Correct defaults. If called with a 0 value, use the default.
Tests:
smokecheck, test case from Jira
Modified: openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx 2007-12-05 00:11:07 UTC (rev
7447)
+++ openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx 2007-12-05 04:23:05 UTC (rev
7448)
@@ -69,6 +69,8 @@
<attribute name="version" type="string" value="4.1"/>
<!-- If true, enable accessibility features -->
<attribute name="accessible" type="boolean" value="false"/>
+ <!-- Set recursion and timeout limits -->
+ <attribute name="scriptlimits" type="css" />
<containsElements>
<element>view</element>
Modified:
openlaszlo/trunk/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/ScriptLimits.java
===================================================================
---
openlaszlo/trunk/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/ScriptLimits.java
2007-12-05 00:11:07 UTC (rev 7447)
+++
openlaszlo/trunk/WEB-INF/lps/server/jgenerator-2.2/src/org/openlaszlo/iv/flash/api/ScriptLimits.java
2007-12-05 04:23:05 UTC (rev 7448)
@@ -20,12 +20,13 @@
int recursion = 0;
int timeout = 0;
- int DEFAULT_RECURSION = 1024; // pixels
- int DEFAULT_TIMEOUT = 60;
+ // Determined empirically
+ public static int DEFAULT_RECURSION = 256;
+ public static int DEFAULT_TIMEOUT = 15;
- public ScriptLimits(int recursion,int timeout) {
- this.recursion = recursion;
- this.timeout = timeout;
+ public ScriptLimits(int recursion, int timeout) {
+ this.recursion = (recursion == 0 ? DEFAULT_RECURSION : recursion);
+ this.timeout = (timeout == 0 ? DEFAULT_TIMEOUT : timeout);
}
public ScriptLimits() {
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
===================================================================
---
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
2007-12-05 00:11:07 UTC (rev 7447)
+++
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/CanvasCompiler.java
2007-12-05 04:23:05 UTC (rev 7448)
@@ -19,6 +19,7 @@
import org.openlaszlo.utils.*;
import org.jdom.*;
import org.apache.log4j.*;
+import org.openlaszlo.css.CSSParser;
/** Compiler for the <code>canvas</code> element. */
class CanvasCompiler extends ToplevelCompiler {
@@ -96,6 +97,24 @@
mEnv.warn(msg, element);
}
+ String scriptLimits = element.getAttributeValue("scriptlimits");
+ if (scriptLimits != null) {
+ try {
+ Map properties = new CSSParser(new AttributeStream(element,
"scriptlimits")).Parse();
+ int recursion =
+ properties.containsKey("recursion") ?
+ ((Integer)properties.get("recursion")).intValue() : 0;
+ int timeout =
+ properties.containsKey("timeout") ?
+ ((Integer)properties.get("timeout")).intValue() : 0;
+ mEnv.setScriptLimits(recursion, timeout);
+ } catch (org.openlaszlo.css.ParseException e) {
+ throw new CompilationError(e);
+ } catch (org.openlaszlo.css.TokenMgrError e) {
+ throw new CompilationError(e);
+ }
+ }
+
if (mEnv.isSWF()) {
String baseLibraryName = getBaseLibraryName(mEnv);
String baseLibraryBecause = "Required for all applications";
Modified:
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
===================================================================
---
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
2007-12-05 00:11:07 UTC (rev 7447)
+++
openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWFWriter.java
2007-12-05 04:23:05 UTC (rev 7448)
@@ -260,6 +260,14 @@
SetBackgroundColor setbgc = new SetBackgroundColor(c);
mFlashFile.getMainScript().setBackgroundColor(setbgc);
+ // Write scriptlimits tag if requested
+ if ((this.mRecursionLimit != 0) || (this.mExecutionTimeout != 0)) {
+ // ScriptLimits tag, to set max recursion depth and timeout
+ Frame frame = mFlashFile.getMainScript().getFrameAt(mLastFrame);
+ ScriptLimits slimit = new ScriptLimits(this.mRecursionLimit,
this.mExecutionTimeout);
+ frame.addFlashObject(slimit);
+ }
+
// NOTE: disable constant pool when compiling canvas constructor
// so that build id etc... are easy for qa to pick out.
Properties props = (Properties)mProperties.clone();
@@ -825,16 +833,6 @@
return s2;
}
- public void setScriptLimits(int recursion, int timeout) {
- this.mRecursionLimit = recursion;
- this.mExecutionTimeout = timeout;
- // ScriptLimits tag, to set max recursion depth and timeout
- Frame frame = mFlashFile.getMainScript().getFrameAt(0);
- ScriptLimits slimit = new ScriptLimits(recursion, timeout);
- frame.addFlashObject(slimit);
- }
-
-
/** Writes the SWF to the <code>OutputStream</code> that was
* supplied to the SWFWriter's constructor.
* @throws IOException if an error occurs
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins