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)) {
527 var d = tnoi.getElementsByTagNameNS(namespaceURI, localName);
529 for (var j=0,dli=d.length;j<dli;++j) {
534 ns = ln = d = void 0;
537 tno = i = j = tcli = dli = void 0;
539 return null; //該当する要素なし
543 /*boolean*/ Element.prototype.hasAttribute = function( /*string*/ name) {
544 return (this.hasAttributeNS("http://www.w3.org/2000/svg", name));
546 /*boolean*/ Element.prototype.hasAttributeNS = function( /*string*/ namespaceURI, /*string*/ localName) {
547 if (this.getAttributeNodeNS(namespaceURI, localName)) { //ノードの取得に成功した場合
560 Text.prototype = new CharacterData(); //文字データのプロトタイプチェーンを作って、継承
561 Text.constructor = CharacterData;
562 Text.prototype.nodeType = Node.TEXT_NODE;
563 Text.prototype.nodeName = "#text";
564 /*Text*/ Text.prototype.splitText = function(/*long*/ offset) {
565 var pre = this.substringData(0, offset - 1); //このノードからoffsetまでの文字列を取り出して、
566 this.replaceData(0, this.length - 1, pre); //このノードの文字列と置き換える
568 if (this.length !== offset) { //このノードの文字列の長さがoffsetに等しくない場合
569 next = this.substringData(offset, this.length - 1); //文字列を取り出す。(等しい場合は文字列を取り出さない)
571 var nnode = this.ownerDocument.createTextNode(next);
572 if (this.parentNode) {
573 this.parentNode.insertBefore(nnode, this.nextSibling);
579 *コメントノード。<!-- --!>で表現される。削除不可。
584 Comment.prototype = new CharacterData(); //文字データのプロトタイプチェーンを作って、継承
585 Comment.constructor = CharacterData;
586 Comment.prototype.nodeType = Node.COMMENT_NODE;
587 Comment.prototype.nodeName = "#comment";
589 *CDATA領域を示すノード。<![CDATA[ ]]!>で表現される。削除不可。
591 function CDATASection() {
592 this.nodeType = Node.CDATA_SECTION_NODE;
593 this.nodeName = "#cdata-section";
596 CDATASection.prototype = new Text(); //テキストノードのプロトタイプチェーンを作って、継承
597 CDATASection.constructor = Text;
600 *DTD(文書型定義)の情報を取り扱うノード。DTDは<!DOCTYPE[ ]>で表現されうる。削除可
602 function DocumentType() {
605 this.entities = new NamedNodeMap(); //パラメタ実体を除く実体の集まり
606 this.notations = new NamedNodeMap(); //DTDで示した記法の集まり
607 this.publicId = ""; //外部サブセットの公開識別子
608 this.systemId = ""; //上同のシステム識別子
609 this.internalSubset = ""; //内部サブセットの内容(文字列)
610 this.nodeValue = null;
611 this.nodeType = Node.DOCUMENT_TYPE_NODE;
614 DocumentType.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
615 DocumentType.constructor = Node;
618 *DTDの記法の情報を取り扱うノード。<!NOTATION >か、処理命令で記法は表現されうる。削除可
620 function Notation() {
621 this.publicId = null;
622 this.systemId = null;
623 this.nodeValue = null;
624 this.nodeType = Node.NOTATION_NODE;
627 Notation.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
628 Notation.constructor = Node;
631 *以下のノードは、もし、DOMを展開する前に、XMLプロセッサが実体参照の読み込みを行うのであれば、文書中に挿入される必要はない。
637 this.publicId = null;
638 this.systemId = null;
639 this.notationName = null; //解析対象外実体のための記法名。解析対象実体ではnull
640 this.nodeValue = null;
641 this.nodeType = Node.ENTITY_NODE;
644 Entity.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
645 Entity.constructor = Node;
648 *実態参照の代わりに挿入されるノード。削除可
650 function EntityReference() {
651 this.nodeValue = null;
652 this.nodeType = Node.ENTITY_REFERENCE_NODE ;
655 EntityReference.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
656 EntityReference.constructor = Node;
658 /*ProcessingInstruction
659 *処理命令ノード。スタイルシート処理命令で使うので、削除不可
661 function ProcessingInstruction() {
662 this.nodeType = Node.PROCESSING_INSTRUCTION_NODE;
665 ProcessingInstruction.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
666 ProcessingInstruction.constructor = Node;
669 *複数のノードを移したりするのに便宜上、用いられる文書ノード。削除可
671 function DocumentFragment() {
672 this.nodeName = "#document-fragment";
673 this.nodeValue = null;
674 this.nodeType = Node.DOCUMENT_FRAGMENT_NODE;
677 DocumentFragment.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
678 DocumentFragment.constructor = Node;
683 function Document() {
684 this.nodeName = "#document";
685 this.nodeValue = null;
686 this.nodeType = Node.DOCUMENT_NODE;
687 this._id = {}; //getElementByIdで使う
690 Document.prototype = new Node(); //ノードのプロトタイプチェーンを作って、継承
691 Document.constructor = Node;
694 *名前空間に対応していないメソッドは、軽量化のため、機能させないようにする。代わりに、**NSメソッドを利用すること。
695 *また、createメソッドは工場メソッドである。クラス名をユーザから隠蔽するのに役に立つ。
696 *突然、クラス名が変更されても、ライブラリを利用したユーザは、コードを書き換える必要がないなどのメリットがある。
698 /*Element*/ Document.prototype.createElement = function( /*string*/ tagName) {
700 /*createDocumentFragmentメソッド
703 /*DocumentFragment*/ Document.prototype.createDocumentFragment = function() {
704 var s = new DocumentFragment();
705 s.ownerDocument = this;
711 /*Text*/ Document.prototype.createTextNode = function( /*string*/ data) {
713 s.data = s.nodeValue = data+"";
714 s.length = data.length;
715 s.ownerDocument = this;
721 /*Comment*/ Document.prototype.createComment = function( /*string*/ data) {
722 var s = new Comment();
723 s.data = s.nodeValue = data;
724 s.length = data.length;
725 s.ownerDocument = this;
728 /*createCDATASectionメソッド
731 /*CDATASection*/ Document.prototype.createCDATASection = function( /*string*/ data) {
732 var s = new CDATASection();
733 s.data = s.nodeValue = data;
734 s.length = data.length;
735 s.ownerDocument = this;
738 /*createProcessingInstructionメソッド
741 /*ProcessingInstruction*/ Document.prototype.createProcessingInstruction = function( /*string*/ target, /*string*/ data) {
742 var s = new ProcessingInstruction();
743 s.target = s.nodeName = target;
744 s.data = s.nodeValue = data;
745 s.ownerDocument = this;
749 *createAttributeNSを推奨
751 /*Attr*/ Document.prototype.createAttribute = function( /*string*/ name) {
753 /*createEntityReferenceメソッド
756 /*EntityReference*/ Document.prototype.createEntityReference = function( /*string*/ name) {
757 var s = new EntityReference();
759 s.ownerDocument = this;
762 /*getElementsByTagNameメソッド
763 *getElementsByTagNameNSを推奨
765 /*NodeList*/ Document.prototype.getElementsByTagName = function( /*string*/ tagname) {
768 *自身のドキュメントノードに、他のドキュメントノードから作られたノードを取り込みたいときに用いる
770 /*Node*/ Document.prototype.importNode = function( /*Node*/ importedNode, /*boolean*/ deep) {
772 imn = importedNode.nodeType,
773 attr, att, fi, n, uri, ch;
774 /*以下の処理は引き渡されたimportedNodeがMSXMLによって解析された
777 if (imn === /*Node.ELEMENT_NODE*/ 1) {
778 s = this.createElementNS(importedNode.namespaceURI, importedNode.nodeName);
779 attr = importedNode.attributes;
780 for (var i=0;attr[i];++i) { //NamedNodeMapを検索する
782 uri = ch.namespaceURI;
783 uri = (uri === "") ? null : uri; //空文字列はnullとして扱うようにする(MSXMLが空文字列を返す時の対策)
784 att = this.createAttributeNS(uri, ch.nodeName);
785 att.nodeValue = ch.nodeValue;
786 s.setAttributeNodeNS(att);
789 fi = importedNode.firstChild;
790 while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
791 n = this.importNode(fi, true);
797 } else if(imn === /*Node.TEXT_NODE*/ 3) {
798 s = this.createTextNode(importedNode.data);
799 } else if(imn === /*Node.ATTRIBUTE_NODE*/ 2) {
800 uri = importedNode.namespaceURI;
801 uri = (uri === "") ? null : uri; //空文字列はnullとして扱うようにする(MSXMLが空文字列を返す時の対策)
802 s = this.createAttributeNS(uri, importedNode.nodeName);
803 s.nodeValue = importedNode.nodeValue;
804 } else if(imn === /*Node.COMMENT_NODE*/ 8) {
805 s = this.createComment(importedNode.data);
806 } else if(imn === Node.DOCUMENT_FRAGMENT_NODE) {
807 s = this.createDocumentFragment();
809 ch = importedNode.childNodes;
810 for (var i=0,chli=ch.length;i<chli;i++) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
811 n = this.importNode(ch[i], true);
816 } else if(imn === Node.CDATA_SECTION_NODE) {
817 s = this.createCDATASection(importedNode.data);
818 } else if(imn === Node.ENTITY_REFERENCE_NODE) {
819 s = this.createEntityReference(importedNode.nodeName);
821 fi = importedNode.firstChild;
823 n = this.importNode(fi, true);
828 } else if(imn === Node.ENTITY_NODE) {
830 s.publicId = importedNode.publicId;
831 s.systemId = importedNode.systemId;
832 s.notationName = importedNode.notationName;
833 } else if(imn === Node.PROCESSING_INSTRUCTION_NODE ) {
834 s = this.createProcessingInstruction(importedNode.nodeName, importedNode.nodeValue)
835 } else if(imn === Node.NOTATION_NODE) {
837 s.publicId = importedNode.publicId;
838 s.systemId = importedNode.systemId;
840 throw (new DOMException(DOMException.NOT_SUPPORTED_ERR));
842 importedNode = deep = imn = attr = att = fi = n = uri = ch = void 0;
845 /*createElementNSメソッド
847 *例:var s = DOC.createElementNS("http://www.w3.org/2000/svg", "svg:svg");
849 /*Element*/ Document.prototype.createElementNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName) {
853 if (!qualifiedName) {
854 throw (new DOMException(DOMException.INVALID_CHARACTER_ERR));
856 if (qualifiedName.indexOf(":") !== -1){
857 var p = qualifiedName.split(":");
861 localName = qualifiedName;
863 var isSpecified = false;
865 var ti = this.implementation;
866 if (!!ti[namespaceURI]) {
867 if (!!ti[namespaceURI][localName]) { //もし、名前空間とローカル名によって、オブジェクトがあった場合
873 ele = new (ti[namespaceURI][localName])(this._document_);
877 ele.namespaceURI = namespaceURI;
878 ele.nodeName = ele.tagName = qualifiedName;
879 ele.localName = localName;
881 ele.ownerDocument = this;
882 ti = namespaceURI = qualifiedName = prefix = localName = isSpecified = void 0;
885 Document.prototype._document_ = document
886 /*createAttributeNSメソッド
887 *属性ノードを作る。setAttributeNSで使うため、削除不可
889 /*Attr*/ Document.prototype.createAttributeNS = function( /*string*/ namespaceURI, /*string*/ qualifiedName) {
890 var attr = new Attr(),
892 attr.namespaceURI = namespaceURI;
893 attr.nodeName = attr.name = qualifiedName;
894 if (qualifiedName.indexOf(":") !== -1){
895 p = qualifiedName.split(":");
897 attr.localName = p[1];
900 attr.localName = qualifiedName;
902 attr.ownerDocument = this;
903 p = qualifiedName = void 0;
906 /*getElementsByTagNameNSメソッド
907 *タグ名と名前空間URIを元に、要素ノード達を取得
909 /*NodeList*/ Document.prototype.getElementsByTagNameNS = function(/*string*/ namespaceURI, /*string*/ localName) {
910 var NodeList = this.documentElement.getElementsByTagNameNS(namespaceURI, localName);
916 /*Element*/ Document.prototype.getElementById = function( /*string*/ elementId) {
917 var s = !!this._id[elementId] ? this._id[elementId] : null;
922 #endif // _DOM_IDL_*/
924 //以下は例外処理のログをとるためのもの。開発者以外は削除すること
925 function STLog(jou) {
928 this.p = document.createElement("div");
929 this.p.innerHTML = "<h1>例外処理のログ</h1>";
930 document.body.insertBefore(this.p,document.body.firstChild);
934 STLog.prototype.add = function(e,code) {
936 this.p.innerHTML += "<p>"+code+":"+e.message+"</p>";
941 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.idl
949 #pragma prefix "dom.w3c.org"
953 typedef dom::DOMString DOMString;
954 typedef dom::DOMTimeStamp DOMTimeStamp;
955 typedef dom::Node Node;
957 interface EventListener;
963 function EventException() {
964 DOMException.call(this,arguments);
965 if (this.code === 0) {
966 this.message = "Uuspecified Event Type Error";
970 /*unsigned short*/ EventException.UNSPECIFIED_EVENT_TYPE_ERR = 0;
972 EventException.prototype = new DOMException();
973 EventException.constructor = DOMException;
976 /* // Introduced in DOM Level 2:
977 interface EventTarget {*/
978 /*void*/ Node.prototype.addEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
979 this.removeEventListener(type, listener, useCapture); //いったん、(あれば)リスナーを離す。
980 var s = new EventListener(useCapture, type, listener), //リスナーを作成
983 this._capter.push(s); //このノードにリスナーを登録しておく
984 if ((t !== "D") && (t !== "S") && (type !== "beginEvent") && (type !== "endEvent") && (type !== "repeatEvent")) { //MouseEventsならば
986 that._tar && that._tar.attachEvent("on" +type, (function(node, type) {
988 var evt = node.ownerDocument.createEvent("MouseEvents");
989 evt.initMouseEvent(type, true, true, node.ownerDocument.defaultView, 0);
990 node.dispatchEvent(evt);
991 /*cancelBubbleプロパティについては、IEのMSDNなどを参照*/
992 node.ownerDocument._window.event.cancelBubble = true;
998 type = listener = useCapture = s = t = that = void 0;
1000 /*void*/ Node.prototype.removeEventListener = function( /*string*/ type, /*EventListener*/ listener, /*boolean*/ useCapture) {
1001 var tce = this._capter;
1002 for (var i=0,tcli=tce.length;i<tcli;i++){
1003 if (tce[i]._listener === listener) { //登録したリスナーと一致すれば
1007 i = tcli = tce = void 0;
1009 /*boolean*/ Node.prototype.dispatchEvent = function( /*Event*/ evt) {
1010 if (!evt.type) { //Eventの型が設定されていないとき
1011 throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR);
1014 td = te.ownerDocument,
1015 etime = evt.timeStamp,
1020 type = /*Event.CAPTURING_PHASE*/ 1,
1021 ecptype = /*Event.CAPTURING_PHASE*/ "1",
1022 ebptype = /*Event.BUBBLING_PHASE*/ "3",
1024 if (!td._isLoaded) {
1025 /*以下では、画像の処理に時間がかかりそうな場合、処理落ちとして、遅延処理
1026 *を行い、バッファリングにイベント送付処理をためていく作業となる
1028 if (!td._limit_time_) {
1029 td._limit_time_ = etime;
1030 } else if ((etime - td._limit_time_) > 1000) {
1031 /*1秒を超えたらバッファにため込んで後で使う*/
1032 tob = td.implementation._buffer_ || [];
1036 td.implementation._buffer_ = tob;
1037 te = td = etime = etype = ebub = tob = toli = type = void 0;
1042 evt.eventPhase = 1;//Event.CAPTURING_PHASE
1043 //このノードからドキュメントノードにいたるまでの、DOMツリーのリストを作成しておく
1045 /*以下の処理では、documentElementのparentNodeが
1046 *Documentノードではなく、nullになっていることを前提としている。
1047 *したがって、documentElementのparentNodeがもし、Documentノードのオブジェクトならば、以下を書き換えるべきである
1049 while (te.parentNode) {
1050 te.parentNode[ecptype] = te;
1051 te[ebptype] = te.parentNode;
1056 /*最初に捕獲フェーズでDOMツリーを下っていき、イベントのターゲットについたら、
1057 *そこで、浮上フェーズとして折り返すように、反復処理をおこなう。
1061 evt.currentTarget = td;
1062 if (td === te) { //イベントのターゲットに到着(折り返し地点)
1063 type = 2;//Event.AT_TARGET;
1065 evt.eventPhase = type;
1066 tce = td._capter; //tceは登録しておいたリスナーのリスト
1067 for (var j=0,tcli=tce.length;j<tcli;++j){
1068 if (tce[j] && (etype === tce[j]._type)) {
1069 tce[j].handleEvent(evt);
1073 break; //stopPropagationメソッドが呼ばれたら、停止する
1077 break; //浮上フェーズに移行せず、停止する
1079 type = 3;//Event.BUBBLING_PHASE;
1083 var ed = evt._default;
1084 evt = te = tce = n = td = type = tob = j = tcli = etype = etime = ebub = ecptype = ebptype = void 0;
1088 function EventListener(cap,type,listener) {
1091 this._listener = listener;
1095 EventListener.prototype = {
1096 /*void*/ handleEvent : function( /*Event*/ evt) {
1098 var ph = evt.eventPhase,
1100 if (ph === /*Event.CAPTURING_PHASE*/ 1) { //イベントフェーズが捕獲段階であることを示し
1101 cap = cap ? false : true; //このオブジェクト(EventListenr)が捕獲フェーズを指定するならば、リスナーを作動させる。指定しなければ、作動しない。
1103 if (!cap && (evt.type === this._type)) {
1104 this._listener(evt);
1106 evt = ph = cap = void 0;
1114 *イベントの雛形となる。プロパティもすべて含めて、必須
1120 /*unsigned short*/ Event.CAPTURING_PHASE = 1;
1121 /*unsigned short*/ Event.AT_TARGET = 2;
1122 /*unsigned short*/ Event.BUBBLING_PHASE = 3;
1124 /*DOMTimeStamp*/ timeStamp : 0,
1125 /*DOMString*/ type : null,
1126 /*EventTarget*/ target : null,
1127 /*EventTarget*/ currentTarget : null,
1128 /*unsigned short*/ eventPhase : Event.CAPTURING_PHASE,
1129 /*boolean*/ bubbles : false,
1130 /*boolean*/ cancelable : false,
1131 _stop : false, //stopPropagationメソッドで使う
1132 _default : true, //preventDefaultメソッドで使う
1133 /*void*/ stopPropagation : function(){
1136 /*void*/ preventDefault : function(){
1137 if (this.cancelable) {
1138 this._default = false;
1139 /*IEのみで使えるreturnValueプロパティ*/
1140 this.target.ownerDocument._window.event.returnValue = false;
1143 /*void*/ initEvent : function( /*string*/ eventTypeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg) {
1144 this.type = eventTypeArg;
1145 this.bubbles = canBubbleArg;
1146 this.cancelable = cancelableArg;
1147 eventTypeArg = canBubbleArg = cancelableArg = void 0;
1150 /*Documentノードに直接結びつける
1151 function DocumentEvent() {
1154 /*Event*/ Document.prototype.createEvent = function( /*string*/ eventType) {
1156 if (eventType === "MutationEvents") {
1157 evt = new MutationEvent();
1158 } else if (eventType === "MouseEvents") {
1159 evt = new MouseEvent();
1160 } else if (eventType === "UIEvents") {
1161 evt = new UIEvent();
1162 } else if (eventType === "SVGEvents") {
1163 evt = new SVGEvent();
1164 } else if (eventType === "TimeEvents") {
1165 evt = new TimeEvent();
1169 evt.type = eventType;
1170 evt.timeStamp = +(new Date());
1175 function UIEvent() {
1176 /*views::AbstractView*/ this.view;
1177 /*long*/ this.detail = 0;
1181 UIEvent.prototype = new Event();
1182 UIEvent.constructor = Event;
1183 /*void*/ UIEvent.prototype.initUIEvent = function( /*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*views::AbstractView*/ viewArg, /*long*/ detailArg) {
1184 this.initEvent(typeArg, canBubbleArg, cancelableArg);
1185 this.detail = detailArg;
1186 this.view = viewArg;
1188 function MouseEvent(evt) {
1189 UIEvent.call(this, arguments);
1190 /*long*/ this.screenX;
1191 /*long*/ this.screenY;
1192 /*long*/ this.clientX = this.clientY = 0;
1193 /*boolean*/ this.ctrlKey = this.shiftKey = this.altKey = this.metaKey = false;
1194 /*unsigned short*/ this.button;
1195 /*EventTarget*/ this.relatedTarget;
1198 MouseEvent.prototype = new UIEvent();
1199 MouseEvent.constructor = UIEvent;
1200 /*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) {
1201 this.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
1202 this.screenX = screenXArg;
1203 this.screenY = screenYArg;
1204 this.clientX = clientXArg;
1205 this.clientY = clientYArg;
1206 this.ctrlKey = ctrlKeyArg;
1207 this.shiftKey = shiftKeyArg;
1208 this.altKey = altKeyArg;
1209 this.metaKey = metaKeyArg;
1210 this.button = buttonArg;
1211 this.relatedTarget = relatedTargetArg;
1214 function MutationEvent(){
1217 MutationEvent.prototype = new Event();
1218 MutationEvent.constructor = Event;
1220 /*void*/ this.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg,
1221 /*boolean*/ cancelableArg, /*Node*/ relatedNodeArg, /*string*/ prevValueArg, /*string*/ newValueArg,
1222 /*string*/ attrNameArg, /*unsigned short*/ attrChangeArg) {
1223 this.initEvent(typeArg, canBubbleArg, cancelableArg);
1224 this.relatedNode = relatedNodeArg;
1225 this.prevValue = prevValueArg;
1226 this.newValue = newValueArg;
1227 this.attrName = attrNameArg;
1228 this.attrChange = attrChangeArg;
1229 typeArg = canBubbleArg = cancelableArg = relatedNodeArg = prevValueArg = newValueArg = attrNameArg = attrChangeArg = void 0;
1231 /*Node*/ this.relatedNode = null;
1232 /*string*/ this.prevValue = this.newValue = this.attrName = null;
1233 /*unsigned short*/ this.attrChange = 2;
1234 }).apply(MutationEvent.prototype);
1236 /*unsigned short*/ MutationEvent.MODIFICATION = 1;
1237 /*unsigned short*/ MutationEvent.ADDITION = 2;
1238 /*unsigned short*/ MutationEvent.REMOVAL = 3;
1240 /*MutationEventsの発動のために、setAttributeNodeNSを上書きする。ファイル統合やmakeの際は、
1241 *重複するのでコアモジュールのメソッドは削除する。モジュールテストを行うために、
1242 *このような形式をとることにする。なお、追加部分には区別を付けるために、前後にコメントを挿入する。
1244 /*Attr*/ Element.prototype.setAttributeNodeNS = function( /*Attr*/ newAttr){
1245 if (newAttr.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1246 throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1248 var s = this.attributes.setNamedItemNS(newAttr);
1249 newAttr.ownerElement = this;
1250 if (newAttr.localName === "id") { //id属性であったならば
1251 this.ownerDocument._id[newAttr.nodeValue] = this; //ドキュメントに登録しておく
1254 var evt = this.ownerDocument.createEvent("MutationEvents");
1255 if (!s) { //ノードがなければ
1256 /*initMutationEventメソッドは軽量化のため省略する*/
1257 evt.initEvent("DOMAttrModified", true, false);
1258 evt.relatedNode = newAttr;
1259 evt.newValue = newAttr.nodeValue;
1260 evt.attrName = newAttr.nodeName;
1262 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, s.nodeValue, newAttr.nodeValue, newAttr.nodeName, MutationEvent.MODIFICATION);
1264 this.dispatchEvent(evt); //このとき、MutationEventsが発動
1270 /*Node*/ Node.prototype.insertBefore = function( /*Node*/ n, ref) {
1271 var tp = this.parentNode,
1276 while (!tp) { //先祖をたどっていく
1277 if (tp === n) { //先祖要素が追加ノードならばエラー
1278 throw (new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
1283 if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
1284 throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1286 if (n.parentNode === this) { //入力した要素が子要素ならば
1287 this.removeChild(n);
1289 if (!ref) { //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
1290 this.childNodes[this.childNodes.length] = n;
1291 if (this.lastChild) {
1292 n.previousSibling = this.lastChild;
1293 this.lastChild.nextSibling = n;
1296 if (ref.parentNode !== this) { //参照ノードが子要素でない場合
1297 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1299 this.childNodes.splice(ref._num,1,n,ref); //Arrayのspliceを利用して、リストにnノードを追加
1300 rp = ref.previousSibling;
1304 ref.previousSibling = n;
1306 n.nextSibling = ref;
1307 this.firstChild = this.childNodes[0];
1308 this.lastChild = this.childNodes[this.childNodes.length-1];
1309 n.parentNode = this;
1310 if ((n.nodeType===/*Node.ENTITY_REFERENCE_NODE*/ 5) || (n.nodeType===/*Node.DOCUMENT_FRAGMENT_NODE*/ 11)) {
1311 /*実体参照や、文書フラグメントノードだけは子ノードを検索して、
1312 *それらを直接文書に埋め込む作業を以下で行う
1314 var ch = n.childNodes.concat([]); //Arrayのコピー
1315 for (var i=0,chli=ch.length;i<chli;i++) {
1316 this.insertBefore(ch[i], n);
1321 evt = this.ownerDocument.createEvent("MutationEvents");
1322 evt.initMutationEvent("DOMNodeInserted", true, false, this, null, null, null, null);
1323 n.dispatchEvent(evt);
1324 /*以下のDOMNodeInsertedIntoDocumentイベントは、間接的、あるいは直接ノードが
1325 *挿入されたときに発火する。間接的な挿入とは、サブツリーを作っておいて、それをいっぺんに挿入する場合など。
1326 *このイベントは浮上しないことに注意を要する
1332 if (s !== this.ownerDocument.documentElement) {
1336 evt = this.ownerDocument.createEvent("MutationEvents");
1337 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1338 n.dispatchEvent(evt);
1339 if (!n.hasChildNodes()) { //子ノードがないので終了
1342 descend = n.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1344 for (var i=0,dli=descend.length;i<dli;++i) {
1346 di.dispatchEvent(evt);
1350 evt = descend = void 0;
1352 tp = rp = te = s = di = void 0;
1356 /*Node*/ Node.prototype.removeChild = function( /*Node*/ ele) {
1357 if (!(ele instanceof Node)) { //Nodeでなければ
1358 throw (new Error());
1361 var evt = this.ownerDocument.createEvent("MutationEvents");
1362 /*以下のDOMNodeRemovedFromDocumentイベントは、間接的、あるいは直接ノードが
1363 *除去されたときに発火する。間接的な除去とは、サブツリーをいっぺんに除去する場合など。
1364 *このイベントは浮上しないことに注意を要する
1366 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1367 ele.dispatchEvent(evt);
1368 var descend = ele.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1370 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1371 for (var i=0,dli=descend.length;i<dli;++i) {
1372 var di = descend[i];
1374 di.dispatchEvent(evt);
1378 evt.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null);
1379 ele.dispatchEvent(evt);
1380 evt = descend = void 0;
1382 if (ele.parentNode === this) {
1383 this.childNodes.splice(ele._num,1); //Arrayのspliceを利用して、リストからeleノードを排除
1385 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1387 if (ele.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1388 throw (new Error());
1393 /*void*/ CharacterData.prototype.appendData = function( /*string*/ arg) {
1397 this.length = this.data.length;
1399 evt = this.ownerDocument.createEvent("MutationEvents");
1400 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1401 this.parentNode.dispatchEvent(evt);
1402 evt = arg = pd = void 0;
1405 /*void*/ CharacterData.prototype.insertData = function( /*long*/ offset, /*string*/ arg) {
1407 pre = this.substring(0, offset - 1), //文字列を二つに分けた、前半部分
1408 next = this.substring(offset, this.length - offset), //後半部分
1410 this.data = pre + this.data + next;
1411 this.length = this.data.length;
1413 evt = this.ownerDocument.createEvent("MutationEvents");
1414 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1415 this.parentNode.dispatchEvent(evt);
1416 evt = arg = pd = pre = next = void 0;
1419 /*void*/ CharacterData.prototype.deleteData = function( /*long*/ offset, /*long*/ count) {
1421 pre = this.substring(0, offset - 1), //残すべき前半部分
1422 next = this.substring(offset + count, this.length - 1), //後半部分
1424 if (offset + count > this.length) { //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを削除
1427 this.data = pre + next;
1428 this.length = this.data.length;
1430 evt = this.ownerDocument.createEvent("MutationEvents");
1431 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1432 this.parentNode.dispatchEvent(evt);
1440 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.idl
1442 #ifndef _STYLESHEETS_IDL_
1443 #define _STYLESHEETS_IDL_
1447 #pragma prefix "dom.w3c.org"
1451 typedef dom::DOMString DOMString;
1452 typedef dom::Node Node;
1458 function StyleSheet() {
1459 this.type = "text/css";
1460 this.disabled = false;
1461 /*Node*/ this.ownerNode = null;
1462 /*StyleSheet*/ this.parentStyleSheet = null;
1465 /*MediaList*/ this.media = new MediaList();
1470 *このインターフェースはArrayで代用する
1471 function StyleSheetList() {
1472 readonly attribute unsigned long length;
1473 StyleSheet item(in unsigned long index);
1477 function MediaList() {
1478 this.mediaText = "";
1482 MediaList.prototype = {
1483 /*string*/ item : function(/*long*/ index) {
1484 return (this[index]);
1486 /*void*/ deleteMedium : function(/*string*/ oldMedium) {
1487 for (var i=0,tli=this.length;i<tli;++i) {
1488 if (this[i] === oldMedium) {
1494 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1496 /*void*/ appendMedium : function(/*string*/ newMedium) {
1497 this[this.length] = newMedium;
1502 function LinkStyle() {
1503 /*StyleSheet*/ this.sheet = new StyleSheet();
1507 function DocumentStyle() {
1508 /*StyleSheetList*/ this.styleSheets = [];
1512 #endif // _STYLESHEETS_IDL_
1515 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.idl
1521 #include "stylesheets.idl"
1522 #include "views.idl"
1524 #pragma prefix "dom.w3c.org"
1528 typedef dom::DOMString DOMString;
1529 typedef dom::Element Element;
1530 typedef dom::DOMImplementation DOMImplementation;
1533 interface CSSStyleSheet;
1534 interface CSSStyleDeclaration;
1542 function CSSRuleList {
1543 readonly attribute unsigned long length;
1544 CSSRule item(in unsigned long index);
1548 *CSSのルールを表現する。基底クラスなので削除不可。
1550 function CSSRule() {
1552 /*CSSStyleSheet*/ this.parentStyleSheet;
1553 /*CSSRule*/ this.parentRule = null;
1557 CSSRule.UNKNOWN_RULE = 0;
1558 CSSRule.STYLE_RULE = 1;
1559 CSSRule.CHARSET_RULE = 2;
1560 CSSRule.IMPORT_RULE = 3;
1561 CSSRule.MEDIA_RULE = 4;
1562 CSSRule.FONT_FACE_RULE = 5;
1563 CSSRule.PAGE_RULE = 6;
1565 function CSSStyleRule() {
1566 CSSRule.call(this, arguments);
1567 this.type = CSSRule.STYLE_RULE;
1568 this.selectorText = "";
1569 /*CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
1570 this.style.parentRule = null;
1573 CSSStyleRule.prototype = new CSSRule();
1574 CSSStyleRule.constructor = CSSRule;
1576 function CSSMediaRule() {
1577 CSSRule.call(this, arguments);
1578 this.type = CSSRule.MEDIA_RULE;
1579 /*stylesheets::MediaList*/ this.media = new MediaList();
1580 /*CSSRuleList*/ this.cssRules = [];
1583 CSSMediaRule.prototype = new CSSRule();
1584 CSSMediaRule.constructor = CSSRule;
1585 /*long*/ CSSMediaRule.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
1586 this.cssRules.splice(index,rule,1);
1587 this.media.appendMedium(rule);
1590 /*void*/ CSSMediaRule.prototype.deleteRule = function( /*long*/ index) {
1593 function CSSFontFaceRule() {
1594 CSSRule.call(this, arguments);
1595 this.type = CSSRule.FONT_FACE_RULE;
1596 /*CSSStyleDeclaration*/ this.style;
1599 CSSFontFaceRule.prototype = new CSSRule();
1600 CSSFontFaceRule.constructor = CSSRule;
1602 function CSSPageRule() {
1603 CSSRule.call(this, arguments);
1604 this.type = CSSRule.PAGE_RULE;
1605 this.selectorText = "";
1606 /*CSSStyleDeclaration*/ this.style;
1609 CSSPageRule.prototype = new CSSRule();
1610 CSSPageRule.constructor = CSSRule;
1612 function CSSImportRule() {
1613 CSSRule.call(this, arguments);
1614 this.type = CSSRule.IMPORT_RULE;
1616 /*stylesheets::MediaList*/ this.media = new MediaList();
1617 /*CSSStyleSheet*/ this.styleSheet = null;
1620 CSSImportRule.prototype = new CSSRule();
1621 CSSImportRule.constructor = CSSRule;
1623 function CSSCharsetRule() {
1624 CSSRule.call(this, arguments);
1625 this.type = CSSRule.CHARSET_RULE;
1629 CSSCharsetRule.prototype = new CSSRule();
1630 CSSCharsetRule.constructor = CSSRule;
1632 function CSSUnknownRule() {
1633 CSSRule.call(this, arguments);
1634 this.type = CSSRule.UNKNOWN_RULE;
1637 CSSUnknownRule.prototype = new CSSRule();
1638 CSSUnknownRule.constructor = CSSRule;
1640 /*CSSStyleDeclaration
1641 *CSSの宣言ブロックを表現。削除不可。
1643 function CSSStyleDeclaration() {
1644 this._list = []; //内部のリスト
1645 this._list._fontSize = this._list._opacity = null;
1648 CSSStyleDeclaration.prototype = {
1650 /*long*/ length : 0,
1651 /*CSSRule*/ parentRule : null,
1652 _urlreg : /url\(#([^)]+)/,
1653 /*getPropertyValueメソッド
1654 *CSSの値を返す。この値は継承ではなくて、明示的に表記されているもの
1656 /*string*/ getPropertyValue : function( /*string*/ propertyName) {
1657 var tg = this.getPropertyCSSValue(propertyName);
1659 var tc = tg.cssText;
1660 return (tc.slice(tc.indexOf(":")+1));
1665 /*getPropertyCSSValueメソッド
1666 *CSSValueオブジェクトを返す。このメソッドは判別に用いているので、削除不可。
1668 /*CSSValue*/ getPropertyCSSValue : function( /*string*/ propertyName) {
1669 var prop = propertyName,
1671 propertyName += ":";
1672 if (propertyName === ":") { //どんなデータ型でも、文字列に変換する機能をJavaScriptが持つことに注意
1675 for (var i=0,tl=this._list,tli=tl.length;i<tli;++i) {
1678 if (tc.indexOf(propertyName) > -1) { //プロパティ名に合致するCSSValueオブジェクトが見つかった場合
1679 ti._empercents = tl._fontSize;
1680 i = tl = tli = tc = prop = propertyName = void 0;
1684 i = tl = tli = prop = propertyName = void 0;
1687 /*removePropertyメソッド
1690 /*string*/ removeProperty : function( /*string*/ propertyName) {
1691 var tg = this.getPropertyCSSValue(propertyName);
1693 this._list.splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
1697 /*getPropertyPriorityメソッド
1698 *importantなどのpriorityを取得する
1700 /*string*/ getPropertyPriority : function( /*string*/ propertyName) {
1701 var tg = this.getPropertyCSSValue(propertyName);
1703 return (tg._priority);
1723 *プロパティを宣言内で、明示的に設定。継承は無視する
1725 /*void*/ setProperty : function( /*string*/ propertyName, /*string*/ value, /*string*/ priority) {
1726 var cssText = propertyName,
1732 if (!!this[propertyName]) {
1733 tg = this.getPropertyCSSValue(propertyName);
1737 if (this._isFillStroke[propertyName]) {
1738 /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
1739 *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
1744 ti = new SVGPaint();
1746 paintType = /*SVGPaint.SVG_PAINTTYPE_UNKNOWN*/ 0;
1747 v1 = value.charAt(0);
1748 if (this._isRS[v1] || ti._keywords[value]) {
1749 paintType = /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1;
1751 } else if (value === "none") {
1752 paintType = /*SVGPaint.SVG_PAINTTYPE_NONE*/ 101;
1753 } else if (this._urlreg.test(value)) { //fill属性の値がurl(#id)ならば
1754 paintType = /*SVGPaint.SVG_PAINTTYPE_URI*/ 107;
1756 } else if (value === "currentColor") {
1757 paintType = /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102;
1759 ti.setPaint(paintType, uri, color, null);
1760 paintType = v1 = uri = color = void 0;
1761 } else if (this._isStop[propertyName]) {
1765 ti = new SVGColor();
1767 if (value === "currentColor") {
1768 ti.colorType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
1770 ti.colorType = /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1;
1772 ti.setRGBColor(value);
1777 ti = new CSSPrimitiveValue();
1780 ti._priority = priority;
1781 ti.cssText = cssText;
1783 //_numプロパティはremovePropertyメソッドで利用する
1784 ti._num = this._list.length;
1785 this._list[ti._num] = ti;
1786 this[propertyName] = 1;
1789 if (value === "inherit") {
1790 ti.cssValueType = CSSValue.CSS_INHERIT;
1791 } else if (propertyName === "opacity") {
1792 this._list._opacity = +value;
1793 } else if (propertyName === "font-size") {
1794 if (/(%|em|ex)/.test(value)) {
1796 ti[tg] = parseFloat(value);
1798 this._em = this._ex = this["_%"] = null;
1799 this._list._fontSize = parseFloat(value);
1805 *リストの位置にあるプロパティ名を取得する。宣言内のすべてのプロパティ名を取得するのに便利
1807 /*string*/ item : function( /*long*/ index) {
1808 if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
1811 var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
1817 function CSSValue() {
1821 CSSValue.CSS_INHERIT = 0;
1822 CSSValue.CSS_PRIMITIVE_VALUE = 1;
1823 CSSValue.CSS_VALUE_LIST = 2;
1824 CSSValue.CSS_CUSTOM = 3;
1825 CSSValue.prototype = {
1827 cssValueType : CSSValue.CSS_CUSTOM,
1828 _isDefault : 0 //デフォルトであるかどうか(独自のプロパティ)
1831 function CSSPrimitiveValue() {
1838 t.CSS_PERCENTAGE = 2;
1854 t.CSS_DIMENSION = 18;
1861 t.CSS_RGBCOLOR = 25;
1862 t.prototype = new CSSValue();
1863 t.constructor = CSSValue;
1864 })(CSSPrimitiveValue);
1867 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に統一)
1868 this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
1869 this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
1871 this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
1872 this._empercent = 0;
1873 this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う
1874 /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
1875 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1876 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1878 this.primitiveType = unitType;
1879 this._value = floatValue * this._n[unitType-1]; //値はあらかじめ、利用しやすいように変換しておく
1884 this._regd = /[\d\.]+/;
1885 /*float*/ this.getFloatValue = function(/*short*/ unitType) {
1886 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1887 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1889 if (this._value || (this._value === 0)) { //すでに、setFloatValueメソッドによって_valueプロパティが設定されていた場合
1890 return (this._value / this._n[unitType-1]);
1892 var tc = this.cssText,
1895 s = +(tc.match(this._regd));
1896 s = isNaN(s) ? 0 : s;
1897 if (n >= "0" && n <= "9") {
1898 type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
1899 if (unitType === 1) {
1900 unitType = tc = n = type = void 0;
1903 } else if (n === "%") {
1905 type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
1906 } else if ((n === "m") && (tc.charAt(tc.length-2) === "e")) {
1907 s *= this._empercent;
1908 type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
1909 } else if ((n === "x") && (tc.charAt(tc.length-2) === "e")) {
1910 type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
1911 } else if ((n === "x") && (tc.charAt(tc.length-2) === "p")) {
1912 type = /*CSSPrimitiveValue.CSS_PX*/ 5;
1913 } else if ((n === "m") && (tc.charAt(tc.length-2) === "c")) {
1914 type = /*CSSPrimitiveValue.CSS_CM*/ 6;
1915 } else if ((n === "m") && (tc.charAt(tc.length-2) === "m")) {
1916 type = /*CSSPrimitiveValue.CSS_MM*/ 7;
1917 } else if (n === "n") {
1918 type = /*CSSPrimitiveValue.CSS_IN*/ 8;
1919 } else if (n === "t") {
1920 type = /*CSSPrimitiveValue.CSS_PT*/ 9;
1921 } else if (n === "c") {
1922 type = /*CSSPrimitiveValue.CSS_PC*/ 10;
1924 s = s * this._n[type-1] / this._n[unitType-1];
1925 tc = n = type = unitType = void 0;
1929 /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
1930 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1931 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1933 this._value = stringValue;
1935 /*string*/ this.getStringValue = function(/*short*/ stringType) {
1936 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1937 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1939 return (this._value);
1941 /*Counter*/ this.getCounterValue = function() {
1942 if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
1943 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1945 return (new Counter());
1947 /*Rect*/ this.getRectValue = function() {
1948 if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
1949 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1951 return (new Rect());
1953 /*RGBColor*/ this.getRGBColorValue = function() {
1954 if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
1955 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1957 var s = new RGBColor();
1958 var rgbColor = this.cssText;
1959 var tkr = SVGColor.prototype._keywords[rgbColor];
1960 if (tkr !== void 0) {
1963 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
1964 rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
1965 return Math.round((2.55 * parseFloat(t)));
1967 } else if (rgbColor.indexOf("#") > -1) { //#を含む場合
1968 rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
1969 return parseInt(s, 16);
1972 var n = rgbColor.match(/\d+/g);
1973 s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
1974 s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
1975 s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
1976 n = rgbColor = void 0;
1979 }).apply(CSSPrimitiveValue.prototype);
1983 function CSSValueList() {
1984 this.cssValueType = CSSValue.CSS_VALUE_LIST;
1988 CSSValueList.prototype = new CSSValue();
1989 CSSValueList.constructor = CSSValue;
1990 /*CSSValue*/ CSSValueList.prototype.item = function( /*long*/ index) {
1991 return (this[index]);
1994 function RGBColor() {
1995 var cs = CSSPrimitiveValue;
1996 this.red = new cs();
1997 this.green = new cs();
1998 this.blue = new cs();
2000 this.red.primitiveType = this.green.primitiveType = this.blue.primitiveType = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2005 var cs = CSSPrimitiveValue;
2006 this.top = new cs();
2007 this.right = new cs();
2008 this.bottom = new cs();
2009 this.left = new cs();
2014 function Counter() {
2015 this.identifier = this.listStyle = this.separator = "";
2019 function ElementCSSInlineStyle() {
2020 var cs = CSSStyleDeclaration;
2021 this.style = new cs();
2022 this._attributeStyle = new cs(); //プレゼンテーション属性の値を格納する
2038 visibility : "visible",
2039 display : "inline-block",
2043 strokeDasharray : n,
2044 strokeDashoffset : "0",
2045 strokeLinecap : "butt",
2046 strokeLinejoin : "miter",
2047 strokeMiterlimit : "4",
2048 strokeOpacity : "1",
2049 writingMode : "lr-tb",
2050 fontFamily : "serif",
2060 //# Gradient properties:
2062 stopColor : "black",
2064 textAnchor : "start",
2066 // raises(dom::DOMException) on setting
2067 //簡略プロパティに関しては、初期値を再考せよ
2072 overflow : "visible",
2079 verticalAlign : "baseline",
2087 //# Filter Effects properties:
2089 enableBackground : "accumulate",
2091 floodColor : "black",
2093 lightingColor : "white",
2095 //# Interactivity properties:
2097 pointerEvents : "visiblePainted",
2099 //# Color and Painting properties:
2101 colorInterpolation : "sRGB",
2102 colorInterpolationFilters : "linearRGB",
2113 //# Text properties:
2115 alignmentBaseline : "",
2116 baselineShift : "baseline",
2117 dominantBaseline : a,
2118 glyphOrientationHorizontal : "0deg",
2119 glyphOrientationVertical : a,
2121 fillRule : "nonzero"
2124 CSS2Properties.visibility._n = 1; //初期値の設定(_setPaintで使う)
2126 function CSSStyleSheet() {
2127 /*CSSRule*/ this.ownerRule = null;
2128 /*CSSRuleList*/ this.cssRules = [];
2131 CSSStyleSheet.prototype = new StyleSheet();
2132 CSSStyleSheet.constructor = StyleSheet;
2133 /*long*/ CSSStyleSheet.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
2134 var s = new CSSStyleRule(), style = s.style, a, sc = rule.match(/\{[\s\S]+\}/), m;
2135 s.parentStyleSheet = this;
2136 style.cssText = rule;
2138 sc = sc.replace(/^[^a-z\-]+/, "")
2139 .replace(/\:\s+/g, ":")
2140 .replace(/\s*;[^a-z\-]*/g, ";");
2142 for (var i=0, ali=a.length;i<ali;++i) {
2146 style.setProperty(m[0], m[1]);
2150 a = sc = style = void 0;
2151 this.cssRules.splice(index,s,1);
2153 /*void*/ CSSStyleSheet.prototype.deleteRule = function(/*long*/ index) {
2154 this.cssRules.splice(index, 1);
2158 /*getComputedStyle関数
2159 *最近の計算値を取得する。Document.defaultViewはSafariがグローバル(window)にサポートしていないため付ける。
2161 /*interface ViewCSS : views::AbstractView {*/
2162 Document.prototype.defaultView = new ViewCSS();
2166 /*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2167 var s = new CSSStyleDeclaration(),
2170 //クロージャを利用して、カスケーディングを実現する
2171 s.getPropertyCSSValue = (function(elt, td, s){
2172 return function( /*string*/ propertyName) {
2176 while (el && (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0))) {
2177 if (el._runtimeStyle && el._runtimeStyle[propertyName]) {
2178 css = el._runtimeStyle.getPropertyCSSValue(propertyName);
2179 } else if (el.style && el.style[propertyName]) {
2180 css = el.style.getPropertyCSSValue(propertyName);
2181 } else if (el._attributeStyle && el._attributeStyle[propertyName]) {
2183 css = el._attributeStyle.getPropertyCSSValue(propertyName);
2184 } else if (el._rules) {
2186 for (var i=0,eli=el._rules.length;i<eli;++i) {
2187 el._rules[i].style[propertyName] && (css = el._rules[i].style.getPropertyCSSValue(propertyName));
2192 if (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0)) {
2194 td && (css = td[propertyName]);
2196 if (css && css.setRGBColor && ((css.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) || (css.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3))) {
2197 css.setRGBColor(s.getPropertyValue("color"));
2198 } else if (css && (css._em || css._ex || css["_%"])) {
2202 if (el.style._list._fontSize) {
2203 n = el.style._list._fontSize;
2210 } else if (css._ex) {
2212 } else if (css["_%"]) {
2213 n *= css["_%"] / 100;
2215 css.cssText = "font-size:" +n+ "px";
2220 })(elt, this._defaultCSS, s); //_defaultCSSはデフォルト値の設定
2224 es = el.style._list._opacity || el._attributeStyle._list._opacity;
2229 s._list._opacity = eso;
2230 el = pelt = eso = es = void 0;
2231 s._document = elt.ownerDocument;
2235 /*getOverrideStyleメソッド
2236 *指定した要素の上書きスタイルシートを取得。
2238 /*function DocumentCSS : stylesheets::DocumentStyle {*/
2239 /*CSSStyleDeclaration*/ Document.prototype.getOverrideStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2241 if (!!tar._runtimeStyle) {
2242 return (tar._runtimeStyle);
2244 var s = new CSSStyleDeclaration(), setProp = s.setProperty;
2245 tar._runtimeStyle = s;
2247 s.setProperty = (function(setProp, s){
2248 return function(propertyName, value, priority) {
2249 setProp.call(s, propertyName, value, priority);
2250 var tar = elt, el = tar._tar, isFill = isStroke = false;
2251 if ((tar.localName === "g") || (tar.localName === "a")) {
2252 var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
2254 for (var i=0,sli=sl.length;i<sli;++i) {
2256 NAIBU._setPaint(di, di.getScreenCTM());
2266 NAIBU._setPaint(tar, tar.getScreenCTM());
2267 el = tar = value = void 0;
2272 /*createCSSStyleSheetメソッド
2275 /*interface DOMImplementationCSS : DOMImplementation {*/
2276 /*CSSStyleSheet*/ DOMImplementation.createCSSStyleSheet = function( /*string*/ title, /*string*/ media) {
2277 var s = new CSSStyleSheet();
2279 var nm = new MediaList();
2280 nm.mediaText = media;
2281 if (media && (media !== "")) {
2282 var mes = media.split(","); //文字列をコンマで区切って配列に
2283 for (var i=0,mli=mes.length;i<mli;++i) {
2284 nm.appendMedium(mes[i]); //メディアリストに値を加えていく
2300 #pragma prefix "dom.w3c.org"
2303 typedef dom::DOMString DOMString;
2305 /*ElementTimeControlはSVGAnimationElementに統合させる。
2308 function ElementTimeControl(ele) {
2310 /*_beginと_endプロパティはミリ秒数を収納する。リピート時に書き換えられることがある。
2311 *_beginはアニメ開始時の秒数。_endはアニメ終了時の秒数。
2312 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
2318 ElementTimeControl.prototype = {
2319 /*void*/ beginElement : function() {
2320 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2321 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
2322 this.dispatchEvent(evt);
2324 /*void*/ endElement : function() {
2325 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2326 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
2327 this.dispatchEvent(evt);
2329 /*void*/ beginElementAt : function(/*float*/ offset) {
2330 var ntc = this.ownerDocument.documentElement.getCurrentTime();
2331 this._begin = offset + ntc;
2333 /*void*/ endElementAt : function(/*float*/ offset) {
2334 var ntc = this.ownerDocument.documentElement.getCurrentTime();
2335 this._end = offset + ntc;
2339 function TimeEvent() {
2341 /*readonly attribute views::AbstractView*/ this.view;
2342 /*readonly attribute long*/ this.detail;
2345 TimeEvent.counstructor = Event;
2346 TimeEvent.prototype = new Event();
2347 /*void*/ TimeEvent.prototype.initTimeEvent = function(/*DOMString*/ typeArg,
2348 /*views::AbstractView*/ viewArg,
2349 /*long*/ detailArg) {
2350 this.type = typeArg;
2351 this.view = viewArg;
2352 this.detail = detailArg;
2354 //#endif // _SMIL_IDL_
2364 // For access to DOM2 core
2366 // For access to DOM2 events
2367 #include "events.idl"
2368 // For access to those parts from DOM2 CSS OM used by SVG DOM.
2370 // For access to those parts from DOM2 Views OM used by SVG DOM.
2371 #include "views.idl"
2372 // For access to the SMIL OM used by SVG DOM.
2374 #pragma prefix "dom.w3c.org"
2375 #pragma javaPackage "org.w3c.dom"
2378 typedef dom::DOMString DOMString;
2379 typedef dom::DOMException DOMException;
2380 typedef dom::Element Element;
2381 typedef dom::Document Document;
2382 typedef dom::NodeList NodeList;
2384 interface SVGElement;
2385 interface SVGLangSpace;
2386 interface SVGExternalResourcesRequired;
2388 interface SVGFitToViewBox;
2389 interface SVGZoomAndPan;
2390 interface SVGViewSpec;
2391 interface SVGURIReference;
2393 interface SVGMatrix;
2394 interface SVGPreserveAspectRatio;
2395 interface SVGAnimatedPreserveAspectRatio;
2396 interface SVGTransformList;
2397 interface SVGAnimatedTransformList;
2398 interface SVGTransform;
2399 interface SVGICCColor;
2402 interface SVGTransformable;
2403 interface SVGDocument;
2404 interface SVGSVGElement;
2405 interface SVGElementInstance;
2406 interface SVGElementInstanceList;
2408 function SVGException(code) {
2409 /*unsigned short*/ this.code = code;
2410 if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
2411 this.message = "SVG Wrong Type Error";
2412 } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
2413 this.message = "SVG Invalid Value Error";
2414 } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
2415 this.message = "SVG Matrix Not Invertable";
2419 SVGException.constructor = Error;
2420 SVGException.prototype = new Error();
2422 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR = 0;
2423 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR = 1;
2424 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE = 2;
2427 *すべてのSVG関連要素の雛形となるオブジェクト
2429 function SVGElement() {
2431 SVGStylable.call(this); //ElementCSSInlineStyleのインタフェースを継承
2432 /*interface SVGTransformable : SVGLocatable
2433 *TransformListはtransform属性を行列で表現したあとのリスト構造
2435 /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
2436 //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
2437 this.addEventListener("DOMAttrModified", function(evt){
2438 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2441 var name = evt.attrName,
2443 if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
2444 tar._attributeStyle.setProperty(name, evt.newValue, "");
2446 if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
2447 tar.id = evt.newValue;
2448 } else if ((name === "transform") && !!tar.transform) {
2449 var tft = evt.newValue,
2451 coma = tft.match(tar._comaReg), //コマンド文字にマッチ translate
2452 list = tft.match(tar._strReg), //カッコ内のリストにマッチ (10 20 30...)
2462 etod = evt.target.ownerDocument.documentElement,
2463 ttb = tar.transform.baseVal;
2464 //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
2465 for (var j=0,cli=coma.length;j<cli;j++) {
2466 s = etod.createSVGTransform();
2469 deg = lis.match(degR);
2482 s.setRotate(degz, +(deg[1]), +(deg[2]))
2483 } else if (degli <= 2) {
2485 if (com === "translate") {
2486 s.setTranslate(degz, +(deg[1] || 0));
2487 } else if (com === "scale") {
2488 s.setScale(degz, +(deg[1] || deg[0]));
2489 } else if (com === "rotate") {
2490 s.setRotate(degz, 0, 0);
2491 } else if (com === "skewX") {
2493 } else if (com === "skewY") {
2500 tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
2501 } else if (name === "style") {
2502 var sc = evt.newValue,
2510 sc = sc.replace(tar._shouReg, "")
2511 .replace(tar._conReg, ":")
2512 .replace(tar._bouReg, ";");
2514 for (var i=0, ali=a.length;i<ali;++i) {
2518 style.setProperty(m[0], m[1]);
2523 a = sc = style = void 0;
2524 } else if (name === "class") {
2525 tar.className = evt.newValue;
2526 } else if (name.indexOf("on") === 0) { //event属性ならば
2527 /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
2528 *ところが、IEでは、undefinedの値を返してしまう。
2529 *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
2531 eval("document._s = (function(evt){" +evt.newValue+ "})");
2532 var v = name.slice(2);
2535 } else if (v === "unload") {
2537 } else if (v === "abort") {
2539 } else if (v === "error") {
2541 } else if (v === "resize") {
2543 } else if (v === "scroll") {
2545 } else if (v === "zoom") {
2547 } else if (v === "begin") {
2549 } else if (v === "end") {
2551 } else if (v === "repeat") {
2554 tar.addEventListener(v, document._s, false);
2555 } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
2556 tar.xmlbase = evt.newValue;
2557 } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
2558 var tea = tar[name],
2559 tod = tar.ownerDocument.documentElement,
2560 tvw = tod.viewport.width,
2561 tvh = tod.viewport.height,
2563 n = evt.newValue.match(tar._NaNReg),
2564 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
2565 _parseFloat = parseFloat;
2569 if (!n) { //軽量化のためにチェックを設ける
2570 } else if (n === "%") {
2571 if (tar._x1width[name]) {
2572 tea.baseVal._percent = tvw * 0.01;
2573 } else if (tar._y1height[name]) {
2574 tea.baseVal._percent = tvh * 0.01;
2576 tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
2578 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
2579 } else if (n === "em") {
2580 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
2581 } else if (n === "ex") {
2582 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
2583 } else if (n === "px") {
2584 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
2585 } else if (n === "cm") {
2586 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
2587 } else if (n === "mm") {
2588 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
2589 } else if (n === "in") {
2590 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
2591 } else if (n === "pt") {
2592 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
2593 } else if (n === "pc") {
2594 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
2596 s = _parseFloat(evt.newValue);
2597 s = isNaN(s) ? 0 : s;
2598 tea.baseVal.newValueSpecifiedUnits(type, s);
2599 tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
2601 evt = _parseFloat = name = tar = null;
2605 SVGElement.constructor = Element;
2606 SVGElement.prototype = new Element();
2609 /*以下の正規表現は属性のパーサの際に用いる*/
2610 this._degReg = /[\-\d\.e]+/g;
2611 this._comaReg = /[A-Za-z]+(?=\s*\()/g;
2612 this._strReg = /\([^\)]+\)/g;
2613 this._syouReg = /^[^a-z\-]+/;
2614 this._conReg = /\:\s+/g;
2615 this._bouReg = /\s*;[^a-z\-]*/g;
2616 this._NaNReg = /\D+$/;
2617 /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
2620 this._cacheMatrix = null;
2621 /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
2636 /*String*/ this.id = null; //id属性の値
2637 /*String*/ this.xmlbase = null; //xml:base属性の値
2638 /*SVGSVGElement*/ this.ownerSVGElement; //ルート要素であるsvg要素
2639 /*readonly SVGElement*/ this.viewportElement; //ビューポートを形成する要素(多くはsvg要素)
2640 /*readonly attribute SVGElement*/ this.nearestViewportElement = null;
2641 /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
2643 /*interface SVGLocatable*/
2644 /*SVGRect*/ this.getBBox = function(){
2645 var s = new SVGRect(),
2646 data = this._tar.path.value,
2647 vi = this.ownerDocument.documentElement.viewport,
2652 degis = data.match(/[0-9\-]+/g),
2655 /*要素の境界領域を求める(四隅の座標を求める)
2656 *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
2657 *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
2659 for (var i=0,degisli=degis.length;i<degisli;i+=2) {
2662 el = el > nx ? nx : el;
2663 et = et > ny ? ny : et;
2664 er = er > nx ? er : nx;
2665 eb = eb > ny ? eb : ny;
2671 nx = ny = data = degis =el = et = er = eb = vi = void 0;
2676 *CTMとは現在の利用座標系に対する変換行列
2677 *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
2678 *1.2ではgetCTMが言及されていない
2679 *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
2681 /*SVGMatrix*/ this.getCTM = function() {
2683 if (!!this._cacheMatrix) { //キャッシュがあれば
2684 s = this._cacheMatrix;
2686 m = this.transform.baseVal.consolidate();
2690 m = this.ownerDocument.documentElement.createSVGMatrix();
2692 if (this.parentNode && !!this.parentNode.getCTM) {
2693 s = this.parentNode.getCTM().multiply(m);
2698 this._cacheMatrix = s; //キャッシュをためて次回で使う
2703 /*SVGMatrix*/ this.getScreenCTM = function(){
2704 if (!this.parentNode) {
2707 var view = this.nearestViewportElement || this.ownerDocument.documentElement;
2708 var s = view.getScreenCTM().multiply(this.getCTM());
2713 /*getTransformToElementメソッド
2714 *これは、あるelementへの変換行列を計算して返す
2715 *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
2717 /*SVGMatrix*/ this.getTransformToElement = function(/*SVGElement*/ element ){
2718 var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
2721 }).apply(SVGElement.prototype);
2723 function SVGAnimatedBoolean() {
2724 /*boolean*/ this.animVal = this.baseVal = true;
2728 function SVGAnimatedString() {
2729 /*String*/ this.animVal = this.baseVal = "";
2733 function SVGStringList() {
2736 SVGStringList.prototype = new Array();
2738 /*readonly unsigned long*/ this.numberOfItems = 0;
2739 /*void*/ this.clear = function(){
2740 for (var i=0, tli=this.length;i<tli;++i) {
2743 this.numberOfItems = 0;
2745 /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
2748 this.numberOfItems = 1;
2751 /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
2752 if (index >= this.numberOfItems || index < 0) {
2753 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2755 return (this[index]);
2758 /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2759 if (index >= this.numberOfItems) {
2760 this.appendItem(newItem);
2762 this.splice(index, 1, newItem, this.getItem[index]);
2763 ++this.numberOfItems;
2767 /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2768 if (index >= this.numberOfItems || index < 0) {
2769 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2771 this.splice(index, 1, newItem);
2775 //raises( DOMException, SVGException );
2776 /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
2777 if (index >= this.numberOfItems || index < 0) {
2778 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2780 this.splice(index, 1);
2781 --this.numberOfItems;
2785 /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
2786 this[this.numberOfItems] = newItem;
2787 ++this.numberOfItems;
2789 }).apply(SVGStringList.prototype);
2791 function SVGAnimatedEnumeration() {
2792 /*unsigned short*/ this.baseVal = 0;
2793 // raises DOMException on setting
2794 /*readonly unsigned short*/ this.animVal = 0;
2797 function SVGAnimatedInteger() {
2798 /*long*/ this.baseVal = 0;
2799 // raises DOMException on setting
2800 /*readonly long*/ this.animVal = 0;
2803 function SVGNumber() {
2804 /*float*/ this.value = 0;
2805 // raises DOMException on setting
2808 function SVGAnimatedNumber() {
2809 /*float*/ this.baseVal = this.animVal = 0;
2813 function SVGNumberList() {
2816 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2817 SVGNumberList.prototype[prop] = SVGStringList.prototype[prop];
2819 function SVGAnimatedNumberList() {
2820 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
2824 *長さを設定する(単位pxに統一する方便として使う)
2825 *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
2827 function SVGLength() {
2831 // Length Unit Types
2832 /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN = 0;
2833 /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER = 1;
2834 /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
2835 /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS = 3;
2836 /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS = 4;
2837 /*const unsigned short*/ t.SVG_LENGTHTYPE_PX = 5;
2838 /*const unsigned short*/ t.SVG_LENGTHTYPE_CM = 6;
2839 /*const unsigned short*/ t.SVG_LENGTHTYPE_MM = 7;
2840 /*const unsigned short*/ t.SVG_LENGTHTYPE_IN = 8;
2841 /*const unsigned short*/ t.SVG_LENGTHTYPE_PT = 9;
2842 /*const unsigned short*/ t.SVG_LENGTHTYPE_PC = 10;
2845 SVGLength.prototype = {
2846 /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
2847 /*attribute float*/ value : 0, //利用単位における値
2848 /*attribute float*/ valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN, //unitTypeにおける値
2849 /*attribute DOMString*/ valueAsString : "0",
2850 _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
2851 _fontSize : 12, //単位のemとexで使われるfont-sizeの値
2852 /*newValueSpedifiedUnitsメソッド
2853 *新しくunitTypeにおける値を設定する
2854 *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
2856 newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
2858 _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
2859 if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
2860 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
2862 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
2865 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
2868 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
2869 n = this._fontSize * 0.5;
2871 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
2874 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
2877 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
2880 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
2883 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
2887 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2889 this.unitType = unitType;
2890 this.value = valueInSpecifiedUnits * n;
2891 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2892 this.valueAsString = valueInSpecifiedUnits + _s;
2893 valueInSpecifiedUnits = unitType = n = _s = void 0;
2895 /*convertToSpecifiedUnitsメソッド
2896 *valueプロパティを書き換えずに、単位だけを変換する
2898 * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
2899 * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
2900 * alert(x.valueAsString); //20mm
2902 convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
2903 if (this.value === 0) {
2904 this.newValueSpecifiedUnits(unitType, 0);
2908 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2909 v = v / this.value * this.valueInSpecifiedUnits;
2910 this.newValueSpecifiedUnits(unitType, v);
2913 *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
2914 *単位が%の場合は、新しいvalueへと変換させておく
2916 _emToUnit : function (/*float*/ fontSize) {
2917 if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
2918 this._fontSize = fontSize;
2919 this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
2923 function SVGAnimatedLength() {
2924 /*readonly SVGLength*/ this.animVal;
2925 this.baseVal = new SVGLength();
2926 this.baseVal.unitType = 1;
2929 function SVGLengthList() {
2932 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2933 SVGLengthList.prototype[prop] = SVGStringList.prototype[prop];
2935 function SVGAnimatedLengthList() {
2936 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
2939 function SVGAngle() {
2942 SVGAngle.prototype = {
2943 /*readonly attribute unsigned short*/ unitType : 0,
2944 /*attribute float*/ value : 0,
2945 // raises DOMException on setting
2946 /*attribute float*/ valueInSpecifiedUnits : 0,
2947 // raises DOMException on setting
2948 /*attribute DOMString*/ valueAsString : "0",
2949 // raises DOMException on setting
2950 /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
2952 _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
2953 if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
2954 } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
2956 } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
2959 } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
2963 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2965 this.unitType = unitType;
2966 this.value = valueInSpecifiedUnits * n;
2967 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2968 this.valueAsString = valueInSpecifiedUnits + _s;
2970 //raises( DOMException );
2972 /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
2973 if (this.value === 0) {
2974 this.newValueSpecifiedUnits(unitType, 0);
2978 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2979 v = v / this.value * this.valueInSpecifiedUnits;
2980 this.newValueSpecifiedUnits(unitType, v);
2981 //raises( DOMException );
2985 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN = 0;
2986 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
2987 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG = 2;
2988 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD = 3;
2989 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD = 4;
2990 function SVGAnimatedAngle() {
2991 /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
2992 /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
2995 function SVGColor() {
2996 CSSValue.apply(this);
2997 /*readonly css::RGBColor*/ this.rgbColor = new RGBColor();
3002 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN = 0;
3003 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR = 1;
3004 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
3005 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR = 3;
3006 SVGColor.prototype = new CSSValue(); //ノードのプロトタイプチェーンを作って、継承
3007 SVGColor.constructor = CSSValue;
3010 /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
3011 /*readonly SVGICCColor*/ this.iccColor = null;
3012 this._regD = /\d+/g;
3013 this._regDP = /[\d.]+%/g;
3014 /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
3019 if (!rgbColor || (typeof rgbColor !== "string")) {
3020 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3022 rgbColor = this._keywords[rgbColor] || rgbColor;
3023 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
3024 rgbColor = rgbColor.replace(this._regDP, function(s) {
3025 return Math.round((2.55 * parseFloat(s)));
3027 s = rgbColor.match(this._regD);
3028 } else if (rgbColor.indexOf("#") === 0) { //#を含む場合
3030 _parseInt = parseInt;
3031 r = rgbColor.charAt(1);
3032 g = rgbColor.charAt(2);
3033 b = rgbColor.charAt(3)
3034 if (rgbColor.length < 5) {
3035 c = "#" + r + r + g + g + b + b;
3039 s[0] = _parseInt(r+rgbColor.charAt(2), 16)+ "";
3040 s[1] = _parseInt(rgbColor.charAt(3)+rgbColor.charAt(4), 16)+ "";
3041 s[2] = _parseInt(rgbColor.charAt(5)+rgbColor.charAt(6), 16)+ "";
3044 s = rgbColor.match(this._regD);
3045 if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
3047 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3050 this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
3051 this.rgbColor.green.setFloatValue(1, s[1]);
3052 this.rgbColor.blue.setFloatValue(1, s[2]);
3053 rgbColor = s = _parseInt = void 0;
3056 // raises( SVGException );
3057 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
3058 this.colorType = colorType;
3059 if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
3060 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3061 } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
3062 this.setRGBColor(rgbColor);
3063 } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
3064 this.setRGBColor(rgbColor);
3065 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
3066 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3067 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
3068 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3070 colorType = rgbColor = void 0;
3072 // raises( SVGException );
3075 aliceblue: "rgb(240,248,255)",
3076 antiquewhite: "rgb(250,235,215)",
3077 aqua: "rgb(0,255,255)",
3078 aquamarine: "rgb(127,255,212)",
3079 azure: "rgb(240,255,255)",
3080 beige: "rgb(245,245,220)",
3081 bisque: "rgb(255,228,196)",
3082 black: "rgb(0,0,0)",
3083 blanchedalmond:"rgb(255,235,205)",
3084 blue: "rgb(0,0,255)",
3085 blueviolet: "rgb(138,43,226)",
3086 brown: "rgb(165,42,42)",
3087 burlywood: "rgb(222,184,135)",
3088 cadetblue: "rgb(95,158,160)",
3089 chartreuse: "rgb(127,255,0)",
3090 chocolate: "rgb(210,105,30)",
3091 coral: "rgb(255,127,80)",
3092 cornflowerblue:"rgb(100,149,237)",
3093 cornsilk: "rgb(255,248,220)",
3094 crimson: "rgb(220,20,60)",
3095 cyan: "rgb(0,255,255)",
3096 darkblue: "rgb(0,0,139)",
3097 darkcyan: "rgb(0,139,139)",
3098 darkgoldenrod:"rgb(184,134,11)",
3099 darkgray: "rgb(169,169,169)",
3100 darkgreen: "rgb(0,100,0)",
3101 darkgrey: "rgb(169,169,169)",
3102 darkkhaki: "rgb(189,183,107)",
3103 darkmagenta: "rgb(139,0,139)",
3104 darkolivegreen:"rgb(85,107,47)",
3105 darkorange: "rgb(255,140,0)",
3106 darkorchid: "rgb(153,50,204)",
3107 darkred: "rgb(139,0,0)",
3108 darksalmon: "rgb(233,150,122)",
3109 darkseagreen: "rgb(143,188,143)",
3110 darkslateblue:"rgb(72,61,139)",
3111 darkslategray:"rgb(47,79,79)",
3112 darkslategrey:"rgb(47,79,79)",
3113 darkturquoise:"rgb(0,206,209)",
3114 darkviolet: "rgb(148,0,211)",
3115 deeppink: "rgb(255,20,147)",
3116 deepskyblue: "rgb(0,191,255)",
3117 dimgray: "rgb(105,105,105)",
3118 dimgrey: "rgb(105,105,105)",
3119 dodgerblue: "rgb(30,144,255)",
3120 firebrick: "rgb(178,34,34)",
3121 floralwhite: "rgb(255,250,240)",
3122 forestgreen: "rgb(34,139,34)",
3123 fuchsia: "rgb(255,0,255)",
3124 gainsboro: "rgb(220,220,220)",
3125 ghostwhite: "rgb(248,248,255)",
3126 gold: "rgb(255,215,0)",
3127 goldenrod: "rgb(218,165,32)",
3128 gray: "rgb(128,128,128)",
3129 grey: "rgb(128,128,128)",
3130 green: "rgb(0,128,0)",
3131 greenyellow: "rgb(173,255,47)",
3132 honeydew: "rgb(240,255,240)",
3133 hotpink: "rgb(255,105,180)",
3134 indianred: "rgb(205,92,92)",
3135 indigo: "rgb(75,0,130)",
3136 ivory: "rgb(255,255,240)",
3137 khaki: "rgb(240,230,140)",
3138 lavender: "rgb(230,230,250)",
3139 lavenderblush:"rgb(255,240,245)",
3140 lawngreen: "rgb(124,252,0)",
3141 lemonchiffon: "rgb(255,250,205)",
3142 lightblue: "rgb(173,216,230)",
3143 lightcoral: "rgb(240,128,128)",
3144 lightcyan: "rgb(224,255,255)",
3145 lightgoldenrodyellow:"rgb(250,250,210)",
3146 lightgray: "rgb(211,211,211)",
3147 lightgreen: "rgb(144,238,144)",
3148 lightgrey: "rgb(211,211,211)",
3149 lightpink: "rgb(255,182,193)",
3150 lightsalmon: "rgb(255,160,122)",
3151 lightseagree: "rgb(32,178,170)",
3152 lightskyblue: "rgb(135,206,250)",
3153 lightslategray:"rgb(119,136,153)",
3154 lightslategrey:"rgb(119,136,153)",
3155 lightsteelblue:"rgb(176,196,222)",
3156 lightyellow: "rgb(255,255,224)",
3157 lime: "rgb(0,255,0)",
3158 limegreen: "rgb(50,205,50)",
3159 linen: "rgb(250,240,230)",
3160 magenta: "rgb(255,0,255)",
3161 maroon: "rgb(128,0,0)",
3162 mediumaquamarine:"rgb(102,205,170)",
3163 mediumblue: "rgb(0,0,205)",
3164 mediumorchid: "rgb(186,85,211)",
3165 mediumpurple: "rgb(147,112,219)",
3166 mediumseagreen:"rgb(60,179,113)",
3167 mediumslateblue:"rgb(123,104,238)",
3168 mediumspringgreen:"rgb(0,250,154)",
3169 mediumturquoise:"rgb(72,209,204)",
3170 mediumvioletred:"rgb(199,21,133)",
3171 midnightblue: "rgb(25,25,112)",
3172 mintcream: "rgb(245,255,250)",
3173 mistyrose: "rgb(255,228,225)",
3174 moccasin: "rgb(255,228,181)",
3175 navajowhite: "rgb(255,222,173)",
3176 navy: "rgb(0,0,128)",
3177 oldlace: "rgb(253,245,230)",
3178 olive: "rgb(128,128,0)",
3179 olivedrab: "rgb(107,142,35)",
3180 orange: "rgb(255,165,0)",
3181 orangered: "rgb(255,69,0)",
3182 orchid: "rgb(218,112,214)",
3183 palegoldenrod: "rgb(238,232,170)",
3184 palegreen: "rgb(152,251,152)",
3185 paleturquoise: "rgb(175,238,238)",
3186 palevioletred: "rgb(219,112,147)",
3187 papayawhip: "rgb(255,239,213)",
3188 peachpuff: "rgb(255,218,185)",
3189 peru: "rgb(205,133,63)",
3190 pink: "rgb(255,192,203)",
3191 plum: "rgb(221,160,221)",
3192 powderblue: "rgb(176,224,230)",
3193 purple: "rgb(128,0,128)",
3194 red: "rgb(255,0,0)",
3195 rosybrown: "rgb(188,143,143)",
3196 royalblue: "rgb(65,105,225)",
3197 saddlebrown: "rgb(139,69,19)",
3198 salmon: "rgb(250,128,114)",
3199 sandybrown: "rgb(244,164,96)",
3200 seagreen: "rgb(46,139,87)",
3201 seashell: "rgb(255,245,238)",
3202 sienna: "rgb(160,82,45)",
3203 silver: "rgb(192,192,192)",
3204 skyblue: "rgb(135,206,235)",
3205 slateblue: "rgb(106,90,205)",
3206 slategray: "rgb(112,128,144)",
3207 slategrey: "rgb(112,128,144)",
3208 snow: "rgb(255,250,250)",
3209 springgreen: "rgb(0,255,127)",
3210 steelblue: "rgb(70,130,180)",
3211 tan: "rgb(210,180,140)",
3212 teal: "rgb(0,128,128)",
3213 thistle: "rgb(216,191,216)",
3214 tomato: "rgb(255,99,71)",
3215 turquoise: "rgb(64,224,208)",
3216 violet: "rgb(238,130,238)",
3217 wheat: "rgb(245,222,179)",
3218 white: "rgb(255,255,255)",
3219 whitesmoke: "rgb(245,245,245)",
3220 yellow: "rgb(255,255,0)",
3221 yellowgreen: "rgb(154,205,50)"
3223 }).apply(SVGColor.prototype);
3225 function SVGRect() {
3226 /*float*/ this.x = 0;
3227 // raises DOMException on setting
3228 /*float*/ this.y = 0;
3229 // raises DOMException on setting
3230 /*float*/ this.width = 0;
3231 // raises DOMException on setting
3232 /*float*/ this.height = 0;
3233 // raises DOMException on setting
3237 function SVGAnimatedRect() {
3238 /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
3244 /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN : 0,
3245 /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE : 1,
3246 /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
3248 function SVGStylable() {
3249 /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
3250 /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
3251 this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
3252 //styleのcssTextプロパティを解析するリスナーを登録しておく
3254 /*getPresentationAttributeメソッド
3255 *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
3257 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
3258 var s = this._attributeStyle.getPropertyCSSValue(name);
3266 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
3267 *SIEでは、もっぱらXLink言語の処理を行う
3269 function SVGURIReference() {
3270 /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
3271 this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
3273 this.addEventListener("DOMAttrModified", function(evt){
3274 if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
3275 evt.target.href.baseVal = evt.newValue;
3276 /*_svgload_limitedを+1とすることで、
3277 *SVGLoadイベントは発火されなくなる。1を引く必要がある
3279 evt.target.ownerDocument.documentElement._svgload_limited++;
3283 this.addEventListener("DOMNodeInserted", function(evt){
3284 var tar = evt.target;
3285 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3288 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3289 var tar = evt.target,
3291 href = tar.href.baseVal,
3292 show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
3293 /*xlink:href属性とxml:base属性を手がかりに、
3294 *ハイパーリンクのURIを決定する処理を行う
3296 if (href !== "") { //xlink:href属性が指定されたとき
3297 egbase = tar.xmlbase;
3299 ep = tar.parentNode;
3306 if (!b) { //xml:baseの指定がなければ
3307 if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
3309 base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
3311 base = location.href;
3317 if (href.indexOf(":") !== -1) { //絶対URIの場合
3321 show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
3322 if (href.indexOf(".") === 0) { //相対URIの場合
3325 if (show === "replace") {
3326 tar._tar.setAttribute("href", uri);
3327 } else if (show === "new") {
3328 tar._tar.setAttribute("target", "_blank");
3329 tar._tar.setAttribute("href", uri);
3330 } else if (show === "embed") {
3331 xmlhttp = NAIBU.xmlhttp;
3332 ui = uri.indexOf("#");
3334 id = uri.slice(ui+1);
3335 uri = uri.replace(/#.+$/, "");
3339 if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
3340 doc = tar.ownerDocument;
3341 ele = doc.getElementById(id);
3342 tar._instance = ele;
3343 ev = doc.createEvent("SVGEvents");
3344 ev.initEvent("S_Load", false, false);
3345 tar.dispatchEvent(ev);
3346 tar = xmlhttp = void 0;
3347 } else if (uri.indexOf("data:") > -1) {
3349 tar = xmlhttp = void 0;
3350 } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
3351 if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
3354 /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
3355 tar.ownerDocument.documentElement._svgload_limited++;
3356 xmlhttp.open("GET", uri, false);
3357 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3358 xmlhttp.onreadystatechange = function() {
3359 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
3360 var type = xmlhttp.getResponseHeader('Content-Type') || "text",
3362 if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
3363 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
3364 *ここでは、responseTextを用いる
3366 /*script要素とstyle要素は、
3367 *_textプロパティに読み込んだテキストを格納しておく
3368 *それら以外は、_instanceプロパティにDOMツリーを格納しておく
3370 if (tar.localName !== "script" && tar.localName !== "style") {
3371 doc = new ActiveXObject("MSXML2.DomDocument");
3372 str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
3373 NAIBU.doc.async = false;
3374 NAIBU.doc.validateOnParse = false;
3375 NAIBU.doc.resolveExternals = false;
3376 NAIBU.doc.preserveWhiteSpace = false;
3378 ele = doc.documentElement;
3379 tar._instance = tar.ownerDocument.importNode(ele, true);
3381 tar._instance = tar._instance.ownerDocument.getElementById(id);
3384 tar._text = xmlhttp.responseText;
3386 } else if (!!tar._tar) {
3389 /*S_LoadイベントとはSIE独自のイベント。
3390 *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
3392 ev = tar.ownerDocument.createEvent("SVGEvents");
3393 ev.initEvent("S_Load", false, false);
3394 tar.dispatchEvent(ev);
3395 tar.ownerDocument.documentElement._svgload_limited--;
3396 /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
3397 if (tar.ownerDocument.documentElement._svgload_limited < 0) {
3398 ev = tar.ownerDocument.createEvent("SVGEvents");
3399 ev.initEvent("SVGLoad", false, false);
3400 tar.ownerDocument.documentElement.dispatchEvent(ev);
3402 tar = type = doc = str = ev = void 0;
3403 /*IEのメモリリーク対策として、空関数を入力*/
3404 xmlhttp.onreadystatechange = NAIBU.emptyFunction;
3412 tar.ownerDocument.documentElement._svgload_limited--;
3414 evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
3420 function SVGCSSRule() {
3421 CSSRule.apply(this, arguments);
3422 // Additional CSS RuleType to support ICC color specifications
3423 /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
3426 SVGCSSRule.constructor = CSSRule;
3427 SVGCSSRule.prototype = new CSSRule(); //ノードのプロトタイプチェーンを作って、継承
3432 function SVGDocument(){
3433 Document.apply(this);
3434 DocumentStyle.apply(this);
3435 /*readonly DOMString*/ this.title = "";
3436 /*readonly DOMString*/ this.referrer = document.referrer;
3437 /*readonly DOMString*/ this.domain = document.domain;
3438 /*readonly DOMString*/ this.URL = document.location;
3439 /*readonly SVGSVGElement*/ this.rootElement;
3442 SVGDocument.constructor = Document;
3443 SVGDocument.prototype = new Document(); //ノードのプロトタイプチェーンを作って、継承
3448 function SVGSVGElement(_doc) {
3449 SVGElement.apply(this, arguments);
3450 this._tar = _doc.createElement("v:group");
3452 /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
3453 * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
3454 this._svgload_limited = 0;
3458 SVGExternalResourcesRequired,
3463 events::EventTarget,
3464 events::DocumentEvent,
3466 css::DocumentCSS {*/
3467 /*以下のx,y,width,heightプロパティは
3468 *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
3469 *1000というのは、W3Cで触れていないため、独自の初期値を採用
3471 var slen = SVGAnimatedLength;
3472 /*readonly SVGAnimatedLength*/ this.x = new slen();
3473 /*readonly SVGAnimatedLength*/ this.y = new slen();
3474 /*readonly SVGAnimatedLength*/ this.width = new slen();
3475 /*readonly SVGAnimatedLength*/ this.height = new slen();
3477 /*DOMString*/ this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
3478 /*DOMString*/ this.contentStyleType = "text/css";
3479 /*readonly SVGRect*/ this.viewport = this.createSVGRect();
3480 /*useCurrentViewプロパティ
3481 * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
3483 /*boolean*/ this.useCurrentView = false;
3485 * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
3487 /*readonly SVGViewSpec*/ this.currentView = new SVGViewSpec(this);
3488 /*もし、画像をズームやパンしたとき、どのような倍率になるかを
3489 *以下のプロパティを使って次の行列で示すことができる
3490 *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]
3492 /*float*/ this.currentScale = 1;
3493 /*readonly SVGPoint*/ this.currentTranslate = this.createSVGPoint();
3494 /*以下は、SVGFitToViewBoxのインターフェースを用いる
3495 *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
3497 /*readonly SVGAnimatedRect*/ this.viewBox = this.currentView.viewBox;
3498 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
3499 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
3502 /*int*/ this._currentTime = 0;
3503 /*DOMAttrModifiedイベントを利用して、
3504 *随時、属性の値をDOMプロパティに変換しておくリスナー登録
3506 this.addEventListener("DOMAttrModified", function(evt){
3507 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3510 var tar = evt.target,
3511 name = evt.attrName,
3512 tv, ovb, par, tp, sa, mos;
3513 if (name === "viewBox") {
3514 tar._cacheScreenCTM = null;
3515 tv = tar.viewBox.baseVal;
3516 ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3517 tv.x = parseFloat(ovb[0]);
3518 tv.y = parseFloat(ovb[1]);
3519 tv.width = parseFloat(ovb[2]);
3520 tv.height = parseFloat(ovb[3]);
3521 tar.viewBox.baseVal._isUsed = 1;
3522 } else if (name === "preserveAspectRatio") {
3523 tar._cacheScreenCTM = null;
3525 tp = tar.preserveAspectRatio.baseVal;
3527 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
3528 if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
3529 switch (RegExp.$1) {
3540 switch (RegExp.$2) {
3550 if (RegExp.$3 === "slice") {
3551 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
3553 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
3557 tp.meetOrSlice = mos;
3558 } else if (name === "width") {
3560 tar.viewport.width = tar.width.baseVal.value;
3561 } else if (name === "height") {
3562 tar.viewport.height = tar.height.baseVal.value;
3564 evt = name = tv = ovb = par = tp = sa = mos = void 0;
3566 this.addEventListener("SVGLoad", function(evt){
3567 /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
3568 *処理を書いたもの。属性が書き換わるたびに、再描画される
3570 evt.target.addEventListener("DOMAttrModified", function(evt){
3573 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3575 if (tar.parentNode) {
3576 evtt = tar.ownerDocument.createEvent("MutationEvents");
3577 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3579 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3580 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3581 for (var j=0,tcli=tce.length;j<tcli;++j){
3583 tce[j].handleEvent(evtt);
3586 if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
3587 tar._cacheMatrix = void 0; //キャッシュを消去
3588 if (tar.firstChild) {
3589 slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
3590 for (var i=0,sli=slist.length;i<sli;++i) {
3592 tar._cacheMatrix = void 0;
3593 evtt = tar.ownerDocument.createEvent("MutationEvents");
3594 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3596 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3597 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3598 for (var j=0,tcli=tce.length;j<tcli;++j){
3600 tce[j].handleEvent(evtt);
3608 evtt = tar = evt = tce = slist = void 0;
3614 SVGSVGElement.constructor = SVGElement;
3615 SVGSVGElement.prototype = new SVGElement();
3616 /*void*/ SVGSVGElement.prototype.forceRedraw = function() {
3618 /*float*/ SVGSVGElement.prototype.getCurrentTime = function(){
3619 return (this._currentTime);
3621 /*void*/ SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
3622 this._currentTime = seconds;
3624 /*SVGNumber*/ SVGSVGElement.prototype.createSVGNumber = function(){
3625 var s = new SVGNumber();
3629 /*SVGAngle*/ SVGSVGElement.prototype.createSVGAngle = function(){
3630 var s = new SVGAngle();
3635 /*SVGLength*/ SVGSVGElement.prototype.createSVGLength = function(){
3636 var s = new SVGLength();
3637 s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
3640 /*SVGPoint*/ SVGSVGElement.prototype.createSVGPoint = function(){
3641 return new SVGPoint();
3643 /*SVGMatrix*/ SVGSVGElement.prototype.createSVGMatrix = function(){
3645 return new SVGMatrix();
3647 /*SVGRect*/ SVGSVGElement.prototype.createSVGRect = function(){
3648 return new SVGRect();
3650 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransform = function(){
3651 var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
3654 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
3655 var s = new SVGTransform();
3656 s.setMatrix(matrix);
3660 *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
3662 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
3663 if (!!this._cacheScreenCTM) { //キャッシュがあれば
3664 return (this._cacheScreenCTM);
3666 var vw = this.viewport.width,
3667 vh = this.viewport.height,
3668 vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
3669 if (!this.useCurrentView) {
3670 vB = this.viewBox.baseVal;
3671 par = this.preserveAspectRatio.baseVal;
3673 vB = this.currentView.viewBox.baseVal;
3674 par = this.currentView.preserveAspectRatio.baseVal;
3676 if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
3677 this._tx = this._ty = 0;
3678 m = this.createSVGMatrix();
3679 this._cacheScreenCTM = m; //キャッシュを作っておく
3692 if (par.align === 1) { //none
3698 var ax = (par.align + 1) % 3 + 1;
3699 var ay = Math.round(par.align / 3);
3700 switch (par.meetOrSlice) {
3702 xr = yr = Math.min(rw, rh);
3705 xr = yr = Math.max(rw, rh);
3714 tx += (vw - vbw * xr) / 2;
3717 tx += vw - vbw * xr;
3724 ty += (vh - vbh * yr) / 2;
3727 ty += vh - vbh * yr;
3732 //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
3735 ttps = this._tar.style;
3736 ttps.marginLeft = tx+ "px";
3737 ttps.marginTop = ty+ "px";
3738 m = this.createSVGMatrix();
3741 this._cacheScreenCTM = m; //キャッシュを作っておく
3742 vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
3746 /*interface SVGZoomAndPan*/
3747 // Zoom and Pan Types
3749 /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
3750 /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
3751 /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
3754 function SVGFitToViewBox() {
3755 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
3756 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3759 function SVGViewSpec(ele) {
3760 SVGFitToViewBox.apply(this, arguments);
3761 /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
3762 /*readonly SVGElement*/ this.viewTarget = ele;
3763 /*readonly DOMString*/ this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
3766 SVGViewSpec.constructor = SVGFitToViewBox;
3767 SVGViewSpec.prototype = new SVGFitToViewBox();
3769 function SVGGElement(_doc) {
3770 SVGElement.apply(this);
3771 this._tar = _doc.createElement("v:group");
3773 /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
3774 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
3776 this.addEventListener("DOMNodeInserted", function(evt){
3777 var tar = evt.target;
3778 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3781 var tnext = tar.nextSibling,
3782 tpart = tar.parentNode._tar,
3784 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3785 tpart.insertBefore(tar._tar, tnext._tar);
3786 } else if (tnext && !tnext._tar && tpart) {
3787 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3788 *use要素や実体参照などは_tarプロパティがないことに注意
3791 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3792 tpart.insertBefore(tar._tar, tnext._tar);
3795 tnext = tnext.nextSibling;
3798 tpart.appendChild(tar._tar);
3800 } else if (!tnext && tpart) {
3801 tpart.appendChild(tar._tar);
3803 tnext = tpart = isLast = evt = tar = void 0;
3807 SVGGElement.constructor = SVGElement;
3808 SVGGElement.prototype = new SVGElement();
3810 function SVGDefsElement() {
3811 SVGElement.apply(this, arguments);
3812 this.style.setProperty("display", "none");
3815 SVGDefsElement.constructor = SVGElement;
3816 SVGDefsElement.prototype = new SVGElement();
3818 function SVGDescElement() {
3819 SVGElement.apply(this, arguments);
3822 SVGDescElement.constructor = SVGElement;
3823 SVGDescElement.prototype = new SVGElement();
3825 function SVGTitleElement() {
3826 SVGElement.apply(this, arguments);
3827 this.addEventListener("DOMCharacterDataModified", function(evt){
3828 evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
3832 SVGTitleElement.constructor = SVGElement;
3833 SVGTitleElement.prototype = new SVGElement();
3835 function SVGSymbolElement() {
3836 SVGElement.apply(this, arguments);
3837 SVGURIReference.apply(this);
3840 SVGDefsElement.constructor = SVGElement;
3841 SVGDefsElement.prototype = new SVGElement();
3843 function SVGUseElement() {
3844 SVGGElement.apply(this, arguments);
3845 var slen = SVGAnimatedLength;
3846 /*readonly SVGAnimatedLength*/ this.x = new slen(); //use要素のx属性に対応(以下、同様)
3847 /*readonly SVGAnimatedLength*/ this.y = new slen();
3848 /*readonly SVGAnimatedLength*/ this.width = new slen();
3849 /*readonly SVGAnimatedLength*/ this.height = new slen();
3851 /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
3852 /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
3853 this.addEventListener("DOMNodeInserted", function(evt){
3854 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3857 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3859 this.addEventListener("S_Load", function(evt){
3860 var tar = evt.target,
3861 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3862 fontSize = parseFloat(style.getPropertyValue("font-size")),
3863 tgtb = tar.transform.baseVal,
3864 trans = tar.ownerDocument.documentElement.createSVGTransform();
3865 tar.x.baseVal._emToUnit(fontSize);
3866 tar.y.baseVal._emToUnit(fontSize);
3867 tar.width.baseVal._emToUnit(fontSize);
3868 tar.height.baseVal._emToUnit(fontSize);
3869 tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tar._instance, true);
3870 trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
3871 tgtb.appendItem(trans);
3872 tar.appendChild(tar.instanceRoot);
3873 evt = trans = tar = evtt = tgtb = style = fontSize = void 0;
3875 SVGURIReference.apply(this);
3878 SVGUseElement.constructor = SVGElement;
3879 SVGUseElement.prototype = new SVGElement();
3881 function SVGElementInstance() {
3885 Node.apply(this, arguments);
3886 /*readonly SVGElement*/ this.correspondingElement; //use要素で使われる参照先の要素
3887 /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
3888 /*readonly SVGElementInstance*/ this.parentNode;
3889 /*readonly SVGElementInstanceList*/ this.childNodes;
3890 /*readonly SVGElementInstance*/ this.firstChild;
3891 /*readonly SVGElementInstance*/ this.lastChild;
3892 /*readonly SVGElementInstance*/ this.previousSibling;
3893 /*readonly SVGElementInstance*/ this.nextSibling;
3896 SVGElementInstance.prototype = new Node();
3897 /*SVGElementInstanceList
3899 function SVGElementInstanceList() {
3900 /*readonly unsigned long*/ this.length = 0;
3903 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
3904 return (this[index]);
3906 function SVGImageElement(_doc) {
3907 SVGElement.apply(this, arguments);
3908 this._tar = _doc.createElement("v:image");
3909 //以下は、与えられた属性の値に対応する
3910 var slen = SVGAnimatedLength;
3911 /*readonly SVGAnimatedLength*/ this.x = new slen();
3912 /*readonly SVGAnimatedLength*/ this.y = new slen();
3913 /*readonly SVGAnimatedLength*/ this.width = new slen();
3914 /*readonly SVGAnimatedLength*/ this.height = new slen();
3915 _doc = slen = void 0;
3916 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3917 this.addEventListener("DOMNodeInserted", function(evt){
3918 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3921 var tar = evt.target;
3922 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3923 if (tar.nextSibling) {
3924 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
3925 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
3927 } else if (!!tar.parentNode._tar){
3928 tar.parentNode._tar.appendChild(tar._tar);
3930 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3931 var tar = evt.target,
3932 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3933 fontSize = parseFloat(style.getPropertyValue("font-size")),
3934 ts = tar._tar.style,
3935 ctm = tar.getScreenCTM(),
3936 po = tar.ownerDocument.documentElement.createSVGPoint(),
3937 fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
3939 tar.x.baseVal._emToUnit(fontSize);
3940 tar.y.baseVal._emToUnit(fontSize);
3941 tar.width.baseVal._emToUnit(fontSize);
3942 tar.height.baseVal._emToUnit(fontSize);
3943 ts.position = "absolute";
3944 po.x = tar.x.baseVal.value;
3945 po.y = tar.y.baseVal.value;
3946 po = po.matrixTransform(ctm);
3947 ts.left = po.x + "px";
3948 ts.top = po.y + "px";
3949 ts.width = tar.width.baseVal.value * ctm.a + "px";
3950 ts.height = tar.height.baseVal.value * ctm.d + "px";
3951 if (fillOpacity !== 1) {
3952 ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
3953 ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
3955 ttfia.Opacity = fillOpacity * 100;
3958 evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
3962 SVGURIReference.apply(this);
3965 SVGImageElement.constructor = SVGElement;
3966 SVGImageElement.prototype = new SVGElement();
3968 function SVGSwitchElement() {
3969 SVGElement.apply(this, arguments);
3972 SVGSwitchElement.constructor = SVGElement;
3973 SVGSwitchElement.prototype = new SVGElement();
3975 //bookmarkletから呼び出されたらtrue
3977 function GetSVGDocument(ele) {
3983 if ((NAIBU._that.xmlhttp.readyState === 4) && (NAIBU._that.xmlhttp.status === 200)) {
3987 GetSVGDocument.prototype = {
3989 *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
3991 _init : function() {
3992 /*objeiはobject要素かembed要素*/
3993 var xmlhttp = NAIBU.xmlhttp,
3996 if (this._tar.nodeName === "OBJECT") {
4001 xmlhttp.open("GET", objei.getAttribute(data), true);
4002 objei.style.display = "none";
4003 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
4004 this.xmlhttp = xmlhttp;
4005 /*クロージャを利用しないことで、軽量化を計る*/
4007 xmlhttp.onreadystatechange = _ca_;
4009 xmlhttp = objei = data = void 0;
4013 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
4014 *ここでは、responseTextを用いる
4016 var ifr = this._tar.previousSibling,
4017 ifcw = ifr.contentWindow,
4020 ifr.contentWindow.screen.updateInterval = 999;
4021 _doc = ifr.contentWindow.document;
4023 _doc.close(); // これがないと document.body は null になる
4024 } else { //インラインSVGの場合
4027 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
4028 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
4029 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
4030 var st = _doc.createStyleSheet(),
4031 vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
4032 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
4033 + "dn\\:defs{display:none}"
4034 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
4035 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
4036 st = vmlUrl = void 0;
4038 DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
4039 var str = this.xmlhttp.responseText,
4041 s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
4042 tar = s.documentElement,
4043 tview = tar.viewport,
4044 objw, objh, fi, n, attr, att, w, h,
4046 sp = _doc.createElement("div"),
4047 dcp = _doc.createElement("v:group"),
4048 backr = _doc.createElement("v:rect"),
4049 style, fontSize, sw, sh, trstyle, tpstyle, backrs, viewWidth, viewHeight, backdown, backright,
4051 _parseFloat = parseFloat,
4052 ndoc = NAIBU.doc || this.xmlhttp.responseXML,
4053 oba = _doc.createElement("div"); //obaはradialGradient要素で使う
4054 if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
4055 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4058 s._iframe = ifr; //_iframeプロパティはSVGAElementでリンク置換のときに扱う
4059 oba.setAttribute("id","_NAIBU_outline");
4060 _doc.body.appendChild(oba);
4061 sp.style.margin = "-1px,0px,0px,-1px"
4063 _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
4066 /*下記のプロパティについては、Microsoftのサイトを参照
4067 *ResolveExternals Property [Second-level DOM]
4068 * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
4069 *ValidateOnParse Property [Second-level DOM]
4070 * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
4072 ndoc.validateOnParse = false;
4073 ndoc.resolveExternals = false;
4074 ndoc.preserveWhiteSpace = true;
4075 ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
4076 /*IE6-8のみで使えるupdateIntervalは、
4077 *描画間隔の調整が可能。デフォルトは0。
4078 *スクロール時にバグが起きるので、0に戻してやる必要がある。
4080 screen.updateInterval = 999;
4081 if (/&[^;]+;/.test(str)) {
4083 *代替の処理を用いて、実体参照を処理するもの
4086 var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
4087 for (var i=0; i<enti.length; i++) {
4088 var map = enti.item(i);
4089 var regex = new RegExp("&"+map.nodeName+";", "g");
4090 tmp = tmp.replace(regex, map.firstChild.xml);
4097 tview.width = objei.clientWidth;
4098 tview.height = objei.clientHeight;
4099 if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4100 tview.height = screen.availHeight;
4102 if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4103 tar.viewport.height = screen.width;
4105 objw = objei.getAttribute("width");
4106 objh = objei.getAttribute("height");
4108 tar.setAttributeNS(null, "width", objw);
4111 tar.setAttributeNS(null, "height", objh);
4113 fi = ndoc.documentElement.firstChild;
4114 attr = ndoc.documentElement.attributes;
4115 /*ルート要素のNamedNodeMapを検索する*/
4116 for (var i=0,atli=attr.length;i<atli;++i) {
4117 att = s.importNode(attr[i], false);
4118 tar.setAttributeNodeNS(att);
4120 str = attr = void 0;
4121 dcp.style.width = tview.width+ "px";
4122 dcp.style.height = tview.height+ "px";
4123 dcp.coordsize = tview.width+ " " +tview.height;
4124 sp.appendChild(dcp);
4126 _doc.body.appendChild(sp);
4128 this._tar.parentNode.insertBefore(sp, this._tar);
4130 dcp.appendChild(sdt);
4131 while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
4132 n = s.importNode(fi, true);
4134 fi = fi.nextSibling;
4137 /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
4138 *ドキュメントにそのオブジェクトを結び付けておく
4141 /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
4144 style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
4145 fontSize = _parseFloat(style.getPropertyValue("font-size"));
4146 tar.x.baseVal._emToUnit(fontSize);
4147 tar.y.baseVal._emToUnit(fontSize);
4148 tar.width.baseVal._emToUnit(fontSize);
4149 tar.height.baseVal._emToUnit(fontSize);
4150 sw = tar.width.baseVal.value;
4151 sh = tar.height.baseVal.value;
4152 backr.style.position = "absolute";
4155 backr.style.width = w+ "px";
4156 backr.style.height = h+ "px";
4157 backr.style.zIndex = -1;
4158 backr.stroked = "false";
4159 backr.filled = "false";
4160 tar._tar.appendChild(backr);
4161 trstyle = tar._tar.style;
4162 tpstyle = objei.style;
4163 trstyle.visibility = "visible";
4164 trstyle.position = "absolute";
4166 trstyle.overflow = "hidden";
4168 viewWidth = w > sw ? sw : w;
4169 viewHeight = h > sh ? sh : h;
4170 backrs = backr.currentStyle;
4171 bfl = _parseFloat(backrs.left);
4172 bft = _parseFloat(backrs.top);
4173 bl = -tar._tx; //blやbtは、ずれを調整するのに使う
4175 if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
4177 dcp.style.left = -bl+ "px";
4179 if (bft !== 0 && !isNaN(bfl)) {
4181 dcp.style.top = -bt+ "px";
4183 backright = bl + viewWidth + 1;
4184 backdown = bt + viewHeight + 1;
4185 trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
4187 if ("_svgload_limited" in s.documentElement) {
4188 /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
4189 *xlink:href属性が指定されるたびに+1となる。
4190 *0以外は、SVGLoadイベントが発火されない仕組みとなっている
4193 * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
4195 s.documentElement._svgload_limited--;
4196 if (s.documentElement._svgload_limited < 0) {
4197 var evt = s.createEvent("SVGEvents");
4198 evt.initEvent("SVGLoad", false, false);
4199 s.documentElement.dispatchEvent(evt);
4203 text = s.documentElement._tar.getElementsByTagName("div");
4204 for (var i=0, texti;text[i];++i) {
4206 if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
4207 var tis = texti.style;
4208 tis.left = _parseFloat(tis.left) + bl + "px";
4209 tis.top = _parseFloat(tis.top) + bt + "px";
4213 //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
4214 ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
4215 s._isLoaded = 1; //_isLoadedプロパティはevents::dispatchEventメソッドで使う
4216 s.defaultView._cache = s.defaultView._cache_ele = null;
4217 oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
4218 trstyle = tpstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
4219 /*IEのメモリリーク対策として、空関数を入力*/
4220 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4222 ifcw && (ifr.contentWindow.screen.updateInterval = 0);
4223 ifr = ifcw = s = void 0;
4227 if (s.implementation._buffer_) {
4228 screen.updateInterval = 0;
4229 /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
4230 NAIBU._buff_num = 0;
4231 NAIBU._buff = setInterval(function(){
4232 var n = NAIBU._buff_num,
4233 dbuf = DOMImplementation._buffer_,
4234 dbufli = dbuf.length,
4237 clearInterval(NAIBU._buff);
4239 for (var i=0;i<50;++i) {
4242 s.dispatchEvent(evt);
4246 clearInterval(NAIBU._buff);
4247 DOMImplementation._buffer_ = null;
4249 dbuf = n = dbufli = void 0;
4253 NAIBU._buff_num = n;
4255 dbuf = n = dbufli = void 0;
4257 ifr = ifcw = s = void 0;
4259 ifr = ifcw = s = void 0;
4265 /*SVGDocument*/ getSVGDocument : function() {
4266 return (this._document);
4269 /*空関数(IEのメモリリーク対策)*/
4270 NAIBU.emptyFunction = function() {};
4275 function SVGStyleElement(_doc) {
4276 SVGElement.apply(this);
4277 LinkStyle.apply(this);
4278 /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
4279 *CSS2 1. Document Object Model Style Sheets
4280 * 1.3. Document Extensions
4281 * Interface LinkStyle (introduced in DOM Level 2)
4282 * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
4284 /*以下はそれぞれ、属性の値に対応している*/
4285 /*DOMString*/ this.xmlspace;
4286 /*DOMString*/ this.type = "text/css";
4287 /*DOMString*/ this.media;
4288 /*DOMString*/ this.title;
4289 SVGURIReference.apply(this);
4290 this.addEventListener("DOMAttrModified", function(evt){
4291 if (evt.attrName === "type") {
4292 evt.target.type = evt.newValue;
4293 } else if (evt.attrName === "title") {
4294 evt.target.title = evt.newValue;
4298 this.addEventListener("S_Load", function(evt){
4299 var tar = evt.target,
4301 styleText = tar._text,
4302 tod = tar.ownerDocument,
4303 style = _doc.createElement("style"),
4305 NAIBU._temp_doc = tod;
4306 sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
4307 sheet.ownerNode = tar;
4308 /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
4309 _doc.documentElement.firstChild.appendChild(style);
4310 style.styleSheet.cssText = styleText;
4311 for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
4313 scri = new CSSStyleRule();
4314 scri.selectorText = ri.selectorText;
4315 scri.style.cssText = ri.style.cssText;
4316 rsc = scri.style.cssText.split(";");
4317 for (var j=0, rsli=rsc.length;j<rsli;++j) {
4318 rsi = rsc[j].split(": ");
4319 scri.style.setProperty(rsi[0], rsi[1]);
4321 sheet.cssRules[sheet.cssRules.length] = scri;
4323 tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4324 var tar = evt.target,
4325 doc = tar.ownerDocument,
4326 rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
4327 selector, ru, tcb = tar.className.baseVal || ".,.";
4328 for (var i=0, rli=rules.length;i<rli;++i) {
4329 selector = rules[i].selectorText;
4330 /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
4331 ru = tar._rules || [];
4332 if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
4333 || (tar.nodeName === selector)) {
4334 ru[ru.length] = rules[i];
4338 tar = doc = rules = void 0;
4340 tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
4342 this.addEventListener("DOMNodeInserted", function(evt){
4343 var tar = evt.target;
4344 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4345 if (tar.nodeName === "#cdata-section") {
4346 evt.currentTarget._text = tar.data;
4350 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4351 var tar = evt.target;
4352 if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
4353 var evtt = tar.ownerDocument.createEvent("SVGEvents");
4354 evtt.initEvent("S_Load", false, false);
4355 evt.currentTarget.dispatchEvent(evtt);
4362 SVGStyleElement.constructor = SVGElement;
4363 SVGStyleElement.prototype = new SVGElement();
4366 *2次元座標の点(x,y)を表すオブジェクト
4368 function SVGPoint() {
4371 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
4372 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
4373 /*整数にしているのは、VMLの設計上、小数点を扱えないときがあるため*/
4374 var x = parseInt(matrix.a * this.x + matrix.c * this.y + matrix.e);
4375 var y = parseInt(matrix.b * this.x + matrix.d * this.y + matrix.f);
4376 if ((-1 < x) && (x < 1)) {x=1;}
4377 if ((-1 < y) && (y < 1)) {y=1;}
4378 var s = new SVGPoint();
4384 function SVGPointList() {
4387 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4388 SVGPointList.prototype[prop] = SVGStringList.prototype[prop];
4392 *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
4397 function SVGMatrix() {
4400 SVGMatrix.prototype = {
4410 /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
4411 var s = new SVGMatrix(), m = secondMatrix;
4412 if (!isFinite(m.a) || !isFinite(m.b) || !isFinite(m.c) || !isFinite(m.d) || !isFinite(m.e) || !isFinite(m.f)) {
4413 throw (new Error("引数の値がNumber型ではありません"));
4415 s.a = this.a * m.a + this.c * m.b;
4416 s.b = this.b * m.a + this.d * m.b;
4417 s.c = this.a * m.c + this.c * m.d;
4418 s.d = this.b * m.c + this.d * m.d;
4419 s.e = this.a * m.e + this.c * m.f + this.e;
4420 s.f = this.b * m.e + this.d * m.f + this.f;
4421 m = secondMatrix = void 0;
4427 /*SVGMatrix*/ inverse : function() {
4428 var s = new SVGMatrix(), n = this._determinant();
4434 s.e = (this.c * this.f - this.d * this.e) / n;
4435 s.f = (this.b * this.e - this.a * this.f) / n;
4438 throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
4441 /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
4442 var m = new SVGMatrix();
4445 var s = this.multiply(m);
4449 /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
4450 var m = new SVGMatrix();
4453 var s = this.multiply(m);
4457 /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
4458 var m = new SVGMatrix();
4461 var s = this.multiply(m);
4465 /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
4466 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4467 m.a = Math.cos(rad);
4468 m.b = Math.sin(rad);
4471 var s = this.multiply(m);
4475 //座標(x, y)と原点の角度の分だけ、回転する
4476 /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
4477 if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
4478 throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
4480 var m = new SVGMatrix(), rad = Math.atan2(y, x);
4481 m.a = Math.cos(rad);
4482 m.b = Math.sin(rad);
4485 var s = this.multiply(m);
4489 /*SVGMatrix*/ flipX : function() {
4490 var m = new SVGMatrix();
4492 var s = this.multiply(m);
4496 /*SVGMatrix*/ flipY : function() {
4497 var m = new SVGMatrix();
4499 var s = this.multiply(m);
4503 /*SVGMatrix*/ skewX : function(/*float*/ angle ){
4504 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4505 m.c = Math.tan(rad);
4506 var s = this.multiply(m);
4510 /*SVGMatrix*/ skewY : function(/*float*/ angle ){
4511 var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
4512 m.b = Math.tan(rad);
4513 var s = this.multiply(m);
4518 /*float*/ _determinant : function() {
4519 return (this.a * this.d - this.b * this.c);
4523 function SVGTransform() {
4524 /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
4528 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN = 0;
4529 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX = 1;
4530 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
4531 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE = 3;
4532 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE = 4;
4533 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX = 5;
4534 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY = 6;
4535 SVGTransform.prototype = {
4536 /*ダミーの単位行列。各メソッドで使う*/
4537 _matrix : (new SVGMatrix()),
4538 /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
4539 /*readonly float*/ angle : 0,
4540 /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
4541 this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
4542 this.matrix = this._matrix.multiply(matrix);
4544 /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
4545 this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
4546 this.matrix = this._matrix.translate(tx, ty);
4548 /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
4549 this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
4550 this.matrix = this._matrix.scaleNonUniform(sx, sy);
4552 /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
4554 this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
4555 this.matrix = this._matrix.rotate(angle);
4556 this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
4557 this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
4559 /*void*/ setSkewX : function(/*float*/ angle ) {
4561 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
4562 this.matrix = this._matrix.skewX(angle);
4564 /*void*/ setSkewY : function(/*float*/ angle ) {
4566 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
4567 this.matrix = this._matrix.skewY(angle);
4571 function SVGTransformList() {
4574 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4575 SVGTransformList.prototype[prop] = SVGStringList.prototype[prop];
4577 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
4578 var t = new SVGTransform();
4579 t.setMatrix(matrix);
4582 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
4583 if(this.numberOfItems === 0) {
4586 var s = this.getItem(0), m = s.matrix;
4587 for (var i=1,nli=this.numberOfItems;i<nli;++i) {
4588 m = m.multiply(this.getItem(i).matrix);
4596 function SVGAnimatedTransformList() {
4597 /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
4600 function SVGPreserveAspectRatio() {
4601 /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
4602 /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
4607 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
4608 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE = 1;
4609 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
4610 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
4611 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
4612 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
4613 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
4614 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
4615 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
4616 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
4617 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
4618 // Meet-or-slice Types
4619 /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN = 0;
4620 /*unsigned short*/ t.SVG_MEETORSLICE_MEET = 1;
4621 /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
4622 })(SVGPreserveAspectRatio);
4624 function SVGAnimatedPreserveAspectRatio() {
4625 /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
4629 function SVGPathSeg() {
4630 /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
4631 /*readonly DOMString*/ this.pathSegTypeAsLetter = null;
4636 // Path Segment Types
4637 /*unsigned short*/ t.PATHSEG_UNKNOWN = 0;
4638 /*unsigned short*/ t.PATHSEG_CLOSEPATH = 1;
4639 /*unsigned short*/ t.PATHSEG_MOVETO_ABS = 2;
4640 /*unsigned short*/ t.PATHSEG_MOVETO_REL = 3;
4641 /*unsigned short*/ t.PATHSEG_LINETO_ABS = 4;
4642 /*unsigned short*/ t.PATHSEG_LINETO_REL = 5;
4643 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS = 6;
4644 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL = 7;
4645 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS = 8;
4646 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL = 9;
4647 /*unsigned short*/ t.PATHSEG_ARC_ABS = 10;
4648 /*unsigned short*/ t.PATHSEG_ARC_REL = 11;
4649 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS = 12;
4650 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL = 13;
4651 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS = 14;
4652 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL = 15;
4653 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;
4654 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;
4655 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
4656 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
4659 *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
4661 function SVGPathSegClosePath() {
4664 SVGPathSegClosePath.prototype = {
4665 pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
4666 pathSegTypeAsLetter : "z"
4668 function SVGPathSegMovetoAbs() {
4673 SVGPathSegMovetoAbs.prototype = {
4674 pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
4675 pathSegTypeAsLetter : "M"
4677 function SVGPathSegMovetoRel() {
4682 SVGPathSegMovetoRel.prototype = {
4683 pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
4684 pathSegTypeAsLetter : "m"
4686 function SVGPathSegLinetoAbs() {
4691 SVGPathSegLinetoAbs.prototype = {
4692 pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
4693 pathSegTypeAsLetter : "L"
4695 function SVGPathSegLinetoRel() {
4700 SVGPathSegLinetoRel.prototype = {
4701 pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
4702 pathSegTypeAsLetter : "l"
4704 function SVGPathSegCurvetoCubicAbs() {
4713 SVGPathSegCurvetoCubicAbs.prototype = {
4714 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
4715 pathSegTypeAsLetter : "C"
4717 function SVGPathSegCurvetoCubicRel() {
4726 SVGPathSegCurvetoCubicRel.prototype = {
4727 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
4728 pathSegTypeAsLetter : "c"
4730 function SVGPathSegCurvetoQuadraticAbs() {
4735 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
4736 this.pathSegTypeAsLetter = "Q";
4739 function SVGPathSegCurvetoQuadraticRel() {
4744 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
4745 this.pathSegTypeAsLetter = "q";
4749 function SVGPathSegArcAbs() {
4754 /*float*/ this.angle;
4757 SVGPathSegArcAbs.prototype = {
4758 /*boolean*/ largeArcFlag : true,
4759 /*boolean*/ sweepFlag : true,
4760 pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
4761 pathSegTypeAsLetter : "A"
4763 function SVGPathSegArcRel() {
4768 /*float*/ this.angle;
4771 SVGPathSegArcRel.prototype = {
4772 /*boolean*/ largeArcFlag : true,
4773 /*boolean*/ sweepFlag : true,
4774 pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
4775 pathSegTypeAsLetter : "a"
4777 function SVGPathSegLinetoHorizontalAbs() {
4779 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
4780 this.pathSegTypeAsLetter = "H";
4783 function SVGPathSegLinetoHorizontalRel() {
4785 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
4786 this.pathSegTypeAsLetter = "h";
4789 function SVGPathSegLinetoVerticalAbs() {
4791 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
4792 this.pathSegTypeAsLetter = "V";
4795 function SVGPathSegLinetoVerticalRel() {
4797 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
4798 this.pathSegTypeAsLetter = "v";
4801 function SVGPathSegCurvetoCubicSmoothAbs() {
4806 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
4807 this.pathSegTypeAsLetter = "S";
4810 function SVGPathSegCurvetoCubicSmoothRel() {
4815 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
4816 this.pathSegTypeAsLetter = "s";
4819 function SVGPathSegCurvetoQuadraticSmoothAbs() {
4822 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
4823 this.pathSegTypeAsLetter = "T";
4826 function SVGPathSegCurvetoQuadraticSmoothRel() {
4829 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
4830 this.pathSegTypeAsLetter = "t";
4833 function SVGPathSegList() {
4836 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4837 SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
4840 /*documentは引数の変数として登録しておく*/
4841 (function(_doc, _pInt, _math) {
4842 //freeArg関数はunloadで使う解放処理
4843 NAIBU.freeArg = function() {
4844 SVGPathElement = _doc = _pInt = _math = void 0;
4846 //仮のfill属性とstroke属性の処理
4847 NAIBU._setPaint = function(tar, matrix) {
4848 /*以下では、スタイルシートを用いて、fill-とstroke-関連の
4849 *処理を行う。SVGPaintインターフェースをも用いる
4851 var tod = tar.ownerDocument,
4852 _doc = tod._document_,
4854 style = tod.defaultView.getComputedStyle(tar, ""),
4855 fill = style.getPropertyCSSValue("fill"),
4856 stroke = style.getPropertyCSSValue("stroke"),
4857 fp = fill.paintType,
4858 sp = stroke.paintType,
4860 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
4861 t, evtt, fillOpacity, strs, cursor, vis, disp,
4862 strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
4866 /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
4867 while (el.firstChild) {
4868 el.removeChild(el.firstChild);
4870 if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4871 if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4872 /*再度、設定。css.jsのsetPropertyを参照*/
4873 style.setProperty("color", style.getPropertyValue("color"));
4875 fillElement = _doc.createElement("v:fill");
4877 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
4878 fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4879 fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
4880 if (fillOpacity < 1) {
4881 fillElement.setAttribute("opacity", fillOpacity+"");
4883 el.appendChild(fillElement);
4884 fillElement = fc = fillOpacity = void 0;
4885 } else if (fill.uri) {
4886 /*以下では、Gradation関連の要素に、イベントを渡すことで、
4889 t = tod.getElementById(fill.uri);
4891 evtt = tod.createEvent("MutationEvents");
4892 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
4893 evtt._tar = _doc.createElement("v:fill");
4894 evtt._style = style;
4896 t.dispatchEvent(evtt);
4897 if (t.localName !== "radialGradient") {
4898 el.appendChild(evtt._tar);
4903 el.filled = "false";
4905 if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4906 if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4907 /*再度、設定。css.jsのsetPropertyを参照*/
4908 style.setProperty("color", style.getPropertyValue("color"));
4910 strokeElement = _doc.createElement("v:stroke");
4911 sgsw = style.getPropertyCSSValue("stroke-width");
4912 w = tod.documentElement.viewport.width;
4913 h = tod.documentElement.viewport.height;
4914 sgsw._percent = _math.sqrt((w*w + h*h) / 2);
4915 swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
4916 strokeElement.setAttribute("weight", swx + "px");
4917 sgsw = w = h = void 0;
4919 fc = stroke.rgbColor;
4920 strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4921 strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
4923 strokeOpacity *= swx; //太さが1px未満なら色を薄くする
4925 if (strokeOpacity < 1) {
4926 strokeElement.setAttribute("opacity", strokeOpacity+"");
4928 fc = strokeOpacity = void 0;
4930 strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
4931 strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
4932 if (style.getPropertyValue("stroke-linecap") === "butt") {
4933 strokeElement.setAttribute("endcap", "flat");
4935 strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
4937 tsd = style.getPropertyValue("stroke-dasharray");
4938 if (tsd !== "none") {
4939 if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
4940 strs = tsd.split(",");
4941 for (var i = 0, sli = strs.length; i < sli; ++i) {
4942 strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
4944 strokedasharray = strs.join(" ");
4945 if (strs.length % 2 === 1) {
4946 strokedasharray += " " + strokedasharray;
4949 strokeElement.setAttribute("dashstyle", strokedasharray);
4950 tsd = strs = void 0;
4952 el.appendChild(strokeElement);
4953 strokeElement = tsd = void 0;
4955 el.stroked = "false";
4957 cursor = style.getPropertyCSSValue("cursor");
4958 if (cursor && !cursor._isDefault) { //初期値でないならば
4959 el.style.cursor = cursor.cssText.split(":")[1];
4961 vis = style.getPropertyCSSValue("visibility");
4962 if (vis && !vis._isDefault) {
4963 el.style.visibility = vis.cssText.split(":")[1];
4965 disp = style.getPropertyCSSValue("display");
4966 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
4967 el.style.display = "none";
4968 } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
4969 el.style.display = "inline-block";
4971 tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
4974 function SVGPathElement(_doc) {
4975 SVGElement.apply(this);
4976 this._tar = _doc.createElement("v:shape");
4977 //interface SVGAnimatedPathData
4978 var sp = SVGPathSegList;
4979 /*readonly SVGPathSegList*/ this.pathSegList = new sp();
4980 this.animatedPathSegList = this.pathSegList;
4981 /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
4983 this.animatedNormalizedPathSegList = this.normalizedPathSegList;
4984 /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
4985 //以下は、d属性に変更があった場合の処理
4986 this.addEventListener("DOMAttrModified", this._attrModi, false);
4987 /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
4988 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
4990 this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
4993 SVGPathElement.constructor = SVGElement;
4994 SVGPathElement.prototype = new SVGElement();
4995 (function(_sproto) {
4996 _sproto._attrModi = function(evt){
4997 var tar = evt.target;
4998 if (evt.attrName === "d" && evt.newValue !== ""){
4999 /* d属性の値が空の場合は、描画を行わないようにする
5001 *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
5003 var tnl = tar.normalizedPathSegList,
5004 tlist = tar.pathSegList;
5005 if (tnl.numberOfItems > 0) {
5009 /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
5011 *D = [["M", 20, 30], ["L", 20 40]]
5013 var taco = tar._com,
5016 .replace(taco.isRa, " -")
5017 .replace(taco.isRb, " ")
5018 .replace(taco.isRc, ",$1 ")
5019 .replace(taco.isRd, ",$1 1")
5020 .replace(taco.isRe, "")
5027 tcc = tar.createSVGPathSegCurvetoCubicAbs,
5028 tcll = tar.createSVGPathSegLinetoAbs;
5029 for (var i=0;i<dli;++i) {
5030 var di = dd[i].match(sgs),
5032 for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
5034 s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5036 } else if (isL[dii]) {
5037 s = tcll(+di[j], +di[j+1]);
5039 } else if (isM[dii]) {
5040 s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
5042 } else if (isZ[dii]) {
5043 s = tar.createSVGPathSegClosePath();
5044 } else if (dii === "A") {
5045 s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5047 } else if (dii === "m") {
5048 s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
5050 } else if (dii === "l") {
5051 s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
5053 } else if (dii === "c") {
5054 s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5056 } else if (dii === "Q") {
5057 s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5059 } else if (dii === "q") {
5060 s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5062 } else if (dii === "a") {
5063 s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5065 } else if (dii === "S") {
5066 s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5068 } else if (dii === "s") {
5069 s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5071 } else if (dii === "T") {
5072 s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
5074 } else if (dii === "t") {
5075 s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
5077 } else if (dii === "H") {
5078 s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
5079 } else if (dii === "h") {
5080 s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
5081 } else if (dii === "V") {
5082 s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
5083 } else if (dii === "v") {
5084 s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
5086 s = new SVGPathSeg();
5088 tlist.appendItem(s);
5091 di = s = sgs = dd = void 0;
5092 /*以下の処理は、pathSegListからnormalizedPathSegListへの
5093 *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
5095 var cx = 0, cy = 0, //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
5096 xn = 0, yn = 0, //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
5097 startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
5098 for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
5099 var ti = tlist.getItem(j),
5100 ts = ti.pathSegType,
5101 dii = ti.pathSegTypeAsLetter;
5102 if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
5104 var rx = cx, ry = cy; //rx, ryは前のセグメントの終了点
5105 if (ts % 2 === 1) { //相対座標ならば
5114 } else if (isL[dii]) {
5116 } else if (isM[dii]) {
5118 /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
5119 *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
5120 *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
5122 var tg = tlist.getItem(j-1);
5123 if (tg.pathSegTypeAsLetter === "M") {
5124 tnl.appendItem(tcll(cx, cy));
5131 } else if (dii === "m") {
5133 var tg = tlist.getItem(j-1);
5134 if (tg.pathSegTypeAsLetter === "m") {
5135 tnl.appendItem(tcll(cx, cy));
5141 tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
5142 } else if (dii === "l") {
5143 tnl.appendItem(tcll(cx, cy));
5144 } else if (dii === "c") {
5145 tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
5146 } else if (isZ[dii]) {
5150 } else if (dii === "Q") {
5153 //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
5154 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));
5155 } else if (dii === "q") {
5156 var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
5159 tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
5161 } else if (dii === "A" || dii === "a") {
5162 (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
5163 /*以下は、Arctoを複数のCuvetoに変換する処理
5164 *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
5165 *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
5167 if (ti.r1 === 0 || ti.r2 === 0) {
5170 var fS = ti.sweepFlag,
5172 r1 = _math.abs(ti.r1),
5173 r2 = _math.abs(ti.r2),
5174 ctx = (rx - cx) / 2, cty = (ry - cy) / 2,
5175 cpsi = _math.cos(psai * _math.PI / 180),
5176 spsi = _math.sin(psai * _math.PI / 180),
5177 rxd = cpsi*ctx + spsi*cty,
5178 ryd = -1*spsi*ctx + cpsi*cty,
5179 rxdd = rxd * rxd, rydd = ryd * ryd,
5182 lamda = rxdd/r1x + rydd/r2y,
5185 r1 = _math.sqrt(lamda) * r1;
5186 r2 = _math.sqrt(lamda) * r2;
5190 if (ti.largeArcFlag === fS) {
5193 sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
5195 var txd = sds*r1*ryd / r2,
5196 tyd = -1 * sds*r2*rxd / r1,
5197 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
5198 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
5199 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
5200 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
5201 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
5202 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
5203 if (!fS && dr > 0) {
5205 } else if (fS && dr < 0) {
5208 var sse = dr * 2 / _math.PI,
5209 seg = _math.ceil(sse<0 ? -1*sse : sse),
5211 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
5212 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
5213 spsir1 = spsi * r1, spsir2 = spsi * r2,
5216 x2 = rx - t * (cpsir1*ms + spsir2*mc),
5217 y2 = ry - t * (spsir1*ms - cpsir2*mc);
5218 for (var n = 0; n < seg; ++n) {
5222 var x3 = cpsir1*mc - spsir2*ms + tx,
5223 y3 = spsir1*mc + cpsir2*ms + ty,
5224 dx = -t * (cpsir1*ms + spsir2*mc),
5225 dy = -t * (spsir1*ms - cpsir2*mc);
5226 tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
5230 ti= cx= cy= rx= ry= tar= tnl = void 0;
5231 })(ti, cx, cy, rx, ry, tar, tnl);
5232 } else if (dii === "S") {
5234 var tg = tnl.getItem(tnl.numberOfItems-1);
5235 if (tg.pathSegTypeAsLetter === "C") {
5236 var x1 = 2*tg.x - tg.x2,
5237 y1 = 2*tg.y - tg.y2;
5238 } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
5246 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
5248 } else if (dii === "s") {
5250 var tg = tnl.getItem(tnl.numberOfItems-1);
5251 if (tg.pathSegTypeAsLetter === "C") {
5252 var x1 = 2*tg.x - tg.x2,
5253 y1 = 2*tg.y - tg.y2;
5262 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
5264 } else if (dii === "T" || dii === "t") {
5266 var tg = tlist.getItem(j-1);
5267 if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
5274 tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
5278 } else if (dii === "H" || dii === "h") {
5279 tnl.appendItem(tcll(cx, ry));
5280 cy = ry; //勝手にti.yが0としているため
5281 } else if (dii === "V" || dii === "v") {
5282 tnl.appendItem(tcll(rx, cy));
5288 evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
5290 _sproto._nodeInsert = function(evt){
5291 var tar = evt.target;
5292 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5295 var tnext = tar.nextSibling,
5296 tpart = tar.parentNode._tar,
5298 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5299 tpart.insertBefore(tar._tar, tnext._tar);
5300 } else if (tnext && !tnext._tar && tpart) {
5301 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5302 *use要素や実体参照などは_tarプロパティがないことに注意
5305 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5306 tpart.insertBefore(tar._tar, tnext._tar);
5309 tnext = tnext.nextSibling;
5312 tpart.appendChild(tar._tar);
5314 } else if (!tnext && tpart) {
5315 tpart.appendChild(tar._tar);
5317 tnext = tpart = isLast = void 0;
5318 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
5321 _sproto._nodeInsertInto = function(evt){
5322 /*以下の処理は、normalizedpathSegListとCTMに基づいて、
5323 *SVGのd属性をVMLに変換していく処理である。
5325 var tar = evt.target,
5326 matrix = tar.getScreenCTM(),
5327 tlist = tar.normalizedPathSegList,
5330 ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
5331 cname = tar._com._nameCom,
5332 isZ = tar._com._isZ, isC = tar._com._isC;
5333 for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
5337 tps = ti.pathSegTypeAsLetter,
5340 /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
5345 t += [_parseInt(ma*ti.x1 + mc*ti.y1 + me, 10),
5346 _parseInt(mb*ti.x1 + md*ti.y1 + mf, 10),
5347 _parseInt(ma*ti.x2 + mc*ti.y2 + me, 10),
5348 _parseInt(mb*ti.x2 + md*ti.y2 + mf, 10),
5349 _parseInt(ma*tx + mc*ty + me, 10),
5350 _parseInt(mb*tx + md*ty + mf, 10)].join(" ");
5351 } else if (!isZ[tps]) {
5352 t += _parseInt(ma*tx + mc*ty + me, 10)+ " " +_parseInt(mb*tx + md*ty + mf, 10);
5356 var vi = tar.ownerDocument.documentElement,
5359 tt.path = dat.join(" ");
5360 tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
5361 NAIBU._setPaint(tar, matrix);
5362 delete tar._cacheMatrix;
5363 evt = tar = dat = t = tx = ty = matrix = tlist = x = y = _parseInt = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
5388 isRc : /([a-yA-Y])/g,
5393 /*float*/ _sproto.getTotalLength = function() {
5395 nl = this.normalizedPathSegList;
5396 for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5397 var seg = nl.getItem(i);
5398 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5399 var ps = nl.getItem(i-1);
5400 s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5401 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5402 var ps = nl.getItem(i-1), dd = 0;
5403 /*2点のハンドルを結んだ線分の3辺と、
5404 *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
5407 *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
5408 *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
5410 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5411 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5412 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5413 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5415 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5416 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5417 s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5421 this.pathLength.baseVal = s;
5424 /*SVGPoint*/ _sproto.getPointAtLength = function(/*float*/ distance ) {
5425 var segn = this.getPathSegAtLength(distance),
5428 nl = this.normalizedPathSegList,
5429 seg = nl.getItem(segn),
5430 s = this.ownerDocument.documentElement.createSVGPoint();
5431 if ((segn-1) <= 0) {
5436 var ps = nl.getItem(segn-1);
5437 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5438 var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5439 var t = (segl + this._dis) / segl;
5440 s.x = ps.x + t * (seg.x-ps.x);
5441 s.y = ps.y + t * (seg.y-ps.y);
5442 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5444 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5445 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5446 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5447 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5449 var t = (segl + this._dis) / segl;
5450 /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
5453 s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
5454 +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
5455 +3*(seg.x1 - ps.x) * t
5457 s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
5458 +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
5459 +3*(seg.y1 - ps.y) * t
5461 } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
5464 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5465 var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
5466 var t = (segl + this._dis) / segl;
5467 s.x = ms.x + t * (seg.x-ms.x);
5468 s.y = ms.y + t * (seg.y-ms.y);
5472 /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
5473 var nl = this.normalizedPathSegList; //仕様ではpathSegList
5474 for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5475 var seg = nl.getItem(i);
5476 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5477 var ps = nl.getItem(i-1);
5478 distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5479 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5480 var ps = nl.getItem(i-1), dd = 0;
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));
5487 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5488 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5489 distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5491 if (distance <= 0) {
5492 /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
5493 this._dis = distance;
5498 /*もし、distanceがパスの距離よりも長い場合、
5500 *なお、これはSVG1.1の仕様の想定外のこと
5502 return (nl.numberOfItems - 1);
5504 /*SVGPathSegClosePath*/ _sproto.createSVGPathSegClosePath = function() {
5505 var _SVGPathSegClosePath = SVGPathSegClosePath;
5506 return (new _SVGPathSegClosePath());
5508 /*SVGPathSegMovetoAbs*/ _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
5509 var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
5514 /*SVGPathSegMovetoRel*/ _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
5515 var s = new SVGPathSegMovetoRel();
5520 /*SVGPathSegLinetoAbs*/ _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
5521 var s = new SVGPathSegLinetoAbs();
5526 /*SVGPathSegLinetoRel*/ _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
5527 var s = new SVGPathSegLinetoRel();
5532 /*SVGPathSegCurvetoCubicAbs*/ _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5533 var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
5542 /*SVGPathSegCurvetoCubicRel*/ _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5543 var s = new SVGPathSegCurvetoCubicRel();
5552 /*SVGPathSegCurvetoQuadraticAbs*/ _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5553 var s = new SVGPathSegCurvetoQuadraticAbs();
5560 /*SVGPathSegCurvetoQuadraticRel*/ _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5561 var s = new SVGPathSegCurvetoQuadraticRel();
5568 /*SVGPathSegArcAbs*/ _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5569 var s = new SVGPathSegArcAbs();
5575 s.largeArcFlag = largeArcFlag;
5576 s.sweepFlag = sweepFlag;
5579 /*SVGPathSegArcRel*/ _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5580 var s = new SVGPathSegArcRel();
5586 s.largeArcFlag = largeArcFlag;
5587 s.sweepFlag = sweepFlag;
5590 /*SVGPathSegLinetoHorizontalAbs*/ _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
5591 var s = new SVGPathSegLinetoHorizontalAbs();
5593 s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
5596 /*SVGPathSegLinetoHorizontalRel*/ _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
5597 var s = new SVGPathSegLinetoHorizontalRel();
5602 /*SVGPathSegLinetoVerticalAbs*/ _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
5603 var s = new SVGPathSegLinetoVerticalAbs();
5608 /*SVGPathSegLinetoVerticalRel*/ _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
5609 var s = new SVGPathSegLinetoVerticalRel();
5614 /*SVGPathSegCurvetoCubicSmoothAbs*/ _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5615 var s = new SVGPathSegCurvetoCubicSmoothAbs();
5622 /*SVGPathSegCurvetoCubicSmoothRel*/ _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5623 var s = new SVGPathSegCurvetoCubicSmoothRel();
5630 /*SVGPathSegCurvetoQuadraticSmoothAbs*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
5631 var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
5636 /*SVGPathSegCurvetoQuadraticSmoothRel*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
5637 var s = new SVGPathSegCurvetoQuadraticSmoothRel();
5642 })(SVGPathElement.prototype)
5643 NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
5644 })(document, parseInt, Math);
5646 function SVGRectElement(_doc) {
5647 SVGElement.apply(this);
5648 this._tar = _doc.createElement("v:shape");
5649 var slen = SVGAnimatedLength;
5650 /*readonly SVGAnimatedLength*/ this.x = new slen();
5651 /*readonly SVGAnimatedLength*/ this.y = new slen();
5652 /*readonly SVGAnimatedLength*/ this.width = new slen();
5653 /*readonly SVGAnimatedLength*/ this.height = new slen();
5654 /*readonly SVGAnimatedLength*/ this.rx = new slen();
5655 /*readonly SVGAnimatedLength*/ this.ry = new slen();
5656 _doc = slen = void 0;
5657 this.addEventListener("DOMNodeInserted", function(evt){
5658 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5661 var tar = evt.target,
5662 tnext = tar.nextSibling,
5663 tpart = tar.parentNode._tar,
5665 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5666 tpart.insertBefore(tar._tar, tnext._tar);
5667 } else if (tnext && !tnext._tar && tpart) {
5668 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5669 *use要素や実体参照などは_tarプロパティがないことに注意
5672 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5673 tpart.insertBefore(tar._tar, tnext._tar);
5676 tnext = tnext.nextSibling;
5679 tpart.appendChild(tar._tar);
5681 } else if (!tnext && tpart) {
5682 tpart.appendChild(tar._tar);
5684 tnext = tpart = isLast = void 0;
5685 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5686 var tar = evt.target,
5687 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5688 fontSize = parseFloat(style.getPropertyValue("font-size"));
5689 tar.x.baseVal._emToUnit(fontSize);
5690 tar.y.baseVal._emToUnit(fontSize);
5691 tar.width.baseVal._emToUnit(fontSize);
5692 tar.height.baseVal._emToUnit(fontSize);
5693 var rx = tar.getAttributeNS(null, "rx"),
5694 ry = tar.getAttributeNS(null, "ry"),
5695 x = tar.x.baseVal.value,
5696 y = tar.y.baseVal.value,
5697 xw = x + tar.width.baseVal.value,
5698 yh = y + tar.height.baseVal.value,
5700 if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
5701 tar.rx.baseVal._emToUnit(fontSize);
5702 tar.ry.baseVal._emToUnit(fontSize);
5703 var thrx = tar.rx.baseVal,
5704 thry = tar.ry.baseVal,
5705 twidth = tar.width.baseVal.value,
5706 theight = tar.height.baseVal.value;
5707 thrx.value = rx ? thrx.value : thry.value;
5708 thry.value = ry ? thry.value : thrx.value;
5709 //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
5710 if (thrx.value > twidth / 2) {
5711 thrx.value = twidth / 2;
5713 if (thry.value > theight / 2) {
5714 thry.value = theight / 2;
5716 var rxv = thrx.value,
5718 rrx = rxv * 0.55228,
5719 rry = ryv * 0.55228,
5724 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];
5726 list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
5728 //以下は、配列listそのものをCTMで座標変換していく処理
5729 var par = tar.ownerDocument.documentElement,
5730 ctm = tar.getScreenCTM(),
5733 vi = tar.ownerDocument.documentElement,
5734 w = vi.width.baseVal.value,
5735 h = vi.height.baseVal.value;
5736 for (var i=0, lili=list.length;i<lili;) {
5737 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5741 p = par.createSVGPoint();
5744 pmt = p.matrixTransform(ctm);
5751 dat = list.join(" ");
5754 ele.coordsize = w + " " + h;
5755 NAIBU._setPaint(tar, ctm);
5756 delete tar._cacheMatrix;
5757 evt = tar = style = list = dat = ele = vi = fontSize = void 0;
5763 SVGRectElement.constructor = SVGElement;
5764 SVGRectElement.prototype = new SVGElement();
5766 function SVGCircleElement(_doc) {
5767 SVGElement.apply(this);
5768 this._tar = _doc.createElement("v:shape");
5769 var sl = SVGAnimatedLength;
5770 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5771 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5772 /*readonly SVGAnimatedLength*/ this.r = new sl();
5774 this.addEventListener("DOMNodeInserted", function(evt){
5775 var tar = evt.target;
5776 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5779 var tnext = tar.nextSibling,
5780 tpart = tar.parentNode._tar,
5782 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5783 tpart.insertBefore(tar._tar, tnext._tar);
5784 } else if (tnext && !tnext._tar && tpart) {
5785 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5786 *use要素や実体参照などは_tarプロパティがないことに注意
5789 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5790 tpart.insertBefore(tar._tar, tnext._tar);
5793 tnext = tnext.nextSibling;
5796 tpart.appendChild(tar._tar);
5798 } else if (!tnext && tpart) {
5799 tpart.appendChild(tar._tar);
5801 tnext = tpart = isLast = void 0;
5802 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5803 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5804 var fontSize = parseFloat(style.getPropertyValue("font-size"));
5805 tar.cx.baseVal._emToUnit(fontSize);
5806 tar.cy.baseVal._emToUnit(fontSize);
5807 tar.r.baseVal._emToUnit(fontSize);
5808 var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = ry = tar.r.baseVal.value;
5809 var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
5810 var rrx = rx * 0.55228, rry = ry * 0.55228;
5811 var 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"];
5812 //以下は、配列listそのものをCTMで座標変換していく処理
5813 var par = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM();
5814 for (var i=0, lili=list.length;i<lili;) {
5815 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5819 var p = par.createSVGPoint();
5822 var pmt = p.matrixTransform(ctm);
5829 var dat = list.join(" ");
5831 var ele = tar._tar, vi = tar.ownerDocument.documentElement;
5832 var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5834 ele.coordsize = w + " " + h;
5835 NAIBU._setPaint(tar, ctm);
5836 delete tar._cacheMatrix;
5837 evt = tar = list = style = fontSize = dat = ele = void 0;
5843 SVGCircleElement.constructor = SVGElement;
5844 SVGCircleElement.prototype = new SVGElement();
5846 function SVGEllipseElement(_doc) {
5847 SVGElement.apply(this);
5848 this._tar = _doc.createElement("v:shape");
5849 var sl = SVGAnimatedLength;
5850 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5851 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5852 /*readonly SVGAnimatedLength*/ this.rx = new sl();
5853 /*readonly SVGAnimatedLength*/ this.ry = new sl();
5855 this.addEventListener("DOMNodeInserted", function(evt){
5856 var tar = evt.target;
5857 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5860 var tnext = tar.nextSibling,
5861 tpart = tar.parentNode._tar,
5863 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5864 tpart.insertBefore(tar._tar, tnext._tar);
5865 } else if (tnext && !tnext._tar && tpart) {
5866 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5867 *use要素や実体参照などは_tarプロパティがないことに注意
5870 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5871 tpart.insertBefore(tar._tar, tnext._tar);
5874 tnext = tnext.nextSibling;
5877 tpart.appendChild(tar._tar);
5879 } else if (!tnext && tpart) {
5880 tpart.appendChild(tar._tar);
5882 tnext = tpart = isLast = void 0;
5883 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5884 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5885 var fontSize = parseFloat(style.getPropertyValue("font-size"));
5886 tar.cx.baseVal._emToUnit(fontSize);
5887 tar.cy.baseVal._emToUnit(fontSize);
5888 tar.rx.baseVal._emToUnit(fontSize);
5889 tar.ry.baseVal._emToUnit(fontSize);
5890 var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = tar.rx.baseVal.value, ry = tar.ry.baseVal.value;
5891 var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
5892 var rrx = rx * 0.55228, rry = ry * 0.55228;
5893 var 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"];
5894 //以下は、配列listそのものをCTMで座標変換していく処理
5895 var par = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM();
5896 for (var i=0, lili=list.length;i<lili;) {
5897 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5901 var p = par.createSVGPoint();
5904 var pmt = p.matrixTransform(ctm);
5911 var dat = list.join(" ");
5913 var ele = tar._tar, vi = tar.ownerDocument.documentElement;
5914 var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5916 ele.coordsize = w + " " + h;
5917 NAIBU._setPaint(tar, ctm);
5918 delete tar._cacheMatrix;
5919 evt = ele = tar = style = fontSize = dat = list = ctm = w = h = void 0;
5925 SVGEllipseElement.constructor = SVGElement;
5926 SVGEllipseElement.prototype = new SVGElement();
5928 function SVGLineElement(_doc) {
5929 SVGElement.apply(this);
5930 this._tar = _doc.createElement("v:shape");
5931 var sl = SVGAnimatedLength;
5932 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
5933 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
5934 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
5935 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
5937 this.addEventListener("DOMNodeInserted", function(evt){
5938 var tar = evt.target;
5939 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5942 var tnext = tar.nextSibling,
5943 tpart = tar.parentNode._tar,
5945 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5946 tpart.insertBefore(tar._tar, tnext._tar);
5947 } else if (tnext && !tnext._tar && tpart) {
5948 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5949 *use要素や実体参照などは_tarプロパティがないことに注意
5952 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5953 tpart.insertBefore(tar._tar, tnext._tar);
5956 tnext = tnext.nextSibling;
5959 tpart.appendChild(tar._tar);
5961 } else if (!tnext && tpart) {
5962 tpart.appendChild(tar._tar);
5964 tnext = tpart = isLast = void 0;
5965 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5966 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5967 var fontSize = parseFloat(style.getPropertyValue("font-size"));
5968 tar.x1.baseVal._emToUnit(fontSize);
5969 tar.y1.baseVal._emToUnit(fontSize);
5970 tar.x2.baseVal._emToUnit(fontSize);
5971 tar.y2.baseVal._emToUnit(fontSize);
5972 //以下は、配列listそのものをCTMで座標変換していく処理
5973 var vi = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM();
5975 var p = vi.createSVGPoint();
5976 p.x = tar.x1.baseVal.value;
5977 p.y = tar.y1.baseVal.value;
5978 var pmt = p.matrixTransform(ctm);
5979 dat += pmt.x+ " " +pmt.y+ " l ";
5980 p.x = tar.x2.baseVal.value;
5981 p.y = tar.y2.baseVal.value;
5982 pmt = p.matrixTransform(ctm);
5983 dat += pmt.x+ " " +pmt.y;
5986 var ele = tar._tar, w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5988 ele.coordsize = w + " " + h;
5989 NAIBU._setPaint(tar, ctm);
5990 delete tar._cacheMatrix;
5991 evt = ele = tar = style = fontSize = dat = list = ctm = vi = w = h = void 0;
5997 SVGLineElement.constructor = SVGElement;
5998 SVGLineElement.prototype = new SVGElement();
6000 /*_GenericSVGPolyElementインターフェース
6001 * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
6002 * ファイルサイズを軽量にすることができる
6004 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
6005 SVGElement.apply(this);
6006 this._tar = _doc.createElement("v:shape");
6008 //interface SVGAnimatedPoints
6009 /*readonly SVGPointList*/ this.animatedPoints = this.points = new SVGPointList();
6010 this.addEventListener("DOMAttrModified", function(evt){
6011 var tar = evt.target;
6012 if (evt.attrName === "points") {
6013 var tp = tar.points, par = tar.ownerDocument.documentElement;
6014 var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
6015 for (var i=0, p, lili=list.length;i<lili;i+=2) {
6016 if (isNaN(list[i])) {
6020 p = par.createSVGPoint();
6021 p.x = parseFloat(list[i]);
6022 p.y = parseFloat(list[i+1]);
6026 evt = tar = list = tp = par = p = void 0;
6028 this.addEventListener("DOMNodeInserted", function(evt){
6029 var tar = evt.target;
6030 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6033 var tnext = tar.nextSibling,
6034 tpart = tar.parentNode._tar,
6036 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6037 tpart.insertBefore(tar._tar, tnext._tar);
6038 } else if (tnext && !tnext._tar && tpart) {
6039 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6040 *use要素や実体参照などは_tarプロパティがないことに注意
6043 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6044 tpart.insertBefore(tar._tar, tnext._tar);
6047 tnext = tnext.nextSibling;
6050 tpart.appendChild(tar._tar);
6052 } else if (!tnext && tpart) {
6053 tpart.appendChild(tar._tar);
6055 tnext = tpart = isLast = void 0;
6056 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6057 var tar = evt.target,
6059 ctm = tar.getScreenCTM();
6060 //以下は、配列listそのものをCTMで座標変換していく処理
6061 for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
6062 var p = tp.getItem(i),
6063 pmt = p.matrixTransform(ctm);
6065 list[2*i + 1] = pmt.y;
6068 list.splice(2, 0, "l");
6069 var dat = "m" + list.join(" ") + xclose,
6071 vi = tar.ownerDocument.documentElement;
6072 w = vi.width.baseVal.value,
6073 h = vi.height.baseVal.value;
6076 ele.coordsize = w + " " + h;
6077 NAIBU._setPaint(tar, ctm);
6078 delete tar._cacheMatrix;
6079 evt = ele = tar = dat = list = ctm = w = h = vi = void 0;
6085 function SVGPolylineElement(_doc) {
6086 NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
6090 SVGPolylineElement.constructor = SVGElement;
6091 SVGPolylineElement.prototype = new SVGElement();
6093 function SVGPolygonElement(_doc) {
6094 NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
6098 SVGPolygonElement.constructor = SVGElement;
6099 SVGPolygonElement.prototype = new SVGElement();
6101 function SVGTextContentElement(_doc) {
6102 SVGElement.apply(this);
6103 /*readonly SVGAnimatedLength*/ this.textLength = new SVGAnimatedLength();
6104 /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
6105 this.addEventListener("DOMNodeInserted", function(evt){
6106 var tar = evt.target, cur = evt.currentTarget;
6107 /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
6108 *あらかじめ、Capturingフェーズで処理しておく
6110 if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
6111 /*a要素の場合はtarをすりかえておく*/
6112 tar = tar.firstChild;
6114 if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !!!tar._tars) {
6115 /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
6117 var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
6119 data = data.split('');
6120 for (var i=0, tdli=data.length;i<tdli;++i) {
6121 var d = _doc.createElement("div"),
6123 dstyle.position = "absolute";
6124 dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = "0px";
6125 dstyle.paddingTop = dstyle.paddingLeft = "0px";
6126 dstyle.whiteSpace = "nowrap";
6127 dstyle.textIndent = "0px";
6128 d.appendChild(_doc.createTextNode(data[i]));
6129 tar._tars[tar._tars.length] = d;
6132 cur._length += tar._tars.length;
6133 } else if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar instanceof SVGTextContentElement) && !!!tar._tars) {
6134 cur._length += tar._length;
6136 evt = tar = cur = void 0;
6142 t.constructor = SVGElement;
6143 t.prototype = new SVGElement();
6144 // lengthAdjust Types
6145 /*unsigned short*/ t.LENGTHADJUST_UNKNOWN = 0;
6146 /*unsigned short*/ t.LENGTHADJUST_SPACING = 1;
6147 /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS = 2;
6148 t.prototype._list = null; //文字の位置を格納しておくリストのキャッシュ
6149 t.prototype._length = 0; //全文字数
6150 t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
6151 t.prototype._chars = 0; //tspan要素が全体の何文字目から始まっているか
6152 t.prototype._isYokogaki = true; //横書きかどうか
6153 /*long*/ t.prototype.getNumberOfChars = function() {
6154 return (this._length);
6156 /*float*/ t.prototype.getComputedTextLength = function() {
6157 var l = this.textLength.baseVal;
6158 if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
6159 /*何も設定されていない場合のみ、初期化を行う*/
6160 l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
6163 return (this.textLength.baseVal.value);
6165 /*getSubStringLengthメソッド
6166 *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
6168 /*float*/ t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
6172 var tg = this.getNumberOfChars();
6173 if (tg < (nchars+charnum)) {
6174 /*ncharsが文字列の長さよりも長くなってしまったときには、
6175 *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
6177 nchars = tg - charnum + 1;
6179 var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
6180 if (this._isYokogaki) {
6181 var s = end.x - st.x;
6183 var s = end.y - st.y;
6185 tg = end = st = void 0;
6188 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
6189 if (charnum > this.getNumberOfChars() || charnum < 0) {
6190 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6193 ti = tar.firstChild,
6194 tp = tar.parentNode;
6197 var chars = tar._chars, //現在、何文字目にあるのか
6198 x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
6199 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6200 isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
6201 fontSize = parseFloat(style.getPropertyValue("font-size")),
6202 tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
6204 if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
6205 var ptx = tp.x.baseVal,
6207 ptdx = tp.dx.baseVal,
6208 ptdy = tp.dy.baseVal;
6210 var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
6212 var kern = "f ijltIr.,:;'-\"()",
6213 akern = "1234567890abcdeghknopquvxyz",
6214 tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
6215 if (isYokogaki && (tar.localName === "text")) {
6216 y += fontSize * 0.2;
6217 } else if (tar.localName === "text"){
6218 x -= fontSize * 0.5;
6221 if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
6223 /*tspan要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
6224 *使う。また、属性が指定されていないときも同様に祖先や親を使う。
6225 *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
6226 *この処理はdx属性やdy、y属性でも同様とする
6228 *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
6230 *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
6232 for (var i=0, tli=tt.length;i<tli;++i) {
6233 if (n < ptx.numberOfItems - chars) {
6234 x = ptx.getItem(n).value;
6236 x -= fontSize * 0.5;
6238 } else if (n < tx.numberOfItems) {
6239 x = tx.getItem(n).value;
6241 x -= fontSize * 0.5;
6244 if (n < pty.numberOfItems - chars) {
6245 y = pty.getItem(n).value;
6247 y += fontSize * 0.2;
6249 } else if (n < ty.numberOfItems) {
6250 y = ty.getItem(n).value;
6252 y += fontSize * 0.2;
6255 if (n < ptdx.numberOfItems - chars) {
6256 x += ptdx.getItem(n).value;
6257 } else if (n < tdx.numberOfItems) {
6258 x += tdx.getItem(n).value;
6260 if (n < ptdy.numberOfItems - chars) {
6261 y += ptdy.getItem(n).value;
6262 } else if (n < tdy.numberOfItems) {
6263 y += tdy.getItem(n).value;
6267 //カーニングを求めて、字の幅を文字ごとに調整する
6268 tdc = ti.data.charAt(i);
6269 if (kern.indexOf(tdc) > -1) {
6270 alm = fontSize * 0.68;
6271 } else if (tdc === "s"){
6272 alm = fontSize * 0.52;
6273 } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
6274 alm = fontSize * 0.2;
6275 } else if (akern.indexOf(tdc) > -1){
6276 alm = fontSize * 0.45;
6278 alm = fontSize * 0.3;
6280 tcca = tdc.charCodeAt(0);
6281 if ((12288 <= tcca) && (tcca <= 65533)) {
6282 alm = -fontSize * 0.01;
6283 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
6284 alm += fontSize * 0.2;
6289 tlist[tlist.length] = x;
6290 tlist[tlist.length] = y;
6291 tlist[tlist.length] = fontSize - alm;
6301 if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
6304 ti = ti.nextSibling;
6305 } else if ((ti.localName === "tspan") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6306 /*現在のテキスト位置(x,y)の分だけ、tspan要素をずらしておく。
6312 p = ti.getStartPositionOfChar(ti.getNumberOfChars());
6317 almx = tlist[tlist.length-1];
6319 almy = tlist[tlist.length-1];
6321 x = tlist[tlist.length-3] + almx;
6322 y = tlist[tlist.length-2] + almy;
6323 tar._list = tar._list.concat(tlist);
6324 tg = ti.getNumberOfChars();
6327 ti = ti.nextSibling;
6328 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6329 /*a要素のテキストノードも処理する*/
6332 ti = ti.nextSibling;
6335 tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
6337 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;
6338 var s = this.ownerDocument.documentElement.createSVGPoint();
6339 s.x = this._list[charnum*3];
6340 s.y = this._list[charnum*3 + 1];
6341 s = s.matrixTransform(this.getScreenCTM());
6345 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
6346 if (charnum > this.getNumberOfChars() || charnum < 0) {
6347 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6349 var s = this.getStartPositionOfChar(charnum);
6350 //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
6351 var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
6352 if (this._isYokogaki) {
6360 /*SVGRect*/ t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
6363 /*float*/ t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
6366 /*long*/ t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
6369 /*void*/ t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
6372 })(SVGTextContentElement);
6374 function SVGTextPositioningElement(_doc) {
6375 SVGTextContentElement.apply(this, arguments);
6376 var sl = SVGAnimatedLengthList;
6377 /*readonly SVGAnimatedLengthList*/ this.x = new sl();
6378 /*readonly SVGAnimatedLengthList*/ this.y = new sl();
6379 /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
6380 /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
6382 /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
6383 this.addEventListener("DOMAttrModified", function(evt){
6384 var tar = evt.target, name = evt.attrName, tod = tar.ownerDocument.documentElement;
6385 var _parseFloat = parseFloat;
6386 if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
6387 var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/), teas = tar[name].baseVal;
6388 for (var i=0, tli=enr.length;i<tli;++i) {
6389 var tea = tod.createSVGLength();
6390 var n = enr[i].match(/\D+$/), type = 0;
6395 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
6396 } else if (n === "%") {
6397 if ((name === "x") || (name === "dx")) {
6398 tea._percent *= tod.viewport.width;
6399 } else if ((name === "y") || (name === "dy")) {
6400 tea._percent *= tod.viewport.height;
6402 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
6403 } else if (n === "em") {
6404 var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
6405 tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
6407 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
6408 } else if (n === "ex") {
6409 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
6410 } else if (n === "px") {
6411 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
6412 } else if (n === "cm") {
6413 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
6414 } else if (n === "mm") {
6415 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
6416 } else if (n === "in") {
6417 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
6418 } else if (n === "pt") {
6419 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
6420 } else if (n === "pc") {
6421 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
6423 var s = _parseFloat(enr[i]);
6424 s = isNaN(s) ? 0 : s;
6425 tea.newValueSpecifiedUnits(type, s);
6426 teas.appendItem(tea);
6432 this.addEventListener("DOMNodeInserted", function(evt){
6433 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6434 var tar = evt.target;
6435 if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
6437 evt.currentTarget._list = null;
6444 SVGTextPositioningElement.constructor = SVGTextContentElement;
6445 SVGTextPositioningElement.prototype = new SVGTextContentElement();
6447 function SVGTextElement(_doc) {
6448 SVGTextPositioningElement.apply(this, arguments);
6449 this._tar = _doc.createElement("v:group");
6450 this.addEventListener("DOMNodeInserted", function(evt){
6451 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6454 var tar = evt.target,
6455 tnext = tar.nextSibling,
6456 tpart = tar.parentNode._tar,
6458 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6459 tpart.insertBefore(tar._tar, tnext._tar);
6460 } else if (tnext && !tnext._tar && tpart) {
6461 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6462 *use要素や実体参照などは_tarプロパティがないことに注意
6465 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6466 tpart.insertBefore(tar._tar, tnext._tar);
6469 tnext = tnext.nextSibling;
6472 tpart.appendChild(tar._tar);
6474 } else if (!tnext && tpart) {
6475 tpart.appendChild(tar._tar);
6477 tnext = tpart = isLast = void 0;
6478 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6479 var tar = evt.target,
6480 ti = tar.firstChild,
6482 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6483 n = parseFloat(style.getPropertyValue("font-size")) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
6484 tod = tar.ownerDocument.documentElement,
6485 ttpc = ttp, //ttpcはttpのキャッシュ
6486 tlen = tar.getComputedTextLength(),
6487 anchor = style.getPropertyValue("text-anchor"),
6488 tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
6491 ttps.fontSize = n + "px";
6492 ttps.fontFamily = style.getPropertyValue("font-family");
6493 ttps.fontStyle = style.getPropertyValue("font-style");
6494 ttps.fontWeight = style.getPropertyValue("font-weight");
6495 /*ここでの変数jは前回ノードまでの総文字数*/
6496 for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
6498 if (!!ti._tars && (ti._tars.length !== 0)) {
6499 var ij = (i > j) ? i - j : j - i
6500 var sty = ti._tars[ij].style,
6501 p = tar.getStartPositionOfChar(i);
6502 sty.position = "absolute";
6503 if (tar._isYokogaki) {
6504 if (anchor === "middle") {
6506 } else if (anchor === "end") {
6510 if (anchor === "middle") {
6512 } else if (anchor === "end") {
6516 sty.left = p.x + "px";
6517 sty.top = p.y + "px";
6520 sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
6521 sty.lineHeight = n+10+ "px";
6522 sty.textDecoration = tedeco;
6523 sty.display = "none"
6524 ttp.appendChild(ti._tars[ij]);
6527 if (ti.nodeName === "#text") {
6528 if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
6529 j = j + ti.data.length;
6530 if (ti.parentNode.localName === "a") {
6534 ti = ti.nextSibling;
6536 } else if (!!ti.getNumberOfChars) {
6537 if ((ti.getNumberOfChars()+j) <= i+1) {
6538 j = j + ti.getNumberOfChars();
6539 ti = ti.nextSibling;
6541 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6549 var color = style.getPropertyValue("fill"),
6550 cursor = style.getPropertyCSSValue("cursor"),
6551 vis = style.getPropertyCSSValue("visibility"),
6552 disp = style.getPropertyCSSValue("display"),
6553 tts = tar._tar.style,
6554 tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
6555 ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
6557 if (color === "none"){
6558 tts.color = "transparent";
6559 } else if (color.indexOf("url") === -1) {
6562 tts.color = "black";
6564 if (cursor && !cursor._isDefault) { //初期値でないならば
6565 var tc = cursor.cssText;
6566 tts.cursor = tc.split(":")[1];
6569 if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
6570 && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
6571 /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
6572 *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
6574 for (var i=1, tli=tft.length;i<tli;++i) {
6576 ttt += tfti.innerText;
6577 tfti.parentNode.removeChild(tfti);
6579 //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
6580 if (tft[0] && tft[0].replaceChild) {
6581 tft[0].replaceChild(_doc.createTextNode(ttt), tft[0].firstChild);
6587 if (ttp.lastChild) {
6588 if (ttp.lastChild.nodeName !== "rect") {
6595 var backr = _doc.createElement("v:rect"),
6596 backrs = backr.style; //ずれを修正するためのもの
6597 backrs.width = backrs.height = "1px";
6598 backrs.left = backrs.top = "0px";
6599 backr.stroked = backr.filled = "false";
6600 ttp.appendChild(backr);
6602 if (vis && !vis._isDefault) {
6603 tts.visibility = vis.cssText.split(":")[1];
6605 /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
6606 *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
6608 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
6610 } else if (disp && !disp._isDefault) {
6613 var jt = tar._tar.firstChild,
6616 jt.style.display = di;
6617 jt = jt.nextSibling;
6619 while (ae[j]) { //要素内部にあるa要素の処理
6620 for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
6621 ae[j]._tars[l].style.display = di;
6626 delete tar._cacheMatrix;
6627 ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = void 0;
6633 SVGTextElement.constructor = SVGTextPositioningElement;
6634 SVGTextElement.prototype = new SVGTextPositioningElement();
6636 function SVGTSpanElement() {
6637 SVGTextElement.apply(this, arguments);
6640 SVGTSpanElement.constructor = SVGTextPositioningElement;
6641 SVGTSpanElement.prototype = new SVGTextPositioningElement();
6643 function SVGTRefElement() {
6644 SVGTextPositioningElement.apply(this, arguments);
6645 SVGURIReference.apply(this, arguments);
6648 SVGTRefElement.constructor = SVGTextPositioningElement;
6649 SVGTRefElement.prototype = new SVGTextPositioningElement();
6651 function SVGTextPathElement() {
6652 SVGTextContentElement.apply(this, arguments);
6653 /*readonly SVGAnimatedLength*/ this.startOffset;
6654 /*readonly SVGAnimatedEnumeration*/ this.method;
6655 /*readonly SVGAnimatedEnumeration*/ this.spacing;
6656 SVGURIReference.apply(this, arguments);
6659 SVGTextPathElement.constructor = SVGTextContentElement;
6660 SVGTextPathElement.prototype = new SVGTextContentElement();
6663 // textPath Method Types
6664 /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN = 0;
6665 /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN = 1;
6666 /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH = 2;
6667 // textPath Spacing Types
6668 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN = 0;
6669 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO = 1;
6670 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT = 2;
6671 })(SVGTextPathElement);
6673 function SVGAltGlyphElement() {
6674 SVGTextPositioningElement.apply(this, arguments);
6675 /*DOMString*/ this.glyphRef;
6676 /*DOMString*/ this.format;
6677 SVGURIReference.apply(this, arguments);
6680 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
6681 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
6683 function SVGAltGlyphDefElement() {
6684 SVGElement.apply(this, arguments);
6687 SVGAltGlyphDefElement.constructor = SVGElement;
6688 SVGAltGlyphDefElement.prototype = new SVGElement();
6690 function SVGAltGlyphItemElement() {
6691 SVGElement.apply(this, arguments);
6694 SVGAltGlyphItemElement.constructor = SVGElement;
6695 SVGAltGlyphItemElement.prototype = new SVGElement();
6697 function SVGGlyphRefElement() {
6698 SVGElement.apply(this, arguments);
6699 /*DOMString*/ this.glyphRef;
6700 /*DOMString*/ this.format;
6705 SVGURIReference.apply(this, arguments);
6708 SVGGlyphRefElement.constructor = SVGElement;
6709 SVGGlyphRefElement.prototype = new SVGElement();
6711 function SVGPaint() {
6712 SVGColor.apply(this, arguments);
6717 t.constructor = SVGColor;
6718 t.prototype = new SVGColor();
6720 /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN = 0;
6721 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR = 1;
6722 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
6723 /*unsigned short*/ t.SVG_PAINTTYPE_NONE = 101;
6724 /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR = 102;
6725 /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE = 103;
6726 /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
6727 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR = 105;
6728 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
6729 /*unsigned short*/ t.SVG_PAINTTYPE_URI = 107;
6730 /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
6731 /*readonly DOMString*/ t.prototype.uri = null;
6732 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
6733 this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
6735 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
6736 if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
6737 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
6740 this.paintType = paintType;
6741 if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
6742 paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
6744 this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
6746 // raises( SVGException );
6750 function SVGMarkerElement(){
6751 SVGElement.apply(this);
6752 var sl = SVGAnimatedLength;
6753 /*readonly SVGAnimatedLength*/ this.refX = new sl();
6754 /*readonly SVGAnimatedLength*/ this.refY = new sl();
6755 /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
6756 /*readonly SVGAnimatedLength*/ this.markerWidth = new sl();
6757 /*readonly SVGAnimatedLength*/ this.markerHeight = new sl();
6759 /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
6760 /*readonly SVGAnimatedAngle*/ this.orientAngle = new SVGAnimatedAngle();
6761 //SVGFitToViewBoxのインターフェースを用いる
6762 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
6763 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
6764 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
6768 // Marker Unit Types
6769 /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN = 0;
6770 /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
6771 /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH = 2;
6772 // Marker Orientation Types
6773 /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN = 0;
6774 /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO = 1;
6775 /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE = 2;
6776 t.constructor = SVGElement;
6777 t.prototype = new SVGElement();
6778 /*void*/ t.prototype.setOrientToAuto = function() {
6781 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
6784 })(SVGMarkerElement);
6785 function SVGColorProfileElement() {
6786 SVGElement.apply(this);
6787 /*DOMString*/ this._local;
6788 // raises DOMException on setting
6789 // (NOTE: is prefixed by "_"
6790 // as "local" is an IDL keyword. The
6791 // prefix will be removed upon processing)
6792 /*DOMString*/ this.name;
6793 /*unsigned short*/ this.renderingIntent;
6794 SVGURIReference.apply(this, arguments);
6797 SVGColorProfileElement.constructor = SVGElement;
6798 SVGColorProfileElement.prototype = new SVGElement();
6800 function SVGColorProfileRule() {
6801 SVGCSSRule.apply(this);
6802 /*DOMString*/ this.src;
6803 /*DOMString*/ this.name;
6804 /*unsigned short*/ this.renderingIntent;
6807 SVGColorProfileRule.constructor = SVGCSSRule;
6808 SVGColorProfileRule.prototype = new SVGCSSRule();
6810 function SVGGradientElement() {
6811 SVGElement.apply(this);
6812 SVGURIReference.apply(this);
6813 /*readonly SVGAnimatedEnumeration*/ this.gradientUnits = new SVGAnimatedEnumeration();
6814 /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
6815 /*readonly SVGAnimatedEnumeration*/ this.spreadMethod = new SVGAnimatedEnumeration();
6816 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6817 var grad = evt.target,
6819 t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
6821 href, stops, length,
6826 if (!ele || !grad) { //まだ、path要素などが設定されていない場合
6827 grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
6830 if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
6831 grad2 = grad._instance;
6833 stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
6835 ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
6838 length = stops.length;
6839 for (var i = 0; i < length; ++i) {
6841 sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
6842 ci = sstyle.getPropertyCSSValue("stop-color");
6843 if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
6844 /*再度、設定。css.jsのsetPropertyを参照*/
6845 sstyle.setProperty("color", sstyle.getPropertyValue("color"));
6847 color[i] = "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
6848 colors[i] = stop.offset.baseVal + " " + color[i];
6849 opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
6851 ele["method"] = "none";
6852 ele["color"] = color[0];
6853 ele["color2"] = color[length-1];
6854 ele["colors"] = colors.join(",");
6855 // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
6856 ele["opacity"] = opacity[length-1]+ "";
6857 ele["o:opacity2"] = opacity[0]+ "";
6858 /*SVGRadialGradientElementインターフェースで利用する*/
6859 grad._color = color;
6860 var gt = grad2.getAttributeNS(null, "gradientTransform");
6862 grad.setAttributeNS(null, "transform", gt);
6864 grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
6868 SVGGradientElement.constructor = SVGElement;
6869 SVGGradientElement.prototype = new SVGElement();
6870 // Spread Method Types
6871 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
6872 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD = 1;
6873 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
6874 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT = 3;
6876 function SVGLinearGradientElement() {
6877 SVGGradientElement.apply(this);
6878 var sl = SVGAnimatedLength;
6879 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
6880 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
6881 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
6882 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
6884 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6885 var grad = evt.target, ele = evt._tar, angle = 270;
6886 if (!!!ele) { //まだ、path要素などが設定されていない場合
6889 var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
6890 var fontSize = parseFloat(style.getPropertyValue("font-size"));
6891 grad.x1.baseVal._emToUnit(fontSize);
6892 grad.y1.baseVal._emToUnit(fontSize);
6893 grad.x2.baseVal._emToUnit(fontSize);
6894 grad.y2.baseVal._emToUnit(fontSize);
6895 angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
6899 ele.setAttribute("type", "gradient");
6900 ele.setAttribute("angle", angle + "");
6901 evt = ele = grad = angle = style = fontSize = void 0;
6905 SVGLinearGradientElement.constructor = SVGGradientElement;
6906 SVGLinearGradientElement.prototype = new SVGGradientElement();
6908 function SVGRadialGradientElement(_doc) {
6909 SVGGradientElement.apply(this);
6910 var sl = SVGAnimatedLength;
6911 /*readonly SVGAnimatedLength*/ this.cx = new sl();
6912 /*readonly SVGAnimatedLength*/ this.cy = new sl();
6913 /*readonly SVGAnimatedLength*/ this.r = new sl();
6914 /*readonly SVGAnimatedLength*/ this.fx = new sl();
6915 /*readonly SVGAnimatedLength*/ this.fy = new sl();
6917 this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
6918 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6919 var grad = evt.target, ele = evt._tar, tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
6920 if (!!!ele) { //まだ、path要素などが設定されていない場合
6923 ele.setAttribute("type", "gradientTitle");
6924 ele.setAttribute("focus", "100%");
6925 ele.setAttribute("focusposition", "0.5 0.5");
6926 if (tar.localName === "rect") {
6927 /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
6928 *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
6930 var style = grad.ownerDocument.defaultView.getComputedStyle(tar, "");
6931 var fontSize = parseFloat(style.getPropertyValue("font-size"));
6932 grad.cx.baseVal._emToUnit(fontSize);
6933 grad.cy.baseVal._emToUnit(fontSize);
6934 grad.r.baseVal._emToUnit(fontSize);
6935 grad.fx.baseVal._emToUnit(fontSize);
6936 grad.fy.baseVal._emToUnit(fontSize);
6937 var cx = grad.cx.baseVal.value, cy = grad.cy.baseVal.value;
6938 var r = grad.r.baseVal.value, rx, ry;
6940 var tarrect = tar.getBBox();
6941 var vi = tar.ownerDocument.documentElement.viewport;
6942 var el = vi.width | 0, et = vi.height | 0, er = 0, eb = 0;
6943 var units = grad.getAttributeNS(null, "gradientUnits");
6944 if (!units || units === "objectBoundingBox") {
6945 //%の場合は小数点に変換(10% -> 0.1)
6946 cx = cx > 1 ? cx/100 : cx; cy = cy > 1 ? cy/100 : cy; r = r > 1 ? r/100 : r;
6947 //要素の境界領域を求める(四隅の座標を求める)
6948 var nx = tarrect.x, ny = tarrect.y, wid = tarrect.width, hei = tarrect.height;
6949 cx = cx*wid + nx; cy = cy*hei + ny; rx = r*wid; ry = r*hei;
6950 nx = ny = wid = hei = void 0;
6952 var matrix = tar.getScreenCTM().multiply(grad.getCTM());
6953 el = cx - rx; et = cy - ry; er = cx + rx; eb = cy + ry;
6954 var rrx = rx * 0.55228, rry = ry * 0.55228;
6955 var 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"];
6956 for (var i = 0, lili = list.length; i < lili;) {
6957 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
6961 var p = grad.ownerDocument.documentElement.createSVGPoint();
6962 p.x = parseFloat(list[i]);
6963 p.y = parseFloat(list[i+1]);
6964 var pmt = p.matrixTransform(matrix);
6971 var ellipse = list.join(" ");
6972 var outline = _doc.getElementById("_NAIBU_outline");
6973 var background = _doc.createElement("div"), bstyle = background.style;
6974 bstyle.position = "absolute";
6975 bstyle.display = "inline-block";
6976 var w = vi.width, h = vi.height;
6977 bstyle.textAlign = "left"; bstyle.top = "0px"; bstyle.left = "0px"; bstyle.width = w+ "px"; bstyle.height = h+ "px";
6978 outline.appendChild(background);
6979 bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
6980 background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
6981 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>';
6982 var data = tar._tar.path.value;
6983 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>';
6984 background.filters[0].apply();
6985 background.innerHTML = circle;
6986 background.filters[0].play();
6987 tar._tar.parentNode.insertBefore(background, tar._tar);
6988 tar._tar.filled = "false";
6989 ellipse = outline = background = style = fontSize = bstyle = circle = data = list = gt = cx = cy = r = w = h = matrix = void 0;
6990 } else if (!ele.parentNode){
6991 tar._tar.appendChild(ele);
6993 evt = tar = ele = gard = void 0;
6997 SVGRadialGradientElement.constructor = SVGGradientElement;
6998 SVGRadialGradientElement.prototype = new SVGGradientElement();
7000 function SVGStopElement() {
7001 SVGElement.apply(this, arguments);
7002 /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
7003 this.addEventListener("DOMAttrModified", function(evt) {
7004 if (evt.attrName === "offset") {
7005 evt.target.offset.baseVal = parseFloat(evt.newValue);
7011 SVGStopElement.constructor = SVGElement;
7012 SVGStopElement.prototype = new SVGElement();
7014 function SVGPatternElement() {
7015 SVGElement.apply(this);
7016 var sl = SVGAnimatedLength;
7017 /*readonly SVGAnimatedEnumeration*/ this.patternUnits = new SVGAnimatedEnumeration();
7018 /*readonly SVGAnimatedEnumeration*/ this.patternContentUnits = new SVGAnimatedEnumeration();
7019 /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
7020 /*readonly SVGAnimatedLength*/ this.x = new sl();
7021 /*readonly SVGAnimatedLength*/ this.y = new sl();
7022 /*readonly SVGAnimatedLength*/ this.width = new sl();
7023 /*readonly SVGAnimatedLength*/ this.height = new sl();
7025 SVGURIReference.apply(this, arguments);
7026 //SVGFitToViewBoxのインターフェースを用いる
7027 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7028 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7029 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7032 SVGPatternElement.constructor = SVGElement;
7033 SVGPatternElement.prototype = new SVGElement();
7035 function SVGClipPathElement() {
7036 SVGElement.apply(this, arguments);
7037 /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
7040 SVGClipPathElement.constructor = SVGElement;
7041 SVGClipPathElement.prototype = new SVGElement();
7043 function SVGMaskElement() {
7044 SVGElement.apply(this);
7045 var sl = SVGAnimatedLength;
7046 /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
7047 /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
7048 /*readonly SVGAnimatedLength*/ this.x = new sl();
7049 /*readonly SVGAnimatedLength*/ this.y = new sl();
7050 /*readonly SVGAnimatedLength*/ this.width = new sl();
7051 /*readonly SVGAnimatedLength*/ this.height = new sl();
7055 SVGMaskElement.constructor = SVGElement;
7056 SVGMaskElement.prototype = new SVGElement();
7058 function SVGFilterElement() {
7059 SVGElement.apply(this);
7060 var sl = SVGAnimatedLength;
7061 /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
7062 /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
7063 /*readonly SVGAnimatedLength*/ this.x = new sl();
7064 /*readonly SVGAnimatedLength*/ this.y = new sl();
7065 /*readonly SVGAnimatedLength*/ this.width = new sl();
7066 /*readonly SVGAnimatedLength*/ this.height = new sl();
7068 /*readonly SVGAnimatedInteger*/ this.filterResX = new SVGAnimatedInteger();
7069 /*readonly SVGAnimatedInteger*/ this.filterResY = new SVGAnimatedInteger();
7070 SVGURIReference.apply(this, arguments);
7071 //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
7074 SVGFilterElement.constructor = SVGElement;
7075 SVGFilterElement.prototype = new SVGElement();
7077 function SVGFilterPrimitiveStandardAttributes(ele) {
7078 SVGStylable.apply(this, arguments);
7080 var sl = SVGAnimatedLength;
7081 /*readonly SVGAnimatedLength*/ this.x = new sl();
7082 /*readonly SVGAnimatedLength*/ this.y = new sl();
7083 /*readonly SVGAnimatedLength*/ this.width = new sl();
7084 /*readonly SVGAnimatedLength*/ this.height = new sl();
7085 /*readonly SVGAnimatedString*/ this.result = new sl();
7088 SVGFilterPrimitiveStandardAttributes.constructor = SVGStylable;
7089 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
7091 function SVGFEBlendElement() {
7092 SVGElement.apply(this, arguments);
7093 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7094 /*readonly SVGAnimatedString*/ this.in2 = new SVGAnimatedString();
7095 /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
7096 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7099 SVGFEBlendElement.constructor = SVGElement;
7100 SVGFEBlendElement.prototype = new SVGElement();
7102 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN = 0;
7103 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL = 1;
7104 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
7105 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN = 3;
7106 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN = 4;
7107 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN = 5;
7109 function SVGFEGaussianBlurElement() {
7110 SVGElement.apply(this, arguments);
7111 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7112 /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
7113 /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
7114 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7117 SVGFEGaussianBlurElement.constructor = SVGElement;
7118 SVGFEGaussianBlurElement.prototype = new SVGElement();
7119 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
7123 function SVGCursorElement() {
7124 SVGElement.apply(this, arguments);
7125 /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
7126 /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
7127 SVGURIReference.apply(this, arguments);
7130 SVGCursorElement.constructor = SVGElement;
7131 SVGCursorElement.prototype = new SVGElement();
7133 function SVGAElement(_doc) {
7134 SVGElement.apply(this);
7135 this._tar = _doc.createElement("a");
7137 /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
7138 this.target.baseVal = "_self";
7139 this.addEventListener("DOMAttrModified", function(evt){
7140 var tar = evt.target;
7141 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7144 if (evt.attrName === "target") {
7145 tar.target.baseVal = evt.newValue;
7146 } else if (evt.attrName === "xlink:title") {
7147 tar._tar.setAttribute("title", evt.newValue);
7151 this.addEventListener("DOMNodeInserted", function(evt){
7152 var tar = evt.target;
7153 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7156 if (tar.nextSibling) {
7157 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
7158 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
7160 } else if (!!tar.parentNode._tar){
7161 tar.parentNode._tar.appendChild(tar._tar);
7163 var txts = tar._tar.style;
7164 txts.cursor = "hand";
7167 txts.textDecoration = "none";
7169 var t = tar.target.baseVal;
7171 if (t === "_blank") {
7174 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
7175 tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
7178 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7179 var tar = evt.target;
7180 if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
7181 var txts = tar._tar.style;
7182 txts.cursor = "hand";
7183 txts.textDecoration = "none";
7189 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7190 var tar = evt.target;
7191 tar._tar.setAttribute("target", tar.target.baseVal);
7192 if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
7193 tar.addEventListener("click", function(evt){
7194 var tar = evt.target,
7197 sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
7198 if (tar.target.baseVal === "_self") {
7199 nd = tar.ownerDocument._iframe;
7200 nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
7201 ob = nd.nextSibling;
7202 if (ob && (ob.tagName === "OBJECT")) {
7203 nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
7204 nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
7205 nd.parentNode.removeChild(ob);
7207 ob = NAIBU._search([nd.previousSibling]);
7208 nd.parentNode.removeChild(nd);
7210 sd.appendChild(sd.lastChild.firstChild);
7211 while (sd.firstChild !== sd.lastChild) { //オブジェクト要素以外を除去
7212 sd.removeChild(sd.firstChild);
7214 ob = NAIBU._search([sd.lastChild]);
7216 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
7217 evt.preventDefault();
7219 _init: (function (ob) {
7221 document.title = ob.getSVGDocument().title;
7227 sd = ob = nd = void 0;
7232 SVGURIReference.apply(this, arguments);
7235 SVGAElement.constructor = SVGElement;
7236 SVGAElement.prototype = new SVGElement();
7238 function SVGViewElement() {
7239 SVGElement.apply(this, arguments);
7240 /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
7241 //SVGFitToViewBoxのインターフェースを用いる
7242 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7243 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7244 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7247 SVGViewElement.constructor = SVGElement;
7248 SVGViewElement.prototype = new SVGElement();
7250 function SVGScriptElement() {
7251 SVGElement.apply(this);
7252 /*DOMString*/ this.type;
7253 SVGURIReference.apply(this, arguments);
7254 this.addEventListener("DOMAttrModified", function(evt){
7255 if (evt.attrName === "type") {
7256 evt.target.type = evt.newValue;
7260 this.addEventListener("S_Load", function(evt){
7261 var tar = evt.target, script = tar._text;
7262 var tod = tar.ownerDocument;
7263 NAIBU._temp_doc = tod;
7264 script = script.replace(/function\s+(\w+)/g, "$1 = function");
7265 script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
7268 } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
7269 script = script.replace(/function\(document\){/, "function() {");
7272 tar = evt = script = void 0;
7274 this.addEventListener("DOMNodeInserted", function(evt){
7275 var tar = evt.target;
7276 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7277 if (tar.nodeName === "#cdata-section") {
7278 evt.currentTarget._text = tar.data;
7282 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7283 var tar = evt.target;
7284 if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7285 var evtt = tar.ownerDocument.createEvent("SVGEvents");
7286 evtt.initEvent("S_Load", false, false);
7287 evt.currentTarget.dispatchEvent(evtt);
7294 SVGScriptElement.constructor = SVGElement;
7295 SVGScriptElement.prototype = new SVGElement();
7297 function SVGEvent() {
7298 Event.apply(this, arguments);
7301 SVGEvent.constructor = Event;
7302 SVGEvent.prototype = new Event();
7304 function SVGZoomEvent() {
7305 UIEvent.apply(this, arguments);
7306 /*readonly SVGRect*/ this.zoomRectScreen = new SVGRect();
7307 /*readonly float*/ this.previousScale = 1;
7308 /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
7309 /*readonly float*/ this.newScale = 1;
7310 /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
7313 SVGZoomEvent.constructor = UIEvent;
7314 SVGZoomEvent.prototype = new UIEvent();
7316 function SVGAnimationElement(es) {
7320 SVGElement.apply(this);
7321 /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
7322 *styleのsetPropertyメソッドを無効化させておく必要がある
7324 this.style.setProperty = function(){};
7326 /*readonly SVGElement*/ this.targetElement;
7327 this._beginValue = "0ms";
7328 this._endValue = null;
7329 this._currentFrame = 0;
7330 this._currentCount = 0;
7331 /*_maxCountはrepeatCount属性で指定された数値
7332 *_maxDurはrepeatDur属性で指定された数値
7336 this._isRepeat = false;
7337 /*_simpleDurationプロパティは
7338 *dur属性の数値を収納しておく。属性がなければnullのまま
7340 this._simpleDuration = null;
7341 /*_beginと_endプロパティはミリ秒数を収納する。リピート時に書き換えられることがある。
7342 *_beginはアニメ開始時の秒数。_endはアニメ終了時の秒数。
7343 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
7347 this._from = this._to = this._values = this._by = null;
7348 this._keyTimes = null;
7349 this.addEventListener("beginEvent", function(evt) {
7350 var tar = evt.target;
7351 if (!tar.isRepeat) {
7352 tar.endElementAt(tar.getSimpleDuration());
7354 tar.beginElementAt(tar.getSimpleDuration());
7355 if (tar.getCurrentTime() !== 0) {
7356 var ttd = tar.ownerDocument, evt = ttd.createEvent("TimeEvents");
7357 tar._currentCount++;
7358 evt.initTimeEvent("repeatEvent", ttd.defaultView, tar._currentCount);
7359 tar.dispatchEvent(evt);
7363 this.addEventListener("DOMAttrModified", function(evt){
7364 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7367 var tar = evt.target, name = evt.attrName;
7368 if (name === "begin") {
7369 tar._beginValue = evt.newValue;
7370 } else if (name === "end") {
7371 tar._endValue = evt.newValue;
7372 } else if (name === "dur") {
7373 tar._simpleDuration = tar._getOffset(evt.newValue);
7374 } else if (name === "repeatCount") {
7375 tar._maxCount = parseFloat(evt.newValue);
7376 tar._isRepeat = true;
7377 } else if (name === "repeatDur") {
7378 tar._maxDur = parseFloat(evt.newValue);
7379 tar._isRepeat = true;
7380 } else if (name === "from") {
7381 tar._from = evt.newValue;
7382 } else if (name === "to") {
7383 tar._to = evt.newValue;
7384 } else if (name === "values") {
7385 tar._values = evt.newValue.split(";");
7386 } else if (name === "by") {
7387 tar._by = evt.newValue;
7388 } else if (name === "keyTimes") {
7389 var s = evt.newValue.split(";");
7390 tar._keyTimes = []; //_keyTimesプロパティを初期化
7391 for (var i=0;i<s.length;++i) {
7392 tar._keyTimes[i] = parseFloat(s[i]);
7398 this.addEventListener("DOMNodeInserted", function(evt){
7399 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7402 var tar = evt.target;
7403 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7404 var tar = evt.target;
7405 /*以降の場合分けルールに関しては、下記の仕様を参照
7406 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
7409 } else if (tar._from && tar._to) {
7410 tar._values = [tar._from, tar._to];
7411 } else if (tar._from && tar._by) {
7412 var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
7413 tar._values = [tar._from, n+tanni[0]];
7414 } else if (tar._to) {
7415 tar._values = [null, tar._to];
7416 } else if (tar._by) {
7417 tar._values = [null, null, tar._by];
7418 } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
7419 /*アニメーションの効果が出ないように調整する
7422 *>if none of the from, to, by or values attributes are specified, the animation will have no effect
7423 *「3.2.2. Animation function values」より引用
7424 *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
7428 if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7429 tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").substring(1))
7431 tar.targetElement = tar.parentNode;
7433 tar._eventSync(tar._beginValue,
7434 (function(te, offse, ta, t) {
7435 ta.addEventListener( t.match(te._eventRegExp)[0],
7438 te.beginElementAt(offse);
7440 te._begin = NAIBU.Time.currentFrame;
7445 }), "beginElementAt");
7446 if (tar._endValue) {
7447 tar._eventSync(tar._endValue,
7448 (function(te, offse, ta, t) {
7449 ta.addEventListener( t.match(te._eventRegExp)[0],
7451 te.endElementAt(offse);
7453 }), "endElementAt");
7459 this.addEventListener("repeatEvent", function(evt) {
7460 var tar = evt.target;
7461 if ((tar._currentCount >= tar._maxCount) || (tar.getCurrentTime() >= (tar._maxDur+tar.getStartTime()))) {
7462 tar._isRepeat = false;
7467 SVGAnimationElement.constructor = SVGElement;
7468 SVGAnimationElement.prototype = new SVGElement();
7469 /*以下のメソッド(beginElementなど)については、
7470 *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
7472 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
7473 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
7474 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
7475 this.dispatchEvent(evt);
7477 /*void*/ SVGAnimationElement.prototype.endElement = function() {
7478 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
7479 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
7480 this.dispatchEvent(evt);
7482 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
7483 var ntc = this.ownerDocument.documentElement.getCurrentTime();
7484 this._begin = offset + ntc;
7486 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
7487 var ntc = this.ownerDocument.documentElement.getCurrentTime();
7488 this._end = offset + ntc;
7490 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
7491 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?/;
7492 SVGAnimationElement.prototype._unit = {
7499 * どれだけズレの時間があるかを計測するメソッド
7500 *tに数値が使われていないときは0を返す
7501 *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
7502 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
7503 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
7504 ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
7506 SVGAnimationElement.prototype._getOffset = function(/*string*/ t) {
7507 var n = parseFloat(t.match(this._timeRegExp));
7508 if (!isNaN(n) && RegExp.$1) {
7509 var offset = n * this._unit[RegExp.$1]
7510 } else if (!isNaN(n)) {
7519 *イベントがある場合とない場合とで、別々の処理に分けるメソッド
7521 SVGAnimationElement.prototype._eventSync = function(/*string*/ t, /*function*/ f, /*string*/ methodName) {
7522 var offset = this._getOffset(t);
7523 this._begin = NAIBU.Time.Max;
7524 if ( /(mouse|activ|click|begin|end)/.test(t) ) { //イベントがある場合
7526 if ( /([^;]+)\.\D/.test(t) ) {
7527 tar = this.ownerDocument.getElementById(RegExp.$1);
7529 tar = this.targetElement;
7531 if (!offset && offset !== 0) {
7532 offset = NAIBU.Time.Max;
7534 f(this, offset, tar, t);
7535 } else if (!offset && (t !== "undefined") && (offset !== 0)) {
7538 this[methodName](offset);
7541 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
7542 if (!!this._begin || (this._begin === 0)) {
7543 return (this._begin);
7545 throw new DOMException(DOMException.INVALID_STATE_ERR);
7548 /*getCurrentTimeメソッド
7550 *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
7552 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
7553 return (this._currentFrame * 125 * 0.8);
7555 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
7556 if (!!!this._simpleDuration && !!!this._end && (this._simpleDuration !== 0)) {
7557 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
7558 } else if (!!this._simpleDuration && !!this._end) {
7559 var s = (this._simpleDuration > this._end - this._begin) ? this._end - this._begin : this._simpleDuration;
7561 var s = !!this._end ? this._end - this._begin : this._simpleDuration;
7565 //raises( DOMException );
7569 start : function() {
7570 if (NAIBU.Clip.length > 0) {
7571 screen.updateInterval = 42; //24fpsとして描画処理
7572 window.onscroll = function () {
7573 screen.updateInterval = 0;
7574 screen.updateInterval = 42;
7576 NAIBU.stop = setInterval( (function() {
7578 var ntc = NAIBU.Time.currentFrame++;
7579 var nc = NAIBU.Clip;
7580 var s = ntc * 100; //フレーム数ntcをミリ秒数sに変換
7581 if (ntc > NAIBU.Time.Max) {
7582 clearInterval(NAIBU.stop);
7584 for (var i=0,ncli=nc.length;i<ncli;++i) {
7586 nci.ownerDocument.documentElement.setCurrentTime(s);
7587 if ("_begin" in nci) {
7588 if (nci.getStartTime() <= s) {
7589 if (nci.getCurrentTime() === 0) {
7592 nci._currentFrame++;
7594 if (nci._end && (nci._end <= s) && (nci.getCurrentTime() !== 0)) {
7596 nci._frame && nci._frame();
7597 nci._currentFrame = 0;
7600 } else if (!!nci._frame) {
7613 window.onscroll = function () {
7614 screen.updateInterval = 0;
7615 window.onscroll = NAIBU.emptyFunction;
7622 function SVGAnimateElement(){
7623 SVGAnimationElement.apply(this);
7624 /*NAIBU.Clipについては、NAIBU.Timeで使う
7625 *くわしくはNAIBU.Time.start関数のコードを参照
7627 NAIBU.Clip[NAIBU.Clip.length] = this;
7629 *機械が理解できる形で保管されているvalueの値の配列リスト
7631 this._valueList = [];
7632 this._isDiscrete = false;
7633 this.addEventListener("DOMAttrModified", function(evt){
7634 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7637 if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
7638 evt.target._isDiscrete = true;
7641 this.addEventListener("DOMNodeInserted", function(evt){
7642 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7645 var tar = evt.target;
7646 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7647 var tar = evt.target,
7648 attrName = tar.getAttributeNS(null, "attributeName"),
7649 ttr = tar.targetElement,
7650 tta = ttr[attrName];
7651 /*tar.valuesのリスト: ["12px", "13px"]
7652 *tar._valueList: [(new SVGPoint()), (new SVGPoint())]
7653 * tar.valuesを機械が理解できるように変換したものがtar._valueList
7654 *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
7656 var vi = ttr.cloneNode(false);
7657 if (!tar._values[0]) { //to属性か、by属性が設定されている場合
7658 var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
7659 tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
7660 if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
7661 var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
7662 tar._values[1] = v2 + tanni[0];
7664 v2 = tanni = void 0;
7667 if ("animatedPoints" in ttr) {
7668 ttr.animatedPoints = vi.points;
7669 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7670 var vir = ttr.cloneNode(false);
7672 vir.setAttributeNS(null, "points", tav[i]);
7673 tar._valueList[tar._valueList.length] = vir.points;
7676 tta.animVal = vi[attrName].baseVal;
7677 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7678 var vir = ttr.cloneNode(false); //仮の要素
7680 vir.setAttributeNS(null, attrName, tav[i]);
7681 tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
7683 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7684 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7685 if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
7686 tar._valueList[i] = new SVGPaint();
7687 tar._valueList[i].setPaint(1, null, tav[i], null)
7689 tar._valueList[i] = parseFloat(tav[i]);
7692 } else if ("normalizedPathSegList" in ttr) {
7693 ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
7694 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7695 var vir = ttr.cloneNode(false);
7697 vir.setAttributeNS(null, "d", tav[i]);
7698 tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
7704 evt = tta = vir = vi = void 0;
7707 this.addEventListener("beginEvent", function(evt) {
7708 var tar = evt.target;
7709 var attrName = tar.getAttributeNS(null, "attributeName"), newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName);
7710 var ttr = tar.targetElement, tta = ttr[attrName];
7711 tar._frame = function() {
7712 var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length-1, tg = tar.getCurrentTime();
7713 if ((n !== -1) && (d !== 0) && (tg <= d)) {
7714 if (tar._isDiscrete) {
7715 ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
7717 var ii = Math.floor((tg*n) / d);
7718 if (ii === n) { //iiが境い目のときは、n-2を適用
7724 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
7726 * 参照:アニメーションサンドイッチモデル
7727 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
7728 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
7730 var evt = tar.ownerDocument.createEvent("MutationEvents");
7731 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7732 if (tar._keyTimes) {
7733 var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
7734 var ti = tar._keyTimes[ii];
7736 var di = d / n; //keyTimesがなければ均等に時間を配分しておく
7739 if ("animatedPoints" in ttr) {
7740 var base = ttr.points;
7741 ttr.points = ttr.animatedPoints;
7742 ttr.dispatchEvent(evt);
7743 ttr.animatedPoints = ttr.points;
7746 var base = tta.baseVal, tanim = tta.animVal;
7747 var v1 = tar._valueList[ii].value;
7748 /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
7749 * 3.4.2 Specifying the simple animation function f(t)
7750 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
7752 if (!tar._isDiscrete) {
7753 var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
7757 tanim.newValueSpecifiedUnits(base.unitType, v);
7758 tta.baseVal = tanim;
7760 ttr.dispatchEvent(evt);
7761 /*変化値はanimValプロパティに収納しておき、
7762 *変化する前の、元の値はbaseValプロパティに再び収納しておく
7764 tta.animVal = tta.baseVal;
7767 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7769 var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
7770 if (!tar._isDiscrete) {
7771 var v = v1 + (v2-v1) * (tg-ti*d) / di;
7775 } else if ("normalizedPathSegList" in ttr) {
7776 var base = ttr.normalizedPathSegList;
7777 ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
7778 ttr.dispatchEvent(evt);
7779 ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
7780 ttr.normalizedPathSegList = base;
7782 evt = v1 = v2 = v = d = n = ii = tg = void 0;
7786 this.addEventListener("endEvent", function(evt) {
7787 var tar = evt.target, fill = tar.getAttributeNS(null, "fill");
7788 if (!fill || (fill === "remove")) {
7789 var evt = tar.ownerDocument.createEvent("MutationEvents");
7790 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7791 tar.targetElement.dispatchEvent(evt);
7795 this.addEventListener("repeatEvent", function(evt) {
7796 var tar = evt.target;
7800 SVGAnimateElement.constructor = SVGAnimationElement;
7801 SVGAnimateElement.prototype = new SVGAnimationElement(1);
7803 function SVGSetElement(){
7804 SVGAnimationElement.apply(this);
7805 NAIBU.Clip[NAIBU.Clip.length] = this;
7807 this.addEventListener("DOMAttrModified", function(evt) {
7808 var tar = evt.target, name = evt.attrName;
7809 if (name === "to") {
7810 tar._to = evt.newValue;
7812 tar = name = void 0;
7814 this.addEventListener("beginEvent", function(evt) {
7815 var tar = evt.target;
7816 if (tar.targetElement) {
7817 var attrName = tar.getAttributeNS(null, "attributeName"),
7818 newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
7819 tta = tar.targetElement[attrName];
7820 if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7821 var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
7822 style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
7825 var base = tta.baseVal;
7826 if (base instanceof SVGLength) {
7827 tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
7828 } else if (base instanceof SVGRect) {
7829 tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
7831 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
7833 * 参照:アニメーションサンドイッチモデル
7834 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
7835 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
7837 var evt = tar.ownerDocument.createEvent("MutationEvents");
7838 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
7839 tar.targetElement.dispatchEvent(evt);
7841 /*変化値はanimValプロパティに収納しておき、
7842 *変化する前の、元の値はbaseValプロパティに再び収納しておく
7844 tta.animVal = tta.baseVal;
7848 evt = tar = attrName = void 0;
7850 this.addEventListener("endEvent", function(evt) {
7851 var tar = evt.target,
7852 fill = tar.getAttributeNS(null, "fill");
7853 if (!fill || (fill === "remove")) {
7854 var attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
7855 tar.targetElement.style.setProperty(attrName, style.getPropertyValue(attrName), null);
7856 var evtt = tar.ownerDocument.createEvent("MutationEvents");
7857 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7858 tar.targetElement.dispatchEvent(evtt);
7859 attrName = style = evtt = void 0;
7861 tar = fill = void 0;
7863 this.addEventListener("repeatEvent", function(evt) {
7864 var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
7868 SVGSetElement.constructor = SVGAnimationElement;
7869 SVGSetElement.prototype = new SVGAnimationElement(1);
7871 function SVGAnimateMotionElement(){
7872 SVGAnimationElement.apply(this);
7873 NAIBU.Clip[NAIBU.Clip.length] = this;
7874 this.addEventListener("DOMAttrModified", function(evt){
7875 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7878 var tar = evt.target,
7879 name = evt.attrName;
7880 if (name === "path") {
7881 var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
7882 d.setAttributeNS(null, "d", evt.newValue);
7887 this.addEventListener("DOMNodeInserted", function(evt){
7888 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7891 var tar = evt.target;
7892 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7896 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7899 vlist[i] = [+ti[0], +ti[1]];
7901 tar._valueList = vlist;
7905 this.addEventListener("beginEvent", function(evt) {
7906 var tar = evt.target,
7907 trans = tar.targetElement.transform;
7908 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
7911 trans.animVal = new SVGTransformList();
7912 if (trans.baseVal.numberOfItems !== 0) {
7913 trans.baseVal.consolidate();
7914 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
7916 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
7918 tar._frame = function() {
7921 tgsd = _tar.getSimpleDuration(),
7923 tg = _tar.getCurrentTime(),
7929 if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
7930 var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
7931 p = tpn.getPointAtLength(st),
7932 trans = _tar.targetElement.transform;
7933 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
7934 var base = trans.baseVal;
7935 trans.baseVal = trans.animVal;
7936 _tar.targetElement._cacheMatrix = null;
7937 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
7938 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7939 _tar.targetElement.dispatchEvent(evtt);
7940 trans.baseVal = base;
7941 evtt = base = trans = st = p = void 0;
7942 } else if (tar._valueList) {
7943 var total = 0, //totalは総距離
7944 st = 0, //stは現在にいたるまでの距離
7945 tav = tar._valueList,
7947 if ((n !== -1) && (d !== 0) && (tg <= d)) {
7948 ii = Math.floor((tg*n) / d);
7949 if (ii === n) { //iiが境い目のときは、n-2を適用
7955 for (var i=1, tvli=tav.length;i<tvli;i+=2) {
7956 total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
7958 for (var i=1;i<ii;i+=2) {
7959 st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
7961 var p = tar.ownerDocument.documentElement.createSVGPoint(),
7962 trans = _tar.targetElement.transform;
7963 st = (st / total) * d;
7964 p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
7965 p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
7966 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
7967 var base = trans.baseVal;
7968 trans.baseVal = trans.animVal;
7969 _tar.targetElement._cacheMatrix = void 0;
7970 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
7971 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7972 _tar.targetElement.dispatchEvent(evtt);
7973 trans.baseVal = base;
7974 evtt = base = trans = st = p = void 0;
7977 evt = trans = tpn = tgsd = void 0;
7979 this.addEventListener("endEvent", function(evt) {
7980 var tar = evt.target,
7981 trans = tar.targetElement.transform,
7982 fill = tar.getAttributeNS(null, "fill");
7983 if (!fill || (fill === "remove")) {
7984 trans.animVal = trans.baseVal;
7985 var evtt = tar.ownerDocument.createEvent("MutationEvents");
7986 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7987 tar.targetElement.dispatchEvent(evtt);
7989 tar._frame = evt = evtt = void 0;
7991 this.addEventListener("repeatEvent", function(evt) {
7992 var tar = evt.target;
7996 SVGAnimateMotionElement.constructor = SVGAnimationElement;
7997 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
7999 function SVGMPathElement() /* :
8002 SVGExternalResourcesRequired*/ {
8003 SVGElement.apply(this);
8004 SVGURIReference.apply(this);
8007 SVGMPathElement.constructor = SVGElement;
8008 SVGMPathElement.prototype = new SVGElement();
8010 function SVGAnimateColorElement() {
8011 SVGAnimationElement.apply(this);
8012 NAIBU.Clip[NAIBU.Clip.length] = this;
8013 this._valueList = [];
8014 this.addEventListener("DOMNodeInserted", function(evt){
8015 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8018 var tar = evt.target;
8019 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8020 var tar = evt.target,
8021 attrName = tar.getAttributeNS(null, "attributeName"),
8022 ttr = tar.targetElement,
8023 fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
8025 if (!tar._values[0]) {
8026 tar._values[0] = fstyle.getPropertyValue(attrName);
8028 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8029 var to = new SVGColor();
8030 if (tar._values[i] === "currentColor") {
8031 to.setRGBColor(fstyle.getPropertyValue("color") || "black");
8032 } else if (tar._values[i] === "inherit") {
8033 /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
8034 css = fstyle.getPropertyCSSValue(attrName);
8035 n = css.cssValueType;
8036 css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
8037 to = fstyle.getPropertyCSSValue(attrName);
8038 css.cssValueType = n;
8040 to.setRGBColor(tar._values[i]);
8042 tar._valueList[tar._valueList.length] = to;
8045 tar = ttr = fstyle = css = n = attrName = void 0;
8048 this.addEventListener("beginEvent", function(evt) {
8049 var tar = evt.target,
8050 attrName = tar.getAttributeNS(null, "attributeName"),
8051 style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
8052 fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8053 tar._frame = function() {
8055 /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8056 * 3.4.2 Specifying the simple animation function f(t)
8057 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8059 var d = _tar.getSimpleDuration() * 0.8,
8060 n = _tar._valueList.length - 1,
8061 tg = _tar.getCurrentTime(),
8063 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8064 ii = Math.floor((tg*n) / d);
8065 if (ii === n) { //iiが境い目のときは、n-2を適用
8071 if (tar._keyTimes) {
8072 di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8073 ti = tar._keyTimes[ii];
8075 di = d / n; //keyTimesがなければ均等に時間を配分しておく
8078 var fc = _tar._valueList[ii].rgbColor,
8079 tc = _tar._valueList[ii+1].rgbColor,
8080 durd = (tg-ti*d) / di,
8081 num = CSSPrimitiveValue.CSS_NUMBER,
8082 fr = fc.red.getFloatValue(num),
8083 fg = fc.green.getFloatValue(num),
8084 fb = fc.blue.getFloatValue(num),
8085 r = fr + (tc.red.getFloatValue(num) - fr) * durd,
8086 g = fg + (tc.green.getFloatValue(num) - fg) * durd,
8087 b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
8088 style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
8089 _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = void 0;
8093 this.addEventListener("endEvent", function(evt) {
8094 var tar = evt.target;
8095 if (!fill || (fill === "remove")) {
8096 var evtt = tar.ownerDocument.createEvent("MutationEvents");
8097 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8098 tar.targetElement.dispatchEvent(evtt);
8100 tar._frame = evt = evtt = void 0;
8102 this.addEventListener("repeatEvent", function(evt) {
8103 var tar = evt.target;
8107 SVGAnimateColorElement.constructor = SVGAnimationElement;
8108 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
8110 function SVGAnimateTransformElement() {
8111 SVGAnimationElement.apply(this);
8112 NAIBU.Clip[NAIBU.Clip.length] = this;
8113 this.addEventListener("beginEvent", function(evt) {
8114 var tar = evt.target, trans = tar.targetElement.transform;
8115 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8118 trans.animVal = new SVGTransformList();
8119 if (trans.baseVal.numberOfItems !== 0) {
8120 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8122 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8124 this.addEventListener("endEvent", function(evt) {
8125 var tar = evt.target;
8127 this.addEventListener("repeatEvent", function(evt) {
8128 var tar = evt.target;
8132 SVGAnimateTransformElement.constructor = SVGAnimationElement;
8133 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
8135 function SVGFontElement() /*:
8137 SVGExternalResourcesRequired,
8139 SVGElement.apply(this);
8140 /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
8141 /*boolean or number*/ this._isExternal = 0;
8142 this.addEventListener("DOMNodeInserted", function(evt){
8143 var tar = evt.target;
8144 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8147 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8148 var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
8149 var nefunc = function(evt){
8150 var svg = evt.target;
8152 var familyName = fontFace.getAttributeNS(null, "font-family");
8153 var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
8154 for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
8155 var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
8156 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8157 NAIBU._noie_createFont(ti, _tar, true);
8160 evt = tar = svg = curt = textElments = svgns = _tar = void 0;
8162 if (!fontFace.__isLinked || tar._isExternal) {
8163 tar.ownerDocument.documentElement._svgload_limited = 0;
8164 tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
8170 SVGFontElement.constructor = SVGElement;
8171 SVGFontElement.prototype = new SVGElement();
8173 function SVGGlyphElement() /*:
8176 SVGElement.apply(this);
8179 SVGGlyphElement.constructor = SVGElement;
8180 SVGGlyphElement.prototype = new SVGElement();
8182 function SVGMissingGlyphElement() /*:
8185 SVGElement.apply(this);
8188 SVGMissingGlyphElement.constructor = SVGElement;
8189 SVGMissingGlyphElement.prototype = new SVGElement();
8191 function SVGHKernElement() {
8192 SVGElement.apply(this);
8195 SVGHKernElement.constructor = SVGElement;
8196 SVGHKernElement.prototype = new SVGElement();
8198 function SVGVKernElement() {
8199 SVGElement.apply(this);
8202 SVGVKernElement.constructor = SVGElement;
8203 SVGVKernElement.prototype = new SVGElement();
8205 function SVGFontFaceElement() {
8206 SVGElement.apply(this);
8207 /*boolean(or number)*/ this._isLinked = 0;
8208 this.addEventListener("DOMNodeInserted", function(evt){
8209 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8210 if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
8211 evt.currentTarget._isLinked = 1;
8218 SVGFontFaceElement.constructor = SVGElement;
8219 SVGFontFaceElement.prototype = new SVGElement();
8221 function SVGFontFaceSrcElement() {
8222 SVGElement.apply(this);
8225 SVGFontFaceSrcElement.constructor = SVGElement;
8226 SVGFontFaceSrcElement.prototype = new SVGElement();
8228 function SVGFontFaceUriElement() {
8229 SVGElement.apply(this);
8230 this.addEventListener("DOMNodeInserted", function(evt){
8231 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8234 evt.target.ownerDocument.documentElement._svgload_limited--
8235 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
8237 this.addEventListener("S_Load", function(evt){
8238 var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
8239 if (tpp.localName === "defs") {
8240 tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
8242 tar._instance._isExternal = 1;
8243 tpp.parentNode.appendChild(tar._instance);
8244 evt = tar = tpp = void 0;
8246 SVGURIReference.apply(this);
8249 SVGFontFaceUriElement.constructor = SVGElement;
8250 SVGFontFaceUriElement.prototype = new SVGElement();
8252 function SVGFontFaceFormatElement() {
8253 SVGElement.apply(this);
8256 SVGFontFaceFormatElement.constructor = SVGElement;
8257 SVGFontFaceFormatElement.prototype = new SVGElement();
8259 function SVGFontFaceNameElement() {
8260 SVGElement.apply(this);
8263 SVGFontFaceNameElement.constructor = SVGElement;
8264 SVGFontFaceNameElement.prototype = new SVGElement();
8266 function SVGDefinitionSrcElement() {
8267 SVGElement.apply(this);
8270 SVGDefinitionSrcElement.constructor = SVGElement;
8271 SVGDefinitionSrcElement.prototype = new SVGElement();
8273 function SVGMetadataElement() {
8274 SVGElement.apply(this);
8277 SVGMetadataElement.constructor = SVGElement;
8278 SVGMetadataElement.prototype = new SVGElement();
8280 function SVGForeignObjectElement() /*:
8284 SVGExternalResourcesRequired,
8287 events::EventTarget*/ {
8288 SVGElement.apply(this);
8289 var sl = SVGAnimatedLength;
8290 /*readonly SVGAnimatedLength*/ this.x = new sl();
8291 /*readonly SVGAnimatedLength*/ this.y = new sl();
8292 /*readonly SVGAnimatedLength*/ this.width = new sl();
8293 /*readonly SVGAnimatedLength*/ this.height = new sl();
8297 SVGForeignObjectElement.constructor = SVGElement;
8298 SVGForeignObjectElement.prototype = new SVGElement();
8301 /*SVGの要素マッピング(DOMでは定められていないが、必須)
8302 *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
8303 *SIEでは軽量化のために、マッピングを用いた
8305 DOMImplementation["http://www.w3.org/2000/svg"] = {
8306 Document: SVGDocument,
8309 path: NAIBU.SVGPathElement,
8310 title: SVGTitleElement,
8311 desc: SVGDescElement,
8312 defs: SVGDefsElement,
8313 linearGradient: SVGLinearGradientElement,
8314 radialGradient: SVGRadialGradientElement,
8315 stop: SVGStopElement,
8316 rect: SVGRectElement,
8317 circle: SVGCircleElement,
8318 ellipse: SVGEllipseElement,
8319 polyline: SVGPolylineElement,
8320 polygon: SVGPolygonElement,
8321 text: SVGTextElement,
8322 tspan: SVGTSpanElement,
8323 image: SVGImageElement,
8324 line: SVGLineElement,
8326 altGlyphDef: SVGAltGlyphDefElement,
8327 altGlyph: SVGAltGlyphElement,
8328 altGlyphItem: SVGAltGlyphItemElement,
8329 animateColor: SVGAnimateColorElement,
8330 animate: SVGAnimateElement,
8331 animateMotion: SVGAnimateMotionElement,
8332 animateTransform:SVGAnimateTransformElement,
8333 clipPath: SVGClipPathElement,
8334 colorProfile: SVGColorProfileElement,
8335 cursor: SVGCursorElement,
8336 definitionSrc: SVGDefinitionSrcElement,
8337 feBlend: SVGFEBlendElement,
8338 feGaussianBlur: SVGFEGaussianBlurElement,
8339 filter: SVGFilterElement,
8340 font: SVGFontElement,
8341 "font-face": SVGFontFaceElement,
8342 "font-face-format":SVGFontFaceFormatElement,
8343 "font-face-name":SVGFontFaceNameElement,
8344 "font-face-src": SVGFontFaceSrcElement,
8345 "font-face-uri": SVGFontFaceUriElement,
8346 foreignObject: SVGForeignObjectElement,
8347 glyph: SVGGlyphElement,
8348 glyphRef: SVGGlyphRefElement,
8349 hkern: SVGHKernElement,
8350 marker: SVGMarkerElement,
8351 mask: SVGMaskElement,
8352 metadata: SVGMetadataElement,
8353 missingGlyph: SVGMissingGlyphElement,
8354 mpath: SVGMPathElement,
8355 script: SVGScriptElement,
8357 style: SVGStyleElement,
8358 "switch": SVGSwitchElement,
8359 textPath: SVGTextPathElement,
8360 tref: SVGTRefElement,
8362 view: SVGViewElement,
8363 vkern: SVGVKernElement,
8364 pattern: SVGPatternElement
8367 NAIBU._fontSearchURI = function(evt){
8368 var doc = evt.target.ownerDocument;
8369 var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
8370 for (var i=0;i<tsrc.length;++i) {
8371 var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
8372 ids = src.split(":")[1],
8373 xmlhttp = NAIBU.xmlhttp;
8374 xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
8375 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
8376 xmlhttp.onreadystatechange = function() {
8377 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
8378 var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
8379 NAIBU._font({document:doce, docu:doc, id:ids});
8380 xmlhttp = doc = doce = void 0;
8386 /*_font関数は、SVGFontで使う*/
8387 NAIBU._font = function (data) {
8388 var doc = data.document, svgns = "http://www.w3.org/2000/svg";
8389 //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
8390 var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
8391 var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
8392 if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
8393 var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
8394 for (var i=0,tli=textElements.length;i<tli;++i) {
8395 var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
8396 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8397 NAIBU._noie_createFont(ti, font, false);
8401 doc = data = void 0;
8403 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
8404 var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
8405 svgns = "http://www.w3.org/2000/svg",
8406 //isTategakiは縦書きならば真
8407 isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
8408 horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
8409 node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
8410 em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
8411 advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
8412 dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
8413 dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
8414 fontSize = parseFloat(style.getPropertyValue("font-size")),
8416 ds = false, npdlist = ["fill",
8422 "stroke-miterlimit",
8427 if (/a/[-1] === 'a') { //Firefoxならば
8429 } else if (isMSIE || isTategaki) {
8438 if (data !== void 0) { //dataがある場合
8439 var advanceX = [], glyphData = [];
8440 for (var i=0,gli=glyphs.length;i<gli;++i) {
8441 var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
8442 var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
8444 if (orientation === "h") {
8448 isOrientationAttribute = false;
8450 if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
8451 //indexは該当する文字が何番目にあるかの数字
8452 var index = data.indexOf(unicode);
8453 while (index > -1) {
8454 advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
8455 glyphData[index] = glyph.getAttributeNS(null, "d");
8456 index = data.indexOf(unicode, index+1);
8460 for (var i=0,adv=0;i<data.length;++i) {
8461 if (advanceX[i] !== void 0) { //配列に含まれていれば
8462 var path = ti.ownerDocument.createElementNS(svgns, "path");
8463 //advance、すなわち字幅の長さ分、ずらしていく
8464 var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
8467 for (var j=0;j<npdlist.length;++j){
8468 var nj = npdlist[j], tg = ti.getAttributeNS(null, nj);
8470 path.setAttributeNS(null, nj, tg);
8474 var y= dy + adv*fe, x = dx;
8475 if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
8476 var fms = fontSize / Math.SQRT2;
8484 matrix.e = dx + adv*fe;
8487 path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
8488 path.setAttributeNS(null, "d", glyphData[i]);
8489 ti.parentNode.insertBefore(path, ti);
8494 adv = advanceX = glyphData = void 0;
8495 } else if ("tspan|a".indexOf(node.localName) > -1){
8496 NAIBU._noie_createFont(node, font, isMSIE);
8498 node = node.nextSibling;
8501 var style = ti.ownerDocument.getOverrideStyle(ti, null);
8502 style.setProperty("visibility", "hidden");
8505 ti.setAttributeNS(null, "opacity", "0");
8508 data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
8511 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
8512 *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
8515 var s = new CSSStyleDeclaration(),
8521 for (var i in CSS2Properties) {
8522 if(CSS2Properties.hasOwnProperty(i)) {
8523 t = i.replace(regAZ, "-");
8525 u = "-" +RegExp.$1.toLowerCase();
8529 t = t.replace(regm, u);
8530 s.setProperty(t, CSS2Properties[i]);
8531 slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
8532 slis[n]._isDefault = 1;
8538 slis._fontSize = 12;
8539 CSS2Properties._list = slis;
8540 Document.prototype.defaultView._defaultCSS = slis;
8541 s = n = regAZ = regm = slis =null;
8544 NAIBU.addEvent = function(evt,lis){
8545 if (window.addEventListener) {
8546 window.addEventListener(evt, lis, false);
8547 } else if (window.attachEvent) {
8548 window.attachEvent('on'+evt, lis);
8550 window['on'+evt] = lis;
8558 function unsvgtovml() {
8560 if ("stop" in NAIBU) {
8561 clearInterval(NAIBU.stop);
8563 window.onscroll = NAIBU.emptyFunction;
8564 window.detachEvent("onload", NAIBU._main);
8566 Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
8567 Array = ActiveXObject = void 0;
8573 NAIBU._main = (function() {
8574 stlog = new STLog(false);
8575 var xmlhttp, //XMLHttpオブジェクトを生成
8576 _doc = document; //documentのエイリアスを作成
8578 if (XMLHttpRequest) {
8581 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
8585 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
8592 xmlhttp = new XMLHttpRequest();
8597 NAIBU.xmlhttp = xmlhttp;
8599 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
8601 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
8606 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
8607 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
8608 var st = _doc.createStyleSheet();
8609 var vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
8610 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
8611 + "dn\\:defs{display:none}"
8612 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
8613 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
8615 var ary = _doc.getElementsByTagName("script");
8616 //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
8617 for (var i=0; ary[i]; ++i) {
8620 if (ai.type === "image/svg+xml") {
8622 if (sieb_s && ait.match(/<svg/)) {
8624 ait = ait.replace(/<.+?>/g, "");
8626 ait = ait.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
8629 var gsd = new GetSVGDocument(ai);
8633 responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
8637 var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
8638 ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
8639 var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
8640 ai.parentNode.insertBefore(s,ai);
8648 if (xmlhttp && NAIBU.isMSIE) {
8649 if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
8651 var ob = _doc.getElementsByTagName("object"),
8652 em = _doc.getElementsByTagName("embed"),
8654 _search = function(_ob) {
8656 s || (s = []); //NAIBU._searchで呼ばれたときに必要
8657 _doc || (_doc = document);
8658 for (var i=0;_ob[i];++i) {
8660 s[s.length] = new GetSVGDocument(obi);
8661 ifr = _doc.createElement("iframe");
8662 ifr.style.background = "black";
8663 n = obi.getAttribute("width");
8664 n && ifr.setAttribute("width", n);
8665 n = obi.getAttribute("height");
8666 n && ifr.setAttribute("height", n);
8667 ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
8668 ifr.scrolling = "no";
8669 ifr.frameBorder = "0";
8670 /*iframe要素を使って、描画のプロセスを分離する
8671 *したがって、_docはdocumentとは別のオブジェクトとなる
8673 obi.parentNode.insertBefore(ifr, obi);
8675 i = obi = ifr = _ob = void 0;
8676 return s[s.length-1];
8680 NAIBU._search = _search; //a要素がクリックされたときに使う関数
8681 ob = em = _search = void 0;
8682 for (var i=0;i<s.length;++i) {
8683 if (i < s.length-1) {
8688 s[0]._init(); //初期化作業を開始
8693 var ob = _doc.getElementsByTagName("object");
8694 for (var i=0;i<ob.length;++i) {
8695 if (ob[i].contentDocument) {
8696 NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
8697 } else if (ob[i].getSVGDocument) {
8698 ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
8703 xmlhttp = _doc = void 0;
8705 NAIBU.addEvent("load", NAIBU._main);
8706 NAIBU.utf16 = function ( /*string*/ s) {
8709 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
8710 return s.replace(/%u\w\w\w\w/g, NAIBU.utf16);
8712 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
8713 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
8714 /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
8717 if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
8718 var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
8719 var ob = document.createElement("object");
8720 ob.setAttribute("data",data);
8721 ob.setAttribute("width",w);
8722 ob.setAttribute("height",h);
8723 ob.setAttribute("type","image/svg+xml");
8726 var doc = (new DOMParser()).parseFromString(source, "text/xml");
8727 return (document.importNode(doc.documentElement, true));
8730 NAIBU.addEvent("unload", unsvgtovml);
8732 NAIBU.isMSIE = /*@cc_on!@*/false;