1 /*SIE-SVG without Plugin under LGPL2.1 & GPL2.0 & Mozilla Public Lisence
2 *公式ページは http://sie.sourceforge.jp/
3 *利用方法は <script defer="defer" type="text/javascript" src="sie.js"></script>
4 *http://sie.sourceforge.jp/
5 *Usage: <script defer="defer" type="text/javascript" src="sie.js"></script>
7 /* ***** BEGIN LICENSE BLOCK *****
8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
10 * The contents of this file are subject to the Mozilla Public License Version
11 * 1.1 (the "License"); you may not use this file except in compliance with
12 * the License. You may obtain a copy of the License at
13 * http://www.mozilla.org/MPL/
15 * Software distributed under the License is distributed on an "AS IS" basis,
16 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 * for the specific language governing rights and limitations under the
20 * The Original Code is the Mozilla SVG Cairo Renderer project.
22 * The Initial Developer of the Original Code is IBM Corporation.
23 * Portions created by the Initial Developer are Copyright (C) 2004
24 * the Initial Developer. All Rights Reserved.
26 * Parts of this file contain code derived from the following files(s)
27 * of the Mozilla SVG project (these parts are Copyright (C) by their
28 * respective copyright-holders):
29 * layout/svg/renderer/src/libart/nsSVGLibartBPathBuilder.cpp
31 * Contributor(s):DHRNAME revulo bellbind
33 * Alternatively, the contents of this file may be used under the terms of
34 * either of the GNU General Public License Version 2 or later (the "GPL"),
35 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
36 * in which case the provisions of the GPL or the LGPL are applicable instead
37 * of those above. If you wish to allow use of your version of this file only
38 * under the terms of either the GPL or the LGPL, and not to allow others to
39 * use your version of this file under the terms of the MPL, indicate your
40 * decision by deleting the provisions above and replace them with the notice
41 * and other provisions required by the GPL or the LGPL. If you do not delete
42 * the provisions above, a recipient may use your version of this file under
43 * the terms of any one of the MPL, the GPL or the LGPL.
45 * ***** END LICENSE BLOCK ***** */
47 * Copyright (c) 2000 World Wide Web Consortium,
48 * (Massachusetts Institute of Technology, Institut National de
49 * Recherche en Informatique et en Automatique, Keio University). All
50 * Rights Reserved. This program is distributed under the W3C's Software
51 * Intellectual Property License. This program is distributed in the
52 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
53 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
55 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
58 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/dom.idl
59 /*W3CのDOMのIDLを参照にコードを起こしている
60 *変数やプロパティ、メソッドの名前の頭に、「_」がついているときはSIE独自のもの
66 #pragma prefix "w3c.org"
70 valuetype DOMString sequence<unsigned short>;
72 typedef unsigned long long DOMTimeStamp;
74 interface DocumentType;
77 interface NamedNodeMap;
80 function DOMException(n){
81 Error.apply(this, arguments);
86 "DOMString Size Error",
87 "Hierarchy Request Error",
88 "Wrong Document Error",
89 "Invalid Character Error",
90 "No Data Allowed Error",
91 "No Modification Allowed Error",
93 "Not Supported Error",
94 "Inuse Attribute Error",
95 "Invalid State Error",
97 "Invalid Modification Error",
99 "Invalid Access Error"
104 テキストの指定された範囲がDOMStringに合致しない。 2
105 HIERARCHY_REQUEST_ERR
106 コードが属さない場所に挿入されている。 3
108 インデクス若しくは大きさが負数,又は許された値よりも大きい。 1
110 他で既に使用されている属性を追加しようとしている。 10
111 INVALID_ACCESS_ERR,DOM水準2で導入
112 パラメタ又は操作が基礎になるオブジェクトによってサポートされていない。 15
113 INVALID_CHARACTER_ERR
114 名前の中などで,妥当でない又は不正な文字が指定されている。文法に合った文字の定義についてはXML規定の 生成規則2 を,文法に合った名前文字については 生成規則5 を参照すること。5
115 INVALID_MODIFICATION_ERR,DOM水準2で導入
116 基礎となるオブジェクトの型を修正しようとしている。 13
117 INVALID_STATE_ERR,DOM水準2で導入
118 利用不可能又はもはや利用可能ではないオブジェクトを使用しようとしている。 11
119 NAMESPACE_ERR,DOM水準2で導入
120 名前空間に関して正しくない方法でオブジェクトを生成又は変更しようとしている。 14
122 ノードが存在しない文脈でそのノードを参照しようとしている。 8
124 実装は,オブジェクト又は操作の要求された型をサポートしていない。9
126 データをサポートしないノードに対してデータを指定している。 6
127 NO_MODIFICATION_ALLOWED_ERR
128 修正が許されない場所でオブジェクトを修正しようとしている。 7
130 妥当ではない又は不正な文字列が指定されている。 12
132 ノードを生成した文書以外の(そのノードをサポートしない)異なる文書で,ノードが使用されている。4
136 t.INDEX_SIZE_ERR = 1;
137 t.DOMSTRING_SIZE_ERR = 2;
138 t.HIERARCHY_REQUEST_ERR = 3;
139 t.WRONG_DOCUMENT_ERR = 4;
140 t.INVALID_CHARACTER_ERR = 5;
141 t.NO_DATA_ALLOWED_ERR = 6;
142 t.NO_MODIFICATION_ALLOWED_ERR = 7;
144 t.NOT_SUPPORTED_ERR = 9;
145 t.INUSE_ATTRIBUTE_ERR = 10;
146 t.INVALID_STATE_ERR = 11;
148 t.INVALID_MODIFICATION_ERR = 13;
149 t.NAMESPACE_ERR = 14;
150 t.INVALID_ACCESS_ERR = 15;
151 t.prototype = new Error();
157 DOMImplementation = {
159 *文字列によって、機能をサポートしているかどうかをチェックする。削除不可。
161 /*boolean*/ hasFeature : function(/*string*/ feature, version) {
165 case "Events" : //DOM level2 Eventを参照
166 case "StyleSheets" : //DOM level2 StyleSheetを参照
167 case "org.w3c.svg.static" : //SVG1.1の仕様を参照
168 case "org.w3c.dom.svg.static" :
171 if (version === "2.0") { //DOM level2 Coreにおいて策定されたバージョン情報
179 /* createDocumentType
180 *ドキュメントタイプを作るためのもの。削除可。
182 /*DocumentType*/ createDocumentType : function(/*string*/ qualifiedName, publicId, systemId) {
184 s.publicId = publicId;
185 s.systemId = systemId;
189 * ドキュメントオブジェクトを作るためのもの。削除不可。
191 /*Document*/ createDocument : function( /*string*/ ns, qname, /*DocumentType*/ doctype) {
195 s = new (DOMImplementation[ns].Document);
196 this._doc_ && (s._document_ = this._doc_); //_document_プロパティはcreateElementNSメソッドやradialGradient要素やNAIBU._setPaintなどで使う
200 s.implementation = this;
202 s.documentElement = s.createElementNS(ns,qname); //ルート要素を作る
204 } catch(e){alert(e.message);}
206 "http://www.w3.org/2000/xmlns": {}
210 *ノード(節)はすべての雛形となる重要なものである。削除不可。
214 this.childNodes = [];
215 this._capter = []; //eventで利用
220 /*const unsigned short*/ t.ELEMENT_NODE = 1;
221 /*const unsigned short*/ t.ATTRIBUTE_NODE = 2;
222 /*const unsigned short*/ t.TEXT_NODE = 3;
223 /*const unsigned short*/ t.CDATA_SECTION_NODE = 4;
224 /*const unsigned short*/ t.ENTITY_REFERENCE_NODE = 5;
225 /*const unsigned short*/ t.ENTITY_NODE = 6;
226 /*const unsigned short*/ t.PROCESSING_INSTRUCTION_NODE = 7;
227 /*const unsigned short*/ t.COMMENT_NODE = 8;
228 /*const unsigned short*/ t.DOCUMENT_NODE = 9;
229 /*const unsigned short*/ t.DOCUMENT_TYPE_NODE = 10;
230 /*const unsigned short*/ t.DOCUMENT_FRAGMENT_NODE = 11;
231 /*const unsigned short*/ t.NOTATION_NODE = 12;
237 previousSibling : null,
244 ownerDocument : null,
247 *指定したoldChildノードの代わりに、新たなnewChildノードを入れる。切り替え機能。
249 /*Node*/ replaceChild : function( /*Node*/ newChild, oldChild) {
250 this.insertBefore(newChild, oldChild);
251 var s = this.removeChild(oldChild);
257 /*Node*/ appendChild : function( /*Node*/ ele) {
258 this.insertBefore(ele,null);
264 /*boolean*/ hasChildNodes : function() {
265 if (this.childNodes.length > 0) {
272 *ノードのコピーを作る。引数は、子ノードのコピーも作るかどうか。コピー機能。
274 /*Node*/ cloneNode : function( /*boolean*/ deep) {
276 if (this.hasOwnProperty("ownerDocument")) {
277 s = this.ownerDocument.importNode(this, deep);
284 *二つ以上の重複したテキストノードを一つにまとめる
286 /*void*/ normalize : function() {
287 var tcn = this.childNodes;
289 for (var i=tcn.length-1;i<0;--i) {
290 var tcni = tcn[i], tcnip = tcni.nextSibling;
292 if (tcni.nodeType === Node.TEXT_NODE && tcnip.nodeType === Node.TEXT_NODE) {
293 tcni.appendData(tcnip.data); //次ノードの文字列データを、現ノード文字列の後に付け加える
294 tcni.legnth = tcni.data.length;
295 this.removeChild(tcnip); //次ノードを排除
306 *どんな機能をサポートしているかどうかをチェック
308 /*boolean*/ isSupported : function( /*string*/ feature, version) {
309 return (this.ownerDocument.implementation.hasFeature(feature+"", version+""));
314 /*boolean*/ hasAttributes : function() {
315 if (this.attributes.length > 0) {
324 Array.prototype.item = function( /*long*/ index) {
325 return (this[index]);
329 Node item(in unsigned long index);
330 readonly attribute unsigned long length;
335 *ノードの集合。ノードリストと違って、順序が決まっていない。削除不可
337 function NamedNodeMap() {
341 *cloneNodeを行う際に、用いる。削除不可
343 Array.prototype._copyNode = function __nnmp_c( /*NamedNodeMap*/ children, /*boolean*/ deep) {
344 for (var i=0,cli=children.length;i<cli;i++) {
345 this[i] = children[i].cloneNode(deep);
349 NamedNodeMap.prototype = {
350 /*number*/ length : 0,
352 *名前空間に対応していないメソッドは、軽量化のため、機能させないようにする。代わりに、**NSメソッドを利用すること
354 /*Node*/ getNamedItem : function(/*string*/ name){
356 /*Node*/ setNamedItem : function(/*Node*/ arg){
358 /*Node*/ removeNamedItem : function(/*string*/ name){
360 /*Node*/ item : function( /*long*/ index) {
364 *名前空間と名前を使って、ノードの集合から特定のノードを取り出す
366 /*Node*/ getNamedItemNS : function(/*string*/ namespaceURI, /*string*/ localName) {
368 for (var i=0,tali=this.length;i<tali;i++) {
370 if (ta.namespaceURI === namespaceURI && ta.localName === localName) { //名前空間と名前がそれぞれ一致すれば
371 this._num = i; //場所をいったん記録しておく。(setNamedItemNSで使う)
381 /*Node*/ setNamedItemNS : function(/*Node*/ arg) {
382 var tgans = this.getNamedItemNS(arg.namespaceURI, arg.localName),
384 if (tgans) { //ノードがすでにあるならば、
386 this[this._num] = arg;
387 arg = tgans = void 0;
390 if (arg.ownerElement !== void 0) { //ノードがもはや別の要素で使われている
391 throw (new DOMException(DOMException.INUSE_ATTRIBUTE_ERR));
393 this[this.length] = arg; //新たに、argを項目として追加する
399 /*removeNamedItemNSメソッド
400 *名前空間と名前を使って、ノードの集合から特定のノードを排除
402 /*Node*/ removeNamedItemNS : function(/*string*/ namespaceURI, /*string*/ localName) {
403 var tgans = this.getNamedItemNS(namespaceURI, localName);
404 if (!tgans) { //ノードが見当たらない場合、
405 throw (new DOMException(DOMException.NOT_FOUND_ERR));
407 var s = this[this._num];
408 delete (this[this._num]);
414 _copyNode : Array.prototype._copyNode //上記のArrayの_copyNodeを参照
418 *文字データ。Textノードなどの元となる。削除不可。
420 function CharacterData(){
424 CharacterData.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
425 CharacterData.constructor = Node;
426 CharacterData.prototype.length = 0;
428 *offsetから数えてcount分の文字列を取り出す
430 /*string*/ CharacterData.prototype.substringData = function(/*long*/ offset, /*long*/ count) {
431 if (offset < 0 || count < 0 || offset > this.length) { //値が負か、データの長さよりoffsetが長いとき、サイズエラーを起こす
432 throw (new DOMException(INDEX_SIZE_ERR));
434 if (offset + count > this.length) { //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを取り出す
435 count = this.length - offset;
437 var s = this.data.substr(offset, count);
440 /*void*/ CharacterData.prototype.replaceData = function( /*long*/ offset, /*long*/ count, /*string*/ arg) {
441 if (offset < 0 || count < 0 || offset > this.length) { //値が負か、データの長さよりoffsetが長いとき、サイズエラーを起こす
442 throw (new DOMException(INDEX_SIZE_ERR));
444 this.deleteData(offset, count);
445 this.insertData(offset, arg);
454 Attr.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
455 Attr.constructor = Node;
456 Attr.prototype.nodeType = Node.ATTRIBUTE_NODE;
457 Attr.prototype.nodeValue = null;
464 this.attributes = new NamedNodeMap(); //属性を収納
467 Element.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
468 Element.constructor = Node;
469 Element.prototype.nodeType = Node.ELEMENT_NODE;
470 Element.prototype.nodeValue = null;
472 *名前空間に対応していないメソッドは、軽量化のため、機能させないようにする。代わりに、**NSメソッドを利用すること
473 *(getAttributeとsetAttributeは普及しているので機能させる
475 /*string*/ Element.prototype.getAttribute = function( /*string*/ name) {
476 return (this.getAttributeNS(null, name));
478 /*void*/ Element.prototype.setAttribute = function( /*string*/ name, /*string*/ value) {
479 this.setAttributeNS(null, name, value);
481 /*void*/ Element.prototype.removeAttribute = function( /*string*/ name) {
482 this.removeAttributeNS(null, name);
484 /*Attr*/ Element.prototype.getAttributeNode = function( /*string*/ name) {
486 /*Attr*/ Element.prototype.setAttributeNode = function( /*Attr*/ newAttr) {
488 /*Attr*/ Element.prototype.removeAttributeNode = function( /*Attr*/ oldAttr) {
489 var s = this.attributes.removeNamedItemNS(oldAttr.namespaceURI, oldAttr.localName); //attributesから該当するノードを排除
492 /*NodeList(Array)*/ Element.prototype.getElementsByTagName = function( /*string*/ name) {
494 /*string*/ Element.prototype.getAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
495 var n = this.getAttributeNodeNS(namespaceURI, localName); //属性ノードを取得する
499 return (n.nodeValue);
502 /*void*/ Element.prototype.setAttributeNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName, /*string*/ value) {
503 var atn = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
504 /*元来、string型以外の型を許容すべきではないが、他のブラウザ(FirefoxやOpera)でエラーが出ないため許容する*/
505 atn.nodeValue = value+"";
506 atn.value = value+"";
507 this.setAttributeNodeNS(atn);
509 /*void*/ Element.prototype.removeAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
511 /*Attr*/ Element.prototype.getAttributeNodeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
512 var s = this.attributes.getNamedItemNS(namespaceURI,localName);
515 /*NodeList(Array)*/ Element.prototype.getElementsByTagNameNS = function( /*string*/ namespaceURI, /*string*/ localName) {
517 var tno = this.childNodes;
518 for (var i=0,tcli = tno.length;i<tcli;i++) {
520 if (tnoi.nodeType === Node.ELEMENT_NODE) {
521 var ns = (namespaceURI === "*") ? tnoi.namespaceURI : namespaceURI;
522 var ln = (localName === "*") ? tnoi.localName : localName;
523 if((tnoi.namespaceURI === ns) && (tnoi.localName === ln)) {
526 var d = tnoi.getElementsByTagNameNS(namespaceURI, localName);
528 for (var j=0,dli=d.length;j<dli;++j) {
532 ns = ln = d = void 0;
535 tno = i = j = tcli = dli = void 0;
538 return null; //該当する要素なし
543 /*boolean*/ Element.prototype.hasAttribute = function( /*string*/ name) {
544 return (this.hasAttributeNS("http://www.w3.org/2000/svg", name));
546 /*boolean*/ Element.prototype.hasAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
547 if (this.getAttributeNodeNS(namespaceURI, localName)) { //ノードの取得に成功した場合
560 Text.prototype = new CharacterData(); //文字データのプロトタイプチェーンを作って、継承
561 Text.constructor = CharacterData;
562 Text.prototype.nodeType = Node.TEXT_NODE;
563 Text.prototype.nodeName = "#text";
564 /*Text*/ Text.prototype.splitText = function(/*long*/ offset) {
565 var pre = this.substringData(0, offset - 1); //このノードからoffsetまでの文字列を取り出して、
566 this.replaceData(0, this.length - 1, pre); //このノードの文字列と置き換える
568 if (this.length !== offset) { //このノードの文字列の長さがoffsetに等しくない場合
569 next = this.substringData(offset, this.length - 1); //文字列を取り出す。(等しい場合は文字列を取り出さない)
571 var nnode = this.ownerDocument.createTextNode(next);
572 if (this.parentNode) {
573 this.parentNode.insertBefore(nnode, this.nextSibling);
579 *コメントノード。<!-- --!>で表現される。削除不可。
584 Comment.prototype = new CharacterData(); //文字データのプロトタイプチェーンを作って、継承
585 Comment.constructor = CharacterData;
586 Comment.prototype.nodeType = Node.COMMENT_NODE;
587 Comment.prototype.nodeName = "#comment";
589 *CDATA領域を示すノード。<![CDATA[ ]]!>で表現される。削除不可。
591 function CDATASection() {
592 this.nodeType = Node.CDATA_SECTION_NODE;
593 this.nodeName = "#cdata-section";
596 CDATASection.prototype = new Text(); //テキストノードのプロトタイプチェーンを作って、継承
597 CDATASection.constructor = Text;
600 *DTD(文書型定義)の情報を取り扱うノード。DTDは<!DOCTYPE[ ]>で表現されうる。削除可
602 function DocumentType() {
605 this.entities = new NamedNodeMap(); //パラメタ実体を除く実体の集まり
606 this.notations = new NamedNodeMap(); //DTDで示した記法の集まり
607 this.publicId = ""; //外部サブセットの公開識別子
608 this.systemId = ""; //上同のシステム識別子
609 this.internalSubset = ""; //内部サブセットの内容(文字列)
610 this.nodeValue = null;
611 this.nodeType = Node.DOCUMENT_TYPE_NODE;
614 DocumentType.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
615 DocumentType.constructor = Node;
618 *DTDの記法の情報を取り扱うノード。<!NOTATION >か、処理命令で記法は表現されうる。削除可
620 function Notation() {
621 this.publicId = null;
622 this.systemId = null;
623 this.nodeValue = null;
624 this.nodeType = Node.NOTATION_NODE;
627 Notation.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
628 Notation.constructor = Node;
631 *以下のノードは、もし、DOMを展開する前に、XMLプロセッサが実体参照の読み込みを行うのであれば、文書中に挿入される必要はない。
637 this.publicId = null;
638 this.systemId = null;
639 this.notationName = null; //解析対象外実体のための記法名。解析対象実体ではnull
640 this.nodeValue = null;
641 this.nodeType = Node.ENTITY_NODE;
644 Entity.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
645 Entity.constructor = Node;
648 *実態参照の代わりに挿入されるノード。削除可
650 function EntityReference() {
651 this.nodeValue = null;
652 this.nodeType = Node.ENTITY_REFERENCE_NODE ;
655 EntityReference.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
656 EntityReference.constructor = Node;
658 /*ProcessingInstruction
659 *処理命令ノード。スタイルシート処理命令で使うので、削除不可
661 function ProcessingInstruction() {
662 this.nodeType = Node.PROCESSING_INSTRUCTION_NODE;
665 ProcessingInstruction.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
666 ProcessingInstruction.constructor = Node;
669 *複数のノードを移したりするのに便宜上、用いられる文書ノード。削除可
671 function DocumentFragment() {
672 this.nodeName = "#document-fragment";
673 this.nodeValue = null;
674 this.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
677 DocumentFragment.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
678 DocumentFragment.constructor = Node;
683 function Document() {
684 this.nodeName = "#document";
685 this.nodeValue = null;
686 this.nodeType = Node.DOCUMENT_NODE;
687 this._id = {}; //getElementByIdで使う
690 Document.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
691 Document.constructor = Node;
694 *名前空間に対応していないメソッドは、軽量化のため、機能させないようにする。代わりに、**NSメソッドを利用すること。
695 *また、createメソッドは工場メソッドである。クラス名をユーザから隠蔽するのに役に立つ。
696 *突然、クラス名が変更されても、ライブラリを利用したユーザは、コードを書き換える必要がないなどのメリットがある。
698 /*Element*/ Document.prototype.createElement = function( /*string*/ tagName) {
700 /*createDocumentFragmentメソッド
703 /*DocumentFragment*/ Document.prototype.createDocumentFragment = function() {
704 var s = new DocumentFragment();
705 s.ownerDocument = this;
711 /*Text*/ Document.prototype.createTextNode = function( /*string*/ data) {
713 s.data = s.nodeValue = data+"";
714 s.length = data.length;
715 s.ownerDocument = this;
721 /*Comment*/ Document.prototype.createComment = function( /*string*/ data) {
722 var s = new Comment();
723 s.data = s.nodeValue = data;
724 s.length = data.length;
725 s.ownerDocument = this;
728 /*createCDATASectionメソッド
731 /*CDATASection*/ Document.prototype.createCDATASection = function( /*string*/ data) {
732 var s = new CDATASection();
733 s.data = s.nodeValue = data;
734 s.length = data.length;
735 s.ownerDocument = this;
738 /*createProcessingInstructionメソッド
741 /*ProcessingInstruction*/ Document.prototype.createProcessingInstruction = function( /*string*/ target, /*string*/ data) {
742 var s = new ProcessingInstruction();
743 s.target = s.nodeName = target;
744 s.data = s.nodeValue = data;
745 s.ownerDocument = this;
749 *createAttributeNSを推奨
751 /*Attr*/ Document.prototype.createAttribute = function( /*string*/ name) {
753 /*createEntityReferenceメソッド
756 /*EntityReference*/ Document.prototype.createEntityReference = function( /*string*/ name) {
757 var s = new EntityReference();
759 s.ownerDocument = this;
762 /*getElementsByTagNameメソッド
763 *getElementsByTagNameNSを推奨
765 /*NodeList*/ Document.prototype.getElementsByTagName = function( /*string*/ tagname) {
768 *自身のドキュメントノードに、他のドキュメントノードから作られたノードを取り込みたいときに用いる
770 /*Node*/ Document.prototype.importNode = function( /*Node*/ importedNode, /*boolean*/ deep) {
772 imn = importedNode.nodeType,
773 attr, att, fi, n, uri, ch;
774 /*以下の処理は引き渡されたimportedNodeがMSXMLによって解析された
777 if (imn === /*Node.ELEMENT_NODE*/ 1) {
778 s = this.createElementNS(importedNode.namespaceURI, importedNode.nodeName);
779 attr = importedNode.attributes;
780 for (var i=0;attr[i];++i) { //NamedNodeMapを検索する
782 uri = ch.namespaceURI;
783 uri = (uri === "") ? null : uri; //空文字列はnullとして扱うようにする(MSXMLが空文字列を返す時の対策)
784 att = this.createAttributeNS(uri, ch.nodeName);
785 att.nodeValue = ch.nodeValue;
786 s.setAttributeNodeNS(att);
789 fi = importedNode.firstChild;
790 while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
791 n = this.importNode(fi, true);
797 } else if(imn === /*Node.TEXT_NODE*/ 3) {
798 s = this.createTextNode(importedNode.data);
799 } else if(imn === /*Node.ATTRIBUTE_NODE*/ 2) {
800 uri = importedNode.namespaceURI;
801 uri = (uri === "") ? null : uri; //空文字列はnullとして扱うようにする(MSXMLが空文字列を返す時の対策)
802 s = this.createAttributeNS(uri, importedNode.nodeName);
803 s.nodeValue = importedNode.nodeValue;
804 } else if(imn === /*Node.COMMENT_NODE*/ 8) {
805 s = this.createComment(importedNode.data);
806 } else if(imn === Node.DOCUMENT_FRAGMENT_NODE) {
807 s = this.createDocumentFragment();
809 ch = importedNode.childNodes;
810 for (var i=0,chli=ch.length;i<chli;i++) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
811 n = this.importNode(ch[i], true);
816 } else if(imn === Node.CDATA_SECTION_NODE) {
817 s = this.createCDATASection(importedNode.data);
818 } else if(imn === Node.ENTITY_REFERENCE_NODE) {
819 s = this.createEntityReference(importedNode.nodeName);
821 fi = importedNode.firstChild;
823 n = this.importNode(fi, true);
828 } else if(imn === Node.ENTITY_NODE) {
830 s.publicId = importedNode.publicId;
831 s.systemId = importedNode.systemId;
832 s.notationName = importedNode.notationName;
833 } else if(imn === Node.PROCESSING_INSTRUCTION_NODE ) {
834 s = this.createProcessingInstruction(importedNode.nodeName, importedNode.nodeValue)
835 } else if(imn === Node.NOTATION_NODE) {
837 s.publicId = importedNode.publicId;
838 s.systemId = importedNode.systemId;
840 throw (new DOMException(DOMException.NOT_SUPPORTED_ERR));
842 importedNode = deep = imn = attr = att = fi = n = uri = ch = void 0;
845 /*createElementNSメソッド
847 *例:var s = DOC.createElementNS("http://www.w3.org/2000/svg", "svg:svg");
849 /*Element*/ Document.prototype.createElementNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName) {
853 if (!qualifiedName) {
854 throw (new DOMException(DOMException.INVALID_CHARACTER_ERR));
856 if (qualifiedName.indexOf(":") !== -1){
857 var p = qualifiedName.split(":");
861 localName = qualifiedName;
863 var isSpecified = false;
865 var ti = this.implementation;
866 if (!!ti[namespaceURI]) {
867 if (!!ti[namespaceURI][localName]) { //もし、名前空間とローカル名によって、オブジェクトがあった場合
873 ele = new (ti[namespaceURI][localName])(this._document_);
877 ele.namespaceURI = namespaceURI;
878 ele.nodeName = ele.tagName = qualifiedName;
879 ele.localName = localName;
881 ele.ownerDocument = this;
882 ti = namespaceURI = qualifiedName = prefix = localName = isSpecified = void 0;
885 Document.prototype._document_ = document
886 /*createAttributeNSメソッド
887 *属性ノードを作る。setAttributeNSで使うため、削除不可
889 /*Attr*/ Document.prototype.createAttributeNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName) {
890 var attr = new Attr(),
892 attr.namespaceURI = namespaceURI;
893 attr.nodeName = attr.name = qualifiedName;
894 if (qualifiedName.indexOf(":") !== -1){
895 p = qualifiedName.split(":");
897 attr.localName = p[1];
900 attr.localName = qualifiedName;
902 attr.ownerDocument = this;
903 p = qualifiedName = void 0;
906 /*getElementsByTagNameNSメソッド
907 *タグ名と名前空間URIを元に、要素ノード達を取得
909 /*NodeList*/ Document.prototype.getElementsByTagNameNS = function(/*string*/ namespaceURI, /*string*/ localName) {
910 var NodeList = this.documentElement.getElementsByTagNameNS(namespaceURI, localName);
916 /*Element*/ Document.prototype.getElementById = function( /*string*/ elementId) {
917 var s = !!this._id[elementId] ? this._id[elementId] : null;
922 #endif // _DOM_IDL_*/
924 //以下は例外処理のログをとるためのもの。開発者以外は削除すること
925 function STLog(jou) {
928 this.p = document.createElement("div");
929 this.p.innerHTML = "<h1>例外処理のログ</h1>";
930 document.body.insertBefore(this.p,document.body.firstChild);
934 STLog.prototype.add = function(e,code) {
936 this.p.innerHTML += "<p>"+code+":"+e.message+"</p>";
941 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.idl
949 #pragma prefix "dom.w3c.org"
953 typedef dom::DOMString DOMString;
954 typedef dom::DOMTimeStamp DOMTimeStamp;
955 typedef dom::Node Node;
957 interface EventListener;
963 function EventException() {
964 DOMException.call(this,arguments);
965 if (this.code === 0) {
966 this.message = "Uuspecified Event Type Error";
970 /*unsigned short*/ EventException.UNSPECIFIED_EVENT_TYPE_ERR = 0;
972 EventException.prototype = new DOMException();
975 /* // Introduced in DOM Level 2:
976 interface EventTarget {*/
977 /*void*/ Node.prototype.addEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
978 this.removeEventListener(type, listener, useCapture); //いったん、(あれば)リスナーを離す。
979 var s = new EventListener(useCapture, type, listener), //リスナーを作成
982 this._capter.push(s); //このノードにリスナーを登録しておく
983 if ((t !== "D") && (t !== "S") && (type !== "beginEvent") && (type !== "endEvent") && (type !== "repeatEvent")) { //MouseEventsならば
985 that._tar && that._tar.attachEvent("on" +type, (function(node, type) {
987 var evt = node.ownerDocument.createEvent("MouseEvents");
988 evt.initMouseEvent(type, true, true, node.ownerDocument.defaultView, 0);
989 node.dispatchEvent(evt);
990 /*cancelBubbleプロパティについては、IEのMSDNなどを参照*/
991 node.ownerDocument._window.event.cancelBubble = true;
997 type = listener = useCapture = s = t = that = void 0;
999 /*void*/ Node.prototype.removeEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
1000 var tce = this._capter;
1001 for (var i=0,tcli=tce.length;i<tcli;i++){
1002 if (tce[i]._listener === listener) { //登録したリスナーと一致すれば
1006 i = tcli = tce = void 0;
1008 /*boolean*/ Node.prototype.dispatchEvent = function( /*Event*/ evt) {
1009 if (!evt.type) { //Eventの型が設定されていないとき
1010 throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR);
1013 td = te.ownerDocument,
1014 etime = evt.timeStamp,
1019 type = /*Event.CAPTURING_PHASE*/ 1,
1020 ecptype = /*Event.CAPTURING_PHASE*/ "1",
1021 ebptype = /*Event.BUBBLING_PHASE*/ "3",
1023 if (!td._isLoaded) {
1024 /*以下では、画像の処理に時間がかかりそうな場合、処理落ちとして、遅延処理
1025 *を行い、バッファリングにイベント送付処理をためていく作業となる
1027 if (!td._limit_time_) {
1028 td._limit_time_ = etime;
1029 } else if ((etime - td._limit_time_) > 1000) {
1030 /*1秒を超えたらバッファにため込んで後で使う*/
1031 tob = td.implementation._buffer_ || [];
1035 td.implementation._buffer_ = tob;
1036 te = td = etime = etype = ebub = tob = toli = type = void 0;
1041 evt.eventPhase = 1;//Event.CAPTURING_PHASE
1042 //このノードからドキュメントノードにいたるまでの、DOMツリーのリストを作成しておく
1044 /*以下の処理では、documentElementのparentNodeが
1045 *Documentノードではなく、nullになっていることを前提としている。
1046 *したがって、documentElementのparentNodeがもし、Documentノードのオブジェクトならば、以下を書き換えるべきである
1048 while (te.parentNode) {
1049 te.parentNode[ecptype] = te;
1050 te[ebptype] = te.parentNode;
1055 /*最初に捕獲フェーズでDOMツリーを下っていき、イベントのターゲットについたら、
1056 *そこで、浮上フェーズとして折り返すように、反復処理をおこなう。
1060 evt.currentTarget = td;
1061 if (td === te) { //イベントのターゲットに到着(折り返し地点)
1062 type = 2;//Event.AT_TARGET;
1064 evt.eventPhase = type;
1065 tce = td._capter; //tceは登録しておいたリスナーのリスト
1066 for (var j=0,tcli=tce.length;j<tcli;++j){
1067 if (tce[j] && (etype === tce[j]._type)) {
1068 tce[j].handleEvent(evt);
1072 break; //stopPropagationメソッドが呼ばれたら、停止する
1076 break; //浮上フェーズに移行せず、停止する
1078 type = 3;//Event.BUBBLING_PHASE;
1082 var ed = evt._default;
1083 evt = te = tce = n = td = type = tob = j = tcli = etype = etime = ebub = ecptype = ebptype = void 0;
1087 function EventListener(cap,type,listener) {
1090 this._listener = listener;
1094 EventListener.prototype = {
1095 /*void*/ handleEvent : function( /*Event*/ evt) {
1097 var ph = evt.eventPhase,
1099 if (ph === /*Event.CAPTURING_PHASE*/ 1) { //イベントフェーズが捕獲段階であることを示し
1100 cap = cap ? false : true; //このオブジェクト(EventListenr)が捕獲フェーズを指定するならば、リスナーを作動させる。指定しなければ、作動しない。
1102 if (!cap && (evt.type === this._type)) {
1103 this._listener(evt);
1105 evt = ph = cap = void 0;
1113 *イベントの雛形となる。プロパティもすべて含めて、必須
1119 /*unsigned short*/ Event.CAPTURING_PHASE = 1;
1120 /*unsigned short*/ Event.AT_TARGET = 2;
1121 /*unsigned short*/ Event.BUBBLING_PHASE = 3;
1123 /*DOMTimeStamp*/ timeStamp : 0,
1124 /*DOMString*/ type : null,
1125 /*EventTarget*/ target : null,
1126 /*EventTarget*/ currentTarget : null,
1127 /*unsigned short*/ eventPhase : Event.CAPTURING_PHASE,
1128 /*boolean*/ bubbles : false,
1129 /*boolean*/ cancelable : false,
1130 _stop : false, //stopPropagationメソッドで使う
1131 _default : true, //preventDefaultメソッドで使う
1132 /*void*/ stopPropagation : function(){
1135 /*void*/ preventDefault : function(){
1136 if (this.cancelable) {
1137 this._default = false;
1138 /*IEのみで使えるreturnValueプロパティ*/
1139 this.target.ownerDocument._window.event.returnValue = false;
1142 /*void*/ initEvent : function( /*string*/ eventTypeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg) {
1143 this.type = eventTypeArg;
1144 this.bubbles = canBubbleArg;
1145 this.cancelable = cancelableArg;
1146 eventTypeArg = canBubbleArg = cancelableArg = void 0;
1149 /*Documentノードに直接結びつける
1150 function DocumentEvent() {
1153 /*Event*/ Document.prototype.createEvent = function( /*string*/ eventType) {
1155 tc = this._cevent[eventType];
1158 } else if (eventType === "SVGEvents") {
1159 evt = new SVGEvent();
1160 } else if (eventType === "TimeEvents") {
1161 evt = new TimeEvent();
1165 evt.type = eventType;
1166 evt.timeStamp = +(new Date());
1171 function UIEvent() {
1172 /*views::AbstractView*/ this.view;
1173 /*long*/ this.detail = 0;
1177 UIEvent.prototype = new Event();
1178 /*void*/ UIEvent.prototype.initUIEvent = function( /*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*views::AbstractView*/ viewArg, /*long*/ detailArg) {
1179 this.initEvent(typeArg, canBubbleArg, cancelableArg);
1180 this.detail = detailArg;
1181 this.view = viewArg;
1183 function MouseEvent(evt) {
1184 UIEvent.call(this, arguments);
1185 /*long*/ this.screenX;
1186 /*long*/ this.screenY;
1187 /*long*/ this.clientX = this.clientY = 0;
1188 /*boolean*/ this.ctrlKey = this.shiftKey = this.altKey = this.metaKey = false;
1189 /*unsigned short*/ this.button;
1190 /*EventTarget*/ this.relatedTarget;
1193 MouseEvent.prototype = new UIEvent();
1194 /*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) {
1195 this.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
1196 this.screenX = screenXArg;
1197 this.screenY = screenYArg;
1198 this.clientX = clientXArg;
1199 this.clientY = clientYArg;
1200 this.ctrlKey = ctrlKeyArg;
1201 this.shiftKey = shiftKeyArg;
1202 this.altKey = altKeyArg;
1203 this.metaKey = metaKeyArg;
1204 this.button = buttonArg;
1205 this.relatedTarget = relatedTargetArg;
1208 function MutationEvent(){
1211 MutationEvent.prototype = new Event();
1213 /*void*/ this.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg,
1214 /*boolean*/ cancelableArg, /*Node*/ relatedNodeArg, /*string*/ prevValueArg, /*string*/ newValueArg,
1215 /*string*/ attrNameArg, /*unsigned short*/ attrChangeArg) {
1216 this.initEvent(typeArg, canBubbleArg, cancelableArg);
1217 this.relatedNode = relatedNodeArg;
1218 this.prevValue = prevValueArg;
1219 this.newValue = newValueArg;
1220 this.attrName = attrNameArg;
1221 this.attrChange = attrChangeArg;
1222 typeArg = canBubbleArg = cancelableArg = relatedNodeArg = prevValueArg = newValueArg = attrNameArg = attrChangeArg = void 0;
1224 /*Node*/ this.relatedNode = null;
1225 /*string*/ this.prevValue = this.newValue = this.attrName = null;
1226 /*unsigned short*/ this.attrChange = 2;
1227 }).apply(MutationEvent.prototype);
1229 /*unsigned short*/ MutationEvent.MODIFICATION = 1;
1230 /*unsigned short*/ MutationEvent.ADDITION = 2;
1231 /*unsigned short*/ MutationEvent.REMOVAL = 3;
1233 /*MutationEventsの発動のために、setAttributeNodeNSを上書きする。ファイル統合やmakeの際は、
1234 *重複するのでコアモジュールのメソッドは削除する。モジュールテストを行うために、
1235 *このような形式をとることにする。なお、追加部分には区別を付けるために、前後にコメントを挿入する。
1237 /*Attr*/ Element.prototype.setAttributeNodeNS = function( /*Attr*/ newAttr){
1238 if (newAttr.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1239 throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1241 var s = this.attributes.setNamedItemNS(newAttr);
1242 newAttr.ownerElement = this;
1243 if (newAttr.localName === "id") { //id属性であったならば
1244 this.ownerDocument._id[newAttr.nodeValue] = this; //ドキュメントに登録しておく
1247 var evt = this.ownerDocument.createEvent("MutationEvents");
1248 if (!s) { //ノードがなければ
1249 /*initMutationEventメソッドは軽量化のため省略する*/
1250 evt.initEvent("DOMAttrModified", true, false);
1251 evt.relatedNode = newAttr;
1252 evt.newValue = newAttr.nodeValue;
1253 evt.attrName = newAttr.nodeName;
1255 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, s.nodeValue, newAttr.nodeValue, newAttr.nodeName, MutationEvent.MODIFICATION);
1257 this.dispatchEvent(evt); //このとき、MutationEventsが発動
1263 /*Node*/ Node.prototype.insertBefore = function( /*Node*/ n, ref) {
1264 var tp = this.parentNode,
1269 while (!tp) { //先祖をたどっていく
1270 if (tp === n) { //先祖要素が追加ノードならばエラー
1271 throw (new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
1276 if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
1277 throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1279 if (n.parentNode === this) { //入力した要素が子要素ならば
1280 this.removeChild(n);
1282 if (!ref) { //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
1283 this.childNodes[this.childNodes.length] = n;
1284 if (this.lastChild) {
1285 n.previousSibling = this.lastChild;
1286 this.lastChild.nextSibling = n;
1289 if (ref.parentNode !== this) { //参照ノードが子要素でない場合
1290 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1292 this.childNodes.splice(ref._num,1,n,ref); //Arrayのspliceを利用して、リストにnノードを追加
1293 rp = ref.previousSibling;
1297 ref.previousSibling = n;
1299 n.nextSibling = ref;
1300 this.firstChild = this.childNodes[0];
1301 this.lastChild = this.childNodes[this.childNodes.length-1];
1302 n.parentNode = this;
1303 if ((n.nodeType===/*Node.ENTITY_REFERENCE_NODE*/ 5) || (n.nodeType===/*Node.DOCUMENT_FRAGMENT_NODE*/ 11)) {
1304 /*実体参照や、文書フラグメントノードだけは子ノードを検索して、
1305 *それらを直接文書に埋め込む作業を以下で行う
1307 var ch = n.childNodes.concat([]); //Arrayのコピー
1308 for (var i=0,chli=ch.length;i<chli;i++) {
1309 this.insertBefore(ch[i], n);
1314 evt = this.ownerDocument.createEvent("MutationEvents");
1315 evt.initMutationEvent("DOMNodeInserted", true, false, this, null, null, null, null);
1316 n.dispatchEvent(evt);
1317 /*以下のDOMNodeInsertedIntoDocumentイベントは、間接的、あるいは直接ノードが
1318 *挿入されたときに発火する。間接的な挿入とは、サブツリーを作っておいて、それをいっぺんに挿入する場合など。
1319 *このイベントは浮上しないことに注意を要する
1325 if (s !== this.ownerDocument.documentElement) {
1329 evt = this.ownerDocument.createEvent("MutationEvents");
1330 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1331 n.dispatchEvent(evt);
1332 if (!n.hasChildNodes()) { //子ノードがないので終了
1335 if (n.getElementsByTagNameNS) {
1336 descend = n.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1338 descend = n.childNodes;
1341 for (var i=0,dli=descend.length;i<dli;++i) {
1343 di.dispatchEvent(evt);
1347 evt = descend = void 0;
1348 tp = rp = te = s = di = void 0;
1352 /*Node*/ Node.prototype.removeChild = function( /*Node*/ ele) {
1353 if (!(ele instanceof Node)) { //Nodeでなければ
1354 throw (new Error());
1357 var evt = this.ownerDocument.createEvent("MutationEvents"),
1359 /*以下のDOMNodeRemovedFromDocumentイベントは、間接的、あるいは直接ノードが
1360 *除去されたときに発火する。間接的な除去とは、サブツリーをいっぺんに除去する場合など。
1361 *このイベントは浮上しないことに注意を要する
1363 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1364 ele.dispatchEvent(evt);
1365 if (ele.getElementsByTagNameNS) {
1366 descend = ele.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1368 descend = ele.childNodes;
1371 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1372 for (var i=0,dli=descend.length;i<dli;++i) {
1373 var di = descend[i];
1375 di.dispatchEvent(evt);
1379 evt.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null);
1380 ele.dispatchEvent(evt);
1381 evt = descend = void 0;
1383 if (ele.parentNode === this) {
1384 this.childNodes.splice(ele._num,1); //Arrayのspliceを利用して、リストからeleノードを排除
1386 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1388 if (ele.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1389 throw (new Error());
1394 /*void*/ CharacterData.prototype.appendData = function( /*string*/ arg) {
1398 this.length = this.data.length;
1400 evt = this.ownerDocument.createEvent("MutationEvents");
1401 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1402 this.parentNode.dispatchEvent(evt);
1403 evt = arg = pd = void 0;
1406 /*void*/ CharacterData.prototype.insertData = function( /*long*/ offset, /*string*/ arg) {
1408 pre = this.substring(0, offset - 1), //文字列を二つに分けた、前半部分
1409 next = this.substring(offset, this.length - offset), //後半部分
1411 this.data = pre + this.data + next;
1412 this.length = this.data.length;
1414 evt = this.ownerDocument.createEvent("MutationEvents");
1415 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1416 this.parentNode.dispatchEvent(evt);
1417 evt = arg = pd = pre = next = void 0;
1420 /*void*/ CharacterData.prototype.deleteData = function( /*long*/ offset, /*long*/ count) {
1422 pre = this.substring(0, offset - 1), //残すべき前半部分
1423 next = this.substring(offset + count, this.length - 1), //後半部分
1425 if (offset + count > this.length) { //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを削除
1428 this.data = pre + next;
1429 this.length = this.data.length;
1431 evt = this.ownerDocument.createEvent("MutationEvents");
1432 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1433 this.parentNode.dispatchEvent(evt);
1438 /*_ceventプロパティはcreateEventメソッドで軽量化のために使う。*/
1439 Document.prototype._cevent = {
1440 "MutationEvents" : MutationEvent,
1441 "MouseEvents" : MouseEvent,
1442 "UIEvents" : UIEvent
1449 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.idl
1451 #ifndef _STYLESHEETS_IDL_
1452 #define _STYLESHEETS_IDL_
1456 #pragma prefix "dom.w3c.org"
1460 typedef dom::DOMString DOMString;
1461 typedef dom::Node Node;
1467 function StyleSheet() {
1468 this.type = "text/css";
1469 this.disabled = false;
1470 /*Node*/ this.ownerNode = null;
1471 /*StyleSheet*/ this.parentStyleSheet = null;
1474 /*MediaList*/ this.media = new MediaList();
1479 *このインターフェースはArrayで代用する
1480 function StyleSheetList() {
1481 readonly attribute unsigned long length;
1482 StyleSheet item(in unsigned long index);
1486 function MediaList() {
1487 this.mediaText = "";
1491 MediaList.prototype = {
1492 /*string*/ item : function(/*long*/ index) {
1493 return (this[index]);
1495 /*void*/ deleteMedium : function(/*string*/ oldMedium) {
1496 for (var i=0,tli=this.length;i<tli;++i) {
1497 if (this[i] === oldMedium) {
1503 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1505 /*void*/ appendMedium : function(/*string*/ newMedium) {
1506 this[this.length] = newMedium;
1511 function LinkStyle() {
1512 /*StyleSheet*/ this.sheet = new StyleSheet();
1516 function DocumentStyle() {
1517 /*StyleSheetList*/ this.styleSheets = [];
1521 #endif // _STYLESHEETS_IDL_
1524 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.idl
1530 #include "stylesheets.idl"
1531 #include "views.idl"
1533 #pragma prefix "dom.w3c.org"
1537 typedef dom::DOMString DOMString;
1538 typedef dom::Element Element;
1539 typedef dom::DOMImplementation DOMImplementation;
1542 interface CSSStyleSheet;
1543 interface CSSStyleDeclaration;
1551 function CSSRuleList {
1552 readonly attribute unsigned long length;
1553 CSSRule item(in unsigned long index);
1557 *CSSのルールを表現する。基底クラスなので削除不可。
1559 function CSSRule() {
1561 /*CSSStyleSheet*/ this.parentStyleSheet;
1562 /*CSSRule*/ this.parentRule = null;
1566 CSSRule.UNKNOWN_RULE = 0;
1567 CSSRule.STYLE_RULE = 1;
1568 CSSRule.CHARSET_RULE = 2;
1569 CSSRule.IMPORT_RULE = 3;
1570 CSSRule.MEDIA_RULE = 4;
1571 CSSRule.FONT_FACE_RULE = 5;
1572 CSSRule.PAGE_RULE = 6;
1574 function CSSStyleRule() {
1575 CSSRule.call(this, arguments);
1576 this.type = CSSRule.STYLE_RULE;
1577 this.selectorText = "";
1578 /*CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
1579 this.style.parentRule = null;
1582 CSSStyleRule.prototype = new CSSRule();
1584 function CSSMediaRule() {
1585 CSSRule.call(this, arguments);
1586 this.type = CSSRule.MEDIA_RULE;
1587 /*stylesheets::MediaList*/ this.media = new MediaList();
1588 /*CSSRuleList*/ this.cssRules = [];
1591 CSSMediaRule.prototype = new CSSRule();
1592 /*long*/ CSSMediaRule.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
1593 this.cssRules.splice(index,rule,1);
1594 this.media.appendMedium(rule);
1597 /*void*/ CSSMediaRule.prototype.deleteRule = function( /*long*/ index) {
1600 function CSSFontFaceRule() {
1601 CSSRule.call(this, arguments);
1602 this.type = CSSRule.FONT_FACE_RULE;
1603 /*CSSStyleDeclaration*/ this.style;
1606 CSSFontFaceRule.prototype = new CSSRule();
1608 function CSSPageRule() {
1609 CSSRule.call(this, arguments);
1610 this.type = CSSRule.PAGE_RULE;
1611 this.selectorText = "";
1612 /*CSSStyleDeclaration*/ this.style;
1615 CSSPageRule.prototype = new CSSRule();
1617 function CSSImportRule() {
1618 CSSRule.call(this, arguments);
1619 this.type = CSSRule.IMPORT_RULE;
1621 /*stylesheets::MediaList*/ this.media = new MediaList();
1622 /*CSSStyleSheet*/ this.styleSheet = null;
1625 CSSImportRule.prototype = new CSSRule();
1627 function CSSCharsetRule() {
1628 CSSRule.call(this, arguments);
1629 this.type = CSSRule.CHARSET_RULE;
1633 CSSCharsetRule.prototype = new CSSRule();
1635 function CSSUnknownRule() {
1636 CSSRule.call(this, arguments);
1637 this.type = CSSRule.UNKNOWN_RULE;
1640 CSSUnknownRule.prototype = new CSSRule();
1642 /*CSSStyleDeclaration
1643 *CSSの宣言ブロックを表現。削除不可。
1645 function CSSStyleDeclaration() {
1646 this._list = []; //内部のリスト
1647 this._list._fontSize = this._list._opacity = null;
1650 CSSStyleDeclaration.prototype = {
1652 /*long*/ length : 0,
1653 /*CSSRule*/ parentRule : null,
1654 _urlreg : /url\(#([^)]+)/,
1655 /*getPropertyValueメソッド
1656 *CSSの値を返す。この値は継承ではなくて、明示的に表記されているもの
1658 /*string*/ getPropertyValue : function( /*string*/ propertyName) {
1659 var tg = this.getPropertyCSSValue(propertyName);
1661 var tc = tg.cssText;
1662 return (tc.slice(tc.indexOf(":")+1));
1667 /*getPropertyCSSValueメソッド
1668 *CSSValueオブジェクトを返す。このメソッドは判別に用いているので、削除不可。
1670 /*CSSValue*/ getPropertyCSSValue : function( /*string*/ propertyName) {
1671 var prop = propertyName,
1673 propertyName += ":";
1674 if (propertyName === ":") { //どんなデータ型でも、文字列に変換する機能をJavaScriptが持つことに注意
1677 for (var i=0,tl=this._list,tli=tl.length;i<tli;++i) {
1680 if (tc.indexOf(propertyName) > -1) { //プロパティ名に合致するCSSValueオブジェクトが見つかった場合
1681 ti._empercents = tl._fontSize;
1682 i = tl = tli = tc = prop = propertyName = void 0;
1686 i = tl = tli = prop = propertyName = void 0;
1689 /*removePropertyメソッド
1692 /*string*/ removeProperty : function( /*string*/ propertyName) {
1693 var tg = this.getPropertyCSSValue(propertyName);
1695 this._list.splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
1699 /*getPropertyPriorityメソッド
1700 *importantなどのpriorityを取得する
1702 /*string*/ getPropertyPriority : function( /*string*/ propertyName) {
1703 var tg = this.getPropertyCSSValue(propertyName);
1705 return (tg._priority);
1725 *プロパティを宣言内で、明示的に設定。継承は無視する
1727 /*void*/ setProperty : function( /*string*/ propertyName, /*string*/ value, /*string*/ priority) {
1728 var cssText = propertyName,
1734 if (!!this[propertyName]) {
1735 tg = this.getPropertyCSSValue(propertyName);
1739 if (this._isFillStroke[propertyName]) {
1740 /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
1741 *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
1746 ti = new SVGPaint();
1748 paintType = /*SVGPaint.SVG_PAINTTYPE_UNKNOWN*/ 0;
1749 v1 = value.charAt(0);
1750 if (this._isRS[v1] || ti._keywords[value]) {
1751 paintType = /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1;
1753 } else if (value === "none") {
1754 paintType = /*SVGPaint.SVG_PAINTTYPE_NONE*/ 101;
1755 } else if (this._urlreg.test(value)) { //fill属性の値がurl(#id)ならば
1756 paintType = /*SVGPaint.SVG_PAINTTYPE_URI*/ 107;
1758 } else if (value === "currentColor") {
1759 paintType = /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102;
1761 ti.setPaint(paintType, uri, color, null);
1762 paintType = v1 = uri = color = void 0;
1763 } else if (this._isStop[propertyName]) {
1767 ti = new SVGColor();
1769 if (value === "currentColor") {
1770 ti.colorType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
1772 ti.colorType = /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1;
1774 ti.setRGBColor(value);
1779 ti = new CSSPrimitiveValue();
1782 ti._priority = priority;
1783 ti.cssText = cssText;
1785 //_numプロパティはremovePropertyメソッドで利用する
1786 ti._num = this._list.length;
1787 this._list[ti._num] = ti;
1788 this[propertyName] = 1;
1791 if (value === "inherit") {
1792 ti.cssValueType = CSSValue.CSS_INHERIT;
1793 } else if (propertyName === "opacity") {
1794 this._list._opacity = +value;
1795 } else if (propertyName === "font-size") {
1796 if (/(%|em|ex)/.test(value)) {
1798 ti[tg] = parseFloat(value);
1800 this._em = this._ex = this["_%"] = null;
1801 this._list._fontSize = parseFloat(value);
1807 *リストの位置にあるプロパティ名を取得する。宣言内のすべてのプロパティ名を取得するのに便利
1809 /*string*/ item : function( /*long*/ index) {
1810 if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
1813 var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
1819 function CSSValue() {
1823 CSSValue.CSS_INHERIT = 0;
1824 CSSValue.CSS_PRIMITIVE_VALUE = 1;
1825 CSSValue.CSS_VALUE_LIST = 2;
1826 CSSValue.CSS_CUSTOM = 3;
1827 CSSValue.prototype = {
1829 cssValueType : CSSValue.CSS_CUSTOM,
1830 _isDefault : 0 //デフォルトであるかどうか(独自のプロパティ)
1833 function CSSPrimitiveValue() {
1840 t.CSS_PERCENTAGE = 2;
1856 t.CSS_DIMENSION = 18;
1863 t.CSS_RGBCOLOR = 25;
1864 t.prototype = new CSSValue();
1865 })(CSSPrimitiveValue);
1868 this._n = [1, 0.01, 1, 1, 1, 35.43307, 3.543307, 90, 1.25, 15, 1, 180 / Math.PI, 90/100, 1, 1000, 1, 1000, 1]; //CSS_PX単位への変換値(なお、CSS_SはCSS_MSに、CSS_RADとCSS_GRADはCSS_DEGに、CSS_KHZはCSS_HZに統一)
1869 this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
1870 this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
1872 this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
1873 this._empercent = 0;
1874 this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う
1875 /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
1876 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1877 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1879 this.primitiveType = unitType;
1880 this._value = floatValue * this._n[unitType-1]; //値はあらかじめ、利用しやすいように変換しておく
1885 this._regd = /[\d\.]+/;
1886 /*float*/ this.getFloatValue = function(/*short*/ unitType) {
1887 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1888 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1890 if (this._value || (this._value === 0)) { //すでに、setFloatValueメソッドによって_valueプロパティが設定されていた場合
1891 return (this._value / this._n[unitType-1]);
1893 var tc = this.cssText,
1896 s = +(tc.match(this._regd));
1897 s = isNaN(s) ? 0 : s;
1898 if (n >= "0" && n <= "9") {
1899 type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
1900 if (unitType === 1) {
1901 unitType = tc = n = type = void 0;
1904 } else if (n === "%") {
1906 type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
1907 } else if ((n === "m") && (tc.charAt(tc.length-2) === "e")) {
1908 s *= this._empercent;
1909 type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
1910 } else if ((n === "x") && (tc.charAt(tc.length-2) === "e")) {
1911 type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
1912 } else if ((n === "x") && (tc.charAt(tc.length-2) === "p")) {
1913 type = /*CSSPrimitiveValue.CSS_PX*/ 5;
1914 } else if ((n === "m") && (tc.charAt(tc.length-2) === "c")) {
1915 type = /*CSSPrimitiveValue.CSS_CM*/ 6;
1916 } else if ((n === "m") && (tc.charAt(tc.length-2) === "m")) {
1917 type = /*CSSPrimitiveValue.CSS_MM*/ 7;
1918 } else if (n === "n") {
1919 type = /*CSSPrimitiveValue.CSS_IN*/ 8;
1920 } else if (n === "t") {
1921 type = /*CSSPrimitiveValue.CSS_PT*/ 9;
1922 } else if (n === "c") {
1923 type = /*CSSPrimitiveValue.CSS_PC*/ 10;
1925 s = s * this._n[type-1] / this._n[unitType-1];
1926 tc = n = type = unitType = void 0;
1930 /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
1931 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1932 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1934 this._value = stringValue;
1936 /*string*/ this.getStringValue = function(/*short*/ stringType) {
1937 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1938 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1940 return (this._value);
1942 /*Counter*/ this.getCounterValue = function() {
1943 if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
1944 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1946 return (new Counter());
1948 /*Rect*/ this.getRectValue = function() {
1949 if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
1950 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1952 return (new Rect());
1954 /*RGBColor*/ this.getRGBColorValue = function() {
1955 if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
1956 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1958 var s = new RGBColor();
1959 var rgbColor = this.cssText;
1960 var tkr = SVGColor.prototype._keywords[rgbColor];
1961 if (tkr !== void 0) {
1964 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
1965 rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
1966 return Math.round((2.55 * parseFloat(t)));
1968 } else if (rgbColor.indexOf("#") > -1) { //#を含む場合
1969 rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
1970 return parseInt(s, 16);
1973 var n = rgbColor.match(/\d+/g);
1974 s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
1975 s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
1976 s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
1977 n = rgbColor = void 0;
1980 }).apply(CSSPrimitiveValue.prototype);
1984 function CSSValueList() {
1985 this.cssValueType = CSSValue.CSS_VALUE_LIST;
1989 CSSValueList.prototype = new CSSValue();
1990 /*CSSValue*/ CSSValueList.prototype.item = function( /*long*/ index) {
1991 return (this[index]);
1994 function RGBColor() {
1995 var cs = CSSPrimitiveValue;
1996 this.red = new cs();
1997 this.green = new cs();
1998 this.blue = new cs();
2000 this.red.primitiveType = this.green.primitiveType = this.blue.primitiveType = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2005 var cs = CSSPrimitiveValue;
2006 this.top = new cs();
2007 this.right = new cs();
2008 this.bottom = new cs();
2009 this.left = new cs();
2014 function Counter() {
2015 this.identifier = this.listStyle = this.separator = "";
2019 function ElementCSSInlineStyle() {
2020 var cs = CSSStyleDeclaration;
2021 this.style = new cs();
2022 this._attributeStyle = new cs(); //プレゼンテーション属性の値を格納する
2038 visibility : "visible",
2039 display : "inline-block",
2043 strokeDasharray : n,
2044 strokeDashoffset : "0",
2045 strokeLinecap : "butt",
2046 strokeLinejoin : "miter",
2047 strokeMiterlimit : "4",
2048 strokeOpacity : "1",
2049 writingMode : "lr-tb",
2050 fontFamily : "serif",
2060 //# Gradient properties:
2062 stopColor : "black",
2064 textAnchor : "start",
2066 // raises(dom::DOMException) on setting
2067 //簡略プロパティに関しては、初期値を再考せよ
2072 overflow : "visible",
2079 verticalAlign : "baseline",
2087 //# Filter Effects properties:
2089 enableBackground : "accumulate",
2091 floodColor : "black",
2093 lightingColor : "white",
2095 //# Interactivity properties:
2097 pointerEvents : "visiblePainted",
2099 //# Color and Painting properties:
2101 colorInterpolation : "sRGB",
2102 colorInterpolationFilters : "linearRGB",
2113 //# Text properties:
2115 alignmentBaseline : "",
2116 baselineShift : "baseline",
2117 dominantBaseline : a,
2118 glyphOrientationHorizontal : "0deg",
2119 glyphOrientationVertical : a,
2121 fillRule : "nonzero"
2124 CSS2Properties.visibility._n = 1; //初期値の設定(_setPaintで使う)
2126 function CSSStyleSheet() {
2127 /*CSSRule*/ this.ownerRule = null;
2128 /*CSSRuleList*/ this.cssRules = [];
2131 CSSStyleSheet.prototype = new StyleSheet();
2132 /*long*/ CSSStyleSheet.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
2133 var s = new CSSStyleRule(), style = s.style, a, sc = rule.match(/\{[\s\S]+\}/), m;
2134 s.parentStyleSheet = this;
2135 style.cssText = rule;
2137 sc = sc.replace(/^[^a-z\-]+/, "")
2138 .replace(/\:\s+/g, ":")
2139 .replace(/\s*;[^a-z\-]*/g, ";");
2141 for (var i=0, ali=a.length;i<ali;++i) {
2145 style.setProperty(m[0], m[1]);
2149 a = sc = style = void 0;
2150 this.cssRules.splice(index,s,1);
2152 /*void*/ CSSStyleSheet.prototype.deleteRule = function(/*long*/ index) {
2153 this.cssRules.splice(index, 1);
2157 /*getComputedStyle関数
2158 *最近の計算値を取得する。Document.defaultViewはSafariがグローバル(window)にサポートしていないため付ける。
2160 /*interface ViewCSS : views::AbstractView {*/
2161 Document.prototype.defaultView = new ViewCSS();
2165 /*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2166 var s = new CSSStyleDeclaration(),
2169 //クロージャを利用して、カスケーディングを実現する
2170 s.getPropertyCSSValue = (function(elt, td, s){
2171 return function( /*string*/ propertyName) {
2175 while (el && (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0))) {
2176 if (el._runtimeStyle && el._runtimeStyle[propertyName]) {
2177 css = el._runtimeStyle.getPropertyCSSValue(propertyName);
2178 } else if (el.style && el.style[propertyName]) {
2179 css = el.style.getPropertyCSSValue(propertyName);
2180 } else if (el._attributeStyle && el._attributeStyle[propertyName]) {
2182 css = el._attributeStyle.getPropertyCSSValue(propertyName);
2183 } else if (el._rules) {
2185 for (var i=0,eli=el._rules.length;i<eli;++i) {
2186 el._rules[i].style[propertyName] && (css = el._rules[i].style.getPropertyCSSValue(propertyName));
2191 if (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0)) {
2193 td && (css = td[propertyName]);
2195 if (css && css.setRGBColor && ((css.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) || (css.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3))) {
2196 css.setRGBColor(s.getPropertyValue("color"));
2197 } else if (css && (css._em || css._ex || css["_%"])) {
2201 if (el.style._list._fontSize) {
2202 n = el.style._list._fontSize;
2209 } else if (css._ex) {
2211 } else if (css["_%"]) {
2212 n *= css["_%"] / 100;
2214 css.cssText = "font-size:" +n+ "px";
2219 })(elt, this._defaultCSS, s); //_defaultCSSはデフォルト値の設定
2223 es = el.style._list._opacity || el._attributeStyle._list._opacity;
2228 s._list._opacity = eso;
2229 el = pelt = eso = es = void 0;
2230 s._document = elt.ownerDocument;
2234 /*getOverrideStyleメソッド
2235 *指定した要素の上書きスタイルシートを取得。
2237 /*function DocumentCSS : stylesheets::DocumentStyle {*/
2238 /*CSSStyleDeclaration*/ Document.prototype.getOverrideStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2240 if (!!tar._runtimeStyle) {
2241 return (tar._runtimeStyle);
2243 var s = new CSSStyleDeclaration(), setProp = s.setProperty;
2244 tar._runtimeStyle = s;
2246 s.setProperty = (function(setProp, s){
2247 return function(propertyName, value, priority) {
2248 setProp.call(s, propertyName, value, priority);
2249 var tar = elt, el = tar._tar, isFill = isStroke = false;
2250 if ((tar.localName === "g") || (tar.localName === "a")) {
2251 var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
2253 for (var i=0,sli=sl.length;i<sli;++i) {
2255 NAIBU._setPaint(di, di.getScreenCTM());
2265 NAIBU._setPaint(tar, tar.getScreenCTM());
2266 el = tar = value = void 0;
2271 /*createCSSStyleSheetメソッド
2274 /*interface DOMImplementationCSS : DOMImplementation {*/
2275 /*CSSStyleSheet*/ DOMImplementation.createCSSStyleSheet = function( /*string*/ title, /*string*/ media) {
2276 var s = new CSSStyleSheet();
2278 var nm = new MediaList();
2279 nm.mediaText = media;
2280 if (media && (media !== "")) {
2281 var mes = media.split(","); //文字列をコンマで区切って配列に
2282 for (var i=0,mli=mes.length;i<mli;++i) {
2283 nm.appendMedium(mes[i]); //メディアリストに値を加えていく
2299 #pragma prefix "dom.w3c.org"
2302 typedef dom::DOMString DOMString;
2304 /*ElementTimeControlはSVGAnimationElementに統合させる。
2307 function ElementTimeControl(ele) {
2309 /*_startと_endプロパティはミリ秒数を収納する。
2310 *_startはアニメ開始時の秒数のリスト。_finishはアニメ終了時の秒数のリスト。
2311 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
2314 this._finish = null;
2317 ElementTimeControl.prototype = {
2318 /*void*/ beginElement : function() {
2319 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2320 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
2321 this.dispatchEvent(evt);
2323 /*void*/ endElement : function() {
2324 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2325 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
2326 this.dispatchEvent(evt);
2328 /*void*/ beginElementAt : function(/*float*/ offset) {
2329 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
2330 start = this._start || [];
2331 for (var i=0,sli=start.length;i<sli;++i) {
2332 if (start[i] === (offset+ntc)) {
2333 ntc = start = offset = void 0;
2337 start.push(offset + ntc);
2338 this._start = start;
2340 /*void*/ endElementAt : function(/*float*/ offset) {
2341 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
2342 fin = this._finish || [];
2343 for (var i=0,fli=fin.length;i<fli;++i) {
2344 if (fin[i] === (offset+ntc)) {
2345 ntc = fin = offset = void 0;
2349 fin.push(offset + ntc);
2354 function TimeEvent() {
2356 /*readonly attribute views::AbstractView*/ this.view;
2357 /*readonly attribute long*/ this.detail;
2360 TimeEvent.counstructor = Event;
2361 TimeEvent.prototype = new Event();
2362 /*void*/ TimeEvent.prototype.initTimeEvent = function(/*DOMString*/ typeArg,
2363 /*views::AbstractView*/ viewArg,
2364 /*long*/ detailArg) {
2365 this.type = typeArg;
2366 this.view = viewArg;
2367 this.detail = detailArg;
2369 //#endif // _SMIL_IDL_
2379 // For access to DOM2 core
2381 // For access to DOM2 events
2382 #include "events.idl"
2383 // For access to those parts from DOM2 CSS OM used by SVG DOM.
2385 // For access to those parts from DOM2 Views OM used by SVG DOM.
2386 #include "views.idl"
2387 // For access to the SMIL OM used by SVG DOM.
2389 #pragma prefix "dom.w3c.org"
2390 #pragma javaPackage "org.w3c.dom"
2393 typedef dom::DOMString DOMString;
2394 typedef dom::DOMException DOMException;
2395 typedef dom::Element Element;
2396 typedef dom::Document Document;
2397 typedef dom::NodeList NodeList;
2399 interface SVGElement;
2400 interface SVGLangSpace;
2401 interface SVGExternalResourcesRequired;
2403 interface SVGFitToViewBox;
2404 interface SVGZoomAndPan;
2405 interface SVGViewSpec;
2406 interface SVGURIReference;
2408 interface SVGMatrix;
2409 interface SVGPreserveAspectRatio;
2410 interface SVGAnimatedPreserveAspectRatio;
2411 interface SVGTransformList;
2412 interface SVGAnimatedTransformList;
2413 interface SVGTransform;
2414 interface SVGICCColor;
2417 interface SVGTransformable;
2418 interface SVGDocument;
2419 interface SVGSVGElement;
2420 interface SVGElementInstance;
2421 interface SVGElementInstanceList;
2423 function SVGException(code) {
2424 /*unsigned short*/ this.code = code;
2425 if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
2426 this.message = "SVG Wrong Type Error";
2427 } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
2428 this.message = "SVG Invalid Value Error";
2429 } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
2430 this.message = "SVG Matrix Not Invertable";
2434 SVGException.prototype = new Error();
2436 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR = 0;
2437 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR = 1;
2438 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE = 2;
2441 *すべてのSVG関連要素の雛形となるオブジェクト
2443 function SVGElement() {
2445 SVGStylable.call(this); //ElementCSSInlineStyleのインタフェースを継承
2446 /*interface SVGTransformable : SVGLocatable
2447 *TransformListはtransform属性を行列で表現したあとのリスト構造
2449 /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
2450 //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
2451 this.addEventListener("DOMAttrModified", function(evt){
2452 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2455 var name = evt.attrName,
2457 if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
2458 tar._attributeStyle.setProperty(name, evt.newValue, "");
2460 if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
2461 tar.id = evt.newValue;
2462 } else if ((name === "transform") && !!tar.transform) {
2463 var tft = evt.newValue,
2465 coma = tft.match(tar._comaReg), //コマンド文字にマッチ translate
2466 list = tft.match(tar._strReg), //カッコ内のリストにマッチ (10 20 30...)
2476 etod = evt.target.ownerDocument.documentElement,
2477 ttb = tar.transform.baseVal;
2478 //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
2479 for (var j=0,cli=coma.length;j<cli;j++) {
2480 s = etod.createSVGTransform();
2483 deg = lis.match(degR);
2496 s.setRotate(degz, +(deg[1]), +(deg[2]))
2497 } else if (degli <= 2) {
2499 if (com === "translate") {
2500 s.setTranslate(degz, +(deg[1] || 0));
2501 } else if (com === "scale") {
2502 s.setScale(degz, +(deg[1] || deg[0]));
2503 } else if (com === "rotate") {
2504 s.setRotate(degz, 0, 0);
2505 } else if (com === "skewX") {
2507 } else if (com === "skewY") {
2514 tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
2515 } else if (name === "style") {
2516 var sc = evt.newValue,
2524 sc = sc.replace(tar._shouReg, "")
2525 .replace(tar._conReg, ":")
2526 .replace(tar._bouReg, ";");
2528 for (var i=0, ali=a.length;i<ali;++i) {
2532 style.setProperty(m[0], m[1]);
2537 a = sc = style = void 0;
2538 } else if (name === "class") {
2539 tar.className = evt.newValue;
2540 } else if (name.indexOf("on") === 0) { //event属性ならば
2541 /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
2542 *ところが、IEでは、undefinedの値を返してしまう。
2543 *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
2545 eval("document._s = (function(evt){" +evt.newValue+ "})");
2546 var v = name.slice(2);
2549 } else if (v === "unload") {
2551 } else if (v === "abort") {
2553 } else if (v === "error") {
2555 } else if (v === "resize") {
2557 } else if (v === "scroll") {
2559 } else if (v === "zoom") {
2561 } else if (v === "begin") {
2563 } else if (v === "end") {
2565 } else if (v === "repeat") {
2568 tar.addEventListener(v, document._s, false);
2569 } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
2570 tar.xmlbase = evt.newValue;
2571 } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
2572 var tea = tar[name],
2573 tod = tar.nearestViewportElement || tar.ownerDocument.documentElement,
2574 tvw = tod.viewport.width,
2575 tvh = tod.viewport.height,
2577 n = evt.newValue.slice(-2),
2579 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
2580 _parseFloat = parseFloat;
2581 if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
2582 } else if (m === "%") {
2583 if (tar._x1width[name]) {
2584 tea.baseVal._percent = tvw * 0.01;
2585 } else if (tar._y1height[name]) {
2586 tea.baseVal._percent = tvh * 0.01;
2588 tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
2590 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
2591 } else if (n === "em") {
2592 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
2593 } else if (n === "ex") {
2594 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
2595 } else if (n === "px") {
2596 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
2597 } else if (n === "cm") {
2598 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
2599 } else if (n === "mm") {
2600 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
2601 } else if (n === "in") {
2602 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
2603 } else if (n === "pt") {
2604 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
2605 } else if (n === "pc") {
2606 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
2608 s = _parseFloat(evt.newValue);
2609 s = isNaN(s) ? 0 : s;
2610 tea.baseVal.newValueSpecifiedUnits(type, s);
2611 tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
2613 evt = _parseFloat = name = tar = null;
2617 SVGElement.prototype = new Element();
2620 /*以下の正規表現は属性のパーサの際に用いる*/
2621 this._degReg = /[\-\d\.e]+/g;
2622 this._comaReg = /[A-Za-z]+(?=\s*\()/g;
2623 this._strReg = /\([^\)]+\)/g;
2624 this._syouReg = /^[^a-z\-]+/;
2625 this._conReg = /\:\s+/g;
2626 this._bouReg = /\s*;[^a-z\-]*/g;
2627 /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
2630 this._cacheMatrix = null;
2631 /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
2646 /*String*/ this.id = null; //id属性の値
2647 /*String*/ this.xmlbase = null; //xml:base属性の値
2648 /*SVGSVGElement*/ this.ownerSVGElement; //ルート要素であるsvg要素
2649 /*readonly SVGElement*/ this.viewportElement; //ビューポートを形成する要素(多くはsvg要素)
2650 /*readonly attribute SVGElement*/ this.nearestViewportElement = null;
2651 /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
2653 /*interface SVGLocatable*/
2654 /*SVGRect*/ this.getBBox = function(){
2655 var s = new SVGRect(),
2656 data = this._tar.path.value,
2657 vi = this.ownerDocument.documentElement.viewport,
2662 degis = data.match(/[0-9\-]+/g),
2665 /*要素の境界領域を求める(四隅の座標を求める)
2666 *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
2667 *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
2669 for (var i=0,degisli=degis.length;i<degisli;i+=2) {
2672 el = el > nx ? nx : el;
2673 et = et > ny ? ny : et;
2674 er = er > nx ? er : nx;
2675 eb = eb > ny ? eb : ny;
2681 nx = ny = data = degis =el = et = er = eb = vi = void 0;
2686 *CTMとは現在の利用座標系に対する変換行列
2687 *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
2688 *1.2ではgetCTMが言及されていない
2689 *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
2691 /*SVGMatrix*/ this.getCTM = function() {
2693 if (!!this._cacheMatrix) { //キャッシュがあれば
2694 s = this._cacheMatrix;
2696 m = this.transform.baseVal.consolidate();
2700 m = this.ownerDocument.documentElement.createSVGMatrix();
2702 if (this.parentNode && !!this.parentNode.getCTM) {
2703 s = this.parentNode.getCTM().multiply(m);
2708 this._cacheMatrix = s; //キャッシュをためて次回で使う
2713 /*SVGMatrix*/ this.getScreenCTM = function(){
2714 if (!this.parentNode) {
2717 var view = this.nearestViewportElement || this.ownerDocument.documentElement;
2718 var s = view.getScreenCTM().multiply(this.getCTM());
2723 /*getTransformToElementメソッド
2724 *これは、あるelementへの変換行列を計算して返す
2725 *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
2727 /*SVGMatrix*/ this.getTransformToElement = function(/*SVGElement*/ element ){
2728 var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
2731 }).apply(SVGElement.prototype);
2733 function SVGAnimatedBoolean() {
2734 /*boolean*/ this.animVal = this.baseVal = true;
2738 function SVGAnimatedString() {
2739 /*String*/ this.animVal = this.baseVal = "";
2743 function SVGStringList() {
2746 SVGStringList.prototype = new Array();
2748 /*readonly unsigned long*/ this.numberOfItems = 0;
2749 /*void*/ this.clear = function(){
2750 for (var i=0, tli=this.length;i<tli;++i) {
2753 this.numberOfItems = 0;
2755 /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
2758 this.numberOfItems = 1;
2761 /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
2762 if (index >= this.numberOfItems || index < 0) {
2763 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2765 return (this[index]);
2768 /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2769 if (index >= this.numberOfItems) {
2770 this.appendItem(newItem);
2772 this.splice(index, 1, newItem, this.getItem[index]);
2773 ++this.numberOfItems;
2777 /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2778 if (index >= this.numberOfItems || index < 0) {
2779 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2781 this.splice(index, 1, newItem);
2785 //raises( DOMException, SVGException );
2786 /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
2787 if (index >= this.numberOfItems || index < 0) {
2788 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2790 this.splice(index, 1);
2791 --this.numberOfItems;
2795 /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
2796 this[this.numberOfItems] = newItem;
2797 ++this.numberOfItems;
2799 }).apply(SVGStringList.prototype);
2801 function SVGAnimatedEnumeration() {
2802 /*unsigned short*/ this.baseVal = 0;
2803 // raises DOMException on setting
2804 /*readonly unsigned short*/ this.animVal = 0;
2807 function SVGAnimatedInteger() {
2808 /*long*/ this.baseVal = 0;
2809 // raises DOMException on setting
2810 /*readonly long*/ this.animVal = 0;
2813 function SVGNumber() {
2814 /*float*/ this.value = 0;
2815 // raises DOMException on setting
2818 function SVGAnimatedNumber() {
2819 /*float*/ this.baseVal = this.animVal = 0;
2823 function SVGNumberList() {
2826 /*SVGUnmberListのメソッドはSVGPathSegListを参照*/
2828 function SVGAnimatedNumberList() {
2829 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
2833 *長さを設定する(単位pxに統一する方便として使う)
2834 *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
2836 function SVGLength() {
2840 // Length Unit Types
2841 /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN = 0;
2842 /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER = 1;
2843 /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
2844 /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS = 3;
2845 /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS = 4;
2846 /*const unsigned short*/ t.SVG_LENGTHTYPE_PX = 5;
2847 /*const unsigned short*/ t.SVG_LENGTHTYPE_CM = 6;
2848 /*const unsigned short*/ t.SVG_LENGTHTYPE_MM = 7;
2849 /*const unsigned short*/ t.SVG_LENGTHTYPE_IN = 8;
2850 /*const unsigned short*/ t.SVG_LENGTHTYPE_PT = 9;
2851 /*const unsigned short*/ t.SVG_LENGTHTYPE_PC = 10;
2854 SVGLength.prototype = {
2855 /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
2856 /*attribute float*/ value : 0, //利用単位における値
2857 /*attribute float*/ valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN, //unitTypeにおける値
2858 /*attribute DOMString*/ valueAsString : "0",
2859 _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
2860 _fontSize : 12, //単位のemとexで使われるfont-sizeの値
2861 /*newValueSpedifiedUnitsメソッド
2862 *新しくunitTypeにおける値を設定する
2863 *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
2865 newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
2867 _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
2868 if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
2869 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
2871 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
2874 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
2877 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
2878 n = this._fontSize * 0.5;
2880 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
2883 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
2886 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
2889 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
2892 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
2896 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2898 this.unitType = unitType;
2899 this.value = valueInSpecifiedUnits * n;
2900 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2901 this.valueAsString = valueInSpecifiedUnits + _s;
2902 valueInSpecifiedUnits = unitType = n = _s = void 0;
2904 /*convertToSpecifiedUnitsメソッド
2905 *valueプロパティを書き換えずに、単位だけを変換する
2907 * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
2908 * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
2909 * alert(x.valueAsString); //20mm
2911 convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
2912 if (this.value === 0) {
2913 this.newValueSpecifiedUnits(unitType, 0);
2917 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2918 v = v / this.value * this.valueInSpecifiedUnits;
2919 this.newValueSpecifiedUnits(unitType, v);
2922 *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
2923 *単位が%の場合は、新しいvalueへと変換させておく
2925 _emToUnit : function (/*float*/ fontSize) {
2926 if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
2927 this._fontSize = fontSize;
2928 this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
2932 function SVGAnimatedLength() {
2933 /*readonly SVGLength*/ this.animVal;
2934 this.baseVal = new SVGLength();
2935 this.baseVal.unitType = 1;
2938 function SVGLengthList() {
2941 /*SVGLengthListのメソッドはSVGPathSegListを参照*/
2943 function SVGAnimatedLengthList() {
2944 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
2947 function SVGAngle() {
2950 SVGAngle.prototype = {
2951 /*readonly attribute unsigned short*/ unitType : 0,
2952 /*attribute float*/ value : 0,
2953 // raises DOMException on setting
2954 /*attribute float*/ valueInSpecifiedUnits : 0,
2955 // raises DOMException on setting
2956 /*attribute DOMString*/ valueAsString : "0",
2957 // raises DOMException on setting
2958 /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
2960 _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
2961 if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
2962 } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
2964 } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
2967 } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
2971 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2973 this.unitType = unitType;
2974 this.value = valueInSpecifiedUnits * n;
2975 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2976 this.valueAsString = valueInSpecifiedUnits + _s;
2978 //raises( DOMException );
2980 /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
2981 if (this.value === 0) {
2982 this.newValueSpecifiedUnits(unitType, 0);
2986 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2987 v = v / this.value * this.valueInSpecifiedUnits;
2988 this.newValueSpecifiedUnits(unitType, v);
2989 //raises( DOMException );
2993 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN = 0;
2994 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
2995 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG = 2;
2996 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD = 3;
2997 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD = 4;
2998 function SVGAnimatedAngle() {
2999 /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
3000 /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
3003 function SVGColor() {
3004 CSSValue.apply(this);
3005 /*readonly css::RGBColor*/ this.rgbColor = new RGBColor();
3010 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN = 0;
3011 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR = 1;
3012 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
3013 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR = 3;
3014 SVGColor.prototype = new CSSValue(); //ノードのプロトタイプチェーンを作って、継承
3017 /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
3018 /*readonly SVGICCColor*/ this.iccColor = null;
3019 this._regD = /\d+/g;
3020 this._regDP = /[\d.]+%/g;
3021 this._exceptionsvg = SVGException.SVG_INVALID_VALUE_ERR;
3022 /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
3026 if (!rgbColor || (typeof rgbColor !== "string")) {
3027 throw new SVGException(this._exceptionsvg);
3029 rgbColor = this._keywords[rgbColor] || rgbColor;
3030 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
3031 rgbColor = rgbColor.replace(this._regDP, function(s) {
3032 return Math.round((2.55 * parseFloat(s)));
3034 s = rgbColor.match(this._regD);
3035 } else if (rgbColor.indexOf("#") === 0) { //#を含む場合
3037 _parseInt = parseInt;
3038 if (rgbColor.length < 5) {
3039 r = rgbColor.charAt(1);
3040 g = rgbColor.charAt(2);
3041 b = rgbColor.charAt(3)
3042 rgbColor = "#" + r + r + g + g + b + b;
3044 s[0] = _parseInt(rgbColor.slice(1, 3), 16)+ "";
3045 s[1] = _parseInt(rgbColor.slice(3, 5), 16)+ "";
3046 s[2] = _parseInt(rgbColor.slice(5, 7), 16)+ "";
3049 s = rgbColor.match(this._regD);
3050 if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
3052 throw new SVGException(this._exceptionsvg);
3055 this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
3056 this.rgbColor.green.setFloatValue(1, s[1]);
3057 this.rgbColor.blue.setFloatValue(1, s[2]);
3058 rgbColor = s = _parseInt = void 0;
3061 // raises( SVGException );
3062 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
3063 this.colorType = colorType;
3064 if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
3065 throw new SVGException(this._exceptionsvg);
3066 } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
3067 this.setRGBColor(rgbColor);
3068 } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
3069 this.setRGBColor(rgbColor);
3070 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
3071 throw new SVGException(this._exceptionsvg);
3072 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
3073 throw new SVGException(this._exceptionsvg);
3075 colorType = rgbColor = void 0;
3077 // raises( SVGException );
3080 aliceblue: "rgb(240,248,255)",
3081 antiquewhite: "rgb(250,235,215)",
3082 aqua: "rgb(0,255,255)",
3083 aquamarine: "rgb(127,255,212)",
3084 azure: "rgb(240,255,255)",
3085 beige: "rgb(245,245,220)",
3086 bisque: "rgb(255,228,196)",
3087 black: "rgb(0,0,0)",
3088 blanchedalmond:"rgb(255,235,205)",
3089 blue: "rgb(0,0,255)",
3090 blueviolet: "rgb(138,43,226)",
3091 brown: "rgb(165,42,42)",
3092 burlywood: "rgb(222,184,135)",
3093 cadetblue: "rgb(95,158,160)",
3094 chartreuse: "rgb(127,255,0)",
3095 chocolate: "rgb(210,105,30)",
3096 coral: "rgb(255,127,80)",
3097 cornflowerblue:"rgb(100,149,237)",
3098 cornsilk: "rgb(255,248,220)",
3099 crimson: "rgb(220,20,60)",
3100 cyan: "rgb(0,255,255)",
3101 darkblue: "rgb(0,0,139)",
3102 darkcyan: "rgb(0,139,139)",
3103 darkgoldenrod:"rgb(184,134,11)",
3104 darkgray: "rgb(169,169,169)",
3105 darkgreen: "rgb(0,100,0)",
3106 darkgrey: "rgb(169,169,169)",
3107 darkkhaki: "rgb(189,183,107)",
3108 darkmagenta: "rgb(139,0,139)",
3109 darkolivegreen:"rgb(85,107,47)",
3110 darkorange: "rgb(255,140,0)",
3111 darkorchid: "rgb(153,50,204)",
3112 darkred: "rgb(139,0,0)",
3113 darksalmon: "rgb(233,150,122)",
3114 darkseagreen: "rgb(143,188,143)",
3115 darkslateblue:"rgb(72,61,139)",
3116 darkslategray:"rgb(47,79,79)",
3117 darkslategrey:"rgb(47,79,79)",
3118 darkturquoise:"rgb(0,206,209)",
3119 darkviolet: "rgb(148,0,211)",
3120 deeppink: "rgb(255,20,147)",
3121 deepskyblue: "rgb(0,191,255)",
3122 dimgray: "rgb(105,105,105)",
3123 dimgrey: "rgb(105,105,105)",
3124 dodgerblue: "rgb(30,144,255)",
3125 firebrick: "rgb(178,34,34)",
3126 floralwhite: "rgb(255,250,240)",
3127 forestgreen: "rgb(34,139,34)",
3128 fuchsia: "rgb(255,0,255)",
3129 gainsboro: "rgb(220,220,220)",
3130 ghostwhite: "rgb(248,248,255)",
3131 gold: "rgb(255,215,0)",
3132 goldenrod: "rgb(218,165,32)",
3133 gray: "rgb(128,128,128)",
3134 grey: "rgb(128,128,128)",
3135 green: "rgb(0,128,0)",
3136 greenyellow: "rgb(173,255,47)",
3137 honeydew: "rgb(240,255,240)",
3138 hotpink: "rgb(255,105,180)",
3139 indianred: "rgb(205,92,92)",
3140 indigo: "rgb(75,0,130)",
3141 ivory: "rgb(255,255,240)",
3142 khaki: "rgb(240,230,140)",
3143 lavender: "rgb(230,230,250)",
3144 lavenderblush:"rgb(255,240,245)",
3145 lawngreen: "rgb(124,252,0)",
3146 lemonchiffon: "rgb(255,250,205)",
3147 lightblue: "rgb(173,216,230)",
3148 lightcoral: "rgb(240,128,128)",
3149 lightcyan: "rgb(224,255,255)",
3150 lightgoldenrodyellow:"rgb(250,250,210)",
3151 lightgray: "rgb(211,211,211)",
3152 lightgreen: "rgb(144,238,144)",
3153 lightgrey: "rgb(211,211,211)",
3154 lightpink: "rgb(255,182,193)",
3155 lightsalmon: "rgb(255,160,122)",
3156 lightseagree: "rgb(32,178,170)",
3157 lightskyblue: "rgb(135,206,250)",
3158 lightslategray:"rgb(119,136,153)",
3159 lightslategrey:"rgb(119,136,153)",
3160 lightsteelblue:"rgb(176,196,222)",
3161 lightyellow: "rgb(255,255,224)",
3162 lime: "rgb(0,255,0)",
3163 limegreen: "rgb(50,205,50)",
3164 linen: "rgb(250,240,230)",
3165 magenta: "rgb(255,0,255)",
3166 maroon: "rgb(128,0,0)",
3167 mediumaquamarine:"rgb(102,205,170)",
3168 mediumblue: "rgb(0,0,205)",
3169 mediumorchid: "rgb(186,85,211)",
3170 mediumpurple: "rgb(147,112,219)",
3171 mediumseagreen:"rgb(60,179,113)",
3172 mediumslateblue:"rgb(123,104,238)",
3173 mediumspringgreen:"rgb(0,250,154)",
3174 mediumturquoise:"rgb(72,209,204)",
3175 mediumvioletred:"rgb(199,21,133)",
3176 midnightblue: "rgb(25,25,112)",
3177 mintcream: "rgb(245,255,250)",
3178 mistyrose: "rgb(255,228,225)",
3179 moccasin: "rgb(255,228,181)",
3180 navajowhite: "rgb(255,222,173)",
3181 navy: "rgb(0,0,128)",
3182 oldlace: "rgb(253,245,230)",
3183 olive: "rgb(128,128,0)",
3184 olivedrab: "rgb(107,142,35)",
3185 orange: "rgb(255,165,0)",
3186 orangered: "rgb(255,69,0)",
3187 orchid: "rgb(218,112,214)",
3188 palegoldenrod: "rgb(238,232,170)",
3189 palegreen: "rgb(152,251,152)",
3190 paleturquoise: "rgb(175,238,238)",
3191 palevioletred: "rgb(219,112,147)",
3192 papayawhip: "rgb(255,239,213)",
3193 peachpuff: "rgb(255,218,185)",
3194 peru: "rgb(205,133,63)",
3195 pink: "rgb(255,192,203)",
3196 plum: "rgb(221,160,221)",
3197 powderblue: "rgb(176,224,230)",
3198 purple: "rgb(128,0,128)",
3199 red: "rgb(255,0,0)",
3200 rosybrown: "rgb(188,143,143)",
3201 royalblue: "rgb(65,105,225)",
3202 saddlebrown: "rgb(139,69,19)",
3203 salmon: "rgb(250,128,114)",
3204 sandybrown: "rgb(244,164,96)",
3205 seagreen: "rgb(46,139,87)",
3206 seashell: "rgb(255,245,238)",
3207 sienna: "rgb(160,82,45)",
3208 silver: "rgb(192,192,192)",
3209 skyblue: "rgb(135,206,235)",
3210 slateblue: "rgb(106,90,205)",
3211 slategray: "rgb(112,128,144)",
3212 slategrey: "rgb(112,128,144)",
3213 snow: "rgb(255,250,250)",
3214 springgreen: "rgb(0,255,127)",
3215 steelblue: "rgb(70,130,180)",
3216 tan: "rgb(210,180,140)",
3217 teal: "rgb(0,128,128)",
3218 thistle: "rgb(216,191,216)",
3219 tomato: "rgb(255,99,71)",
3220 turquoise: "rgb(64,224,208)",
3221 violet: "rgb(238,130,238)",
3222 wheat: "rgb(245,222,179)",
3223 white: "rgb(255,255,255)",
3224 whitesmoke: "rgb(245,245,245)",
3225 yellow: "rgb(255,255,0)",
3226 yellowgreen: "rgb(154,205,50)"
3228 }).apply(SVGColor.prototype);
3230 function SVGRect() {
3231 /*float*/ this.x = 0;
3232 // raises DOMException on setting
3233 /*float*/ this.y = 0;
3234 // raises DOMException on setting
3235 /*float*/ this.width = 0;
3236 // raises DOMException on setting
3237 /*float*/ this.height = 0;
3238 // raises DOMException on setting
3242 function SVGAnimatedRect() {
3243 /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
3249 /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN : 0,
3250 /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE : 1,
3251 /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
3253 function SVGStylable() {
3254 /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
3255 /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
3256 this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
3257 //styleのcssTextプロパティを解析するリスナーを登録しておく
3259 /*getPresentationAttributeメソッド
3260 *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
3262 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
3263 var s = this._attributeStyle.getPropertyCSSValue(name);
3271 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
3272 *SIEでは、もっぱらXLink言語の処理を行う
3274 function SVGURIReference() {
3275 /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
3276 this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
3278 this.addEventListener("DOMAttrModified", function(evt){
3279 if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
3280 evt.target.href.baseVal = evt.newValue;
3281 /*_svgload_limitedを+1とすることで、
3282 *SVGLoadイベントは発火されなくなる。1を引く必要がある
3284 evt.target.ownerDocument.documentElement._svgload_limited++;
3288 this.addEventListener("DOMNodeInserted", function(evt){
3289 var tar = evt.target;
3290 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3293 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3294 var tar = evt.target,
3296 href = tar.href.baseVal,
3297 show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
3298 /*xlink:href属性とxml:base属性を手がかりに、
3299 *ハイパーリンクのURIを決定する処理を行う
3301 if (href !== "") { //xlink:href属性が指定されたとき
3302 egbase = tar.xmlbase;
3304 ep = tar.parentNode;
3311 if (!b) { //xml:baseの指定がなければ
3312 if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
3314 base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
3316 base = location.href;
3322 if (href.indexOf(":") !== -1) { //絶対URIの場合
3326 show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
3327 if (href.indexOf(".") === 0) { //相対URIの場合
3330 if (show === "replace") {
3331 tar._tar.setAttribute("href", uri);
3332 } else if (show === "new") {
3333 tar._tar.setAttribute("target", "_blank");
3334 tar._tar.setAttribute("href", uri);
3335 } else if (show === "embed") {
3336 xmlhttp = NAIBU.xmlhttp;
3337 ui = uri.indexOf("#");
3339 id = uri.slice(ui+1);
3340 uri = uri.replace(/#.+$/, "");
3344 if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
3345 doc = tar.ownerDocument;
3346 ele = doc.getElementById(id);
3347 tar._instance = ele;
3348 ev = doc.createEvent("SVGEvents");
3349 ev.initEvent("S_Load", false, false);
3350 tar.dispatchEvent(ev);
3351 tar = xmlhttp = void 0;
3352 } else if (uri.indexOf("data:") > -1) {
3354 tar = xmlhttp = void 0;
3355 } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
3356 if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
3359 /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
3360 tar.ownerDocument.documentElement._svgload_limited++;
3361 xmlhttp.open("GET", uri, false);
3362 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3363 xmlhttp.onreadystatechange = function() {
3364 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
3365 var type = xmlhttp.getResponseHeader('Content-Type') || "text",
3367 if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
3368 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
3369 *ここでは、responseTextを用いる
3371 /*script要素とstyle要素は、
3372 *_textプロパティに読み込んだテキストを格納しておく
3373 *それら以外は、_instanceプロパティにDOMツリーを格納しておく
3375 if (tar.localName !== "script" && tar.localName !== "style") {
3376 doc = new ActiveXObject("MSXML2.DomDocument");
3377 str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
3378 NAIBU.doc.async = false;
3379 NAIBU.doc.validateOnParse = false;
3380 NAIBU.doc.resolveExternals = false;
3381 NAIBU.doc.preserveWhiteSpace = false;
3383 ele = doc.documentElement;
3384 tar._instance = tar.ownerDocument.importNode(ele, true);
3386 tar._instance = tar._instance.ownerDocument.getElementById(id);
3389 tar._text = xmlhttp.responseText;
3391 } else if (!!tar._tar) {
3394 /*S_LoadイベントとはSIE独自のイベント。
3395 *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
3397 ev = tar.ownerDocument.createEvent("SVGEvents");
3398 ev.initEvent("S_Load", false, false);
3399 tar.dispatchEvent(ev);
3400 tar.ownerDocument.documentElement._svgload_limited--;
3401 /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
3402 if (tar.ownerDocument.documentElement._svgload_limited < 0) {
3403 ev = tar.ownerDocument.createEvent("SVGEvents");
3404 ev.initEvent("SVGLoad", false, false);
3405 tar.ownerDocument.documentElement.dispatchEvent(ev);
3407 tar = type = doc = str = ev = void 0;
3408 /*IEのメモリリーク対策として、空関数を入力*/
3409 xmlhttp.onreadystatechange = NAIBU.emptyFunction;
3417 tar.ownerDocument.documentElement._svgload_limited--;
3419 evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
3425 function SVGCSSRule() {
3426 CSSRule.apply(this, arguments);
3427 // Additional CSS RuleType to support ICC color specifications
3428 /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
3431 SVGCSSRule.prototype = new CSSRule(); //ノードのプロトタイプチェーンを作って、継承
3436 function SVGDocument(){
3437 Document.apply(this);
3438 DocumentStyle.apply(this);
3439 /*readonly DOMString*/ this.title = "";
3440 /*readonly DOMString*/ this.referrer = document.referrer;
3441 /*readonly DOMString*/ this.domain = document.domain;
3442 /*readonly DOMString*/ this.URL = document.location;
3443 /*readonly SVGSVGElement*/ this.rootElement;
3446 SVGDocument.prototype = new Document(); //ノードのプロトタイプチェーンを作って、継承
3448 /*軽量化のために、頻繁に使われる処理をSVGDocumentの独自メソッドとしてまとめておく*/
3449 SVGDocument.prototype._domnodeEvent = function() {
3450 var evtt = this.createEvent("MutationEvents");
3451 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3458 function SVGSVGElement(_doc) {
3459 SVGElement.apply(this, arguments);
3460 this._tar = _doc.createElement("v:group");
3462 /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
3463 * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
3464 this._svgload_limited = 0;
3468 SVGExternalResourcesRequired,
3473 events::EventTarget,
3474 events::DocumentEvent,
3476 css::DocumentCSS {*/
3477 /*以下のx,y,width,heightプロパティは
3478 *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
3479 *1000というのは、W3Cで触れていないため、独自の初期値を採用
3481 var slen = SVGAnimatedLength;
3482 /*readonly SVGAnimatedLength*/ this.x = new slen();
3483 /*readonly SVGAnimatedLength*/ this.y = new slen();
3484 /*readonly SVGAnimatedLength*/ this.width = new slen();
3485 /*readonly SVGAnimatedLength*/ this.height = new slen();
3487 /*DOMString*/ this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
3488 /*DOMString*/ this.contentStyleType = "text/css";
3489 /*readonly SVGRect*/ this.viewport = this.createSVGRect();
3490 /*useCurrentViewプロパティ
3491 * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
3493 /*boolean*/ this.useCurrentView = false;
3495 * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
3497 /*readonly SVGViewSpec*/ this.currentView = new SVGViewSpec(this);
3498 /*もし、画像をズームやパンしたとき、どのような倍率になるかを
3499 *以下のプロパティを使って次の行列で示すことができる
3500 *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]
3502 /*float*/ this.currentScale = 1;
3503 /*readonly SVGPoint*/ this.currentTranslate = this.createSVGPoint();
3504 /*以下は、SVGFitToViewBoxのインターフェースを用いる
3505 *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
3507 /*readonly SVGAnimatedRect*/ this.viewBox = this.currentView.viewBox;
3508 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
3509 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
3512 /*int*/ this._currentTime = 0;
3513 /*DOMAttrModifiedイベントを利用して、
3514 *随時、属性の値をDOMプロパティに変換しておくリスナー登録
3516 this.addEventListener("DOMAttrModified", function(evt){
3517 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3520 var tar = evt.target,
3521 name = evt.attrName,
3522 tv, ovb, par, tp, sa, mos;
3523 if (name === "viewBox") {
3524 tar._cacheScreenCTM = null;
3525 tv = tar.viewBox.baseVal;
3526 ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3527 tv.x = parseFloat(ovb[0]);
3528 tv.y = parseFloat(ovb[1]);
3529 tv.width = parseFloat(ovb[2]);
3530 tv.height = parseFloat(ovb[3]);
3531 tar.viewBox.baseVal._isUsed = 1;
3532 } else if (name === "preserveAspectRatio") {
3533 tar._cacheScreenCTM = null;
3535 tp = tar.preserveAspectRatio.baseVal;
3537 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
3538 if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
3539 switch (RegExp.$1) {
3550 switch (RegExp.$2) {
3560 if (RegExp.$3 === "slice") {
3561 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
3563 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
3567 tp.meetOrSlice = mos;
3568 } else if (name === "width") {
3570 tar.viewport.width = tar.width.baseVal.value;
3571 } else if (name === "height") {
3572 tar.viewport.height = tar.height.baseVal.value;
3574 evt = name = tv = ovb = par = tp = sa = mos = void 0;
3576 this.addEventListener("SVGLoad", function(evt){
3577 /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
3578 *処理を書いたもの。属性が書き換わるたびに、再描画される
3580 evt.target.addEventListener("DOMAttrModified", function(evt){
3583 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3585 if (tar.parentNode) {
3586 evtt = tar.ownerDocument._domnodeEvent();
3588 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3589 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3590 for (var j=0,tcli=tce.length;j<tcli;++j){
3592 tce[j].handleEvent(evtt);
3595 if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
3596 tar._cacheMatrix = void 0; //キャッシュを消去
3597 if (tar.firstChild) {
3598 slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
3599 for (var i=0,sli=slist.length;i<sli;++i) {
3601 tar._cacheMatrix = void 0;
3602 evtt = tar.ownerDocument.createEvent("MutationEvents");
3603 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3605 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3606 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3607 for (var j=0,tcli=tce.length;j<tcli;++j){
3609 tce[j].handleEvent(evtt);
3617 evtt = tar = evt = tce = slist = void 0;
3619 evt.target.addEventListener("DOMNodeRemovedFromDocument", function(evt){
3620 var tar = evt.target;
3621 tar._tar && tar._tar.parentNode && tar._tar.parentNode.removeChild(tar._tar);
3628 SVGSVGElement.prototype = new SVGElement();
3629 /*void*/ SVGSVGElement.prototype.forceRedraw = function() {
3631 /*float*/ SVGSVGElement.prototype.getCurrentTime = function(){
3632 return (this._currentTime);
3634 /*void*/ SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
3635 this._currentTime = seconds;
3637 /*SVGNumber*/ SVGSVGElement.prototype.createSVGNumber = function(){
3638 var s = new SVGNumber();
3642 /*SVGAngle*/ SVGSVGElement.prototype.createSVGAngle = function(){
3643 var s = new SVGAngle();
3648 /*SVGLength*/ SVGSVGElement.prototype.createSVGLength = function(){
3649 var s = new SVGLength();
3650 s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
3653 /*SVGPoint*/ SVGSVGElement.prototype.createSVGPoint = function(){
3654 return new SVGPoint();
3656 /*SVGMatrix*/ SVGSVGElement.prototype.createSVGMatrix = function(){
3658 return new SVGMatrix();
3660 /*SVGRect*/ SVGSVGElement.prototype.createSVGRect = function(){
3661 return new SVGRect();
3663 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransform = function(){
3664 var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
3667 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
3668 var s = new SVGTransform();
3669 s.setMatrix(matrix);
3673 *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
3675 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
3676 if (!!this._cacheScreenCTM) { //キャッシュがあれば
3677 return (this._cacheScreenCTM);
3679 var vw = this.viewport.width,
3680 vh = this.viewport.height,
3681 vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
3682 if (!this.useCurrentView) {
3683 vB = this.viewBox.baseVal;
3684 par = this.preserveAspectRatio.baseVal;
3686 vB = this.currentView.viewBox.baseVal;
3687 par = this.currentView.preserveAspectRatio.baseVal;
3689 if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
3690 this._tx = this._ty = 0;
3691 m = this.createSVGMatrix();
3692 this._cacheScreenCTM = m; //キャッシュを作っておく
3705 if (par.align === 1) { //none
3711 var ax = (par.align + 1) % 3 + 1;
3712 var ay = Math.round(par.align / 3);
3713 switch (par.meetOrSlice) {
3715 xr = yr = Math.min(rw, rh);
3718 xr = yr = Math.max(rw, rh);
3727 tx += (vw - vbw * xr) / 2;
3730 tx += vw - vbw * xr;
3737 ty += (vh - vbh * yr) / 2;
3740 ty += vh - vbh * yr;
3745 //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
3748 ttps = this._tar.style;
3749 ttps.marginLeft = tx+ "px";
3750 ttps.marginTop = ty+ "px";
3751 m = this.createSVGMatrix();
3754 this._cacheScreenCTM = m; //キャッシュを作っておく
3755 vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
3759 /*interface SVGZoomAndPan*/
3760 // Zoom and Pan Types
3762 /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
3763 /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
3764 /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
3767 function SVGFitToViewBox() {
3768 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
3769 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3772 function SVGViewSpec(ele) {
3773 SVGFitToViewBox.apply(this, arguments);
3774 /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
3775 /*readonly SVGElement*/ this.viewTarget = ele;
3776 /*readonly DOMString*/ this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
3779 SVGViewSpec.prototype = new SVGFitToViewBox();
3781 function SVGGElement(_doc) {
3782 SVGElement.apply(this);
3783 this._tar = _doc.createElement("v:group");
3785 /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
3786 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
3788 this.addEventListener("DOMNodeInserted", function(evt){
3789 var tar = evt.target;
3790 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3793 var tnext = tar.nextSibling,
3794 tpart = tar.parentNode._tar,
3796 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3797 tpart.insertBefore(tar._tar, tnext._tar);
3798 } else if (tnext && !tnext._tar && tpart) {
3799 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3800 *use要素や実体参照などは_tarプロパティがないことに注意
3803 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3804 tpart.insertBefore(tar._tar, tnext._tar);
3807 tnext = tnext.nextSibling;
3810 tpart.appendChild(tar._tar);
3812 } else if (!tnext && tpart) {
3813 tpart.appendChild(tar._tar);
3815 tnext = tpart = isLast = evt = tar = void 0;
3819 SVGGElement.prototype = new SVGElement();
3821 function SVGDefsElement() {
3822 SVGElement.apply(this, arguments);
3823 this.style.setProperty("display", "none");
3826 SVGDefsElement.prototype = new SVGElement();
3828 function SVGDescElement() {
3829 SVGElement.apply(this, arguments);
3832 SVGDescElement.prototype = new SVGElement();
3834 function SVGTitleElement() {
3835 SVGElement.apply(this, arguments);
3836 this.addEventListener("DOMCharacterDataModified", function(evt){
3837 evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
3841 SVGTitleElement.prototype = new SVGElement();
3843 function SVGSymbolElement(_doc) {
3844 SVGElement.apply(this, arguments);
3847 SVGSymbolElement.prototype = new SVGElement();
3849 function SVGUseElement() {
3850 SVGGElement.apply(this, arguments);
3851 var slen = SVGAnimatedLength;
3852 /*readonly SVGAnimatedLength*/ this.x = new slen(); //use要素のx属性に対応(以下、同様)
3853 /*readonly SVGAnimatedLength*/ this.y = new slen();
3854 /*readonly SVGAnimatedLength*/ this.width = new slen();
3855 /*readonly SVGAnimatedLength*/ this.height = new slen();
3857 /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
3858 /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
3859 this.addEventListener("DOMNodeInserted", function(evt){
3860 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3863 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3865 this.addEventListener("S_Load", function(evt){
3866 var tar = evt.target,
3867 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3868 fontSize = parseFloat(style.getPropertyValue("font-size")),
3869 trans = tar.ownerDocument.documentElement.createSVGTransform(),
3870 tari = tar._instance,
3872 tar.x.baseVal._emToUnit(fontSize);
3873 tar.y.baseVal._emToUnit(fontSize);
3874 tar.width.baseVal._emToUnit(fontSize);
3875 tar.height.baseVal._emToUnit(fontSize);
3876 tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tari, true);
3877 trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
3878 tar.transform.baseVal.appendItem(trans);
3879 if (tar._instance.localName === "symbol") {
3880 /*symbol要素の場合、別途svg要素に置き換える*/
3881 svg = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "svg");
3882 svg.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3883 /*viewportをsymbol要素として新規に設定*/
3884 evt.target.nearestViewportElement = evt.currentTarget;
3886 tar._tar.appendChild(svg._tar);
3887 tn = tar.getScreenCTM();
3888 svg.setAttributeNS(null, "width", tar.width.baseVal.value);
3889 svg.setAttributeNS(null, "height", tar.height.baseVal.value);
3890 tari.hasAttributeNS(null, "viewBox") && svg.setAttributeNS(null, "viewBox", tari.getAttributeNS(null, "viewBox"));
3891 tari.hasAttributeNS(null, "preserveAspectRatio") && svg.setAttributeNS(null, "preserveAspectRatio", tari.getAttributeNS(null, "preserveAspectRatio"));
3892 svg._cacheScreenCTM = tn.multiply(svg.getScreenCTM());
3893 ti = tar.instanceRoot.firstChild;
3895 ta = ti.nextSibling;
3896 svg.appendChild(ti);
3897 ti.getScreenCTM && ti.getScreenCTM();
3900 tar.appendChild(svg);
3902 tar.appendChild(tar.instanceRoot);
3904 evt = trans = tar = evtt = style = fontSize = svg = ti = ta = tn = void 0;
3906 SVGURIReference.apply(this);
3909 SVGUseElement.prototype = new SVGElement();
3911 function SVGElementInstance() {
3915 Node.apply(this, arguments);
3916 /*readonly SVGElement*/ this.correspondingElement; //use要素で使われる参照先の要素
3917 /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
3918 /*readonly SVGElementInstance*/ this.parentNode;
3919 /*readonly SVGElementInstanceList*/ this.childNodes;
3920 /*readonly SVGElementInstance*/ this.firstChild;
3921 /*readonly SVGElementInstance*/ this.lastChild;
3922 /*readonly SVGElementInstance*/ this.previousSibling;
3923 /*readonly SVGElementInstance*/ this.nextSibling;
3926 SVGElementInstance.prototype = new Node();
3927 /*SVGElementInstanceList
3929 function SVGElementInstanceList() {
3930 /*readonly unsigned long*/ this.length = 0;
3933 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
3934 return (this[index]);
3936 function SVGImageElement(_doc) {
3937 SVGElement.apply(this, arguments);
3938 this._tar = _doc.createElement("v:image");
3939 //以下は、与えられた属性の値に対応する
3940 var slen = SVGAnimatedLength;
3941 /*readonly SVGAnimatedLength*/ this.x = new slen();
3942 /*readonly SVGAnimatedLength*/ this.y = new slen();
3943 /*readonly SVGAnimatedLength*/ this.width = new slen();
3944 /*readonly SVGAnimatedLength*/ this.height = new slen();
3945 _doc = slen = void 0;
3946 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3947 this.addEventListener("DOMNodeInserted", function(evt){
3948 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3951 var tar = evt.target;
3952 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3953 if (tar.nextSibling) {
3954 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
3955 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
3957 } else if (!!tar.parentNode._tar){
3958 tar.parentNode._tar.appendChild(tar._tar);
3960 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3961 var tar = evt.target,
3962 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3963 fontSize = parseFloat(style.getPropertyValue("font-size")),
3964 ts = tar._tar.style,
3965 ctm = tar.getScreenCTM(),
3966 po = tar.ownerDocument.documentElement.createSVGPoint(),
3967 fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
3969 tar.x.baseVal._emToUnit(fontSize);
3970 tar.y.baseVal._emToUnit(fontSize);
3971 tar.width.baseVal._emToUnit(fontSize);
3972 tar.height.baseVal._emToUnit(fontSize);
3973 ts.position = "absolute";
3974 po.x = tar.x.baseVal.value;
3975 po.y = tar.y.baseVal.value;
3976 po = po.matrixTransform(ctm);
3977 ts.left = po.x + "px";
3978 ts.top = po.y + "px";
3979 ts.width = tar.width.baseVal.value * ctm.a + "px";
3980 ts.height = tar.height.baseVal.value * ctm.d + "px";
3981 if (fillOpacity !== 1) {
3982 ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
3983 ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
3985 ttfia.Opacity = fillOpacity * 100;
3988 evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
3992 SVGURIReference.apply(this);
3995 SVGImageElement.prototype = new SVGElement();
3997 function SVGSwitchElement() {
3998 SVGElement.apply(this, arguments);
4001 SVGSwitchElement.prototype = new SVGElement();
4003 //bookmarkletから呼び出されたらtrue
4005 function GetSVGDocument(ele) {
4011 if ((NAIBU._that.xmlhttp.readyState === 4) && (NAIBU._that.xmlhttp.status === 200)) {
4015 GetSVGDocument.prototype = {
4017 *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
4019 _init : function() {
4020 /*objeiはobject要素かembed要素*/
4021 var xmlhttp = NAIBU.xmlhttp,
4024 if (this._tar.nodeName === "OBJECT") {
4029 xmlhttp.open("GET", objei.getAttribute(data), true);
4030 objei.style.display = "none";
4031 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
4032 this.xmlhttp = xmlhttp;
4033 /*クロージャを利用しないことで、軽量化を計る*/
4035 xmlhttp.onreadystatechange = _ca_;
4037 xmlhttp = objei = data = void 0;
4041 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
4042 *ここでは、responseTextを用いる
4044 var ifr = this._tar.previousSibling,
4045 ifcw = ifr.contentWindow,
4048 ifr.contentWindow.screen.updateInterval = 999;
4049 _doc = ifr.contentWindow.document;
4051 _doc.close(); // これがないと document.body は null になる
4052 } else { //インラインSVGの場合
4055 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
4056 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
4057 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
4058 var st = _doc.createStyleSheet(),
4059 vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
4060 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
4061 + "dn\\:defs{display:none}"
4062 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
4063 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
4064 st = vmlUrl = void 0;
4066 DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
4067 var str = this.xmlhttp.responseText,
4069 s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
4070 tar = s.documentElement,
4071 tview = tar.viewport,
4072 objw, objh, fi, n, attr, att, w, h,
4074 sp = _doc.createElement("div"),
4075 dcp = _doc.createElement("v:group"),
4076 backr = _doc.createElement("v:rect"),
4077 style, fontSize, sw, sh, trstyle, backrs, viewWidth, viewHeight, backdown, backright,
4079 _parseFloat = parseFloat,
4080 ndoc = NAIBU.doc || this.xmlhttp.responseXML,
4081 oba = _doc.createElement("div"); //obaはradialGradient要素で使う
4082 if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
4083 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4086 s._iframe = ifr; //_iframeプロパティはSVGAElementでリンク置換のときに扱う
4087 oba.setAttribute("id","_NAIBU_outline");
4088 _doc.body.appendChild(oba);
4089 sp.style.margin = "-1px,0px,0px,-1px"
4091 _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
4094 /*下記のプロパティについては、Microsoftのサイトを参照
4095 *ResolveExternals Property [Second-level DOM]
4096 * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
4097 *ValidateOnParse Property [Second-level DOM]
4098 * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
4100 ndoc.validateOnParse = false;
4101 ndoc.resolveExternals = false;
4102 ndoc.preserveWhiteSpace = true;
4103 ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
4104 /*IE6-8のみで使えるupdateIntervalは、
4105 *描画間隔の調整が可能。デフォルトは0。
4106 *スクロール時にバグが起きるので、0に戻してやる必要がある。
4108 screen.updateInterval = 999;
4109 if (/&[^;]+;/.test(str)) {
4111 *代替の処理を用いて、実体参照を処理するもの
4114 var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
4115 for (var i=0; i<enti.length; i++) {
4116 var map = enti.item(i);
4117 var regex = new RegExp("&"+map.nodeName+";", "g");
4118 tmp = tmp.replace(regex, map.firstChild.xml);
4125 tview.width = objei.clientWidth;
4126 tview.height = objei.clientHeight;
4127 if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4128 tview.height = screen.availHeight;
4130 if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4131 tar.viewport.height = screen.width;
4133 objw = objei.getAttribute("width");
4134 objh = objei.getAttribute("height");
4136 tar.setAttributeNS(null, "width", objw);
4139 tar.setAttributeNS(null, "height", objh);
4141 fi = ndoc.documentElement.firstChild;
4142 attr = ndoc.documentElement.attributes;
4143 /*ルート要素のNamedNodeMapを検索する*/
4144 for (var i=0,atli=attr.length;i<atli;++i) {
4145 att = s.importNode(attr[i], false);
4146 tar.setAttributeNodeNS(att);
4148 str = attr = void 0;
4149 dcp.style.width = tview.width+ "px";
4150 dcp.style.height = tview.height+ "px";
4151 dcp.coordsize = tview.width+ " " +tview.height;
4152 sp.appendChild(dcp);
4154 _doc.body.appendChild(sp);
4156 this._tar.parentNode.insertBefore(sp, this._tar);
4158 dcp.appendChild(sdt);
4159 while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
4160 n = s.importNode(fi, true);
4162 fi = fi.nextSibling;
4165 /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
4166 *ドキュメントにそのオブジェクトを結び付けておく
4169 /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
4172 style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
4173 fontSize = _parseFloat(style.getPropertyValue("font-size"));
4174 tar.x.baseVal._emToUnit(fontSize);
4175 tar.y.baseVal._emToUnit(fontSize);
4176 tar.width.baseVal._emToUnit(fontSize);
4177 tar.height.baseVal._emToUnit(fontSize);
4178 sw = tar.width.baseVal.value;
4179 sh = tar.height.baseVal.value;
4180 backr.style.position = "absolute";
4183 backr.style.width = w+ "px";
4184 backr.style.height = h+ "px";
4185 backr.style.zIndex = -1;
4186 backr.stroked = "false";
4187 backr.filled = "false";
4188 tar._tar.appendChild(backr);
4189 trstyle = tar._tar.style;
4190 trstyle.visibility = "visible";
4191 trstyle.position = "absolute";
4193 trstyle.overflow = "hidden";
4195 viewWidth = w > sw ? sw : w;
4196 viewHeight = h > sh ? sh : h;
4197 backrs = backr.currentStyle;
4198 bfl = _parseFloat(backrs.left);
4199 bft = _parseFloat(backrs.top);
4200 bl = -tar._tx; //blやbtは、ずれを調整するのに使う
4202 if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
4204 dcp.style.left = -bl+ "px";
4206 if (bft !== 0 && !isNaN(bfl)) {
4208 dcp.style.top = -bt+ "px";
4210 backright = bl + viewWidth + 1;
4211 backdown = bt + viewHeight + 1;
4212 trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
4214 if ("_svgload_limited" in s.documentElement) {
4215 /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
4216 *xlink:href属性が指定されるたびに+1となる。
4217 *0以外は、SVGLoadイベントが発火されない仕組みとなっている
4220 * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
4222 s.documentElement._svgload_limited--;
4223 if (s.documentElement._svgload_limited < 0) {
4224 var evt = s.createEvent("SVGEvents");
4225 evt.initEvent("SVGLoad", false, false);
4226 s.documentElement.dispatchEvent(evt);
4230 text = s.documentElement._tar.getElementsByTagName("div");
4231 for (var i=0, texti;text[i];++i) {
4233 if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
4234 var tis = texti.style;
4235 tis.left = _parseFloat(tis.left) + bl + "px";
4236 tis.top = _parseFloat(tis.top) + bt + "px";
4240 //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
4241 ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
4242 s._isLoaded = 1; //_isLoadedプロパティはevents::dispatchEventメソッドで使う
4243 s.defaultView._cache = s.defaultView._cache_ele = null;
4244 oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
4245 trstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
4246 /*IEのメモリリーク対策として、空関数を入力*/
4247 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4249 ifcw && (ifr.contentWindow.screen.updateInterval = 0);
4250 ifr = ifcw = s = void 0;
4254 if (s.implementation._buffer_) {
4255 screen.updateInterval = 0;
4256 /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
4257 NAIBU._buff_num = 0;
4258 NAIBU._buff = setInterval(function(){
4259 var n = NAIBU._buff_num,
4260 dbuf = DOMImplementation._buffer_,
4261 dbufli = dbuf ? dbuf.length : 0, //極端な負荷がかかると、dbufはnullになる可能性あり
4264 clearInterval(NAIBU._buff);
4266 for (var i=0;i<50;++i) {
4269 s.dispatchEvent(evt);
4273 clearInterval(NAIBU._buff);
4274 DOMImplementation._buffer_ = null;
4276 dbuf = n = dbufli = void 0;
4280 NAIBU._buff_num = n;
4282 dbuf = n = dbufli = void 0;
4284 ifr = ifcw = s = void 0;
4286 ifr = ifcw = s = void 0;
4292 /*SVGDocument*/ getSVGDocument : function() {
4293 return (this._document);
4296 /*空関数(IEのメモリリーク対策)*/
4297 NAIBU.emptyFunction = function() {};
4302 function SVGStyleElement(_doc) {
4303 SVGElement.apply(this);
4304 LinkStyle.apply(this);
4305 /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
4306 *CSS2 1. Document Object Model Style Sheets
4307 * 1.3. Document Extensions
4308 * Interface LinkStyle (introduced in DOM Level 2)
4309 * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
4311 /*以下はそれぞれ、属性の値に対応している*/
4312 /*DOMString*/ this.xmlspace;
4313 /*DOMString*/ this.type = "text/css";
4314 /*DOMString*/ this.media;
4315 /*DOMString*/ this.title;
4316 SVGURIReference.apply(this);
4317 this.addEventListener("DOMAttrModified", function(evt){
4318 if (evt.attrName === "type") {
4319 evt.target.type = evt.newValue;
4320 } else if (evt.attrName === "title") {
4321 evt.target.title = evt.newValue;
4325 this.addEventListener("S_Load", function(evt){
4326 var tar = evt.target,
4328 styleText = tar._text,
4329 tod = tar.ownerDocument,
4330 style = _doc.createElement("style"),
4332 NAIBU._temp_doc = tod;
4333 sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
4334 sheet.ownerNode = tar;
4335 /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
4336 _doc.documentElement.firstChild.appendChild(style);
4337 style.styleSheet.cssText = styleText;
4338 for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
4340 scri = new CSSStyleRule();
4341 scri.selectorText = ri.selectorText;
4342 scri.style.cssText = ri.style.cssText;
4343 rsc = scri.style.cssText.split(";");
4344 for (var j=0, rsli=rsc.length;j<rsli;++j) {
4345 rsi = rsc[j].split(": ");
4346 scri.style.setProperty(rsi[0], rsi[1]);
4348 sheet.cssRules[sheet.cssRules.length] = scri;
4350 tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4351 var tar = evt.target,
4352 doc = tar.ownerDocument,
4353 rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
4354 selector, ru, tcb = tar.className.baseVal || ".,.";
4355 for (var i=0, rli=rules.length;i<rli;++i) {
4356 selector = rules[i].selectorText;
4357 /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
4358 ru = tar._rules || [];
4359 if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
4360 || (tar.nodeName === selector)) {
4361 ru[ru.length] = rules[i];
4365 tar = doc = rules = void 0;
4367 tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
4369 this.addEventListener("DOMNodeInserted", function(evt){
4370 var tar = evt.target;
4371 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4372 if (tar.nodeName === "#cdata-section") {
4373 evt.currentTarget._text = tar.data;
4377 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4378 var tar = evt.target;
4379 if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
4380 var evtt = tar.ownerDocument.createEvent("SVGEvents");
4381 evtt.initEvent("S_Load", false, false);
4382 evt.currentTarget.dispatchEvent(evtt);
4389 SVGStyleElement.prototype = new SVGElement();
4392 *2次元座標の点(x,y)を表すオブジェクト
4394 function SVGPoint() {
4397 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
4398 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
4399 if (!isFinite(matrix.a) || !isFinite(matrix.b) || !isFinite(matrix.c) || !isFinite(matrix.d) || !isFinite(matrix.e) || !isFinite(matrix.f)) {
4400 throw (new Error("Type Error: 引数の値がNumber型ではありません"));
4402 var s = new SVGPoint();
4403 s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
4404 s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
4408 function SVGPointList() {
4411 /*SVGPointListのメソッドはSVGPathSegListを参照*/
4414 *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
4419 function SVGMatrix() {
4422 SVGMatrix.prototype = {
4432 /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
4433 var s = new SVGMatrix(), m = secondMatrix;
4434 if (!isFinite(m.a) || !isFinite(m.b) || !isFinite(m.c) || !isFinite(m.d) || !isFinite(m.e) || !isFinite(m.f)) {
4435 throw (new Error("Type Error: 引数の値がNumber型ではありません"));
4437 s.a = this.a * m.a + this.c * m.b;
4438 s.b = this.b * m.a + this.d * m.b;
4439 s.c = this.a * m.c + this.c * m.d;
4440 s.d = this.b * m.c + this.d * m.d;
4441 s.e = this.a * m.e + this.c * m.f + this.e;
4442 s.f = this.b * m.e + this.d * m.f + this.f;
4443 m = secondMatrix = void 0;
4449 /*SVGMatrix*/ inverse : function() {
4450 var s = new SVGMatrix(), n = this._determinant();
4456 s.e = (this.c * this.f - this.d * this.e) / n;
4457 s.f = (this.b * this.e - this.a * this.f) / n;
4460 throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
4463 /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
4464 var m = new SVGMatrix();
4467 var s = this.multiply(m);
4471 /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
4472 var m = new SVGMatrix();
4475 var s = this.multiply(m);
4479 /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
4480 var m = new SVGMatrix();
4483 var s = this.multiply(m);
4487 /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
4488 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4489 m.a = Math.cos(rad);
4490 m.b = Math.sin(rad);
4493 var s = this.multiply(m);
4497 //座標(x, y)と原点の角度の分だけ、回転する
4498 /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
4499 if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
4500 throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
4502 var m = new SVGMatrix(), rad = Math.atan2(y, x);
4503 m.a = Math.cos(rad);
4504 m.b = Math.sin(rad);
4507 var s = this.multiply(m);
4511 /*SVGMatrix*/ flipX : function() {
4512 var m = new SVGMatrix();
4514 var s = this.multiply(m);
4518 /*SVGMatrix*/ flipY : function() {
4519 var m = new SVGMatrix();
4521 var s = this.multiply(m);
4525 /*SVGMatrix*/ skewX : function(/*float*/ angle ){
4526 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4527 m.c = Math.tan(rad);
4528 var s = this.multiply(m);
4532 /*SVGMatrix*/ skewY : function(/*float*/ angle ){
4533 var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
4534 m.b = Math.tan(rad);
4535 var s = this.multiply(m);
4540 /*float*/ _determinant : function() {
4541 return (this.a * this.d - this.b * this.c);
4545 function SVGTransform() {
4546 /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
4550 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN = 0;
4551 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX = 1;
4552 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
4553 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE = 3;
4554 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE = 4;
4555 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX = 5;
4556 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY = 6;
4557 SVGTransform.prototype = {
4558 /*ダミーの単位行列。各メソッドで使う*/
4559 _matrix : (new SVGMatrix()),
4560 /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
4561 /*readonly float*/ angle : 0,
4562 /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
4563 this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
4564 this.matrix = this._matrix.multiply(matrix);
4566 /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
4567 this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
4568 this.matrix = this._matrix.translate(tx, ty);
4570 /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
4571 this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
4572 this.matrix = this._matrix.scaleNonUniform(sx, sy);
4574 /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
4576 this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
4577 this.matrix = this._matrix.rotate(angle);
4578 this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
4579 this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
4581 /*void*/ setSkewX : function(/*float*/ angle ) {
4583 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
4584 this.matrix = this._matrix.skewX(angle);
4586 /*void*/ setSkewY : function(/*float*/ angle ) {
4588 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
4589 this.matrix = this._matrix.skewY(angle);
4593 function SVGTransformList() {
4596 /*SVGTransformListのメソッドはSVGPathSegListを参照*/
4598 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
4599 var t = new SVGTransform();
4600 t.setMatrix(matrix);
4603 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
4604 if(this.numberOfItems === 0) {
4607 var s = this.getItem(0), m = s.matrix;
4608 for (var i=1,nli=this.numberOfItems;i<nli;++i) {
4609 m = m.multiply(this.getItem(i).matrix);
4617 function SVGAnimatedTransformList() {
4618 /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
4621 function SVGPreserveAspectRatio() {
4622 /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
4623 /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
4628 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
4629 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE = 1;
4630 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
4631 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
4632 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
4633 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
4634 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
4635 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
4636 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
4637 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
4638 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
4639 // Meet-or-slice Types
4640 /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN = 0;
4641 /*unsigned short*/ t.SVG_MEETORSLICE_MEET = 1;
4642 /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
4643 })(SVGPreserveAspectRatio);
4645 function SVGAnimatedPreserveAspectRatio() {
4646 /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
4650 function SVGPathSeg() {
4651 /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
4652 /*readonly DOMString*/ this.pathSegTypeAsLetter = null;
4657 // Path Segment Types
4658 /*unsigned short*/ t.PATHSEG_UNKNOWN = 0;
4659 /*unsigned short*/ t.PATHSEG_CLOSEPATH = 1;
4660 /*unsigned short*/ t.PATHSEG_MOVETO_ABS = 2;
4661 /*unsigned short*/ t.PATHSEG_MOVETO_REL = 3;
4662 /*unsigned short*/ t.PATHSEG_LINETO_ABS = 4;
4663 /*unsigned short*/ t.PATHSEG_LINETO_REL = 5;
4664 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS = 6;
4665 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL = 7;
4666 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS = 8;
4667 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL = 9;
4668 /*unsigned short*/ t.PATHSEG_ARC_ABS = 10;
4669 /*unsigned short*/ t.PATHSEG_ARC_REL = 11;
4670 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS = 12;
4671 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL = 13;
4672 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS = 14;
4673 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL = 15;
4674 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;
4675 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;
4676 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
4677 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
4680 *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
4682 function SVGPathSegClosePath() {
4685 SVGPathSegClosePath.prototype = {
4686 pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
4687 pathSegTypeAsLetter : "z"
4689 function SVGPathSegMovetoAbs() {
4694 SVGPathSegMovetoAbs.prototype = {
4695 pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
4696 pathSegTypeAsLetter : "M"
4698 function SVGPathSegMovetoRel() {
4703 SVGPathSegMovetoRel.prototype = {
4704 pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
4705 pathSegTypeAsLetter : "m"
4707 function SVGPathSegLinetoAbs() {
4712 SVGPathSegLinetoAbs.prototype = {
4713 pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
4714 pathSegTypeAsLetter : "L"
4716 function SVGPathSegLinetoRel() {
4721 SVGPathSegLinetoRel.prototype = {
4722 pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
4723 pathSegTypeAsLetter : "l"
4725 function SVGPathSegCurvetoCubicAbs() {
4734 SVGPathSegCurvetoCubicAbs.prototype = {
4735 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
4736 pathSegTypeAsLetter : "C"
4738 function SVGPathSegCurvetoCubicRel() {
4747 SVGPathSegCurvetoCubicRel.prototype = {
4748 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
4749 pathSegTypeAsLetter : "c"
4751 function SVGPathSegCurvetoQuadraticAbs() {
4756 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
4757 this.pathSegTypeAsLetter = "Q";
4760 function SVGPathSegCurvetoQuadraticRel() {
4765 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
4766 this.pathSegTypeAsLetter = "q";
4770 function SVGPathSegArcAbs() {
4775 /*float*/ this.angle;
4778 SVGPathSegArcAbs.prototype = {
4779 /*boolean*/ largeArcFlag : true,
4780 /*boolean*/ sweepFlag : true,
4781 pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
4782 pathSegTypeAsLetter : "A"
4784 function SVGPathSegArcRel() {
4789 /*float*/ this.angle;
4792 SVGPathSegArcRel.prototype = {
4793 /*boolean*/ largeArcFlag : true,
4794 /*boolean*/ sweepFlag : true,
4795 pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
4796 pathSegTypeAsLetter : "a"
4798 function SVGPathSegLinetoHorizontalAbs() {
4800 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
4801 this.pathSegTypeAsLetter = "H";
4804 function SVGPathSegLinetoHorizontalRel() {
4806 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
4807 this.pathSegTypeAsLetter = "h";
4810 function SVGPathSegLinetoVerticalAbs() {
4812 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
4813 this.pathSegTypeAsLetter = "V";
4816 function SVGPathSegLinetoVerticalRel() {
4818 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
4819 this.pathSegTypeAsLetter = "v";
4822 function SVGPathSegCurvetoCubicSmoothAbs() {
4827 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
4828 this.pathSegTypeAsLetter = "S";
4831 function SVGPathSegCurvetoCubicSmoothRel() {
4836 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
4837 this.pathSegTypeAsLetter = "s";
4840 function SVGPathSegCurvetoQuadraticSmoothAbs() {
4843 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
4844 this.pathSegTypeAsLetter = "T";
4847 function SVGPathSegCurvetoQuadraticSmoothRel() {
4850 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
4851 this.pathSegTypeAsLetter = "t";
4854 function SVGPathSegList() {
4857 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4858 SVGNumberList.prototype[prop] = SVGLengthList.prototype[prop] = SVGPointList.prototype[prop] = SVGTransformList.prototype[prop] = SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
4862 /*documentは引数の変数として登録しておく*/
4863 (function(_doc, _math) {
4864 //freeArg関数はunloadで使う解放処理
4865 NAIBU.freeArg = function() {
4866 SVGPathElement = _doc = _math = void 0;
4868 //仮のfill属性とstroke属性の処理
4869 NAIBU._setPaint = function(tar, matrix) {
4870 /*以下では、スタイルシートを用いて、fill-とstroke-関連の
4871 *処理を行う。SVGPaintインターフェースをも用いる
4873 var tod = tar.ownerDocument,
4874 _doc = tod._document_,
4876 style = tod.defaultView.getComputedStyle(tar, ""),
4877 fill = style.getPropertyCSSValue("fill"),
4878 stroke = style.getPropertyCSSValue("stroke"),
4879 fp = fill.paintType,
4880 sp = stroke.paintType,
4882 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
4883 t, evtt, fillOpacity, strs, cursor, vis, disp,
4884 strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
4888 /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
4889 while (el.firstChild) {
4890 el.removeChild(el.firstChild);
4892 if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4893 if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4894 /*再度、設定。css.jsのsetPropertyを参照*/
4895 style.setProperty("color", style.getPropertyValue("color"));
4897 fillElement = _doc.createElement("v:fill");
4899 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
4900 fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4901 fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
4902 if (fillOpacity < 1) {
4903 fillElement.setAttribute("opacity", fillOpacity+"");
4905 el.appendChild(fillElement);
4906 fillElement = fc = fillOpacity = void 0;
4907 } else if (fill.uri) {
4908 /*以下では、Gradation関連の要素に、イベントを渡すことで、
4911 t = tod.getElementById(fill.uri);
4913 evtt = tod._domnodeEvent();
4914 evtt._tar = _doc.createElement("v:fill");
4915 evtt._style = style;
4917 t.dispatchEvent(evtt);
4918 if (t.localName !== "radialGradient") {
4919 el.appendChild(evtt._tar);
4924 el.filled = "false";
4926 if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4927 if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4928 /*再度、設定。css.jsのsetPropertyを参照*/
4929 style.setProperty("color", style.getPropertyValue("color"));
4931 strokeElement = _doc.createElement("v:stroke");
4932 sgsw = style.getPropertyCSSValue("stroke-width");
4933 w = tod.documentElement.viewport.width;
4934 h = tod.documentElement.viewport.height;
4935 sgsw._percent = _math.sqrt((w*w + h*h) / 2);
4936 swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
4937 strokeElement.setAttribute("weight", swx + "px");
4938 sgsw = w = h = void 0;
4940 fc = stroke.rgbColor;
4941 strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4942 strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
4944 strokeOpacity *= swx; //太さが1px未満なら色を薄くする
4946 if (strokeOpacity < 1) {
4947 strokeElement.setAttribute("opacity", strokeOpacity+"");
4949 fc = strokeOpacity = void 0;
4951 strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
4952 strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
4953 if (style.getPropertyValue("stroke-linecap") === "butt") {
4954 strokeElement.setAttribute("endcap", "flat");
4956 strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
4958 tsd = style.getPropertyValue("stroke-dasharray");
4959 if (tsd !== "none") {
4960 if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
4961 strs = tsd.split(",");
4962 for (var i = 0, sli = strs.length; i < sli; ++i) {
4963 strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
4965 strokedasharray = strs.join(" ");
4966 if (strs.length % 2 === 1) {
4967 strokedasharray += " " + strokedasharray;
4970 strokeElement.setAttribute("dashstyle", strokedasharray);
4971 tsd = strs = void 0;
4973 el.appendChild(strokeElement);
4974 strokeElement = tsd = void 0;
4976 el.stroked = "false";
4978 cursor = style.getPropertyCSSValue("cursor");
4979 if (cursor && !cursor._isDefault) { //初期値でないならば
4980 el.style.cursor = cursor.cssText.split(":")[1];
4982 vis = style.getPropertyCSSValue("visibility");
4983 if (vis && !vis._isDefault) {
4984 el.style.visibility = vis.cssText.split(":")[1];
4986 disp = style.getPropertyCSSValue("display");
4987 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
4988 el.style.display = "none";
4989 } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
4990 el.style.display = "inline-block";
4992 tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
4995 function SVGPathElement(_doc) {
4996 SVGElement.apply(this);
4997 this._tar = _doc.createElement("v:shape");
4998 //interface SVGAnimatedPathData
4999 var sp = SVGPathSegList;
5000 /*readonly SVGPathSegList*/ this.pathSegList = new sp();
5001 this.animatedPathSegList = this.pathSegList;
5002 /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
5004 this.animatedNormalizedPathSegList = this.normalizedPathSegList;
5005 /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
5006 //以下は、d属性に変更があった場合の処理
5007 this.addEventListener("DOMAttrModified", this._attrModi, false);
5008 /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
5009 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
5011 this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
5014 SVGPathElement.prototype = new SVGElement();
5015 (function(_sproto) {
5016 _sproto._attrModi = function(evt){
5017 var tar = evt.target;
5018 if (evt.attrName === "d" && evt.newValue !== ""){
5019 /* d属性の値が空の場合は、描画を行わないようにする
5021 *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
5023 var tnl = tar.normalizedPathSegList,
5024 tlist = tar.pathSegList;
5025 if (tnl.numberOfItems > 0) {
5029 /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
5031 *D = [["M", 20, 30], ["L", 20 40]]
5033 var taco = tar._com,
5036 .replace(taco.isRa, " -")
5037 .replace(taco.isRb, " ")
5038 .replace(taco.isRc, ",$1 ")
5039 .replace(taco.isRd, ",$1 1")
5040 .replace(taco.isRe, "")
5047 tcc = tar.createSVGPathSegCurvetoCubicAbs,
5048 tcll = tar.createSVGPathSegLinetoAbs;
5049 for (var i=0;i<dli;++i) {
5050 var di = dd[i].match(sgs),
5052 for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
5054 s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5056 } else if (isL[dii]) {
5057 s = tcll(+di[j], +di[j+1]);
5059 } else if (isM[dii]) {
5060 s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
5062 } else if (isZ[dii]) {
5063 s = tar.createSVGPathSegClosePath();
5064 } else if (dii === "A") {
5065 s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5067 } else if (dii === "m") {
5068 s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
5070 } else if (dii === "l") {
5071 s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
5073 } else if (dii === "c") {
5074 s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5076 } else if (dii === "Q") {
5077 s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5079 } else if (dii === "q") {
5080 s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5082 } else if (dii === "a") {
5083 s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5085 } else if (dii === "S") {
5086 s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5088 } else if (dii === "s") {
5089 s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5091 } else if (dii === "T") {
5092 s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
5094 } else if (dii === "t") {
5095 s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
5097 } else if (dii === "H") {
5098 s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
5099 } else if (dii === "h") {
5100 s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
5101 } else if (dii === "V") {
5102 s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
5103 } else if (dii === "v") {
5104 s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
5106 s = new SVGPathSeg();
5108 tlist.appendItem(s);
5111 di = s = sgs = dd = void 0;
5112 /*以下の処理は、pathSegListからnormalizedPathSegListへの
5113 *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
5115 var cx = 0, cy = 0, //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
5116 xn = 0, yn = 0, //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
5117 startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
5118 for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
5119 var ti = tlist.getItem(j),
5120 ts = ti.pathSegType,
5121 dii = ti.pathSegTypeAsLetter;
5122 if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
5124 var rx = cx, ry = cy; //rx, ryは前のセグメントの終了点
5125 if (ts % 2 === 1) { //相対座標ならば
5134 } else if (isL[dii]) {
5136 } else if (isM[dii]) {
5138 /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
5139 *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
5140 *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
5142 var tg = tlist.getItem(j-1);
5143 if (tg.pathSegTypeAsLetter === "M") {
5144 tnl.appendItem(tcll(cx, cy));
5151 } else if (dii === "m") {
5153 var tg = tlist.getItem(j-1);
5154 if (tg.pathSegTypeAsLetter === "m") {
5155 tnl.appendItem(tcll(cx, cy));
5161 tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
5162 } else if (dii === "l") {
5163 tnl.appendItem(tcll(cx, cy));
5164 } else if (dii === "c") {
5165 tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
5166 } else if (isZ[dii]) {
5170 } else if (dii === "Q") {
5173 //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
5174 tnl.appendItem(tcc(cx, cy, (rx + 2*ti.x1) / 3, (ry + 2*ti.y1) / 3, (2*ti.x1 + cx) / 3, (2*ti.y1 + cy) / 3));
5175 } else if (dii === "q") {
5176 var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
5179 tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
5181 } else if (dii === "A" || dii === "a") {
5182 (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
5183 /*以下は、Arctoを複数のCuvetoに変換する処理
5184 *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
5185 *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
5187 if (ti.r1 === 0 || ti.r2 === 0) {
5190 var fS = ti.sweepFlag,
5192 r1 = _math.abs(ti.r1),
5193 r2 = _math.abs(ti.r2),
5194 ctx = (rx - cx) / 2, cty = (ry - cy) / 2,
5195 cpsi = _math.cos(psai * _math.PI / 180),
5196 spsi = _math.sin(psai * _math.PI / 180),
5197 rxd = cpsi*ctx + spsi*cty,
5198 ryd = -1*spsi*ctx + cpsi*cty,
5199 rxdd = rxd * rxd, rydd = ryd * ryd,
5202 lamda = rxdd/r1x + rydd/r2y,
5205 r1 = _math.sqrt(lamda) * r1;
5206 r2 = _math.sqrt(lamda) * r2;
5210 if (ti.largeArcFlag === fS) {
5213 sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
5215 var txd = sds*r1*ryd / r2,
5216 tyd = -1 * sds*r2*rxd / r1,
5217 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
5218 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
5219 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
5220 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
5221 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
5222 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
5223 if (!fS && dr > 0) {
5225 } else if (fS && dr < 0) {
5228 var sse = dr * 2 / _math.PI,
5229 seg = _math.ceil(sse<0 ? -1*sse : sse),
5231 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
5232 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
5233 spsir1 = spsi * r1, spsir2 = spsi * r2,
5236 x2 = rx - t * (cpsir1*ms + spsir2*mc),
5237 y2 = ry - t * (spsir1*ms - cpsir2*mc);
5238 for (var n = 0; n < seg; ++n) {
5242 var x3 = cpsir1*mc - spsir2*ms + tx,
5243 y3 = spsir1*mc + cpsir2*ms + ty,
5244 dx = -t * (cpsir1*ms + spsir2*mc),
5245 dy = -t * (spsir1*ms - cpsir2*mc);
5246 tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
5250 ti= cx= cy= rx= ry= tar= tnl = void 0;
5251 })(ti, cx, cy, rx, ry, tar, tnl);
5252 } else if (dii === "S") {
5254 var tg = tnl.getItem(tnl.numberOfItems-1);
5255 if (tg.pathSegTypeAsLetter === "C") {
5256 var x1 = 2*tg.x - tg.x2,
5257 y1 = 2*tg.y - tg.y2;
5258 } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
5266 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
5268 } else if (dii === "s") {
5270 var tg = tnl.getItem(tnl.numberOfItems-1);
5271 if (tg.pathSegTypeAsLetter === "C") {
5272 var x1 = 2*tg.x - tg.x2,
5273 y1 = 2*tg.y - tg.y2;
5282 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
5284 } else if (dii === "T" || dii === "t") {
5286 var tg = tlist.getItem(j-1);
5287 if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
5294 tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
5298 } else if (dii === "H" || dii === "h") {
5299 tnl.appendItem(tcll(cx, ry));
5300 cy = ry; //勝手にti.yが0としているため
5301 } else if (dii === "V" || dii === "v") {
5302 tnl.appendItem(tcll(rx, cy));
5308 evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
5310 _sproto._nodeInsert = function(evt){
5311 var tar = evt.target;
5312 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5315 var tnext = tar.nextSibling,
5316 tpart = tar.parentNode._tar,
5318 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5319 tpart.insertBefore(tar._tar, tnext._tar);
5320 } else if (tnext && !tnext._tar && tpart) {
5321 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5322 *use要素や実体参照などは_tarプロパティがないことに注意
5325 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5326 tpart.insertBefore(tar._tar, tnext._tar);
5329 tnext = tnext.nextSibling;
5332 tpart.appendChild(tar._tar);
5334 } else if (!tnext && tpart) {
5335 tpart.appendChild(tar._tar);
5337 tnext = tpart = isLast = void 0;
5338 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
5341 _sproto._nodeInsertInto = function(evt){
5342 /*以下の処理は、normalizedpathSegListとCTMに基づいて、
5343 *SVGのd属性をVMLに変換していく処理である。
5345 var tar = evt.target,
5346 matrix = tar.getScreenCTM(),
5347 tlist = tar.normalizedPathSegList,
5349 ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
5350 cname = tar._com._nameCom,
5351 isZ = tar._com._isZ, isC = tar._com._isC,
5353 for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
5357 tps = ti.pathSegTypeAsLetter,
5360 /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
5365 t += [mr(ma*ti.x1 + mc*ti.y1 + me),
5366 mr(mb*ti.x1 + md*ti.y1 + mf),
5367 mr(ma*ti.x2 + mc*ti.y2 + me),
5368 mr(mb*ti.x2 + md*ti.y2 + mf),
5369 mr(ma*tx + mc*ty + me),
5370 mr(mb*tx + md*ty + mf)].join(" ");
5371 } else if (!isZ[tps]) {
5372 t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
5376 var vi = tar.ownerDocument.documentElement,
5379 tt.path = dat.join(" ");
5380 tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
5381 NAIBU._setPaint(tar, matrix);
5382 delete tar._cacheMatrix;
5383 evt = tar = dat = t = tx = ty = matrix = tlist = x = y = mr = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
5408 isRc : /([a-yA-Y])/g,
5413 /*float*/ _sproto.getTotalLength = function() {
5415 nl = this.normalizedPathSegList;
5416 for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5417 var seg = nl.getItem(i);
5418 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5419 var ps = nl.getItem(i-1);
5420 s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5421 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5422 var ps = nl.getItem(i-1), dd = 0;
5423 /*2点のハンドルを結んだ線分の3辺と、
5424 *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
5427 *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
5428 *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
5430 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5431 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5432 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5433 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5435 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5436 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5437 s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5441 this.pathLength.baseVal = s;
5444 /*SVGPoint*/ _sproto.getPointAtLength = function(/*float*/ distance ) {
5445 var segn = this.getPathSegAtLength(distance),
5448 nl = this.normalizedPathSegList,
5449 seg = nl.getItem(segn),
5450 s = this.ownerDocument.documentElement.createSVGPoint();
5451 if ((segn-1) <= 0) {
5456 var ps = nl.getItem(segn-1);
5457 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5458 var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5459 var t = (segl + this._dis) / segl;
5460 s.x = ps.x + t * (seg.x-ps.x);
5461 s.y = ps.y + t * (seg.y-ps.y);
5462 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5464 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5465 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5466 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5467 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5469 var t = (segl + this._dis) / segl;
5470 /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
5473 s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
5474 +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
5475 +3*(seg.x1 - ps.x) * t
5477 s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
5478 +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
5479 +3*(seg.y1 - ps.y) * t
5481 } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
5484 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5485 var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
5486 var t = (segl + this._dis) / segl;
5487 s.x = ms.x + t * (seg.x-ms.x);
5488 s.y = ms.y + t * (seg.y-ms.y);
5492 /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
5493 var nl = this.normalizedPathSegList; //仕様ではpathSegList
5494 for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5495 var seg = nl.getItem(i);
5496 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5497 var ps = nl.getItem(i-1);
5498 distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5499 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5500 var ps = nl.getItem(i-1), dd = 0;
5501 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5502 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5503 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5504 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5507 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5508 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5509 distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5511 if (distance <= 0) {
5512 /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
5513 this._dis = distance;
5518 /*もし、distanceがパスの距離よりも長い場合、
5520 *なお、これはSVG1.1の仕様の想定外のこと
5522 return (nl.numberOfItems - 1);
5524 /*SVGPathSegClosePath*/ _sproto.createSVGPathSegClosePath = function() {
5525 var _SVGPathSegClosePath = SVGPathSegClosePath;
5526 return (new _SVGPathSegClosePath());
5528 /*SVGPathSegMovetoAbs*/ _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
5529 var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
5534 /*SVGPathSegMovetoRel*/ _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
5535 var s = new SVGPathSegMovetoRel();
5540 /*SVGPathSegLinetoAbs*/ _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
5541 var s = new SVGPathSegLinetoAbs();
5546 /*SVGPathSegLinetoRel*/ _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
5547 var s = new SVGPathSegLinetoRel();
5552 /*SVGPathSegCurvetoCubicAbs*/ _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5553 var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
5562 /*SVGPathSegCurvetoCubicRel*/ _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5563 var s = new SVGPathSegCurvetoCubicRel();
5572 /*SVGPathSegCurvetoQuadraticAbs*/ _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5573 var s = new SVGPathSegCurvetoQuadraticAbs();
5580 /*SVGPathSegCurvetoQuadraticRel*/ _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5581 var s = new SVGPathSegCurvetoQuadraticRel();
5588 /*SVGPathSegArcAbs*/ _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5589 var s = new SVGPathSegArcAbs();
5595 s.largeArcFlag = largeArcFlag;
5596 s.sweepFlag = sweepFlag;
5599 /*SVGPathSegArcRel*/ _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5600 var s = new SVGPathSegArcRel();
5606 s.largeArcFlag = largeArcFlag;
5607 s.sweepFlag = sweepFlag;
5610 /*SVGPathSegLinetoHorizontalAbs*/ _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
5611 var s = new SVGPathSegLinetoHorizontalAbs();
5613 s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
5616 /*SVGPathSegLinetoHorizontalRel*/ _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
5617 var s = new SVGPathSegLinetoHorizontalRel();
5622 /*SVGPathSegLinetoVerticalAbs*/ _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
5623 var s = new SVGPathSegLinetoVerticalAbs();
5628 /*SVGPathSegLinetoVerticalRel*/ _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
5629 var s = new SVGPathSegLinetoVerticalRel();
5634 /*SVGPathSegCurvetoCubicSmoothAbs*/ _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5635 var s = new SVGPathSegCurvetoCubicSmoothAbs();
5642 /*SVGPathSegCurvetoCubicSmoothRel*/ _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5643 var s = new SVGPathSegCurvetoCubicSmoothRel();
5650 /*SVGPathSegCurvetoQuadraticSmoothAbs*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
5651 var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
5656 /*SVGPathSegCurvetoQuadraticSmoothRel*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
5657 var s = new SVGPathSegCurvetoQuadraticSmoothRel();
5662 })(SVGPathElement.prototype)
5663 NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
5666 function SVGRectElement(_doc) {
5667 SVGElement.apply(this);
5668 this._tar = _doc.createElement("v:shape");
5669 var slen = SVGAnimatedLength;
5670 /*readonly SVGAnimatedLength*/ this.x = new slen();
5671 /*readonly SVGAnimatedLength*/ this.y = new slen();
5672 /*readonly SVGAnimatedLength*/ this.width = new slen();
5673 /*readonly SVGAnimatedLength*/ this.height = new slen();
5674 /*readonly SVGAnimatedLength*/ this.rx = new slen();
5675 /*readonly SVGAnimatedLength*/ this.ry = new slen();
5676 _doc = slen = void 0;
5677 this.addEventListener("DOMNodeInserted", function(evt){
5678 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5681 var tar = evt.target,
5682 tnext = tar.nextSibling,
5683 tpart = tar.parentNode._tar,
5685 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5686 tpart.insertBefore(tar._tar, tnext._tar);
5687 } else if (tnext && !tnext._tar && tpart) {
5688 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5689 *use要素や実体参照などは_tarプロパティがないことに注意
5692 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5693 tpart.insertBefore(tar._tar, tnext._tar);
5696 tnext = tnext.nextSibling;
5699 tpart.appendChild(tar._tar);
5701 } else if (!tnext && tpart) {
5702 tpart.appendChild(tar._tar);
5704 tnext = tpart = isLast = void 0;
5705 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5706 var tar = evt.target,
5707 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5708 fontSize = parseFloat(style.getPropertyValue("font-size"));
5709 tar.x.baseVal._emToUnit(fontSize);
5710 tar.y.baseVal._emToUnit(fontSize);
5711 tar.width.baseVal._emToUnit(fontSize);
5712 tar.height.baseVal._emToUnit(fontSize);
5713 var rx = tar.getAttributeNS(null, "rx"),
5714 ry = tar.getAttributeNS(null, "ry"),
5715 x = tar.x.baseVal.value,
5716 y = tar.y.baseVal.value,
5717 xw = x + tar.width.baseVal.value,
5718 yh = y + tar.height.baseVal.value,
5720 if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
5721 tar.rx.baseVal._emToUnit(fontSize);
5722 tar.ry.baseVal._emToUnit(fontSize);
5723 var thrx = tar.rx.baseVal,
5724 thry = tar.ry.baseVal,
5725 twidth = tar.width.baseVal.value,
5726 theight = tar.height.baseVal.value;
5727 thrx.value = rx ? thrx.value : thry.value;
5728 thry.value = ry ? thry.value : thrx.value;
5729 //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
5730 if (thrx.value > twidth / 2) {
5731 thrx.value = twidth / 2;
5733 if (thry.value > theight / 2) {
5734 thry.value = theight / 2;
5736 var rxv = thrx.value,
5738 rrx = rxv * 0.55228,
5739 rry = ryv * 0.55228,
5744 list = ["m",b,y, "l",a,y, "c",a+rrx,y,xw,c-rry,xw,c, "l",xw,d, "c",xw,d+rry,a+rrx,yh,a,yh, "l",b,yh, "c",b-rrx,yh,x,d+rry,x,d, "l",x,c, "c",x,c-rry,b-rrx,y,b,y];
5746 list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
5748 //以下は、配列listそのものをCTMで座標変換していく処理
5749 var par = tar.ownerDocument.documentElement,
5750 ctm = tar.getScreenCTM(),
5753 vi = tar.ownerDocument.documentElement,
5754 w = vi.width.baseVal.value,
5755 h = vi.height.baseVal.value,
5757 for (var i=0, lili=list.length;i<lili;) {
5758 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5762 p = par.createSVGPoint();
5765 pmt = p.matrixTransform(ctm);
5766 list[i] = mr(pmt.x);
5768 list[i] = mr(pmt.y);
5772 dat = list.join(" ");
5775 ele.coordsize = w + " " + h;
5776 NAIBU._setPaint(tar, ctm);
5777 delete tar._cacheMatrix;
5778 evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
5784 SVGRectElement.prototype = new SVGElement();
5786 function SVGCircleElement(_doc) {
5787 SVGElement.apply(this);
5788 this._tar = _doc.createElement("v:shape");
5789 var sl = SVGAnimatedLength;
5790 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5791 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5792 /*readonly SVGAnimatedLength*/ this.r = new sl();
5794 this.addEventListener("DOMNodeInserted", function(evt){
5795 var tar = evt.target;
5796 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5799 var tnext = tar.nextSibling,
5800 tpart = tar.parentNode._tar,
5802 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5803 tpart.insertBefore(tar._tar, tnext._tar);
5804 } else if (tnext && !tnext._tar && tpart) {
5805 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5806 *use要素や実体参照などは_tarプロパティがないことに注意
5809 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5810 tpart.insertBefore(tar._tar, tnext._tar);
5813 tnext = tnext.nextSibling;
5816 tpart.appendChild(tar._tar);
5818 } else if (!tnext && tpart) {
5819 tpart.appendChild(tar._tar);
5821 tnext = tpart = isLast = void 0;
5822 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5823 var tar = evt.target,
5824 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5825 fontSize = parseFloat(style.getPropertyValue("font-size"));
5826 tar.cx.baseVal._emToUnit(fontSize);
5827 tar.cy.baseVal._emToUnit(fontSize);
5828 tar.r.baseVal._emToUnit(fontSize);
5829 var cx = tar.cx.baseVal.value,
5830 cy = tar.cy.baseVal.value,
5831 rx = ry = tar.r.baseVal.value,
5838 list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
5839 //以下は、配列listそのものをCTMで座標変換していく処理
5840 var par = tar.ownerDocument.documentElement,
5841 ctm = tar.getScreenCTM(),
5843 for (var i=0, lili=list.length;i<lili;) {
5844 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5848 var p = par.createSVGPoint();
5851 var pmt = p.matrixTransform(ctm);
5852 list[i] = mr(pmt.x);
5854 list[i] = mr(pmt.y);
5858 var dat = list.join(" "),
5860 vi = tar.ownerDocument.documentElement,
5861 w = vi.width.baseVal.value,
5862 h = vi.height.baseVal.value;
5865 ele.coordsize = w + " " + h;
5866 NAIBU._setPaint(tar, ctm);
5867 delete tar._cacheMatrix;
5868 evt = tar = list = mr = style = fontSize = dat = ele = void 0;
5874 SVGCircleElement.prototype = new SVGElement();
5876 function SVGEllipseElement(_doc) {
5877 SVGElement.apply(this);
5878 this._tar = _doc.createElement("v:shape");
5879 var sl = SVGAnimatedLength;
5880 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5881 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5882 /*readonly SVGAnimatedLength*/ this.rx = new sl();
5883 /*readonly SVGAnimatedLength*/ this.ry = new sl();
5885 this.addEventListener("DOMNodeInserted", function(evt){
5886 var tar = evt.target;
5887 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5890 var tnext = tar.nextSibling,
5891 tpart = tar.parentNode._tar,
5893 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5894 tpart.insertBefore(tar._tar, tnext._tar);
5895 } else if (tnext && !tnext._tar && tpart) {
5896 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5897 *use要素や実体参照などは_tarプロパティがないことに注意
5900 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5901 tpart.insertBefore(tar._tar, tnext._tar);
5904 tnext = tnext.nextSibling;
5907 tpart.appendChild(tar._tar);
5909 } else if (!tnext && tpart) {
5910 tpart.appendChild(tar._tar);
5912 tnext = tpart = isLast = void 0;
5913 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5914 var tar = evt.target,
5915 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5916 fontSize = parseFloat(style.getPropertyValue("font-size"));
5917 tar.cx.baseVal._emToUnit(fontSize);
5918 tar.cy.baseVal._emToUnit(fontSize);
5919 tar.rx.baseVal._emToUnit(fontSize);
5920 tar.ry.baseVal._emToUnit(fontSize);
5921 var cx = tar.cx.baseVal.value,
5922 cy = tar.cy.baseVal.value,
5923 rx = tar.rx.baseVal.value,
5924 ry = tar.ry.baseVal.value,
5931 list = ["m", cx,top, "c", cx-rrx,top, left,cy-rry, left,cy, left,cy+rry, cx-rrx,bottom, cx,bottom, cx+rrx,bottom, right,cy+rry, right,cy, right,cy-rry, cx+rrx,top, cx,top, "x e"];
5932 //以下は、配列listそのものをCTMで座標変換していく処理
5933 var par = tar.ownerDocument.documentElement,
5934 ctm = tar.getScreenCTM(),
5936 for (var i=0, lili=list.length;i<lili;) {
5937 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5941 var p = par.createSVGPoint();
5944 var pmt = p.matrixTransform(ctm);
5945 list[i] = mr(pmt.x);
5947 list[i] = mr(pmt.y);
5951 var dat = list.join(" "),
5953 vi = tar.ownerDocument.documentElement,
5954 w = vi.width.baseVal.value,
5955 h = vi.height.baseVal.value;
5958 ele.coordsize = w + " " + h;
5959 NAIBU._setPaint(tar, ctm);
5960 delete tar._cacheMatrix;
5961 evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
5967 SVGEllipseElement.prototype = new SVGElement();
5969 function SVGLineElement(_doc) {
5970 SVGElement.apply(this);
5971 this._tar = _doc.createElement("v:shape");
5972 var sl = SVGAnimatedLength;
5973 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
5974 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
5975 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
5976 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
5978 this.addEventListener("DOMNodeInserted", function(evt){
5979 var tar = evt.target;
5980 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5983 var tnext = tar.nextSibling,
5984 tpart = tar.parentNode._tar,
5986 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5987 tpart.insertBefore(tar._tar, tnext._tar);
5988 } else if (tnext && !tnext._tar && tpart) {
5989 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5990 *use要素や実体参照などは_tarプロパティがないことに注意
5993 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5994 tpart.insertBefore(tar._tar, tnext._tar);
5997 tnext = tnext.nextSibling;
6000 tpart.appendChild(tar._tar);
6002 } else if (!tnext && tpart) {
6003 tpart.appendChild(tar._tar);
6005 tnext = tpart = isLast = void 0;
6006 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6007 var tar = evt.target,
6008 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
6009 fontSize = parseFloat(style.getPropertyValue("font-size"));
6010 tar.x1.baseVal._emToUnit(fontSize);
6011 tar.y1.baseVal._emToUnit(fontSize);
6012 tar.x2.baseVal._emToUnit(fontSize);
6013 tar.y2.baseVal._emToUnit(fontSize);
6014 //以下は、配列listそのものをCTMで座標変換していく処理
6015 var vi = tar.ownerDocument.documentElement,
6016 ctm = tar.getScreenCTM(),
6019 p = vi.createSVGPoint();
6020 p.x = tar.x1.baseVal.value;
6021 p.y = tar.y1.baseVal.value;
6022 var pmt = p.matrixTransform(ctm);
6023 dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
6024 p.x = tar.x2.baseVal.value;
6025 p.y = tar.y2.baseVal.value;
6026 pmt = p.matrixTransform(ctm);
6027 dat += mr(pmt.x)+ " " +mr(pmt.y);
6031 w = vi.width.baseVal.value,
6032 h = vi.height.baseVal.value;
6034 ele.coordsize = w + " " + h;
6035 NAIBU._setPaint(tar, ctm);
6036 delete tar._cacheMatrix;
6037 evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
6043 SVGLineElement.prototype = new SVGElement();
6045 /*_GenericSVGPolyElementインターフェース
6046 * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
6047 * ファイルサイズを軽量にすることができる
6049 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
6050 SVGElement.apply(this);
6051 this._tar = _doc.createElement("v:shape");
6053 //interface SVGAnimatedPoints
6054 /*readonly SVGPointList*/ this.animatedPoints = this.points = new SVGPointList();
6055 this.addEventListener("DOMAttrModified", function(evt){
6056 var tar = evt.target;
6057 if (evt.attrName === "points") {
6058 var tp = tar.points, par = tar.ownerDocument.documentElement;
6059 var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
6060 for (var i=0, p, lili=list.length;i<lili;i+=2) {
6061 if (isNaN(list[i])) {
6065 p = par.createSVGPoint();
6066 p.x = parseFloat(list[i]);
6067 p.y = parseFloat(list[i+1]);
6071 evt = tar = list = tp = par = p = void 0;
6073 this.addEventListener("DOMNodeInserted", function(evt){
6074 var tar = evt.target;
6075 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6078 var tnext = tar.nextSibling,
6079 tpart = tar.parentNode._tar,
6081 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6082 tpart.insertBefore(tar._tar, tnext._tar);
6083 } else if (tnext && !tnext._tar && tpart) {
6084 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6085 *use要素や実体参照などは_tarプロパティがないことに注意
6088 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6089 tpart.insertBefore(tar._tar, tnext._tar);
6092 tnext = tnext.nextSibling;
6095 tpart.appendChild(tar._tar);
6097 } else if (!tnext && tpart) {
6098 tpart.appendChild(tar._tar);
6100 tnext = tpart = isLast = void 0;
6101 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6102 var tar = evt.target,
6104 ctm = tar.getScreenCTM(),
6106 //以下は、配列listそのものをCTMで座標変換していく処理
6107 for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
6108 var p = tp.getItem(i),
6109 pmt = p.matrixTransform(ctm);
6110 list[2*i] = mr(pmt.x);
6111 list[2*i + 1] = mr(pmt.y);
6114 list.splice(2, 0, "l");
6115 var dat = "m" + list.join(" ") + xclose,
6117 vi = tar.ownerDocument.documentElement;
6118 w = vi.width.baseVal.value,
6119 h = vi.height.baseVal.value;
6122 ele.coordsize = w + " " + h;
6123 NAIBU._setPaint(tar, ctm);
6124 delete tar._cacheMatrix;
6125 evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
6131 function SVGPolylineElement(_doc) {
6132 NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
6136 SVGPolylineElement.prototype = new SVGElement();
6138 function SVGPolygonElement(_doc) {
6139 NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
6143 SVGPolygonElement.prototype = new SVGElement();
6145 function SVGTextContentElement(_doc) {
6146 SVGElement.apply(this);
6147 /*readonly SVGAnimatedLength*/ this.textLength = new SVGAnimatedLength();
6148 /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
6149 this.addEventListener("DOMNodeInserted", function(evt){
6150 var tar = evt.target,
6151 cur = evt.currentTarget,
6152 eph = evt.eventPhase;
6153 /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
6154 *あらかじめ、Capturingフェーズで処理しておく
6156 if ((eph === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
6157 /*a要素の場合はtarをすりかえておく*/
6158 tar = tar.firstChild;
6160 if ((eph === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !tar._tars) {
6161 /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
6163 var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
6165 data = data.split('');
6166 for (var i=0, tdli=data.length;i<tdli;++i) {
6167 var d = _doc.createElement("div"),
6169 dstyle.position = "absolute";
6170 dstyle.textIndent = dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = dstyle.paddingTop = dstyle.paddingLeft = "0px";
6171 dstyle.whiteSpace = "nowrap";
6172 d.appendChild(_doc.createTextNode(data[i]));
6173 tar._tars[tar._tars.length] = d;
6177 evt = tar = cur = eph = void 0;
6179 this.addEventListener("DOMNodeRemoved", function(evt){
6180 var tar = evt.target;
6181 if ((evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) && (tar.nodeType === /*Node.TEXT_NODE*/ 3)) {
6182 delete evt.currentTarget._length;
6190 t.prototype = new SVGElement();
6191 // lengthAdjust Types
6192 /*unsigned short*/ t.LENGTHADJUST_UNKNOWN = 0;
6193 /*unsigned short*/ t.LENGTHADJUST_SPACING = 1;
6194 /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS = 2;
6195 t.prototype._list = null; //文字の位置を格納しておくリストのキャッシュ
6196 t.prototype._length = null; //全文字数のキャッシュ
6197 t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
6198 t.prototype._chars = 0; //tspan (tref)要素が全体の何文字目から始まっているか
6199 t.prototype._isYokogaki = true; //横書きかどうか
6200 /*long*/ t.prototype.getNumberOfChars = function() {
6202 return (this._length);
6204 var t = this.firstChild,
6207 if (t.length && (t.nodeType === /*Node.TEXT_NODE*/ 3)) {
6209 } else if (t.getNumberOfChars) { //tspan要素などであれば
6210 s += t.getNumberOfChars();
6219 /*float*/ t.prototype.getComputedTextLength = function() {
6220 var l = this.textLength.baseVal;
6221 if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
6222 /*何も設定されていない場合のみ、初期化を行う*/
6223 l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
6226 return (this.textLength.baseVal.value);
6228 /*getSubStringLengthメソッド
6229 *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
6231 /*float*/ t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
6235 var tg = this.getNumberOfChars();
6236 if (tg < (nchars+charnum)) {
6237 /*ncharsが文字列の長さよりも長くなってしまったときには、
6238 *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
6240 nchars = tg - charnum + 1;
6242 var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
6243 if (this._isYokogaki) {
6244 var s = end.x - st.x;
6246 var s = end.y - st.y;
6248 tg = end = st = void 0;
6251 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
6252 if (charnum > this.getNumberOfChars() || charnum < 0) {
6253 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6256 ti = tar.firstChild,
6257 tp = tar.parentNode;
6260 var chars = tar._chars, //現在、何文字目にあるのか
6261 x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
6262 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6263 isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
6264 fontSize = parseFloat(style.getPropertyValue("font-size")),
6265 tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
6267 if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
6268 var ptx = tp.x.baseVal,
6270 ptdx = tp.dx.baseVal,
6271 ptdy = tp.dy.baseVal;
6273 var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
6275 var kern = "f ijltIr.,:;'-\"()",
6276 akern = "1234567890abcdeghknopquvxyz",
6277 tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
6278 if (isYokogaki && (tar.localName === "text")) {
6279 y += fontSize * 0.2;
6280 } else if (tar.localName === "text"){
6281 x -= fontSize * 0.5;
6284 if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
6286 /*tspan(tref)要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
6287 *使う。また、属性が指定されていないときも同様に祖先や親を使う。
6288 *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
6289 *この処理はdx属性やdy、y属性でも同様とする
6291 *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
6293 *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
6295 for (var i=0, tli=tt.length;i<tli;++i) {
6296 if (n < ptx.numberOfItems - chars) {
6297 x = ptx.getItem(n).value;
6299 x -= fontSize * 0.5;
6301 } else if (n < tx.numberOfItems) {
6302 x = tx.getItem(n).value;
6304 x -= fontSize * 0.5;
6307 if (n < pty.numberOfItems - chars) {
6308 y = pty.getItem(n).value;
6310 y += fontSize * 0.2;
6312 } else if (n < ty.numberOfItems) {
6313 y = ty.getItem(n).value;
6315 y += fontSize * 0.2;
6318 if (n < ptdx.numberOfItems - chars) {
6319 x += ptdx.getItem(n).value;
6320 } else if (n < tdx.numberOfItems) {
6321 x += tdx.getItem(n).value;
6323 if (n < ptdy.numberOfItems - chars) {
6324 y += ptdy.getItem(n).value;
6325 } else if (n < tdy.numberOfItems) {
6326 y += tdy.getItem(n).value;
6330 //カーニングを求めて、字の幅を文字ごとに調整する
6331 tdc = ti.data.charAt(i);
6332 if (kern.indexOf(tdc) > -1) {
6333 alm = fontSize * 0.68;
6334 } else if (tdc === "s"){
6335 alm = fontSize * 0.52;
6336 } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
6337 alm = fontSize * 0.2;
6338 } else if (akern.indexOf(tdc) > -1){
6339 alm = fontSize * 0.45;
6341 alm = fontSize * 0.3;
6343 tcca = tdc.charCodeAt(0);
6344 if ((12288 <= tcca) && (tcca <= 65533)) {
6345 alm = -fontSize * 0.01;
6346 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
6347 alm += fontSize * 0.2;
6352 tlist[tlist.length] = x;
6353 tlist[tlist.length] = y;
6354 tlist[tlist.length] = fontSize - alm;
6364 if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
6367 ti = ti.nextSibling;
6368 } else if (((ti.localName === "tspan") || (ti.localName === "tref"))
6369 && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6370 /*現在のテキスト位置(x,y)の分だけ、tspan (tref)要素をずらしておく。
6376 p = ti.getStartPositionOfChar(ti.getNumberOfChars());
6381 almx = tlist[tlist.length-1];
6383 almy = tlist[tlist.length-1];
6385 x = tlist[tlist.length-3] + almx;
6386 y = tlist[tlist.length-2] + almy;
6387 tar._list = tar._list.concat(tlist);
6388 tg = ti.getNumberOfChars();
6391 ti = ti.nextSibling;
6392 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6393 /*a要素のテキストノードも処理する*/
6396 ti = ti.nextSibling;
6399 tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
6401 tar = ti = tp = ptx = pty = tx = ty = chars = style = x = y = isYokogaki = kern = akern = tt = alm = tdc = tcca = p = almx = almy = tlist = tg = void 0;
6402 var s = this.ownerDocument.documentElement.createSVGPoint();
6403 s.x = this._list[charnum*3];
6404 s.y = this._list[charnum*3 + 1];
6405 s = s.matrixTransform(this.getScreenCTM());
6409 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
6410 if (charnum > this.getNumberOfChars() || charnum < 0) {
6411 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6413 var s = this.getStartPositionOfChar(charnum);
6414 //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
6415 var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
6416 if (this._isYokogaki) {
6424 /*SVGRect*/ t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
6427 /*float*/ t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
6430 /*long*/ t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
6433 /*void*/ t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
6436 })(SVGTextContentElement);
6438 function SVGTextPositioningElement(_doc) {
6439 SVGTextContentElement.apply(this, arguments);
6440 var sl = SVGAnimatedLengthList;
6441 /*readonly SVGAnimatedLengthList*/ this.x = new sl();
6442 /*readonly SVGAnimatedLengthList*/ this.y = new sl();
6443 /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
6444 /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
6446 /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
6447 this.addEventListener("DOMAttrModified", function(evt){
6448 var tar = evt.target,
6449 name = evt.attrName,
6450 tod = tar.ownerDocument.documentElement,
6451 _parseFloat = parseFloat;
6452 if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
6453 var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
6454 teas = tar[name].baseVal;
6455 for (var i=0, tli=enr.length;i<tli;++i) {
6456 var tea = tod.createSVGLength(),
6457 n = enr[i].slice(-1),
6459 if (n >= "0" && n <= "9") {
6460 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
6461 } else if (n === "%") {
6462 if ((name === "x") || (name === "dx")) {
6463 tea._percent *= tod.viewport.width;
6464 } else if ((name === "y") || (name === "dy")) {
6465 tea._percent *= tod.viewport.height;
6467 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
6469 n = enr[i].slice(-2);
6471 var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
6472 tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
6474 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
6475 } else if (n === "ex") {
6476 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
6477 } else if (n === "px") {
6478 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
6479 } else if (n === "cm") {
6480 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
6481 } else if (n === "mm") {
6482 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
6483 } else if (n === "in") {
6484 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
6485 } else if (n === "pt") {
6486 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
6487 } else if (n === "pc") {
6488 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
6491 var s = _parseFloat(enr[i]);
6492 s = isNaN(s) ? 0 : s;
6493 tea.newValueSpecifiedUnits(type, s);
6494 teas.appendItem(tea);
6500 this.addEventListener("DOMNodeInserted", function(evt){
6501 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6502 var tar = evt.target;
6503 if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
6505 evt.currentTarget._list = null;
6511 this._tar = _doc.createElement("v:group");
6512 this._doc = _doc; //_docプロパティは_texto関数内で使われる
6514 this.addEventListener("DOMNodeInserted", function(evt){
6515 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6518 var tar = evt.target,
6519 tnext = tar.nextSibling,
6520 tpart = tar.parentNode._tar,
6522 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6523 tpart.insertBefore(tar._tar, tnext._tar);
6524 } else if (tnext && !tnext._tar && tpart) {
6525 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6526 *use要素や実体参照などは_tarプロパティがないことに注意
6529 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6530 tpart.insertBefore(tar._tar, tnext._tar);
6533 tnext = tnext.nextSibling;
6536 tpart.appendChild(tar._tar);
6538 } else if (!tnext && tpart) {
6539 tpart.appendChild(tar._tar);
6541 tnext = tpart = isLast = void 0;
6542 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._texto, false);
6547 SVGTextPositioningElement.constructor = SVGTextContentElement;
6548 SVGTextPositioningElement.prototype = new SVGTextContentElement();
6549 SVGTextPositioningElement.prototype._texto = function(evt) {
6550 var tar = evt.target,
6551 ti = tar.firstChild,
6553 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6554 deter = Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
6555 n = parseFloat(style.getPropertyValue("font-size")) * deter,
6556 tod = tar.ownerDocument.documentElement,
6557 ttpc = ttp, //ttpcはttpのキャッシュ
6558 tlen = tar.getComputedTextLength(),
6559 anchor = style.getPropertyValue("text-anchor"),
6560 tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
6563 lts = parseFloat(style.getPropertyValue("letter-spacing")),
6564 wds = parseFloat(style.getPropertyValue("word-spacing"));
6565 ttps.fontSize = n + "px"; //nは算出された文字の大きさ (CSSではなく、SVG独自のCTM方式による)
6566 ttps.fontFamily = style.getPropertyValue("font-family");
6567 ttps.fontStyle = style.getPropertyValue("font-style");
6568 ttps.fontWeight = style.getPropertyValue("font-weight");
6569 if (isFinite(lts)) {
6570 ttps.letterSpacing = lts * deter + "px";
6572 if (isFinite(parseFloat(wds))) {
6573 ttps.wordSpacing = wds * deter + "px";
6575 /*ここでの変数jは前回ノードまでの総文字数*/
6576 for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
6578 if (!!ti._tars && (ti._tars.length !== 0)) {
6579 var ij = (i > j) ? i - j : j - i
6580 var sty = ti._tars[ij].style,
6581 p = tar.getStartPositionOfChar(i);
6582 sty.position = "absolute";
6583 if (tar._isYokogaki) {
6584 if (anchor === "middle") {
6586 } else if (anchor === "end") {
6590 if (anchor === "middle") {
6592 } else if (anchor === "end") {
6596 sty.left = p.x + "px";
6597 sty.top = p.y + "px";
6600 sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
6601 sty.lineHeight = n+10+ "px";
6602 sty.textDecoration = tedeco;
6603 sty.display = "none"
6604 ttp.appendChild(ti._tars[ij]);
6607 if (ti.nodeName === "#text") {
6608 if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
6609 j = j + ti.data.length;
6610 if (ti.parentNode.localName === "a") {
6614 ti = ti.nextSibling;
6616 } else if (!!ti.getNumberOfChars) {
6617 if ((ti.getNumberOfChars()+j) <= i+1) {
6618 j = j + ti.getNumberOfChars();
6619 ti = ti.nextSibling;
6621 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6629 var color = style.getPropertyValue("fill"),
6630 cursor = style.getPropertyCSSValue("cursor"),
6631 vis = style.getPropertyCSSValue("visibility"),
6632 disp = style.getPropertyCSSValue("display"),
6633 tts = tar._tar.style,
6634 tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
6635 ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
6637 if (color === "none"){
6638 tts.color = "transparent";
6639 } else if (color.indexOf("url") === -1) {
6642 tts.color = "black";
6644 if (cursor && !cursor._isDefault) { //初期値でないならば
6645 var tc = cursor.cssText;
6646 tts.cursor = tc.split(":")[1];
6649 if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
6650 && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
6651 /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
6652 *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
6654 for (var i=1, tli=tft.length;i<tli;++i) {
6656 ttt += tfti.innerText;
6657 tfti.parentNode.removeChild(tfti);
6659 //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
6660 if (tft[0] && tft[0].replaceChild) {
6661 tft[0].replaceChild(tar._doc.createTextNode(ttt), tft[0].firstChild);
6667 if (ttp.lastChild) {
6668 if (ttp.lastChild.nodeName !== "rect") {
6675 var backr = tar._doc.createElement("v:rect"),
6676 backrs = backr.style; //ずれを修正するためのもの
6677 backrs.width = backrs.height = "1px";
6678 backrs.left = backrs.top = "0px";
6679 backr.stroked = backr.filled = "false";
6680 ttp.appendChild(backr);
6682 if (vis && !vis._isDefault) {
6683 tts.visibility = vis.cssText.split(":")[1];
6685 /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
6686 *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
6688 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
6690 } else if (disp && !disp._isDefault) {
6693 var jt = tar._tar.firstChild,
6696 jt.style.display = di;
6697 jt = jt.nextSibling;
6699 while (ae[j]) { //要素内部にあるa要素の処理
6700 for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
6701 ae[j]._tars[l].style.display = di;
6706 delete tar._cacheMatrix;
6707 ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = lts = deter = void 0;
6710 function SVGTextElement(_doc) {
6711 SVGTextPositioningElement.apply(this, arguments);
6714 SVGTextElement.constructor = SVGTextPositioningElement;
6715 SVGTextElement.prototype = new SVGTextPositioningElement();
6717 function SVGTSpanElement() {
6718 SVGTextElement.apply(this, arguments);
6721 SVGTSpanElement.constructor = SVGTextPositioningElement;
6722 SVGTSpanElement.prototype = new SVGTextPositioningElement();
6724 function SVGTRefElement(_doc) {
6725 SVGTextPositioningElement.apply(this, arguments);
6726 this.addEventListener("DOMNodeInserted", function(evt){
6727 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6730 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
6732 this.addEventListener("S_Load", function(evt){
6733 var tar = evt.target,
6734 tic = tar._instance.firstChild;
6735 /*textノードのデータだけを処理*/
6736 while (tic && (tic.nodeName !== "#text")) {
6737 tic = tic.nextSibling;
6739 tic && tar.parentNode.insertBefore(tar.ownerDocument.importNode(tic, false), tar);
6740 evt.target = tar.parentNode;
6741 tar.parentNode._texto(evt);
6742 tar = tic = evtt = void 0;
6744 SVGURIReference.apply(this, arguments);
6747 SVGTRefElement.constructor = SVGTextPositioningElement;
6748 SVGTRefElement.prototype = new SVGTextPositioningElement();
6750 function SVGTextPathElement() {
6751 SVGTextContentElement.apply(this, arguments);
6752 /*readonly SVGAnimatedLength*/ this.startOffset;
6753 /*readonly SVGAnimatedEnumeration*/ this.method;
6754 /*readonly SVGAnimatedEnumeration*/ this.spacing;
6755 SVGURIReference.apply(this, arguments);
6758 SVGTextPathElement.constructor = SVGTextContentElement;
6759 SVGTextPathElement.prototype = new SVGTextContentElement();
6762 // textPath Method Types
6763 /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN = 0;
6764 /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN = 1;
6765 /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH = 2;
6766 // textPath Spacing Types
6767 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN = 0;
6768 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO = 1;
6769 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT = 2;
6770 })(SVGTextPathElement);
6772 function SVGAltGlyphElement() {
6773 SVGTextPositioningElement.apply(this, arguments);
6774 /*DOMString*/ this.glyphRef;
6775 /*DOMString*/ this.format;
6776 SVGURIReference.apply(this, arguments);
6779 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
6780 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
6782 function SVGAltGlyphDefElement() {
6783 SVGElement.apply(this, arguments);
6786 SVGAltGlyphDefElement.prototype = new SVGElement();
6788 function SVGAltGlyphItemElement() {
6789 SVGElement.apply(this, arguments);
6792 SVGAltGlyphItemElement.prototype = new SVGElement();
6794 function SVGGlyphRefElement() {
6795 SVGElement.apply(this, arguments);
6796 /*DOMString*/ this.glyphRef;
6797 /*DOMString*/ this.format;
6802 SVGURIReference.apply(this, arguments);
6805 SVGGlyphRefElement.prototype = new SVGElement();
6807 function SVGPaint() {
6808 SVGColor.apply(this, arguments);
6813 t.prototype = new SVGColor();
6815 /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN = 0;
6816 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR = 1;
6817 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
6818 /*unsigned short*/ t.SVG_PAINTTYPE_NONE = 101;
6819 /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR = 102;
6820 /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE = 103;
6821 /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
6822 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR = 105;
6823 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
6824 /*unsigned short*/ t.SVG_PAINTTYPE_URI = 107;
6825 /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
6826 /*readonly DOMString*/ t.prototype.uri = null;
6827 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
6828 this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
6830 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
6831 if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
6832 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
6835 this.paintType = paintType;
6836 if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
6837 paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
6839 this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
6841 // raises( SVGException );
6845 function SVGMarkerElement(){
6846 SVGElement.apply(this);
6847 var sl = SVGAnimatedLength;
6848 /*readonly SVGAnimatedLength*/ this.refX = new sl();
6849 /*readonly SVGAnimatedLength*/ this.refY = new sl();
6850 /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
6851 /*readonly SVGAnimatedLength*/ this.markerWidth = new sl();
6852 /*readonly SVGAnimatedLength*/ this.markerHeight = new sl();
6854 /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
6855 /*readonly SVGAnimatedAngle*/ this.orientAngle = new SVGAnimatedAngle();
6856 //SVGFitToViewBoxのインターフェースを用いる
6857 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
6858 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
6859 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
6863 // Marker Unit Types
6864 /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN = 0;
6865 /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
6866 /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH = 2;
6867 // Marker Orientation Types
6868 /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN = 0;
6869 /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO = 1;
6870 /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE = 2;
6871 t.prototype = new SVGElement();
6872 /*void*/ t.prototype.setOrientToAuto = function() {
6875 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
6878 })(SVGMarkerElement);
6879 function SVGColorProfileElement() {
6880 SVGElement.apply(this);
6881 /*DOMString*/ this._local;
6882 // raises DOMException on setting
6883 // (NOTE: is prefixed by "_"
6884 // as "local" is an IDL keyword. The
6885 // prefix will be removed upon processing)
6886 /*DOMString*/ this.name;
6887 /*unsigned short*/ this.renderingIntent;
6888 SVGURIReference.apply(this, arguments);
6891 SVGColorProfileElement.prototype = new SVGElement();
6893 function SVGColorProfileRule() {
6894 SVGCSSRule.apply(this);
6895 /*DOMString*/ this.src;
6896 /*DOMString*/ this.name;
6897 /*unsigned short*/ this.renderingIntent;
6900 SVGColorProfileRule.prototype = new SVGCSSRule();
6902 function SVGGradientElement() {
6903 SVGElement.apply(this);
6904 SVGURIReference.apply(this);
6905 /*readonly SVGAnimatedEnumeration*/ this.gradientUnits = new SVGAnimatedEnumeration();
6906 /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
6907 /*readonly SVGAnimatedEnumeration*/ this.spreadMethod = new SVGAnimatedEnumeration();
6908 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6909 var grad = evt.target,
6911 t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
6913 href, stops, length,
6918 if (!ele || !grad) { //まだ、path要素などが設定されていない場合
6919 grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
6922 if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
6923 grad2 = grad._instance;
6925 stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
6927 ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
6930 length = stops.length;
6931 for (var i = 0; i < length; ++i) {
6933 sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
6934 ci = sstyle.getPropertyCSSValue("stop-color");
6935 if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
6936 /*再度、設定。css.jsのsetPropertyを参照*/
6937 sstyle.setProperty("color", sstyle.getPropertyValue("color"));
6939 color[i] = "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
6940 colors[i] = stop.offset.baseVal + " " + color[i];
6941 opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
6943 ele["method"] = "none";
6944 ele["color"] = color[0];
6945 ele["color2"] = color[length-1];
6946 ele["colors"] = colors.join(",");
6947 // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
6948 ele["opacity"] = opacity[length-1]+ "";
6949 ele["o:opacity2"] = opacity[0]+ "";
6950 /*SVGRadialGradientElementインターフェースで利用する*/
6951 grad._color = color;
6952 var gt = grad2.getAttributeNS(null, "gradientTransform");
6954 grad.setAttributeNS(null, "transform", gt);
6956 grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
6960 SVGGradientElement.prototype = new SVGElement();
6961 // Spread Method Types
6962 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
6963 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD = 1;
6964 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
6965 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT = 3;
6967 function SVGLinearGradientElement() {
6968 SVGGradientElement.apply(this);
6969 var sl = SVGAnimatedLength;
6970 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
6971 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
6972 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
6973 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
6975 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6976 var grad = evt.target, ele = evt._tar, angle = 270;
6977 if (!!!ele) { //まだ、path要素などが設定されていない場合
6980 var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
6981 var fontSize = parseFloat(style.getPropertyValue("font-size"));
6982 grad.x1.baseVal._emToUnit(fontSize);
6983 grad.y1.baseVal._emToUnit(fontSize);
6984 grad.x2.baseVal._emToUnit(fontSize);
6985 grad.y2.baseVal._emToUnit(fontSize);
6986 angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
6990 ele.setAttribute("type", "gradient");
6991 ele.setAttribute("angle", angle + "");
6992 evt = ele = grad = angle = style = fontSize = void 0;
6996 SVGLinearGradientElement.prototype = new SVGGradientElement();
6998 function SVGRadialGradientElement(_doc) {
6999 SVGGradientElement.apply(this);
7000 var sl = SVGAnimatedLength;
7001 /*readonly SVGAnimatedLength*/ this.cx = new sl();
7002 /*readonly SVGAnimatedLength*/ this.cy = new sl();
7003 /*readonly SVGAnimatedLength*/ this.r = new sl();
7004 /*readonly SVGAnimatedLength*/ this.fx = new sl();
7005 /*readonly SVGAnimatedLength*/ this.fy = new sl();
7007 this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
7008 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
7009 var grad = evt.target,
7011 tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
7012 if (!!!ele) { //まだ、path要素などが設定されていない場合
7015 ele.setAttribute("type", "gradientTitle");
7016 ele.setAttribute("focus", "100%");
7017 ele.setAttribute("focusposition", "0.5 0.5");
7018 if (tar.localName === "rect") {
7019 /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
7020 *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
7022 var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
7023 fontSize = parseFloat(style.getPropertyValue("font-size"));
7024 grad.cx.baseVal._emToUnit(fontSize);
7025 grad.cy.baseVal._emToUnit(fontSize);
7026 grad.r.baseVal._emToUnit(fontSize);
7027 grad.fx.baseVal._emToUnit(fontSize);
7028 grad.fy.baseVal._emToUnit(fontSize);
7029 var cx = grad.cx.baseVal.value,
7030 cy = grad.cy.baseVal.value,
7031 r = grad.r.baseVal.value,
7035 var tarrect = tar.getBBox(),
7036 vi = tar.ownerDocument.documentElement.viewport,
7041 units = grad.getAttributeNS(null, "gradientUnits");
7042 if (!units || units === "objectBoundingBox") {
7043 //%の場合は小数点に変換(10% -> 0.1)
7044 cx = cx > 1 ? cx/100 : cx;
7045 cy = cy > 1 ? cy/100 : cy;
7046 r = r > 1 ? r/100 : r;
7047 //要素の境界領域を求める(四隅の座標を求める)
7050 wid = tarrect.width,
7051 hei = tarrect.height;
7056 nx = ny = wid = hei = void 0;
7058 var matrix = tar.getScreenCTM().multiply(grad.getCTM());
7063 var rrx = rx * 0.55228,
7065 list = ["m", cx,et, "c", cx-rrx,et, el,cy-rry, el,cy, el,cy+rry, cx-rrx,eb, cx,eb, cx+rrx,eb, er,cy+rry, er,cy, er,cy-rry, cx+rrx,et, cx,et, "x e"];
7066 for (var i = 0, lili = list.length; i < lili;) {
7067 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
7071 var p = grad.ownerDocument.documentElement.createSVGPoint();
7072 p.x = parseFloat(list[i]);
7073 p.y = parseFloat(list[i+1]);
7074 var pmt = p.matrixTransform(matrix);
7075 list[i] = mr(pmt.x);
7077 list[i] = mr(pmt.y);
7081 var ellipse = list.join(" "),
7082 outline = _doc.getElementById("_NAIBU_outline"),
7083 background = _doc.createElement("div"),
7084 bstyle = background.style;
7085 bstyle.position = "absolute";
7086 bstyle.display = "inline-block";
7089 bstyle.textAlign = "left";
7091 bstyle.left = "0px";
7092 bstyle.width = w+ "px";
7093 bstyle.height = h+ "px";
7094 outline.appendChild(background);
7095 bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
7096 background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
7097 var circle = '<v:shape style="display:inline-block; position:relative; antialias:false; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +ellipse+ '" stroked="f">' +ele.outerHTML+ '</v:shape>',
7098 data = tar._tar.path.value;
7099 background.innerHTML = '<v:shape style="display:inline-block; position:relative; top:0px; left:0px;" coordsize="' +w+ ' ' +h+ '" path="' +data+ '" stroked="f" fillcolor="' +grad._color[grad._color.length-1]+ '" ></v:shape>';
7100 background.filters[0].apply();
7101 background.innerHTML = circle;
7102 background.filters[0].play();
7103 tar._tar.parentNode.insertBefore(background, tar._tar);
7104 tar._tar.filled = "false";
7105 ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
7106 } else if (!ele.parentNode){
7107 tar._tar.appendChild(ele);
7109 evt = tar = ele = gard = void 0;
7113 SVGRadialGradientElement.prototype = new SVGGradientElement();
7115 function SVGStopElement() {
7116 SVGElement.apply(this, arguments);
7117 /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
7118 this.addEventListener("DOMAttrModified", function(evt) {
7119 if (evt.attrName === "offset") {
7120 evt.target.offset.baseVal = parseFloat(evt.newValue);
7126 SVGStopElement.prototype = new SVGElement();
7128 function SVGPatternElement() {
7129 SVGElement.apply(this);
7130 var sl = SVGAnimatedLength;
7131 /*readonly SVGAnimatedEnumeration*/ this.patternUnits = new SVGAnimatedEnumeration();
7132 /*readonly SVGAnimatedEnumeration*/ this.patternContentUnits = new SVGAnimatedEnumeration();
7133 /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
7134 /*readonly SVGAnimatedLength*/ this.x = new sl();
7135 /*readonly SVGAnimatedLength*/ this.y = new sl();
7136 /*readonly SVGAnimatedLength*/ this.width = new sl();
7137 /*readonly SVGAnimatedLength*/ this.height = new sl();
7139 SVGURIReference.apply(this, arguments);
7140 //SVGFitToViewBoxのインターフェースを用いる
7141 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7142 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7143 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7146 SVGPatternElement.prototype = new SVGElement();
7148 function SVGClipPathElement() {
7149 SVGElement.apply(this, arguments);
7150 /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
7153 SVGClipPathElement.prototype = new SVGElement();
7155 function SVGMaskElement() {
7156 SVGElement.apply(this);
7157 var sl = SVGAnimatedLength;
7158 /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
7159 /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
7160 /*readonly SVGAnimatedLength*/ this.x = new sl();
7161 /*readonly SVGAnimatedLength*/ this.y = new sl();
7162 /*readonly SVGAnimatedLength*/ this.width = new sl();
7163 /*readonly SVGAnimatedLength*/ this.height = new sl();
7167 SVGMaskElement.prototype = new SVGElement();
7169 function SVGFilterElement() {
7170 SVGElement.apply(this);
7171 var sl = SVGAnimatedLength;
7172 /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
7173 /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
7174 /*readonly SVGAnimatedLength*/ this.x = new sl();
7175 /*readonly SVGAnimatedLength*/ this.y = new sl();
7176 /*readonly SVGAnimatedLength*/ this.width = new sl();
7177 /*readonly SVGAnimatedLength*/ this.height = new sl();
7179 /*readonly SVGAnimatedInteger*/ this.filterResX = new SVGAnimatedInteger();
7180 /*readonly SVGAnimatedInteger*/ this.filterResY = new SVGAnimatedInteger();
7181 SVGURIReference.apply(this, arguments);
7182 //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
7185 SVGFilterElement.prototype = new SVGElement();
7187 function SVGFilterPrimitiveStandardAttributes(ele) {
7188 SVGStylable.apply(this, arguments);
7190 var sl = SVGAnimatedLength;
7191 /*readonly SVGAnimatedLength*/ this.x = new sl();
7192 /*readonly SVGAnimatedLength*/ this.y = new sl();
7193 /*readonly SVGAnimatedLength*/ this.width = new sl();
7194 /*readonly SVGAnimatedLength*/ this.height = new sl();
7195 /*readonly SVGAnimatedString*/ this.result = new sl();
7198 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
7200 function SVGFEBlendElement() {
7201 SVGElement.apply(this, arguments);
7202 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7203 /*readonly SVGAnimatedString*/ this.in2 = new SVGAnimatedString();
7204 /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
7205 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7208 SVGFEBlendElement.prototype = new SVGElement();
7210 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN = 0;
7211 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL = 1;
7212 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
7213 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN = 3;
7214 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN = 4;
7215 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN = 5;
7217 function SVGFEGaussianBlurElement() {
7218 SVGElement.apply(this, arguments);
7219 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7220 /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
7221 /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
7222 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7225 SVGFEGaussianBlurElement.prototype = new SVGElement();
7226 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
7230 function SVGCursorElement() {
7231 SVGElement.apply(this, arguments);
7232 /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
7233 /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
7234 SVGURIReference.apply(this, arguments);
7237 SVGCursorElement.prototype = new SVGElement();
7239 function SVGAElement(_doc) {
7240 SVGElement.apply(this);
7241 this._tar = _doc.createElement("a");
7243 /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
7244 this.target.baseVal = "_self";
7245 this.addEventListener("DOMAttrModified", function(evt){
7246 var tar = evt.target;
7247 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7250 if (evt.attrName === "target") {
7251 tar.target.baseVal = evt.newValue;
7252 } else if (evt.attrName === "xlink:title") {
7253 tar._tar.setAttribute("title", evt.newValue);
7257 this.addEventListener("DOMNodeInserted", function(evt){
7258 var tar = evt.target;
7259 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7262 if (tar.nextSibling) {
7263 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
7264 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
7266 } else if (!!tar.parentNode._tar){
7267 tar.parentNode._tar.appendChild(tar._tar);
7269 var txts = tar._tar.style;
7270 txts.cursor = "hand";
7273 txts.textDecoration = "none";
7275 var t = tar.target.baseVal;
7277 if (t === "_blank") {
7280 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
7281 tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
7284 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7285 var tar = evt.target;
7286 if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
7287 var txts = tar._tar.style;
7288 txts.cursor = "hand";
7289 txts.textDecoration = "none";
7295 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7296 var tar = evt.target;
7297 tar._tar.setAttribute("target", tar.target.baseVal);
7298 if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
7299 tar.addEventListener("click", function(evt){
7300 var tar = evt.target,
7303 sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
7304 if (tar.target.baseVal === "_self") {
7305 nd = tar.ownerDocument._iframe;
7306 nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
7307 ob = nd.nextSibling;
7308 if (ob && (ob.tagName === "OBJECT")) {
7309 nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
7310 nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
7311 nd.parentNode.removeChild(ob);
7313 ob = NAIBU._search([nd.previousSibling]);
7314 nd.parentNode.removeChild(nd);
7316 sd.appendChild(sd.lastChild.firstChild);
7317 while (sd.firstChild !== sd.lastChild) { //オブジェクト要素以外を除去
7318 sd.removeChild(sd.firstChild);
7320 ob = NAIBU._search([sd.lastChild]);
7322 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
7323 evt.preventDefault();
7325 _init: (function (ob) {
7327 document.title = ob.getSVGDocument().title;
7333 sd = ob = nd = void 0;
7338 SVGURIReference.apply(this, arguments);
7341 SVGAElement.prototype = new SVGElement();
7343 function SVGViewElement() {
7344 SVGElement.apply(this, arguments);
7345 /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
7346 //SVGFitToViewBoxのインターフェースを用いる
7347 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7348 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7349 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7352 SVGViewElement.prototype = new SVGElement();
7354 function SVGScriptElement() {
7355 SVGElement.apply(this);
7356 /*DOMString*/ this.type;
7357 SVGURIReference.apply(this, arguments);
7358 this.addEventListener("DOMAttrModified", function(evt){
7359 if (evt.attrName === "type") {
7360 evt.target.type = evt.newValue;
7364 this.addEventListener("S_Load", function(evt){
7365 var tar = evt.target, script = tar._text;
7366 var tod = tar.ownerDocument;
7367 NAIBU._temp_doc = tod;
7368 script = script.replace(/function\s+(\w+)/g, "$1 = function");
7369 script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
7372 } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
7373 script = script.replace(/function\(document\){/, "function() {");
7376 tar = evt = script = void 0;
7378 this.addEventListener("DOMNodeInserted", function(evt){
7379 var tar = evt.target;
7380 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7381 if (tar.nodeName === "#cdata-section") {
7382 evt.currentTarget._text = tar.data;
7386 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7387 var tar = evt.target;
7388 if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7389 var evtt = tar.ownerDocument.createEvent("SVGEvents");
7390 evtt.initEvent("S_Load", false, false);
7391 evt.currentTarget.dispatchEvent(evtt);
7398 SVGScriptElement.prototype = new SVGElement();
7400 function SVGEvent() {
7401 Event.apply(this, arguments);
7404 SVGEvent.prototype = new Event();
7406 function SVGZoomEvent() {
7407 UIEvent.apply(this, arguments);
7408 /*readonly SVGRect*/ this.zoomRectScreen = new SVGRect();
7409 /*readonly float*/ this.previousScale = 1;
7410 /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
7411 /*readonly float*/ this.newScale = 1;
7412 /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
7415 SVGZoomEvent.prototype = new UIEvent();
7417 function SVGAnimationElement(es) {
7421 SVGElement.apply(this);
7422 /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
7423 *styleのsetPropertyメソッドを無効化させておく必要がある
7425 this.style.setProperty = function(){};
7427 /*readonly SVGElement*/ this.targetElement;
7428 /*それぞれのプロパティは、_を除いた属性に対応している*/
7429 this._begin = this._end = this._repeatCount = this._repeatDur = this._dur = this._resatrt = null;
7430 this._currentFrame = 0;
7431 /*_isRepeatと_numRepeatは繰り返し再生のときに使う。なお、後者は現在のリピート回数*/
7432 this._isRepeat = false;
7433 this._numRepeat = 0;
7434 /*_isStartプロパティは一度は起動したかどうか*/
7435 this._isStarted = false;
7436 /*_startと_finishプロパティはミリ秒数のリストを収納する。
7437 *_startはアニメ開始時の秒数リスト。_finishはアニメ終了時の秒数のリスト。
7438 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
7439 *_startingプロパティは現在アニメーションでの開始時刻。getSartTimeメソッドで使う
7441 this._start = this._finish = this._starting = null;
7442 /*_activeDurプロパティは現時点でのアニメーションの活動期間*/
7443 this._activeDur = 0;
7444 this._from = this._to = this._values = this._by = null;
7445 this._keyTimes = null;
7446 this.addEventListener("beginEvent", function(evt) {
7448 var tar = evt.target,
7449 begin = tar.getStartTime(),
7451 dur = tar._getOffset(durv),
7454 td = tar._repeatDur,
7455 tc = tar._repeatCount,
7458 for (var i=0, eli=end.length;i<eli;++i) {
7459 /*endの配列(ソース済み)からbeginに最も近い数値を選ぶ*/
7460 if (end[i] >= begin) {
7466 /*イベント待ちの場合は、endの値を、indefiniteとみなす。参照: http://www.w3.org/TR/smil-animation/#ComputingActiveDur
7468 * 3.3.4. Computing the active duration
7470 * If the value of end cannot be resolved (e.g. when it is event-based),
7471 * the value is considered to be "indefinite" for the purposes of evaluating the active duration.
7476 /*Activate Duration (活性持続時間と呼ぶことにする)を計算
7478 *http://www.w3.org/TR/smil-animation/#ComputingActiveDur
7479 *3.3.4. Computing the active duration
7481 if ((td === "indefinite") || (tc === "indefinite")) {
7485 /*活性持続時間が不定(indefinite)なので、強制的にアニメを終了させる*/
7488 } else if (durv === "indefinite") {
7490 /*活性持続時間が不定(indefinite)なので、強制的にアニメを終了させる*/
7492 } else if (tc && !endv) {
7493 ac = tar._getOffset(td);
7494 } else if (!tc && endv) {
7497 ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
7499 } else if (durv && !td && !tc && !endv) {
7501 } else if (durv && !td && tc && !endv) {
7503 } else if (durv && td && !tc && !endv) {
7504 ac = tar._getOffset(td);
7505 } else if (durv && !td && !tc && endv) {
7506 ac = (dur > (end - begin)) ? dur : (end - begin);
7507 } else if (durv && td && tc && !endv) {
7508 ac = (+tc*dur > tar._getOffset(td)) ? +tc*dur : tar._getOffset(td);
7509 } else if (durv && td && tc && endv) {
7510 ac = (+tc*dur > Math.min(+td, (end-begin))) ? +tc*dur : Math.min(tar._getOffset(td), (end - begin));
7511 } else if (durv && td && !tc && endv) {
7512 ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
7513 } else if (durv && !td && tc && endv) {
7514 ac = (+tc*dur > (end - begin)) ? +tc*dur : (end - begin)
7517 tar.endElementAt(1);
7518 throw new DOMException(DOMException.INVALID_STATE_ERR);
7520 if ((ac || (ac === 0)) && isFinite(ac)) {
7521 /*endの値がすでにある場合は、二重指定を避ける*/
7522 endv || tar.endElementAt(ac);
7523 tar._activeDur = ac;
7525 tar = begin = dur = durv = end = endv= td = tc = ac = void 0;
7527 this.addEventListener("DOMAttrModified", function(evt){
7528 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7531 var tar = evt.target,
7532 name = evt.attrName,
7533 evtv = evt.newValue;
7534 if (name === "begin") {
7535 tar._begin = evtv.replace(/\s+/g, "").split(";"); //空白は取り除く
7536 } else if (name === "end") {
7537 tar._end = evtv.replace(/\s+/g, "").split(";");
7538 } else if (name === "dur") {
7540 } else if (name === "repeatCount") {
7541 tar._repeatCount = evtv;
7542 tar._isRepeat = true;
7543 } else if (name === "repeatDur") {
7544 tar._repeatCount = evtv;
7545 tar._isRepeat = true;
7546 } else if (name === "from") {
7548 } else if (name === "to") {
7550 } else if (name === "values") {
7551 tar._values = evtv.split(";");
7552 } else if (name === "by") {
7554 } else if (name === "keyTimes") {
7555 var s = evtv.split(";");
7556 tar._keyTimes = []; //_keyTimesプロパティを初期化
7557 for (var i=0;i<s.length;++i) {
7558 tar._keyTimes[i] = parseFloat(s[i]);
7561 } else if (name === "restart") {
7562 tar._restart = evtv;
7564 evt = evtv = void 0;
7566 this.addEventListener("DOMNodeInserted", function(evt){
7567 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7570 var tar = evt.target;
7571 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7572 var tar = evt.target;
7573 /*以降の場合分けルールに関しては、下記の仕様を参照
7574 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
7577 } else if (tar._from && tar._to) {
7578 tar._values = [tar._from, tar._to];
7579 } else if (tar._from && tar._by) {
7580 var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
7581 tar._values = [tar._from, n+tanni[0]];
7582 } else if (tar._to) {
7583 tar._values = [null, tar._to];
7584 } else if (tar._by) {
7585 tar._values = [null, null, tar._by];
7586 } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
7587 /*アニメーションの効果が出ないように調整する
7590 *>if none of the from, to, by or values attributes are specified, the animation will have no effect
7591 *「3.2.2. Animation function values」より引用
7592 *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
7596 /*begin属性とend属性を処理する*/
7598 timing = function(val, name, offset) {
7599 /*timing関数は時間のタイミングをidとeventと、clock-value(offset)に分割して処理していく
7600 *まず、idを検出するためのsearcIdローカル関数を作る
7602 var searchId = function () {
7603 var n = val.indexOf(".");
7604 if ((n > 0) && (/[a-z]/i).test(val.charAt(n+1))) { //. (dot)の後がアルファベットならば
7605 return (val.slice(0, n));
7612 *W3CのSMIl AnimationのTimingモデルは7パターンがあるので、場合分けする
7614 if (isFinite(parseFloat(val))) { //1) offset-valueの場合
7616 } else if (val.indexOf("repeat(") > -1) { //2) repeat-valueの場合
7617 var inte = parseFloat(val.slice(7)),
7618 ds = (function(that, name, offset) {
7619 return function (evt) {
7620 if (inte === evt.target._numRepeat) {
7624 })(that, name, offset),
7627 that.ownerDocument.getElementById(id).addEventListener("repeatEvent", ds);
7629 that.addEventListener("repeatEvent", ds);
7631 } else if (/\.(begin|end)/.test(val)) { //3) syncbase-valueの場合
7634 var ds = (function(that, name, offset) {
7635 return function (evt) {
7638 })(that, name, offset),
7640 /\.(begin|end)/.test(val); //RegExp.$1のために、もう一度する必要がある
7641 if (RegExp.$1 === "begin") {
7643 } else if (RegExp.$1 === "end") {
7646 that.ownerDocument.getElementById(id).addEventListener(ev, ds, false);
7648 } else if (val.indexOf("wallclock(") === 0) { //4) wallclock-valueの場合
7650 } else if (val === "indefinite") { //5) indefiniteの場合
7651 } else if (val.indexOf("accesskey(") > -1) { //6) accesskey-valueの場合
7653 } else { //7) event-valueの場合
7655 var ds = (function(that, name, offset) {
7656 return function (evt) {
7659 })(that, name, offset);
7660 if (id && val.match(/\.([a-z]+)/i)) {
7661 that.ownerDocument.getElementById(id).addEventListener(RegExp.$1, ds);
7663 that.targetElement.addEventListener(val.match(/^[a-z]+/i)[0], ds)
7666 val = searchId = id = void 0;
7669 for (var i=0,tli=tar._begin.length;i<tli;++i) {
7670 timing(tar._begin[i], "beginElementAt", tar._getOffset(tar._begin[i]));
7673 tar.beginElementAt(0);
7676 for (var i=0,tli=tar._end.length;i<tli;++i) {
7677 timing(tar._end[i], "endElementAt", tar._getOffset(tar._end[i]));
7681 if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7682 tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").slice(1))
7684 tar.targetElement = tar.parentNode;
7692 SVGAnimationElement.prototype = new SVGElement();
7693 /*以下のメソッド(beginElementなど)については、
7694 *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
7696 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
7697 var ttd = this.ownerDocument,
7698 evt = ttd.createEvent("TimeEvents");
7699 this._starting = ttd.documentElement.getCurrentTime(); //getStartTimeメソッドで使う開始時刻
7700 if (this._isStarted && ((this._restart === "never")
7701 || ((this._restart === "whenNotActive") && (this.getCurrentTime() > 0)))) {
7702 return; //restart属性の設定により、再起動させないようにする
7704 if (this.getCurrentTime() > 0) {
7705 /*アニメーションの最中で、beginEventが起きるときは、endEventが前もって起こされる。SVG1.1の仕様を参照
7707 * 19.4.2 Interface TimeEvent
7708 * Note that if an element is restarted while it is currently playing, the element will raise an end event and another begin event, as the element restarts.
7710 * http://www.w3.org/TR/SVG/animate.html#InterfaceTimeEvent
7715 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
7716 this.dispatchEvent(evt);
7717 /*新しくリストの頭を更新して、別の値も実行させるようにする*/
7718 this._start && this._start.shift();
7719 this._isStarted = true;
7722 /*void*/ SVGAnimationElement.prototype.endElement = function() {
7723 var ttd = this.ownerDocument,
7724 evt = ttd.createEvent("TimeEvents");
7725 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
7726 this.dispatchEvent(evt);
7727 this._finish && this._finish.shift();
7728 this._currentFrame = 0;
7730 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
7731 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
7732 start = this._start || [];
7733 for (var i=0,sli=start.length;i<sli;++i) {
7734 if (start[i] === (offset+ntc)) {
7735 ntc = start = offset = void 0;
7739 start.push(offset + ntc);
7740 start.sort(function(a, b) {
7743 this._start = start;
7744 ntc = start = offset = void 0;
7746 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
7747 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
7748 fin = this._finish || [];
7749 for (var i=0,fli=fin.length;i<fli;++i) {
7750 if (fin[i] === (offset+ntc)) {
7751 ntc = fin = offset = void 0;
7755 fin.push(offset + ntc);
7756 fin.sort(function(a, b) {
7760 ntc = start = offset = void 0;
7762 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
7763 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?$/;
7764 SVGAnimationElement.prototype._unit = {
7770 * どれだけズレの時間があるかを計測するメソッド
7771 *tに数値が使われていないときは0を返す
7772 *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
7773 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
7774 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
7775 ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
7777 SVGAnimationElement.prototype._getOffset = function(/*string*/ val) {
7778 var t = null, //tは最初の数値
7779 n = [val.indexOf("+"), val.indexOf("-")],
7782 s = val.slice(n[0]);
7784 } else if (n[1] > -1) {
7785 s = val.slice(n[1]);
7789 t = parseFloat(val);
7792 if (/\d+\:(\d\d)\:([\d\.]+)$/.test(s)) { //Full-Clock-Valueの場合
7793 t = (t*3600 + parseInt(RegExp.$1, 10)*60 + parseFloat(RegExp.$2)) * 1000;
7794 } else if (/\d\d\:([\d\.]+)$/.test(s)) {
7795 t = (t*60 + parseFloat(RegExp.$1)) * 1000;
7796 } else if (/(h|min|s)$/.test(s)) {
7797 t *= this._unit[RegExp.$1];
7807 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
7808 if (this._starting || (this._starting === 0)) {
7809 return (this._starting);
7811 throw new DOMException(DOMException.INVALID_STATE_ERR);
7814 /*getCurrentTimeメソッド
7816 *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
7818 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
7819 return (this._currentFrame * 125 * 0.8);
7821 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
7822 if (!this._dur && !this._finish && (this._dur === "indefinite")) {
7823 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
7825 return (this._getOffset(this._dur));
7828 //raises( DOMException );
7832 start : function() {
7833 if (NAIBU.Clip.length > 0) {
7834 screen.updateInterval = 42; //24fpsとして描画処理
7835 window.onscroll = function () {
7836 screen.updateInterval = 0;
7837 screen.updateInterval = 42;
7839 NAIBU.stop = setInterval( (function() {
7841 var ntc = NAIBU.Time.currentFrame,
7843 s = ntc * 100; //フレーム数ntcをミリ秒数sに変換 (100 = 125 * 0.8)
7844 if (ntc > NAIBU.Time.Max) {
7845 clearInterval(NAIBU.stop);
7847 nc[0] && nc[0].ownerDocument.documentElement.setCurrentTime(s);
7848 for (var i=0,ncli=nc.length;i<ncli;++i) {
7853 var sti = nci._start[0];
7854 if (sti && nci._finish && (sti === nci._finish[0])) { //アニメーションの途中ならば
7857 if ((sti || (sti === 0)) && (s1 <= sti) && (sti < s)) {
7862 if (nci._isRepeat && (nci.getCurrentTime() >= nci.getSimpleDuration()*nci._numRepeat)) {
7864 var ttd = nci.ownerDocument,
7865 evt = ttd.createEvent("TimeEvents");
7867 evt.initTimeEvent("repeatEvent", ttd.defaultView, nci._numRepeat);
7868 nci.dispatchEvent(evt);
7871 if (nci._finish && (nci.getCurrentTime() !== 0)) {
7872 var fti = nci._finish[0];
7873 if ((fti || (fti === 0)) && (s1 <= fti) && (fti <= s)) {
7879 ++nci._currentFrame;
7883 ++NAIBU.Time.currentFrame;
7884 ntc = nc = s = nci = s1 = s2 = void 0;
7892 window.onscroll = function () {
7893 screen.updateInterval = 0;
7894 window.onscroll = NAIBU.emptyFunction;
7901 function SVGAnimateElement(){
7902 SVGAnimationElement.apply(this);
7903 /*NAIBU.Clipについては、NAIBU.Timeで使う
7904 *くわしくはNAIBU.Time.start関数のコードを参照
7906 NAIBU.Clip[NAIBU.Clip.length] = this;
7908 *機械が理解できる形で保管されているvalueの値の配列リスト
7910 this._valueList = [];
7911 this._isDiscrete = false;
7912 this.addEventListener("DOMAttrModified", function(evt){
7913 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7916 if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
7917 evt.target._isDiscrete = true;
7920 this.addEventListener("DOMNodeInserted", function(evt){
7921 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7924 var tar = evt.target;
7925 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7926 var tar = evt.target,
7927 attrName = tar.getAttributeNS(null, "attributeName"),
7928 ttr = tar.targetElement,
7929 tta = ttr[attrName];
7930 /*tar.valuesのリスト: ["12px", "13px"]
7931 *tar._valueList: [(new SVGPoint()), (new SVGPoint())]
7932 * tar.valuesを機械が理解できるように変換したものがtar._valueList
7933 *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
7935 var vi = ttr.cloneNode(false);
7936 if (!tar._values[0]) { //to属性か、by属性が設定されている場合
7937 var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
7938 tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
7939 if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
7940 var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
7941 tar._values[1] = v2 + tanni[0];
7943 v2 = tanni = void 0;
7946 if (("animatedPoints" in ttr) && (attrName === "points")) {
7947 ttr.animatedPoints = vi.points;
7948 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7949 var vir = ttr.cloneNode(false);
7951 vir.setAttributeNS(null, "points", tav[i]);
7952 tar._valueList[tar._valueList.length] = vir.points;
7955 tta.animVal = vi[attrName].baseVal;
7956 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7957 var vir = ttr.cloneNode(false); //仮の要素
7959 vir.setAttributeNS(null, attrName, tav[i]);
7960 tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
7962 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7963 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7964 if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
7965 tar._valueList[i] = new SVGPaint();
7966 tar._valueList[i].setPaint(1, null, tav[i], null)
7968 tar._valueList[i] = parseFloat(tav[i]);
7971 } else if (("normalizedPathSegList" in ttr) && (attrName === "d")) {
7972 ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
7973 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7974 var vir = ttr.cloneNode(false);
7976 vir.setAttributeNS(null, "d", tav[i]);
7977 tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
7983 evt = tta = vir = vi = void 0;
7986 this.addEventListener("beginEvent", function(evt) {
7987 var _tar = evt.target,
7988 attrName = _tar.getAttributeNS(null, "attributeName"),
7989 newAttr = _tar.targetElement.attributes.getNamedItemNS(null, attrName),
7990 ttr = _tar.targetElement,
7991 tta = ttr[attrName];
7992 _tar._frame = function() {
7994 d = tar._isRepeat ? tar.getSimpleDuration() : tar._activeDur,
7995 n = tar._valueList.length-1,
7996 tg = tar.getCurrentTime();
7997 tar._activeDur || (d = 0);
7999 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8000 if (tar._isDiscrete) {
8001 ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
8003 var ii = Math.floor((tg*n) / d);
8004 if (ii === n) { //iiが境い目のときは、n-2を適用
8010 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
8012 * 参照:アニメーションサンドイッチモデル
8013 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
8014 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
8016 var evt = tar.ownerDocument._domnodeEvent();
8017 if (tar._keyTimes) {
8018 var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8019 var ti = tar._keyTimes[ii];
8021 var di = d / n; //keyTimesがなければ均等に時間を配分しておく
8024 if (("animatedPoints" in ttr) && (attrName === "points")) {
8025 var base = ttr.points;
8026 ttr.points = ttr.animatedPoints;
8027 ttr.dispatchEvent(evt);
8028 ttr.animatedPoints = ttr.points;
8031 var base = tta.baseVal, tanim = tta.animVal;
8032 var v1 = tar._valueList[ii].value;
8033 /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8034 * 3.4.2 Specifying the simple animation function f(t)
8035 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8037 if (!tar._isDiscrete) {
8038 var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
8042 tanim.newValueSpecifiedUnits(base.unitType, v);
8043 tta.baseVal = tanim;
8045 ttr.dispatchEvent(evt);
8046 /*変化値はanimValプロパティに収納しておき、
8047 *変化する前の、元の値はbaseValプロパティに再び収納しておく
8049 tta.animVal = tta.baseVal;
8052 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8054 var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
8055 if (!tar._isDiscrete) {
8056 var v = v1 + (v2-v1) * (tg-ti*d) / di;
8060 } else if (("normalizedPathSegList" in ttr) && (attrName === "d")) {
8061 var base = ttr.normalizedPathSegList;
8062 ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
8063 ttr.dispatchEvent(evt);
8064 ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
8065 ttr.normalizedPathSegList = base;
8067 evt = tar = v1 = v2 = v = d = n = ii = tg = void 0;
8071 this.addEventListener("endEvent", function(evt) {
8072 var tar = evt.target,
8073 fill = tar.getAttributeNS(null, "fill");
8074 if (!fill || (fill === "remove")) {
8075 var evt = tar.ownerDocument._domnodeEvent();
8076 tar.targetElement.dispatchEvent(evt);
8078 tar._frame && tar._frame();
8082 this.addEventListener("repeatEvent", function(evt) {
8083 var tar = evt.target;
8087 SVGAnimateElement.prototype = new SVGAnimationElement(1);
8089 function SVGSetElement(){
8090 SVGAnimationElement.apply(this);
8091 NAIBU.Clip[NAIBU.Clip.length] = this;
8093 this.addEventListener("DOMAttrModified", function(evt) {
8094 var tar = evt.target, name = evt.attrName;
8095 if (name === "to") {
8096 tar._to = evt.newValue;
8098 tar = name = void 0;
8100 this.addEventListener("beginEvent", function(evt) {
8101 var tar = evt.target;
8102 tar._currentFrame = 1; //これがないと、NAIBU.stopの内部の処理の都合上、endEventが発動しない。
8103 if (tar.targetElement) {
8104 var attrName = tar.getAttributeNS(null, "attributeName"),
8105 newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
8106 tta = tar.targetElement[attrName];
8107 if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8108 /*前もって、スタイルシートの値を取得しておいて、endEventの際に使う*/
8109 tar._prestyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "").getPropertyValue(attrName);
8110 var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
8111 style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
8114 var base = tta.baseVal;
8115 if (base instanceof SVGLength) {
8116 tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
8117 } else if (base instanceof SVGRect) {
8118 tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
8120 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
8122 * 参照:アニメーションサンドイッチモデル
8123 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
8124 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
8126 var evt = tar.ownerDocument.createEvent("MutationEvents");
8127 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
8128 tar.targetElement.dispatchEvent(evt);
8130 /*変化値はanimValプロパティに収納しておき、
8131 *変化する前の、元の値はbaseValプロパティに再び収納しておく
8133 tta.animVal = tta.baseVal;
8137 evt = tar = attrName = void 0;
8139 this.addEventListener("endEvent", function(evt) {
8140 var tar = evt.target,
8141 fill = tar.getAttributeNS(null, "fill");
8142 if (!fill || (fill === "remove")) {
8143 var attrName = tar.getAttributeNS(null, "attributeName"),
8144 style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
8145 if (tar._prestyle) { //スタイルシートの変更ならば
8146 style.setProperty(attrName, tar._prestyle, null);
8148 var evtt = tar.ownerDocument._domnodeEvent();
8149 tar.targetElement.dispatchEvent(evtt);
8151 attrName = style = evtt = void 0;
8153 tar = fill = void 0;
8155 this.addEventListener("repeatEvent", function(evt) {
8156 var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8160 SVGSetElement.prototype = new SVGAnimationElement(1);
8162 function SVGAnimateMotionElement(){
8163 SVGAnimationElement.apply(this);
8164 NAIBU.Clip[NAIBU.Clip.length] = this;
8165 this.addEventListener("DOMAttrModified", function(evt){
8166 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8169 var tar = evt.target,
8170 name = evt.attrName;
8171 if (name === "path") {
8172 var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
8173 d.setAttributeNS(null, "d", evt.newValue);
8178 this.addEventListener("DOMNodeInserted", function(evt){
8179 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8182 var tar = evt.target;
8183 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8187 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8190 vlist[i] = [+ti[0], +ti[1]];
8192 tar._valueList = vlist;
8196 this.addEventListener("beginEvent", function(evt) {
8197 var tar = evt.target,
8198 trans = tar.targetElement.transform;
8199 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8202 trans.animVal = new SVGTransformList();
8203 if (trans.baseVal.numberOfItems !== 0) {
8204 trans.baseVal.consolidate();
8205 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8207 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8209 tar._frame = function() {
8212 tgsd = _tar._isRepeat ? _tar.getSimpleDuration() : _tar._activeDur,
8214 tg = _tar.getCurrentTime(),
8216 _tar._activeDur || (d = 0);
8221 if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
8222 var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
8223 p = tpn.getPointAtLength(st),
8224 trans = _tar.targetElement.transform;
8225 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8226 var base = trans.baseVal;
8227 trans.baseVal = trans.animVal;
8228 _tar.targetElement._cacheMatrix = null;
8229 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8230 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8231 _tar.targetElement.dispatchEvent(evtt);
8232 trans.baseVal = base;
8233 evtt = base = trans = st = p = void 0;
8234 } else if (tar._valueList) {
8235 var total = 0, //totalは総距離
8236 st = 0, //stは現在にいたるまでの距離
8237 tav = tar._valueList,
8239 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8240 ii = Math.floor((tg*n) / d);
8241 if (ii === n) { //iiが境い目のときは、n-2を適用
8247 for (var i=1, tvli=tav.length;i<tvli;i+=2) {
8248 total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
8250 for (var i=1;i<ii;i+=2) {
8251 st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
8253 var p = tar.ownerDocument.documentElement.createSVGPoint(),
8254 trans = _tar.targetElement.transform;
8255 st = (st / total) * d;
8256 p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
8257 p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
8258 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8259 var base = trans.baseVal;
8260 trans.baseVal = trans.animVal;
8261 _tar.targetElement._cacheMatrix = void 0;
8262 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8263 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8264 _tar.targetElement.dispatchEvent(evtt);
8265 trans.baseVal = base;
8266 evtt = base = trans = st = p = i = void 0;
8269 evt = trans = tpn = tgsd = void 0;
8271 this.addEventListener("endEvent", function(evt) {
8272 var tar = evt.target,
8273 trans = tar.targetElement.transform,
8274 fill = tar.getAttributeNS(null, "fill"),
8275 tavli = tar._valueList,
8277 if (!fill || (fill === "remove")) {
8278 /*アニメが開始される前の状態に戻す*/
8279 var evtt = tar.ownerDocument._domnodeEvent();
8280 tar.targetElement.dispatchEvent(evtt);
8281 tar._frame && tar._frame();
8283 /*_frame関数で終了位置に会わないことがあるので、以下の処理で位置を修正*/
8284 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(tavli[tavli.length-1][0], tavli[tavli.length-1][1]);
8286 trans.baseVal = trans.animVal;
8287 var evtt = tar.ownerDocument._domnodeEvent();
8288 tar.targetElement.dispatchEvent(evtt);
8292 evt = evtt = trans = fill = tar = tavli = tb = void 0;
8294 this.addEventListener("repeatEvent", function(evt) {
8295 var tar = evt.target;
8299 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
8301 function SVGMPathElement() /* :
8304 SVGExternalResourcesRequired*/ {
8305 SVGElement.apply(this);
8306 SVGURIReference.apply(this);
8309 SVGMPathElement.prototype = new SVGElement();
8311 function SVGAnimateColorElement() {
8312 SVGAnimationElement.apply(this);
8313 NAIBU.Clip[NAIBU.Clip.length] = this;
8314 this._valueList = [];
8315 this.addEventListener("DOMNodeInserted", function(evt){
8316 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8319 var tar = evt.target;
8320 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8321 var tar = evt.target,
8322 attrName = tar.getAttributeNS(null, "attributeName"),
8323 ttr = tar.targetElement,
8324 fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
8326 if (!tar._values[0]) {
8327 tar._values[0] = fstyle.getPropertyValue(attrName);
8329 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8330 var to = new SVGColor();
8331 if (tar._values[i] === "currentColor") {
8332 to.setRGBColor(fstyle.getPropertyValue("color") || "black");
8333 } else if (tar._values[i] === "inherit") {
8334 /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
8335 css = fstyle.getPropertyCSSValue(attrName);
8336 n = css.cssValueType;
8337 css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
8338 to = fstyle.getPropertyCSSValue(attrName);
8339 css.cssValueType = n;
8341 to.setRGBColor(tar._values[i]);
8343 tar._valueList[tar._valueList.length] = to;
8346 tar = ttr = fstyle = css = n = attrName = void 0;
8349 this.addEventListener("beginEvent", function(evt) {
8350 var tar = evt.target,
8351 attrName = tar.getAttributeNS(null, "attributeName"),
8352 style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
8353 fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8354 tar._frame = function() {
8356 /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8357 * 3.4.2 Specifying the simple animation function f(t)
8358 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8360 var d = _tar._isRepeat ? _tar.getSimpleDuration() : _tar._activeDur,
8361 n = _tar._valueList.length - 1,
8362 tg = _tar.getCurrentTime(),
8364 _tar._activeDur || (d = 0);
8366 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8367 ii = Math.floor((tg*n) / d);
8368 if (ii === n) { //iiが境い目のときは、n-2を適用
8374 if (tar._keyTimes) {
8375 di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8376 ti = tar._keyTimes[ii];
8378 di = d / n; //keyTimesがなければ均等に時間を配分しておく
8381 var fc = _tar._valueList[ii].rgbColor,
8382 tc = _tar._valueList[ii+1].rgbColor,
8383 durd = (tg-ti*d) / di,
8384 num = CSSPrimitiveValue.CSS_NUMBER,
8385 fr = fc.red.getFloatValue(num),
8386 fg = fc.green.getFloatValue(num),
8387 fb = fc.blue.getFloatValue(num),
8388 r = fr + (tc.red.getFloatValue(num) - fr) * durd,
8389 g = fg + (tc.green.getFloatValue(num) - fg) * durd,
8390 b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
8391 style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
8392 _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = ii = void 0;
8396 this.addEventListener("endEvent", function(evt) {
8397 var tar = evt.target,
8398 fill = tar.getAttributeNS(null, "fill");
8399 if (!fill || (fill === "remove")) {
8400 var evtt = tar.ownerDocument._domnodeEvent();
8401 tar.targetElement.dispatchEvent(evtt);
8402 tar._frame && tar._frame();
8405 evt = evtt = tar = fill = void 0;
8407 this.addEventListener("repeatEvent", function(evt) {
8408 var tar = evt.target;
8412 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
8414 function SVGAnimateTransformElement() {
8415 SVGAnimationElement.apply(this);
8416 NAIBU.Clip[NAIBU.Clip.length] = this;
8417 this.addEventListener("beginEvent", function(evt) {
8418 var tar = evt.target, trans = tar.targetElement.transform;
8419 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8422 trans.animVal = new SVGTransformList();
8423 if (trans.baseVal.numberOfItems !== 0) {
8424 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8426 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8428 this.addEventListener("endEvent", function(evt) {
8429 var tar = evt.target,
8430 fill = tar.getAttributeNS(null, "fill");
8431 if (!fill || (fill === "remove")) {
8432 var evtt = tar.ownerDocument._domnodeEvent();
8433 tar.targetElement.dispatchEvent(evtt);
8434 tar._frame && tar._frame();
8437 evt = evtt = tar = fill = void 0;
8439 this.addEventListener("repeatEvent", function(evt) {
8440 var tar = evt.target;
8444 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
8446 function SVGFontElement() /*:
8448 SVGExternalResourcesRequired,
8450 SVGElement.apply(this);
8451 /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
8452 /*boolean or number*/ this._isExternal = 0;
8453 this.addEventListener("DOMNodeInserted", function(evt){
8454 var tar = evt.target;
8455 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8458 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8459 var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
8460 var nefunc = function(evt){
8461 var svg = evt.target;
8463 var familyName = fontFace.getAttributeNS(null, "font-family");
8464 var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
8465 for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
8466 var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
8467 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8468 NAIBU._noie_createFont(ti, _tar, true);
8471 evt = tar = svg = curt = textElments = svgns = _tar = void 0;
8473 if (!fontFace.__isLinked || tar._isExternal) {
8474 tar.ownerDocument.documentElement._svgload_limited = 0;
8475 tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
8481 SVGFontElement.prototype = new SVGElement();
8483 function SVGGlyphElement() /*:
8486 SVGElement.apply(this);
8489 SVGGlyphElement.prototype = new SVGElement();
8491 function SVGMissingGlyphElement() /*:
8494 SVGElement.apply(this);
8497 SVGMissingGlyphElement.prototype = new SVGElement();
8499 function SVGHKernElement() {
8500 SVGElement.apply(this);
8503 SVGHKernElement.prototype = new SVGElement();
8505 function SVGVKernElement() {
8506 SVGElement.apply(this);
8509 SVGVKernElement.prototype = new SVGElement();
8511 function SVGFontFaceElement() {
8512 SVGElement.apply(this);
8513 /*boolean(or number)*/ this._isLinked = 0;
8514 this.addEventListener("DOMNodeInserted", function(evt){
8515 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8516 if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
8517 evt.currentTarget._isLinked = 1;
8524 SVGFontFaceElement.prototype = new SVGElement();
8526 function SVGFontFaceSrcElement() {
8527 SVGElement.apply(this);
8530 SVGFontFaceSrcElement.prototype = new SVGElement();
8532 function SVGFontFaceUriElement() {
8533 SVGElement.apply(this);
8534 this.addEventListener("DOMNodeInserted", function(evt){
8535 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8538 evt.target.ownerDocument.documentElement._svgload_limited--
8539 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
8541 this.addEventListener("S_Load", function(evt){
8542 var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
8543 if (tpp.localName === "defs") {
8544 tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
8546 tar._instance._isExternal = 1;
8547 tpp.parentNode.appendChild(tar._instance);
8548 evt = tar = tpp = void 0;
8550 SVGURIReference.apply(this);
8553 SVGFontFaceUriElement.prototype = new SVGElement();
8555 function SVGFontFaceFormatElement() {
8556 SVGElement.apply(this);
8559 SVGFontFaceFormatElement.prototype = new SVGElement();
8561 function SVGFontFaceNameElement() {
8562 SVGElement.apply(this);
8565 SVGFontFaceNameElement.prototype = new SVGElement();
8567 function SVGDefinitionSrcElement() {
8568 SVGElement.apply(this);
8571 SVGDefinitionSrcElement.prototype = new SVGElement();
8573 function SVGMetadataElement() {
8574 SVGElement.apply(this);
8577 SVGMetadataElement.prototype = new SVGElement();
8579 function SVGForeignObjectElement() /*:
8583 SVGExternalResourcesRequired,
8586 events::EventTarget*/ {
8587 SVGElement.apply(this);
8588 var sl = SVGAnimatedLength;
8589 /*readonly SVGAnimatedLength*/ this.x = new sl();
8590 /*readonly SVGAnimatedLength*/ this.y = new sl();
8591 /*readonly SVGAnimatedLength*/ this.width = new sl();
8592 /*readonly SVGAnimatedLength*/ this.height = new sl();
8596 SVGForeignObjectElement.prototype = new SVGElement();
8599 /*SVGの要素マッピング(DOMでは定められていないが、必須)
8600 *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
8601 *SIEでは軽量化のために、マッピングを用いた
8603 DOMImplementation["http://www.w3.org/2000/svg"] = {
8604 Document: SVGDocument,
8607 path: NAIBU.SVGPathElement,
8608 title: SVGTitleElement,
8609 desc: SVGDescElement,
8610 defs: SVGDefsElement,
8611 linearGradient: SVGLinearGradientElement,
8612 radialGradient: SVGRadialGradientElement,
8613 stop: SVGStopElement,
8614 rect: SVGRectElement,
8615 circle: SVGCircleElement,
8616 ellipse: SVGEllipseElement,
8617 polyline: SVGPolylineElement,
8618 polygon: SVGPolygonElement,
8619 text: SVGTextElement,
8620 tspan: SVGTSpanElement,
8621 image: SVGImageElement,
8622 line: SVGLineElement,
8624 altGlyphDef: SVGAltGlyphDefElement,
8625 altGlyph: SVGAltGlyphElement,
8626 altGlyphItem: SVGAltGlyphItemElement,
8627 animateColor: SVGAnimateColorElement,
8628 animate: SVGAnimateElement,
8629 animateMotion: SVGAnimateMotionElement,
8630 animateTransform:SVGAnimateTransformElement,
8631 clipPath: SVGClipPathElement,
8632 colorProfile: SVGColorProfileElement,
8633 cursor: SVGCursorElement,
8634 definitionSrc: SVGDefinitionSrcElement,
8635 feBlend: SVGFEBlendElement,
8636 feGaussianBlur: SVGFEGaussianBlurElement,
8637 filter: SVGFilterElement,
8638 font: SVGFontElement,
8639 "font-face": SVGFontFaceElement,
8640 "font-face-format":SVGFontFaceFormatElement,
8641 "font-face-name":SVGFontFaceNameElement,
8642 "font-face-src": SVGFontFaceSrcElement,
8643 "font-face-uri": SVGFontFaceUriElement,
8644 foreignObject: SVGForeignObjectElement,
8645 glyph: SVGGlyphElement,
8646 glyphRef: SVGGlyphRefElement,
8647 hkern: SVGHKernElement,
8648 marker: SVGMarkerElement,
8649 mask: SVGMaskElement,
8650 metadata: SVGMetadataElement,
8651 missingGlyph: SVGMissingGlyphElement,
8652 mpath: SVGMPathElement,
8653 script: SVGScriptElement,
8655 style: SVGStyleElement,
8656 "switch": SVGSwitchElement,
8657 "symbol": SVGSymbolElement,
8658 textPath: SVGTextPathElement,
8659 tref: SVGTRefElement,
8661 view: SVGViewElement,
8662 vkern: SVGVKernElement,
8663 pattern: SVGPatternElement
8666 NAIBU._fontSearchURI = function(evt){
8667 var doc = evt.target.ownerDocument;
8668 var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
8669 for (var i=0;i<tsrc.length;++i) {
8670 var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
8671 ids = src.split(":")[1],
8672 xmlhttp = NAIBU.xmlhttp;
8673 xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
8674 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
8675 xmlhttp.onreadystatechange = function() {
8676 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
8677 var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
8678 NAIBU._font({document:doce, docu:doc, id:ids});
8679 xmlhttp = doc = doce = void 0;
8685 /*_font関数は、SVGFontで使う*/
8686 NAIBU._font = function (data) {
8687 var doc = data.document, svgns = "http://www.w3.org/2000/svg";
8688 //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
8689 var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
8690 var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
8691 if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
8692 var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
8693 for (var i=0,tli=textElements.length;i<tli;++i) {
8694 var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
8695 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8696 NAIBU._noie_createFont(ti, font, false);
8700 doc = data = void 0;
8702 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
8703 var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
8704 svgns = "http://www.w3.org/2000/svg",
8705 //isTategakiは縦書きならば真
8706 isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
8707 horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
8708 node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
8709 em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
8710 advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
8711 dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
8712 dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
8713 fontSize = parseFloat(style.getPropertyValue("font-size")),
8715 ds = false, npdlist = ["fill",
8721 "stroke-miterlimit",
8726 if (/a/[-1] === 'a') { //Firefoxならば
8728 } else if (isMSIE || isTategaki) {
8737 if (data !== void 0) { //dataがある場合
8738 var advanceX = [], glyphData = [];
8739 for (var i=0,gli=glyphs.length;i<gli;++i) {
8740 var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
8741 var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
8743 if (orientation === "h") {
8747 isOrientationAttribute = false;
8749 if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
8750 //indexは該当する文字が何番目にあるかの数字
8751 var index = data.indexOf(unicode);
8752 while (index > -1) {
8753 advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
8754 glyphData[index] = glyph.getAttributeNS(null, "d");
8755 index = data.indexOf(unicode, index+1);
8759 for (var i=0,adv=0;i<data.length;++i) {
8760 if (advanceX[i] !== void 0) { //配列に含まれていれば
8761 var path = ti.ownerDocument.createElementNS(svgns, "path");
8762 //advance、すなわち字幅の長さ分、ずらしていく
8763 var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
8766 for (var j=0;j<npdlist.length;++j){
8767 var nj = npdlist[j],
8768 tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
8769 if (nj === "stroke-width") {
8770 tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
8774 path.setAttributeNS(null, nj, tg);
8778 var y= dy + adv*fe, x = dx;
8779 if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
8780 var fms = fontSize / Math.SQRT2;
8788 matrix.e = dx + adv*fe;
8791 path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
8792 path.setAttributeNS(null, "d", glyphData[i]);
8793 ti.parentNode.insertBefore(path, ti);
8798 adv = advanceX = glyphData = void 0;
8799 } else if ("tspan|a".indexOf(node.localName) > -1){
8800 NAIBU._noie_createFont(node, font, isMSIE);
8802 node = node.nextSibling;
8805 var style = ti.ownerDocument.getOverrideStyle(ti, null);
8806 style.setProperty("visibility", "hidden");
8809 ti.setAttributeNS(null, "opacity", "0");
8812 data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
8815 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
8816 *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
8819 var s = new CSSStyleDeclaration(),
8825 for (var i in CSS2Properties) {
8826 if(CSS2Properties.hasOwnProperty(i)) {
8827 t = i.replace(regAZ, "-");
8829 u = "-" +RegExp.$1.toLowerCase();
8833 t = t.replace(regm, u);
8834 s.setProperty(t, CSS2Properties[i]);
8835 slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
8836 slis[n]._isDefault = 1;
8842 slis._fontSize = 12;
8843 CSS2Properties._list = slis;
8844 Document.prototype.defaultView._defaultCSS = slis;
8845 s = n = regAZ = regm = slis =null;
8848 NAIBU.addEvent = function(evt,lis){
8849 if (window.addEventListener) {
8850 window.addEventListener(evt, lis, false);
8851 } else if (window.attachEvent) {
8852 window.attachEvent('on'+evt, lis);
8854 window['on'+evt] = lis;
8862 function unsvgtovml() {
8864 if ("stop" in NAIBU) {
8865 clearInterval(NAIBU.stop);
8867 window.onscroll = NAIBU.emptyFunction;
8868 window.detachEvent("onload", NAIBU._main);
8870 Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
8871 Array = ActiveXObject = void 0;
8877 NAIBU._main = (function() {
8878 stlog = new STLog(false);
8879 var xmlhttp, //XMLHttpオブジェクトを生成
8880 _doc = document; //documentのエイリアスを作成
8882 if (XMLHttpRequest) {
8885 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
8889 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
8896 xmlhttp = new XMLHttpRequest();
8901 NAIBU.xmlhttp = xmlhttp;
8903 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
8905 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
8910 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
8911 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
8912 var st = _doc.createStyleSheet(),
8913 vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
8914 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
8915 + "dn\\:defs{display:none}"
8916 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
8917 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
8919 var ary = _doc.getElementsByTagName("script");
8920 //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
8921 for (var i=0; ary[i]; ++i) {
8924 if (ai.type === "image/svg+xml") {
8926 if (sieb_s && ait.match(/<svg/)) {
8928 ait = ait.replace(/<.+?>/g, "");
8930 ait = ait.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
8933 var gsd = new GetSVGDocument(ai);
8937 responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
8941 var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
8942 ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
8943 var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
8944 ai.parentNode.insertBefore(s,ai);
8952 if (xmlhttp && NAIBU.isMSIE) {
8953 if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
8955 var ob = _doc.getElementsByTagName("object"),
8956 em = _doc.getElementsByTagName("embed"),
8957 img = _doc.getElementsByTagName("img"),
8960 _search = function(_ob) {
8964 s || (s = []); //NAIBU._searchで呼ばれたときに必要
8965 _doc || (_doc = document);
8966 for (var i=0;_ob[i];++i) {
8968 s[s.length] = new GetSVGDocument(obi);
8969 ifr = _doc.createElement("iframe");
8970 ifr.style.cssText = obi.style.cssText;
8971 ifr.style.background = "black";
8972 n = obi.getAttribute(w);
8973 n && ifr.setAttribute(w, n);
8974 n = obi.getAttribute(h);
8975 n && ifr.setAttribute(h, n);
8976 ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
8977 ifr.scrolling = "no";
8978 ifr.frameBorder = "0";
8979 /*iframe要素を使って、描画のプロセスを分離する
8980 *したがって、_docはdocumentとは別のオブジェクトとなる
8982 obi.parentNode.insertBefore(ifr, obi);
8984 i = obi = ifr = _ob = w = h = void 0;
8985 return s[s.length-1];
8989 for (var i=0,j=0;img[i];++i) {
8991 if (img[i].getAttribute("src").indexOf(".svg") > -1) { //拡張子があればSVG画像と判断
8997 NAIBU._search = _search; //a要素がクリックされたときに使う関数
8998 ob = em = t = img = _search = void 0;
8999 for (var i=0;i<s.length;++i) {
9000 /*あとで変数iが使われるために、次の条件分岐が必要*/
9001 if (i < s.length-1) {
9006 s[0]._init(); //初期化作業を開始
9011 var ob = _doc.getElementsByTagName("object");
9012 for (var i=0;i<ob.length;++i) {
9013 if (ob[i].contentDocument) {
9014 NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
9015 } else if (ob[i].getSVGDocument) {
9016 ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
9021 xmlhttp = _doc = void 0;
9023 NAIBU.addEvent("load", NAIBU._main);
9024 NAIBU.utf16 = function ( /*string*/ s) {
9027 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
9028 return s.replace(/%u\w\w\w\w/g, NAIBU.utf16);
9030 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
9031 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
9032 /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
9035 if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
9036 var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
9037 var ob = document.createElement("object");
9038 ob.setAttribute("data",data);
9039 ob.setAttribute("width",w);
9040 ob.setAttribute("height",h);
9041 ob.setAttribute("type","image/svg+xml");
9044 var doc = (new DOMParser()).parseFromString(source, "text/xml");
9045 return (document.importNode(doc.documentElement, true));
9048 NAIBU.addEvent("unload", unsvgtovml);
9050 NAIBU.isMSIE = /*@cc_on!@*/false;