[Sie-announce] SIEコード [1889] 1, MouseEventの実装開始

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2010年 6月 9日 (水) 22:30:16 JST


Revision: 1889
          http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1889
Author:   dhrname
Date:     2010-06-09 22:30:16 +0900 (Wed, 09 Jun 2010)

Log Message:
-----------
1, MouseEventの実装開始
2, getAttributeNodeNSの修正
3, Eventオブジェクトの最適化

Modified Paths:
--------------
    branches/06x/061/org/w3c/dom/events.js

Modified: branches/06x/061/org/w3c/dom/events.js
===================================================================
--- branches/06x/061/org/w3c/dom/events.js	2010-06-08 10:27:58 UTC (rev 1888)
+++ branches/06x/061/org/w3c/dom/events.js	2010-06-09 13:30:16 UTC (rev 1889)
@@ -114,7 +114,20 @@
     this.removeEventListener(type, listener, useCapture);  //いったん、(あれば)リスナーを離す。
     var s = new EventListener(useCapture, type, listener); //リスナーを作成
     this._capter[this._capter.length] = s;                 //このノードにリスナーを登録しておく
-  }catch(e){}
+    var t = type.charAt(0);
+    if (t !== "D" && t !== "S") { //MouseEventsならば
+      var node = this;
+      node._tar.attachEvent("on" +type, function(){
+        var evt = node.ownerDocument.createEvent("MouseEvents");
+        evt.initMouseEvent(type, true, true, node.ownerDocument.defaultView, 0);
+        node.dispatchEvent(evt);
+        evt - null;
+      });
+    }
+    s = t = null;
+  }catch(e){
+    stlog.add(e, 122);
+  }
 };
 /*void*/  Node.prototype.removeEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
   var tce = this._capter;
@@ -191,7 +204,7 @@
       evtt.target = evt.target;
       evtt.initEvent("SVGError", true, false);
       evt.target.dispatchEvent(evtt);
-      stlog.add(e, 194);
+      stlog.add(e, 200);
       evtt = null;
     };
   }
@@ -203,9 +216,9 @@
   /*DOMString*/        this.type;
   /*EventTarget*/      this.target;
   /*EventTarget*/      this.currentTarget = null;
-  /*unsigned short*/   this.eventPhase = Event.CAPTURING_PHASE;
-  /*boolean*/          this.bubbles = false;
-  /*boolean*/          this.cancelable = false;
+  /*unsigned short*/   this.eventPhase = 1;//Event.CAPTURING_PHASE;
+  /*boolean*/          this.bubbles;
+  /*boolean*/          this.cancelable;
   /*DOMTimeStamp*/     this.timeStamp = (new Date()).getTime();
   this._stop = false; //stopPropagationメソッドで使う
   this._default = true; //preventDefaultメソッドで使う
@@ -281,6 +294,17 @@
 MouseEvent.prototype = new UIEvent();
 MouseEvent.constructor = UIEvent;
 /*void*/ MouseEvent.prototype.initMouseEvent = function( /*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*views::AbstractView*/ viewArg, /*long*/ detailArg, /*long*/ screenXArg, /*long*/ screenYArg, /*long*/ clientXArg, /*long*/ clientYArg, /*boolean*/ ctrlKeyArg, /*boolean*/ altKeyArg, /*boolean*/ shiftKeyArg, /*boolean*/ metaKeyArg, /*unsigned short*/ buttonArg, /*EventTarget*/ relatedTargetArg) {
+  this.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
+  this.screenX = screenXArg;
+  this.screenY = screenYArg;
+  this.clientX  = clientXArg;
+  this.clientY  = clientYArg;
+  this.ctrlKey  = ctrlKeyArg;
+  this.shiftKey = shiftKeyArg;
+  this.altKey   = altKeyArg;
+  this.metaKey  = metaKeyArg;
+  this.button = buttonArg;
+  this.relatedTarget = relatedTargetArg;
 };
 
 function MutationEvent(){
@@ -326,11 +350,10 @@
   var evt = this.ownerDocument.createEvent("MutationEvents");
   if (!s) { //ノードがなければ
     evt.initMutationEvent("DOMAttrModified", true, false, newAttr, null, newAttr.nodeValue, newAttr.nodeName, MutationEvent.ADDITION);
-    this.dispatchEvent(evt); //このとき、MutationEventsが発動
   } else {
     evt.initMutationEvent("DOMAttrModified", true, false, newAttr, s.nodeValue, newAttr.nodeValue, newAttr.nodeName, MutationEvent.MODIFICATION);
-    this.dispatchEvent(evt);
   }
+  this.dispatchEvent(evt); //このとき、MutationEventsが発動
   evt = null;
   /*ここまで追加*/
   return s;
@@ -379,7 +402,7 @@
   evt.target = n;
   evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
   n.dispatchEvent(evt);
-  if (!(n instanceof Element)) {                       //子要素がないので終了
+  if (!n.hasChildNodes()) {                       //子ノードがないので終了
     return n;
   }
   var descend = n.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
@@ -388,8 +411,13 @@
       var di = descend[i];
       evt.target = di;
       evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
-      di.dispatchEvent(evt);
-      di = null;
+      var tce = di._capter; //tceは登録しておいたリスナーのリスト
+      for (var j=0,tcli=tce.length;j<tcli;++j){
+        if (tce[j]) {
+          tce[j].handleEvent(evtt);
+        }
+      }
+      j = tcli = di = null;
     }
   }
   evt = descend = null;




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