[Sie-announce] SIEコード [2706] dispatchEventメソッドの軽量化

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 5月 26日 (木) 22:03:12 JST


Revision: 2706
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2706
Author:   dhrname
Date:     2011-05-26 22:03:12 +0900 (Thu, 26 May 2011)

Log Message:
-----------
dispatchEventメソッドの軽量化

Modified Paths:
--------------
    branches/07x/078/org/w3c/dom/events.js

Modified: branches/07x/078/org/w3c/dom/events.js
===================================================================
--- branches/07x/078/org/w3c/dom/events.js	2011-05-26 12:41:33 UTC (rev 2705)
+++ branches/07x/078/org/w3c/dom/events.js	2011-05-26 13:03:12 UTC (rev 2706)
@@ -142,13 +142,15 @@
     throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR);
   }
   var te = this,
-      td = this.ownerDocument,
+      td = te.ownerDocument,
       etime = evt.timeStamp,
       etype = evt.type,
       ebub = evt.bubbles,
       tob,
       toli,
       type = /*Event.CAPTURING_PHASE*/ 1,
+      ecptype = /*Event.CAPTURING_PHASE*/ "1",
+      ebptype = /*Event.BUBBLING_PHASE*/ "3",
       tce;
   if (!td._isLoaded) {
     /*以下では、画像の処理に時間がかかりそうな場合、処理落ちとして、遅延処理
@@ -170,27 +172,28 @@
       return true;
     }
   }
-  evt.target = this;
+  evt.target = te;
   evt.eventPhase = 1;//Event.CAPTURING_PHASE
   //このノードからドキュメントノードにいたるまでの、DOMツリーのリストを作成しておく
-  td[/*Event.BUBBLING_PHASE*/ "3"] = null;
+  td[ebptype] = null;
   /*以下の処理では、documentElementのparentNodeが
    *Documentノードではなく、nullになっていることを前提としている。
    *したがって、documentElementのparentNodeがもし、Documentノードのオブジェクトならば、以下を書き換えるべきである
    */
   while (te.parentNode) {
-    te.parentNode[/*Event.CAPTURING_PHASE*/ "1"] = te;
-    te[/*Event.BUBBLING_PHASE*/ "3"] = te.parentNode;
+    te.parentNode[ecptype] = te;
+    te[ebptype] = te.parentNode;
     te = te.parentNode;
   }
-  td[/*Event.CAPTURING_PHASE*/ "1"] = te;
-  te[/*Event.BUBBLING_PHASE*/ "3"] = td;
+  td[ecptype] = te;
+  te[ebptype] = td;
   /*最初に捕獲フェーズでDOMツリーを下っていき、イベントのターゲットについたら、
    *そこで、浮上フェーズとして折り返すように、反復処理をおこなう。
    */
+  te = this;
   while (td) {
     evt.currentTarget = td;
-    if (td === this) { //イベントのターゲットに到着(折り返し地点)
+    if (td === te) { //イベントのターゲットに到着(折り返し地点)
       type = 2;//Event.AT_TARGET;
     }
     evt.eventPhase = type;
@@ -203,7 +206,7 @@
     if (evt._stop) {
       break; //stopPropagationメソッドが呼ばれたら、停止する
     }
-    if (td === this) {
+    if (td === te) {
       if (!ebub) {
         break; //浮上フェーズに移行せず、停止する
       }
@@ -212,7 +215,7 @@
     td = td[type];
   }
   var ed = evt._default;
-  evt = te = tce = n = td = type = tob = j = tcli = etype = etime = ebub =null;
+  evt = te = tce = n = td = type = tob = j = tcli = etype = etime = ebub = ecptype = ebptype =null;
   return ed;
 };
 




Sie-announce メーリングリストの案内
Back to archive index