OSDN Git Service

Support the inherit and the currentColor keyword
authordhrname <dhrname@users.sourceforge.jp>
Tue, 3 Nov 2015 14:01:40 +0000 (23:01 +0900)
committerdhrname <dhrname@users.sourceforge.jp>
Tue, 3 Nov 2015 14:01:40 +0000 (23:01 +0900)
org/w3c/dom/smil.js

index 68a9118..e2b78ac 100644 (file)
@@ -785,17 +785,26 @@ base("$calcMode").up("$attribute").mix( {
   /*$fromオブジェクトを作るためのひな形となるオブジェクト*/\r
   $from: base("$from").up(),\r
   \r
+  /*attributeName属性の値*/\r
+  attrName: "",\r
+  \r
   /*指定した要素の属性値を取得するメソッド*/\r
   _getAttr: function(/*string*/ name, def) {\r
     var nameSpace = null;\r
     if (name.indexOf("xlink:") > -1) {\r
       nameSpace = "http://www.w3.org/1999/xlink";\r
     }\r
+    var s = this._ele.getAttributeNS(nameSpace, name);\r
+    if (this.element && (s === "inherit")) {\r
+      return this.element.ownerDocument.defaultView.getComputedStyle(this.element.parentNode, "").getPropertyValue(this.attrName);\r
+    } else if (this.element && (s === "currentColor")) {\r
+      return this.element.ownerDocument.defaultView.getComputedStyle(this._ele, "").getPropertyValue("color");\r
+    }\r
     /*DOM Level2やIE11では、getAttributeNSメソッドは空文字を返す。他のブラウザではnullを返すことが多い\r
      * \r
      * >the empty string if that attribute does not have a specified or default value\r
      * http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-ElGetAttrNS*/\r
-    return (this._ele.getAttributeNS(nameSpace, name) || def);\r
+    return (s || def);\r
   },\r
   \r
   _ele: document.documentElement,\r
@@ -827,6 +836,7 @@ base("$calcMode").up("$attribute").mix( {
     }\r
     /*_getAttrメソッドで必要*/\r
     this._ele = ele;\r
+    this.attrName = this._getAttr("attributeName", "");\r
     /*eleの属性の値を、それぞれオブジェクトに割り当て*/\r
     var $frame = base("$frame"),\r
         begin = $frame.$begin,\r
@@ -1019,9 +1029,6 @@ base("$calcMode").up("$attribute").mix( {
   /*to属性の値、文字列*/\r
   to: "",\r
   \r
-  /*attributeName属性の値*/\r
-  attrName: "",\r
-  \r
   /*指定された属性の規定値*/\r
   defaultValue: "",\r
   \r
@@ -1072,7 +1079,6 @@ base("$calcMode").up("$attribute").mix( {
     if (ele && ele.getAttributeNS) {\r
       this._ele = ele;\r
       this.to = this._getAttr("to", "");\r
-      this.attrName = this._getAttr("attributeName", "");\r
       this.fill = this._getAttr("fill", "remove");\r
     }\r
     var thisele = this.element;\r