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(null, 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") && !this.ownerDocument._id[newAttr.nodeValue]) { //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,
1270 while (!tp) { //先祖をたどっていく
1271 if (tp === n) { //先祖要素が追加ノードならばエラー
1272 throw (new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
1277 if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
1278 throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1280 if (np === this) { //入力した要素が子要素ならば
1281 this.removeChild(n);
1284 (n === np.firstChild) && (np.firstChild = n.nextSibling);
1285 (n === np.lastChild ) && (np.lastChild = n.previousSibling);
1287 if (!ref) { //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
1288 n._num = this.childNodes.length;
1289 this.childNodes[n._num] = n;
1290 if (this.lastChild) {
1291 n.previousSibling = this.lastChild;
1292 this.lastChild.nextSibling = n;
1295 if (ref.parentNode !== this) { //参照ノードが子要素でない場合
1296 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1298 this.childNodes.splice(ref._num,1,n,ref); //Arrayのspliceを利用して、リストにnノードを追加
1299 rp = ref.previousSibling;
1303 ref.previousSibling = n;
1305 n.nextSibling = ref;
1306 this.firstChild = this.childNodes[0];
1307 this.lastChild = this.childNodes[this.childNodes.length-1];
1308 n.parentNode = this;
1309 if ((n.nodeType===/*Node.ENTITY_REFERENCE_NODE*/ 5) || (n.nodeType===/*Node.DOCUMENT_FRAGMENT_NODE*/ 11)) {
1310 /*実体参照や、文書フラグメントノードだけは子ノードを検索して、
1311 *それらを直接文書に埋め込む作業を以下で行う
1313 var ch = n.childNodes.concat([]); //Arrayのコピー
1314 for (var i=0,chli=ch.length;i<chli;i++) {
1315 this.insertBefore(ch[i], n);
1320 evt = this.ownerDocument.createEvent("MutationEvents");
1321 evt.initMutationEvent("DOMNodeInserted", true, false, this, null, null, null, null);
1322 n.dispatchEvent(evt);
1323 /*以下のDOMNodeInsertedIntoDocumentイベントは、間接的、あるいは直接ノードが
1324 *挿入されたときに発火する。間接的な挿入とは、サブツリーを作っておいて、それをいっぺんに挿入する場合など。
1325 *このイベントは浮上しないことに注意を要する
1331 if (s !== this.ownerDocument.documentElement) {
1335 evt = this.ownerDocument.createEvent("MutationEvents");
1336 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1337 n.dispatchEvent(evt);
1338 if (!n.hasChildNodes()) { //子ノードがないので終了
1341 if (n.getElementsByTagNameNS) {
1342 descend = n.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1344 descend = n.childNodes;
1347 for (var i=0,dli=descend.length;i<dli;++i) {
1349 di.dispatchEvent(evt);
1353 evt = descend = void 0;
1354 tp = np = rp = te = s = di = void 0;
1358 /*Node*/ Node.prototype.removeChild = function( /*Node*/ ele) {
1359 if (!(ele instanceof Node)) { //Nodeでなければ
1360 throw (new Error());
1363 var evt = this.ownerDocument.createEvent("MutationEvents"),
1365 /*以下のDOMNodeRemovedFromDocumentイベントは、間接的、あるいは直接ノードが
1366 *除去されたときに発火する。間接的な除去とは、サブツリーをいっぺんに除去する場合など。
1367 *このイベントは浮上しないことに注意を要する
1369 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1370 ele.dispatchEvent(evt);
1371 if (ele.getElementsByTagNameNS) {
1372 descend = ele.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1374 descend = ele.childNodes;
1377 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1378 for (var i=0,dli=descend.length;i<dli;++i) {
1379 var di = descend[i];
1381 di.dispatchEvent(evt);
1385 evt.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null);
1386 ele.dispatchEvent(evt);
1387 evt = descend = void 0;
1389 if (ele.parentNode === this) {
1390 this.childNodes.splice(ele._num,1); //Arrayのspliceを利用して、リストからeleノードを排除
1391 if (this.firstChild === ele) {
1392 this.firstChild = null;
1394 if (this.lastChild === ele) {
1395 this.lastChild = null;
1397 ele.previousSibling && (ele.previousSibling.nextSibling = ele.nextSibling);
1398 ele.nextSibling && (ele.nextSibling.previousSibling = ele.previousSibling);
1400 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1402 if (ele.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1403 throw (new Error());
1408 /*void*/ CharacterData.prototype.appendData = function( /*string*/ arg) {
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 = void 0;
1420 /*void*/ CharacterData.prototype.insertData = function( /*long*/ offset, /*string*/ arg) {
1422 pre = this.substring(0, offset - 1), //文字列を二つに分けた、前半部分
1423 next = this.substring(offset, this.length - offset), //後半部分
1425 this.data = pre + this.data + next;
1426 this.length = this.data.length;
1428 evt = this.ownerDocument.createEvent("MutationEvents");
1429 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1430 this.parentNode.dispatchEvent(evt);
1431 evt = arg = pd = pre = next = void 0;
1434 /*void*/ CharacterData.prototype.deleteData = function( /*long*/ offset, /*long*/ count) {
1436 pre = this.substring(0, offset - 1), //残すべき前半部分
1437 next = this.substring(offset + count, this.length - 1), //後半部分
1439 if (offset + count > this.length) { //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを削除
1442 this.data = pre + next;
1443 this.length = this.data.length;
1445 evt = this.ownerDocument.createEvent("MutationEvents");
1446 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1447 this.parentNode.dispatchEvent(evt);
1452 /*_ceventプロパティはcreateEventメソッドで軽量化のために使う。*/
1453 Document.prototype._cevent = {
1454 "MutationEvents" : MutationEvent,
1455 "MouseEvents" : MouseEvent,
1456 "UIEvents" : UIEvent
1463 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.idl
1465 #ifndef _STYLESHEETS_IDL_
1466 #define _STYLESHEETS_IDL_
1470 #pragma prefix "dom.w3c.org"
1474 typedef dom::DOMString DOMString;
1475 typedef dom::Node Node;
1481 function StyleSheet() {
1482 this.type = "text/css";
1483 this.disabled = false;
1484 /*Node*/ this.ownerNode = null;
1485 /*StyleSheet*/ this.parentStyleSheet = null;
1488 /*MediaList*/ this.media = new MediaList();
1493 *このインターフェースはArrayで代用する
1494 function StyleSheetList() {
1495 readonly attribute unsigned long length;
1496 StyleSheet item(in unsigned long index);
1500 function MediaList() {
1501 this.mediaText = "";
1505 MediaList.prototype = {
1506 /*string*/ item : function(/*long*/ index) {
1507 return (this[index]);
1509 /*void*/ deleteMedium : function(/*string*/ oldMedium) {
1510 for (var i=0,tli=this.length;i<tli;++i) {
1511 if (this[i] === oldMedium) {
1517 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1519 /*void*/ appendMedium : function(/*string*/ newMedium) {
1520 this[this.length] = newMedium;
1525 function LinkStyle() {
1526 /*StyleSheet*/ this.sheet = new StyleSheet();
1530 function DocumentStyle() {
1531 /*StyleSheetList*/ this.styleSheets = [];
1535 #endif // _STYLESHEETS_IDL_
1538 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.idl
1544 #include "stylesheets.idl"
1545 #include "views.idl"
1547 #pragma prefix "dom.w3c.org"
1551 typedef dom::DOMString DOMString;
1552 typedef dom::Element Element;
1553 typedef dom::DOMImplementation DOMImplementation;
1556 interface CSSStyleSheet;
1557 interface CSSStyleDeclaration;
1565 function CSSRuleList {
1566 readonly attribute unsigned long length;
1567 CSSRule item(in unsigned long index);
1571 *CSSのルールを表現する。基底クラスなので削除不可。
1573 function CSSRule() {
1575 /*CSSStyleSheet*/ this.parentStyleSheet;
1576 /*CSSRule*/ this.parentRule = null;
1580 CSSRule.UNKNOWN_RULE = 0;
1581 CSSRule.STYLE_RULE = 1;
1582 CSSRule.CHARSET_RULE = 2;
1583 CSSRule.IMPORT_RULE = 3;
1584 CSSRule.MEDIA_RULE = 4;
1585 CSSRule.FONT_FACE_RULE = 5;
1586 CSSRule.PAGE_RULE = 6;
1588 function CSSStyleRule() {
1589 CSSRule.call(this, arguments);
1590 this.type = CSSRule.STYLE_RULE;
1591 this.selectorText = "";
1592 /*CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
1593 this.style.parentRule = null;
1596 CSSStyleRule.prototype = new CSSRule();
1598 function CSSMediaRule() {
1599 CSSRule.call(this, arguments);
1600 this.type = CSSRule.MEDIA_RULE;
1601 /*stylesheets::MediaList*/ this.media = new MediaList();
1602 /*CSSRuleList*/ this.cssRules = [];
1605 CSSMediaRule.prototype = new CSSRule();
1606 /*long*/ CSSMediaRule.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
1607 this.cssRules.splice(index,rule,1);
1608 this.media.appendMedium(rule);
1611 /*void*/ CSSMediaRule.prototype.deleteRule = function( /*long*/ index) {
1614 function CSSFontFaceRule() {
1615 CSSRule.call(this, arguments);
1616 this.type = CSSRule.FONT_FACE_RULE;
1617 /*CSSStyleDeclaration*/ this.style;
1620 CSSFontFaceRule.prototype = new CSSRule();
1622 function CSSPageRule() {
1623 CSSRule.call(this, arguments);
1624 this.type = CSSRule.PAGE_RULE;
1625 this.selectorText = "";
1626 /*CSSStyleDeclaration*/ this.style;
1629 CSSPageRule.prototype = new CSSRule();
1631 function CSSImportRule() {
1632 CSSRule.call(this, arguments);
1633 this.type = CSSRule.IMPORT_RULE;
1635 /*stylesheets::MediaList*/ this.media = new MediaList();
1636 /*CSSStyleSheet*/ this.styleSheet = null;
1639 CSSImportRule.prototype = new CSSRule();
1641 function CSSCharsetRule() {
1642 CSSRule.call(this, arguments);
1643 this.type = CSSRule.CHARSET_RULE;
1647 CSSCharsetRule.prototype = new CSSRule();
1649 function CSSUnknownRule() {
1650 CSSRule.call(this, arguments);
1651 this.type = CSSRule.UNKNOWN_RULE;
1654 CSSUnknownRule.prototype = new CSSRule();
1656 /*CSSStyleDeclaration
1657 *CSSの宣言ブロックを表現。削除不可。
1659 function CSSStyleDeclaration() {
1660 this._list = []; //内部のリスト
1661 this._list._fontSize = this._list._opacity = null;
1664 CSSStyleDeclaration.prototype = {
1666 /*long*/ length : 0,
1667 /*CSSRule*/ parentRule : null,
1668 _urlreg : /url\(#([^)]+)/,
1669 /*getPropertyValueメソッド
1670 *CSSの値を返す。この値は継承ではなくて、明示的に表記されているもの
1672 /*string*/ getPropertyValue : function( /*string*/ propertyName) {
1673 var tg = this.getPropertyCSSValue(propertyName);
1675 var tc = tg.cssText;
1676 return (tc.slice(tc.indexOf(":")+1));
1681 /*getPropertyCSSValueメソッド
1682 *CSSValueオブジェクトを返す。このメソッドは判別に用いているので、削除不可。
1684 /*CSSValue*/ getPropertyCSSValue : function( /*string*/ propertyName) {
1685 var prop = propertyName,
1687 propertyName += ":";
1688 if (propertyName === ":") { //どんなデータ型でも、文字列に変換する機能をJavaScriptが持つことに注意
1691 for (var i=0,tl=this._list,tli=tl.length;i<tli;++i) {
1694 if (tc.indexOf(propertyName) > -1) { //プロパティ名に合致するCSSValueオブジェクトが見つかった場合
1695 ti._empercents = tl._fontSize;
1696 i = tl = tli = tc = prop = propertyName = void 0;
1700 i = tl = tli = prop = propertyName = void 0;
1703 /*removePropertyメソッド
1706 /*string*/ removeProperty : function( /*string*/ propertyName) {
1707 var tg = this.getPropertyCSSValue(propertyName);
1709 this._list.splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
1713 /*getPropertyPriorityメソッド
1714 *importantなどのpriorityを取得する
1716 /*string*/ getPropertyPriority : function( /*string*/ propertyName) {
1717 var tg = this.getPropertyCSSValue(propertyName);
1719 return (tg._priority);
1739 *プロパティを宣言内で、明示的に設定。継承は無視する
1741 /*void*/ setProperty : function( /*string*/ propertyName, /*string*/ value, /*string*/ priority) {
1742 var cssText = propertyName,
1748 if (!!this[propertyName]) {
1749 tg = this.getPropertyCSSValue(propertyName);
1753 if (this._isFillStroke[propertyName]) {
1754 /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
1755 *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
1760 ti = new SVGPaint();
1762 paintType = /*SVGPaint.SVG_PAINTTYPE_UNKNOWN*/ 0;
1763 v1 = value.charAt(0);
1764 if (this._isRS[v1] || ti._keywords[value]) {
1765 paintType = /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1;
1767 } else if (value === "none") {
1768 paintType = /*SVGPaint.SVG_PAINTTYPE_NONE*/ 101;
1769 } else if (this._urlreg.test(value)) { //fill属性の値がurl(#id)ならば
1770 paintType = /*SVGPaint.SVG_PAINTTYPE_URI*/ 107;
1772 } else if (value === "currentColor") {
1773 paintType = /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102;
1775 ti.setPaint(paintType, uri, color, null);
1776 paintType = v1 = uri = color = void 0;
1777 } else if (this._isStop[propertyName]) {
1781 ti = new SVGColor();
1783 if (value === "currentColor") {
1784 ti.colorType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
1786 ti.colorType = /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1;
1788 ti.setRGBColor(value);
1793 ti = new CSSPrimitiveValue();
1796 ti._priority = priority;
1797 ti.cssText = cssText;
1799 //_numプロパティはremovePropertyメソッドで利用する
1800 ti._num = this._list.length;
1801 this._list[ti._num] = ti;
1802 this[propertyName] = 1;
1805 if (value === "inherit") {
1806 ti.cssValueType = CSSValue.CSS_INHERIT;
1807 } else if (propertyName === "opacity") {
1808 this._list._opacity = +value;
1809 } else if (propertyName === "font-size") {
1810 if (/(%|em|ex)/.test(value)) {
1812 ti[tg] = parseFloat(value);
1814 this._em = this._ex = this["_%"] = null;
1815 this._list._fontSize = parseFloat(value);
1821 *リストの位置にあるプロパティ名を取得する。宣言内のすべてのプロパティ名を取得するのに便利
1823 /*string*/ item : function( /*long*/ index) {
1824 if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
1827 var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
1833 function CSSValue() {
1837 CSSValue.CSS_INHERIT = 0;
1838 CSSValue.CSS_PRIMITIVE_VALUE = 1;
1839 CSSValue.CSS_VALUE_LIST = 2;
1840 CSSValue.CSS_CUSTOM = 3;
1841 CSSValue.prototype = {
1843 cssValueType : CSSValue.CSS_CUSTOM,
1844 _isDefault : 0 //デフォルトであるかどうか(独自のプロパティ)
1847 function CSSPrimitiveValue() {
1854 t.CSS_PERCENTAGE = 2;
1870 t.CSS_DIMENSION = 18;
1877 t.CSS_RGBCOLOR = 25;
1878 t.prototype = new CSSValue();
1879 })(CSSPrimitiveValue);
1882 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に統一)
1883 this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
1884 this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
1886 this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
1887 this._empercent = 0;
1888 this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う
1889 /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
1890 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1891 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1893 this.primitiveType = unitType;
1894 this._value = floatValue * this._n[unitType-1]; //値はあらかじめ、利用しやすいように変換しておく
1899 this._regd = /[\d\.]+/;
1900 /*float*/ this.getFloatValue = function(/*short*/ unitType) {
1901 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1902 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1904 if (this._value || (this._value === 0)) { //すでに、setFloatValueメソッドによって_valueプロパティが設定されていた場合
1905 return (this._value / this._n[unitType-1]);
1907 var tc = this.cssText,
1910 s = +(tc.match(this._regd));
1911 s = isNaN(s) ? 0 : s;
1912 if (n >= "0" && n <= "9") {
1913 type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
1914 if (unitType === 1) {
1915 unitType = tc = n = type = void 0;
1918 } else if (n === "%") {
1920 type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
1921 } else if ((n === "m") && (tc.charAt(tc.length-2) === "e")) {
1922 s *= this._empercent;
1923 type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
1924 } else if ((n === "x") && (tc.charAt(tc.length-2) === "e")) {
1925 type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
1926 } else if ((n === "x") && (tc.charAt(tc.length-2) === "p")) {
1927 type = /*CSSPrimitiveValue.CSS_PX*/ 5;
1928 } else if ((n === "m") && (tc.charAt(tc.length-2) === "c")) {
1929 type = /*CSSPrimitiveValue.CSS_CM*/ 6;
1930 } else if ((n === "m") && (tc.charAt(tc.length-2) === "m")) {
1931 type = /*CSSPrimitiveValue.CSS_MM*/ 7;
1932 } else if (n === "n") {
1933 type = /*CSSPrimitiveValue.CSS_IN*/ 8;
1934 } else if (n === "t") {
1935 type = /*CSSPrimitiveValue.CSS_PT*/ 9;
1936 } else if (n === "c") {
1937 type = /*CSSPrimitiveValue.CSS_PC*/ 10;
1939 s = s * this._n[type-1] / this._n[unitType-1];
1940 tc = n = type = unitType = void 0;
1944 /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
1945 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1946 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1948 this._value = stringValue;
1950 /*string*/ this.getStringValue = function(/*short*/ stringType) {
1951 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1952 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1954 return (this._value);
1956 /*Counter*/ this.getCounterValue = function() {
1957 if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
1958 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1960 return (new Counter());
1962 /*Rect*/ this.getRectValue = function() {
1963 if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
1964 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1966 return (new Rect());
1968 /*RGBColor*/ this.getRGBColorValue = function() {
1969 if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
1970 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1972 var s = new RGBColor();
1973 var rgbColor = this.cssText;
1974 var tkr = SVGColor.prototype._keywords[rgbColor];
1975 if (tkr !== void 0) {
1978 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
1979 rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
1980 return Math.round((2.55 * parseFloat(t)));
1982 } else if (rgbColor.indexOf("#") > -1) { //#を含む場合
1983 rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
1984 return parseInt(s, 16);
1987 var n = rgbColor.match(/\d+/g);
1988 s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
1989 s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
1990 s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
1991 n = rgbColor = void 0;
1994 }).apply(CSSPrimitiveValue.prototype);
1998 function CSSValueList() {
1999 this.cssValueType = CSSValue.CSS_VALUE_LIST;
2003 CSSValueList.prototype = new CSSValue();
2004 /*CSSValue*/ CSSValueList.prototype.item = function( /*long*/ index) {
2005 return (this[index]);
2008 function RGBColor() {
2009 var cs = CSSPrimitiveValue;
2010 this.red = new cs();
2011 this.green = new cs();
2012 this.blue = new cs();
2014 this.red.primitiveType = this.green.primitiveType = this.blue.primitiveType = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2019 var cs = CSSPrimitiveValue;
2020 this.top = new cs();
2021 this.right = new cs();
2022 this.bottom = new cs();
2023 this.left = new cs();
2028 function Counter() {
2029 this.identifier = this.listStyle = this.separator = "";
2033 function ElementCSSInlineStyle() {
2034 var cs = CSSStyleDeclaration;
2035 this.style = new cs();
2036 this._attributeStyle = new cs(); //プレゼンテーション属性の値を格納する
2052 visibility : "visible",
2053 display : "inline-block",
2057 strokeDasharray : n,
2058 strokeDashoffset : "0",
2059 strokeLinecap : "butt",
2060 strokeLinejoin : "miter",
2061 strokeMiterlimit : "4",
2062 strokeOpacity : "1",
2063 writingMode : "lr-tb",
2064 fontFamily : "serif",
2074 //# Gradient properties:
2076 stopColor : "black",
2078 textAnchor : "start",
2080 // raises(dom::DOMException) on setting
2081 //簡略プロパティに関しては、初期値を再考せよ
2086 overflow : "visible",
2093 verticalAlign : "baseline",
2103 fillRule : "nonzero",
2105 //# Filter Effects properties:
2107 enableBackground : "accumulate",
2109 floodColor : "black",
2111 lightingColor : "white",
2113 //# Interactivity properties:
2115 pointerEvents : "visiblePainted",
2117 //# Color and Painting properties:
2119 colorInterpolation : "sRGB",
2120 colorInterpolationFilters : "linearRGB",
2128 //# Text properties:
2130 alignmentBaseline : "",
2131 baselineShift : "baseline",
2132 dominantBaseline : a,
2133 glyphOrientationHorizontal : "0deg",
2134 glyphOrientationVertical : a,
2138 CSS2Properties.visibility._n = 1; //初期値の設定(_setPaintで使う)
2140 function CSSStyleSheet() {
2141 /*CSSRule*/ this.ownerRule = null;
2142 /*CSSRuleList*/ this.cssRules = [];
2145 CSSStyleSheet.prototype = new StyleSheet();
2146 /*long*/ CSSStyleSheet.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
2147 var s = new CSSStyleRule(), style = s.style, a, sc = rule.match(/\{[\s\S]+\}/), m;
2148 s.parentStyleSheet = this;
2149 style.cssText = rule;
2151 sc = sc.replace(/^[^a-z\-]+/, "")
2152 .replace(/\:\s+/g, ":")
2153 .replace(/\s*;[^a-z\-]*/g, ";");
2155 for (var i=0, ali=a.length;i<ali;++i) {
2159 style.setProperty(m[0], m[1]);
2163 a = sc = style = void 0;
2164 this.cssRules.splice(index,s,1);
2166 /*void*/ CSSStyleSheet.prototype.deleteRule = function(/*long*/ index) {
2167 this.cssRules.splice(index, 1);
2171 /*getComputedStyle関数
2172 *最近の計算値を取得する。Document.defaultViewはSafariがグローバル(window)にサポートしていないため付ける。
2174 /*interface ViewCSS : views::AbstractView {*/
2175 Document.prototype.defaultView = new ViewCSS();
2179 /*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2180 var s = new CSSStyleDeclaration(),
2183 //クロージャを利用して、カスケーディングを実現する
2184 s.getPropertyCSSValue = (function(elt, td, s){
2185 return function( /*string*/ propertyName) {
2189 while (el && (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0))) {
2190 if (el._runtimeStyle && el._runtimeStyle[propertyName]) {
2191 css = el._runtimeStyle.getPropertyCSSValue(propertyName);
2192 } else if (el.style && el.style[propertyName]) {
2193 css = el.style.getPropertyCSSValue(propertyName);
2194 } else if (el._attributeStyle && el._attributeStyle[propertyName]) {
2196 css = el._attributeStyle.getPropertyCSSValue(propertyName);
2197 } else if (el._rules) {
2199 for (var i=0,eli=el._rules.length;i<eli;++i) {
2200 el._rules[i].style[propertyName] && (css = el._rules[i].style.getPropertyCSSValue(propertyName));
2205 if (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0)) {
2207 td && (css = td[propertyName]);
2209 if (css && css.setRGBColor && ((css.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) || (css.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3))) {
2210 css.setRGBColor(s.getPropertyValue("color"));
2211 } else if (css && (css._em || css._ex || css["_%"])) {
2215 if (el.style._list._fontSize) {
2216 n = el.style._list._fontSize;
2223 } else if (css._ex) {
2225 } else if (css["_%"]) {
2226 n *= css["_%"] / 100;
2228 css.cssText = "font-size:" +n+ "px";
2233 })(elt, this._defaultCSS, s); //_defaultCSSはデフォルト値の設定
2237 es = el.style._list._opacity || el._attributeStyle._list._opacity;
2242 s._list._opacity = eso;
2243 el = pelt = eso = es = void 0;
2244 s._document = elt.ownerDocument;
2248 /*getOverrideStyleメソッド
2249 *指定した要素の上書きスタイルシートを取得。
2251 /*function DocumentCSS : stylesheets::DocumentStyle {*/
2252 /*CSSStyleDeclaration*/ Document.prototype.getOverrideStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2254 if (!!tar._runtimeStyle) {
2255 return (tar._runtimeStyle);
2257 var s = new CSSStyleDeclaration(), setProp = s.setProperty;
2258 tar._runtimeStyle = s;
2260 s.setProperty = (function(setProp, s){
2261 return function(propertyName, value, priority) {
2262 setProp.call(s, propertyName, value, priority);
2263 var tar = elt, el = tar._tar, isFill = isStroke = false;
2264 if ((tar.localName === "g") || (tar.localName === "a")) {
2265 var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
2267 for (var i=0,sli=sl.length;i<sli;++i) {
2269 NAIBU._setPaint(di, di.getScreenCTM());
2279 NAIBU._setPaint(tar, tar.getScreenCTM());
2280 el = tar = value = void 0;
2285 /*createCSSStyleSheetメソッド
2288 /*interface DOMImplementationCSS : DOMImplementation {*/
2289 /*CSSStyleSheet*/ DOMImplementation.createCSSStyleSheet = function( /*string*/ title, /*string*/ media) {
2290 var s = new CSSStyleSheet();
2292 var nm = new MediaList();
2293 nm.mediaText = media;
2294 if (media && (media !== "")) {
2295 var mes = media.split(","); //文字列をコンマで区切って配列に
2296 for (var i=0,mli=mes.length;i<mli;++i) {
2297 nm.appendMedium(mes[i]); //メディアリストに値を加えていく
2313 #pragma prefix "dom.w3c.org"
2316 typedef dom::DOMString DOMString;
2318 /*ElementTimeControlはSVGAnimationElementに統合させる。
2321 function ElementTimeControl(ele) {
2323 /*_startと_endプロパティはミリ秒数を収納する。
2324 *_startはアニメ開始時の秒数のリスト。_finishはアニメ終了時の秒数のリスト。
2325 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
2328 this._finish = null;
2331 ElementTimeControl.prototype = {
2332 /*void*/ beginElement : function() {
2333 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2334 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
2335 this.dispatchEvent(evt);
2337 /*void*/ endElement : function() {
2338 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2339 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
2340 this.dispatchEvent(evt);
2342 /*void*/ beginElementAt : function(/*float*/ offset) {
2343 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
2344 start = this._start || [];
2345 for (var i=0,sli=start.length;i<sli;++i) {
2346 if (start[i] === (offset+ntc)) {
2347 ntc = start = offset = void 0;
2351 start.push(offset + ntc);
2352 this._start = start;
2354 /*void*/ endElementAt : function(/*float*/ offset) {
2355 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
2356 fin = this._finish || [];
2357 for (var i=0,fli=fin.length;i<fli;++i) {
2358 if (fin[i] === (offset+ntc)) {
2359 ntc = fin = offset = void 0;
2363 fin.push(offset + ntc);
2368 function TimeEvent() {
2370 /*readonly attribute views::AbstractView*/ this.view;
2371 /*readonly attribute long*/ this.detail;
2374 TimeEvent.counstructor = Event;
2375 TimeEvent.prototype = new Event();
2376 /*void*/ TimeEvent.prototype.initTimeEvent = function(/*DOMString*/ typeArg,
2377 /*views::AbstractView*/ viewArg,
2378 /*long*/ detailArg) {
2379 this.type = typeArg;
2380 this.view = viewArg;
2381 this.detail = detailArg;
2383 //#endif // _SMIL_IDL_
2393 // For access to DOM2 core
2395 // For access to DOM2 events
2396 #include "events.idl"
2397 // For access to those parts from DOM2 CSS OM used by SVG DOM.
2399 // For access to those parts from DOM2 Views OM used by SVG DOM.
2400 #include "views.idl"
2401 // For access to the SMIL OM used by SVG DOM.
2403 #pragma prefix "dom.w3c.org"
2404 #pragma javaPackage "org.w3c.dom"
2407 typedef dom::DOMString DOMString;
2408 typedef dom::DOMException DOMException;
2409 typedef dom::Element Element;
2410 typedef dom::Document Document;
2411 typedef dom::NodeList NodeList;
2413 interface SVGElement;
2414 interface SVGLangSpace;
2415 interface SVGExternalResourcesRequired;
2417 interface SVGFitToViewBox;
2418 interface SVGZoomAndPan;
2419 interface SVGViewSpec;
2420 interface SVGURIReference;
2422 interface SVGMatrix;
2423 interface SVGPreserveAspectRatio;
2424 interface SVGAnimatedPreserveAspectRatio;
2425 interface SVGTransformList;
2426 interface SVGAnimatedTransformList;
2427 interface SVGTransform;
2428 interface SVGICCColor;
2431 interface SVGTransformable;
2432 interface SVGDocument;
2433 interface SVGSVGElement;
2434 interface SVGElementInstance;
2435 interface SVGElementInstanceList;
2437 function SVGException(code) {
2438 /*unsigned short*/ this.code = code;
2439 if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
2440 this.message = "SVG Wrong Type Error";
2441 } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
2442 this.message = "SVG Invalid Value Error";
2443 } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
2444 this.message = "SVG Matrix Not Invertable";
2448 SVGException.prototype = new Error();
2450 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR = 0;
2451 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR = 1;
2452 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE = 2;
2455 *すべてのSVG関連要素の雛形となるオブジェクト
2457 function SVGElement() {
2459 SVGStylable.call(this); //ElementCSSInlineStyleのインタフェースを継承
2460 /*interface SVGTransformable : SVGLocatable
2461 *TransformListはtransform属性を行列で表現したあとのリスト構造
2463 /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
2464 //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
2465 this.addEventListener("DOMAttrModified", function(evt){
2466 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2469 var name = evt.attrName,
2471 if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
2472 tar._attributeStyle.setProperty(name, evt.newValue, "");
2474 if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
2475 tar.id = evt.newValue;
2476 } else if ((name === "transform") && !!tar.transform) {
2477 var tft = evt.newValue,
2479 coma = tft.match(tar._comaReg), //コマンド文字にマッチ translate
2480 list = tft.match(tar._strReg), //カッコ内のリストにマッチ (10 20 30...)
2490 etod = evt.target.ownerDocument.documentElement,
2491 ttb = tar.transform.baseVal;
2492 //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
2493 for (var j=0,cli=coma.length;j<cli;j++) {
2494 s = etod.createSVGTransform();
2497 deg = lis.match(degR);
2510 s.setRotate(degz, +(deg[1]), +(deg[2]))
2511 } else if (degli <= 2) {
2513 if (com === "translate") {
2514 s.setTranslate(degz, +(deg[1] || 0));
2515 } else if (com === "scale") {
2516 s.setScale(degz, +(deg[1] || deg[0]));
2517 } else if (com === "rotate") {
2518 s.setRotate(degz, 0, 0);
2519 } else if (com === "skewX") {
2521 } else if (com === "skewY") {
2528 tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
2529 } else if (name === "style") {
2530 var sc = evt.newValue,
2538 sc = sc.replace(tar._shouReg, "")
2539 .replace(tar._conReg, ":")
2540 .replace(tar._bouReg, ";");
2542 for (var i=0, ali=a.length;i<ali;++i) {
2546 style.setProperty(m[0], m[1]);
2551 a = sc = style = void 0;
2552 } else if (name === "class") {
2553 tar.className = evt.newValue;
2554 } else if (name.indexOf("on") === 0) { //event属性ならば
2555 /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
2556 *ところが、IEでは、undefinedの値を返してしまう。
2557 *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
2559 eval("document._s = (function(evt){" +evt.newValue+ "})");
2560 var v = name.slice(2);
2563 } else if (v === "unload") {
2565 } else if (v === "abort") {
2567 } else if (v === "error") {
2569 } else if (v === "resize") {
2571 } else if (v === "scroll") {
2573 } else if (v === "zoom") {
2575 } else if (v === "begin") {
2577 } else if (v === "end") {
2579 } else if (v === "repeat") {
2582 tar.addEventListener(v, document._s, false);
2583 } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
2584 tar.xmlbase = evt.newValue;
2585 } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
2586 var tea = tar[name],
2587 tod = tar.nearestViewportElement || tar.ownerDocument.documentElement,
2588 tvw = tod.viewport.width,
2589 tvh = tod.viewport.height,
2591 n = evt.newValue.slice(-2),
2593 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
2594 _parseFloat = parseFloat;
2595 if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
2596 } else if (m === "%") {
2597 if (tar._x1width[name]) {
2598 tea.baseVal._percent = tvw * 0.01;
2599 } else if (tar._y1height[name]) {
2600 tea.baseVal._percent = tvh * 0.01;
2602 tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
2604 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
2605 } else if (n === "em") {
2606 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
2607 } else if (n === "ex") {
2608 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
2609 } else if (n === "px") {
2610 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
2611 } else if (n === "cm") {
2612 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
2613 } else if (n === "mm") {
2614 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
2615 } else if (n === "in") {
2616 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
2617 } else if (n === "pt") {
2618 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
2619 } else if (n === "pc") {
2620 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
2622 s = _parseFloat(evt.newValue);
2623 s = isNaN(s) ? 0 : s;
2624 tea.baseVal.newValueSpecifiedUnits(type, s);
2625 tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
2627 evt = _parseFloat = name = tar = null;
2631 SVGElement.prototype = new Element();
2634 /*以下の正規表現は属性のパーサの際に用いる*/
2635 this._degReg = /[\-\d\.e]+/g;
2636 this._comaReg = /[A-Za-z]+(?=\s*\()/g;
2637 this._strReg = /\([^\)]+\)/g;
2638 this._syouReg = /^[^a-z\-]+/;
2639 this._conReg = /\:\s+/g;
2640 this._bouReg = /\s*;[^a-z\-]*/g;
2641 /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
2644 this._cacheMatrix = null;
2645 /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
2660 /*String*/ this.id = null; //id属性の値
2661 /*String*/ this.xmlbase = null; //xml:base属性の値
2662 /*SVGSVGElement*/ this.ownerSVGElement; //ルート要素であるsvg要素
2663 /*readonly SVGElement*/ this.viewportElement; //ビューポートを形成する要素(多くはsvg要素)
2664 /*readonly attribute SVGElement*/ this.nearestViewportElement = null;
2665 /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
2667 /*interface SVGLocatable*/
2668 /*SVGRect*/ this.getBBox = function(){
2669 var s = new SVGRect(),
2670 data = this._tar.path.value,
2671 vi = this.ownerDocument.documentElement.viewport,
2676 degis = data.match(/[0-9\-]+/g),
2679 /*要素の境界領域を求める(四隅の座標を求める)
2680 *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
2681 *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
2683 for (var i=0,degisli=degis.length;i<degisli;i+=2) {
2686 el = el > nx ? nx : el;
2687 et = et > ny ? ny : et;
2688 er = er > nx ? er : nx;
2689 eb = eb > ny ? eb : ny;
2695 nx = ny = data = degis =el = et = er = eb = vi = void 0;
2700 *CTMとは現在の利用座標系に対する変換行列
2701 *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
2702 *1.2ではgetCTMが言及されていない
2703 *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
2705 /*SVGMatrix*/ this.getCTM = function() {
2707 if (!!this._cacheMatrix) { //キャッシュがあれば
2708 s = this._cacheMatrix;
2710 m = this.transform.baseVal.consolidate();
2714 m = this.ownerDocument.documentElement.createSVGMatrix();
2716 if (this.parentNode && !!this.parentNode.getCTM) {
2717 s = this.parentNode.getCTM().multiply(m);
2722 this._cacheMatrix = s; //キャッシュをためて次回で使う
2727 /*SVGMatrix*/ this.getScreenCTM = function(){
2728 if (!this.parentNode) {
2731 var view = this.nearestViewportElement || this.ownerDocument.documentElement;
2732 var s = view.getScreenCTM().multiply(this.getCTM());
2737 /*getTransformToElementメソッド
2738 *これは、あるelementへの変換行列を計算して返す
2739 *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
2741 /*SVGMatrix*/ this.getTransformToElement = function(/*SVGElement*/ element ){
2742 var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
2745 }).apply(SVGElement.prototype);
2747 function SVGAnimatedBoolean() {
2748 /*boolean*/ this.animVal = this.baseVal = true;
2752 function SVGAnimatedString() {
2753 /*String*/ this.animVal = this.baseVal = "";
2757 function SVGStringList() {
2760 SVGStringList.prototype = new Array();
2762 /*readonly unsigned long*/ this.numberOfItems = 0;
2763 /*void*/ this.clear = function(){
2764 for (var i=0, tli=this.length;i<tli;++i) {
2767 this.numberOfItems = 0;
2769 /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
2772 this.numberOfItems = 1;
2775 /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
2776 if (index >= this.numberOfItems || index < 0) {
2777 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2779 return (this[index]);
2782 /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2783 if (index >= this.numberOfItems) {
2784 this.appendItem(newItem);
2786 this.splice(index, 1, newItem, this.getItem[index]);
2787 ++this.numberOfItems;
2791 /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2792 if (index >= this.numberOfItems || index < 0) {
2793 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2795 this.splice(index, 1, newItem);
2799 //raises( DOMException, SVGException );
2800 /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
2801 if (index >= this.numberOfItems || index < 0) {
2802 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2804 this.splice(index, 1);
2805 --this.numberOfItems;
2809 /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
2810 this[this.numberOfItems] = newItem;
2811 ++this.numberOfItems;
2813 }).apply(SVGStringList.prototype);
2815 function SVGAnimatedEnumeration() {
2816 /*unsigned short*/ this.baseVal = 0;
2817 // raises DOMException on setting
2818 /*readonly unsigned short*/ this.animVal = 0;
2821 function SVGAnimatedInteger() {
2822 /*long*/ this.baseVal = 0;
2823 // raises DOMException on setting
2824 /*readonly long*/ this.animVal = 0;
2827 function SVGNumber() {
2828 /*float*/ this.value = 0;
2829 // raises DOMException on setting
2832 function SVGAnimatedNumber() {
2833 /*float*/ this.baseVal = this.animVal = 0;
2837 function SVGNumberList() {
2840 /*SVGUnmberListのメソッドはSVGPathSegListを参照*/
2842 function SVGAnimatedNumberList() {
2843 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
2847 *長さを設定する(単位pxに統一する方便として使う)
2848 *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
2850 function SVGLength() {
2854 // Length Unit Types
2855 /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN = 0;
2856 /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER = 1;
2857 /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
2858 /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS = 3;
2859 /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS = 4;
2860 /*const unsigned short*/ t.SVG_LENGTHTYPE_PX = 5;
2861 /*const unsigned short*/ t.SVG_LENGTHTYPE_CM = 6;
2862 /*const unsigned short*/ t.SVG_LENGTHTYPE_MM = 7;
2863 /*const unsigned short*/ t.SVG_LENGTHTYPE_IN = 8;
2864 /*const unsigned short*/ t.SVG_LENGTHTYPE_PT = 9;
2865 /*const unsigned short*/ t.SVG_LENGTHTYPE_PC = 10;
2868 SVGLength.prototype = {
2869 /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
2870 /*attribute float*/ value : 0, //利用単位における値
2871 /*attribute float*/ valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN, //unitTypeにおける値
2872 /*attribute DOMString*/ valueAsString : "0",
2873 _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
2874 _fontSize : 12, //単位のemとexで使われるfont-sizeの値
2875 /*newValueSpedifiedUnitsメソッド
2876 *新しくunitTypeにおける値を設定する
2877 *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
2879 newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
2881 _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
2882 if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
2883 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
2885 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
2888 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
2891 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
2892 n = this._fontSize * 0.5;
2894 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
2897 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
2900 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
2903 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
2906 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
2910 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2912 this.unitType = unitType;
2913 this.value = valueInSpecifiedUnits * n;
2914 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2915 this.valueAsString = valueInSpecifiedUnits + _s;
2916 valueInSpecifiedUnits = unitType = n = _s = void 0;
2918 /*convertToSpecifiedUnitsメソッド
2919 *valueプロパティを書き換えずに、単位だけを変換する
2921 * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
2922 * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
2923 * alert(x.valueAsString); //20mm
2925 convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
2926 if (this.value === 0) {
2927 this.newValueSpecifiedUnits(unitType, 0);
2931 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2932 v = v / this.value * this.valueInSpecifiedUnits;
2933 this.newValueSpecifiedUnits(unitType, v);
2936 *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
2937 *単位が%の場合は、新しいvalueへと変換させておく
2939 _emToUnit : function (/*float*/ fontSize) {
2940 if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
2941 this._fontSize = fontSize;
2942 this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
2946 function SVGAnimatedLength() {
2947 /*readonly SVGLength*/ this.animVal;
2948 this.baseVal = new SVGLength();
2949 this.baseVal.unitType = 1;
2952 function SVGLengthList() {
2955 /*SVGLengthListのメソッドはSVGPathSegListを参照*/
2957 function SVGAnimatedLengthList() {
2958 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
2961 function SVGAngle() {
2964 SVGAngle.prototype = {
2965 /*readonly attribute unsigned short*/ unitType : 0,
2966 /*attribute float*/ value : 0,
2967 // raises DOMException on setting
2968 /*attribute float*/ valueInSpecifiedUnits : 0,
2969 // raises DOMException on setting
2970 /*attribute DOMString*/ valueAsString : "0",
2971 // raises DOMException on setting
2972 /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
2974 _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
2975 if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
2976 } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
2978 } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
2981 } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
2985 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2987 this.unitType = unitType;
2988 this.value = valueInSpecifiedUnits * n;
2989 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2990 this.valueAsString = valueInSpecifiedUnits + _s;
2992 //raises( DOMException );
2994 /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
2995 if (this.value === 0) {
2996 this.newValueSpecifiedUnits(unitType, 0);
3000 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
3001 v = v / this.value * this.valueInSpecifiedUnits;
3002 this.newValueSpecifiedUnits(unitType, v);
3003 //raises( DOMException );
3007 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN = 0;
3008 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
3009 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG = 2;
3010 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD = 3;
3011 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD = 4;
3012 function SVGAnimatedAngle() {
3013 /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
3014 /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
3017 function SVGColor() {
3018 CSSValue.apply(this);
3019 /*readonly css::RGBColor*/ this.rgbColor = new RGBColor();
3024 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN = 0;
3025 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR = 1;
3026 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
3027 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR = 3;
3028 SVGColor.prototype = new CSSValue(); //ノードのプロトタイプチェーンを作って、継承
3031 /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
3032 /*readonly SVGICCColor*/ this.iccColor = null;
3033 this._regD = /\d+/g;
3034 this._regDP = /[\d.]+%/g;
3035 this._exceptionsvg = SVGException.SVG_INVALID_VALUE_ERR;
3036 /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
3040 if (!rgbColor || (typeof rgbColor !== "string")) {
3041 throw new SVGException(this._exceptionsvg);
3043 rgbColor = this._keywords[rgbColor] || rgbColor;
3044 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
3045 rgbColor = rgbColor.replace(this._regDP, function(s) {
3046 return Math.round((2.55 * parseFloat(s)));
3048 s = rgbColor.match(this._regD);
3049 } else if (rgbColor.indexOf("#") === 0) { //#を含む場合
3051 _parseInt = parseInt;
3052 if (rgbColor.length < 5) {
3053 r = rgbColor.charAt(1);
3054 g = rgbColor.charAt(2);
3055 b = rgbColor.charAt(3)
3056 rgbColor = "#" + r + r + g + g + b + b;
3058 s[0] = _parseInt(rgbColor.slice(1, 3), 16)+ "";
3059 s[1] = _parseInt(rgbColor.slice(3, 5), 16)+ "";
3060 s[2] = _parseInt(rgbColor.slice(5, 7), 16)+ "";
3063 s = rgbColor.match(this._regD);
3064 if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
3066 throw new SVGException(this._exceptionsvg);
3069 this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
3070 this.rgbColor.green.setFloatValue(1, s[1]);
3071 this.rgbColor.blue.setFloatValue(1, s[2]);
3072 rgbColor = s = _parseInt = void 0;
3075 // raises( SVGException );
3076 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
3077 this.colorType = colorType;
3078 if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
3079 throw new SVGException(this._exceptionsvg);
3080 } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
3081 this.setRGBColor(rgbColor);
3082 } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
3083 this.setRGBColor(rgbColor);
3084 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
3085 throw new SVGException(this._exceptionsvg);
3086 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
3087 throw new SVGException(this._exceptionsvg);
3089 colorType = rgbColor = void 0;
3091 // raises( SVGException );
3094 aliceblue: "rgb(240,248,255)",
3095 antiquewhite: "rgb(250,235,215)",
3096 aqua: "rgb(0,255,255)",
3097 aquamarine: "rgb(127,255,212)",
3098 azure: "rgb(240,255,255)",
3099 beige: "rgb(245,245,220)",
3100 bisque: "rgb(255,228,196)",
3101 black: "rgb(0,0,0)",
3102 blanchedalmond:"rgb(255,235,205)",
3103 blue: "rgb(0,0,255)",
3104 blueviolet: "rgb(138,43,226)",
3105 brown: "rgb(165,42,42)",
3106 burlywood: "rgb(222,184,135)",
3107 cadetblue: "rgb(95,158,160)",
3108 chartreuse: "rgb(127,255,0)",
3109 chocolate: "rgb(210,105,30)",
3110 coral: "rgb(255,127,80)",
3111 cornflowerblue:"rgb(100,149,237)",
3112 cornsilk: "rgb(255,248,220)",
3113 crimson: "rgb(220,20,60)",
3114 cyan: "rgb(0,255,255)",
3115 darkblue: "rgb(0,0,139)",
3116 darkcyan: "rgb(0,139,139)",
3117 darkgoldenrod:"rgb(184,134,11)",
3118 darkgray: "rgb(169,169,169)",
3119 darkgreen: "rgb(0,100,0)",
3120 darkgrey: "rgb(169,169,169)",
3121 darkkhaki: "rgb(189,183,107)",
3122 darkmagenta: "rgb(139,0,139)",
3123 darkolivegreen:"rgb(85,107,47)",
3124 darkorange: "rgb(255,140,0)",
3125 darkorchid: "rgb(153,50,204)",
3126 darkred: "rgb(139,0,0)",
3127 darksalmon: "rgb(233,150,122)",
3128 darkseagreen: "rgb(143,188,143)",
3129 darkslateblue:"rgb(72,61,139)",
3130 darkslategray:"rgb(47,79,79)",
3131 darkslategrey:"rgb(47,79,79)",
3132 darkturquoise:"rgb(0,206,209)",
3133 darkviolet: "rgb(148,0,211)",
3134 deeppink: "rgb(255,20,147)",
3135 deepskyblue: "rgb(0,191,255)",
3136 dimgray: "rgb(105,105,105)",
3137 dimgrey: "rgb(105,105,105)",
3138 dodgerblue: "rgb(30,144,255)",
3139 firebrick: "rgb(178,34,34)",
3140 floralwhite: "rgb(255,250,240)",
3141 forestgreen: "rgb(34,139,34)",
3142 fuchsia: "rgb(255,0,255)",
3143 gainsboro: "rgb(220,220,220)",
3144 ghostwhite: "rgb(248,248,255)",
3145 gold: "rgb(255,215,0)",
3146 goldenrod: "rgb(218,165,32)",
3147 gray: "rgb(128,128,128)",
3148 grey: "rgb(128,128,128)",
3149 green: "rgb(0,128,0)",
3150 greenyellow: "rgb(173,255,47)",
3151 honeydew: "rgb(240,255,240)",
3152 hotpink: "rgb(255,105,180)",
3153 indianred: "rgb(205,92,92)",
3154 indigo: "rgb(75,0,130)",
3155 ivory: "rgb(255,255,240)",
3156 khaki: "rgb(240,230,140)",
3157 lavender: "rgb(230,230,250)",
3158 lavenderblush:"rgb(255,240,245)",
3159 lawngreen: "rgb(124,252,0)",
3160 lemonchiffon: "rgb(255,250,205)",
3161 lightblue: "rgb(173,216,230)",
3162 lightcoral: "rgb(240,128,128)",
3163 lightcyan: "rgb(224,255,255)",
3164 lightgoldenrodyellow:"rgb(250,250,210)",
3165 lightgray: "rgb(211,211,211)",
3166 lightgreen: "rgb(144,238,144)",
3167 lightgrey: "rgb(211,211,211)",
3168 lightpink: "rgb(255,182,193)",
3169 lightsalmon: "rgb(255,160,122)",
3170 lightseagree: "rgb(32,178,170)",
3171 lightskyblue: "rgb(135,206,250)",
3172 lightslategray:"rgb(119,136,153)",
3173 lightslategrey:"rgb(119,136,153)",
3174 lightsteelblue:"rgb(176,196,222)",
3175 lightyellow: "rgb(255,255,224)",
3176 lime: "rgb(0,255,0)",
3177 limegreen: "rgb(50,205,50)",
3178 linen: "rgb(250,240,230)",
3179 magenta: "rgb(255,0,255)",
3180 maroon: "rgb(128,0,0)",
3181 mediumaquamarine:"rgb(102,205,170)",
3182 mediumblue: "rgb(0,0,205)",
3183 mediumorchid: "rgb(186,85,211)",
3184 mediumpurple: "rgb(147,112,219)",
3185 mediumseagreen:"rgb(60,179,113)",
3186 mediumslateblue:"rgb(123,104,238)",
3187 mediumspringgreen:"rgb(0,250,154)",
3188 mediumturquoise:"rgb(72,209,204)",
3189 mediumvioletred:"rgb(199,21,133)",
3190 midnightblue: "rgb(25,25,112)",
3191 mintcream: "rgb(245,255,250)",
3192 mistyrose: "rgb(255,228,225)",
3193 moccasin: "rgb(255,228,181)",
3194 navajowhite: "rgb(255,222,173)",
3195 navy: "rgb(0,0,128)",
3196 oldlace: "rgb(253,245,230)",
3197 olive: "rgb(128,128,0)",
3198 olivedrab: "rgb(107,142,35)",
3199 orange: "rgb(255,165,0)",
3200 orangered: "rgb(255,69,0)",
3201 orchid: "rgb(218,112,214)",
3202 palegoldenrod: "rgb(238,232,170)",
3203 palegreen: "rgb(152,251,152)",
3204 paleturquoise: "rgb(175,238,238)",
3205 palevioletred: "rgb(219,112,147)",
3206 papayawhip: "rgb(255,239,213)",
3207 peachpuff: "rgb(255,218,185)",
3208 peru: "rgb(205,133,63)",
3209 pink: "rgb(255,192,203)",
3210 plum: "rgb(221,160,221)",
3211 powderblue: "rgb(176,224,230)",
3212 purple: "rgb(128,0,128)",
3213 red: "rgb(255,0,0)",
3214 rosybrown: "rgb(188,143,143)",
3215 royalblue: "rgb(65,105,225)",
3216 saddlebrown: "rgb(139,69,19)",
3217 salmon: "rgb(250,128,114)",
3218 sandybrown: "rgb(244,164,96)",
3219 seagreen: "rgb(46,139,87)",
3220 seashell: "rgb(255,245,238)",
3221 sienna: "rgb(160,82,45)",
3222 silver: "rgb(192,192,192)",
3223 skyblue: "rgb(135,206,235)",
3224 slateblue: "rgb(106,90,205)",
3225 slategray: "rgb(112,128,144)",
3226 slategrey: "rgb(112,128,144)",
3227 snow: "rgb(255,250,250)",
3228 springgreen: "rgb(0,255,127)",
3229 steelblue: "rgb(70,130,180)",
3230 tan: "rgb(210,180,140)",
3231 teal: "rgb(0,128,128)",
3232 thistle: "rgb(216,191,216)",
3233 tomato: "rgb(255,99,71)",
3234 turquoise: "rgb(64,224,208)",
3235 violet: "rgb(238,130,238)",
3236 wheat: "rgb(245,222,179)",
3237 white: "rgb(255,255,255)",
3238 whitesmoke: "rgb(245,245,245)",
3239 yellow: "rgb(255,255,0)",
3240 yellowgreen: "rgb(154,205,50)"
3242 }).apply(SVGColor.prototype);
3244 function SVGRect() {
3245 /*float*/ this.x = 0;
3246 // raises DOMException on setting
3247 /*float*/ this.y = 0;
3248 // raises DOMException on setting
3249 /*float*/ this.width = 0;
3250 // raises DOMException on setting
3251 /*float*/ this.height = 0;
3252 // raises DOMException on setting
3256 function SVGAnimatedRect() {
3257 /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
3263 /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN : 0,
3264 /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE : 1,
3265 /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
3267 function SVGStylable() {
3268 /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
3269 /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
3270 this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
3271 //styleのcssTextプロパティを解析するリスナーを登録しておく
3273 /*getPresentationAttributeメソッド
3274 *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
3276 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
3277 var s = this._attributeStyle.getPropertyCSSValue(name);
3285 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
3286 *SIEでは、もっぱらXLink言語の処理を行う
3288 function SVGURIReference() {
3289 /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
3290 this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
3292 this.addEventListener("DOMAttrModified", function(evt){
3293 if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
3294 evt.target.href.baseVal = evt.newValue;
3295 /*_svgload_limitedを+1とすることで、
3296 *SVGLoadイベントは発火されなくなる。1を引く必要がある
3298 evt.target.ownerDocument.documentElement._svgload_limited++;
3302 this.addEventListener("DOMNodeInserted", function(evt){
3303 var tar = evt.target;
3304 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3307 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3308 var tar = evt.target,
3310 href = tar.href.baseVal,
3311 show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
3312 /*xlink:href属性とxml:base属性を手がかりに、
3313 *ハイパーリンクのURIを決定する処理を行う
3315 if (href !== "") { //xlink:href属性が指定されたとき
3316 egbase = tar.xmlbase;
3318 ep = tar.parentNode;
3325 if (!b) { //xml:baseの指定がなければ
3326 if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
3328 base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
3330 base = location.href;
3336 if (href.indexOf(":") !== -1) { //絶対URIの場合
3340 show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
3341 if (href.indexOf(".") === 0) { //相対URIの場合
3344 if (show === "replace") {
3345 tar._tar.setAttribute("href", uri);
3346 } else if (show === "new") {
3347 tar._tar.setAttribute("target", "_blank");
3348 tar._tar.setAttribute("href", uri);
3349 } else if (show === "embed") {
3350 xmlhttp = NAIBU.xmlhttp;
3351 ui = uri.indexOf("#");
3353 id = uri.slice(ui+1);
3354 uri = uri.replace(/#.+$/, "");
3358 if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
3359 doc = tar.ownerDocument;
3360 ele = doc.getElementById(id);
3361 tar._instance = ele;
3362 ev = doc.createEvent("SVGEvents");
3363 ev.initEvent("S_Load", false, false);
3364 tar.dispatchEvent(ev);
3365 tar = xmlhttp = void 0;
3366 } else if (uri.indexOf("data:") > -1) {
3368 tar = xmlhttp = void 0;
3369 } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
3370 if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
3373 /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
3374 tar.ownerDocument.documentElement._svgload_limited++;
3375 xmlhttp.open("GET", uri, false);
3376 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3377 xmlhttp.onreadystatechange = function() {
3378 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
3379 var type = xmlhttp.getResponseHeader('Content-Type') || "text",
3381 if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
3382 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
3383 *ここでは、responseTextを用いる
3385 /*script要素とstyle要素は、
3386 *_textプロパティに読み込んだテキストを格納しておく
3387 *それら以外は、_instanceプロパティにDOMツリーを格納しておく
3389 if (tar.localName !== "script" && tar.localName !== "style") {
3390 doc = new ActiveXObject("MSXML2.DomDocument");
3391 str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
3392 NAIBU.doc.async = false;
3393 NAIBU.doc.validateOnParse = false;
3394 NAIBU.doc.resolveExternals = false;
3395 NAIBU.doc.preserveWhiteSpace = false;
3397 ele = doc.documentElement;
3398 tar._instance = tar.ownerDocument.importNode(ele, true);
3400 tar._instance = tar._instance.ownerDocument.getElementById(id);
3403 tar._text = xmlhttp.responseText;
3405 } else if (!!tar._tar) {
3408 /*S_LoadイベントとはSIE独自のイベント。
3409 *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
3411 ev = tar.ownerDocument.createEvent("SVGEvents");
3412 ev.initEvent("S_Load", false, false);
3413 tar.dispatchEvent(ev);
3414 tar.ownerDocument.documentElement._svgload_limited--;
3415 /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
3416 if (tar.ownerDocument.documentElement._svgload_limited < 0) {
3417 ev = tar.ownerDocument.createEvent("SVGEvents");
3418 ev.initEvent("SVGLoad", false, false);
3419 tar.ownerDocument.documentElement.dispatchEvent(ev);
3421 tar = type = doc = str = ev = void 0;
3422 /*IEのメモリリーク対策として、空関数を入力*/
3423 xmlhttp.onreadystatechange = NAIBU.emptyFunction;
3431 tar.ownerDocument.documentElement._svgload_limited--;
3433 evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
3439 function SVGCSSRule() {
3440 CSSRule.apply(this, arguments);
3441 // Additional CSS RuleType to support ICC color specifications
3442 /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
3445 SVGCSSRule.prototype = new CSSRule(); //ノードのプロトタイプチェーンを作って、継承
3450 function SVGDocument(){
3451 Document.apply(this);
3452 DocumentStyle.apply(this);
3453 /*readonly DOMString*/ this.title = "";
3454 /*readonly DOMString*/ this.referrer = document.referrer;
3455 /*readonly DOMString*/ this.domain = document.domain;
3456 /*readonly DOMString*/ this.URL = document.location;
3457 /*readonly SVGSVGElement*/ this.rootElement;
3460 SVGDocument.prototype = new Document(); //ノードのプロトタイプチェーンを作って、継承
3462 /*軽量化のために、頻繁に使われる処理をSVGDocumentの独自メソッドとしてまとめておく*/
3463 SVGDocument.prototype._domnodeEvent = function() {
3464 var evtt = this.createEvent("MutationEvents");
3465 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3472 function SVGSVGElement(_doc) {
3473 SVGElement.apply(this, arguments);
3474 _doc && (this._tar = _doc.createElement("v:group"));
3476 /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
3477 * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
3478 this._svgload_limited = 0;
3482 SVGExternalResourcesRequired,
3487 events::EventTarget,
3488 events::DocumentEvent,
3490 css::DocumentCSS {*/
3491 /*以下のx,y,width,heightプロパティは
3492 *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
3493 *1000というのは、W3Cで触れていないため、独自の初期値を採用
3495 var slen = SVGAnimatedLength;
3496 /*readonly SVGAnimatedLength*/ this.x = new slen();
3497 /*readonly SVGAnimatedLength*/ this.y = new slen();
3498 /*readonly SVGAnimatedLength*/ this.width = new slen();
3499 /*readonly SVGAnimatedLength*/ this.height = new slen();
3501 /*DOMString*/ this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
3502 /*DOMString*/ this.contentStyleType = "text/css";
3503 /*readonly SVGRect*/ this.viewport = this.createSVGRect();
3504 /*useCurrentViewプロパティ
3505 * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
3507 /*boolean*/ this.useCurrentView = false;
3509 * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
3511 /*readonly SVGViewSpec*/ this.currentView = new SVGViewSpec(this);
3512 /*もし、画像をズームやパンしたとき、どのような倍率になるかを
3513 *以下のプロパティを使って次の行列で示すことができる
3514 *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]
3516 /*float*/ this.currentScale = 1;
3517 /*readonly SVGPoint*/ this.currentTranslate = this.createSVGPoint();
3518 /*以下は、SVGFitToViewBoxのインターフェースを用いる
3519 *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
3521 /*readonly SVGAnimatedRect*/ this.viewBox = this.currentView.viewBox;
3522 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
3523 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
3526 /*int*/ this._currentTime = 0;
3527 /*DOMAttrModifiedイベントを利用して、
3528 *随時、属性の値をDOMプロパティに変換しておくリスナー登録
3530 this.addEventListener("DOMAttrModified", function(evt){
3531 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3534 var tar = evt.target,
3535 name = evt.attrName,
3536 tv, ovb, par, tp, sa, mos;
3537 if (name === "viewBox") {
3538 tar._cacheScreenCTM = null;
3539 tv = tar.viewBox.baseVal;
3540 ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3541 tv.x = parseFloat(ovb[0]);
3542 tv.y = parseFloat(ovb[1]);
3543 tv.width = parseFloat(ovb[2]);
3544 tv.height = parseFloat(ovb[3]);
3545 tar.viewBox.baseVal._isUsed = 1;
3546 } else if (name === "preserveAspectRatio") {
3547 tar._cacheScreenCTM = null;
3549 tp = tar.preserveAspectRatio.baseVal;
3551 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
3552 if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
3553 switch (RegExp.$1) {
3564 switch (RegExp.$2) {
3574 if (RegExp.$3 === "slice") {
3575 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
3577 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
3581 tp.meetOrSlice = mos;
3582 } else if (name === "width") {
3584 tar.viewport.width = tar.width.baseVal.value;
3585 } else if (name === "height") {
3586 tar.viewport.height = tar.height.baseVal.value;
3588 evt = name = tv = ovb = par = tp = sa = mos = void 0;
3590 this.addEventListener("SVGLoad", function(evt){
3591 /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
3592 *処理を書いたもの。属性が書き換わるたびに、再描画される
3594 evt.target.addEventListener("DOMAttrModified", function(evt){
3597 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3599 if (tar.parentNode) {
3600 evtt = tar.ownerDocument._domnodeEvent();
3602 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3603 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3604 for (var j=0,tcli=tce.length;j<tcli;++j){
3606 tce[j].handleEvent(evtt);
3609 if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
3610 tar._cacheMatrix = void 0; //キャッシュを消去
3611 if (tar.firstChild) {
3612 slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
3613 for (var i=0,sli=slist.length;i<sli;++i) {
3615 tar._cacheMatrix = void 0;
3616 evtt = tar.ownerDocument.createEvent("MutationEvents");
3617 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3619 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3620 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3621 for (var j=0,tcli=tce.length;j<tcli;++j){
3623 tce[j].handleEvent(evtt);
3631 evtt = tar = evt = tce = slist = void 0;
3633 evt.target.addEventListener("DOMNodeRemovedFromDocument", function(evt){
3634 var tar = evt.target;
3635 tar._tar && tar._tar.parentNode && tar._tar.parentNode.removeChild(tar._tar);
3642 SVGSVGElement.prototype = new SVGElement();
3643 /*void*/ SVGSVGElement.prototype.forceRedraw = function() {
3645 /*float*/ SVGSVGElement.prototype.getCurrentTime = function(){
3646 return (this._currentTime);
3648 /*void*/ SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
3649 this._currentTime = seconds;
3651 /*SVGNumber*/ SVGSVGElement.prototype.createSVGNumber = function(){
3652 var s = new SVGNumber();
3656 /*SVGAngle*/ SVGSVGElement.prototype.createSVGAngle = function(){
3657 var s = new SVGAngle();
3662 /*SVGLength*/ SVGSVGElement.prototype.createSVGLength = function(){
3663 var s = new SVGLength();
3664 s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
3667 /*SVGPoint*/ SVGSVGElement.prototype.createSVGPoint = function(){
3668 return new SVGPoint();
3670 /*SVGMatrix*/ SVGSVGElement.prototype.createSVGMatrix = function(){
3672 return new SVGMatrix();
3674 /*SVGRect*/ SVGSVGElement.prototype.createSVGRect = function(){
3675 return new SVGRect();
3677 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransform = function(){
3678 var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
3681 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
3682 var s = new SVGTransform();
3683 s.setMatrix(matrix);
3687 *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
3689 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
3690 if (!!this._cacheScreenCTM) { //キャッシュがあれば
3691 return (this._cacheScreenCTM);
3693 var vw = this.viewport.width,
3694 vh = this.viewport.height,
3695 vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
3696 if (!this.useCurrentView) {
3697 vB = this.viewBox.baseVal;
3698 par = this.preserveAspectRatio.baseVal;
3700 vB = this.currentView.viewBox.baseVal;
3701 par = this.currentView.preserveAspectRatio.baseVal;
3703 if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
3704 this._tx = this._ty = 0;
3705 m = this.createSVGMatrix();
3706 this._cacheScreenCTM = m; //キャッシュを作っておく
3719 if (par.align === 1) { //none
3725 var ax = (par.align + 1) % 3 + 1;
3726 var ay = Math.round(par.align / 3);
3727 switch (par.meetOrSlice) {
3729 xr = yr = Math.min(rw, rh);
3732 xr = yr = Math.max(rw, rh);
3741 tx += (vw - vbw * xr) / 2;
3744 tx += vw - vbw * xr;
3751 ty += (vh - vbh * yr) / 2;
3754 ty += vh - vbh * yr;
3759 //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
3762 ttps = this._tar.style;
3763 ttps.marginLeft = tx+ "px";
3764 ttps.marginTop = ty+ "px";
3765 m = this.createSVGMatrix();
3768 this._cacheScreenCTM = m; //キャッシュを作っておく
3769 vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
3773 /*interface SVGZoomAndPan*/
3774 // Zoom and Pan Types
3776 /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
3777 /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
3778 /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
3781 function SVGFitToViewBox() {
3782 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
3783 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3786 function SVGViewSpec(ele) {
3787 SVGFitToViewBox.apply(this, arguments);
3788 /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
3789 /*readonly SVGElement*/ this.viewTarget = ele;
3790 /*readonly DOMString*/ this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
3793 SVGViewSpec.prototype = new SVGFitToViewBox();
3795 function SVGGElement(_doc) {
3796 SVGElement.apply(this);
3797 this._tar = _doc.createElement("v:group");
3799 /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
3800 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
3802 this.addEventListener("DOMNodeInserted", function(evt){
3803 var tar = evt.target;
3804 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3807 var tnext = tar.nextSibling,
3808 tpart = tar.parentNode._tar,
3810 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3811 tpart.insertBefore(tar._tar, tnext._tar);
3812 } else if (tnext && !tnext._tar && tpart) {
3813 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3814 *use要素や実体参照などは_tarプロパティがないことに注意
3817 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3818 tpart.insertBefore(tar._tar, tnext._tar);
3821 tnext = tnext.nextSibling;
3824 tpart.appendChild(tar._tar);
3826 } else if (!tnext && tpart) {
3827 tpart.appendChild(tar._tar);
3829 tnext = tpart = isLast = evt = tar = void 0;
3833 SVGGElement.prototype = new SVGElement();
3835 function SVGDefsElement() {
3836 SVGElement.apply(this, arguments);
3837 this.style.setProperty("display", "none");
3840 SVGDefsElement.prototype = new SVGElement();
3842 function SVGDescElement() {
3843 SVGElement.apply(this, arguments);
3846 SVGDescElement.prototype = new SVGElement();
3848 function SVGTitleElement() {
3849 SVGElement.apply(this, arguments);
3850 this.addEventListener("DOMCharacterDataModified", function(evt){
3851 evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
3855 SVGTitleElement.prototype = new SVGElement();
3857 function SVGSymbolElement(_doc) {
3858 SVGElement.apply(this, arguments);
3861 SVGSymbolElement.prototype = new SVGElement();
3863 function SVGUseElement() {
3864 SVGGElement.apply(this, arguments);
3865 var slen = SVGAnimatedLength;
3866 /*readonly SVGAnimatedLength*/ this.x = new slen(); //use要素のx属性に対応(以下、同様)
3867 /*readonly SVGAnimatedLength*/ this.y = new slen();
3868 /*readonly SVGAnimatedLength*/ this.width = new slen();
3869 /*readonly SVGAnimatedLength*/ this.height = new slen();
3871 /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
3872 /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
3873 this.addEventListener("DOMNodeInserted", function(evt){
3874 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3877 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3879 this.addEventListener("S_Load", function(evt){
3880 var tar = evt.target,
3881 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3882 fontSize = parseFloat(style.getPropertyValue("font-size")),
3883 trans = tar.ownerDocument.documentElement.createSVGTransform(),
3884 tari = tar._instance,
3886 tar.x.baseVal._emToUnit(fontSize);
3887 tar.y.baseVal._emToUnit(fontSize);
3888 tar.width.baseVal._emToUnit(fontSize);
3889 tar.height.baseVal._emToUnit(fontSize);
3890 tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tari, true);
3891 trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
3892 tar.transform.baseVal.appendItem(trans);
3893 if (tar._instance.localName === "symbol") {
3894 /*symbol要素の場合、別途svg要素に置き換える*/
3895 svg = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "svg");
3896 svg.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3897 /*viewportをsymbol要素として新規に設定*/
3898 evt.target.nearestViewportElement = evt.currentTarget;
3900 tar._tar.appendChild(svg._tar);
3901 tn = tar.getScreenCTM();
3902 svg.setAttributeNS(null, "width", tar.width.baseVal.value);
3903 svg.setAttributeNS(null, "height", tar.height.baseVal.value);
3904 tari.hasAttributeNS(null, "viewBox") && svg.setAttributeNS(null, "viewBox", tari.getAttributeNS(null, "viewBox"));
3905 tari.hasAttributeNS(null, "preserveAspectRatio") && svg.setAttributeNS(null, "preserveAspectRatio", tari.getAttributeNS(null, "preserveAspectRatio"));
3906 svg._cacheScreenCTM = tn.multiply(svg.getScreenCTM());
3907 ti = tar.instanceRoot.firstChild;
3909 ta = ti.nextSibling;
3910 svg.appendChild(ti);
3911 ti.getScreenCTM && ti.getScreenCTM();
3914 tar.appendChild(svg);
3916 tar.appendChild(tar.instanceRoot);
3918 evt = trans = tar = evtt = style = fontSize = svg = ti = ta = tn = void 0;
3920 SVGURIReference.apply(this);
3923 SVGUseElement.prototype = new SVGElement();
3925 function SVGElementInstance() {
3929 Node.apply(this, arguments);
3930 /*readonly SVGElement*/ this.correspondingElement; //use要素で使われる参照先の要素
3931 /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
3932 /*readonly SVGElementInstance*/ this.parentNode;
3933 /*readonly SVGElementInstanceList*/ this.childNodes;
3934 /*readonly SVGElementInstance*/ this.firstChild;
3935 /*readonly SVGElementInstance*/ this.lastChild;
3936 /*readonly SVGElementInstance*/ this.previousSibling;
3937 /*readonly SVGElementInstance*/ this.nextSibling;
3940 SVGElementInstance.prototype = new Node();
3941 /*SVGElementInstanceList
3943 function SVGElementInstanceList() {
3944 /*readonly unsigned long*/ this.length = 0;
3947 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
3948 return (this[index]);
3950 function SVGImageElement(_doc) {
3951 SVGElement.apply(this, arguments);
3952 this._tar = _doc.createElement("v:image");
3953 //以下は、与えられた属性の値に対応する
3954 var slen = SVGAnimatedLength;
3955 /*readonly SVGAnimatedLength*/ this.x = new slen();
3956 /*readonly SVGAnimatedLength*/ this.y = new slen();
3957 /*readonly SVGAnimatedLength*/ this.width = new slen();
3958 /*readonly SVGAnimatedLength*/ this.height = new slen();
3959 _doc = slen = void 0;
3960 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3961 this.addEventListener("DOMNodeInserted", function(evt){
3962 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3965 var tar = evt.target;
3966 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3967 if (tar.nextSibling) {
3968 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
3969 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
3971 } else if (!!tar.parentNode._tar){
3972 tar.parentNode._tar.appendChild(tar._tar);
3974 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3975 var tar = evt.target,
3976 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3977 fontSize = parseFloat(style.getPropertyValue("font-size")),
3978 ts = tar._tar.style,
3979 ctm = tar.getScreenCTM(),
3980 po = tar.ownerDocument.documentElement.createSVGPoint(),
3981 fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
3983 tar.x.baseVal._emToUnit(fontSize);
3984 tar.y.baseVal._emToUnit(fontSize);
3985 tar.width.baseVal._emToUnit(fontSize);
3986 tar.height.baseVal._emToUnit(fontSize);
3987 ts.position = "absolute";
3988 po.x = tar.x.baseVal.value;
3989 po.y = tar.y.baseVal.value;
3990 po = po.matrixTransform(ctm);
3991 ts.left = po.x + "px";
3992 ts.top = po.y + "px";
3993 ts.width = tar.width.baseVal.value * ctm.a + "px";
3994 ts.height = tar.height.baseVal.value * ctm.d + "px";
3995 if (fillOpacity !== 1) {
3996 ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
3997 ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
3999 ttfia.Opacity = fillOpacity * 100;
4002 evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
4006 SVGURIReference.apply(this);
4009 SVGImageElement.prototype = new SVGElement();
4011 function SVGSwitchElement() {
4012 SVGElement.apply(this, arguments);
4015 SVGSwitchElement.prototype = new SVGElement();
4017 //bookmarkletから呼び出されたらtrue
4019 function GetSVGDocument(ele) {
4025 if ((NAIBU._that.xmlhttp.readyState === 4) && (NAIBU._that.xmlhttp.status === 200)) {
4029 GetSVGDocument.prototype = {
4031 *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
4033 _init : function() {
4034 /*objeiはobject要素かembed要素*/
4035 var xmlhttp = NAIBU.xmlhttp,
4038 if (this._tar.nodeName === "OBJECT") {
4043 xmlhttp.open("GET", objei.getAttribute(data), true);
4044 objei.style.display = "none";
4045 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
4046 this.xmlhttp = xmlhttp;
4047 /*クロージャを利用しないことで、軽量化を計る*/
4049 xmlhttp.onreadystatechange = _ca_;
4051 xmlhttp = objei = data = void 0;
4055 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
4056 *ここでは、responseTextを用いる
4058 var ifr = this._tar.previousSibling,
4059 ifcw = ifr.contentWindow,
4062 ifr.contentWindow.screen.updateInterval = 999;
4063 _doc = ifr.contentWindow.document;
4065 _doc.close(); // これがないと document.body は null になる
4066 } else { //インラインSVGの場合
4069 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
4070 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
4071 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
4072 var st = _doc.createStyleSheet(),
4073 vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
4074 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
4075 + "dn\\:defs{display:none}"
4076 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
4077 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
4078 st = vmlUrl = void 0;
4080 DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
4081 var str = this.xmlhttp.responseText,
4083 s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
4084 tar = s.documentElement,
4085 tview = tar.viewport,
4086 objw, objh, fi, n, attr, att, w, h,
4088 sp = _doc.createElement("div"),
4089 dcp = _doc.createElement("v:group"),
4090 backr = _doc.createElement("v:rect"),
4091 style, fontSize, sw, sh, trstyle, backrs, viewWidth, viewHeight, backdown, backright,
4093 _parseFloat = parseFloat,
4094 ndoc = NAIBU.doc || this.xmlhttp.responseXML,
4095 oba = _doc.createElement("div"); //obaはradialGradient要素で使う
4096 if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
4097 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4100 s._iframe = ifr; //_iframeプロパティはSVGAElementでリンク置換のときに扱う
4101 oba.setAttribute("id","_NAIBU_outline");
4102 _doc.body.appendChild(oba);
4103 sp.style.margin = "-1px,0px,0px,-1px"
4105 _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
4108 /*下記のプロパティについては、Microsoftのサイトを参照
4109 *ResolveExternals Property [Second-level DOM]
4110 * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
4111 *ValidateOnParse Property [Second-level DOM]
4112 * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
4114 ndoc.validateOnParse = false;
4115 ndoc.resolveExternals = false;
4116 ndoc.preserveWhiteSpace = true;
4117 ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
4118 /*IE6-8のみで使えるupdateIntervalは、
4119 *描画間隔の調整が可能。デフォルトは0。
4120 *スクロール時にバグが起きるので、0に戻してやる必要がある。
4122 screen.updateInterval = 999;
4123 if (/&[^;]+;/.test(str)) {
4125 *代替の処理を用いて、実体参照を処理するもの
4128 var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
4129 for (var i=0; i<enti.length; i++) {
4130 var map = enti.item(i);
4131 var regex = new RegExp("&"+map.nodeName+";", "g");
4132 tmp = tmp.replace(regex, map.firstChild.xml);
4139 tview.width = objei.clientWidth;
4140 tview.height = objei.clientHeight;
4141 if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4142 tview.height = screen.availHeight;
4144 if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4145 tar.viewport.height = screen.width;
4147 objw = objei.getAttribute("width");
4148 objh = objei.getAttribute("height");
4150 tar.setAttributeNS(null, "width", objw);
4153 tar.setAttributeNS(null, "height", objh);
4155 fi = ndoc.documentElement.firstChild;
4156 attr = ndoc.documentElement.attributes;
4157 /*ルート要素のNamedNodeMapを検索する*/
4158 for (var i=0,atli=attr.length;i<atli;++i) {
4159 att = s.importNode(attr[i], false);
4160 tar.setAttributeNodeNS(att);
4162 str = attr = void 0;
4163 dcp.style.width = tview.width+ "px";
4164 dcp.style.height = tview.height+ "px";
4165 dcp.coordsize = tview.width+ " " +tview.height;
4166 sp.appendChild(dcp);
4168 _doc.body.appendChild(sp);
4170 this._tar.parentNode.insertBefore(sp, this._tar);
4172 dcp.appendChild(sdt);
4173 while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
4174 n = s.importNode(fi, true);
4176 fi = fi.nextSibling;
4179 /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
4180 *ドキュメントにそのオブジェクトを結び付けておく
4183 /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
4186 style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
4187 fontSize = _parseFloat(style.getPropertyValue("font-size"));
4188 tar.x.baseVal._emToUnit(fontSize);
4189 tar.y.baseVal._emToUnit(fontSize);
4190 tar.width.baseVal._emToUnit(fontSize);
4191 tar.height.baseVal._emToUnit(fontSize);
4192 sw = tar.width.baseVal.value;
4193 sh = tar.height.baseVal.value;
4194 backr.style.position = "absolute";
4197 backr.style.width = w+ "px";
4198 backr.style.height = h+ "px";
4199 backr.style.zIndex = -1;
4200 backr.stroked = "false";
4201 backr.filled = "false";
4202 tar._tar.appendChild(backr);
4203 trstyle = tar._tar.style;
4204 trstyle.visibility = "visible";
4205 trstyle.position = "absolute";
4207 trstyle.overflow = "hidden";
4209 viewWidth = w > sw ? sw : w;
4210 viewHeight = h > sh ? sh : h;
4211 backrs = backr.currentStyle;
4212 bfl = _parseFloat(backrs.left);
4213 bft = _parseFloat(backrs.top);
4214 bl = -tar._tx; //blやbtは、ずれを調整するのに使う
4216 if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
4218 dcp.style.left = -bl+ "px";
4220 if (bft !== 0 && !isNaN(bfl)) {
4222 dcp.style.top = -bt+ "px";
4224 backright = bl + viewWidth + 1;
4225 backdown = bt + viewHeight + 1;
4226 trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
4228 if ("_svgload_limited" in s.documentElement) {
4229 /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
4230 *xlink:href属性が指定されるたびに+1となる。
4231 *0以外は、SVGLoadイベントが発火されない仕組みとなっている
4234 * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
4236 s.documentElement._svgload_limited--;
4237 if (s.documentElement._svgload_limited < 0) {
4238 var evt = s.createEvent("SVGEvents");
4239 evt.initEvent("SVGLoad", false, false);
4240 s.documentElement.dispatchEvent(evt);
4244 text = s.documentElement._tar.getElementsByTagName("div");
4245 for (var i=0, texti;text[i];++i) {
4247 if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
4248 var tis = texti.style;
4249 tis.left = _parseFloat(tis.left) + bl + "px";
4250 tis.top = _parseFloat(tis.top) + bt + "px";
4254 //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
4255 ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
4256 s._isLoaded = 1; //_isLoadedプロパティはevents::dispatchEventメソッドで使う
4257 s.defaultView._cache = s.defaultView._cache_ele = null;
4258 oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
4259 trstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
4260 /*IEのメモリリーク対策として、空関数を入力*/
4261 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4263 ifcw && (ifr.contentWindow.screen.updateInterval = 0);
4264 ifr = ifcw = s = void 0;
4268 if (s.implementation._buffer_) {
4269 screen.updateInterval = 0;
4270 /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
4271 NAIBU._buff_num = 0;
4272 NAIBU._buff = setInterval(function(){
4273 var n = NAIBU._buff_num,
4274 dbuf = DOMImplementation._buffer_,
4275 dbufli = dbuf ? dbuf.length : 0, //極端な負荷がかかると、dbufはnullになる可能性あり
4278 clearInterval(NAIBU._buff);
4280 for (var i=0;i<50;++i) {
4283 s.dispatchEvent(evt);
4287 clearInterval(NAIBU._buff);
4288 DOMImplementation._buffer_ = null;
4290 dbuf = n = dbufli = void 0;
4294 NAIBU._buff_num = n;
4296 dbuf = n = dbufli = void 0;
4298 ifr = ifcw = s = void 0;
4300 ifr = ifcw = s = void 0;
4306 /*SVGDocument*/ getSVGDocument : function() {
4307 return (this._document);
4310 /*空関数(IEのメモリリーク対策)*/
4311 NAIBU.emptyFunction = function() {};
4316 function SVGStyleElement(_doc) {
4317 SVGElement.apply(this);
4318 LinkStyle.apply(this);
4319 /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
4320 *CSS2 1. Document Object Model Style Sheets
4321 * 1.3. Document Extensions
4322 * Interface LinkStyle (introduced in DOM Level 2)
4323 * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
4325 /*以下はそれぞれ、属性の値に対応している*/
4326 /*DOMString*/ this.xmlspace;
4327 /*DOMString*/ this.type = "text/css";
4328 /*DOMString*/ this.media;
4329 /*DOMString*/ this.title;
4330 SVGURIReference.apply(this);
4331 this.addEventListener("DOMAttrModified", function(evt){
4332 if (evt.attrName === "type") {
4333 evt.target.type = evt.newValue;
4334 } else if (evt.attrName === "title") {
4335 evt.target.title = evt.newValue;
4339 this.addEventListener("S_Load", function(evt){
4340 var tar = evt.target,
4342 styleText = tar._text,
4343 tod = tar.ownerDocument,
4344 style = _doc.createElement("style"),
4346 NAIBU._temp_doc = tod;
4347 sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
4348 sheet.ownerNode = tar;
4349 /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
4350 _doc.documentElement.firstChild.appendChild(style);
4351 style.styleSheet.cssText = styleText;
4352 for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
4354 scri = new CSSStyleRule();
4355 scri.selectorText = ri.selectorText;
4356 scri.style.cssText = ri.style.cssText;
4357 rsc = scri.style.cssText.split(";");
4358 for (var j=0, rsli=rsc.length;j<rsli;++j) {
4359 rsi = rsc[j].split(": ");
4360 scri.style.setProperty(rsi[0], rsi[1]);
4362 sheet.cssRules[sheet.cssRules.length] = scri;
4364 tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4365 var tar = evt.target,
4366 doc = tar.ownerDocument,
4367 rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
4368 selector, ru, tcb = tar.className.baseVal || ".,.";
4369 for (var i=0, rli=rules.length;i<rli;++i) {
4370 selector = rules[i].selectorText;
4371 /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
4372 ru = tar._rules || [];
4373 if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
4374 || (tar.nodeName === selector)) {
4375 ru[ru.length] = rules[i];
4379 tar = doc = rules = void 0;
4381 tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
4383 this.addEventListener("DOMNodeInserted", function(evt){
4384 var tar = evt.target;
4385 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4386 if (tar.nodeName === "#cdata-section") {
4387 evt.currentTarget._text = tar.data;
4391 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4392 var tar = evt.target;
4393 if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
4394 var evtt = tar.ownerDocument.createEvent("SVGEvents");
4395 evtt.initEvent("S_Load", false, false);
4396 evt.currentTarget.dispatchEvent(evtt);
4403 SVGStyleElement.prototype = new SVGElement();
4406 *2次元座標の点(x,y)を表すオブジェクト
4408 function SVGPoint() {
4411 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
4412 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
4413 if (!isFinite(matrix.a) || !isFinite(matrix.b) || !isFinite(matrix.c) || !isFinite(matrix.d) || !isFinite(matrix.e) || !isFinite(matrix.f)) {
4414 throw (new Error("Type Error: 引数の値がNumber型ではありません"));
4416 var s = new SVGPoint();
4417 s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
4418 s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
4422 function SVGPointList() {
4425 /*SVGPointListのメソッドはSVGPathSegListを参照*/
4428 *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
4433 function SVGMatrix() {
4436 SVGMatrix.prototype = {
4446 /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
4447 var s = new SVGMatrix(),
4451 if (!isf(m.a) || !isf(m.b) || !isf(m.c) || !isf(m.d) || !isf(m.e) || !isf(m.f)) {
4452 throw (new Error("Type Error: 引数の値がNumber型ではありません"));
4454 s.a = t.a * m.a + t.c * m.b;
4455 s.b = t.b * m.a + t.d * m.b;
4456 s.c = t.a * m.c + t.c * m.d;
4457 s.d = t.b * m.c + t.d * m.d;
4458 s.e = t.a * m.e + t.c * m.f + t.e;
4459 s.f = t.b * m.e + t.d * m.f + t.f;
4460 m = t = secondMatrix = isf = void 0;
4466 /*SVGMatrix*/ inverse : function() {
4467 var s = new SVGMatrix(), n = this._determinant();
4473 s.e = (this.c * this.f - this.d * this.e) / n;
4474 s.f = (this.b * this.e - this.a * this.f) / n;
4477 throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
4480 /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
4481 var m = new SVGMatrix();
4484 var s = this.multiply(m);
4488 /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
4489 var m = new SVGMatrix();
4492 var s = this.multiply(m);
4496 /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
4497 var m = new SVGMatrix();
4500 var s = this.multiply(m);
4504 /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
4505 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4506 m.a = Math.cos(rad);
4507 m.b = Math.sin(rad);
4510 var s = this.multiply(m);
4514 //座標(x, y)と原点の角度の分だけ、回転する
4515 /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
4516 if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
4517 throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
4519 var m = new SVGMatrix(), rad = Math.atan2(y, x);
4520 m.a = Math.cos(rad);
4521 m.b = Math.sin(rad);
4524 var s = this.multiply(m);
4528 /*SVGMatrix*/ flipX : function() {
4529 var m = new SVGMatrix();
4531 var s = this.multiply(m);
4535 /*SVGMatrix*/ flipY : function() {
4536 var m = new SVGMatrix();
4538 var s = this.multiply(m);
4542 /*SVGMatrix*/ skewX : function(/*float*/ angle ){
4543 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4544 m.c = Math.tan(rad);
4545 var s = this.multiply(m);
4549 /*SVGMatrix*/ skewY : function(/*float*/ angle ){
4550 var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
4551 m.b = Math.tan(rad);
4552 var s = this.multiply(m);
4557 /*float*/ _determinant : function() {
4558 return (this.a * this.d - this.b * this.c);
4562 function SVGTransform() {
4563 /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
4567 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN = 0;
4568 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX = 1;
4569 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
4570 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE = 3;
4571 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE = 4;
4572 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX = 5;
4573 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY = 6;
4574 SVGTransform.prototype = {
4575 /*ダミーの単位行列。各メソッドで使う*/
4576 _matrix : (new SVGMatrix()),
4577 /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
4578 /*readonly float*/ angle : 0,
4579 /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
4580 this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
4581 this.matrix = this._matrix.multiply(matrix);
4583 /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
4584 this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
4585 this.matrix = this._matrix.translate(tx, ty);
4587 /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
4588 this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
4589 this.matrix = this._matrix.scaleNonUniform(sx, sy);
4591 /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
4593 this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
4594 this.matrix = this._matrix.rotate(angle);
4595 this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
4596 this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
4598 /*void*/ setSkewX : function(/*float*/ angle ) {
4600 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
4601 this.matrix = this._matrix.skewX(angle);
4603 /*void*/ setSkewY : function(/*float*/ angle ) {
4605 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
4606 this.matrix = this._matrix.skewY(angle);
4610 function SVGTransformList() {
4613 /*SVGTransformListのメソッドはSVGPathSegListを参照*/
4615 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
4616 var t = new SVGTransform();
4617 t.setMatrix(matrix);
4620 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
4621 if(this.numberOfItems === 0) {
4624 var s = this.getItem(0), m = s.matrix;
4625 for (var i=1,nli=this.numberOfItems;i<nli;++i) {
4626 m = m.multiply(this.getItem(i).matrix);
4634 function SVGAnimatedTransformList() {
4635 /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
4638 function SVGPreserveAspectRatio() {
4639 /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
4640 /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
4645 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
4646 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE = 1;
4647 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
4648 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
4649 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
4650 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
4651 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
4652 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
4653 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
4654 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
4655 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
4656 // Meet-or-slice Types
4657 /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN = 0;
4658 /*unsigned short*/ t.SVG_MEETORSLICE_MEET = 1;
4659 /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
4660 })(SVGPreserveAspectRatio);
4662 function SVGAnimatedPreserveAspectRatio() {
4663 /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
4667 function SVGPathSeg() {
4668 /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
4669 /*readonly DOMString*/ this.pathSegTypeAsLetter = null;
4674 // Path Segment Types
4675 /*unsigned short*/ t.PATHSEG_UNKNOWN = 0;
4676 /*unsigned short*/ t.PATHSEG_CLOSEPATH = 1;
4677 /*unsigned short*/ t.PATHSEG_MOVETO_ABS = 2;
4678 /*unsigned short*/ t.PATHSEG_MOVETO_REL = 3;
4679 /*unsigned short*/ t.PATHSEG_LINETO_ABS = 4;
4680 /*unsigned short*/ t.PATHSEG_LINETO_REL = 5;
4681 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS = 6;
4682 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL = 7;
4683 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS = 8;
4684 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL = 9;
4685 /*unsigned short*/ t.PATHSEG_ARC_ABS = 10;
4686 /*unsigned short*/ t.PATHSEG_ARC_REL = 11;
4687 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS = 12;
4688 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL = 13;
4689 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS = 14;
4690 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL = 15;
4691 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;
4692 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;
4693 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
4694 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
4697 *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
4699 function SVGPathSegClosePath() {
4702 SVGPathSegClosePath.prototype = {
4703 pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
4704 pathSegTypeAsLetter : "z"
4706 function SVGPathSegMovetoAbs() {
4711 SVGPathSegMovetoAbs.prototype = {
4712 pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
4713 pathSegTypeAsLetter : "M"
4715 function SVGPathSegMovetoRel() {
4720 SVGPathSegMovetoRel.prototype = {
4721 pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
4722 pathSegTypeAsLetter : "m"
4724 function SVGPathSegLinetoAbs() {
4729 SVGPathSegLinetoAbs.prototype = {
4730 pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
4731 pathSegTypeAsLetter : "L"
4733 function SVGPathSegLinetoRel() {
4738 SVGPathSegLinetoRel.prototype = {
4739 pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
4740 pathSegTypeAsLetter : "l"
4742 function SVGPathSegCurvetoCubicAbs() {
4751 SVGPathSegCurvetoCubicAbs.prototype = {
4752 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
4753 pathSegTypeAsLetter : "C"
4755 function SVGPathSegCurvetoCubicRel() {
4764 SVGPathSegCurvetoCubicRel.prototype = {
4765 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
4766 pathSegTypeAsLetter : "c"
4768 function SVGPathSegCurvetoQuadraticAbs() {
4773 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
4774 this.pathSegTypeAsLetter = "Q";
4777 function SVGPathSegCurvetoQuadraticRel() {
4782 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
4783 this.pathSegTypeAsLetter = "q";
4787 function SVGPathSegArcAbs() {
4792 /*float*/ this.angle;
4795 SVGPathSegArcAbs.prototype = {
4796 /*boolean*/ largeArcFlag : true,
4797 /*boolean*/ sweepFlag : true,
4798 pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
4799 pathSegTypeAsLetter : "A"
4801 function SVGPathSegArcRel() {
4806 /*float*/ this.angle;
4809 SVGPathSegArcRel.prototype = {
4810 /*boolean*/ largeArcFlag : true,
4811 /*boolean*/ sweepFlag : true,
4812 pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
4813 pathSegTypeAsLetter : "a"
4815 function SVGPathSegLinetoHorizontalAbs() {
4817 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
4818 this.pathSegTypeAsLetter = "H";
4821 function SVGPathSegLinetoHorizontalRel() {
4823 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
4824 this.pathSegTypeAsLetter = "h";
4827 function SVGPathSegLinetoVerticalAbs() {
4829 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
4830 this.pathSegTypeAsLetter = "V";
4833 function SVGPathSegLinetoVerticalRel() {
4835 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
4836 this.pathSegTypeAsLetter = "v";
4839 function SVGPathSegCurvetoCubicSmoothAbs() {
4844 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
4845 this.pathSegTypeAsLetter = "S";
4848 function SVGPathSegCurvetoCubicSmoothRel() {
4853 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
4854 this.pathSegTypeAsLetter = "s";
4857 function SVGPathSegCurvetoQuadraticSmoothAbs() {
4860 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
4861 this.pathSegTypeAsLetter = "T";
4864 function SVGPathSegCurvetoQuadraticSmoothRel() {
4867 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
4868 this.pathSegTypeAsLetter = "t";
4871 function SVGPathSegList() {
4874 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4875 SVGNumberList.prototype[prop] = SVGLengthList.prototype[prop] = SVGPointList.prototype[prop] = SVGTransformList.prototype[prop] = SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
4879 /*documentは引数の変数として登録しておく*/
4880 (function(_doc, _math) {
4881 //freeArg関数はunloadで使う解放処理
4882 NAIBU.freeArg = function() {
4883 SVGPathElement = _doc = _math = void 0;
4885 //仮のfill属性とstroke属性の処理
4886 NAIBU._setPaint = function(tar, matrix) {
4887 /*以下では、スタイルシートを用いて、fill-とstroke-関連の
4888 *処理を行う。SVGPaintインターフェースをも用いる
4890 var tod = tar.ownerDocument,
4891 _doc = tod._document_,
4893 style = tod.defaultView.getComputedStyle(tar, ""),
4894 fill = style.getPropertyCSSValue("fill"),
4895 stroke = style.getPropertyCSSValue("stroke"),
4896 fp = fill.paintType,
4897 sp = stroke.paintType,
4899 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
4900 t, evtt, fillOpacity, strs, cursor, vis, disp,
4901 strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
4905 /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
4906 while (el.firstChild) {
4907 el.removeChild(el.firstChild);
4909 if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4910 if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4911 /*再度、設定。css.jsのsetPropertyを参照*/
4912 style.setProperty("color", style.getPropertyValue("color"));
4914 fillElement = _doc.createElement("v:fill");
4916 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
4917 fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4918 fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
4919 if (fillOpacity < 1) {
4920 fillElement.setAttribute("opacity", fillOpacity+"");
4922 el.appendChild(fillElement);
4923 fillElement = fc = fillOpacity = void 0;
4924 } else if (fill.uri) {
4925 /*以下では、Gradation関連の要素に、イベントを渡すことで、
4928 t = tod.getElementById(fill.uri);
4930 evtt = tod._domnodeEvent();
4931 evtt._tar = _doc.createElement("v:fill");
4932 evtt._style = style;
4934 t.dispatchEvent(evtt);
4935 if (t.localName !== "radialGradient") {
4936 el.appendChild(evtt._tar);
4941 el.filled = "false";
4943 if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4944 if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4945 /*再度、設定。css.jsのsetPropertyを参照*/
4946 style.setProperty("color", style.getPropertyValue("color"));
4948 strokeElement = _doc.createElement("v:stroke");
4949 sgsw = style.getPropertyCSSValue("stroke-width");
4950 w = tod.documentElement.viewport.width;
4951 h = tod.documentElement.viewport.height;
4952 sgsw._percent = _math.sqrt((w*w + h*h) / 2);
4953 swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
4954 strokeElement.setAttribute("weight", swx + "px");
4955 sgsw = w = h = void 0;
4957 fc = stroke.rgbColor;
4958 strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4959 strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
4961 strokeOpacity *= swx; //太さが1px未満なら色を薄くする
4963 if (strokeOpacity < 1) {
4964 strokeElement.setAttribute("opacity", strokeOpacity+"");
4966 fc = strokeOpacity = void 0;
4968 strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
4969 strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
4970 if (style.getPropertyValue("stroke-linecap") === "butt") {
4971 strokeElement.setAttribute("endcap", "flat");
4973 strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
4975 tsd = style.getPropertyValue("stroke-dasharray");
4976 if (tsd !== "none") {
4977 if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
4978 strs = tsd.split(",");
4979 for (var i = 0, sli = strs.length; i < sli; ++i) {
4980 strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
4982 strokedasharray = strs.join(" ");
4983 if (strs.length % 2 === 1) {
4984 strokedasharray += " " + strokedasharray;
4987 strokeElement.setAttribute("dashstyle", strokedasharray);
4988 tsd = strs = void 0;
4990 el.appendChild(strokeElement);
4991 strokeElement = tsd = void 0;
4993 el.stroked = "false";
4995 cursor = style.getPropertyCSSValue("cursor");
4996 if (cursor && !cursor._isDefault) { //初期値でないならば
4997 el.style.cursor = cursor.cssText.split(":")[1];
4999 vis = style.getPropertyCSSValue("visibility");
5000 if (vis && !vis._isDefault) {
5001 el.style.visibility = vis.cssText.split(":")[1];
5003 disp = style.getPropertyCSSValue("display");
5004 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
5005 el.style.display = "none";
5006 } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
5007 el.style.display = "inline-block";
5009 tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
5012 function SVGPathElement(_doc) {
5013 SVGElement.apply(this);
5014 this._tar = _doc.createElement("v:shape");
5015 //interface SVGAnimatedPathData
5016 var sp = SVGPathSegList;
5017 /*readonly SVGPathSegList*/ this.pathSegList = new sp();
5018 this.animatedPathSegList = this.pathSegList;
5019 /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
5021 this.animatedNormalizedPathSegList = this.normalizedPathSegList;
5022 /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
5023 //以下は、d属性に変更があった場合の処理
5024 this.addEventListener("DOMAttrModified", this._attrModi, false);
5025 /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
5026 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
5028 this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
5031 SVGPathElement.prototype = new SVGElement();
5032 (function(_sproto) {
5033 _sproto._attrModi = function(evt){
5034 var tar = evt.target;
5035 if (evt.attrName === "d" && evt.newValue !== ""){
5036 /* d属性の値が空の場合は、描画を行わないようにする
5038 *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
5040 var tnl = tar.normalizedPathSegList,
5041 tlist = tar.pathSegList;
5042 if (tnl.numberOfItems > 0) {
5046 /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
5048 *D = [["M", 20, 30], ["L", 20 40]]
5050 var taco = tar._com,
5053 .replace(taco.isRa, " -")
5054 .replace(taco.isRb, " ")
5055 .replace(taco.isRc, ",$1 ")
5056 .replace(taco.isRd, ",$1 1")
5057 .replace(taco.isRe, "")
5064 tcc = tar.createSVGPathSegCurvetoCubicAbs,
5065 tcll = tar.createSVGPathSegLinetoAbs;
5066 for (var i=0;i<dli;++i) {
5067 var di = dd[i].match(sgs),
5069 for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
5071 s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5073 } else if (isL[dii]) {
5074 s = tcll(+di[j], +di[j+1]);
5076 } else if (isM[dii]) {
5077 s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
5079 } else if (isZ[dii]) {
5080 s = tar.createSVGPathSegClosePath();
5081 } else if (dii === "A") {
5082 s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5084 } else if (dii === "m") {
5085 s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
5087 } else if (dii === "l") {
5088 s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
5090 } else if (dii === "c") {
5091 s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5093 } else if (dii === "Q") {
5094 s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5096 } else if (dii === "q") {
5097 s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5099 } else if (dii === "a") {
5100 s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5102 } else if (dii === "S") {
5103 s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5105 } else if (dii === "s") {
5106 s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5108 } else if (dii === "T") {
5109 s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
5111 } else if (dii === "t") {
5112 s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
5114 } else if (dii === "H") {
5115 s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
5116 } else if (dii === "h") {
5117 s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
5118 } else if (dii === "V") {
5119 s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
5120 } else if (dii === "v") {
5121 s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
5123 s = new SVGPathSeg();
5125 tlist.appendItem(s);
5128 di = s = sgs = dd = void 0;
5129 /*以下の処理は、pathSegListからnormalizedPathSegListへの
5130 *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
5132 var cx = 0, cy = 0, //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
5133 xn = 0, yn = 0, //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
5134 startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
5135 for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
5136 var ti = tlist.getItem(j),
5137 ts = ti.pathSegType,
5138 dii = ti.pathSegTypeAsLetter;
5139 if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
5141 var rx = cx, ry = cy; //rx, ryは前のセグメントの終了点
5142 if (ts % 2 === 1) { //相対座標ならば
5151 } else if (isL[dii]) {
5153 } else if (isM[dii]) {
5155 /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
5156 *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
5157 *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
5159 var tg = tlist.getItem(j-1);
5160 if (tg.pathSegTypeAsLetter === "M") {
5161 tnl.appendItem(tcll(cx, cy));
5168 } else if (dii === "m") {
5170 var tg = tlist.getItem(j-1);
5171 if (tg.pathSegTypeAsLetter === "m") {
5172 tnl.appendItem(tcll(cx, cy));
5178 tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
5179 } else if (dii === "l") {
5180 tnl.appendItem(tcll(cx, cy));
5181 } else if (dii === "c") {
5182 tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
5183 } else if (isZ[dii]) {
5187 } else if (dii === "Q") {
5190 //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
5191 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));
5192 } else if (dii === "q") {
5193 var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
5196 tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
5198 } else if (dii === "A" || dii === "a") {
5199 (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
5200 /*以下は、Arctoを複数のCuvetoに変換する処理
5201 *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
5202 *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
5204 if (ti.r1 === 0 || ti.r2 === 0) {
5207 var fS = ti.sweepFlag,
5209 r1 = _math.abs(ti.r1),
5210 r2 = _math.abs(ti.r2),
5211 ctx = (rx - cx) / 2, cty = (ry - cy) / 2,
5212 cpsi = _math.cos(psai * _math.PI / 180),
5213 spsi = _math.sin(psai * _math.PI / 180),
5214 rxd = cpsi*ctx + spsi*cty,
5215 ryd = -1*spsi*ctx + cpsi*cty,
5216 rxdd = rxd * rxd, rydd = ryd * ryd,
5219 lamda = rxdd/r1x + rydd/r2y,
5222 r1 = _math.sqrt(lamda) * r1;
5223 r2 = _math.sqrt(lamda) * r2;
5227 if (ti.largeArcFlag === fS) {
5230 sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
5232 var txd = sds*r1*ryd / r2,
5233 tyd = -1 * sds*r2*rxd / r1,
5234 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
5235 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
5236 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
5237 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
5238 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
5239 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
5240 if (!fS && dr > 0) {
5242 } else if (fS && dr < 0) {
5245 var sse = dr * 2 / _math.PI,
5246 seg = _math.ceil(sse<0 ? -1*sse : sse),
5248 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
5249 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
5250 spsir1 = spsi * r1, spsir2 = spsi * r2,
5253 x2 = rx - t * (cpsir1*ms + spsir2*mc),
5254 y2 = ry - t * (spsir1*ms - cpsir2*mc);
5255 for (var n = 0; n < seg; ++n) {
5259 var x3 = cpsir1*mc - spsir2*ms + tx,
5260 y3 = spsir1*mc + cpsir2*ms + ty,
5261 dx = -t * (cpsir1*ms + spsir2*mc),
5262 dy = -t * (spsir1*ms - cpsir2*mc);
5263 tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
5267 ti= cx= cy= rx= ry= tar= tnl = void 0;
5268 })(ti, cx, cy, rx, ry, tar, tnl);
5269 } else if (dii === "S") {
5271 var tg = tnl.getItem(tnl.numberOfItems-1);
5272 if (tg.pathSegTypeAsLetter === "C") {
5273 var x1 = 2*tg.x - tg.x2,
5274 y1 = 2*tg.y - tg.y2;
5275 } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
5283 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
5285 } else if (dii === "s") {
5287 var tg = tnl.getItem(tnl.numberOfItems-1);
5288 if (tg.pathSegTypeAsLetter === "C") {
5289 var x1 = 2*tg.x - tg.x2,
5290 y1 = 2*tg.y - tg.y2;
5299 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
5301 } else if (dii === "T" || dii === "t") {
5303 var tg = tlist.getItem(j-1);
5304 if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
5311 tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
5315 } else if (dii === "H" || dii === "h") {
5316 tnl.appendItem(tcll(cx, ry));
5317 cy = ry; //勝手にti.yが0としているため
5318 } else if (dii === "V" || dii === "v") {
5319 tnl.appendItem(tcll(rx, cy));
5325 evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
5327 _sproto._nodeInsert = function(evt){
5328 var tar = evt.target;
5329 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5332 var tnext = tar.nextSibling,
5333 tpart = tar.parentNode._tar,
5335 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5336 tpart.insertBefore(tar._tar, tnext._tar);
5337 } else if (tnext && !tnext._tar && tpart) {
5338 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5339 *use要素や実体参照などは_tarプロパティがないことに注意
5342 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5343 tpart.insertBefore(tar._tar, tnext._tar);
5346 tnext = tnext.nextSibling;
5349 tpart.appendChild(tar._tar);
5351 } else if (!tnext && tpart) {
5352 tpart.appendChild(tar._tar);
5354 tnext = tpart = isLast = void 0;
5355 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
5358 _sproto._nodeInsertInto = function(evt){
5359 /*以下の処理は、normalizedpathSegListとCTMに基づいて、
5360 *SVGのd属性をVMLに変換していく処理である。
5362 var tar = evt.target,
5363 matrix = tar.getScreenCTM(),
5364 tlist = tar.normalizedPathSegList,
5366 ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
5367 cname = tar._com._nameCom,
5368 isZ = tar._com._isZ, isC = tar._com._isC,
5370 for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
5374 tps = ti.pathSegTypeAsLetter,
5377 /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
5382 t += [mr(ma*ti.x1 + mc*ti.y1 + me),
5383 mr(mb*ti.x1 + md*ti.y1 + mf),
5384 mr(ma*ti.x2 + mc*ti.y2 + me),
5385 mr(mb*ti.x2 + md*ti.y2 + mf),
5386 mr(ma*tx + mc*ty + me),
5387 mr(mb*tx + md*ty + mf)].join(" ");
5388 } else if (!isZ[tps]) {
5389 t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
5393 var vi = tar.ownerDocument.documentElement,
5396 tt.path = dat.join(" ");
5397 tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
5398 NAIBU._setPaint(tar, matrix);
5399 delete tar._cacheMatrix;
5400 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;
5425 isRc : /([a-yA-Y])/g,
5430 /*float*/ _sproto.getTotalLength = function() {
5432 nl = this.normalizedPathSegList;
5433 for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5434 var seg = nl.getItem(i);
5435 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5436 var ps = nl.getItem(i-1);
5437 s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5438 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5439 var ps = nl.getItem(i-1), dd = 0;
5440 /*2点のハンドルを結んだ線分の3辺と、
5441 *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
5444 *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
5445 *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
5447 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5448 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5449 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5450 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5452 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5453 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5454 s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5458 this.pathLength.baseVal = s;
5461 /*SVGPoint*/ _sproto.getPointAtLength = function(/*float*/ distance ) {
5462 var segn = this.getPathSegAtLength(distance),
5465 nl = this.normalizedPathSegList,
5466 seg = nl.getItem(segn),
5467 s = this.ownerDocument.documentElement.createSVGPoint();
5468 if ((segn-1) <= 0) {
5473 var ps = nl.getItem(segn-1);
5474 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5475 var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5476 var t = (segl + this._dis) / segl;
5477 s.x = ps.x + t * (seg.x-ps.x);
5478 s.y = ps.y + t * (seg.y-ps.y);
5479 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5481 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5482 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5483 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5484 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5486 var t = (segl + this._dis) / segl;
5487 /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
5490 s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
5491 +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
5492 +3*(seg.x1 - ps.x) * t
5494 s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
5495 +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
5496 +3*(seg.y1 - ps.y) * t
5498 } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
5501 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5502 var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
5503 var t = (segl + this._dis) / segl;
5504 s.x = ms.x + t * (seg.x-ms.x);
5505 s.y = ms.y + t * (seg.y-ms.y);
5509 /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
5510 var nl = this.normalizedPathSegList; //仕様ではpathSegList
5511 for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5512 var seg = nl.getItem(i);
5513 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5514 var ps = nl.getItem(i-1);
5515 distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5516 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5517 var ps = nl.getItem(i-1), dd = 0;
5518 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5519 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5520 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5521 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5524 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5525 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5526 distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5528 if (distance <= 0) {
5529 /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
5530 this._dis = distance;
5535 /*もし、distanceがパスの距離よりも長い場合、
5537 *なお、これはSVG1.1の仕様の想定外のこと
5539 return (nl.numberOfItems - 1);
5541 /*SVGPathSegClosePath*/ _sproto.createSVGPathSegClosePath = function() {
5542 var _SVGPathSegClosePath = SVGPathSegClosePath;
5543 return (new _SVGPathSegClosePath());
5545 /*SVGPathSegMovetoAbs*/ _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
5546 var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
5551 /*SVGPathSegMovetoRel*/ _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
5552 var s = new SVGPathSegMovetoRel();
5557 /*SVGPathSegLinetoAbs*/ _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
5558 var s = new SVGPathSegLinetoAbs();
5563 /*SVGPathSegLinetoRel*/ _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
5564 var s = new SVGPathSegLinetoRel();
5569 /*SVGPathSegCurvetoCubicAbs*/ _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5570 var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
5579 /*SVGPathSegCurvetoCubicRel*/ _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5580 var s = new SVGPathSegCurvetoCubicRel();
5589 /*SVGPathSegCurvetoQuadraticAbs*/ _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5590 var s = new SVGPathSegCurvetoQuadraticAbs();
5597 /*SVGPathSegCurvetoQuadraticRel*/ _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5598 var s = new SVGPathSegCurvetoQuadraticRel();
5605 /*SVGPathSegArcAbs*/ _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5606 var s = new SVGPathSegArcAbs();
5612 s.largeArcFlag = largeArcFlag;
5613 s.sweepFlag = sweepFlag;
5616 /*SVGPathSegArcRel*/ _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5617 var s = new SVGPathSegArcRel();
5623 s.largeArcFlag = largeArcFlag;
5624 s.sweepFlag = sweepFlag;
5627 /*SVGPathSegLinetoHorizontalAbs*/ _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
5628 var s = new SVGPathSegLinetoHorizontalAbs();
5630 s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
5633 /*SVGPathSegLinetoHorizontalRel*/ _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
5634 var s = new SVGPathSegLinetoHorizontalRel();
5639 /*SVGPathSegLinetoVerticalAbs*/ _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
5640 var s = new SVGPathSegLinetoVerticalAbs();
5645 /*SVGPathSegLinetoVerticalRel*/ _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
5646 var s = new SVGPathSegLinetoVerticalRel();
5651 /*SVGPathSegCurvetoCubicSmoothAbs*/ _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5652 var s = new SVGPathSegCurvetoCubicSmoothAbs();
5659 /*SVGPathSegCurvetoCubicSmoothRel*/ _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5660 var s = new SVGPathSegCurvetoCubicSmoothRel();
5667 /*SVGPathSegCurvetoQuadraticSmoothAbs*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
5668 var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
5673 /*SVGPathSegCurvetoQuadraticSmoothRel*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
5674 var s = new SVGPathSegCurvetoQuadraticSmoothRel();
5679 })(SVGPathElement.prototype)
5680 NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
5683 function SVGRectElement(_doc) {
5684 SVGElement.apply(this);
5685 this._tar = _doc.createElement("v:shape");
5686 var slen = SVGAnimatedLength;
5687 /*readonly SVGAnimatedLength*/ this.x = new slen();
5688 /*readonly SVGAnimatedLength*/ this.y = new slen();
5689 /*readonly SVGAnimatedLength*/ this.width = new slen();
5690 /*readonly SVGAnimatedLength*/ this.height = new slen();
5691 /*readonly SVGAnimatedLength*/ this.rx = new slen();
5692 /*readonly SVGAnimatedLength*/ this.ry = new slen();
5693 _doc = slen = void 0;
5694 this.addEventListener("DOMNodeInserted", function(evt){
5695 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5698 var tar = evt.target,
5699 tnext = tar.nextSibling,
5700 tpart = tar.parentNode._tar,
5702 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5703 tpart.insertBefore(tar._tar, tnext._tar);
5704 } else if (tnext && !tnext._tar && tpart) {
5705 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5706 *use要素や実体参照などは_tarプロパティがないことに注意
5709 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5710 tpart.insertBefore(tar._tar, tnext._tar);
5713 tnext = tnext.nextSibling;
5716 tpart.appendChild(tar._tar);
5718 } else if (!tnext && tpart) {
5719 tpart.appendChild(tar._tar);
5721 tnext = tpart = isLast = void 0;
5722 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5723 var tar = evt.target,
5724 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5725 fontSize = parseFloat(style.getPropertyValue("font-size"));
5726 tar.x.baseVal._emToUnit(fontSize);
5727 tar.y.baseVal._emToUnit(fontSize);
5728 tar.width.baseVal._emToUnit(fontSize);
5729 tar.height.baseVal._emToUnit(fontSize);
5730 var rx = tar.getAttributeNS(null, "rx"),
5731 ry = tar.getAttributeNS(null, "ry"),
5732 x = tar.x.baseVal.value,
5733 y = tar.y.baseVal.value,
5734 xw = x + tar.width.baseVal.value,
5735 yh = y + tar.height.baseVal.value,
5737 if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
5738 tar.rx.baseVal._emToUnit(fontSize);
5739 tar.ry.baseVal._emToUnit(fontSize);
5740 var thrx = tar.rx.baseVal,
5741 thry = tar.ry.baseVal,
5742 twidth = tar.width.baseVal.value,
5743 theight = tar.height.baseVal.value;
5744 thrx.value = rx ? thrx.value : thry.value;
5745 thry.value = ry ? thry.value : thrx.value;
5746 //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
5747 if (thrx.value > twidth / 2) {
5748 thrx.value = twidth / 2;
5750 if (thry.value > theight / 2) {
5751 thry.value = theight / 2;
5753 var rxv = thrx.value,
5755 rrx = rxv * 0.55228,
5756 rry = ryv * 0.55228,
5761 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];
5763 list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
5765 //以下は、配列listそのものをCTMで座標変換していく処理
5766 var par = tar.ownerDocument.documentElement,
5767 ctm = tar.getScreenCTM(),
5770 vi = tar.ownerDocument.documentElement,
5771 w = vi.width.baseVal.value,
5772 h = vi.height.baseVal.value,
5774 for (var i=0, lili=list.length;i<lili;) {
5775 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5779 p = par.createSVGPoint();
5782 pmt = p.matrixTransform(ctm);
5783 list[i] = mr(pmt.x);
5785 list[i] = mr(pmt.y);
5789 dat = list.join(" ");
5792 ele.coordsize = w + " " + h;
5793 NAIBU._setPaint(tar, ctm);
5794 delete tar._cacheMatrix;
5795 evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
5801 SVGRectElement.prototype = new SVGElement();
5803 function SVGCircleElement(_doc) {
5804 SVGElement.apply(this);
5805 this._tar = _doc.createElement("v:shape");
5806 var sl = SVGAnimatedLength;
5807 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5808 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5809 /*readonly SVGAnimatedLength*/ this.r = new sl();
5811 this.addEventListener("DOMNodeInserted", function(evt){
5812 var tar = evt.target;
5813 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5816 var tnext = tar.nextSibling,
5817 tpart = tar.parentNode._tar,
5819 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5820 tpart.insertBefore(tar._tar, tnext._tar);
5821 } else if (tnext && !tnext._tar && tpart) {
5822 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5823 *use要素や実体参照などは_tarプロパティがないことに注意
5826 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5827 tpart.insertBefore(tar._tar, tnext._tar);
5830 tnext = tnext.nextSibling;
5833 tpart.appendChild(tar._tar);
5835 } else if (!tnext && tpart) {
5836 tpart.appendChild(tar._tar);
5838 tnext = tpart = isLast = void 0;
5839 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5840 var tar = evt.target,
5841 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5842 fontSize = parseFloat(style.getPropertyValue("font-size"));
5843 tar.cx.baseVal._emToUnit(fontSize);
5844 tar.cy.baseVal._emToUnit(fontSize);
5845 tar.r.baseVal._emToUnit(fontSize);
5846 var cx = tar.cx.baseVal.value,
5847 cy = tar.cy.baseVal.value,
5848 rx = ry = tar.r.baseVal.value,
5855 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"];
5856 //以下は、配列listそのものをCTMで座標変換していく処理
5857 var par = tar.ownerDocument.documentElement,
5858 ctm = tar.getScreenCTM(),
5860 for (var i=0, lili=list.length;i<lili;) {
5861 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5865 var p = par.createSVGPoint();
5868 var pmt = p.matrixTransform(ctm);
5869 list[i] = mr(pmt.x);
5871 list[i] = mr(pmt.y);
5875 var dat = list.join(" "),
5877 vi = tar.ownerDocument.documentElement,
5878 w = vi.width.baseVal.value,
5879 h = vi.height.baseVal.value;
5882 ele.coordsize = w + " " + h;
5883 NAIBU._setPaint(tar, ctm);
5884 delete tar._cacheMatrix;
5885 evt = tar = list = mr = style = fontSize = dat = ele = void 0;
5891 SVGCircleElement.prototype = new SVGElement();
5893 function SVGEllipseElement(_doc) {
5894 SVGElement.apply(this);
5895 this._tar = _doc.createElement("v:shape");
5896 var sl = SVGAnimatedLength;
5897 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5898 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5899 /*readonly SVGAnimatedLength*/ this.rx = new sl();
5900 /*readonly SVGAnimatedLength*/ this.ry = new sl();
5902 this.addEventListener("DOMNodeInserted", function(evt){
5903 var tar = evt.target;
5904 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5907 var tnext = tar.nextSibling,
5908 tpart = tar.parentNode._tar,
5910 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5911 tpart.insertBefore(tar._tar, tnext._tar);
5912 } else if (tnext && !tnext._tar && tpart) {
5913 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5914 *use要素や実体参照などは_tarプロパティがないことに注意
5917 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5918 tpart.insertBefore(tar._tar, tnext._tar);
5921 tnext = tnext.nextSibling;
5924 tpart.appendChild(tar._tar);
5926 } else if (!tnext && tpart) {
5927 tpart.appendChild(tar._tar);
5929 tnext = tpart = isLast = void 0;
5930 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5931 var tar = evt.target,
5932 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5933 fontSize = parseFloat(style.getPropertyValue("font-size"));
5934 tar.cx.baseVal._emToUnit(fontSize);
5935 tar.cy.baseVal._emToUnit(fontSize);
5936 tar.rx.baseVal._emToUnit(fontSize);
5937 tar.ry.baseVal._emToUnit(fontSize);
5938 var cx = tar.cx.baseVal.value,
5939 cy = tar.cy.baseVal.value,
5940 rx = tar.rx.baseVal.value,
5941 ry = tar.ry.baseVal.value,
5948 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"];
5949 //以下は、配列listそのものをCTMで座標変換していく処理
5950 var par = tar.ownerDocument.documentElement,
5951 ctm = tar.getScreenCTM(),
5953 for (var i=0, lili=list.length;i<lili;) {
5954 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5958 var p = par.createSVGPoint();
5961 var pmt = p.matrixTransform(ctm);
5962 list[i] = mr(pmt.x);
5964 list[i] = mr(pmt.y);
5968 var dat = list.join(" "),
5970 vi = tar.ownerDocument.documentElement,
5971 w = vi.width.baseVal.value,
5972 h = vi.height.baseVal.value;
5975 ele.coordsize = w + " " + h;
5976 NAIBU._setPaint(tar, ctm);
5977 delete tar._cacheMatrix;
5978 evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
5984 SVGEllipseElement.prototype = new SVGElement();
5986 function SVGLineElement(_doc) {
5987 SVGElement.apply(this);
5988 this._tar = _doc.createElement("v:shape");
5989 var sl = SVGAnimatedLength;
5990 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
5991 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
5992 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
5993 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
5995 this.addEventListener("DOMNodeInserted", function(evt){
5996 var tar = evt.target;
5997 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6000 var tnext = tar.nextSibling,
6001 tpart = tar.parentNode._tar,
6003 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6004 tpart.insertBefore(tar._tar, tnext._tar);
6005 } else if (tnext && !tnext._tar && tpart) {
6006 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6007 *use要素や実体参照などは_tarプロパティがないことに注意
6010 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6011 tpart.insertBefore(tar._tar, tnext._tar);
6014 tnext = tnext.nextSibling;
6017 tpart.appendChild(tar._tar);
6019 } else if (!tnext && tpart) {
6020 tpart.appendChild(tar._tar);
6022 tnext = tpart = isLast = void 0;
6023 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6024 var tar = evt.target,
6025 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
6026 fontSize = parseFloat(style.getPropertyValue("font-size"));
6027 tar.x1.baseVal._emToUnit(fontSize);
6028 tar.y1.baseVal._emToUnit(fontSize);
6029 tar.x2.baseVal._emToUnit(fontSize);
6030 tar.y2.baseVal._emToUnit(fontSize);
6031 //以下は、配列listそのものをCTMで座標変換していく処理
6032 var vi = tar.ownerDocument.documentElement,
6033 ctm = tar.getScreenCTM(),
6036 p = vi.createSVGPoint();
6037 p.x = tar.x1.baseVal.value;
6038 p.y = tar.y1.baseVal.value;
6039 var pmt = p.matrixTransform(ctm);
6040 dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
6041 p.x = tar.x2.baseVal.value;
6042 p.y = tar.y2.baseVal.value;
6043 pmt = p.matrixTransform(ctm);
6044 dat += mr(pmt.x)+ " " +mr(pmt.y);
6048 w = vi.width.baseVal.value,
6049 h = vi.height.baseVal.value;
6051 ele.coordsize = w + " " + h;
6052 NAIBU._setPaint(tar, ctm);
6053 delete tar._cacheMatrix;
6054 evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
6060 SVGLineElement.prototype = new SVGElement();
6062 /*_GenericSVGPolyElementインターフェース
6063 * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
6064 * ファイルサイズを軽量にすることができる
6066 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
6067 SVGElement.apply(this);
6068 this._tar = _doc.createElement("v:shape");
6070 //interface SVGAnimatedPoints
6071 /*readonly SVGPointList*/ this.animatedPoints = this.points = new SVGPointList();
6072 this.addEventListener("DOMAttrModified", function(evt){
6073 var tar = evt.target;
6074 if (evt.attrName === "points") {
6075 var tp = tar.points, par = tar.ownerDocument.documentElement;
6076 var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
6077 for (var i=0, p, lili=list.length;i<lili;i+=2) {
6078 if (isNaN(list[i])) {
6082 p = par.createSVGPoint();
6083 p.x = parseFloat(list[i]);
6084 p.y = parseFloat(list[i+1]);
6088 evt = tar = list = tp = par = p = void 0;
6090 this.addEventListener("DOMNodeInserted", function(evt){
6091 var tar = evt.target;
6092 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6095 var tnext = tar.nextSibling,
6096 tpart = tar.parentNode._tar,
6098 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6099 tpart.insertBefore(tar._tar, tnext._tar);
6100 } else if (tnext && !tnext._tar && tpart) {
6101 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6102 *use要素や実体参照などは_tarプロパティがないことに注意
6105 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6106 tpart.insertBefore(tar._tar, tnext._tar);
6109 tnext = tnext.nextSibling;
6112 tpart.appendChild(tar._tar);
6114 } else if (!tnext && tpart) {
6115 tpart.appendChild(tar._tar);
6117 tnext = tpart = isLast = void 0;
6118 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6119 var tar = evt.target,
6121 ctm = tar.getScreenCTM(),
6123 //以下は、配列listそのものをCTMで座標変換していく処理
6124 for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
6125 var p = tp.getItem(i),
6126 pmt = p.matrixTransform(ctm);
6127 list[2*i] = mr(pmt.x);
6128 list[2*i + 1] = mr(pmt.y);
6131 list.splice(2, 0, "l");
6132 var dat = "m" + list.join(" ") + xclose,
6134 vi = tar.ownerDocument.documentElement;
6135 w = vi.width.baseVal.value,
6136 h = vi.height.baseVal.value;
6139 ele.coordsize = w + " " + h;
6140 NAIBU._setPaint(tar, ctm);
6141 delete tar._cacheMatrix;
6142 evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
6148 function SVGPolylineElement(_doc) {
6149 NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
6153 SVGPolylineElement.prototype = new SVGElement();
6155 function SVGPolygonElement(_doc) {
6156 NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
6160 SVGPolygonElement.prototype = new SVGElement();
6162 function SVGTextContentElement(_doc) {
6163 SVGElement.apply(this);
6164 /*readonly SVGAnimatedLength*/ this.textLength = new SVGAnimatedLength();
6165 /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
6166 this.addEventListener("DOMNodeInserted", function(evt){
6167 var tar = evt.target,
6168 cur = evt.currentTarget,
6169 eph = evt.eventPhase;
6170 /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
6171 *あらかじめ、Capturingフェーズで処理しておく
6173 if ((eph === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
6174 /*a要素の場合はtarをすりかえておく*/
6175 tar = tar.firstChild;
6177 if ((eph === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !!!tar._tars) {
6178 /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
6180 var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
6182 tar.length = data.length
6183 data = data.split('');
6184 for (var i=0, tdli=data.length;i<tdli;++i) {
6185 var d = _doc.createElement("div"),
6187 dstyle.position = "absolute";
6188 dstyle.textIndent = dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = dstyle.paddingTop = dstyle.paddingLeft = "0px";
6189 dstyle.whiteSpace = "nowrap";
6190 d.appendChild(_doc.createTextNode(data[i]));
6191 tar._tars[tar._tars.length] = d;
6195 evt = tar = cur = eph = void 0;
6197 this.addEventListener("DOMNodeRemoved", function(evt){
6198 var tar = evt.target;
6199 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6200 delete evt.currentTarget._length;
6208 t.prototype = new SVGElement();
6209 // lengthAdjust Types
6210 /*unsigned short*/ t.LENGTHADJUST_UNKNOWN = 0;
6211 /*unsigned short*/ t.LENGTHADJUST_SPACING = 1;
6212 /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS = 2;
6213 t.prototype._list = null; //文字の位置を格納しておくリストのキャッシュ
6214 t.prototype._length = null; //全文字数のキャッシュ
6215 t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
6216 t.prototype._chars = 0; //tspan (tref)要素が全体の何文字目から始まっているか
6217 t.prototype._isYokogaki = true; //横書きかどうか
6218 /*long*/ t.prototype.getNumberOfChars = function() {
6220 return (this._length);
6225 if (ts.length && (ts.nodeType === /*Node.TEXT_NODE*/ 3)) {
6227 } else if (ts.getNumberOfChars) { //tspan要素などであれば
6228 s += ts.getNumberOfChars();
6229 } else if (ts.firstChild && (ts.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
6230 f(ts.firstChild); //再帰的に呼び出す
6232 ts = ts.nextSibling;
6241 /*float*/ t.prototype.getComputedTextLength = function() {
6242 var l = this.textLength.baseVal;
6243 if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
6244 /*何も設定されていない場合のみ、初期化を行う*/
6245 l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
6248 return (this.textLength.baseVal.value);
6250 /*getSubStringLengthメソッド
6251 *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
6253 /*float*/ t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
6257 var tg = this.getNumberOfChars();
6258 if (tg < (nchars+charnum)) {
6259 /*ncharsが文字列の長さよりも長くなってしまったときには、
6260 *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
6262 nchars = tg - charnum + 1;
6264 var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
6265 if (this._isYokogaki) {
6266 var s = end.x - st.x;
6268 var s = end.y - st.y;
6270 tg = end = st = void 0;
6273 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
6274 if (charnum > this.getNumberOfChars() || charnum < 0) {
6275 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6278 ti = tar.firstChild,
6279 tp = tar.parentNode;
6282 var chars = tar._chars, //現在、何文字目にあるのか
6283 x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
6284 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6285 isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
6286 fontSize = parseFloat(style.getPropertyValue("font-size")),
6287 tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
6289 if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
6290 var ptx = tp.x.baseVal,
6292 ptdx = tp.dx.baseVal,
6293 ptdy = tp.dy.baseVal;
6295 var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
6297 var kern = "f ijltIr.,:;'-\"()",
6298 akern = "1234567890abcdeghknopquvxyz",
6299 tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
6300 if (isYokogaki && (tar.localName === "text")) {
6301 y += fontSize * 0.2;
6302 } else if (tar.localName === "text"){
6303 x -= fontSize * 0.5;
6306 if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
6308 /*tspan(tref)要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
6309 *使う。また、属性が指定されていないときも同様に祖先や親を使う。
6310 *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
6311 *この処理はdx属性やdy、y属性でも同様とする
6313 *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
6315 *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
6317 for (var i=0, tli=tt.length;i<tli;++i) {
6318 if (n < ptx.numberOfItems - chars) {
6319 x = ptx.getItem(n).value;
6321 x -= fontSize * 0.5;
6323 } else if (n < tx.numberOfItems) {
6324 x = tx.getItem(n).value;
6326 x -= fontSize * 0.5;
6329 if (n < pty.numberOfItems - chars) {
6330 y = pty.getItem(n).value;
6332 y += fontSize * 0.2;
6334 } else if (n < ty.numberOfItems) {
6335 y = ty.getItem(n).value;
6337 y += fontSize * 0.2;
6340 if (n < ptdx.numberOfItems - chars) {
6341 x += ptdx.getItem(n).value;
6342 } else if (n < tdx.numberOfItems) {
6343 x += tdx.getItem(n).value;
6345 if (n < ptdy.numberOfItems - chars) {
6346 y += ptdy.getItem(n).value;
6347 } else if (n < tdy.numberOfItems) {
6348 y += tdy.getItem(n).value;
6352 //カーニングを求めて、字の幅を文字ごとに調整する
6353 tdc = ti.data.charAt(i);
6354 if (kern.indexOf(tdc) > -1) {
6355 alm = fontSize * 0.68;
6356 } else if (tdc === "s"){
6357 alm = fontSize * 0.52;
6358 } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
6359 alm = fontSize * 0.2;
6360 } else if (akern.indexOf(tdc) > -1){
6361 alm = fontSize * 0.45;
6363 alm = fontSize * 0.3;
6365 tcca = tdc.charCodeAt(0);
6366 if ((12288 <= tcca) && (tcca <= 65533)) {
6367 alm = -fontSize * 0.01;
6368 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
6369 alm += fontSize * 0.2;
6374 tlist[tlist.length] = x;
6375 tlist[tlist.length] = y;
6376 tlist[tlist.length] = fontSize - alm;
6386 if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
6389 ti = ti.nextSibling;
6390 } else if (((ti.localName === "tspan") || (ti.localName === "tref"))
6391 && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6392 /*現在のテキスト位置(x,y)の分だけ、tspan (tref)要素をずらしておく。
6398 p = ti.getStartPositionOfChar(ti.getNumberOfChars());
6403 almx = tlist[tlist.length-1];
6405 almy = tlist[tlist.length-1];
6407 x = tlist[tlist.length-3] + almx;
6408 y = tlist[tlist.length-2] + almy;
6409 tar._list = tar._list.concat(tlist);
6410 tg = ti.getNumberOfChars();
6413 ti = ti.nextSibling;
6414 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6415 /*a要素のテキストノードも処理する*/
6418 ti = ti.nextSibling;
6421 tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
6423 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;
6424 var s = this.ownerDocument.documentElement.createSVGPoint();
6425 s.x = this._list[charnum*3];
6426 s.y = this._list[charnum*3 + 1];
6427 s = s.matrixTransform(this.getScreenCTM());
6431 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
6432 if (charnum > this.getNumberOfChars() || charnum < 0) {
6433 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6435 var s = this.getStartPositionOfChar(charnum);
6436 //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
6437 var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
6438 if (this._isYokogaki) {
6446 /*SVGRect*/ t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
6449 /*float*/ t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
6452 /*long*/ t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
6455 /*void*/ t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
6458 })(SVGTextContentElement);
6460 function SVGTextPositioningElement(_doc) {
6461 SVGTextContentElement.apply(this, arguments);
6462 var sl = SVGAnimatedLengthList;
6463 /*readonly SVGAnimatedLengthList*/ this.x = new sl();
6464 /*readonly SVGAnimatedLengthList*/ this.y = new sl();
6465 /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
6466 /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
6468 /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
6469 this.addEventListener("DOMAttrModified", function(evt){
6470 var tar = evt.target,
6471 name = evt.attrName,
6472 tod = tar.ownerDocument.documentElement,
6473 _parseFloat = parseFloat;
6474 if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
6475 var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
6476 teas = tar[name].baseVal;
6477 for (var i=0, tli=enr.length;i<tli;++i) {
6478 var tea = tod.createSVGLength(),
6479 n = enr[i].slice(-1),
6481 if (n >= "0" && n <= "9") {
6482 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
6483 } else if (n === "%") {
6484 if ((name === "x") || (name === "dx")) {
6485 tea._percent *= tod.viewport.width;
6486 } else if ((name === "y") || (name === "dy")) {
6487 tea._percent *= tod.viewport.height;
6489 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
6491 n = enr[i].slice(-2);
6493 var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
6494 tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
6496 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
6497 } else if (n === "ex") {
6498 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
6499 } else if (n === "px") {
6500 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
6501 } else if (n === "cm") {
6502 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
6503 } else if (n === "mm") {
6504 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
6505 } else if (n === "in") {
6506 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
6507 } else if (n === "pt") {
6508 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
6509 } else if (n === "pc") {
6510 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
6513 var s = _parseFloat(enr[i]);
6514 s = isNaN(s) ? 0 : s;
6515 tea.newValueSpecifiedUnits(type, s);
6516 teas.appendItem(tea);
6522 this.addEventListener("DOMNodeInserted", function(evt){
6523 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6524 var tar = evt.target;
6525 if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
6527 evt.currentTarget._list = null;
6533 this._tar = _doc.createElement("v:group");
6534 this._doc = _doc; //_docプロパティは_texto関数内で使われる
6536 this.addEventListener("DOMNodeInserted", function(evt){
6537 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6540 var tar = evt.target,
6541 tnext = tar.nextSibling,
6542 tpart = tar.parentNode._tar,
6544 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6545 tpart.insertBefore(tar._tar, tnext._tar);
6546 } else if (tnext && !tnext._tar && tpart) {
6547 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6548 *use要素や実体参照などは_tarプロパティがないことに注意
6551 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6552 tpart.insertBefore(tar._tar, tnext._tar);
6555 tnext = tnext.nextSibling;
6558 tpart.appendChild(tar._tar);
6560 } else if (!tnext && tpart) {
6561 tpart.appendChild(tar._tar);
6563 tnext = tpart = isLast = void 0;
6564 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._texto, false);
6569 SVGTextPositioningElement.constructor = SVGTextContentElement;
6570 SVGTextPositioningElement.prototype = new SVGTextContentElement();
6571 SVGTextPositioningElement.prototype._texto = function(evt) {
6572 var tar = evt.target,
6573 ti = tar.firstChild,
6575 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6576 deter = Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
6577 n = parseFloat(style.getPropertyValue("font-size")) * deter,
6578 tod = tar.ownerDocument.documentElement,
6579 ttpc = ttp, //ttpcはttpのキャッシュ
6580 tlen = tar.getComputedTextLength(),
6581 anchor = style.getPropertyValue("text-anchor"),
6582 tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
6585 lts = parseFloat(style.getPropertyValue("letter-spacing")),
6586 wds = parseFloat(style.getPropertyValue("word-spacing"));
6587 ttps.fontSize = n + "px"; //nは算出された文字の大きさ (CSSではなく、SVG独自のCTM方式による)
6588 ttps.fontFamily = style.getPropertyValue("font-family");
6589 ttps.fontStyle = style.getPropertyValue("font-style");
6590 ttps.fontWeight = style.getPropertyValue("font-weight");
6591 if (isFinite(lts)) {
6592 ttps.letterSpacing = lts * deter + "px";
6594 if (isFinite(parseFloat(wds))) {
6595 ttps.wordSpacing = wds * deter + "px";
6597 /*ここでの変数jは前回ノードまでの総文字数*/
6598 for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
6600 if (!!ti._tars && (ti._tars.length !== 0)) {
6601 var ij = (i > j) ? i - j : j - i
6602 var sty = ti._tars[ij].style,
6603 p = tar.getStartPositionOfChar(i);
6604 sty.position = "absolute";
6605 if (tar._isYokogaki) {
6606 if (anchor === "middle") {
6608 } else if (anchor === "end") {
6612 if (anchor === "middle") {
6614 } else if (anchor === "end") {
6618 sty.left = p.x + "px";
6619 sty.top = p.y + "px";
6622 sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
6623 sty.lineHeight = n+10+ "px";
6624 sty.textDecoration = tedeco;
6625 sty.display = "none"
6626 ttp.appendChild(ti._tars[ij]);
6629 if (ti.nodeName === "#text") {
6630 if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
6631 j = j + ti.data.length;
6632 if (ti.parentNode.localName === "a") {
6636 ti = ti.nextSibling;
6638 } else if (!!ti.getNumberOfChars) {
6639 if ((ti.getNumberOfChars()+j) <= i+1) {
6640 j = j + ti.getNumberOfChars();
6641 ti = ti.nextSibling;
6643 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6651 var color = style.getPropertyValue("fill"),
6652 cursor = style.getPropertyCSSValue("cursor"),
6653 vis = style.getPropertyCSSValue("visibility"),
6654 disp = style.getPropertyCSSValue("display"),
6655 tts = tar._tar.style,
6656 tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
6657 ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
6659 if (color === "none"){
6660 tts.color = "transparent";
6661 } else if (color.indexOf("url") === -1) {
6664 tts.color = "black";
6666 if (cursor && !cursor._isDefault) { //初期値でないならば
6667 var tc = cursor.cssText;
6668 tts.cursor = tc.split(":")[1];
6671 if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
6672 && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
6673 /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
6674 *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
6676 for (var i=1, tli=tft.length;i<tli;++i) {
6678 ttt += tfti.innerText;
6679 tfti.parentNode.removeChild(tfti);
6681 //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
6682 if (tft[0] && tft[0].replaceChild) {
6683 tft[0].replaceChild(tar._doc.createTextNode(ttt), tft[0].firstChild);
6689 if (ttp.lastChild) {
6690 if (ttp.lastChild.nodeName !== "rect") {
6697 var backr = tar._doc.createElement("v:rect"),
6698 backrs = backr.style; //ずれを修正するためのもの
6699 backrs.width = backrs.height = "1px";
6700 backrs.left = backrs.top = "0px";
6701 backr.stroked = backr.filled = "false";
6702 ttp.appendChild(backr);
6704 if (vis && !vis._isDefault) {
6705 tts.visibility = vis.cssText.split(":")[1];
6707 /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
6708 *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
6710 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
6712 } else if (disp && !disp._isDefault) {
6715 var jt = tar._tar.firstChild,
6718 jt.style.display = di;
6719 jt = jt.nextSibling;
6721 while (ae[j]) { //要素内部にあるa要素の処理
6722 for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
6723 ae[j]._tars[l].style.display = di;
6728 delete tar._cacheMatrix;
6729 ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = lts = deter = void 0;
6732 function SVGTextElement(_doc) {
6733 SVGTextPositioningElement.apply(this, arguments);
6736 SVGTextElement.constructor = SVGTextPositioningElement;
6737 SVGTextElement.prototype = new SVGTextPositioningElement();
6739 function SVGTSpanElement() {
6740 SVGTextElement.apply(this, arguments);
6743 SVGTSpanElement.constructor = SVGTextPositioningElement;
6744 SVGTSpanElement.prototype = new SVGTextPositioningElement();
6746 function SVGTRefElement(_doc) {
6747 SVGTextPositioningElement.apply(this, arguments);
6748 this.addEventListener("DOMNodeInserted", function(evt){
6749 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6752 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
6754 this.addEventListener("S_Load", function(evt){
6755 var tar = evt.target,
6756 tic = tar._instance.firstChild;
6757 /*textノードのデータだけを処理*/
6758 while (tic && (tic.nodeName !== "#text")) {
6759 tic = tic.nextSibling;
6761 tic && tar.parentNode.insertBefore(tar.ownerDocument.importNode(tic, false), tar);
6762 evt.target = tar.parentNode;
6763 tar.parentNode._texto(evt);
6764 tar = tic = evtt = void 0;
6766 SVGURIReference.apply(this, arguments);
6769 SVGTRefElement.constructor = SVGTextPositioningElement;
6770 SVGTRefElement.prototype = new SVGTextPositioningElement();
6772 function SVGTextPathElement() {
6773 SVGTextContentElement.apply(this, arguments);
6774 /*readonly SVGAnimatedLength*/ this.startOffset;
6775 /*readonly SVGAnimatedEnumeration*/ this.method;
6776 /*readonly SVGAnimatedEnumeration*/ this.spacing;
6777 SVGURIReference.apply(this, arguments);
6780 SVGTextPathElement.constructor = SVGTextContentElement;
6781 SVGTextPathElement.prototype = new SVGTextContentElement();
6784 // textPath Method Types
6785 /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN = 0;
6786 /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN = 1;
6787 /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH = 2;
6788 // textPath Spacing Types
6789 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN = 0;
6790 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO = 1;
6791 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT = 2;
6792 })(SVGTextPathElement);
6794 function SVGAltGlyphElement() {
6795 SVGTextPositioningElement.apply(this, arguments);
6796 /*DOMString*/ this.glyphRef;
6797 /*DOMString*/ this.format;
6798 SVGURIReference.apply(this, arguments);
6801 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
6802 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
6804 function SVGAltGlyphDefElement() {
6805 SVGElement.apply(this, arguments);
6808 SVGAltGlyphDefElement.prototype = new SVGElement();
6810 function SVGAltGlyphItemElement() {
6811 SVGElement.apply(this, arguments);
6814 SVGAltGlyphItemElement.prototype = new SVGElement();
6816 function SVGGlyphRefElement() {
6817 SVGElement.apply(this, arguments);
6818 /*DOMString*/ this.glyphRef;
6819 /*DOMString*/ this.format;
6824 SVGURIReference.apply(this, arguments);
6827 SVGGlyphRefElement.prototype = new SVGElement();
6829 function SVGPaint() {
6830 SVGColor.apply(this, arguments);
6835 t.prototype = new SVGColor();
6837 /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN = 0;
6838 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR = 1;
6839 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
6840 /*unsigned short*/ t.SVG_PAINTTYPE_NONE = 101;
6841 /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR = 102;
6842 /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE = 103;
6843 /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
6844 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR = 105;
6845 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
6846 /*unsigned short*/ t.SVG_PAINTTYPE_URI = 107;
6847 /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
6848 /*readonly DOMString*/ t.prototype.uri = null;
6849 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
6850 this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
6852 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
6853 if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
6854 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
6857 this.paintType = paintType;
6858 if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
6859 paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
6861 this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
6863 // raises( SVGException );
6867 function SVGMarkerElement(){
6868 SVGSVGElement.apply(this, [{createElement:function(){}}]);
6869 this._tar = {style:{}}; //getScreenCTMメソッド対策
6870 var sl = SVGAnimatedLength;
6871 /*readonly SVGAnimatedLength*/ this.refX = new sl();
6872 /*readonly SVGAnimatedLength*/ this.refY = new sl();
6873 /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
6874 this.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH;
6875 /*readonly SVGAnimatedLength*/ this.markerWidth = new sl();
6876 /*readonly SVGAnimatedLength*/ this.markerHeight = new sl();
6877 this.refX.baseVal.newValueSpecifiedUnits(1, 0);
6878 this.refY.baseVal.newValueSpecifiedUnits(1, 0);
6879 this.markerWidth.baseVal.newValueSpecifiedUnits(1, 3);
6880 this.markerHeight.baseVal.newValueSpecifiedUnits(1, 3);
6882 /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
6883 this.orientType.baseVal = SVGMarkerElement.SVG_MARKER_ORIENT_ANGLE;
6884 /*readonly SVGAnimatedAngle*/ this.orientAngle = new SVGAnimatedAngle();
6885 //SVGFitToViewBoxのインターフェースはSVGSVGElementで代用
6886 this.addEventListener("DOMAttrModified", function(evt) {
6887 var tar = evt.target,
6890 if (evt.attrName === "orient") {
6891 if (en === "auto") {
6892 tar.setOrientToAuto();
6894 angle = tar.ownerDocument.documentElement.createSVGAngle();
6895 angle.newValueSpecifiedUnits(1, +en);
6896 tar.setOrientToAngle(angle);
6898 } else if (evt.attrName === "markerUnits") {
6899 if (en === "strokeWidth") {
6900 tar.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH;
6902 tar.markerUnits.baseVal = SVGMarkerElement.SVG_MARKERUNITS_USERSPACEONUSE;
6906 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6907 /*注意: グローバル関数を書き換えているので注意を要する*/
6908 var ns = NAIBU._setPaint,
6909 id = evt.target.getAttributeNS(null, "id");
6910 NAIBU._setPaint = (function(ns, id) {
6911 return function(tar, ctm) {
6913 var td = tar.ownerDocument,
6914 tde = td.documentElement,
6915 style = td.defaultView.getComputedStyle(tar, ""),
6916 ms = style.getPropertyValue("marker-start").slice(5, -1),
6917 me = style.getPropertyValue("marker-end").slice(5, -1),
6918 mid = style.getPropertyValue("marker-mid").slice(5, -1),
6928 /*url(#id)で一致する文字列があるかどうか*/
6930 marker = td.getElementById(ms);
6931 if (tar.normalizedPathSegList || tar.points) {
6932 tn = tar.normalizedPathSegList || tar.points;
6933 plist = [tn.getItem(0), tn.getItem(1)];
6934 } else if (tar.x1) {
6935 plist = [{x:tar.x1, y:tar.y1}, {x:tar.x2, y:tar.y2}];
6937 cmarker = marker.cloneNode(true);
6938 gmarker = td.createElementNS("http://www.w3.org/2000/svg", "g");
6939 /*marker要素の子要素はすべて、g要素としてまとめておく*/
6940 while (cmarker.lastChild) {
6941 gmarker.appendChild(cmarker.lastChild);
6943 tr = gmarker.transform.baseVal;
6944 ttr = tar.transform.baseVal.consolidate() || td.documentElement.createSVGMatrix();
6945 if (marker.markerUnits.baseVal === SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH) {
6946 sth = +style.getPropertyValue("stroke-width");
6951 if (marker.hasAttributeNS(null, "viewBox")) {
6952 marker.viewport.width = marker.markerWidth.baseVal.value;
6953 marker.viewport.height = marker.markerHeight.baseVal.value;
6954 /*applyを使って、marker要素のCTMを算出*/
6955 ctm = tde.getScreenCTM.apply(marker);
6957 ctm = tde.createSVGMatrix();
6959 if (marker.orientType.baseVal === SVGMarkerElement.SVG_MARKER_ORIENT_AUTO) {
6960 angle = Math.atan2(plist[1].y-plist[0].y, plist[1].x-plist[0].x)*180/Math.PI;
6962 angle = marker.orientAngle.baseVal.value;
6964 tr.appendItem(tr.createSVGTransformFromMatrix(ttr.translate(plist[0].x, plist[0].y)
6968 .translate(-marker.refX.baseVal.value, -marker.refY.baseVal.value)));
6969 tar.parentNode.insertBefore(gmarker, tar.nextSibling);
6972 marker = td.getElementById(me);
6973 if (tar.normalizedPathSegList || tar.points) {
6974 tn = tar.normalizedPathSegList || tar.points;
6975 plist = [tn.getItem(tn.numberOfItems-2), tn.getItem(tn.numberOfItems-1)];
6976 } else if (tar.x1) {
6977 plist = [{x:tar.x1, y:tar.y1}, {x:tar.x2, y:tar.y2}];
6979 cmarker = marker.cloneNode(true);
6980 gmarker = td.createElementNS("http://www.w3.org/2000/svg", "g");
6981 /*marker要素の子要素はすべて、g要素としてまとめておく*/
6982 while (cmarker.lastChild) {
6983 gmarker.appendChild(cmarker.lastChild);
6985 tr = gmarker.transform.baseVal;
6986 ttr = tar.transform.baseVal.consolidate() || td.documentElement.createSVGMatrix();
6987 if (marker.markerUnits.baseVal === SVGMarkerElement.SVG_MARKERUNITS_STROKEWIDTH) {
6988 sth = +style.getPropertyValue("stroke-width");
6992 if (marker.hasAttributeNS(null, "viewBox")) {
6993 marker.viewport.width = marker.markerWidth.baseVal.value;
6994 marker.viewport.height = marker.markerHeight.baseVal.value;
6995 /*applyを使って、marker要素のCTMを算出*/
6996 ctm = tde.getScreenCTM.apply(marker);
6998 ctm = tde.createSVGMatrix();
7000 if (marker.orientType.baseVal === SVGMarkerElement.SVG_MARKER_ORIENT_AUTO) {
7001 angle = Math.atan2(plist[1].y-plist[0].y, plist[1].x-plist[0].x)*180/Math.PI;
7003 angle = marker.orientAngle.baseVal.value;
7005 tr.appendItem(tr.createSVGTransformFromMatrix(ttr.translate(plist[1].x, plist[1].y)
7009 .translate(-marker.refX.baseVal.value, -marker.refY.baseVal.value)));
7010 tar.parentNode.insertBefore(gmarker, tar.nextSibling);
7013 marker = td.getElementById(mid);
7015 td = tde = style = ms = me = mid = marker = cmarker = gmarker = ctm = sth = tr = tn = ttr = plist = void 0;
7022 // Marker Unit Types
7023 /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN = 0;
7024 /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
7025 /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH = 2;
7026 // Marker Orientation Types
7027 /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN = 0;
7028 /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO = 1;
7029 /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE = 2;
7030 t.prototype = new SVGSVGElement();
7031 t.prototype.getScreenCTM = SVGElement.prototype.getScreenCTM;
7032 /*void*/ t.prototype.setOrientToAuto = function() {
7033 this.orientType.baseVal = t.SVG_MARKER_ORIENT_AUTO;
7035 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
7036 this.orientType.baseVal = t.SVG_MARKER_ORIENT_ANGLE;
7037 this.orientAngle.baseVal = angle;
7040 })(SVGMarkerElement);
7041 function SVGColorProfileElement() {
7042 SVGElement.apply(this);
7043 /*DOMString*/ this._local;
7044 // raises DOMException on setting
7045 // (NOTE: is prefixed by "_"
7046 // as "local" is an IDL keyword. The
7047 // prefix will be removed upon processing)
7048 /*DOMString*/ this.name;
7049 /*unsigned short*/ this.renderingIntent;
7050 SVGURIReference.apply(this, arguments);
7053 SVGColorProfileElement.prototype = new SVGElement();
7055 function SVGColorProfileRule() {
7056 SVGCSSRule.apply(this);
7057 /*DOMString*/ this.src;
7058 /*DOMString*/ this.name;
7059 /*unsigned short*/ this.renderingIntent;
7062 SVGColorProfileRule.prototype = new SVGCSSRule();
7064 function SVGGradientElement() {
7065 SVGElement.apply(this);
7066 SVGURIReference.apply(this);
7067 /*readonly SVGAnimatedEnumeration*/ this.gradientUnits = new SVGAnimatedEnumeration();
7068 /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
7069 /*readonly SVGAnimatedEnumeration*/ this.spreadMethod = new SVGAnimatedEnumeration();
7070 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
7071 var grad = evt.target,
7073 t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
7075 href, stops, length,
7080 if (!ele || !grad) { //まだ、path要素などが設定されていない場合
7081 grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
7084 if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
7085 grad2 = grad._instance;
7087 stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
7089 ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
7092 length = stops.length;
7093 for (var i = 0; i < length; ++i) {
7095 sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
7096 ci = sstyle.getPropertyCSSValue("stop-color");
7097 if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
7098 /*再度、設定。css.jsのsetPropertyを参照*/
7099 sstyle.setProperty("color", sstyle.getPropertyValue("color"));
7101 color[i] = "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
7102 colors[i] = stop.offset.baseVal + " " + color[i];
7103 opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
7105 ele["method"] = "none";
7106 ele["color"] = color[0];
7107 ele["color2"] = color[length-1];
7108 ele["colors"] = colors.join(",");
7109 // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
7110 ele["opacity"] = opacity[length-1]+ "";
7111 ele["o:opacity2"] = opacity[0]+ "";
7112 /*SVGRadialGradientElementインターフェースで利用する*/
7113 grad._color = color;
7114 var gt = grad2.getAttributeNS(null, "gradientTransform");
7116 grad.setAttributeNS(null, "transform", gt);
7118 grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
7122 SVGGradientElement.prototype = new SVGElement();
7123 // Spread Method Types
7124 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
7125 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD = 1;
7126 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
7127 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT = 3;
7129 function SVGLinearGradientElement() {
7130 SVGGradientElement.apply(this);
7131 var sl = SVGAnimatedLength;
7132 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
7133 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
7134 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
7135 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
7137 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
7138 var grad = evt.target, ele = evt._tar, angle = 270;
7139 if (!!!ele) { //まだ、path要素などが設定されていない場合
7142 var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
7143 var fontSize = parseFloat(style.getPropertyValue("font-size"));
7144 grad.x1.baseVal._emToUnit(fontSize);
7145 grad.y1.baseVal._emToUnit(fontSize);
7146 grad.x2.baseVal._emToUnit(fontSize);
7147 grad.y2.baseVal._emToUnit(fontSize);
7148 angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
7152 ele.setAttribute("type", "gradient");
7153 ele.setAttribute("angle", angle + "");
7154 evt = ele = grad = angle = style = fontSize = void 0;
7158 SVGLinearGradientElement.prototype = new SVGGradientElement();
7160 function SVGRadialGradientElement(_doc) {
7161 SVGGradientElement.apply(this);
7162 var sl = SVGAnimatedLength;
7163 /*readonly SVGAnimatedLength*/ this.cx = new sl();
7164 /*readonly SVGAnimatedLength*/ this.cy = new sl();
7165 /*readonly SVGAnimatedLength*/ this.r = new sl();
7166 /*readonly SVGAnimatedLength*/ this.fx = new sl();
7167 /*readonly SVGAnimatedLength*/ this.fy = new sl();
7169 this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
7170 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
7171 var grad = evt.target,
7173 tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
7174 if (!!!ele) { //まだ、path要素などが設定されていない場合
7177 ele.setAttribute("type", "gradientTitle");
7178 ele.setAttribute("focus", "100%");
7179 ele.setAttribute("focusposition", "0.5 0.5");
7180 if (tar.localName === "rect") {
7181 /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
7182 *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
7184 var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
7185 fontSize = parseFloat(style.getPropertyValue("font-size"));
7186 grad.cx.baseVal._emToUnit(fontSize);
7187 grad.cy.baseVal._emToUnit(fontSize);
7188 grad.r.baseVal._emToUnit(fontSize);
7189 grad.fx.baseVal._emToUnit(fontSize);
7190 grad.fy.baseVal._emToUnit(fontSize);
7191 var cx = grad.cx.baseVal.value,
7192 cy = grad.cy.baseVal.value,
7193 r = grad.r.baseVal.value,
7197 var tarrect = tar.getBBox(),
7198 vi = tar.ownerDocument.documentElement.viewport,
7203 units = grad.getAttributeNS(null, "gradientUnits");
7204 if (!units || units === "objectBoundingBox") {
7205 //%の場合は小数点に変換(10% -> 0.1)
7206 cx = cx > 1 ? cx/100 : cx;
7207 cy = cy > 1 ? cy/100 : cy;
7208 r = r > 1 ? r/100 : r;
7209 //要素の境界領域を求める(四隅の座標を求める)
7212 wid = tarrect.width,
7213 hei = tarrect.height;
7218 nx = ny = wid = hei = void 0;
7220 var matrix = tar.getScreenCTM().multiply(grad.getCTM());
7225 var rrx = rx * 0.55228,
7227 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"];
7228 for (var i = 0, lili = list.length; i < lili;) {
7229 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
7233 var p = grad.ownerDocument.documentElement.createSVGPoint();
7234 p.x = parseFloat(list[i]);
7235 p.y = parseFloat(list[i+1]);
7236 var pmt = p.matrixTransform(matrix);
7237 list[i] = mr(pmt.x);
7239 list[i] = mr(pmt.y);
7243 var ellipse = list.join(" "),
7244 outline = _doc.getElementById("_NAIBU_outline"),
7245 background = _doc.createElement("div"),
7246 bstyle = background.style;
7247 bstyle.position = "absolute";
7248 bstyle.display = "inline-block";
7251 bstyle.textAlign = "left";
7253 bstyle.left = "0px";
7254 bstyle.width = w+ "px";
7255 bstyle.height = h+ "px";
7256 outline.appendChild(background);
7257 bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
7258 background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
7259 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>',
7260 data = tar._tar.path.value;
7261 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>';
7262 background.filters[0].apply();
7263 background.innerHTML = circle;
7264 background.filters[0].play();
7265 tar._tar.parentNode.insertBefore(background, tar._tar);
7266 tar._tar.filled = "false";
7267 ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
7268 } else if (!ele.parentNode){
7269 tar._tar.appendChild(ele);
7271 evt = tar = ele = gard = void 0;
7275 SVGRadialGradientElement.prototype = new SVGGradientElement();
7277 function SVGStopElement() {
7278 SVGElement.apply(this, arguments);
7279 /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
7280 this.addEventListener("DOMAttrModified", function(evt) {
7281 if (evt.attrName === "offset") {
7282 evt.target.offset.baseVal = parseFloat(evt.newValue);
7288 SVGStopElement.prototype = new SVGElement();
7290 function SVGPatternElement() {
7291 SVGElement.apply(this);
7292 var sl = SVGAnimatedLength;
7293 /*readonly SVGAnimatedEnumeration*/ this.patternUnits = new SVGAnimatedEnumeration();
7294 /*readonly SVGAnimatedEnumeration*/ this.patternContentUnits = new SVGAnimatedEnumeration();
7295 /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
7296 /*readonly SVGAnimatedLength*/ this.x = new sl();
7297 /*readonly SVGAnimatedLength*/ this.y = new sl();
7298 /*readonly SVGAnimatedLength*/ this.width = new sl();
7299 /*readonly SVGAnimatedLength*/ this.height = new sl();
7301 SVGURIReference.apply(this, arguments);
7302 //SVGFitToViewBoxのインターフェースを用いる
7303 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7304 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7305 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7308 SVGPatternElement.prototype = new SVGElement();
7310 function SVGClipPathElement() {
7311 SVGElement.apply(this, arguments);
7312 /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
7315 SVGClipPathElement.prototype = new SVGElement();
7317 function SVGMaskElement() {
7318 SVGElement.apply(this);
7319 var sl = SVGAnimatedLength;
7320 /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
7321 /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
7322 /*readonly SVGAnimatedLength*/ this.x = new sl();
7323 /*readonly SVGAnimatedLength*/ this.y = new sl();
7324 /*readonly SVGAnimatedLength*/ this.width = new sl();
7325 /*readonly SVGAnimatedLength*/ this.height = new sl();
7329 SVGMaskElement.prototype = new SVGElement();
7331 function SVGFilterElement() {
7332 SVGElement.apply(this);
7333 var sl = SVGAnimatedLength;
7334 /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
7335 /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
7336 /*readonly SVGAnimatedLength*/ this.x = new sl();
7337 /*readonly SVGAnimatedLength*/ this.y = new sl();
7338 /*readonly SVGAnimatedLength*/ this.width = new sl();
7339 /*readonly SVGAnimatedLength*/ this.height = new sl();
7341 /*readonly SVGAnimatedInteger*/ this.filterResX = new SVGAnimatedInteger();
7342 /*readonly SVGAnimatedInteger*/ this.filterResY = new SVGAnimatedInteger();
7343 SVGURIReference.apply(this, arguments);
7344 //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
7347 SVGFilterElement.prototype = new SVGElement();
7349 function SVGFilterPrimitiveStandardAttributes(ele) {
7350 SVGStylable.apply(this, arguments);
7352 var sl = SVGAnimatedLength;
7353 /*readonly SVGAnimatedLength*/ this.x = new sl();
7354 /*readonly SVGAnimatedLength*/ this.y = new sl();
7355 /*readonly SVGAnimatedLength*/ this.width = new sl();
7356 /*readonly SVGAnimatedLength*/ this.height = new sl();
7357 /*readonly SVGAnimatedString*/ this.result = new sl();
7360 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
7362 function SVGFEBlendElement() {
7363 SVGElement.apply(this, arguments);
7364 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7365 /*readonly SVGAnimatedString*/ this.in2 = new SVGAnimatedString();
7366 /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
7367 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7370 SVGFEBlendElement.prototype = new SVGElement();
7372 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN = 0;
7373 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL = 1;
7374 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
7375 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN = 3;
7376 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN = 4;
7377 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN = 5;
7379 function SVGFEGaussianBlurElement() {
7380 SVGElement.apply(this, arguments);
7381 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7382 /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
7383 /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
7384 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7387 SVGFEGaussianBlurElement.prototype = new SVGElement();
7388 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
7392 function SVGCursorElement() {
7393 SVGElement.apply(this, arguments);
7394 /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
7395 /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
7396 SVGURIReference.apply(this, arguments);
7399 SVGCursorElement.prototype = new SVGElement();
7401 function SVGAElement(_doc) {
7402 SVGElement.apply(this);
7403 this._tar = _doc.createElement("a");
7405 /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
7406 this.target.baseVal = "_self";
7407 this.addEventListener("DOMAttrModified", function(evt){
7408 var tar = evt.target;
7409 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7412 if (evt.attrName === "target") {
7413 tar.target.baseVal = evt.newValue;
7414 } else if (evt.attrName === "xlink:title") {
7415 tar._tar.setAttribute("title", evt.newValue);
7419 this.addEventListener("DOMNodeInserted", function(evt){
7420 var tar = evt.target;
7421 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7424 if (tar.nextSibling) {
7425 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
7426 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
7428 } else if (!!tar.parentNode._tar){
7429 tar.parentNode._tar.appendChild(tar._tar);
7431 var txts = tar._tar.style;
7432 txts.cursor = "hand";
7435 txts.textDecoration = "none";
7437 var t = tar.target.baseVal;
7439 if (t === "_blank") {
7442 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
7443 tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
7446 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7447 var tar = evt.target;
7448 if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
7449 var txts = tar._tar.style;
7450 txts.cursor = "hand";
7451 txts.textDecoration = "none";
7457 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7458 var tar = evt.target;
7459 tar._tar.setAttribute("target", tar.target.baseVal);
7460 if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
7461 tar.addEventListener("click", function(evt){
7462 var tar = evt.target,
7465 sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
7466 if (tar.target.baseVal === "_self") {
7467 nd = tar.ownerDocument._iframe;
7468 nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
7469 ob = nd.nextSibling;
7470 if (ob && (ob.tagName === "OBJECT")) {
7471 nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
7472 nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
7473 nd.parentNode.removeChild(ob);
7475 ob = NAIBU._search([nd.previousSibling]);
7476 nd.parentNode.removeChild(nd);
7478 sd.appendChild(sd.lastChild.firstChild);
7479 while (sd.firstChild !== sd.lastChild) { //オブジェクト要素以外を除去
7480 sd.removeChild(sd.firstChild);
7482 ob = NAIBU._search([sd.lastChild]);
7484 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
7485 evt.preventDefault();
7487 _init: (function (ob) {
7489 document.title = ob.getSVGDocument().title;
7495 sd = ob = nd = void 0;
7500 SVGURIReference.apply(this, arguments);
7503 SVGAElement.prototype = new SVGElement();
7505 function SVGViewElement() {
7506 SVGElement.apply(this, arguments);
7507 /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
7508 //SVGFitToViewBoxのインターフェースを用いる
7509 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7510 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7511 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7514 SVGViewElement.prototype = new SVGElement();
7516 function SVGScriptElement() {
7517 SVGElement.apply(this);
7518 /*DOMString*/ this.type;
7519 SVGURIReference.apply(this, arguments);
7520 this.addEventListener("DOMAttrModified", function(evt){
7521 if (evt.attrName === "type") {
7522 evt.target.type = evt.newValue;
7526 this.addEventListener("S_Load", function(evt){
7527 var tar = evt.target, script = tar._text;
7528 var tod = tar.ownerDocument;
7529 NAIBU._temp_doc = tod;
7530 script = script.replace(/function\s+(\w+)/g, "$1 = function");
7531 script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
7534 } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
7535 script = script.replace(/function\(document\){/, "function() {");
7538 tar = evt = script = void 0;
7540 this.addEventListener("DOMNodeInserted", function(evt){
7541 var tar = evt.target;
7542 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7543 if (tar.nodeName === "#cdata-section") {
7544 evt.currentTarget._text = tar.data;
7548 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7549 var tar = evt.target;
7550 if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7551 var evtt = tar.ownerDocument.createEvent("SVGEvents");
7552 evtt.initEvent("S_Load", false, false);
7553 evt.currentTarget.dispatchEvent(evtt);
7560 SVGScriptElement.prototype = new SVGElement();
7562 function SVGEvent() {
7563 Event.apply(this, arguments);
7566 SVGEvent.prototype = new Event();
7568 function SVGZoomEvent() {
7569 UIEvent.apply(this, arguments);
7570 /*readonly SVGRect*/ this.zoomRectScreen = new SVGRect();
7571 /*readonly float*/ this.previousScale = 1;
7572 /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
7573 /*readonly float*/ this.newScale = 1;
7574 /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
7577 SVGZoomEvent.prototype = new UIEvent();
7579 function SVGAnimationElement(es) {
7583 SVGElement.apply(this);
7584 /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
7585 *styleのsetPropertyメソッドを無効化させておく必要がある
7587 this.style.setProperty = function(){};
7589 /*readonly SVGElement*/ this.targetElement;
7590 /*それぞれのプロパティは、_を除いた属性に対応している*/
7591 this._begin = this._end = this._repeatCount = this._repeatDur = this._dur = this._resatrt = null;
7592 this._currentFrame = 0;
7593 /*_isRepeatと_numRepeatは繰り返し再生のときに使う。なお、後者は現在のリピート回数*/
7594 this._isRepeat = false;
7595 this._numRepeat = 0;
7596 /*_isStartプロパティは一度は起動したかどうか*/
7597 this._isStarted = false;
7598 /*_startと_finishプロパティはミリ秒数のリストを収納する。
7599 *_startはアニメ開始時の秒数リスト。_finishはアニメ終了時の秒数のリスト。
7600 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
7601 *_startingプロパティは現在アニメーションでの開始時刻。getSartTimeメソッドで使う
7603 this._start = this._finish = this._starting = null;
7604 /*_activeDurプロパティは現時点でのアニメーションの活動期間*/
7605 this._activeDur = 0;
7606 this._from = this._to = this._values = this._by = null;
7607 this._keyTimes = null;
7608 this.addEventListener("beginEvent", function(evt) {
7610 var tar = evt.target,
7611 begin = tar.getStartTime(),
7613 dur = tar._getOffset(durv),
7616 td = tar._repeatDur,
7617 tc = tar._repeatCount,
7620 for (var i=0, eli=end.length;i<eli;++i) {
7621 /*endの配列(ソース済み)からbeginに最も近い数値を選ぶ*/
7622 if (end[i] >= begin) {
7628 /*イベント待ちの場合は、endの値を、indefiniteとみなす。参照: http://www.w3.org/TR/smil-animation/#ComputingActiveDur
7630 * 3.3.4. Computing the active duration
7632 * If the value of end cannot be resolved (e.g. when it is event-based),
7633 * the value is considered to be "indefinite" for the purposes of evaluating the active duration.
7638 /*Activate Duration (活性持続時間と呼ぶことにする)を計算
7640 *http://www.w3.org/TR/smil-animation/#ComputingActiveDur
7641 *3.3.4. Computing the active duration
7643 if ((td === "indefinite") || (tc === "indefinite")) {
7647 /*活性持続時間が不定(indefinite)なので、強制的にアニメを終了させる*/
7650 } else if (durv === "indefinite") {
7652 /*活性持続時間が不定(indefinite)なので、強制的にアニメを終了させる*/
7654 } else if (tc && !endv) {
7655 ac = tar._getOffset(td);
7656 } else if (!tc && endv) {
7659 ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
7661 } else if (durv && !td && !tc && !endv) {
7663 } else if (durv && !td && tc && !endv) {
7665 } else if (durv && td && !tc && !endv) {
7666 ac = tar._getOffset(td);
7667 } else if (durv && !td && !tc && endv) {
7668 ac = (dur > (end - begin)) ? dur : (end - begin);
7669 } else if (durv && td && tc && !endv) {
7670 ac = (+tc*dur > tar._getOffset(td)) ? +tc*dur : tar._getOffset(td);
7671 } else if (durv && td && tc && endv) {
7672 ac = (+tc*dur > Math.min(+td, (end-begin))) ? +tc*dur : Math.min(tar._getOffset(td), (end - begin));
7673 } else if (durv && td && !tc && endv) {
7674 ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
7675 } else if (durv && !td && tc && endv) {
7676 ac = (+tc*dur > (end - begin)) ? +tc*dur : (end - begin)
7679 tar.endElementAt(1);
7680 throw new DOMException(DOMException.INVALID_STATE_ERR);
7682 if ((ac || (ac === 0)) && isFinite(ac)) {
7683 /*endの値がすでにある場合は、二重指定を避ける*/
7684 endv || tar.endElementAt(ac);
7685 tar._activeDur = ac;
7687 tar = begin = dur = durv = end = endv= td = tc = ac = void 0;
7689 this.addEventListener("DOMAttrModified", function(evt){
7690 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7693 var tar = evt.target,
7694 name = evt.attrName,
7695 evtv = evt.newValue;
7696 if (name === "begin") {
7697 tar._begin = evtv.replace(/\s+/g, "").split(";"); //空白は取り除く
7698 } else if (name === "end") {
7699 tar._end = evtv.replace(/\s+/g, "").split(";");
7700 } else if (name === "dur") {
7702 } else if (name === "repeatCount") {
7703 tar._repeatCount = evtv;
7704 tar._isRepeat = true;
7705 } else if (name === "repeatDur") {
7706 tar._repeatCount = evtv;
7707 tar._isRepeat = true;
7708 } else if (name === "from") {
7710 } else if (name === "to") {
7712 } else if (name === "values") {
7713 tar._values = evtv.split(";");
7714 } else if (name === "by") {
7716 } else if (name === "keyTimes") {
7717 var s = evtv.split(";");
7718 tar._keyTimes = []; //_keyTimesプロパティを初期化
7719 for (var i=0;i<s.length;++i) {
7720 tar._keyTimes[i] = parseFloat(s[i]);
7723 } else if (name === "restart") {
7724 tar._restart = evtv;
7726 evt = evtv = void 0;
7728 this.addEventListener("DOMNodeInserted", function(evt){
7729 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7732 var tar = evt.target;
7733 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7734 var tar = evt.target;
7735 /*以降の場合分けルールに関しては、下記の仕様を参照
7736 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
7739 } else if (tar._from && tar._to) {
7740 tar._values = [tar._from, tar._to];
7741 } else if (tar._from && tar._by) {
7742 var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
7743 tar._values = [tar._from, n+tanni[0]];
7744 } else if (tar._to) {
7745 tar._values = [null, tar._to];
7746 } else if (tar._by) {
7747 tar._values = [null, null, tar._by];
7748 } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
7749 /*アニメーションの効果が出ないように調整する
7752 *>if none of the from, to, by or values attributes are specified, the animation will have no effect
7753 *「3.2.2. Animation function values」より引用
7754 *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
7758 /*begin属性とend属性を処理する*/
7760 timing = function(val, name, offset) {
7761 /*timing関数は時間のタイミングをidとeventと、clock-value(offset)に分割して処理していく
7762 *まず、idを検出するためのsearcIdローカル関数を作る
7764 var searchId = function () {
7765 var n = val.indexOf(".");
7766 if ((n > 0) && (/[a-z]/i).test(val.charAt(n+1))) { //. (dot)の後がアルファベットならば
7767 return (val.slice(0, n));
7774 *W3CのSMIl AnimationのTimingモデルは7パターンがあるので、場合分けする
7776 if (isFinite(parseFloat(val))) { //1) offset-valueの場合
7778 } else if (val.indexOf("repeat(") > -1) { //2) repeat-valueの場合
7779 var inte = parseFloat(val.slice(7)),
7780 ds = (function(that, name, offset) {
7781 return function (evt) {
7782 if (inte === evt.target._numRepeat) {
7786 })(that, name, offset),
7789 that.ownerDocument.getElementById(id).addEventListener("repeatEvent", ds);
7791 that.addEventListener("repeatEvent", ds);
7793 } else if (/\.(begin|end)/.test(val)) { //3) syncbase-valueの場合
7796 var ds = (function(that, name, offset) {
7797 return function (evt) {
7800 })(that, name, offset),
7802 /\.(begin|end)/.test(val); //RegExp.$1のために、もう一度する必要がある
7803 if (RegExp.$1 === "begin") {
7805 } else if (RegExp.$1 === "end") {
7808 that.ownerDocument.getElementById(id).addEventListener(ev, ds, false);
7810 } else if (val.indexOf("wallclock(") === 0) { //4) wallclock-valueの場合
7812 } else if (val === "indefinite") { //5) indefiniteの場合
7813 } else if (val.indexOf("accesskey(") > -1) { //6) accesskey-valueの場合
7815 } else { //7) event-valueの場合
7817 var ds = (function(that, name, offset) {
7818 return function (evt) {
7821 })(that, name, offset);
7822 if (id && val.match(/\.([a-z]+)/i)) {
7823 that.ownerDocument.getElementById(id).addEventListener(RegExp.$1, ds);
7825 that.targetElement.addEventListener(val.match(/^[a-z]+/i)[0], ds)
7828 val = searchId = id = void 0;
7831 for (var i=0,tli=tar._begin.length;i<tli;++i) {
7832 timing(tar._begin[i], "beginElementAt", tar._getOffset(tar._begin[i]));
7835 tar.beginElementAt(0);
7838 for (var i=0,tli=tar._end.length;i<tli;++i) {
7839 timing(tar._end[i], "endElementAt", tar._getOffset(tar._end[i]));
7843 if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7844 tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").slice(1))
7846 tar.targetElement = tar.parentNode;
7854 SVGAnimationElement.prototype = new SVGElement();
7855 /*以下のメソッド(beginElementなど)については、
7856 *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
7858 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
7859 var ttd = this.ownerDocument,
7860 evt = ttd.createEvent("TimeEvents");
7861 this._starting = ttd.documentElement.getCurrentTime(); //getStartTimeメソッドで使う開始時刻
7862 if (this._isStarted && ((this._restart === "never")
7863 || ((this._restart === "whenNotActive") && (this.getCurrentTime() > 0)))) {
7864 return; //restart属性の設定により、再起動させないようにする
7866 if (this.getCurrentTime() > 0) {
7867 /*アニメーションの最中で、beginEventが起きるときは、endEventが前もって起こされる。SVG1.1の仕様を参照
7869 * 19.4.2 Interface TimeEvent
7870 * 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.
7872 * http://www.w3.org/TR/SVG/animate.html#InterfaceTimeEvent
7877 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
7878 this.dispatchEvent(evt);
7879 /*新しくリストの頭を更新して、別の値も実行させるようにする*/
7880 this._start && this._start.shift();
7881 this._isStarted = true;
7884 /*void*/ SVGAnimationElement.prototype.endElement = function() {
7885 var ttd = this.ownerDocument,
7886 evt = ttd.createEvent("TimeEvents");
7887 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
7888 this.dispatchEvent(evt);
7889 this._finish && this._finish.shift();
7890 this._currentFrame = 0;
7892 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
7893 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
7894 start = this._start || [];
7895 for (var i=0,sli=start.length;i<sli;++i) {
7896 if (start[i] === (offset+ntc)) {
7897 ntc = start = offset = void 0;
7901 start.push(offset + ntc);
7902 start.sort(function(a, b) {
7905 this._start = start;
7906 ntc = start = offset = void 0;
7908 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
7909 var ntc = this.ownerDocument.documentElement.getCurrentTime(),
7910 fin = this._finish || [];
7911 for (var i=0,fli=fin.length;i<fli;++i) {
7912 if (fin[i] === (offset+ntc)) {
7913 ntc = fin = offset = void 0;
7917 fin.push(offset + ntc);
7918 fin.sort(function(a, b) {
7922 ntc = start = offset = void 0;
7924 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
7925 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?$/;
7926 SVGAnimationElement.prototype._unit = {
7932 * どれだけズレの時間があるかを計測するメソッド
7933 *tに数値が使われていないときは0を返す
7934 *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
7935 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
7936 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
7937 ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
7939 SVGAnimationElement.prototype._getOffset = function(/*string*/ val) {
7940 var t = null, //tは最初の数値
7941 n = [val.indexOf("+"), val.indexOf("-")],
7944 s = val.slice(n[0]);
7946 } else if (n[1] > -1) {
7947 s = val.slice(n[1]);
7951 t = parseFloat(val);
7954 if (/\d+\:(\d\d)\:([\d\.]+)$/.test(s)) { //Full-Clock-Valueの場合
7955 t = (t*3600 + parseInt(RegExp.$1, 10)*60 + parseFloat(RegExp.$2)) * 1000;
7956 } else if (/\d\d\:([\d\.]+)$/.test(s)) {
7957 t = (t*60 + parseFloat(RegExp.$1)) * 1000;
7958 } else if (/(h|min|s)$/.test(s)) {
7959 t *= this._unit[RegExp.$1];
7969 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
7970 if (this._starting || (this._starting === 0)) {
7971 return (this._starting);
7973 throw new DOMException(DOMException.INVALID_STATE_ERR);
7976 /*getCurrentTimeメソッド
7978 *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
7980 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
7981 return (this._currentFrame * 125 * 0.8);
7983 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
7984 if (!this._dur && !this._finish && (this._dur === "indefinite")) {
7985 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
7987 return (this._getOffset(this._dur));
7990 //raises( DOMException );
7994 start : function() {
7995 if (NAIBU.Clip.length > 0) {
7996 screen.updateInterval = 42; //24fpsとして描画処理
7997 window.onscroll = function () {
7998 screen.updateInterval = 0;
7999 screen.updateInterval = 42;
8001 NAIBU.stop = setInterval( (function() {
8003 var ntc = NAIBU.Time.currentFrame,
8005 s = ntc * 100; //フレーム数ntcをミリ秒数sに変換 (100 = 125 * 0.8)
8006 if (ntc > NAIBU.Time.Max) {
8007 clearInterval(NAIBU.stop);
8009 nc[0] && nc[0].ownerDocument.documentElement.setCurrentTime(s);
8010 for (var i=0,ncli=nc.length;i<ncli;++i) {
8015 var sti = nci._start[0];
8016 if (sti && nci._finish && (sti === nci._finish[0])) { //アニメーションの途中ならば
8019 if ((sti || (sti === 0)) && (s1 <= sti) && (sti < s)) {
8024 if (nci._isRepeat && (nci.getCurrentTime() >= nci.getSimpleDuration()*nci._numRepeat)) {
8026 var ttd = nci.ownerDocument,
8027 evt = ttd.createEvent("TimeEvents");
8029 evt.initTimeEvent("repeatEvent", ttd.defaultView, nci._numRepeat);
8030 nci.dispatchEvent(evt);
8033 if (nci._finish && (nci.getCurrentTime() !== 0)) {
8034 var fti = nci._finish[0];
8035 if ((fti || (fti === 0)) && (s1 <= fti) && (fti <= s)) {
8041 ++nci._currentFrame;
8045 ++NAIBU.Time.currentFrame;
8046 ntc = nc = s = nci = s1 = s2 = void 0;
8054 window.onscroll = function () {
8055 screen.updateInterval = 0;
8056 window.onscroll = NAIBU.emptyFunction;
8063 function SVGAnimateElement(){
8064 SVGAnimationElement.apply(this);
8065 /*NAIBU.Clipについては、NAIBU.Timeで使う
8066 *くわしくはNAIBU.Time.start関数のコードを参照
8068 NAIBU.Clip[NAIBU.Clip.length] = this;
8070 *機械が理解できる形で保管されているvalueの値の配列リスト
8072 this._valueList = [];
8073 this._isDiscrete = false;
8074 this.addEventListener("DOMAttrModified", function(evt){
8075 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8078 if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
8079 evt.target._isDiscrete = true;
8082 this.addEventListener("DOMNodeInserted", function(evt){
8083 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8086 var tar = evt.target;
8087 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8088 var tar = evt.target,
8089 attrName = tar.getAttributeNS(null, "attributeName"),
8090 ttr = tar.targetElement,
8091 tta = ttr[attrName];
8092 /*tar.valuesのリスト: ["12px", "13px"]
8093 *tar._valueList: [(new SVGPoint()), (new SVGPoint())]
8094 * tar.valuesを機械が理解できるように変換したものがtar._valueList
8095 *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
8097 var vi = ttr.cloneNode(false);
8098 if (!tar._values[0]) { //to属性か、by属性が設定されている場合
8099 var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
8100 tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
8101 if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
8102 var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
8103 tar._values[1] = v2 + tanni[0];
8105 v2 = tanni = void 0;
8108 if (("animatedPoints" in ttr) && (attrName === "points")) {
8109 ttr.animatedPoints = vi.points;
8110 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8111 var vir = ttr.cloneNode(false);
8113 vir.setAttributeNS(null, "points", tav[i]);
8114 tar._valueList[tar._valueList.length] = vir.points;
8117 tta.animVal = vi[attrName].baseVal;
8118 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8119 var vir = ttr.cloneNode(false); //仮の要素
8121 vir.setAttributeNS(null, attrName, tav[i]);
8122 tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
8124 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8125 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8126 if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
8127 tar._valueList[i] = new SVGPaint();
8128 tar._valueList[i].setPaint(1, null, tav[i], null)
8130 tar._valueList[i] = parseFloat(tav[i]);
8133 } else if (("normalizedPathSegList" in ttr) && (attrName === "d")) {
8134 ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
8135 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8136 var vir = ttr.cloneNode(false);
8138 vir.setAttributeNS(null, "d", tav[i]);
8139 tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
8145 evt = tta = vir = vi = void 0;
8148 this.addEventListener("beginEvent", function(evt) {
8149 var _tar = evt.target,
8150 attrName = _tar.getAttributeNS(null, "attributeName"),
8151 newAttr = _tar.targetElement.attributes.getNamedItemNS(null, attrName),
8152 ttr = _tar.targetElement,
8153 tta = ttr[attrName];
8154 _tar._frame = function() {
8156 d = tar._isRepeat ? tar.getSimpleDuration() : tar._activeDur,
8157 n = tar._valueList.length-1,
8158 tg = tar.getCurrentTime();
8159 tar._activeDur || (d = 0);
8161 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8162 if (tar._isDiscrete) {
8163 ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
8165 var ii = Math.floor((tg*n) / d);
8166 if (ii === n) { //iiが境い目のときは、n-2を適用
8172 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
8174 * 参照:アニメーションサンドイッチモデル
8175 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
8176 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
8178 var evt = tar.ownerDocument._domnodeEvent();
8179 if (tar._keyTimes) {
8180 var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8181 var ti = tar._keyTimes[ii];
8183 var di = d / n; //keyTimesがなければ均等に時間を配分しておく
8186 if (("animatedPoints" in ttr) && (attrName === "points")) {
8187 var base = ttr.points;
8188 ttr.points = ttr.animatedPoints;
8189 ttr.dispatchEvent(evt);
8190 ttr.animatedPoints = ttr.points;
8193 var base = tta.baseVal, tanim = tta.animVal;
8194 var v1 = tar._valueList[ii].value;
8195 /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8196 * 3.4.2 Specifying the simple animation function f(t)
8197 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8199 if (!tar._isDiscrete) {
8200 var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
8204 tanim.newValueSpecifiedUnits(base.unitType, v);
8205 tta.baseVal = tanim;
8207 ttr.dispatchEvent(evt);
8208 /*変化値はanimValプロパティに収納しておき、
8209 *変化する前の、元の値はbaseValプロパティに再び収納しておく
8211 tta.animVal = tta.baseVal;
8214 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8216 var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
8217 if (!tar._isDiscrete) {
8218 var v = v1 + (v2-v1) * (tg-ti*d) / di;
8222 } else if (("normalizedPathSegList" in ttr) && (attrName === "d")) {
8223 var base = ttr.normalizedPathSegList;
8224 ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
8225 ttr.dispatchEvent(evt);
8226 ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
8227 ttr.normalizedPathSegList = base;
8229 evt = tar = v1 = v2 = v = d = n = ii = tg = void 0;
8233 this.addEventListener("endEvent", function(evt) {
8234 var tar = evt.target,
8235 fill = tar.getAttributeNS(null, "fill");
8236 if (!fill || (fill === "remove")) {
8237 var evt = tar.ownerDocument._domnodeEvent();
8238 tar.targetElement.dispatchEvent(evt);
8240 tar._frame && tar._frame();
8244 this.addEventListener("repeatEvent", function(evt) {
8245 var tar = evt.target;
8249 SVGAnimateElement.prototype = new SVGAnimationElement(1);
8251 function SVGSetElement(){
8252 SVGAnimationElement.apply(this);
8253 NAIBU.Clip[NAIBU.Clip.length] = this;
8255 this.addEventListener("DOMAttrModified", function(evt) {
8256 var tar = evt.target, name = evt.attrName;
8257 if (name === "to") {
8258 tar._to = evt.newValue;
8260 tar = name = void 0;
8262 this.addEventListener("beginEvent", function(evt) {
8263 var tar = evt.target;
8264 tar._currentFrame = 1; //これがないと、NAIBU.stopの内部の処理の都合上、endEventが発動しない。
8265 if (tar.targetElement) {
8266 var attrName = tar.getAttributeNS(null, "attributeName"),
8267 newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
8268 tta = tar.targetElement[attrName];
8269 if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
8270 /*前もって、スタイルシートの値を取得しておいて、endEventの際に使う*/
8271 tar._prestyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "").getPropertyValue(attrName);
8272 var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
8273 style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
8276 var base = tta.baseVal;
8277 if (base instanceof SVGLength) {
8278 tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
8279 } else if (base instanceof SVGRect) {
8280 tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
8282 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
8284 * 参照:アニメーションサンドイッチモデル
8285 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
8286 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
8288 var evt = tar.ownerDocument.createEvent("MutationEvents");
8289 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
8290 tar.targetElement.dispatchEvent(evt);
8292 /*変化値はanimValプロパティに収納しておき、
8293 *変化する前の、元の値はbaseValプロパティに再び収納しておく
8295 tta.animVal = tta.baseVal;
8299 evt = tar = attrName = void 0;
8301 this.addEventListener("endEvent", function(evt) {
8302 var tar = evt.target,
8303 fill = tar.getAttributeNS(null, "fill");
8304 if (!fill || (fill === "remove")) {
8305 var attrName = tar.getAttributeNS(null, "attributeName"),
8306 style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
8307 if (tar._prestyle) { //スタイルシートの変更ならば
8308 style.setProperty(attrName, tar._prestyle, null);
8310 var evtt = tar.ownerDocument._domnodeEvent();
8311 tar.targetElement.dispatchEvent(evtt);
8313 attrName = style = evtt = void 0;
8315 tar = fill = void 0;
8317 this.addEventListener("repeatEvent", function(evt) {
8318 var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8322 SVGSetElement.prototype = new SVGAnimationElement(1);
8324 function SVGAnimateMotionElement(){
8325 SVGAnimationElement.apply(this);
8326 NAIBU.Clip[NAIBU.Clip.length] = this;
8327 this.addEventListener("DOMAttrModified", function(evt){
8328 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8331 var tar = evt.target,
8332 name = evt.attrName;
8333 if (name === "path") {
8334 var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
8335 d.setAttributeNS(null, "d", evt.newValue);
8340 this.addEventListener("DOMNodeInserted", function(evt){
8341 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8344 var tar = evt.target;
8345 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8349 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8352 vlist[i] = [+ti[0], +ti[1]];
8354 tar._valueList = vlist;
8358 this.addEventListener("beginEvent", function(evt) {
8359 var tar = evt.target,
8360 trans = tar.targetElement.transform;
8361 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8364 trans.animVal = new SVGTransformList();
8365 if (trans.baseVal.numberOfItems !== 0) {
8366 trans.baseVal.consolidate();
8367 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8369 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8371 tar._frame = function() {
8374 tgsd = _tar._isRepeat ? _tar.getSimpleDuration() : _tar._activeDur,
8376 tg = _tar.getCurrentTime(),
8378 _tar._activeDur || (d = 0);
8383 if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
8384 var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
8385 p = tpn.getPointAtLength(st),
8386 trans = _tar.targetElement.transform;
8387 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8388 var base = trans.baseVal;
8389 trans.baseVal = trans.animVal;
8390 _tar.targetElement._cacheMatrix = null;
8391 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8392 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8393 _tar.targetElement.dispatchEvent(evtt);
8394 trans.baseVal = base;
8395 evtt = base = trans = st = p = void 0;
8396 } else if (tar._valueList) {
8397 var total = 0, //totalは総距離
8398 st = 0, //stは現在にいたるまでの距離
8399 tav = tar._valueList,
8401 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8402 ii = Math.floor((tg*n) / d);
8403 if (ii === n) { //iiが境い目のときは、n-2を適用
8409 for (var i=1, tvli=tav.length;i<tvli;i+=2) {
8410 total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
8412 for (var i=1;i<ii;i+=2) {
8413 st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
8415 var p = tar.ownerDocument.documentElement.createSVGPoint(),
8416 trans = _tar.targetElement.transform;
8417 st = (st / total) * d;
8418 p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
8419 p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
8420 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8421 var base = trans.baseVal;
8422 trans.baseVal = trans.animVal;
8423 _tar.targetElement._cacheMatrix = void 0;
8424 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8425 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8426 _tar.targetElement.dispatchEvent(evtt);
8427 trans.baseVal = base;
8428 evtt = base = trans = st = p = i = void 0;
8431 evt = trans = tpn = tgsd = void 0;
8433 this.addEventListener("endEvent", function(evt) {
8434 var tar = evt.target,
8435 trans = tar.targetElement.transform,
8436 fill = tar.getAttributeNS(null, "fill"),
8437 tavli = tar._valueList,
8439 if (!fill || (fill === "remove")) {
8440 /*アニメが開始される前の状態に戻す*/
8441 var evtt = tar.ownerDocument._domnodeEvent();
8442 tar.targetElement.dispatchEvent(evtt);
8443 tar._frame && tar._frame();
8445 /*_frame関数で終了位置に会わないことがあるので、以下の処理で位置を修正*/
8446 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(tavli[tavli.length-1][0], tavli[tavli.length-1][1]);
8448 trans.baseVal = trans.animVal;
8449 var evtt = tar.ownerDocument._domnodeEvent();
8450 tar.targetElement.dispatchEvent(evtt);
8454 evt = evtt = trans = fill = tar = tavli = tb = void 0;
8456 this.addEventListener("repeatEvent", function(evt) {
8457 var tar = evt.target;
8461 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
8463 function SVGMPathElement() /* :
8466 SVGExternalResourcesRequired*/ {
8467 SVGElement.apply(this);
8468 SVGURIReference.apply(this);
8471 SVGMPathElement.prototype = new SVGElement();
8473 function SVGAnimateColorElement() {
8474 SVGAnimationElement.apply(this);
8475 NAIBU.Clip[NAIBU.Clip.length] = this;
8476 this._valueList = [];
8477 this.addEventListener("DOMNodeInserted", function(evt){
8478 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8481 var tar = evt.target;
8482 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8483 var tar = evt.target,
8484 attrName = tar.getAttributeNS(null, "attributeName"),
8485 ttr = tar.targetElement,
8486 fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
8488 if (!tar._values[0]) {
8489 tar._values[0] = fstyle.getPropertyValue(attrName);
8491 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8492 var to = new SVGColor();
8493 if (tar._values[i] === "currentColor") {
8494 to.setRGBColor(fstyle.getPropertyValue("color") || "black");
8495 } else if (tar._values[i] === "inherit") {
8496 /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
8497 css = fstyle.getPropertyCSSValue(attrName);
8498 n = css.cssValueType;
8499 css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
8500 to = fstyle.getPropertyCSSValue(attrName);
8501 css.cssValueType = n;
8503 to.setRGBColor(tar._values[i]);
8505 tar._valueList[tar._valueList.length] = to;
8508 tar = ttr = fstyle = css = n = attrName = void 0;
8511 this.addEventListener("beginEvent", function(evt) {
8512 var tar = evt.target,
8513 attrName = tar.getAttributeNS(null, "attributeName"),
8514 style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
8515 fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8516 tar._frame = function() {
8518 /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8519 * 3.4.2 Specifying the simple animation function f(t)
8520 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8522 var d = _tar._isRepeat ? _tar.getSimpleDuration() : _tar._activeDur,
8523 n = _tar._valueList.length - 1,
8524 tg = _tar.getCurrentTime(),
8526 _tar._activeDur || (d = 0);
8528 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8529 ii = Math.floor((tg*n) / d);
8530 if (ii === n) { //iiが境い目のときは、n-2を適用
8536 if (tar._keyTimes) {
8537 di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8538 ti = tar._keyTimes[ii];
8540 di = d / n; //keyTimesがなければ均等に時間を配分しておく
8543 var fc = _tar._valueList[ii].rgbColor,
8544 tc = _tar._valueList[ii+1].rgbColor,
8545 durd = (tg-ti*d) / di,
8546 num = CSSPrimitiveValue.CSS_NUMBER,
8547 fr = fc.red.getFloatValue(num),
8548 fg = fc.green.getFloatValue(num),
8549 fb = fc.blue.getFloatValue(num),
8550 r = fr + (tc.red.getFloatValue(num) - fr) * durd,
8551 g = fg + (tc.green.getFloatValue(num) - fg) * durd,
8552 b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
8553 style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
8554 _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = ii = void 0;
8558 this.addEventListener("endEvent", function(evt) {
8559 var tar = evt.target,
8560 fill = tar.getAttributeNS(null, "fill");
8561 if (!fill || (fill === "remove")) {
8562 var evtt = tar.ownerDocument._domnodeEvent();
8563 tar.targetElement.dispatchEvent(evtt);
8564 tar._frame && tar._frame();
8567 evt = evtt = tar = fill = void 0;
8569 this.addEventListener("repeatEvent", function(evt) {
8570 var tar = evt.target;
8574 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
8576 function SVGAnimateTransformElement() {
8577 SVGAnimationElement.apply(this);
8578 NAIBU.Clip[NAIBU.Clip.length] = this;
8579 this.addEventListener("beginEvent", function(evt) {
8580 var tar = evt.target, trans = tar.targetElement.transform;
8581 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8584 trans.animVal = new SVGTransformList();
8585 if (trans.baseVal.numberOfItems !== 0) {
8586 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8588 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8590 this.addEventListener("endEvent", function(evt) {
8591 var tar = evt.target,
8592 fill = tar.getAttributeNS(null, "fill");
8593 if (!fill || (fill === "remove")) {
8594 var evtt = tar.ownerDocument._domnodeEvent();
8595 tar.targetElement.dispatchEvent(evtt);
8596 tar._frame && tar._frame();
8599 evt = evtt = tar = fill = void 0;
8601 this.addEventListener("repeatEvent", function(evt) {
8602 var tar = evt.target;
8606 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
8608 function SVGFontElement() /*:
8610 SVGExternalResourcesRequired,
8612 SVGElement.apply(this);
8613 /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
8614 /*boolean or number*/ this._isExternal = 0;
8615 this.addEventListener("DOMNodeInserted", function(evt){
8616 var tar = evt.target;
8617 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8620 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8621 var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
8622 var nefunc = function(evt){
8623 var svg = evt.target;
8625 var familyName = fontFace.getAttributeNS(null, "font-family");
8626 var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
8627 for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
8628 var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
8629 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8630 NAIBU._noie_createFont(ti, _tar, true);
8633 evt = tar = svg = curt = textElments = svgns = _tar = void 0;
8635 if (!fontFace.__isLinked || tar._isExternal) {
8636 tar.ownerDocument.documentElement._svgload_limited = 0;
8637 tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
8643 SVGFontElement.prototype = new SVGElement();
8645 function SVGGlyphElement() /*:
8648 SVGElement.apply(this);
8651 SVGGlyphElement.prototype = new SVGElement();
8653 function SVGMissingGlyphElement() /*:
8656 SVGElement.apply(this);
8659 SVGMissingGlyphElement.prototype = new SVGElement();
8661 function SVGHKernElement() {
8662 SVGElement.apply(this);
8665 SVGHKernElement.prototype = new SVGElement();
8667 function SVGVKernElement() {
8668 SVGElement.apply(this);
8671 SVGVKernElement.prototype = new SVGElement();
8673 function SVGFontFaceElement() {
8674 SVGElement.apply(this);
8675 /*boolean(or number)*/ this._isLinked = 0;
8676 this.addEventListener("DOMNodeInserted", function(evt){
8677 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8678 if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
8679 evt.currentTarget._isLinked = 1;
8686 SVGFontFaceElement.prototype = new SVGElement();
8688 function SVGFontFaceSrcElement() {
8689 SVGElement.apply(this);
8692 SVGFontFaceSrcElement.prototype = new SVGElement();
8694 function SVGFontFaceUriElement() {
8695 SVGElement.apply(this);
8696 this.addEventListener("DOMNodeInserted", function(evt){
8697 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8700 evt.target.ownerDocument.documentElement._svgload_limited--
8701 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
8703 this.addEventListener("S_Load", function(evt){
8704 var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
8705 if (tpp.localName === "defs") {
8706 tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
8708 tar._instance._isExternal = 1;
8709 tpp.parentNode.appendChild(tar._instance);
8710 evt = tar = tpp = void 0;
8712 SVGURIReference.apply(this);
8715 SVGFontFaceUriElement.prototype = new SVGElement();
8717 function SVGFontFaceFormatElement() {
8718 SVGElement.apply(this);
8721 SVGFontFaceFormatElement.prototype = new SVGElement();
8723 function SVGFontFaceNameElement() {
8724 SVGElement.apply(this);
8727 SVGFontFaceNameElement.prototype = new SVGElement();
8729 function SVGDefinitionSrcElement() {
8730 SVGElement.apply(this);
8733 SVGDefinitionSrcElement.prototype = new SVGElement();
8735 function SVGMetadataElement() {
8736 SVGElement.apply(this);
8739 SVGMetadataElement.prototype = new SVGElement();
8741 function SVGForeignObjectElement() /*:
8745 SVGExternalResourcesRequired,
8748 events::EventTarget*/ {
8749 SVGElement.apply(this);
8750 var sl = SVGAnimatedLength;
8751 /*readonly SVGAnimatedLength*/ this.x = new sl();
8752 /*readonly SVGAnimatedLength*/ this.y = new sl();
8753 /*readonly SVGAnimatedLength*/ this.width = new sl();
8754 /*readonly SVGAnimatedLength*/ this.height = new sl();
8758 SVGForeignObjectElement.prototype = new SVGElement();
8761 /*SVGの要素マッピング(DOMでは定められていないが、必須)
8762 *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
8763 *SIEでは軽量化のために、マッピングを用いた
8765 DOMImplementation["http://www.w3.org/2000/svg"] = {
8766 Document: SVGDocument,
8769 path: NAIBU.SVGPathElement,
8770 title: SVGTitleElement,
8771 desc: SVGDescElement,
8772 defs: SVGDefsElement,
8773 linearGradient: SVGLinearGradientElement,
8774 radialGradient: SVGRadialGradientElement,
8775 stop: SVGStopElement,
8776 rect: SVGRectElement,
8777 circle: SVGCircleElement,
8778 ellipse: SVGEllipseElement,
8779 polyline: SVGPolylineElement,
8780 polygon: SVGPolygonElement,
8781 text: SVGTextElement,
8782 tspan: SVGTSpanElement,
8783 image: SVGImageElement,
8784 line: SVGLineElement,
8786 altGlyphDef: SVGAltGlyphDefElement,
8787 altGlyph: SVGAltGlyphElement,
8788 altGlyphItem: SVGAltGlyphItemElement,
8789 animateColor: SVGAnimateColorElement,
8790 animate: SVGAnimateElement,
8791 animateMotion: SVGAnimateMotionElement,
8792 animateTransform:SVGAnimateTransformElement,
8793 clipPath: SVGClipPathElement,
8794 colorProfile: SVGColorProfileElement,
8795 cursor: SVGCursorElement,
8796 definitionSrc: SVGDefinitionSrcElement,
8797 feBlend: SVGFEBlendElement,
8798 feGaussianBlur: SVGFEGaussianBlurElement,
8799 filter: SVGFilterElement,
8800 font: SVGFontElement,
8801 "font-face": SVGFontFaceElement,
8802 "font-face-format":SVGFontFaceFormatElement,
8803 "font-face-name":SVGFontFaceNameElement,
8804 "font-face-src": SVGFontFaceSrcElement,
8805 "font-face-uri": SVGFontFaceUriElement,
8806 foreignObject: SVGForeignObjectElement,
8807 glyph: SVGGlyphElement,
8808 glyphRef: SVGGlyphRefElement,
8809 hkern: SVGHKernElement,
8810 marker: SVGMarkerElement,
8811 mask: SVGMaskElement,
8812 metadata: SVGMetadataElement,
8813 missingGlyph: SVGMissingGlyphElement,
8814 mpath: SVGMPathElement,
8815 script: SVGScriptElement,
8817 style: SVGStyleElement,
8818 "switch": SVGSwitchElement,
8819 "symbol": SVGSymbolElement,
8820 textPath: SVGTextPathElement,
8821 tref: SVGTRefElement,
8823 view: SVGViewElement,
8824 vkern: SVGVKernElement,
8825 pattern: SVGPatternElement
8828 NAIBU._fontSearchURI = function(evt){
8829 var doc = evt.target.ownerDocument;
8830 var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
8831 for (var i=0;i<tsrc.length;++i) {
8832 var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
8833 ids = src.split(":")[1],
8834 xmlhttp = NAIBU.xmlhttp;
8835 xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
8836 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
8837 xmlhttp.onreadystatechange = function() {
8838 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
8839 var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
8840 NAIBU._font({document:doce, docu:doc, id:ids});
8841 xmlhttp = doc = doce = void 0;
8847 /*_font関数は、SVGFontで使う*/
8848 NAIBU._font = function (data) {
8849 var doc = data.document, svgns = "http://www.w3.org/2000/svg";
8850 //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
8851 var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
8852 var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
8853 if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
8854 var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
8855 for (var i=0,tli=textElements.length;i<tli;++i) {
8856 var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
8857 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8858 NAIBU._noie_createFont(ti, font, false);
8862 doc = data = void 0;
8864 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
8865 var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
8866 svgns = "http://www.w3.org/2000/svg",
8867 //isTategakiは縦書きならば真
8868 isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
8869 horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
8870 node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
8871 em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
8872 advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
8873 dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
8874 dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
8875 fontSize = parseFloat(style.getPropertyValue("font-size")),
8877 ds = false, npdlist = ["fill",
8883 "stroke-miterlimit",
8888 if (/a/[-1] === 'a') { //Firefoxならば
8890 } else if (isMSIE || isTategaki) {
8899 if (data !== void 0) { //dataがある場合
8900 var advanceX = [], glyphData = [];
8901 for (var i=0,gli=glyphs.length;i<gli;++i) {
8902 var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
8903 var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
8905 if (orientation === "h") {
8909 isOrientationAttribute = false;
8911 if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
8912 //indexは該当する文字が何番目にあるかの数字
8913 var index = data.indexOf(unicode);
8914 while (index > -1) {
8915 advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
8916 glyphData[index] = glyph.getAttributeNS(null, "d");
8917 index = data.indexOf(unicode, index+1);
8921 for (var i=0,adv=0;i<data.length;++i) {
8922 if (advanceX[i] !== void 0) { //配列に含まれていれば
8923 var path = ti.ownerDocument.createElementNS(svgns, "path");
8924 //advance、すなわち字幅の長さ分、ずらしていく
8925 var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
8928 for (var j=0;j<npdlist.length;++j){
8929 var nj = npdlist[j],
8930 tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
8931 if (nj === "stroke-width") {
8932 tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
8936 path.setAttributeNS(null, nj, tg);
8940 var y= dy + adv*fe, x = dx;
8941 if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
8942 var fms = fontSize / Math.SQRT2;
8950 matrix.e = dx + adv*fe;
8953 path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
8954 path.setAttributeNS(null, "d", glyphData[i]);
8955 ti.parentNode.insertBefore(path, ti);
8960 adv = advanceX = glyphData = void 0;
8961 } else if ("tspan|a".indexOf(node.localName) > -1){
8962 NAIBU._noie_createFont(node, font, isMSIE);
8964 node = node.nextSibling;
8967 var style = ti.ownerDocument.getOverrideStyle(ti, null);
8968 style.setProperty("visibility", "hidden");
8971 ti.setAttributeNS(null, "opacity", "0");
8974 data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
8977 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
8978 *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
8981 var s = new CSSStyleDeclaration(),
8987 for (var i in CSS2Properties) {
8988 if(CSS2Properties.hasOwnProperty(i)) {
8989 t = i.replace(regAZ, "-");
8991 u = "-" +RegExp.$1.toLowerCase();
8995 t = t.replace(regm, u);
8996 s.setProperty(t, CSS2Properties[i]);
8997 slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
8998 slis[n]._isDefault = 1;
9004 slis._fontSize = 12;
9005 CSS2Properties._list = slis;
9006 Document.prototype.defaultView._defaultCSS = slis;
9007 s = n = regAZ = regm = slis =null;
9010 NAIBU.addEvent = function(evt,lis){
9011 if (window.addEventListener) {
9012 window.addEventListener(evt, lis, false);
9013 } else if (window.attachEvent) {
9014 window.attachEvent('on'+evt, lis);
9016 window['on'+evt] = lis;
9024 function unsvgtovml() {
9026 if ("stop" in NAIBU) {
9027 clearInterval(NAIBU.stop);
9029 window.onscroll = NAIBU.emptyFunction;
9030 window.detachEvent("onload", NAIBU._main);
9032 Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
9033 Array = ActiveXObject = void 0;
9039 NAIBU._main = (function() {
9040 stlog = new STLog(false);
9041 var xmlhttp, //XMLHttpオブジェクトを生成
9042 _doc = document; //documentのエイリアスを作成
9044 if (XMLHttpRequest) {
9047 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
9051 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
9058 xmlhttp = new XMLHttpRequest();
9063 NAIBU.xmlhttp = xmlhttp;
9065 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
9067 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
9072 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
9073 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
9074 var st = _doc.createStyleSheet(),
9075 vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
9076 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
9077 + "dn\\:defs{display:none}"
9078 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
9079 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
9081 var ary = _doc.getElementsByTagName("script");
9082 //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
9083 for (var i=0; ary[i]; ++i) {
9086 if (ai.type === "image/svg+xml") {
9088 if (sieb_s && ait.match(/<svg/)) {
9090 ait = ait.replace(/<.+?>/g, "");
9092 ait = ait.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
9095 var gsd = new GetSVGDocument(ai);
9099 responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
9103 var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
9104 ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
9105 var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
9106 ai.parentNode.insertBefore(s,ai);
9114 if (xmlhttp && NAIBU.isMSIE) {
9115 if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
9117 var ob = _doc.getElementsByTagName("object"),
9118 em = _doc.getElementsByTagName("embed"),
9119 img = _doc.getElementsByTagName("img"),
9122 _search = function(_ob) {
9126 s || (s = []); //NAIBU._searchで呼ばれたときに必要
9127 _doc || (_doc = document);
9128 for (var i=0;_ob[i];++i) {
9130 s[s.length] = new GetSVGDocument(obi);
9131 ifr = _doc.createElement("iframe");
9132 ifr.style.cssText = obi.style.cssText;
9133 ifr.style.background = "black";
9134 n = obi.getAttribute(w);
9135 n && ifr.setAttribute(w, n);
9136 n = obi.getAttribute(h);
9137 n && ifr.setAttribute(h, n);
9138 ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
9139 ifr.scrolling = "no";
9140 ifr.frameBorder = "0";
9141 /*iframe要素を使って、描画のプロセスを分離する
9142 *したがって、_docはdocumentとは別のオブジェクトとなる
9144 obi.parentNode.insertBefore(ifr, obi);
9146 i = obi = ifr = _ob = w = h = void 0;
9147 return s[s.length-1];
9151 for (var i=0,j=0;img[i];++i) {
9153 if (img[i].getAttribute("src").indexOf(".svg") > -1) { //拡張子があればSVG画像と判断
9159 NAIBU._search = _search; //a要素がクリックされたときに使う関数
9160 ob = em = t = img = _search = void 0;
9161 for (var i=0;i<s.length;++i) {
9162 /*あとで変数iが使われるために、次の条件分岐が必要*/
9163 if (i < s.length-1) {
9168 s[0]._init(); //初期化作業を開始
9173 var ob = _doc.getElementsByTagName("object");
9174 for (var i=0;i<ob.length;++i) {
9175 if (ob[i].contentDocument) {
9176 NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
9177 } else if (ob[i].getSVGDocument) {
9178 ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
9183 xmlhttp = _doc = void 0;
9185 NAIBU.addEvent("load", NAIBU._main);
9186 NAIBU.utf16 = function ( /*string*/ s) {
9189 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
9190 return s.replace(/%u\w\w\w\w/g, NAIBU.utf16);
9192 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
9193 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
9194 /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
9197 if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
9198 var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
9199 var ob = document.createElement("object");
9200 ob.setAttribute("data",data);
9201 ob.setAttribute("width",w);
9202 ob.setAttribute("height",h);
9203 ob.setAttribute("type","image/svg+xml");
9206 var doc = (new DOMParser()).parseFromString(source, "text/xml");
9207 return (document.importNode(doc.documentElement, true));
9210 NAIBU.addEvent("unload", unsvgtovml);
9212 NAIBU.isMSIE = /*@cc_on!@*/false;