Update of /cvsroot/qooxdoo/qooxdoo/source/script/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23584/source/script/core
Modified Files:
Tag: renderer
QxApplication.js QxMain.js
Log Message:
Reworked application startup, optimized layout of test examples
Index: QxApplication.js
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/core/QxApplication.js,v
retrieving revision 1.2.2.58
retrieving revision 1.2.2.59
diff -u -d -r1.2.2.58 -r1.2.2.59
--- QxApplication.js 24 Jan 2006 16:48:54 -0000 1.2.2.58
+++ QxApplication.js 25 Jan 2006 17:47:59 -0000 1.2.2.59
@@ -48,215 +48,254 @@
{
QxTarget.call(this, false);
- /*
- Try alternative initialisation
-
- http://dean.edwards.name/my/readyState.html
- http://www.quirksmode.org/blog/archives/2005/06/you_shouldve_be_1.html
-
- Probably the most interesting one:
- http://www.themaninblue.com/writing/perspective/2004/09/29/
-
- The problem is that the dom is available then, but the dom isn't... mhh
- */
-
- /*
- switch(QxClient.getEngine())
- {
- case "gecko_":
- window.addEventListener("DOMContentLoaded", function() { window.application.init(); }, false);
- break;
-
- case "opera":
- case "mshtml":
- window.onreadystatechange = function() { if (document.readyState == "interactive") window.application.init(); };
- break;
-
- case "mshtml-alternative":
- window.ondocumentready = function() { window.application.init(); };
- break;
-
- default:
- window.onload = function() { window.application.init(); };
+ function init() {
+ window.application.init();
};
- */
- window.onload = function() { window.application.init(); };
+ if (QxClient.isGecko()) {
+ QxDom.addEventListener(window, "DOMContentLoaded", init);
+ } else {
+ QxDom.addEventListener(window, "load", init);
+ };
};
QxApplication.extend(QxTarget, "QxApplication");
-QxApplication.MSG_INSTANCES = "Created Instances: ";
-QxApplication.MSG_CLASSES = "Available Classes: ";
-QxApplication.MSG_PROPERTIES = "Property Count: ";
-QxApplication.MSG_CLIENTINFO = "Client Detection: ";
-QxApplication.MSG_STRICTMODE = "Document is not in Quirksmode! This is needed in Internet Explorer <= 6 to let qooxdoo render correctly.";
+
/*
---------------------------------------------------------------------------
- APPLICATION INIT
+ USER APPLICATION METHODS
---------------------------------------------------------------------------
*/
-proto._ready = false;
-
-// user defineable methods of an qooxdoo initialization
proto.pre = QxUtil.returnTrue;
proto.main = QxUtil.returnTrue;
proto.post = QxUtil.returnTrue;
+
+
+
+
+
+/*
+---------------------------------------------------------------------------
+ MAIN INITIALISATION ROUTINE
+---------------------------------------------------------------------------
+*/
+
/*!
Global application init routine
*/
proto.init = function()
{
- this._printRuntimeInfo(this._initLoad, "Loading Data", window._htmlstart);
- this._printRuntimeInfo(this._initApplication, "Initialize Application");
- this._printRuntimeInfo(this._initMain, "Executing User Application");
- this._printRuntimeInfo(this._initPreload, "Preloading Images");
+ if (this._initDone) {
+ return;
+ };
+
+ this._initDone = true;
+
+ this._initApplication();
+ this._initMain();
+ this._initPreload();
+
+ // initPostload will be executed from the first queue flush
};
-proto._initLoad = QxUtil.returnTrue;
-proto._initApplication = function()
-{
- // Output the number of available classes
- this._printClassInfo();
- // Output the number existing properties
- this._printPropertyInfo();
-
- // Print short client detection info
- this._printClientInfo();
- // Execute user define 'pre' method
- this.pre();
- // Fire global 'pre' event
- this.createDispatchEvent(QxConst.EVENT_TYPE_PRE);
- // Create client window instance (and client-document, event- and focus-manager, ...)
- this._clientWindow = new QxClientWindow(window);
+/*
+---------------------------------------------------------------------------
+ SEPERATE INITIALISATION ROUTINES
+---------------------------------------------------------------------------
+*/
- // Build virtual methods for easy additions of childrens and so on
- this._remappingChildTable = QxParent.prototype._remappingChildTable;
- QxParent.prototype.remapChildrenHandlingTo.call(this, this._clientWindow.getClientDocument());
+proto._initApplication = function()
+{
+ var s = (new Date).valueOf();
- // Early initial flush
- QxWidget.flushGlobalQueues();
+ this.debug("Pre phase...");
+
+ try
+ {
+ // Output the number of available classes
+ this._printClassInfo();
+
+ // Output the number existing properties
+ this._printPropertyInfo();
+
+ // Print short client detection info
+ this._printClientInfo();
+
+ // Execute user define 'pre' method
+ this.debug(" - executing application pre");
+ this.pre();
+
+ // Fire global 'pre' event
+ this.createDispatchEvent(QxConst.EVENT_TYPE_PRE);
+
+ // Create client window instance (and client-document, event- and focus-manager, ...)
+ this._clientWindow = new QxClientWindow(window);
+
+ // Build virtual methods for easy additions of childrens and so on
+ this._remappingChildTable = QxParent.prototype._remappingChildTable;
+ QxParent.prototype.remapChildrenHandlingTo.call(this, this._clientWindow.getClientDocument());
+
+ // Output the number of currently instanciated objects
+ this._printInstanceInfo();
+ }
+ catch(ex)
+ {
+ return this.error("...failed: " + ex);
+ };
+
+ this.debug(" - done in: " + ((new Date).valueOf() - s) + "ms");
+ this.debug("\n");
};
proto._initMain = function()
{
- // Output the number of currently instanciated objects
- this._printInstanceInfo();
-
- // Execute user define 'main' method
- this.main();
-
- // Fire global 'main' event
- this.createDispatchEvent(QxConst.EVENT_TYPE_MAIN);
-
- this._ready = true;
+ var s = (new Date).valueOf();
+ this.debug("Main phase...");
+
+ try
+ {
+ // Execute user define 'main' method
+ this.debug(" - executing application main");
+ this.main();
+
+ // Fire global 'main' event
+ this.createDispatchEvent(QxConst.EVENT_TYPE_MAIN);
+
+ // Output the number of currently instanciated objects
+ this._printInstanceInfo();
+ }
+ catch(ex)
+ {
+ return this.error("...failed: " + ex);
+ };
+
+ this.debug(" - done in: " + ((new Date).valueOf() - s) + "ms");
+ this.debug("\n");
};
proto._initPreload = function()
{
- // Preloading images which should be currently visible
- var vPreloadList = QxImageManager._preloadList;
-
- for (var vImageUri in vPreloadList) {
- new QxImagePreloader(QxImageManager.buildURI(vImageUri));
+ var s = (new Date).valueOf();
+ this.debug("Preloading phase...");
+
+ try
+ {
+ // Preloading images which should be currently visible
+ var vPreloadList = QxImageManager._preloadList;
+
+ for (var vImageUri in vPreloadList) {
+ new QxImagePreloader(QxImageManager.buildURI(vImageUri));
+ };
+
+ // Fire global 'cache' event
+ this.createDispatchEvent(QxConst.EVENT_TYPE_CACHE);
+
+ // Finally flushing the queues with a timeout of 100ms
+ window.setTimeout(function()
+ {
+ var s = (new Date).valueOf();
+ window.application.debug("Widget phase");
+ window.application.debug(" - updating widgets");
+
+ window.application._ready = true;
+ QxWidget.flushGlobalQueues(true);
+
+ window.application.debug(" - done in: " + ((new Date).valueOf() - s) + "ms");
+ window.application.debug("\n");
+ window.application._initPostload();
+ }, 100);
+ }
+ catch(ex)
+ {
+ return this.error("...failed: " + ex);
};
-
- // Fire global 'cache' event
- this.createDispatchEvent(QxConst.EVENT_TYPE_CACHE);
-
- // Calculating real start of interface rendering
- this._interfaceStart = (new Date).valueOf() + QxWidget.FLUSH_TIMEOUT;
-
- // Finally flushing the queues with a timeout of QxWidget.FLUSH_TIMEOUT
- QxWidget.flushGlobalQueuesTimeout();
+
+ this.debug(" - done in: " + ((new Date).valueOf() - s) + "ms");
+ this.debug("\n");
};
proto._initPostload = function()
{
- // Execute user define 'post' method
- this.post();
-
- // Post load images which could be visible later
- var vPreloadList = QxImageManager._preloadList;
- var vImageList = QxImageManager._imageList;
-
- for (var vImageUri in vImageList)
+ var s = (new Date).valueOf();
+ this.debug("Post phase...");
+
+ try
{
- if (!vPreloadList[vImageUri]) {
- new QxImagePreloader(QxImageManager.buildURI(vImageUri));
+ // Output the number of currently instanciated objects
+ this._printInstanceInfo();
+
+ // Execute user define 'post' method
+ this.debug(" - executing application post");
+ this.post();
+
+ // Post load images which could be visible later
+ var vPreloadList = QxImageManager._preloadList;
+ var vImageList = QxImageManager._imageList;
+
+ for (var vImageUri in vImageList)
+ {
+ if (!vPreloadList[vImageUri]) {
+ new QxImagePreloader(QxImageManager.buildURI(vImageUri));
+ };
};
+
+ // Fire global 'post' event
+ this.createDispatchEvent(QxConst.EVENT_TYPE_POST);
+ }
+ catch(ex)
+ {
+ return this.error("...failed: " + ex);
};
-
- // Fire global 'post' event
- this.createDispatchEvent(QxConst.EVENT_TYPE_POST);
+
+ this.debug(" - done in: " + ((new Date).valueOf() - s) + "ms");
};
-/*!
- Will be executed from the QxWidget queue flush
-*/
-proto._postmain = function(vTime)
-{
- // Output the number of currently instanciated objects
- this._printInstanceInfo();
- // Inform the user about the progress made
- this.debug("Initialize Interface" + QxConst.CORE_COLON + QxConst.CORE_SPACE + vTime + QxConst.CORE_MILLISECONDS);
- // Timeout execution of post processing
- QxTimer.once(this._postMainHelper, this, 500);
-};
-proto._postMainHelper = function() {
- this._printRuntimeInfo(this._initPostload, "Postloading Images");
-};
+
+
+/*
+---------------------------------------------------------------------------
+ ADDITIONAL INFORMATIONAL OUTPUT
+---------------------------------------------------------------------------
+*/
proto._printInstanceInfo = function() {
- this.info(QxApplication.MSG_INSTANCES + QxObjectDataBase.length);
+ this.debug(" - number of instances: " + QxObjectDataBase.length);
};
proto._printClassInfo = function() {
- this.info(QxApplication.MSG_CLASSES + QxUtil.getObjectLength(QxClasses));
+ this.debug(" - number of classes: " + QxUtil.getObjectLength(QxClasses));
};
proto._printPropertyInfo = function() {
- this.info(QxApplication.MSG_PROPERTIES + QxPropertyCounter);
+ this.debug(" - number of properties: " + QxPropertyCounter);
};
proto._printClientInfo = function()
{
- this.info(QxApplication.MSG_CLIENTINFO + QxClient.getEngine() + QxConst.CORE_SPACE + QxClient.getVersion() + (QxUtil.isValidString(QxClient.getEmulation()) ? QxConst.CORE_SPACE + QxClient.getEmulation() : QxConst.CORE_EMPTY));
+ this.debug(" - client detection: " + QxClient.getEngine() + QxConst.CORE_SPACE + QxClient.getVersion() + (QxUtil.isValidString(QxClient.getEmulation()) ? QxConst.CORE_SPACE + QxClient.getEmulation() : QxConst.CORE_EMPTY));
if (!QxClient.isInQuirksMode() && QxClient.isMshtml()) {
- this.warn(QxApplication.MSG_STRICTMODE);
+ this.warn("Document is not in Quirksmode! This is needed in Internet Explorer <= 6 to let qooxdoo render correctly.");
};
};
-proto._printRuntimeInfo = function(vFunc, vJob, vStart)
-{
- vStart = vStart ? vStart : (new Date).valueOf();
- try
- {
- vFunc.call(this);
- }
- catch(ex)
- {
- this.error("Failed to execute init function: " + vJob + ": " + ex);
- };
- this.debug(vJob + QxConst.CORE_COLON + QxConst.CORE_SPACE + ((new Date).valueOf() - vStart) + QxConst.CORE_MILLISECONDS);
-};
@@ -269,6 +308,8 @@
---------------------------------------------------------------------------
*/
+proto._ready = false;
+
proto.isReady = function() {
return this._ready;
};
@@ -282,11 +323,11 @@
};
proto.getEventManager = function() {
- return this._clientWindow.getEventManager();
+ return this.getClientWindow().getEventManager();
};
proto.getClientDocument = function() {
- return this._clientWindow.getClientDocument();
+ return this.getClientWindow().getClientDocument();
};
Index: QxMain.js
===================================================================
RCS file: /cvsroot/qooxdoo/qooxdoo/source/script/core/Attic/QxMain.js,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -d -r1.1.2.8 -r1.1.2.9
--- QxMain.js 16 Jan 2006 16:11:55 -0000 1.1.2.8
+++ QxMain.js 25 Jan 2006 17:47:59 -0000 1.1.2.9
@@ -29,7 +29,7 @@
************************************************************************ */
-var QxVersion = "0.2_beta-4";
+var QxVersion = "0.2_rc1";
var QxPropertyCounter = 0;
var QxClasses = {};
|