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 tc = this._cevent[eventType];
1159 } else if (eventType === "SVGEvents") {
1160 evt = new SVGEvent();
1161 } else if (eventType === "TimeEvents") {
1162 evt = new TimeEvent();
1166 evt.type = eventType;
1167 evt.timeStamp = +(new Date());
1172 function UIEvent() {
1173 /*views::AbstractView*/ this.view;
1174 /*long*/ this.detail = 0;
1178 UIEvent.prototype = new Event();
1179 UIEvent.constructor = Event;
1180 /*void*/ UIEvent.prototype.initUIEvent = function( /*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*views::AbstractView*/ viewArg, /*long*/ detailArg) {
1181 this.initEvent(typeArg, canBubbleArg, cancelableArg);
1182 this.detail = detailArg;
1183 this.view = viewArg;
1185 function MouseEvent(evt) {
1186 UIEvent.call(this, arguments);
1187 /*long*/ this.screenX;
1188 /*long*/ this.screenY;
1189 /*long*/ this.clientX = this.clientY = 0;
1190 /*boolean*/ this.ctrlKey = this.shiftKey = this.altKey = this.metaKey = false;
1191 /*unsigned short*/ this.button;
1192 /*EventTarget*/ this.relatedTarget;
1195 MouseEvent.prototype = new UIEvent();
1196 MouseEvent.constructor = UIEvent;
1197 /*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) {
1198 this.initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg);
1199 this.screenX = screenXArg;
1200 this.screenY = screenYArg;
1201 this.clientX = clientXArg;
1202 this.clientY = clientYArg;
1203 this.ctrlKey = ctrlKeyArg;
1204 this.shiftKey = shiftKeyArg;
1205 this.altKey = altKeyArg;
1206 this.metaKey = metaKeyArg;
1207 this.button = buttonArg;
1208 this.relatedTarget = relatedTargetArg;
1211 function MutationEvent(){
1214 MutationEvent.prototype = new Event();
1215 MutationEvent.constructor = Event;
1217 /*void*/ this.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg,
1218 /*boolean*/ cancelableArg, /*Node*/ relatedNodeArg, /*string*/ prevValueArg, /*string*/ newValueArg,
1219 /*string*/ attrNameArg, /*unsigned short*/ attrChangeArg) {
1220 this.initEvent(typeArg, canBubbleArg, cancelableArg);
1221 this.relatedNode = relatedNodeArg;
1222 this.prevValue = prevValueArg;
1223 this.newValue = newValueArg;
1224 this.attrName = attrNameArg;
1225 this.attrChange = attrChangeArg;
1226 typeArg = canBubbleArg = cancelableArg = relatedNodeArg = prevValueArg = newValueArg = attrNameArg = attrChangeArg = void 0;
1228 /*Node*/ this.relatedNode = null;
1229 /*string*/ this.prevValue = this.newValue = this.attrName = null;
1230 /*unsigned short*/ this.attrChange = 2;
1231 }).apply(MutationEvent.prototype);
1233 /*unsigned short*/ MutationEvent.MODIFICATION = 1;
1234 /*unsigned short*/ MutationEvent.ADDITION = 2;
1235 /*unsigned short*/ MutationEvent.REMOVAL = 3;
1237 /*MutationEventsの発動のために、setAttributeNodeNSを上書きする。ファイル統合やmakeの際は、
1238 *重複するのでコアモジュールのメソッドは削除する。モジュールテストを行うために、
1239 *このような形式をとることにする。なお、追加部分には区別を付けるために、前後にコメントを挿入する。
1241 /*Attr*/ Element.prototype.setAttributeNodeNS = function( /*Attr*/ newAttr){
1242 if (newAttr.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1243 throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1245 var s = this.attributes.setNamedItemNS(newAttr);
1246 newAttr.ownerElement = this;
1247 if (newAttr.localName === "id") { //id属性であったならば
1248 this.ownerDocument._id[newAttr.nodeValue] = this; //ドキュメントに登録しておく
1251 var evt = this.ownerDocument.createEvent("MutationEvents");
1252 if (!s) { //ノードがなければ
1253 /*initMutationEventメソッドは軽量化のため省略する*/
1254 evt.initEvent("DOMAttrModified", true, false);
1255 evt.relatedNode = newAttr;
1256 evt.newValue = newAttr.nodeValue;
1257 evt.attrName = newAttr.nodeName;
1259 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, s.nodeValue, newAttr.nodeValue, newAttr.nodeName, MutationEvent.MODIFICATION);
1261 this.dispatchEvent(evt); //このとき、MutationEventsが発動
1267 /*Node*/ Node.prototype.insertBefore = function( /*Node*/ n, ref) {
1268 var tp = this.parentNode,
1273 while (!tp) { //先祖をたどっていく
1274 if (tp === n) { //先祖要素が追加ノードならばエラー
1275 throw (new DOMException(DOMException.HIERARCHY_REQUEST_ERR));
1280 if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
1281 throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
1283 if (n.parentNode === this) { //入力した要素が子要素ならば
1284 this.removeChild(n);
1286 if (!ref) { //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
1287 this.childNodes[this.childNodes.length] = n;
1288 if (this.lastChild) {
1289 n.previousSibling = this.lastChild;
1290 this.lastChild.nextSibling = n;
1293 if (ref.parentNode !== this) { //参照ノードが子要素でない場合
1294 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1296 this.childNodes.splice(ref._num,1,n,ref); //Arrayのspliceを利用して、リストにnノードを追加
1297 rp = ref.previousSibling;
1301 ref.previousSibling = n;
1303 n.nextSibling = ref;
1304 this.firstChild = this.childNodes[0];
1305 this.lastChild = this.childNodes[this.childNodes.length-1];
1306 n.parentNode = this;
1307 if ((n.nodeType===/*Node.ENTITY_REFERENCE_NODE*/ 5) || (n.nodeType===/*Node.DOCUMENT_FRAGMENT_NODE*/ 11)) {
1308 /*実体参照や、文書フラグメントノードだけは子ノードを検索して、
1309 *それらを直接文書に埋め込む作業を以下で行う
1311 var ch = n.childNodes.concat([]); //Arrayのコピー
1312 for (var i=0,chli=ch.length;i<chli;i++) {
1313 this.insertBefore(ch[i], n);
1318 evt = this.ownerDocument.createEvent("MutationEvents");
1319 evt.initMutationEvent("DOMNodeInserted", true, false, this, null, null, null, null);
1320 n.dispatchEvent(evt);
1321 /*以下のDOMNodeInsertedIntoDocumentイベントは、間接的、あるいは直接ノードが
1322 *挿入されたときに発火する。間接的な挿入とは、サブツリーを作っておいて、それをいっぺんに挿入する場合など。
1323 *このイベントは浮上しないことに注意を要する
1329 if (s !== this.ownerDocument.documentElement) {
1333 evt = this.ownerDocument.createEvent("MutationEvents");
1334 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1335 n.dispatchEvent(evt);
1336 if (!n.hasChildNodes()) { //子ノードがないので終了
1339 descend = n.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1341 for (var i=0,dli=descend.length;i<dli;++i) {
1343 di.dispatchEvent(evt);
1347 evt = descend = void 0;
1349 tp = rp = te = s = di = void 0;
1353 /*Node*/ Node.prototype.removeChild = function( /*Node*/ ele) {
1354 if (!(ele instanceof Node)) { //Nodeでなければ
1355 throw (new Error());
1358 var evt = this.ownerDocument.createEvent("MutationEvents");
1359 /*以下のDOMNodeRemovedFromDocumentイベントは、間接的、あるいは直接ノードが
1360 *除去されたときに発火する。間接的な除去とは、サブツリーをいっぺんに除去する場合など。
1361 *このイベントは浮上しないことに注意を要する
1363 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1364 ele.dispatchEvent(evt);
1365 var descend = ele.getElementsByTagNameNS("*", "*"); //全子孫要素を取得
1367 evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null);
1368 for (var i=0,dli=descend.length;i<dli;++i) {
1369 var di = descend[i];
1371 di.dispatchEvent(evt);
1375 evt.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null);
1376 ele.dispatchEvent(evt);
1377 evt = descend = void 0;
1379 if (ele.parentNode === this) {
1380 this.childNodes.splice(ele._num,1); //Arrayのspliceを利用して、リストからeleノードを排除
1382 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1384 if (ele.ownerDocument !== this.ownerDocument) { //所属ドキュメントが違う場合
1385 throw (new Error());
1390 /*void*/ CharacterData.prototype.appendData = function( /*string*/ arg) {
1394 this.length = this.data.length;
1396 evt = this.ownerDocument.createEvent("MutationEvents");
1397 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1398 this.parentNode.dispatchEvent(evt);
1399 evt = arg = pd = void 0;
1402 /*void*/ CharacterData.prototype.insertData = function( /*long*/ offset, /*string*/ arg) {
1404 pre = this.substring(0, offset - 1), //文字列を二つに分けた、前半部分
1405 next = this.substring(offset, this.length - offset), //後半部分
1407 this.data = pre + this.data + next;
1408 this.length = this.data.length;
1410 evt = this.ownerDocument.createEvent("MutationEvents");
1411 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1412 this.parentNode.dispatchEvent(evt);
1413 evt = arg = pd = pre = next = void 0;
1416 /*void*/ CharacterData.prototype.deleteData = function( /*long*/ offset, /*long*/ count) {
1418 pre = this.substring(0, offset - 1), //残すべき前半部分
1419 next = this.substring(offset + count, this.length - 1), //後半部分
1421 if (offset + count > this.length) { //offsetとcountの和が文字全体の長さを超える場合、offsetから最後までのを削除
1424 this.data = pre + next;
1425 this.length = this.data.length;
1427 evt = this.ownerDocument.createEvent("MutationEvents");
1428 evt.initMutationEvent("DOMCharacterDataModified", true, false, null, pd, this.data, null, null);
1429 this.parentNode.dispatchEvent(evt);
1434 /*_ceventプロパティはcreateEventメソッドで軽量化のために使う。*/
1435 Document.prototype._cevent = {
1436 "MutationEvents" : MutationEvent,
1437 "MouseEvents" : MouseEvent,
1438 "UIEvents" : UIEvent
1445 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.idl
1447 #ifndef _STYLESHEETS_IDL_
1448 #define _STYLESHEETS_IDL_
1452 #pragma prefix "dom.w3c.org"
1456 typedef dom::DOMString DOMString;
1457 typedef dom::Node Node;
1463 function StyleSheet() {
1464 this.type = "text/css";
1465 this.disabled = false;
1466 /*Node*/ this.ownerNode = null;
1467 /*StyleSheet*/ this.parentStyleSheet = null;
1470 /*MediaList*/ this.media = new MediaList();
1475 *このインターフェースはArrayで代用する
1476 function StyleSheetList() {
1477 readonly attribute unsigned long length;
1478 StyleSheet item(in unsigned long index);
1482 function MediaList() {
1483 this.mediaText = "";
1487 MediaList.prototype = {
1488 /*string*/ item : function(/*long*/ index) {
1489 return (this[index]);
1491 /*void*/ deleteMedium : function(/*string*/ oldMedium) {
1492 for (var i=0,tli=this.length;i<tli;++i) {
1493 if (this[i] === oldMedium) {
1499 throw (new DOMException(DOMException.NOT_FOUND_ERR));
1501 /*void*/ appendMedium : function(/*string*/ newMedium) {
1502 this[this.length] = newMedium;
1507 function LinkStyle() {
1508 /*StyleSheet*/ this.sheet = new StyleSheet();
1512 function DocumentStyle() {
1513 /*StyleSheetList*/ this.styleSheets = [];
1517 #endif // _STYLESHEETS_IDL_
1520 // File: http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.idl
1526 #include "stylesheets.idl"
1527 #include "views.idl"
1529 #pragma prefix "dom.w3c.org"
1533 typedef dom::DOMString DOMString;
1534 typedef dom::Element Element;
1535 typedef dom::DOMImplementation DOMImplementation;
1538 interface CSSStyleSheet;
1539 interface CSSStyleDeclaration;
1547 function CSSRuleList {
1548 readonly attribute unsigned long length;
1549 CSSRule item(in unsigned long index);
1553 *CSSのルールを表現する。基底クラスなので削除不可。
1555 function CSSRule() {
1557 /*CSSStyleSheet*/ this.parentStyleSheet;
1558 /*CSSRule*/ this.parentRule = null;
1562 CSSRule.UNKNOWN_RULE = 0;
1563 CSSRule.STYLE_RULE = 1;
1564 CSSRule.CHARSET_RULE = 2;
1565 CSSRule.IMPORT_RULE = 3;
1566 CSSRule.MEDIA_RULE = 4;
1567 CSSRule.FONT_FACE_RULE = 5;
1568 CSSRule.PAGE_RULE = 6;
1570 function CSSStyleRule() {
1571 CSSRule.call(this, arguments);
1572 this.type = CSSRule.STYLE_RULE;
1573 this.selectorText = "";
1574 /*CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
1575 this.style.parentRule = null;
1578 CSSStyleRule.prototype = new CSSRule();
1579 CSSStyleRule.constructor = CSSRule;
1581 function CSSMediaRule() {
1582 CSSRule.call(this, arguments);
1583 this.type = CSSRule.MEDIA_RULE;
1584 /*stylesheets::MediaList*/ this.media = new MediaList();
1585 /*CSSRuleList*/ this.cssRules = [];
1588 CSSMediaRule.prototype = new CSSRule();
1589 CSSMediaRule.constructor = CSSRule;
1590 /*long*/ CSSMediaRule.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
1591 this.cssRules.splice(index,rule,1);
1592 this.media.appendMedium(rule);
1595 /*void*/ CSSMediaRule.prototype.deleteRule = function( /*long*/ index) {
1598 function CSSFontFaceRule() {
1599 CSSRule.call(this, arguments);
1600 this.type = CSSRule.FONT_FACE_RULE;
1601 /*CSSStyleDeclaration*/ this.style;
1604 CSSFontFaceRule.prototype = new CSSRule();
1605 CSSFontFaceRule.constructor = CSSRule;
1607 function CSSPageRule() {
1608 CSSRule.call(this, arguments);
1609 this.type = CSSRule.PAGE_RULE;
1610 this.selectorText = "";
1611 /*CSSStyleDeclaration*/ this.style;
1614 CSSPageRule.prototype = new CSSRule();
1615 CSSPageRule.constructor = CSSRule;
1617 function CSSImportRule() {
1618 CSSRule.call(this, arguments);
1619 this.type = CSSRule.IMPORT_RULE;
1621 /*stylesheets::MediaList*/ this.media = new MediaList();
1622 /*CSSStyleSheet*/ this.styleSheet = null;
1625 CSSImportRule.prototype = new CSSRule();
1626 CSSImportRule.constructor = CSSRule;
1628 function CSSCharsetRule() {
1629 CSSRule.call(this, arguments);
1630 this.type = CSSRule.CHARSET_RULE;
1634 CSSCharsetRule.prototype = new CSSRule();
1635 CSSCharsetRule.constructor = CSSRule;
1637 function CSSUnknownRule() {
1638 CSSRule.call(this, arguments);
1639 this.type = CSSRule.UNKNOWN_RULE;
1642 CSSUnknownRule.prototype = new CSSRule();
1643 CSSUnknownRule.constructor = CSSRule;
1645 /*CSSStyleDeclaration
1646 *CSSの宣言ブロックを表現。削除不可。
1648 function CSSStyleDeclaration() {
1649 this._list = []; //内部のリスト
1650 this._list._fontSize = this._list._opacity = null;
1653 CSSStyleDeclaration.prototype = {
1655 /*long*/ length : 0,
1656 /*CSSRule*/ parentRule : null,
1657 _urlreg : /url\(#([^)]+)/,
1658 /*getPropertyValueメソッド
1659 *CSSの値を返す。この値は継承ではなくて、明示的に表記されているもの
1661 /*string*/ getPropertyValue : function( /*string*/ propertyName) {
1662 var tg = this.getPropertyCSSValue(propertyName);
1664 var tc = tg.cssText;
1665 return (tc.slice(tc.indexOf(":")+1));
1670 /*getPropertyCSSValueメソッド
1671 *CSSValueオブジェクトを返す。このメソッドは判別に用いているので、削除不可。
1673 /*CSSValue*/ getPropertyCSSValue : function( /*string*/ propertyName) {
1674 var prop = propertyName,
1676 propertyName += ":";
1677 if (propertyName === ":") { //どんなデータ型でも、文字列に変換する機能をJavaScriptが持つことに注意
1680 for (var i=0,tl=this._list,tli=tl.length;i<tli;++i) {
1683 if (tc.indexOf(propertyName) > -1) { //プロパティ名に合致するCSSValueオブジェクトが見つかった場合
1684 ti._empercents = tl._fontSize;
1685 i = tl = tli = tc = prop = propertyName = void 0;
1689 i = tl = tli = prop = propertyName = void 0;
1692 /*removePropertyメソッド
1695 /*string*/ removeProperty : function( /*string*/ propertyName) {
1696 var tg = this.getPropertyCSSValue(propertyName);
1698 this._list.splice(tg._num,1); //Arrayのspliceを利用して、リストからCSSValueオブジェクトを排除
1702 /*getPropertyPriorityメソッド
1703 *importantなどのpriorityを取得する
1705 /*string*/ getPropertyPriority : function( /*string*/ propertyName) {
1706 var tg = this.getPropertyCSSValue(propertyName);
1708 return (tg._priority);
1728 *プロパティを宣言内で、明示的に設定。継承は無視する
1730 /*void*/ setProperty : function( /*string*/ propertyName, /*string*/ value, /*string*/ priority) {
1731 var cssText = propertyName,
1737 if (!!this[propertyName]) {
1738 tg = this.getPropertyCSSValue(propertyName);
1742 if (this._isFillStroke[propertyName]) {
1743 /*fill、strokeプロパティは別途、SVGPaintで処理(JavaScriptでは、型キャストを使えないため)
1744 *CSSPrimitiveValueオブジェクトとSVGPaintオブジェクトを最後に置き換える
1749 ti = new SVGPaint();
1751 paintType = /*SVGPaint.SVG_PAINTTYPE_UNKNOWN*/ 0;
1752 v1 = value.charAt(0);
1753 if (this._isRS[v1] || ti._keywords[value]) {
1754 paintType = /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1;
1756 } else if (value === "none") {
1757 paintType = /*SVGPaint.SVG_PAINTTYPE_NONE*/ 101;
1758 } else if (this._urlreg.test(value)) { //fill属性の値がurl(#id)ならば
1759 paintType = /*SVGPaint.SVG_PAINTTYPE_URI*/ 107;
1761 } else if (value === "currentColor") {
1762 paintType = /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102;
1764 ti.setPaint(paintType, uri, color, null);
1765 paintType = v1 = uri = color = void 0;
1766 } else if (this._isStop[propertyName]) {
1770 ti = new SVGColor();
1772 if (value === "currentColor") {
1773 ti.colorType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
1775 ti.colorType = /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1;
1777 ti.setRGBColor(value);
1782 ti = new CSSPrimitiveValue();
1785 ti._priority = priority;
1786 ti.cssText = cssText;
1788 //_numプロパティはremovePropertyメソッドで利用する
1789 ti._num = this._list.length;
1790 this._list[ti._num] = ti;
1791 this[propertyName] = 1;
1794 if (value === "inherit") {
1795 ti.cssValueType = CSSValue.CSS_INHERIT;
1796 } else if (propertyName === "opacity") {
1797 this._list._opacity = +value;
1798 } else if (propertyName === "font-size") {
1799 if (/(%|em|ex)/.test(value)) {
1801 ti[tg] = parseFloat(value);
1803 this._em = this._ex = this["_%"] = null;
1804 this._list._fontSize = parseFloat(value);
1810 *リストの位置にあるプロパティ名を取得する。宣言内のすべてのプロパティ名を取得するのに便利
1812 /*string*/ item : function( /*long*/ index) {
1813 if (index >= this.length) { //indexの位置にCSSValueが指定されていないとき
1816 var s = this._list[index].cssText.substring(0, this._list[index].cssText.indexOf(":"));
1822 function CSSValue() {
1826 CSSValue.CSS_INHERIT = 0;
1827 CSSValue.CSS_PRIMITIVE_VALUE = 1;
1828 CSSValue.CSS_VALUE_LIST = 2;
1829 CSSValue.CSS_CUSTOM = 3;
1830 CSSValue.prototype = {
1832 cssValueType : CSSValue.CSS_CUSTOM,
1833 _isDefault : 0 //デフォルトであるかどうか(独自のプロパティ)
1836 function CSSPrimitiveValue() {
1843 t.CSS_PERCENTAGE = 2;
1859 t.CSS_DIMENSION = 18;
1866 t.CSS_RGBCOLOR = 25;
1867 t.prototype = new CSSValue();
1868 t.constructor = CSSValue;
1869 })(CSSPrimitiveValue);
1872 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に統一)
1873 this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
1874 this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
1876 this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
1877 this._empercent = 0;
1878 this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う
1879 /*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
1880 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1881 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1883 this.primitiveType = unitType;
1884 this._value = floatValue * this._n[unitType-1]; //値はあらかじめ、利用しやすいように変換しておく
1889 this._regd = /[\d\.]+/;
1890 /*float*/ this.getFloatValue = function(/*short*/ unitType) {
1891 if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
1892 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1894 if (this._value || (this._value === 0)) { //すでに、setFloatValueメソッドによって_valueプロパティが設定されていた場合
1895 return (this._value / this._n[unitType-1]);
1897 var tc = this.cssText,
1900 s = +(tc.match(this._regd));
1901 s = isNaN(s) ? 0 : s;
1902 if (n >= "0" && n <= "9") {
1903 type = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
1904 if (unitType === 1) {
1905 unitType = tc = n = type = void 0;
1908 } else if (n === "%") {
1910 type = /*CSSPrimitiveValue.CSS_PERCENTAGE*/ 2;
1911 } else if ((n === "m") && (tc.charAt(tc.length-2) === "e")) {
1912 s *= this._empercent;
1913 type = /*CSSPrimitiveValue.CSS_EMS*/ 3;
1914 } else if ((n === "x") && (tc.charAt(tc.length-2) === "e")) {
1915 type = /*CSSPrimitiveValue.CSS_EXS*/ 4;
1916 } else if ((n === "x") && (tc.charAt(tc.length-2) === "p")) {
1917 type = /*CSSPrimitiveValue.CSS_PX*/ 5;
1918 } else if ((n === "m") && (tc.charAt(tc.length-2) === "c")) {
1919 type = /*CSSPrimitiveValue.CSS_CM*/ 6;
1920 } else if ((n === "m") && (tc.charAt(tc.length-2) === "m")) {
1921 type = /*CSSPrimitiveValue.CSS_MM*/ 7;
1922 } else if (n === "n") {
1923 type = /*CSSPrimitiveValue.CSS_IN*/ 8;
1924 } else if (n === "t") {
1925 type = /*CSSPrimitiveValue.CSS_PT*/ 9;
1926 } else if (n === "c") {
1927 type = /*CSSPrimitiveValue.CSS_PC*/ 10;
1929 s = s * this._n[type-1] / this._n[unitType-1];
1930 tc = n = type = unitType = void 0;
1934 /*void*/ this.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
1935 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1936 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1938 this._value = stringValue;
1940 /*string*/ this.getStringValue = function(/*short*/ stringType) {
1941 if (CSSPrimitiveValue.CSS_DIMENSION >= stringType && stringType >= CSSPrimitiveValue.CSS_COUNTER) { //文字列型をサポートしないCSS単位である場合
1942 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1944 return (this._value);
1946 /*Counter*/ this.getCounterValue = function() {
1947 if (this.primitiveType !== CSSPrimitiveValue.CSS_COUNTER) { //Counter型ではないとき
1948 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1950 return (new Counter());
1952 /*Rect*/ this.getRectValue = function() {
1953 if (this.primitiveType !== CSSPrimitiveValue.CSS_RECT) { //Rect型ではないとき
1954 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1956 return (new Rect());
1958 /*RGBColor*/ this.getRGBColorValue = function() {
1959 if (this.primitiveType !== CSSPrimitiveValue.CSS_RGBCOLOR) { //RGBColor型ではないとき
1960 throw new DOMException(DOMException.INVALID_ACCESS_ERR);
1962 var s = new RGBColor();
1963 var rgbColor = this.cssText;
1964 var tkr = SVGColor.prototype._keywords[rgbColor];
1965 if (tkr !== void 0) {
1968 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
1969 rgbColor = rgbColor.replace(/[\d.]+%/g, function(t) {
1970 return Math.round((2.55 * parseFloat(t)));
1972 } else if (rgbColor.indexOf("#") > -1) { //#を含む場合
1973 rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
1974 return parseInt(s, 16);
1977 var n = rgbColor.match(/\d+/g);
1978 s.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[0]));
1979 s.green.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[1]));
1980 s.blue.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(n[2]));
1981 n = rgbColor = void 0;
1984 }).apply(CSSPrimitiveValue.prototype);
1988 function CSSValueList() {
1989 this.cssValueType = CSSValue.CSS_VALUE_LIST;
1993 CSSValueList.prototype = new CSSValue();
1994 CSSValueList.constructor = CSSValue;
1995 /*CSSValue*/ CSSValueList.prototype.item = function( /*long*/ index) {
1996 return (this[index]);
1999 function RGBColor() {
2000 var cs = CSSPrimitiveValue;
2001 this.red = new cs();
2002 this.green = new cs();
2003 this.blue = new cs();
2005 this.red.primitiveType = this.green.primitiveType = this.blue.primitiveType = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2010 var cs = CSSPrimitiveValue;
2011 this.top = new cs();
2012 this.right = new cs();
2013 this.bottom = new cs();
2014 this.left = new cs();
2019 function Counter() {
2020 this.identifier = this.listStyle = this.separator = "";
2024 function ElementCSSInlineStyle() {
2025 var cs = CSSStyleDeclaration;
2026 this.style = new cs();
2027 this._attributeStyle = new cs(); //プレゼンテーション属性の値を格納する
2043 visibility : "visible",
2044 display : "inline-block",
2048 strokeDasharray : n,
2049 strokeDashoffset : "0",
2050 strokeLinecap : "butt",
2051 strokeLinejoin : "miter",
2052 strokeMiterlimit : "4",
2053 strokeOpacity : "1",
2054 writingMode : "lr-tb",
2055 fontFamily : "serif",
2065 //# Gradient properties:
2067 stopColor : "black",
2069 textAnchor : "start",
2071 // raises(dom::DOMException) on setting
2072 //簡略プロパティに関しては、初期値を再考せよ
2077 overflow : "visible",
2084 verticalAlign : "baseline",
2092 //# Filter Effects properties:
2094 enableBackground : "accumulate",
2096 floodColor : "black",
2098 lightingColor : "white",
2100 //# Interactivity properties:
2102 pointerEvents : "visiblePainted",
2104 //# Color and Painting properties:
2106 colorInterpolation : "sRGB",
2107 colorInterpolationFilters : "linearRGB",
2118 //# Text properties:
2120 alignmentBaseline : "",
2121 baselineShift : "baseline",
2122 dominantBaseline : a,
2123 glyphOrientationHorizontal : "0deg",
2124 glyphOrientationVertical : a,
2126 fillRule : "nonzero"
2129 CSS2Properties.visibility._n = 1; //初期値の設定(_setPaintで使う)
2131 function CSSStyleSheet() {
2132 /*CSSRule*/ this.ownerRule = null;
2133 /*CSSRuleList*/ this.cssRules = [];
2136 CSSStyleSheet.prototype = new StyleSheet();
2137 CSSStyleSheet.constructor = StyleSheet;
2138 /*long*/ CSSStyleSheet.prototype.insertRule = function( /*string*/ rule, /*long*/ index) {
2139 var s = new CSSStyleRule(), style = s.style, a, sc = rule.match(/\{[\s\S]+\}/), m;
2140 s.parentStyleSheet = this;
2141 style.cssText = rule;
2143 sc = sc.replace(/^[^a-z\-]+/, "")
2144 .replace(/\:\s+/g, ":")
2145 .replace(/\s*;[^a-z\-]*/g, ";");
2147 for (var i=0, ali=a.length;i<ali;++i) {
2151 style.setProperty(m[0], m[1]);
2155 a = sc = style = void 0;
2156 this.cssRules.splice(index,s,1);
2158 /*void*/ CSSStyleSheet.prototype.deleteRule = function(/*long*/ index) {
2159 this.cssRules.splice(index, 1);
2163 /*getComputedStyle関数
2164 *最近の計算値を取得する。Document.defaultViewはSafariがグローバル(window)にサポートしていないため付ける。
2166 /*interface ViewCSS : views::AbstractView {*/
2167 Document.prototype.defaultView = new ViewCSS();
2171 /*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2172 var s = new CSSStyleDeclaration(),
2175 //クロージャを利用して、カスケーディングを実現する
2176 s.getPropertyCSSValue = (function(elt, td, s){
2177 return function( /*string*/ propertyName) {
2181 while (el && (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0))) {
2182 if (el._runtimeStyle && el._runtimeStyle[propertyName]) {
2183 css = el._runtimeStyle.getPropertyCSSValue(propertyName);
2184 } else if (el.style && el.style[propertyName]) {
2185 css = el.style.getPropertyCSSValue(propertyName);
2186 } else if (el._attributeStyle && el._attributeStyle[propertyName]) {
2188 css = el._attributeStyle.getPropertyCSSValue(propertyName);
2189 } else if (el._rules) {
2191 for (var i=0,eli=el._rules.length;i<eli;++i) {
2192 el._rules[i].style[propertyName] && (css = el._rules[i].style.getPropertyCSSValue(propertyName));
2197 if (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0)) {
2199 td && (css = td[propertyName]);
2201 if (css && css.setRGBColor && ((css.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) || (css.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3))) {
2202 css.setRGBColor(s.getPropertyValue("color"));
2203 } else if (css && (css._em || css._ex || css["_%"])) {
2207 if (el.style._list._fontSize) {
2208 n = el.style._list._fontSize;
2215 } else if (css._ex) {
2217 } else if (css["_%"]) {
2218 n *= css["_%"] / 100;
2220 css.cssText = "font-size:" +n+ "px";
2225 })(elt, this._defaultCSS, s); //_defaultCSSはデフォルト値の設定
2229 es = el.style._list._opacity || el._attributeStyle._list._opacity;
2234 s._list._opacity = eso;
2235 el = pelt = eso = es = void 0;
2236 s._document = elt.ownerDocument;
2240 /*getOverrideStyleメソッド
2241 *指定した要素の上書きスタイルシートを取得。
2243 /*function DocumentCSS : stylesheets::DocumentStyle {*/
2244 /*CSSStyleDeclaration*/ Document.prototype.getOverrideStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
2246 if (!!tar._runtimeStyle) {
2247 return (tar._runtimeStyle);
2249 var s = new CSSStyleDeclaration(), setProp = s.setProperty;
2250 tar._runtimeStyle = s;
2252 s.setProperty = (function(setProp, s){
2253 return function(propertyName, value, priority) {
2254 setProp.call(s, propertyName, value, priority);
2255 var tar = elt, el = tar._tar, isFill = isStroke = false;
2256 if ((tar.localName === "g") || (tar.localName === "a")) {
2257 var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
2259 for (var i=0,sli=sl.length;i<sli;++i) {
2261 NAIBU._setPaint(di, di.getScreenCTM());
2271 NAIBU._setPaint(tar, tar.getScreenCTM());
2272 el = tar = value = void 0;
2277 /*createCSSStyleSheetメソッド
2280 /*interface DOMImplementationCSS : DOMImplementation {*/
2281 /*CSSStyleSheet*/ DOMImplementation.createCSSStyleSheet = function( /*string*/ title, /*string*/ media) {
2282 var s = new CSSStyleSheet();
2284 var nm = new MediaList();
2285 nm.mediaText = media;
2286 if (media && (media !== "")) {
2287 var mes = media.split(","); //文字列をコンマで区切って配列に
2288 for (var i=0,mli=mes.length;i<mli;++i) {
2289 nm.appendMedium(mes[i]); //メディアリストに値を加えていく
2305 #pragma prefix "dom.w3c.org"
2308 typedef dom::DOMString DOMString;
2310 /*ElementTimeControlはSVGAnimationElementに統合させる。
2313 function ElementTimeControl(ele) {
2315 /*_beginと_endプロパティはミリ秒数を収納する。リピート時に書き換えられることがある。
2316 *_beginはアニメ開始時の秒数。_endはアニメ終了時の秒数。
2317 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
2323 ElementTimeControl.prototype = {
2324 /*void*/ beginElement : function() {
2325 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2326 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
2327 this.dispatchEvent(evt);
2329 /*void*/ endElement : function() {
2330 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
2331 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
2332 this.dispatchEvent(evt);
2334 /*void*/ beginElementAt : function(/*float*/ offset) {
2335 var ntc = this.ownerDocument.documentElement.getCurrentTime();
2336 this._begin = offset + ntc;
2338 /*void*/ endElementAt : function(/*float*/ offset) {
2339 var ntc = this.ownerDocument.documentElement.getCurrentTime();
2340 this._end = offset + ntc;
2344 function TimeEvent() {
2346 /*readonly attribute views::AbstractView*/ this.view;
2347 /*readonly attribute long*/ this.detail;
2350 TimeEvent.counstructor = Event;
2351 TimeEvent.prototype = new Event();
2352 /*void*/ TimeEvent.prototype.initTimeEvent = function(/*DOMString*/ typeArg,
2353 /*views::AbstractView*/ viewArg,
2354 /*long*/ detailArg) {
2355 this.type = typeArg;
2356 this.view = viewArg;
2357 this.detail = detailArg;
2359 //#endif // _SMIL_IDL_
2369 // For access to DOM2 core
2371 // For access to DOM2 events
2372 #include "events.idl"
2373 // For access to those parts from DOM2 CSS OM used by SVG DOM.
2375 // For access to those parts from DOM2 Views OM used by SVG DOM.
2376 #include "views.idl"
2377 // For access to the SMIL OM used by SVG DOM.
2379 #pragma prefix "dom.w3c.org"
2380 #pragma javaPackage "org.w3c.dom"
2383 typedef dom::DOMString DOMString;
2384 typedef dom::DOMException DOMException;
2385 typedef dom::Element Element;
2386 typedef dom::Document Document;
2387 typedef dom::NodeList NodeList;
2389 interface SVGElement;
2390 interface SVGLangSpace;
2391 interface SVGExternalResourcesRequired;
2393 interface SVGFitToViewBox;
2394 interface SVGZoomAndPan;
2395 interface SVGViewSpec;
2396 interface SVGURIReference;
2398 interface SVGMatrix;
2399 interface SVGPreserveAspectRatio;
2400 interface SVGAnimatedPreserveAspectRatio;
2401 interface SVGTransformList;
2402 interface SVGAnimatedTransformList;
2403 interface SVGTransform;
2404 interface SVGICCColor;
2407 interface SVGTransformable;
2408 interface SVGDocument;
2409 interface SVGSVGElement;
2410 interface SVGElementInstance;
2411 interface SVGElementInstanceList;
2413 function SVGException(code) {
2414 /*unsigned short*/ this.code = code;
2415 if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
2416 this.message = "SVG Wrong Type Error";
2417 } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
2418 this.message = "SVG Invalid Value Error";
2419 } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
2420 this.message = "SVG Matrix Not Invertable";
2424 SVGException.constructor = Error;
2425 SVGException.prototype = new Error();
2427 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR = 0;
2428 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR = 1;
2429 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE = 2;
2432 *すべてのSVG関連要素の雛形となるオブジェクト
2434 function SVGElement() {
2436 SVGStylable.call(this); //ElementCSSInlineStyleのインタフェースを継承
2437 /*interface SVGTransformable : SVGLocatable
2438 *TransformListはtransform属性を行列で表現したあとのリスト構造
2440 /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
2441 //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
2442 this.addEventListener("DOMAttrModified", function(evt){
2443 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2446 var name = evt.attrName,
2448 if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
2449 tar._attributeStyle.setProperty(name, evt.newValue, "");
2451 if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
2452 tar.id = evt.newValue;
2453 } else if ((name === "transform") && !!tar.transform) {
2454 var tft = evt.newValue,
2456 coma = tft.match(tar._comaReg), //コマンド文字にマッチ translate
2457 list = tft.match(tar._strReg), //カッコ内のリストにマッチ (10 20 30...)
2467 etod = evt.target.ownerDocument.documentElement,
2468 ttb = tar.transform.baseVal;
2469 //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
2470 for (var j=0,cli=coma.length;j<cli;j++) {
2471 s = etod.createSVGTransform();
2474 deg = lis.match(degR);
2487 s.setRotate(degz, +(deg[1]), +(deg[2]))
2488 } else if (degli <= 2) {
2490 if (com === "translate") {
2491 s.setTranslate(degz, +(deg[1] || 0));
2492 } else if (com === "scale") {
2493 s.setScale(degz, +(deg[1] || deg[0]));
2494 } else if (com === "rotate") {
2495 s.setRotate(degz, 0, 0);
2496 } else if (com === "skewX") {
2498 } else if (com === "skewY") {
2505 tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
2506 } else if (name === "style") {
2507 var sc = evt.newValue,
2515 sc = sc.replace(tar._shouReg, "")
2516 .replace(tar._conReg, ":")
2517 .replace(tar._bouReg, ";");
2519 for (var i=0, ali=a.length;i<ali;++i) {
2523 style.setProperty(m[0], m[1]);
2528 a = sc = style = void 0;
2529 } else if (name === "class") {
2530 tar.className = evt.newValue;
2531 } else if (name.indexOf("on") === 0) { //event属性ならば
2532 /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
2533 *ところが、IEでは、undefinedの値を返してしまう。
2534 *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
2536 eval("document._s = (function(evt){" +evt.newValue+ "})");
2537 var v = name.slice(2);
2540 } else if (v === "unload") {
2542 } else if (v === "abort") {
2544 } else if (v === "error") {
2546 } else if (v === "resize") {
2548 } else if (v === "scroll") {
2550 } else if (v === "zoom") {
2552 } else if (v === "begin") {
2554 } else if (v === "end") {
2556 } else if (v === "repeat") {
2559 tar.addEventListener(v, document._s, false);
2560 } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
2561 tar.xmlbase = evt.newValue;
2562 } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
2563 var tea = tar[name],
2564 tod = tar.ownerDocument.documentElement,
2565 tvw = tod.viewport.width,
2566 tvh = tod.viewport.height,
2568 n = evt.newValue.slice(-2),
2570 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
2571 _parseFloat = parseFloat;
2572 if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
2573 } else if (m === "%") {
2574 if (tar._x1width[name]) {
2575 tea.baseVal._percent = tvw * 0.01;
2576 } else if (tar._y1height[name]) {
2577 tea.baseVal._percent = tvh * 0.01;
2579 tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
2581 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
2582 } else if (n === "em") {
2583 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
2584 } else if (n === "ex") {
2585 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
2586 } else if (n === "px") {
2587 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
2588 } else if (n === "cm") {
2589 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
2590 } else if (n === "mm") {
2591 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
2592 } else if (n === "in") {
2593 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
2594 } else if (n === "pt") {
2595 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
2596 } else if (n === "pc") {
2597 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
2599 s = _parseFloat(evt.newValue);
2600 s = isNaN(s) ? 0 : s;
2601 tea.baseVal.newValueSpecifiedUnits(type, s);
2602 tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
2604 evt = _parseFloat = name = tar = null;
2608 SVGElement.constructor = Element;
2609 SVGElement.prototype = new Element();
2612 /*以下の正規表現は属性のパーサの際に用いる*/
2613 this._degReg = /[\-\d\.e]+/g;
2614 this._comaReg = /[A-Za-z]+(?=\s*\()/g;
2615 this._strReg = /\([^\)]+\)/g;
2616 this._syouReg = /^[^a-z\-]+/;
2617 this._conReg = /\:\s+/g;
2618 this._bouReg = /\s*;[^a-z\-]*/g;
2619 /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
2622 this._cacheMatrix = null;
2623 /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
2638 /*String*/ this.id = null; //id属性の値
2639 /*String*/ this.xmlbase = null; //xml:base属性の値
2640 /*SVGSVGElement*/ this.ownerSVGElement; //ルート要素であるsvg要素
2641 /*readonly SVGElement*/ this.viewportElement; //ビューポートを形成する要素(多くはsvg要素)
2642 /*readonly attribute SVGElement*/ this.nearestViewportElement = null;
2643 /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
2645 /*interface SVGLocatable*/
2646 /*SVGRect*/ this.getBBox = function(){
2647 var s = new SVGRect(),
2648 data = this._tar.path.value,
2649 vi = this.ownerDocument.documentElement.viewport,
2654 degis = data.match(/[0-9\-]+/g),
2657 /*要素の境界領域を求める(四隅の座標を求める)
2658 *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
2659 *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
2661 for (var i=0,degisli=degis.length;i<degisli;i+=2) {
2664 el = el > nx ? nx : el;
2665 et = et > ny ? ny : et;
2666 er = er > nx ? er : nx;
2667 eb = eb > ny ? eb : ny;
2673 nx = ny = data = degis =el = et = er = eb = vi = void 0;
2678 *CTMとは現在の利用座標系に対する変換行列
2679 *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
2680 *1.2ではgetCTMが言及されていない
2681 *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
2683 /*SVGMatrix*/ this.getCTM = function() {
2685 if (!!this._cacheMatrix) { //キャッシュがあれば
2686 s = this._cacheMatrix;
2688 m = this.transform.baseVal.consolidate();
2692 m = this.ownerDocument.documentElement.createSVGMatrix();
2694 if (this.parentNode && !!this.parentNode.getCTM) {
2695 s = this.parentNode.getCTM().multiply(m);
2700 this._cacheMatrix = s; //キャッシュをためて次回で使う
2705 /*SVGMatrix*/ this.getScreenCTM = function(){
2706 if (!this.parentNode) {
2709 var view = this.nearestViewportElement || this.ownerDocument.documentElement;
2710 var s = view.getScreenCTM().multiply(this.getCTM());
2715 /*getTransformToElementメソッド
2716 *これは、あるelementへの変換行列を計算して返す
2717 *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
2719 /*SVGMatrix*/ this.getTransformToElement = function(/*SVGElement*/ element ){
2720 var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
2723 }).apply(SVGElement.prototype);
2725 function SVGAnimatedBoolean() {
2726 /*boolean*/ this.animVal = this.baseVal = true;
2730 function SVGAnimatedString() {
2731 /*String*/ this.animVal = this.baseVal = "";
2735 function SVGStringList() {
2738 SVGStringList.prototype = new Array();
2740 /*readonly unsigned long*/ this.numberOfItems = 0;
2741 /*void*/ this.clear = function(){
2742 for (var i=0, tli=this.length;i<tli;++i) {
2745 this.numberOfItems = 0;
2747 /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
2750 this.numberOfItems = 1;
2753 /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
2754 if (index >= this.numberOfItems || index < 0) {
2755 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2757 return (this[index]);
2760 /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2761 if (index >= this.numberOfItems) {
2762 this.appendItem(newItem);
2764 this.splice(index, 1, newItem, this.getItem[index]);
2765 ++this.numberOfItems;
2769 /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
2770 if (index >= this.numberOfItems || index < 0) {
2771 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2773 this.splice(index, 1, newItem);
2777 //raises( DOMException, SVGException );
2778 /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
2779 if (index >= this.numberOfItems || index < 0) {
2780 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
2782 this.splice(index, 1);
2783 --this.numberOfItems;
2787 /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
2788 this[this.numberOfItems] = newItem;
2789 ++this.numberOfItems;
2791 }).apply(SVGStringList.prototype);
2793 function SVGAnimatedEnumeration() {
2794 /*unsigned short*/ this.baseVal = 0;
2795 // raises DOMException on setting
2796 /*readonly unsigned short*/ this.animVal = 0;
2799 function SVGAnimatedInteger() {
2800 /*long*/ this.baseVal = 0;
2801 // raises DOMException on setting
2802 /*readonly long*/ this.animVal = 0;
2805 function SVGNumber() {
2806 /*float*/ this.value = 0;
2807 // raises DOMException on setting
2810 function SVGAnimatedNumber() {
2811 /*float*/ this.baseVal = this.animVal = 0;
2815 function SVGNumberList() {
2818 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2819 SVGNumberList.prototype[prop] = SVGStringList.prototype[prop];
2821 function SVGAnimatedNumberList() {
2822 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
2826 *長さを設定する(単位pxに統一する方便として使う)
2827 *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
2829 function SVGLength() {
2833 // Length Unit Types
2834 /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN = 0;
2835 /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER = 1;
2836 /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
2837 /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS = 3;
2838 /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS = 4;
2839 /*const unsigned short*/ t.SVG_LENGTHTYPE_PX = 5;
2840 /*const unsigned short*/ t.SVG_LENGTHTYPE_CM = 6;
2841 /*const unsigned short*/ t.SVG_LENGTHTYPE_MM = 7;
2842 /*const unsigned short*/ t.SVG_LENGTHTYPE_IN = 8;
2843 /*const unsigned short*/ t.SVG_LENGTHTYPE_PT = 9;
2844 /*const unsigned short*/ t.SVG_LENGTHTYPE_PC = 10;
2847 SVGLength.prototype = {
2848 /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
2849 /*attribute float*/ value : 0, //利用単位における値
2850 /*attribute float*/ valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN, //unitTypeにおける値
2851 /*attribute DOMString*/ valueAsString : "0",
2852 _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
2853 _fontSize : 12, //単位のemとexで使われるfont-sizeの値
2854 /*newValueSpedifiedUnitsメソッド
2855 *新しくunitTypeにおける値を設定する
2856 *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
2858 newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
2860 _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
2861 if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
2862 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
2864 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
2867 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
2870 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
2871 n = this._fontSize * 0.5;
2873 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
2876 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
2879 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
2882 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
2885 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
2889 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2891 this.unitType = unitType;
2892 this.value = valueInSpecifiedUnits * n;
2893 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2894 this.valueAsString = valueInSpecifiedUnits + _s;
2895 valueInSpecifiedUnits = unitType = n = _s = void 0;
2897 /*convertToSpecifiedUnitsメソッド
2898 *valueプロパティを書き換えずに、単位だけを変換する
2900 * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
2901 * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
2902 * alert(x.valueAsString); //20mm
2904 convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
2905 if (this.value === 0) {
2906 this.newValueSpecifiedUnits(unitType, 0);
2910 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2911 v = v / this.value * this.valueInSpecifiedUnits;
2912 this.newValueSpecifiedUnits(unitType, v);
2915 *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
2916 *単位が%の場合は、新しいvalueへと変換させておく
2918 _emToUnit : function (/*float*/ fontSize) {
2919 if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
2920 this._fontSize = fontSize;
2921 this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
2925 function SVGAnimatedLength() {
2926 /*readonly SVGLength*/ this.animVal;
2927 this.baseVal = new SVGLength();
2928 this.baseVal.unitType = 1;
2931 function SVGLengthList() {
2934 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2935 SVGLengthList.prototype[prop] = SVGStringList.prototype[prop];
2937 function SVGAnimatedLengthList() {
2938 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
2941 function SVGAngle() {
2944 SVGAngle.prototype = {
2945 /*readonly attribute unsigned short*/ unitType : 0,
2946 /*attribute float*/ value : 0,
2947 // raises DOMException on setting
2948 /*attribute float*/ valueInSpecifiedUnits : 0,
2949 // raises DOMException on setting
2950 /*attribute DOMString*/ valueAsString : "0",
2951 // raises DOMException on setting
2952 /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
2954 _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
2955 if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
2956 } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
2958 } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
2961 } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
2965 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
2967 this.unitType = unitType;
2968 this.value = valueInSpecifiedUnits * n;
2969 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
2970 this.valueAsString = valueInSpecifiedUnits + _s;
2972 //raises( DOMException );
2974 /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
2975 if (this.value === 0) {
2976 this.newValueSpecifiedUnits(unitType, 0);
2980 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
2981 v = v / this.value * this.valueInSpecifiedUnits;
2982 this.newValueSpecifiedUnits(unitType, v);
2983 //raises( DOMException );
2987 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN = 0;
2988 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
2989 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG = 2;
2990 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD = 3;
2991 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD = 4;
2992 function SVGAnimatedAngle() {
2993 /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
2994 /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
2997 function SVGColor() {
2998 CSSValue.apply(this);
2999 /*readonly css::RGBColor*/ this.rgbColor = new RGBColor();
3004 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN = 0;
3005 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR = 1;
3006 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
3007 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR = 3;
3008 SVGColor.prototype = new CSSValue(); //ノードのプロトタイプチェーンを作って、継承
3009 SVGColor.constructor = CSSValue;
3012 /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
3013 /*readonly SVGICCColor*/ this.iccColor = null;
3014 this._regD = /\d+/g;
3015 this._regDP = /[\d.]+%/g;
3016 /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
3021 if (!rgbColor || (typeof rgbColor !== "string")) {
3022 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3024 rgbColor = this._keywords[rgbColor] || rgbColor;
3025 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
3026 rgbColor = rgbColor.replace(this._regDP, function(s) {
3027 return Math.round((2.55 * parseFloat(s)));
3029 s = rgbColor.match(this._regD);
3030 } else if (rgbColor.indexOf("#") === 0) { //#を含む場合
3032 _parseInt = parseInt;
3033 r = rgbColor.charAt(1);
3034 g = rgbColor.charAt(2);
3035 b = rgbColor.charAt(3)
3036 if (rgbColor.length < 5) {
3037 c = "#" + r + r + g + g + b + b;
3041 s[0] = _parseInt(r+rgbColor.charAt(2), 16)+ "";
3042 s[1] = _parseInt(rgbColor.charAt(3)+rgbColor.charAt(4), 16)+ "";
3043 s[2] = _parseInt(rgbColor.charAt(5)+rgbColor.charAt(6), 16)+ "";
3046 s = rgbColor.match(this._regD);
3047 if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
3049 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3052 this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
3053 this.rgbColor.green.setFloatValue(1, s[1]);
3054 this.rgbColor.blue.setFloatValue(1, s[2]);
3055 rgbColor = s = _parseInt = void 0;
3058 // raises( SVGException );
3059 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
3060 this.colorType = colorType;
3061 if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
3062 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3063 } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
3064 this.setRGBColor(rgbColor);
3065 } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
3066 this.setRGBColor(rgbColor);
3067 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
3068 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3069 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
3070 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
3072 colorType = rgbColor = void 0;
3074 // raises( SVGException );
3077 aliceblue: "rgb(240,248,255)",
3078 antiquewhite: "rgb(250,235,215)",
3079 aqua: "rgb(0,255,255)",
3080 aquamarine: "rgb(127,255,212)",
3081 azure: "rgb(240,255,255)",
3082 beige: "rgb(245,245,220)",
3083 bisque: "rgb(255,228,196)",
3084 black: "rgb(0,0,0)",
3085 blanchedalmond:"rgb(255,235,205)",
3086 blue: "rgb(0,0,255)",
3087 blueviolet: "rgb(138,43,226)",
3088 brown: "rgb(165,42,42)",
3089 burlywood: "rgb(222,184,135)",
3090 cadetblue: "rgb(95,158,160)",
3091 chartreuse: "rgb(127,255,0)",
3092 chocolate: "rgb(210,105,30)",
3093 coral: "rgb(255,127,80)",
3094 cornflowerblue:"rgb(100,149,237)",
3095 cornsilk: "rgb(255,248,220)",
3096 crimson: "rgb(220,20,60)",
3097 cyan: "rgb(0,255,255)",
3098 darkblue: "rgb(0,0,139)",
3099 darkcyan: "rgb(0,139,139)",
3100 darkgoldenrod:"rgb(184,134,11)",
3101 darkgray: "rgb(169,169,169)",
3102 darkgreen: "rgb(0,100,0)",
3103 darkgrey: "rgb(169,169,169)",
3104 darkkhaki: "rgb(189,183,107)",
3105 darkmagenta: "rgb(139,0,139)",
3106 darkolivegreen:"rgb(85,107,47)",
3107 darkorange: "rgb(255,140,0)",
3108 darkorchid: "rgb(153,50,204)",
3109 darkred: "rgb(139,0,0)",
3110 darksalmon: "rgb(233,150,122)",
3111 darkseagreen: "rgb(143,188,143)",
3112 darkslateblue:"rgb(72,61,139)",
3113 darkslategray:"rgb(47,79,79)",
3114 darkslategrey:"rgb(47,79,79)",
3115 darkturquoise:"rgb(0,206,209)",
3116 darkviolet: "rgb(148,0,211)",
3117 deeppink: "rgb(255,20,147)",
3118 deepskyblue: "rgb(0,191,255)",
3119 dimgray: "rgb(105,105,105)",
3120 dimgrey: "rgb(105,105,105)",
3121 dodgerblue: "rgb(30,144,255)",
3122 firebrick: "rgb(178,34,34)",
3123 floralwhite: "rgb(255,250,240)",
3124 forestgreen: "rgb(34,139,34)",
3125 fuchsia: "rgb(255,0,255)",
3126 gainsboro: "rgb(220,220,220)",
3127 ghostwhite: "rgb(248,248,255)",
3128 gold: "rgb(255,215,0)",
3129 goldenrod: "rgb(218,165,32)",
3130 gray: "rgb(128,128,128)",
3131 grey: "rgb(128,128,128)",
3132 green: "rgb(0,128,0)",
3133 greenyellow: "rgb(173,255,47)",
3134 honeydew: "rgb(240,255,240)",
3135 hotpink: "rgb(255,105,180)",
3136 indianred: "rgb(205,92,92)",
3137 indigo: "rgb(75,0,130)",
3138 ivory: "rgb(255,255,240)",
3139 khaki: "rgb(240,230,140)",
3140 lavender: "rgb(230,230,250)",
3141 lavenderblush:"rgb(255,240,245)",
3142 lawngreen: "rgb(124,252,0)",
3143 lemonchiffon: "rgb(255,250,205)",
3144 lightblue: "rgb(173,216,230)",
3145 lightcoral: "rgb(240,128,128)",
3146 lightcyan: "rgb(224,255,255)",
3147 lightgoldenrodyellow:"rgb(250,250,210)",
3148 lightgray: "rgb(211,211,211)",
3149 lightgreen: "rgb(144,238,144)",
3150 lightgrey: "rgb(211,211,211)",
3151 lightpink: "rgb(255,182,193)",
3152 lightsalmon: "rgb(255,160,122)",
3153 lightseagree: "rgb(32,178,170)",
3154 lightskyblue: "rgb(135,206,250)",
3155 lightslategray:"rgb(119,136,153)",
3156 lightslategrey:"rgb(119,136,153)",
3157 lightsteelblue:"rgb(176,196,222)",
3158 lightyellow: "rgb(255,255,224)",
3159 lime: "rgb(0,255,0)",
3160 limegreen: "rgb(50,205,50)",
3161 linen: "rgb(250,240,230)",
3162 magenta: "rgb(255,0,255)",
3163 maroon: "rgb(128,0,0)",
3164 mediumaquamarine:"rgb(102,205,170)",
3165 mediumblue: "rgb(0,0,205)",
3166 mediumorchid: "rgb(186,85,211)",
3167 mediumpurple: "rgb(147,112,219)",
3168 mediumseagreen:"rgb(60,179,113)",
3169 mediumslateblue:"rgb(123,104,238)",
3170 mediumspringgreen:"rgb(0,250,154)",
3171 mediumturquoise:"rgb(72,209,204)",
3172 mediumvioletred:"rgb(199,21,133)",
3173 midnightblue: "rgb(25,25,112)",
3174 mintcream: "rgb(245,255,250)",
3175 mistyrose: "rgb(255,228,225)",
3176 moccasin: "rgb(255,228,181)",
3177 navajowhite: "rgb(255,222,173)",
3178 navy: "rgb(0,0,128)",
3179 oldlace: "rgb(253,245,230)",
3180 olive: "rgb(128,128,0)",
3181 olivedrab: "rgb(107,142,35)",
3182 orange: "rgb(255,165,0)",
3183 orangered: "rgb(255,69,0)",
3184 orchid: "rgb(218,112,214)",
3185 palegoldenrod: "rgb(238,232,170)",
3186 palegreen: "rgb(152,251,152)",
3187 paleturquoise: "rgb(175,238,238)",
3188 palevioletred: "rgb(219,112,147)",
3189 papayawhip: "rgb(255,239,213)",
3190 peachpuff: "rgb(255,218,185)",
3191 peru: "rgb(205,133,63)",
3192 pink: "rgb(255,192,203)",
3193 plum: "rgb(221,160,221)",
3194 powderblue: "rgb(176,224,230)",
3195 purple: "rgb(128,0,128)",
3196 red: "rgb(255,0,0)",
3197 rosybrown: "rgb(188,143,143)",
3198 royalblue: "rgb(65,105,225)",
3199 saddlebrown: "rgb(139,69,19)",
3200 salmon: "rgb(250,128,114)",
3201 sandybrown: "rgb(244,164,96)",
3202 seagreen: "rgb(46,139,87)",
3203 seashell: "rgb(255,245,238)",
3204 sienna: "rgb(160,82,45)",
3205 silver: "rgb(192,192,192)",
3206 skyblue: "rgb(135,206,235)",
3207 slateblue: "rgb(106,90,205)",
3208 slategray: "rgb(112,128,144)",
3209 slategrey: "rgb(112,128,144)",
3210 snow: "rgb(255,250,250)",
3211 springgreen: "rgb(0,255,127)",
3212 steelblue: "rgb(70,130,180)",
3213 tan: "rgb(210,180,140)",
3214 teal: "rgb(0,128,128)",
3215 thistle: "rgb(216,191,216)",
3216 tomato: "rgb(255,99,71)",
3217 turquoise: "rgb(64,224,208)",
3218 violet: "rgb(238,130,238)",
3219 wheat: "rgb(245,222,179)",
3220 white: "rgb(255,255,255)",
3221 whitesmoke: "rgb(245,245,245)",
3222 yellow: "rgb(255,255,0)",
3223 yellowgreen: "rgb(154,205,50)"
3225 }).apply(SVGColor.prototype);
3227 function SVGRect() {
3228 /*float*/ this.x = 0;
3229 // raises DOMException on setting
3230 /*float*/ this.y = 0;
3231 // raises DOMException on setting
3232 /*float*/ this.width = 0;
3233 // raises DOMException on setting
3234 /*float*/ this.height = 0;
3235 // raises DOMException on setting
3239 function SVGAnimatedRect() {
3240 /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
3246 /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN : 0,
3247 /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE : 1,
3248 /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
3250 function SVGStylable() {
3251 /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
3252 /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
3253 this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
3254 //styleのcssTextプロパティを解析するリスナーを登録しておく
3256 /*getPresentationAttributeメソッド
3257 *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
3259 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
3260 var s = this._attributeStyle.getPropertyCSSValue(name);
3268 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
3269 *SIEでは、もっぱらXLink言語の処理を行う
3271 function SVGURIReference() {
3272 /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
3273 this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
3275 this.addEventListener("DOMAttrModified", function(evt){
3276 if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
3277 evt.target.href.baseVal = evt.newValue;
3278 /*_svgload_limitedを+1とすることで、
3279 *SVGLoadイベントは発火されなくなる。1を引く必要がある
3281 evt.target.ownerDocument.documentElement._svgload_limited++;
3285 this.addEventListener("DOMNodeInserted", function(evt){
3286 var tar = evt.target;
3287 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3290 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
3291 var tar = evt.target,
3293 href = tar.href.baseVal,
3294 show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
3295 /*xlink:href属性とxml:base属性を手がかりに、
3296 *ハイパーリンクのURIを決定する処理を行う
3298 if (href !== "") { //xlink:href属性が指定されたとき
3299 egbase = tar.xmlbase;
3301 ep = tar.parentNode;
3308 if (!b) { //xml:baseの指定がなければ
3309 if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
3311 base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
3313 base = location.href;
3319 if (href.indexOf(":") !== -1) { //絶対URIの場合
3323 show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
3324 if (href.indexOf(".") === 0) { //相対URIの場合
3327 if (show === "replace") {
3328 tar._tar.setAttribute("href", uri);
3329 } else if (show === "new") {
3330 tar._tar.setAttribute("target", "_blank");
3331 tar._tar.setAttribute("href", uri);
3332 } else if (show === "embed") {
3333 xmlhttp = NAIBU.xmlhttp;
3334 ui = uri.indexOf("#");
3336 id = uri.slice(ui+1);
3337 uri = uri.replace(/#.+$/, "");
3341 if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
3342 doc = tar.ownerDocument;
3343 ele = doc.getElementById(id);
3344 tar._instance = ele;
3345 ev = doc.createEvent("SVGEvents");
3346 ev.initEvent("S_Load", false, false);
3347 tar.dispatchEvent(ev);
3348 tar = xmlhttp = void 0;
3349 } else if (uri.indexOf("data:") > -1) {
3351 tar = xmlhttp = void 0;
3352 } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
3353 if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
3356 /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
3357 tar.ownerDocument.documentElement._svgload_limited++;
3358 xmlhttp.open("GET", uri, false);
3359 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
3360 xmlhttp.onreadystatechange = function() {
3361 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
3362 var type = xmlhttp.getResponseHeader('Content-Type') || "text",
3364 if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
3365 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
3366 *ここでは、responseTextを用いる
3368 /*script要素とstyle要素は、
3369 *_textプロパティに読み込んだテキストを格納しておく
3370 *それら以外は、_instanceプロパティにDOMツリーを格納しておく
3372 if (tar.localName !== "script" && tar.localName !== "style") {
3373 doc = new ActiveXObject("MSXML2.DomDocument");
3374 str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
3375 NAIBU.doc.async = false;
3376 NAIBU.doc.validateOnParse = false;
3377 NAIBU.doc.resolveExternals = false;
3378 NAIBU.doc.preserveWhiteSpace = false;
3380 ele = doc.documentElement;
3381 tar._instance = tar.ownerDocument.importNode(ele, true);
3383 tar._instance = tar._instance.ownerDocument.getElementById(id);
3386 tar._text = xmlhttp.responseText;
3388 } else if (!!tar._tar) {
3391 /*S_LoadイベントとはSIE独自のイベント。
3392 *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
3394 ev = tar.ownerDocument.createEvent("SVGEvents");
3395 ev.initEvent("S_Load", false, false);
3396 tar.dispatchEvent(ev);
3397 tar.ownerDocument.documentElement._svgload_limited--;
3398 /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
3399 if (tar.ownerDocument.documentElement._svgload_limited < 0) {
3400 ev = tar.ownerDocument.createEvent("SVGEvents");
3401 ev.initEvent("SVGLoad", false, false);
3402 tar.ownerDocument.documentElement.dispatchEvent(ev);
3404 tar = type = doc = str = ev = void 0;
3405 /*IEのメモリリーク対策として、空関数を入力*/
3406 xmlhttp.onreadystatechange = NAIBU.emptyFunction;
3414 tar.ownerDocument.documentElement._svgload_limited--;
3416 evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
3422 function SVGCSSRule() {
3423 CSSRule.apply(this, arguments);
3424 // Additional CSS RuleType to support ICC color specifications
3425 /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
3428 SVGCSSRule.constructor = CSSRule;
3429 SVGCSSRule.prototype = new CSSRule(); //ノードのプロトタイプチェーンを作って、継承
3434 function SVGDocument(){
3435 Document.apply(this);
3436 DocumentStyle.apply(this);
3437 /*readonly DOMString*/ this.title = "";
3438 /*readonly DOMString*/ this.referrer = document.referrer;
3439 /*readonly DOMString*/ this.domain = document.domain;
3440 /*readonly DOMString*/ this.URL = document.location;
3441 /*readonly SVGSVGElement*/ this.rootElement;
3444 SVGDocument.constructor = Document;
3445 SVGDocument.prototype = new Document(); //ノードのプロトタイプチェーンを作って、継承
3450 function SVGSVGElement(_doc) {
3451 SVGElement.apply(this, arguments);
3452 this._tar = _doc.createElement("v:group");
3454 /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
3455 * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
3456 this._svgload_limited = 0;
3460 SVGExternalResourcesRequired,
3465 events::EventTarget,
3466 events::DocumentEvent,
3468 css::DocumentCSS {*/
3469 /*以下のx,y,width,heightプロパティは
3470 *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
3471 *1000というのは、W3Cで触れていないため、独自の初期値を採用
3473 var slen = SVGAnimatedLength;
3474 /*readonly SVGAnimatedLength*/ this.x = new slen();
3475 /*readonly SVGAnimatedLength*/ this.y = new slen();
3476 /*readonly SVGAnimatedLength*/ this.width = new slen();
3477 /*readonly SVGAnimatedLength*/ this.height = new slen();
3479 /*DOMString*/ this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
3480 /*DOMString*/ this.contentStyleType = "text/css";
3481 /*readonly SVGRect*/ this.viewport = this.createSVGRect();
3482 /*useCurrentViewプロパティ
3483 * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
3485 /*boolean*/ this.useCurrentView = false;
3487 * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
3489 /*readonly SVGViewSpec*/ this.currentView = new SVGViewSpec(this);
3490 /*もし、画像をズームやパンしたとき、どのような倍率になるかを
3491 *以下のプロパティを使って次の行列で示すことができる
3492 *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]
3494 /*float*/ this.currentScale = 1;
3495 /*readonly SVGPoint*/ this.currentTranslate = this.createSVGPoint();
3496 /*以下は、SVGFitToViewBoxのインターフェースを用いる
3497 *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
3499 /*readonly SVGAnimatedRect*/ this.viewBox = this.currentView.viewBox;
3500 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
3501 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
3504 /*int*/ this._currentTime = 0;
3505 /*DOMAttrModifiedイベントを利用して、
3506 *随時、属性の値をDOMプロパティに変換しておくリスナー登録
3508 this.addEventListener("DOMAttrModified", function(evt){
3509 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3512 var tar = evt.target,
3513 name = evt.attrName,
3514 tv, ovb, par, tp, sa, mos;
3515 if (name === "viewBox") {
3516 tar._cacheScreenCTM = null;
3517 tv = tar.viewBox.baseVal;
3518 ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3519 tv.x = parseFloat(ovb[0]);
3520 tv.y = parseFloat(ovb[1]);
3521 tv.width = parseFloat(ovb[2]);
3522 tv.height = parseFloat(ovb[3]);
3523 tar.viewBox.baseVal._isUsed = 1;
3524 } else if (name === "preserveAspectRatio") {
3525 tar._cacheScreenCTM = null;
3527 tp = tar.preserveAspectRatio.baseVal;
3529 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
3530 if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
3531 switch (RegExp.$1) {
3542 switch (RegExp.$2) {
3552 if (RegExp.$3 === "slice") {
3553 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
3555 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
3559 tp.meetOrSlice = mos;
3560 } else if (name === "width") {
3562 tar.viewport.width = tar.width.baseVal.value;
3563 } else if (name === "height") {
3564 tar.viewport.height = tar.height.baseVal.value;
3566 evt = name = tv = ovb = par = tp = sa = mos = void 0;
3568 this.addEventListener("SVGLoad", function(evt){
3569 /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
3570 *処理を書いたもの。属性が書き換わるたびに、再描画される
3572 evt.target.addEventListener("DOMAttrModified", function(evt){
3575 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3577 if (tar.parentNode) {
3578 evtt = tar.ownerDocument.createEvent("MutationEvents");
3579 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3581 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3582 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3583 for (var j=0,tcli=tce.length;j<tcli;++j){
3585 tce[j].handleEvent(evtt);
3588 if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
3589 tar._cacheMatrix = void 0; //キャッシュを消去
3590 if (tar.firstChild) {
3591 slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
3592 for (var i=0,sli=slist.length;i<sli;++i) {
3594 tar._cacheMatrix = void 0;
3595 evtt = tar.ownerDocument.createEvent("MutationEvents");
3596 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
3598 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
3599 tce = tar._capter; //tceは登録しておいたリスナーのリスト
3600 for (var j=0,tcli=tce.length;j<tcli;++j){
3602 tce[j].handleEvent(evtt);
3610 evtt = tar = evt = tce = slist = void 0;
3616 SVGSVGElement.constructor = SVGElement;
3617 SVGSVGElement.prototype = new SVGElement();
3618 /*void*/ SVGSVGElement.prototype.forceRedraw = function() {
3620 /*float*/ SVGSVGElement.prototype.getCurrentTime = function(){
3621 return (this._currentTime);
3623 /*void*/ SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
3624 this._currentTime = seconds;
3626 /*SVGNumber*/ SVGSVGElement.prototype.createSVGNumber = function(){
3627 var s = new SVGNumber();
3631 /*SVGAngle*/ SVGSVGElement.prototype.createSVGAngle = function(){
3632 var s = new SVGAngle();
3637 /*SVGLength*/ SVGSVGElement.prototype.createSVGLength = function(){
3638 var s = new SVGLength();
3639 s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
3642 /*SVGPoint*/ SVGSVGElement.prototype.createSVGPoint = function(){
3643 return new SVGPoint();
3645 /*SVGMatrix*/ SVGSVGElement.prototype.createSVGMatrix = function(){
3647 return new SVGMatrix();
3649 /*SVGRect*/ SVGSVGElement.prototype.createSVGRect = function(){
3650 return new SVGRect();
3652 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransform = function(){
3653 var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
3656 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
3657 var s = new SVGTransform();
3658 s.setMatrix(matrix);
3662 *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
3664 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
3665 if (!!this._cacheScreenCTM) { //キャッシュがあれば
3666 return (this._cacheScreenCTM);
3668 var vw = this.viewport.width,
3669 vh = this.viewport.height,
3670 vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
3671 if (!this.useCurrentView) {
3672 vB = this.viewBox.baseVal;
3673 par = this.preserveAspectRatio.baseVal;
3675 vB = this.currentView.viewBox.baseVal;
3676 par = this.currentView.preserveAspectRatio.baseVal;
3678 if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
3679 this._tx = this._ty = 0;
3680 m = this.createSVGMatrix();
3681 this._cacheScreenCTM = m; //キャッシュを作っておく
3694 if (par.align === 1) { //none
3700 var ax = (par.align + 1) % 3 + 1;
3701 var ay = Math.round(par.align / 3);
3702 switch (par.meetOrSlice) {
3704 xr = yr = Math.min(rw, rh);
3707 xr = yr = Math.max(rw, rh);
3716 tx += (vw - vbw * xr) / 2;
3719 tx += vw - vbw * xr;
3726 ty += (vh - vbh * yr) / 2;
3729 ty += vh - vbh * yr;
3734 //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
3737 ttps = this._tar.style;
3738 ttps.marginLeft = tx+ "px";
3739 ttps.marginTop = ty+ "px";
3740 m = this.createSVGMatrix();
3743 this._cacheScreenCTM = m; //キャッシュを作っておく
3744 vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
3748 /*interface SVGZoomAndPan*/
3749 // Zoom and Pan Types
3751 /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
3752 /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
3753 /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
3756 function SVGFitToViewBox() {
3757 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
3758 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3761 function SVGViewSpec(ele) {
3762 SVGFitToViewBox.apply(this, arguments);
3763 /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
3764 /*readonly SVGElement*/ this.viewTarget = ele;
3765 /*readonly DOMString*/ this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
3768 SVGViewSpec.constructor = SVGFitToViewBox;
3769 SVGViewSpec.prototype = new SVGFitToViewBox();
3771 function SVGGElement(_doc) {
3772 SVGElement.apply(this);
3773 this._tar = _doc.createElement("v:group");
3775 /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
3776 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
3778 this.addEventListener("DOMNodeInserted", function(evt){
3779 var tar = evt.target;
3780 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3783 var tnext = tar.nextSibling,
3784 tpart = tar.parentNode._tar,
3786 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3787 tpart.insertBefore(tar._tar, tnext._tar);
3788 } else if (tnext && !tnext._tar && tpart) {
3789 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3790 *use要素や実体参照などは_tarプロパティがないことに注意
3793 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3794 tpart.insertBefore(tar._tar, tnext._tar);
3797 tnext = tnext.nextSibling;
3800 tpart.appendChild(tar._tar);
3802 } else if (!tnext && tpart) {
3803 tpart.appendChild(tar._tar);
3805 tnext = tpart = isLast = evt = tar = void 0;
3809 SVGGElement.constructor = SVGElement;
3810 SVGGElement.prototype = new SVGElement();
3812 function SVGDefsElement() {
3813 SVGElement.apply(this, arguments);
3814 this.style.setProperty("display", "none");
3817 SVGDefsElement.constructor = SVGElement;
3818 SVGDefsElement.prototype = new SVGElement();
3820 function SVGDescElement() {
3821 SVGElement.apply(this, arguments);
3824 SVGDescElement.constructor = SVGElement;
3825 SVGDescElement.prototype = new SVGElement();
3827 function SVGTitleElement() {
3828 SVGElement.apply(this, arguments);
3829 this.addEventListener("DOMCharacterDataModified", function(evt){
3830 evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
3834 SVGTitleElement.constructor = SVGElement;
3835 SVGTitleElement.prototype = new SVGElement();
3837 function SVGSymbolElement() {
3838 SVGElement.apply(this, arguments);
3839 SVGURIReference.apply(this);
3842 SVGDefsElement.constructor = SVGElement;
3843 SVGDefsElement.prototype = new SVGElement();
3845 function SVGUseElement() {
3846 SVGGElement.apply(this, arguments);
3847 var slen = SVGAnimatedLength;
3848 /*readonly SVGAnimatedLength*/ this.x = new slen(); //use要素のx属性に対応(以下、同様)
3849 /*readonly SVGAnimatedLength*/ this.y = new slen();
3850 /*readonly SVGAnimatedLength*/ this.width = new slen();
3851 /*readonly SVGAnimatedLength*/ this.height = new slen();
3853 /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
3854 /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
3855 this.addEventListener("DOMNodeInserted", function(evt){
3856 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3859 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3861 this.addEventListener("S_Load", function(evt){
3862 var tar = evt.target,
3863 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3864 fontSize = parseFloat(style.getPropertyValue("font-size")),
3865 tgtb = tar.transform.baseVal,
3866 trans = tar.ownerDocument.documentElement.createSVGTransform();
3867 tar.x.baseVal._emToUnit(fontSize);
3868 tar.y.baseVal._emToUnit(fontSize);
3869 tar.width.baseVal._emToUnit(fontSize);
3870 tar.height.baseVal._emToUnit(fontSize);
3871 tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tar._instance, true);
3872 trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
3873 tgtb.appendItem(trans);
3874 tar.appendChild(tar.instanceRoot);
3875 evt = trans = tar = evtt = tgtb = style = fontSize = void 0;
3877 SVGURIReference.apply(this);
3880 SVGUseElement.constructor = SVGElement;
3881 SVGUseElement.prototype = new SVGElement();
3883 function SVGElementInstance() {
3887 Node.apply(this, arguments);
3888 /*readonly SVGElement*/ this.correspondingElement; //use要素で使われる参照先の要素
3889 /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
3890 /*readonly SVGElementInstance*/ this.parentNode;
3891 /*readonly SVGElementInstanceList*/ this.childNodes;
3892 /*readonly SVGElementInstance*/ this.firstChild;
3893 /*readonly SVGElementInstance*/ this.lastChild;
3894 /*readonly SVGElementInstance*/ this.previousSibling;
3895 /*readonly SVGElementInstance*/ this.nextSibling;
3898 SVGElementInstance.prototype = new Node();
3899 /*SVGElementInstanceList
3901 function SVGElementInstanceList() {
3902 /*readonly unsigned long*/ this.length = 0;
3905 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
3906 return (this[index]);
3908 function SVGImageElement(_doc) {
3909 SVGElement.apply(this, arguments);
3910 this._tar = _doc.createElement("v:image");
3911 //以下は、与えられた属性の値に対応する
3912 var slen = SVGAnimatedLength;
3913 /*readonly SVGAnimatedLength*/ this.x = new slen();
3914 /*readonly SVGAnimatedLength*/ this.y = new slen();
3915 /*readonly SVGAnimatedLength*/ this.width = new slen();
3916 /*readonly SVGAnimatedLength*/ this.height = new slen();
3917 _doc = slen = void 0;
3918 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
3919 this.addEventListener("DOMNodeInserted", function(evt){
3920 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3923 var tar = evt.target;
3924 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
3925 if (tar.nextSibling) {
3926 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
3927 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
3929 } else if (!!tar.parentNode._tar){
3930 tar.parentNode._tar.appendChild(tar._tar);
3932 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3933 var tar = evt.target,
3934 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3935 fontSize = parseFloat(style.getPropertyValue("font-size")),
3936 ts = tar._tar.style,
3937 ctm = tar.getScreenCTM(),
3938 po = tar.ownerDocument.documentElement.createSVGPoint(),
3939 fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
3941 tar.x.baseVal._emToUnit(fontSize);
3942 tar.y.baseVal._emToUnit(fontSize);
3943 tar.width.baseVal._emToUnit(fontSize);
3944 tar.height.baseVal._emToUnit(fontSize);
3945 ts.position = "absolute";
3946 po.x = tar.x.baseVal.value;
3947 po.y = tar.y.baseVal.value;
3948 po = po.matrixTransform(ctm);
3949 ts.left = po.x + "px";
3950 ts.top = po.y + "px";
3951 ts.width = tar.width.baseVal.value * ctm.a + "px";
3952 ts.height = tar.height.baseVal.value * ctm.d + "px";
3953 if (fillOpacity !== 1) {
3954 ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
3955 ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
3957 ttfia.Opacity = fillOpacity * 100;
3960 evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
3964 SVGURIReference.apply(this);
3967 SVGImageElement.constructor = SVGElement;
3968 SVGImageElement.prototype = new SVGElement();
3970 function SVGSwitchElement() {
3971 SVGElement.apply(this, arguments);
3974 SVGSwitchElement.constructor = SVGElement;
3975 SVGSwitchElement.prototype = new SVGElement();
3977 //bookmarkletから呼び出されたらtrue
3979 function GetSVGDocument(ele) {
3985 if ((NAIBU._that.xmlhttp.readyState === 4) && (NAIBU._that.xmlhttp.status === 200)) {
3989 GetSVGDocument.prototype = {
3991 *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
3993 _init : function() {
3994 /*objeiはobject要素かembed要素*/
3995 var xmlhttp = NAIBU.xmlhttp,
3998 if (this._tar.nodeName === "OBJECT") {
4003 xmlhttp.open("GET", objei.getAttribute(data), true);
4004 objei.style.display = "none";
4005 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
4006 this.xmlhttp = xmlhttp;
4007 /*クロージャを利用しないことで、軽量化を計る*/
4009 xmlhttp.onreadystatechange = _ca_;
4011 xmlhttp = objei = data = void 0;
4015 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
4016 *ここでは、responseTextを用いる
4018 var ifr = this._tar.previousSibling,
4019 ifcw = ifr.contentWindow,
4022 ifr.contentWindow.screen.updateInterval = 999;
4023 _doc = ifr.contentWindow.document;
4025 _doc.close(); // これがないと document.body は null になる
4026 } else { //インラインSVGの場合
4029 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
4030 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
4031 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
4032 var st = _doc.createStyleSheet(),
4033 vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
4034 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
4035 + "dn\\:defs{display:none}"
4036 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
4037 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
4038 st = vmlUrl = void 0;
4040 DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
4041 var str = this.xmlhttp.responseText,
4043 s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
4044 tar = s.documentElement,
4045 tview = tar.viewport,
4046 objw, objh, fi, n, attr, att, w, h,
4048 sp = _doc.createElement("div"),
4049 dcp = _doc.createElement("v:group"),
4050 backr = _doc.createElement("v:rect"),
4051 style, fontSize, sw, sh, trstyle, tpstyle, backrs, viewWidth, viewHeight, backdown, backright,
4053 _parseFloat = parseFloat,
4054 ndoc = NAIBU.doc || this.xmlhttp.responseXML,
4055 oba = _doc.createElement("div"); //obaはradialGradient要素で使う
4056 if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
4057 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4060 s._iframe = ifr; //_iframeプロパティはSVGAElementでリンク置換のときに扱う
4061 oba.setAttribute("id","_NAIBU_outline");
4062 _doc.body.appendChild(oba);
4063 sp.style.margin = "-1px,0px,0px,-1px"
4065 _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
4068 /*下記のプロパティについては、Microsoftのサイトを参照
4069 *ResolveExternals Property [Second-level DOM]
4070 * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
4071 *ValidateOnParse Property [Second-level DOM]
4072 * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
4074 ndoc.validateOnParse = false;
4075 ndoc.resolveExternals = false;
4076 ndoc.preserveWhiteSpace = true;
4077 ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
4078 /*IE6-8のみで使えるupdateIntervalは、
4079 *描画間隔の調整が可能。デフォルトは0。
4080 *スクロール時にバグが起きるので、0に戻してやる必要がある。
4082 screen.updateInterval = 999;
4083 if (/&[^;]+;/.test(str)) {
4085 *代替の処理を用いて、実体参照を処理するもの
4088 var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
4089 for (var i=0; i<enti.length; i++) {
4090 var map = enti.item(i);
4091 var regex = new RegExp("&"+map.nodeName+";", "g");
4092 tmp = tmp.replace(regex, map.firstChild.xml);
4099 tview.width = objei.clientWidth;
4100 tview.height = objei.clientHeight;
4101 if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4102 tview.height = screen.availHeight;
4104 if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
4105 tar.viewport.height = screen.width;
4107 objw = objei.getAttribute("width");
4108 objh = objei.getAttribute("height");
4110 tar.setAttributeNS(null, "width", objw);
4113 tar.setAttributeNS(null, "height", objh);
4115 fi = ndoc.documentElement.firstChild;
4116 attr = ndoc.documentElement.attributes;
4117 /*ルート要素のNamedNodeMapを検索する*/
4118 for (var i=0,atli=attr.length;i<atli;++i) {
4119 att = s.importNode(attr[i], false);
4120 tar.setAttributeNodeNS(att);
4122 str = attr = void 0;
4123 dcp.style.width = tview.width+ "px";
4124 dcp.style.height = tview.height+ "px";
4125 dcp.coordsize = tview.width+ " " +tview.height;
4126 sp.appendChild(dcp);
4128 _doc.body.appendChild(sp);
4130 this._tar.parentNode.insertBefore(sp, this._tar);
4132 dcp.appendChild(sdt);
4133 while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
4134 n = s.importNode(fi, true);
4136 fi = fi.nextSibling;
4139 /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
4140 *ドキュメントにそのオブジェクトを結び付けておく
4143 /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
4146 style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
4147 fontSize = _parseFloat(style.getPropertyValue("font-size"));
4148 tar.x.baseVal._emToUnit(fontSize);
4149 tar.y.baseVal._emToUnit(fontSize);
4150 tar.width.baseVal._emToUnit(fontSize);
4151 tar.height.baseVal._emToUnit(fontSize);
4152 sw = tar.width.baseVal.value;
4153 sh = tar.height.baseVal.value;
4154 backr.style.position = "absolute";
4157 backr.style.width = w+ "px";
4158 backr.style.height = h+ "px";
4159 backr.style.zIndex = -1;
4160 backr.stroked = "false";
4161 backr.filled = "false";
4162 tar._tar.appendChild(backr);
4163 trstyle = tar._tar.style;
4164 tpstyle = objei.style;
4165 trstyle.visibility = "visible";
4166 trstyle.position = "absolute";
4168 trstyle.overflow = "hidden";
4170 viewWidth = w > sw ? sw : w;
4171 viewHeight = h > sh ? sh : h;
4172 backrs = backr.currentStyle;
4173 bfl = _parseFloat(backrs.left);
4174 bft = _parseFloat(backrs.top);
4175 bl = -tar._tx; //blやbtは、ずれを調整するのに使う
4177 if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
4179 dcp.style.left = -bl+ "px";
4181 if (bft !== 0 && !isNaN(bfl)) {
4183 dcp.style.top = -bt+ "px";
4185 backright = bl + viewWidth + 1;
4186 backdown = bt + viewHeight + 1;
4187 trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
4189 if ("_svgload_limited" in s.documentElement) {
4190 /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
4191 *xlink:href属性が指定されるたびに+1となる。
4192 *0以外は、SVGLoadイベントが発火されない仕組みとなっている
4195 * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
4197 s.documentElement._svgload_limited--;
4198 if (s.documentElement._svgload_limited < 0) {
4199 var evt = s.createEvent("SVGEvents");
4200 evt.initEvent("SVGLoad", false, false);
4201 s.documentElement.dispatchEvent(evt);
4205 text = s.documentElement._tar.getElementsByTagName("div");
4206 for (var i=0, texti;text[i];++i) {
4208 if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
4209 var tis = texti.style;
4210 tis.left = _parseFloat(tis.left) + bl + "px";
4211 tis.top = _parseFloat(tis.top) + bt + "px";
4215 //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
4216 ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
4217 s._isLoaded = 1; //_isLoadedプロパティはevents::dispatchEventメソッドで使う
4218 s.defaultView._cache = s.defaultView._cache_ele = null;
4219 oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
4220 trstyle = tpstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
4221 /*IEのメモリリーク対策として、空関数を入力*/
4222 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
4224 ifcw && (ifr.contentWindow.screen.updateInterval = 0);
4225 ifr = ifcw = s = void 0;
4229 if (s.implementation._buffer_) {
4230 screen.updateInterval = 0;
4231 /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
4232 NAIBU._buff_num = 0;
4233 NAIBU._buff = setInterval(function(){
4234 var n = NAIBU._buff_num,
4235 dbuf = DOMImplementation._buffer_,
4236 dbufli = dbuf.length,
4239 clearInterval(NAIBU._buff);
4241 for (var i=0;i<50;++i) {
4244 s.dispatchEvent(evt);
4248 clearInterval(NAIBU._buff);
4249 DOMImplementation._buffer_ = null;
4251 dbuf = n = dbufli = void 0;
4255 NAIBU._buff_num = n;
4257 dbuf = n = dbufli = void 0;
4259 ifr = ifcw = s = void 0;
4261 ifr = ifcw = s = void 0;
4267 /*SVGDocument*/ getSVGDocument : function() {
4268 return (this._document);
4271 /*空関数(IEのメモリリーク対策)*/
4272 NAIBU.emptyFunction = function() {};
4277 function SVGStyleElement(_doc) {
4278 SVGElement.apply(this);
4279 LinkStyle.apply(this);
4280 /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
4281 *CSS2 1. Document Object Model Style Sheets
4282 * 1.3. Document Extensions
4283 * Interface LinkStyle (introduced in DOM Level 2)
4284 * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
4286 /*以下はそれぞれ、属性の値に対応している*/
4287 /*DOMString*/ this.xmlspace;
4288 /*DOMString*/ this.type = "text/css";
4289 /*DOMString*/ this.media;
4290 /*DOMString*/ this.title;
4291 SVGURIReference.apply(this);
4292 this.addEventListener("DOMAttrModified", function(evt){
4293 if (evt.attrName === "type") {
4294 evt.target.type = evt.newValue;
4295 } else if (evt.attrName === "title") {
4296 evt.target.title = evt.newValue;
4300 this.addEventListener("S_Load", function(evt){
4301 var tar = evt.target,
4303 styleText = tar._text,
4304 tod = tar.ownerDocument,
4305 style = _doc.createElement("style"),
4307 NAIBU._temp_doc = tod;
4308 sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
4309 sheet.ownerNode = tar;
4310 /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
4311 _doc.documentElement.firstChild.appendChild(style);
4312 style.styleSheet.cssText = styleText;
4313 for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
4315 scri = new CSSStyleRule();
4316 scri.selectorText = ri.selectorText;
4317 scri.style.cssText = ri.style.cssText;
4318 rsc = scri.style.cssText.split(";");
4319 for (var j=0, rsli=rsc.length;j<rsli;++j) {
4320 rsi = rsc[j].split(": ");
4321 scri.style.setProperty(rsi[0], rsi[1]);
4323 sheet.cssRules[sheet.cssRules.length] = scri;
4325 tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4326 var tar = evt.target,
4327 doc = tar.ownerDocument,
4328 rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
4329 selector, ru, tcb = tar.className.baseVal || ".,.";
4330 for (var i=0, rli=rules.length;i<rli;++i) {
4331 selector = rules[i].selectorText;
4332 /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
4333 ru = tar._rules || [];
4334 if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
4335 || (tar.nodeName === selector)) {
4336 ru[ru.length] = rules[i];
4340 tar = doc = rules = void 0;
4342 tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
4344 this.addEventListener("DOMNodeInserted", function(evt){
4345 var tar = evt.target;
4346 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4347 if (tar.nodeName === "#cdata-section") {
4348 evt.currentTarget._text = tar.data;
4352 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4353 var tar = evt.target;
4354 if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
4355 var evtt = tar.ownerDocument.createEvent("SVGEvents");
4356 evtt.initEvent("S_Load", false, false);
4357 evt.currentTarget.dispatchEvent(evtt);
4364 SVGStyleElement.constructor = SVGElement;
4365 SVGStyleElement.prototype = new SVGElement();
4368 *2次元座標の点(x,y)を表すオブジェクト
4370 function SVGPoint() {
4373 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
4374 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
4375 /*整数にしているのは、VMLの設計上、小数点を扱えないときがあるため*/
4376 var s = new SVGPoint();
4377 s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
4378 s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
4382 function SVGPointList() {
4385 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4386 SVGPointList.prototype[prop] = SVGStringList.prototype[prop];
4390 *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
4395 function SVGMatrix() {
4398 SVGMatrix.prototype = {
4408 /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
4409 var s = new SVGMatrix(), m = secondMatrix;
4410 if (!isFinite(m.a) || !isFinite(m.b) || !isFinite(m.c) || !isFinite(m.d) || !isFinite(m.e) || !isFinite(m.f)) {
4411 throw (new Error("引数の値がNumber型ではありません"));
4413 s.a = this.a * m.a + this.c * m.b;
4414 s.b = this.b * m.a + this.d * m.b;
4415 s.c = this.a * m.c + this.c * m.d;
4416 s.d = this.b * m.c + this.d * m.d;
4417 s.e = this.a * m.e + this.c * m.f + this.e;
4418 s.f = this.b * m.e + this.d * m.f + this.f;
4419 m = secondMatrix = void 0;
4425 /*SVGMatrix*/ inverse : function() {
4426 var s = new SVGMatrix(), n = this._determinant();
4432 s.e = (this.c * this.f - this.d * this.e) / n;
4433 s.f = (this.b * this.e - this.a * this.f) / n;
4436 throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
4439 /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
4440 var m = new SVGMatrix();
4443 var s = this.multiply(m);
4447 /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
4448 var m = new SVGMatrix();
4451 var s = this.multiply(m);
4455 /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
4456 var m = new SVGMatrix();
4459 var s = this.multiply(m);
4463 /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
4464 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4465 m.a = Math.cos(rad);
4466 m.b = Math.sin(rad);
4469 var s = this.multiply(m);
4473 //座標(x, y)と原点の角度の分だけ、回転する
4474 /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
4475 if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
4476 throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
4478 var m = new SVGMatrix(), rad = Math.atan2(y, x);
4479 m.a = Math.cos(rad);
4480 m.b = Math.sin(rad);
4483 var s = this.multiply(m);
4487 /*SVGMatrix*/ flipX : function() {
4488 var m = new SVGMatrix();
4490 var s = this.multiply(m);
4494 /*SVGMatrix*/ flipY : function() {
4495 var m = new SVGMatrix();
4497 var s = this.multiply(m);
4501 /*SVGMatrix*/ skewX : function(/*float*/ angle ){
4502 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
4503 m.c = Math.tan(rad);
4504 var s = this.multiply(m);
4508 /*SVGMatrix*/ skewY : function(/*float*/ angle ){
4509 var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
4510 m.b = Math.tan(rad);
4511 var s = this.multiply(m);
4516 /*float*/ _determinant : function() {
4517 return (this.a * this.d - this.b * this.c);
4521 function SVGTransform() {
4522 /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
4526 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN = 0;
4527 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX = 1;
4528 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
4529 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE = 3;
4530 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE = 4;
4531 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX = 5;
4532 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY = 6;
4533 SVGTransform.prototype = {
4534 /*ダミーの単位行列。各メソッドで使う*/
4535 _matrix : (new SVGMatrix()),
4536 /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
4537 /*readonly float*/ angle : 0,
4538 /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
4539 this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
4540 this.matrix = this._matrix.multiply(matrix);
4542 /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
4543 this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
4544 this.matrix = this._matrix.translate(tx, ty);
4546 /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
4547 this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
4548 this.matrix = this._matrix.scaleNonUniform(sx, sy);
4550 /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
4552 this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
4553 this.matrix = this._matrix.rotate(angle);
4554 this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
4555 this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
4557 /*void*/ setSkewX : function(/*float*/ angle ) {
4559 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
4560 this.matrix = this._matrix.skewX(angle);
4562 /*void*/ setSkewY : function(/*float*/ angle ) {
4564 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
4565 this.matrix = this._matrix.skewY(angle);
4569 function SVGTransformList() {
4572 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4573 SVGTransformList.prototype[prop] = SVGStringList.prototype[prop];
4575 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
4576 var t = new SVGTransform();
4577 t.setMatrix(matrix);
4580 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
4581 if(this.numberOfItems === 0) {
4584 var s = this.getItem(0), m = s.matrix;
4585 for (var i=1,nli=this.numberOfItems;i<nli;++i) {
4586 m = m.multiply(this.getItem(i).matrix);
4594 function SVGAnimatedTransformList() {
4595 /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
4598 function SVGPreserveAspectRatio() {
4599 /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
4600 /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
4605 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
4606 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE = 1;
4607 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
4608 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
4609 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
4610 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
4611 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
4612 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
4613 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
4614 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
4615 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
4616 // Meet-or-slice Types
4617 /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN = 0;
4618 /*unsigned short*/ t.SVG_MEETORSLICE_MEET = 1;
4619 /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
4620 })(SVGPreserveAspectRatio);
4622 function SVGAnimatedPreserveAspectRatio() {
4623 /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
4627 function SVGPathSeg() {
4628 /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
4629 /*readonly DOMString*/ this.pathSegTypeAsLetter = null;
4634 // Path Segment Types
4635 /*unsigned short*/ t.PATHSEG_UNKNOWN = 0;
4636 /*unsigned short*/ t.PATHSEG_CLOSEPATH = 1;
4637 /*unsigned short*/ t.PATHSEG_MOVETO_ABS = 2;
4638 /*unsigned short*/ t.PATHSEG_MOVETO_REL = 3;
4639 /*unsigned short*/ t.PATHSEG_LINETO_ABS = 4;
4640 /*unsigned short*/ t.PATHSEG_LINETO_REL = 5;
4641 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS = 6;
4642 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL = 7;
4643 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS = 8;
4644 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL = 9;
4645 /*unsigned short*/ t.PATHSEG_ARC_ABS = 10;
4646 /*unsigned short*/ t.PATHSEG_ARC_REL = 11;
4647 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS = 12;
4648 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL = 13;
4649 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS = 14;
4650 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL = 15;
4651 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;
4652 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;
4653 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
4654 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
4657 *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
4659 function SVGPathSegClosePath() {
4662 SVGPathSegClosePath.prototype = {
4663 pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
4664 pathSegTypeAsLetter : "z"
4666 function SVGPathSegMovetoAbs() {
4671 SVGPathSegMovetoAbs.prototype = {
4672 pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
4673 pathSegTypeAsLetter : "M"
4675 function SVGPathSegMovetoRel() {
4680 SVGPathSegMovetoRel.prototype = {
4681 pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
4682 pathSegTypeAsLetter : "m"
4684 function SVGPathSegLinetoAbs() {
4689 SVGPathSegLinetoAbs.prototype = {
4690 pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
4691 pathSegTypeAsLetter : "L"
4693 function SVGPathSegLinetoRel() {
4698 SVGPathSegLinetoRel.prototype = {
4699 pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
4700 pathSegTypeAsLetter : "l"
4702 function SVGPathSegCurvetoCubicAbs() {
4711 SVGPathSegCurvetoCubicAbs.prototype = {
4712 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
4713 pathSegTypeAsLetter : "C"
4715 function SVGPathSegCurvetoCubicRel() {
4724 SVGPathSegCurvetoCubicRel.prototype = {
4725 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
4726 pathSegTypeAsLetter : "c"
4728 function SVGPathSegCurvetoQuadraticAbs() {
4733 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
4734 this.pathSegTypeAsLetter = "Q";
4737 function SVGPathSegCurvetoQuadraticRel() {
4742 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
4743 this.pathSegTypeAsLetter = "q";
4747 function SVGPathSegArcAbs() {
4752 /*float*/ this.angle;
4755 SVGPathSegArcAbs.prototype = {
4756 /*boolean*/ largeArcFlag : true,
4757 /*boolean*/ sweepFlag : true,
4758 pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
4759 pathSegTypeAsLetter : "A"
4761 function SVGPathSegArcRel() {
4766 /*float*/ this.angle;
4769 SVGPathSegArcRel.prototype = {
4770 /*boolean*/ largeArcFlag : true,
4771 /*boolean*/ sweepFlag : true,
4772 pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
4773 pathSegTypeAsLetter : "a"
4775 function SVGPathSegLinetoHorizontalAbs() {
4777 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
4778 this.pathSegTypeAsLetter = "H";
4781 function SVGPathSegLinetoHorizontalRel() {
4783 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
4784 this.pathSegTypeAsLetter = "h";
4787 function SVGPathSegLinetoVerticalAbs() {
4789 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
4790 this.pathSegTypeAsLetter = "V";
4793 function SVGPathSegLinetoVerticalRel() {
4795 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
4796 this.pathSegTypeAsLetter = "v";
4799 function SVGPathSegCurvetoCubicSmoothAbs() {
4804 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
4805 this.pathSegTypeAsLetter = "S";
4808 function SVGPathSegCurvetoCubicSmoothRel() {
4813 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
4814 this.pathSegTypeAsLetter = "s";
4817 function SVGPathSegCurvetoQuadraticSmoothAbs() {
4820 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
4821 this.pathSegTypeAsLetter = "T";
4824 function SVGPathSegCurvetoQuadraticSmoothRel() {
4827 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
4828 this.pathSegTypeAsLetter = "t";
4831 function SVGPathSegList() {
4834 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
4835 SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
4838 /*documentは引数の変数として登録しておく*/
4839 (function(_doc, _math) {
4840 //freeArg関数はunloadで使う解放処理
4841 NAIBU.freeArg = function() {
4842 SVGPathElement = _doc = _math = void 0;
4844 //仮のfill属性とstroke属性の処理
4845 NAIBU._setPaint = function(tar, matrix) {
4846 /*以下では、スタイルシートを用いて、fill-とstroke-関連の
4847 *処理を行う。SVGPaintインターフェースをも用いる
4849 var tod = tar.ownerDocument,
4850 _doc = tod._document_,
4852 style = tod.defaultView.getComputedStyle(tar, ""),
4853 fill = style.getPropertyCSSValue("fill"),
4854 stroke = style.getPropertyCSSValue("stroke"),
4855 fp = fill.paintType,
4856 sp = stroke.paintType,
4858 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
4859 t, evtt, fillOpacity, strs, cursor, vis, disp,
4860 strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
4864 /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
4865 while (el.firstChild) {
4866 el.removeChild(el.firstChild);
4868 if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4869 if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4870 /*再度、設定。css.jsのsetPropertyを参照*/
4871 style.setProperty("color", style.getPropertyValue("color"));
4873 fillElement = _doc.createElement("v:fill");
4875 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
4876 fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4877 fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
4878 if (fillOpacity < 1) {
4879 fillElement.setAttribute("opacity", fillOpacity+"");
4881 el.appendChild(fillElement);
4882 fillElement = fc = fillOpacity = void 0;
4883 } else if (fill.uri) {
4884 /*以下では、Gradation関連の要素に、イベントを渡すことで、
4887 t = tod.getElementById(fill.uri);
4889 evtt = tod.createEvent("MutationEvents");
4890 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
4891 evtt._tar = _doc.createElement("v:fill");
4892 evtt._style = style;
4894 t.dispatchEvent(evtt);
4895 if (t.localName !== "radialGradient") {
4896 el.appendChild(evtt._tar);
4901 el.filled = "false";
4903 if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
4904 if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4905 /*再度、設定。css.jsのsetPropertyを参照*/
4906 style.setProperty("color", style.getPropertyValue("color"));
4908 strokeElement = _doc.createElement("v:stroke");
4909 sgsw = style.getPropertyCSSValue("stroke-width");
4910 w = tod.documentElement.viewport.width;
4911 h = tod.documentElement.viewport.height;
4912 sgsw._percent = _math.sqrt((w*w + h*h) / 2);
4913 swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
4914 strokeElement.setAttribute("weight", swx + "px");
4915 sgsw = w = h = void 0;
4917 fc = stroke.rgbColor;
4918 strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
4919 strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
4921 strokeOpacity *= swx; //太さが1px未満なら色を薄くする
4923 if (strokeOpacity < 1) {
4924 strokeElement.setAttribute("opacity", strokeOpacity+"");
4926 fc = strokeOpacity = void 0;
4928 strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
4929 strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
4930 if (style.getPropertyValue("stroke-linecap") === "butt") {
4931 strokeElement.setAttribute("endcap", "flat");
4933 strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
4935 tsd = style.getPropertyValue("stroke-dasharray");
4936 if (tsd !== "none") {
4937 if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
4938 strs = tsd.split(",");
4939 for (var i = 0, sli = strs.length; i < sli; ++i) {
4940 strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
4942 strokedasharray = strs.join(" ");
4943 if (strs.length % 2 === 1) {
4944 strokedasharray += " " + strokedasharray;
4947 strokeElement.setAttribute("dashstyle", strokedasharray);
4948 tsd = strs = void 0;
4950 el.appendChild(strokeElement);
4951 strokeElement = tsd = void 0;
4953 el.stroked = "false";
4955 cursor = style.getPropertyCSSValue("cursor");
4956 if (cursor && !cursor._isDefault) { //初期値でないならば
4957 el.style.cursor = cursor.cssText.split(":")[1];
4959 vis = style.getPropertyCSSValue("visibility");
4960 if (vis && !vis._isDefault) {
4961 el.style.visibility = vis.cssText.split(":")[1];
4963 disp = style.getPropertyCSSValue("display");
4964 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
4965 el.style.display = "none";
4966 } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
4967 el.style.display = "inline-block";
4969 tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
4972 function SVGPathElement(_doc) {
4973 SVGElement.apply(this);
4974 this._tar = _doc.createElement("v:shape");
4975 //interface SVGAnimatedPathData
4976 var sp = SVGPathSegList;
4977 /*readonly SVGPathSegList*/ this.pathSegList = new sp();
4978 this.animatedPathSegList = this.pathSegList;
4979 /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
4981 this.animatedNormalizedPathSegList = this.normalizedPathSegList;
4982 /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
4983 //以下は、d属性に変更があった場合の処理
4984 this.addEventListener("DOMAttrModified", this._attrModi, false);
4985 /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
4986 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
4988 this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
4991 SVGPathElement.constructor = SVGElement;
4992 SVGPathElement.prototype = new SVGElement();
4993 (function(_sproto) {
4994 _sproto._attrModi = function(evt){
4995 var tar = evt.target;
4996 if (evt.attrName === "d" && evt.newValue !== ""){
4997 /* d属性の値が空の場合は、描画を行わないようにする
4999 *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
5001 var tnl = tar.normalizedPathSegList,
5002 tlist = tar.pathSegList;
5003 if (tnl.numberOfItems > 0) {
5007 /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
5009 *D = [["M", 20, 30], ["L", 20 40]]
5011 var taco = tar._com,
5014 .replace(taco.isRa, " -")
5015 .replace(taco.isRb, " ")
5016 .replace(taco.isRc, ",$1 ")
5017 .replace(taco.isRd, ",$1 1")
5018 .replace(taco.isRe, "")
5025 tcc = tar.createSVGPathSegCurvetoCubicAbs,
5026 tcll = tar.createSVGPathSegLinetoAbs;
5027 for (var i=0;i<dli;++i) {
5028 var di = dd[i].match(sgs),
5030 for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
5032 s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5034 } else if (isL[dii]) {
5035 s = tcll(+di[j], +di[j+1]);
5037 } else if (isM[dii]) {
5038 s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
5040 } else if (isZ[dii]) {
5041 s = tar.createSVGPathSegClosePath();
5042 } else if (dii === "A") {
5043 s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5045 } else if (dii === "m") {
5046 s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
5048 } else if (dii === "l") {
5049 s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
5051 } else if (dii === "c") {
5052 s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
5054 } else if (dii === "Q") {
5055 s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5057 } else if (dii === "q") {
5058 s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5060 } else if (dii === "a") {
5061 s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
5063 } else if (dii === "S") {
5064 s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5066 } else if (dii === "s") {
5067 s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
5069 } else if (dii === "T") {
5070 s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
5072 } else if (dii === "t") {
5073 s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
5075 } else if (dii === "H") {
5076 s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
5077 } else if (dii === "h") {
5078 s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
5079 } else if (dii === "V") {
5080 s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
5081 } else if (dii === "v") {
5082 s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
5084 s = new SVGPathSeg();
5086 tlist.appendItem(s);
5089 di = s = sgs = dd = void 0;
5090 /*以下の処理は、pathSegListからnormalizedPathSegListへの
5091 *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
5093 var cx = 0, cy = 0, //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
5094 xn = 0, yn = 0, //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
5095 startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
5096 for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
5097 var ti = tlist.getItem(j),
5098 ts = ti.pathSegType,
5099 dii = ti.pathSegTypeAsLetter;
5100 if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
5102 var rx = cx, ry = cy; //rx, ryは前のセグメントの終了点
5103 if (ts % 2 === 1) { //相対座標ならば
5112 } else if (isL[dii]) {
5114 } else if (isM[dii]) {
5116 /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
5117 *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
5118 *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
5120 var tg = tlist.getItem(j-1);
5121 if (tg.pathSegTypeAsLetter === "M") {
5122 tnl.appendItem(tcll(cx, cy));
5129 } else if (dii === "m") {
5131 var tg = tlist.getItem(j-1);
5132 if (tg.pathSegTypeAsLetter === "m") {
5133 tnl.appendItem(tcll(cx, cy));
5139 tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
5140 } else if (dii === "l") {
5141 tnl.appendItem(tcll(cx, cy));
5142 } else if (dii === "c") {
5143 tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
5144 } else if (isZ[dii]) {
5148 } else if (dii === "Q") {
5151 //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
5152 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));
5153 } else if (dii === "q") {
5154 var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
5157 tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
5159 } else if (dii === "A" || dii === "a") {
5160 (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
5161 /*以下は、Arctoを複数のCuvetoに変換する処理
5162 *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
5163 *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
5165 if (ti.r1 === 0 || ti.r2 === 0) {
5168 var fS = ti.sweepFlag,
5170 r1 = _math.abs(ti.r1),
5171 r2 = _math.abs(ti.r2),
5172 ctx = (rx - cx) / 2, cty = (ry - cy) / 2,
5173 cpsi = _math.cos(psai * _math.PI / 180),
5174 spsi = _math.sin(psai * _math.PI / 180),
5175 rxd = cpsi*ctx + spsi*cty,
5176 ryd = -1*spsi*ctx + cpsi*cty,
5177 rxdd = rxd * rxd, rydd = ryd * ryd,
5180 lamda = rxdd/r1x + rydd/r2y,
5183 r1 = _math.sqrt(lamda) * r1;
5184 r2 = _math.sqrt(lamda) * r2;
5188 if (ti.largeArcFlag === fS) {
5191 sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
5193 var txd = sds*r1*ryd / r2,
5194 tyd = -1 * sds*r2*rxd / r1,
5195 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
5196 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
5197 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
5198 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
5199 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
5200 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
5201 if (!fS && dr > 0) {
5203 } else if (fS && dr < 0) {
5206 var sse = dr * 2 / _math.PI,
5207 seg = _math.ceil(sse<0 ? -1*sse : sse),
5209 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
5210 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
5211 spsir1 = spsi * r1, spsir2 = spsi * r2,
5214 x2 = rx - t * (cpsir1*ms + spsir2*mc),
5215 y2 = ry - t * (spsir1*ms - cpsir2*mc);
5216 for (var n = 0; n < seg; ++n) {
5220 var x3 = cpsir1*mc - spsir2*ms + tx,
5221 y3 = spsir1*mc + cpsir2*ms + ty,
5222 dx = -t * (cpsir1*ms + spsir2*mc),
5223 dy = -t * (spsir1*ms - cpsir2*mc);
5224 tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
5228 ti= cx= cy= rx= ry= tar= tnl = void 0;
5229 })(ti, cx, cy, rx, ry, tar, tnl);
5230 } else if (dii === "S") {
5232 var tg = tnl.getItem(tnl.numberOfItems-1);
5233 if (tg.pathSegTypeAsLetter === "C") {
5234 var x1 = 2*tg.x - tg.x2,
5235 y1 = 2*tg.y - tg.y2;
5236 } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
5244 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
5246 } else if (dii === "s") {
5248 var tg = tnl.getItem(tnl.numberOfItems-1);
5249 if (tg.pathSegTypeAsLetter === "C") {
5250 var x1 = 2*tg.x - tg.x2,
5251 y1 = 2*tg.y - tg.y2;
5260 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
5262 } else if (dii === "T" || dii === "t") {
5264 var tg = tlist.getItem(j-1);
5265 if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
5272 tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
5276 } else if (dii === "H" || dii === "h") {
5277 tnl.appendItem(tcll(cx, ry));
5278 cy = ry; //勝手にti.yが0としているため
5279 } else if (dii === "V" || dii === "v") {
5280 tnl.appendItem(tcll(rx, cy));
5286 evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
5288 _sproto._nodeInsert = function(evt){
5289 var tar = evt.target;
5290 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5293 var tnext = tar.nextSibling,
5294 tpart = tar.parentNode._tar,
5296 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5297 tpart.insertBefore(tar._tar, tnext._tar);
5298 } else if (tnext && !tnext._tar && tpart) {
5299 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5300 *use要素や実体参照などは_tarプロパティがないことに注意
5303 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5304 tpart.insertBefore(tar._tar, tnext._tar);
5307 tnext = tnext.nextSibling;
5310 tpart.appendChild(tar._tar);
5312 } else if (!tnext && tpart) {
5313 tpart.appendChild(tar._tar);
5315 tnext = tpart = isLast = void 0;
5316 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
5319 _sproto._nodeInsertInto = function(evt){
5320 /*以下の処理は、normalizedpathSegListとCTMに基づいて、
5321 *SVGのd属性をVMLに変換していく処理である。
5323 var tar = evt.target,
5324 matrix = tar.getScreenCTM(),
5325 tlist = tar.normalizedPathSegList,
5327 ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
5328 cname = tar._com._nameCom,
5329 isZ = tar._com._isZ, isC = tar._com._isC,
5331 for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
5335 tps = ti.pathSegTypeAsLetter,
5338 /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
5343 t += [mr(ma*ti.x1 + mc*ti.y1 + me),
5344 mr(mb*ti.x1 + md*ti.y1 + mf),
5345 mr(ma*ti.x2 + mc*ti.y2 + me),
5346 mr(mb*ti.x2 + md*ti.y2 + mf),
5347 mr(ma*tx + mc*ty + me),
5348 mr(mb*tx + md*ty + mf)].join(" ");
5349 } else if (!isZ[tps]) {
5350 t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
5354 var vi = tar.ownerDocument.documentElement,
5357 tt.path = dat.join(" ");
5358 tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
5359 NAIBU._setPaint(tar, matrix);
5360 delete tar._cacheMatrix;
5361 evt = tar = dat = t = tx = ty = matrix = tlist = x = y = mr = ma = mb = mc = md = me = mf = vi = isZ = isC = i = tli = tps = ti = cname = tt = void 0;
5386 isRc : /([a-yA-Y])/g,
5391 /*float*/ _sproto.getTotalLength = function() {
5393 nl = this.normalizedPathSegList;
5394 for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5395 var seg = nl.getItem(i);
5396 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5397 var ps = nl.getItem(i-1);
5398 s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5399 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5400 var ps = nl.getItem(i-1), dd = 0;
5401 /*2点のハンドルを結んだ線分の3辺と、
5402 *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
5405 *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
5406 *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
5408 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5409 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5410 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5411 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5413 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5414 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5415 s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5419 this.pathLength.baseVal = s;
5422 /*SVGPoint*/ _sproto.getPointAtLength = function(/*float*/ distance ) {
5423 var segn = this.getPathSegAtLength(distance),
5426 nl = this.normalizedPathSegList,
5427 seg = nl.getItem(segn),
5428 s = this.ownerDocument.documentElement.createSVGPoint();
5429 if ((segn-1) <= 0) {
5434 var ps = nl.getItem(segn-1);
5435 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5436 var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5437 var t = (segl + this._dis) / segl;
5438 s.x = ps.x + t * (seg.x-ps.x);
5439 s.y = ps.y + t * (seg.y-ps.y);
5440 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5442 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5443 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5444 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5445 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5447 var t = (segl + this._dis) / segl;
5448 /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
5451 s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
5452 +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
5453 +3*(seg.x1 - ps.x) * t
5455 s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
5456 +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
5457 +3*(seg.y1 - ps.y) * t
5459 } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
5462 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5463 var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
5464 var t = (segl + this._dis) / segl;
5465 s.x = ms.x + t * (seg.x-ms.x);
5466 s.y = ms.y + t * (seg.y-ms.y);
5470 /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
5471 var nl = this.normalizedPathSegList; //仕様ではpathSegList
5472 for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
5473 var seg = nl.getItem(i);
5474 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
5475 var ps = nl.getItem(i-1);
5476 distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5477 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
5478 var ps = nl.getItem(i-1), dd = 0;
5479 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
5480 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5481 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
5482 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
5485 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
5486 var ps = nl.getItem(i-1), ms = nl.getItem(0);
5487 distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
5489 if (distance <= 0) {
5490 /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
5491 this._dis = distance;
5496 /*もし、distanceがパスの距離よりも長い場合、
5498 *なお、これはSVG1.1の仕様の想定外のこと
5500 return (nl.numberOfItems - 1);
5502 /*SVGPathSegClosePath*/ _sproto.createSVGPathSegClosePath = function() {
5503 var _SVGPathSegClosePath = SVGPathSegClosePath;
5504 return (new _SVGPathSegClosePath());
5506 /*SVGPathSegMovetoAbs*/ _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
5507 var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
5512 /*SVGPathSegMovetoRel*/ _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
5513 var s = new SVGPathSegMovetoRel();
5518 /*SVGPathSegLinetoAbs*/ _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
5519 var s = new SVGPathSegLinetoAbs();
5524 /*SVGPathSegLinetoRel*/ _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
5525 var s = new SVGPathSegLinetoRel();
5530 /*SVGPathSegCurvetoCubicAbs*/ _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5531 var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
5540 /*SVGPathSegCurvetoCubicRel*/ _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
5541 var s = new SVGPathSegCurvetoCubicRel();
5550 /*SVGPathSegCurvetoQuadraticAbs*/ _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5551 var s = new SVGPathSegCurvetoQuadraticAbs();
5558 /*SVGPathSegCurvetoQuadraticRel*/ _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
5559 var s = new SVGPathSegCurvetoQuadraticRel();
5566 /*SVGPathSegArcAbs*/ _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5567 var s = new SVGPathSegArcAbs();
5573 s.largeArcFlag = largeArcFlag;
5574 s.sweepFlag = sweepFlag;
5577 /*SVGPathSegArcRel*/ _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
5578 var s = new SVGPathSegArcRel();
5584 s.largeArcFlag = largeArcFlag;
5585 s.sweepFlag = sweepFlag;
5588 /*SVGPathSegLinetoHorizontalAbs*/ _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
5589 var s = new SVGPathSegLinetoHorizontalAbs();
5591 s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
5594 /*SVGPathSegLinetoHorizontalRel*/ _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
5595 var s = new SVGPathSegLinetoHorizontalRel();
5600 /*SVGPathSegLinetoVerticalAbs*/ _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
5601 var s = new SVGPathSegLinetoVerticalAbs();
5606 /*SVGPathSegLinetoVerticalRel*/ _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
5607 var s = new SVGPathSegLinetoVerticalRel();
5612 /*SVGPathSegCurvetoCubicSmoothAbs*/ _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5613 var s = new SVGPathSegCurvetoCubicSmoothAbs();
5620 /*SVGPathSegCurvetoCubicSmoothRel*/ _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
5621 var s = new SVGPathSegCurvetoCubicSmoothRel();
5628 /*SVGPathSegCurvetoQuadraticSmoothAbs*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
5629 var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
5634 /*SVGPathSegCurvetoQuadraticSmoothRel*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
5635 var s = new SVGPathSegCurvetoQuadraticSmoothRel();
5640 })(SVGPathElement.prototype)
5641 NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
5644 function SVGRectElement(_doc) {
5645 SVGElement.apply(this);
5646 this._tar = _doc.createElement("v:shape");
5647 var slen = SVGAnimatedLength;
5648 /*readonly SVGAnimatedLength*/ this.x = new slen();
5649 /*readonly SVGAnimatedLength*/ this.y = new slen();
5650 /*readonly SVGAnimatedLength*/ this.width = new slen();
5651 /*readonly SVGAnimatedLength*/ this.height = new slen();
5652 /*readonly SVGAnimatedLength*/ this.rx = new slen();
5653 /*readonly SVGAnimatedLength*/ this.ry = new slen();
5654 _doc = slen = void 0;
5655 this.addEventListener("DOMNodeInserted", function(evt){
5656 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5659 var tar = evt.target,
5660 tnext = tar.nextSibling,
5661 tpart = tar.parentNode._tar,
5663 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5664 tpart.insertBefore(tar._tar, tnext._tar);
5665 } else if (tnext && !tnext._tar && tpart) {
5666 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5667 *use要素や実体参照などは_tarプロパティがないことに注意
5670 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5671 tpart.insertBefore(tar._tar, tnext._tar);
5674 tnext = tnext.nextSibling;
5677 tpart.appendChild(tar._tar);
5679 } else if (!tnext && tpart) {
5680 tpart.appendChild(tar._tar);
5682 tnext = tpart = isLast = void 0;
5683 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5684 var tar = evt.target,
5685 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
5686 fontSize = parseFloat(style.getPropertyValue("font-size"));
5687 tar.x.baseVal._emToUnit(fontSize);
5688 tar.y.baseVal._emToUnit(fontSize);
5689 tar.width.baseVal._emToUnit(fontSize);
5690 tar.height.baseVal._emToUnit(fontSize);
5691 var rx = tar.getAttributeNS(null, "rx"),
5692 ry = tar.getAttributeNS(null, "ry"),
5693 x = tar.x.baseVal.value,
5694 y = tar.y.baseVal.value,
5695 xw = x + tar.width.baseVal.value,
5696 yh = y + tar.height.baseVal.value,
5698 if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
5699 tar.rx.baseVal._emToUnit(fontSize);
5700 tar.ry.baseVal._emToUnit(fontSize);
5701 var thrx = tar.rx.baseVal,
5702 thry = tar.ry.baseVal,
5703 twidth = tar.width.baseVal.value,
5704 theight = tar.height.baseVal.value;
5705 thrx.value = rx ? thrx.value : thry.value;
5706 thry.value = ry ? thry.value : thrx.value;
5707 //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
5708 if (thrx.value > twidth / 2) {
5709 thrx.value = twidth / 2;
5711 if (thry.value > theight / 2) {
5712 thry.value = theight / 2;
5714 var rxv = thrx.value,
5716 rrx = rxv * 0.55228,
5717 rry = ryv * 0.55228,
5722 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];
5724 list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
5726 //以下は、配列listそのものをCTMで座標変換していく処理
5727 var par = tar.ownerDocument.documentElement,
5728 ctm = tar.getScreenCTM(),
5731 vi = tar.ownerDocument.documentElement,
5732 w = vi.width.baseVal.value,
5733 h = vi.height.baseVal.value,
5735 for (var i=0, lili=list.length;i<lili;) {
5736 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5740 p = par.createSVGPoint();
5743 pmt = p.matrixTransform(ctm);
5744 list[i] = mr(pmt.x);
5746 list[i] = mr(pmt.y);
5750 dat = list.join(" ");
5753 ele.coordsize = w + " " + h;
5754 NAIBU._setPaint(tar, ctm);
5755 delete tar._cacheMatrix;
5756 evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
5762 SVGRectElement.constructor = SVGElement;
5763 SVGRectElement.prototype = new SVGElement();
5765 function SVGCircleElement(_doc) {
5766 SVGElement.apply(this);
5767 this._tar = _doc.createElement("v:shape");
5768 var sl = SVGAnimatedLength;
5769 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5770 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5771 /*readonly SVGAnimatedLength*/ this.r = new sl();
5773 this.addEventListener("DOMNodeInserted", function(evt){
5774 var tar = evt.target;
5775 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5778 var tnext = tar.nextSibling,
5779 tpart = tar.parentNode._tar,
5781 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5782 tpart.insertBefore(tar._tar, tnext._tar);
5783 } else if (tnext && !tnext._tar && tpart) {
5784 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5785 *use要素や実体参照などは_tarプロパティがないことに注意
5788 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5789 tpart.insertBefore(tar._tar, tnext._tar);
5792 tnext = tnext.nextSibling;
5795 tpart.appendChild(tar._tar);
5797 } else if (!tnext && tpart) {
5798 tpart.appendChild(tar._tar);
5800 tnext = tpart = isLast = void 0;
5801 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5802 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5803 var fontSize = parseFloat(style.getPropertyValue("font-size"));
5804 tar.cx.baseVal._emToUnit(fontSize);
5805 tar.cy.baseVal._emToUnit(fontSize);
5806 tar.r.baseVal._emToUnit(fontSize);
5807 var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = ry = tar.r.baseVal.value;
5808 var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
5809 var rrx = rx * 0.55228, rry = ry * 0.55228;
5810 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"];
5811 //以下は、配列listそのものをCTMで座標変換していく処理
5812 var par = tar.ownerDocument.documentElement,
5813 ctm = tar.getScreenCTM(),
5815 for (var i=0, lili=list.length;i<lili;) {
5816 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5820 var p = par.createSVGPoint();
5823 var pmt = p.matrixTransform(ctm);
5824 list[i] = mr(pmt.x);
5826 list[i] = mr(pmt.y);
5830 var dat = list.join(" ");
5832 var ele = tar._tar, vi = tar.ownerDocument.documentElement;
5833 var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5835 ele.coordsize = w + " " + h;
5836 NAIBU._setPaint(tar, ctm);
5837 delete tar._cacheMatrix;
5838 evt = tar = list = mr = style = fontSize = dat = ele = void 0;
5844 SVGCircleElement.constructor = SVGElement;
5845 SVGCircleElement.prototype = new SVGElement();
5847 function SVGEllipseElement(_doc) {
5848 SVGElement.apply(this);
5849 this._tar = _doc.createElement("v:shape");
5850 var sl = SVGAnimatedLength;
5851 /*readonly SVGAnimatedLength*/ this.cx = new sl();
5852 /*readonly SVGAnimatedLength*/ this.cy = new sl();
5853 /*readonly SVGAnimatedLength*/ this.rx = new sl();
5854 /*readonly SVGAnimatedLength*/ this.ry = new sl();
5856 this.addEventListener("DOMNodeInserted", function(evt){
5857 var tar = evt.target;
5858 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5861 var tnext = tar.nextSibling,
5862 tpart = tar.parentNode._tar,
5864 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5865 tpart.insertBefore(tar._tar, tnext._tar);
5866 } else if (tnext && !tnext._tar && tpart) {
5867 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5868 *use要素や実体参照などは_tarプロパティがないことに注意
5871 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5872 tpart.insertBefore(tar._tar, tnext._tar);
5875 tnext = tnext.nextSibling;
5878 tpart.appendChild(tar._tar);
5880 } else if (!tnext && tpart) {
5881 tpart.appendChild(tar._tar);
5883 tnext = tpart = isLast = void 0;
5884 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5885 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5886 var fontSize = parseFloat(style.getPropertyValue("font-size"));
5887 tar.cx.baseVal._emToUnit(fontSize);
5888 tar.cy.baseVal._emToUnit(fontSize);
5889 tar.rx.baseVal._emToUnit(fontSize);
5890 tar.ry.baseVal._emToUnit(fontSize);
5891 var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = tar.rx.baseVal.value, ry = tar.ry.baseVal.value;
5892 var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
5893 var rrx = rx * 0.55228, rry = ry * 0.55228;
5894 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"];
5895 //以下は、配列listそのものをCTMで座標変換していく処理
5896 var par = tar.ownerDocument.documentElement,
5897 ctm = tar.getScreenCTM(),
5899 for (var i=0, lili=list.length;i<lili;) {
5900 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
5904 var p = par.createSVGPoint();
5907 var pmt = p.matrixTransform(ctm);
5908 list[i] = mr(pmt.x);
5910 list[i] = mr(pmt.y);
5914 var dat = list.join(" ");
5916 var ele = tar._tar, vi = tar.ownerDocument.documentElement;
5917 var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5919 ele.coordsize = w + " " + h;
5920 NAIBU._setPaint(tar, ctm);
5921 delete tar._cacheMatrix;
5922 evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
5928 SVGEllipseElement.constructor = SVGElement;
5929 SVGEllipseElement.prototype = new SVGElement();
5931 function SVGLineElement(_doc) {
5932 SVGElement.apply(this);
5933 this._tar = _doc.createElement("v:shape");
5934 var sl = SVGAnimatedLength;
5935 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
5936 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
5937 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
5938 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
5940 this.addEventListener("DOMNodeInserted", function(evt){
5941 var tar = evt.target;
5942 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5945 var tnext = tar.nextSibling,
5946 tpart = tar.parentNode._tar,
5948 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
5949 tpart.insertBefore(tar._tar, tnext._tar);
5950 } else if (tnext && !tnext._tar && tpart) {
5951 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
5952 *use要素や実体参照などは_tarプロパティがないことに注意
5955 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
5956 tpart.insertBefore(tar._tar, tnext._tar);
5959 tnext = tnext.nextSibling;
5962 tpart.appendChild(tar._tar);
5964 } else if (!tnext && tpart) {
5965 tpart.appendChild(tar._tar);
5967 tnext = tpart = isLast = void 0;
5968 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
5969 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
5970 var fontSize = parseFloat(style.getPropertyValue("font-size"));
5971 tar.x1.baseVal._emToUnit(fontSize);
5972 tar.y1.baseVal._emToUnit(fontSize);
5973 tar.x2.baseVal._emToUnit(fontSize);
5974 tar.y2.baseVal._emToUnit(fontSize);
5975 //以下は、配列listそのものをCTMで座標変換していく処理
5976 var vi = tar.ownerDocument.documentElement,
5977 ctm = tar.getScreenCTM(),
5980 p = vi.createSVGPoint();
5981 p.x = tar.x1.baseVal.value;
5982 p.y = tar.y1.baseVal.value;
5983 var pmt = p.matrixTransform(ctm);
5984 dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
5985 p.x = tar.x2.baseVal.value;
5986 p.y = tar.y2.baseVal.value;
5987 pmt = p.matrixTransform(ctm);
5988 dat += mr(pmt.x)+ " " +mr(pmt.y);
5991 var ele = tar._tar, w = vi.width.baseVal.value, h = vi.height.baseVal.value;
5993 ele.coordsize = w + " " + h;
5994 NAIBU._setPaint(tar, ctm);
5995 delete tar._cacheMatrix;
5996 evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
6002 SVGLineElement.constructor = SVGElement;
6003 SVGLineElement.prototype = new SVGElement();
6005 /*_GenericSVGPolyElementインターフェース
6006 * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
6007 * ファイルサイズを軽量にすることができる
6009 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
6010 SVGElement.apply(this);
6011 this._tar = _doc.createElement("v:shape");
6013 //interface SVGAnimatedPoints
6014 /*readonly SVGPointList*/ this.animatedPoints = this.points = new SVGPointList();
6015 this.addEventListener("DOMAttrModified", function(evt){
6016 var tar = evt.target;
6017 if (evt.attrName === "points") {
6018 var tp = tar.points, par = tar.ownerDocument.documentElement;
6019 var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
6020 for (var i=0, p, lili=list.length;i<lili;i+=2) {
6021 if (isNaN(list[i])) {
6025 p = par.createSVGPoint();
6026 p.x = parseFloat(list[i]);
6027 p.y = parseFloat(list[i+1]);
6031 evt = tar = list = tp = par = p = void 0;
6033 this.addEventListener("DOMNodeInserted", function(evt){
6034 var tar = evt.target;
6035 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6038 var tnext = tar.nextSibling,
6039 tpart = tar.parentNode._tar,
6041 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6042 tpart.insertBefore(tar._tar, tnext._tar);
6043 } else if (tnext && !tnext._tar && tpart) {
6044 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6045 *use要素や実体参照などは_tarプロパティがないことに注意
6048 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6049 tpart.insertBefore(tar._tar, tnext._tar);
6052 tnext = tnext.nextSibling;
6055 tpart.appendChild(tar._tar);
6057 } else if (!tnext && tpart) {
6058 tpart.appendChild(tar._tar);
6060 tnext = tpart = isLast = void 0;
6061 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6062 var tar = evt.target,
6064 ctm = tar.getScreenCTM(),
6066 //以下は、配列listそのものをCTMで座標変換していく処理
6067 for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
6068 var p = tp.getItem(i),
6069 pmt = p.matrixTransform(ctm);
6070 list[2*i] = mr(pmt.x);
6071 list[2*i + 1] = mr(pmt.y);
6074 list.splice(2, 0, "l");
6075 var dat = "m" + list.join(" ") + xclose,
6077 vi = tar.ownerDocument.documentElement;
6078 w = vi.width.baseVal.value,
6079 h = vi.height.baseVal.value;
6082 ele.coordsize = w + " " + h;
6083 NAIBU._setPaint(tar, ctm);
6084 delete tar._cacheMatrix;
6085 evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
6091 function SVGPolylineElement(_doc) {
6092 NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
6096 SVGPolylineElement.constructor = SVGElement;
6097 SVGPolylineElement.prototype = new SVGElement();
6099 function SVGPolygonElement(_doc) {
6100 NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
6104 SVGPolygonElement.constructor = SVGElement;
6105 SVGPolygonElement.prototype = new SVGElement();
6107 function SVGTextContentElement(_doc) {
6108 SVGElement.apply(this);
6109 /*readonly SVGAnimatedLength*/ this.textLength = new SVGAnimatedLength();
6110 /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
6111 this.addEventListener("DOMNodeInserted", function(evt){
6112 var tar = evt.target, cur = evt.currentTarget;
6113 /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
6114 *あらかじめ、Capturingフェーズで処理しておく
6116 if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
6117 /*a要素の場合はtarをすりかえておく*/
6118 tar = tar.firstChild;
6120 if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !!!tar._tars) {
6121 /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
6123 var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
6125 data = data.split('');
6126 for (var i=0, tdli=data.length;i<tdli;++i) {
6127 var d = _doc.createElement("div"),
6129 dstyle.position = "absolute";
6130 dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = "0px";
6131 dstyle.paddingTop = dstyle.paddingLeft = "0px";
6132 dstyle.whiteSpace = "nowrap";
6133 dstyle.textIndent = "0px";
6134 d.appendChild(_doc.createTextNode(data[i]));
6135 tar._tars[tar._tars.length] = d;
6138 cur._length += tar._tars.length;
6139 } else if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar instanceof SVGTextContentElement) && !!!tar._tars) {
6140 cur._length += tar._length;
6142 evt = tar = cur = void 0;
6148 t.constructor = SVGElement;
6149 t.prototype = new SVGElement();
6150 // lengthAdjust Types
6151 /*unsigned short*/ t.LENGTHADJUST_UNKNOWN = 0;
6152 /*unsigned short*/ t.LENGTHADJUST_SPACING = 1;
6153 /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS = 2;
6154 t.prototype._list = null; //文字の位置を格納しておくリストのキャッシュ
6155 t.prototype._length = 0; //全文字数
6156 t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
6157 t.prototype._chars = 0; //tspan要素が全体の何文字目から始まっているか
6158 t.prototype._isYokogaki = true; //横書きかどうか
6159 /*long*/ t.prototype.getNumberOfChars = function() {
6160 return (this._length);
6162 /*float*/ t.prototype.getComputedTextLength = function() {
6163 var l = this.textLength.baseVal;
6164 if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
6165 /*何も設定されていない場合のみ、初期化を行う*/
6166 l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
6169 return (this.textLength.baseVal.value);
6171 /*getSubStringLengthメソッド
6172 *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
6174 /*float*/ t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
6178 var tg = this.getNumberOfChars();
6179 if (tg < (nchars+charnum)) {
6180 /*ncharsが文字列の長さよりも長くなってしまったときには、
6181 *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
6183 nchars = tg - charnum + 1;
6185 var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
6186 if (this._isYokogaki) {
6187 var s = end.x - st.x;
6189 var s = end.y - st.y;
6191 tg = end = st = void 0;
6194 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
6195 if (charnum > this.getNumberOfChars() || charnum < 0) {
6196 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6199 ti = tar.firstChild,
6200 tp = tar.parentNode;
6203 var chars = tar._chars, //現在、何文字目にあるのか
6204 x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
6205 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6206 isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
6207 fontSize = parseFloat(style.getPropertyValue("font-size")),
6208 tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
6210 if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
6211 var ptx = tp.x.baseVal,
6213 ptdx = tp.dx.baseVal,
6214 ptdy = tp.dy.baseVal;
6216 var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
6218 var kern = "f ijltIr.,:;'-\"()",
6219 akern = "1234567890abcdeghknopquvxyz",
6220 tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
6221 if (isYokogaki && (tar.localName === "text")) {
6222 y += fontSize * 0.2;
6223 } else if (tar.localName === "text"){
6224 x -= fontSize * 0.5;
6227 if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
6229 /*tspan要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
6230 *使う。また、属性が指定されていないときも同様に祖先や親を使う。
6231 *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
6232 *この処理はdx属性やdy、y属性でも同様とする
6234 *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
6236 *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
6238 for (var i=0, tli=tt.length;i<tli;++i) {
6239 if (n < ptx.numberOfItems - chars) {
6240 x = ptx.getItem(n).value;
6242 x -= fontSize * 0.5;
6244 } else if (n < tx.numberOfItems) {
6245 x = tx.getItem(n).value;
6247 x -= fontSize * 0.5;
6250 if (n < pty.numberOfItems - chars) {
6251 y = pty.getItem(n).value;
6253 y += fontSize * 0.2;
6255 } else if (n < ty.numberOfItems) {
6256 y = ty.getItem(n).value;
6258 y += fontSize * 0.2;
6261 if (n < ptdx.numberOfItems - chars) {
6262 x += ptdx.getItem(n).value;
6263 } else if (n < tdx.numberOfItems) {
6264 x += tdx.getItem(n).value;
6266 if (n < ptdy.numberOfItems - chars) {
6267 y += ptdy.getItem(n).value;
6268 } else if (n < tdy.numberOfItems) {
6269 y += tdy.getItem(n).value;
6273 //カーニングを求めて、字の幅を文字ごとに調整する
6274 tdc = ti.data.charAt(i);
6275 if (kern.indexOf(tdc) > -1) {
6276 alm = fontSize * 0.68;
6277 } else if (tdc === "s"){
6278 alm = fontSize * 0.52;
6279 } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
6280 alm = fontSize * 0.2;
6281 } else if (akern.indexOf(tdc) > -1){
6282 alm = fontSize * 0.45;
6284 alm = fontSize * 0.3;
6286 tcca = tdc.charCodeAt(0);
6287 if ((12288 <= tcca) && (tcca <= 65533)) {
6288 alm = -fontSize * 0.01;
6289 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
6290 alm += fontSize * 0.2;
6295 tlist[tlist.length] = x;
6296 tlist[tlist.length] = y;
6297 tlist[tlist.length] = fontSize - alm;
6307 if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
6310 ti = ti.nextSibling;
6311 } else if ((ti.localName === "tspan") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6312 /*現在のテキスト位置(x,y)の分だけ、tspan要素をずらしておく。
6318 p = ti.getStartPositionOfChar(ti.getNumberOfChars());
6323 almx = tlist[tlist.length-1];
6325 almy = tlist[tlist.length-1];
6327 x = tlist[tlist.length-3] + almx;
6328 y = tlist[tlist.length-2] + almy;
6329 tar._list = tar._list.concat(tlist);
6330 tg = ti.getNumberOfChars();
6333 ti = ti.nextSibling;
6334 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6335 /*a要素のテキストノードも処理する*/
6338 ti = ti.nextSibling;
6341 tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
6343 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;
6344 var s = this.ownerDocument.documentElement.createSVGPoint();
6345 s.x = this._list[charnum*3];
6346 s.y = this._list[charnum*3 + 1];
6347 s = s.matrixTransform(this.getScreenCTM());
6351 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
6352 if (charnum > this.getNumberOfChars() || charnum < 0) {
6353 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
6355 var s = this.getStartPositionOfChar(charnum);
6356 //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
6357 var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
6358 if (this._isYokogaki) {
6366 /*SVGRect*/ t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
6369 /*float*/ t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
6372 /*long*/ t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
6375 /*void*/ t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
6378 })(SVGTextContentElement);
6380 function SVGTextPositioningElement(_doc) {
6381 SVGTextContentElement.apply(this, arguments);
6382 var sl = SVGAnimatedLengthList;
6383 /*readonly SVGAnimatedLengthList*/ this.x = new sl();
6384 /*readonly SVGAnimatedLengthList*/ this.y = new sl();
6385 /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
6386 /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
6388 /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
6389 this.addEventListener("DOMAttrModified", function(evt){
6390 var tar = evt.target,
6391 name = evt.attrName,
6392 tod = tar.ownerDocument.documentElement,
6393 _parseFloat = parseFloat;
6394 if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
6395 var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
6396 teas = tar[name].baseVal;
6397 for (var i=0, tli=enr.length;i<tli;++i) {
6398 var tea = tod.createSVGLength(),
6399 n = enr[i].slice(-1),
6401 if (n >= "0" && n <= "9") {
6402 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
6403 } else if (n === "%") {
6404 if ((name === "x") || (name === "dx")) {
6405 tea._percent *= tod.viewport.width;
6406 } else if ((name === "y") || (name === "dy")) {
6407 tea._percent *= tod.viewport.height;
6409 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
6411 n = enr[i].slice(-2);
6413 var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
6414 tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
6416 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
6417 } else if (n === "ex") {
6418 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
6419 } else if (n === "px") {
6420 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
6421 } else if (n === "cm") {
6422 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
6423 } else if (n === "mm") {
6424 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
6425 } else if (n === "in") {
6426 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
6427 } else if (n === "pt") {
6428 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
6429 } else if (n === "pc") {
6430 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
6433 var s = _parseFloat(enr[i]);
6434 s = isNaN(s) ? 0 : s;
6435 tea.newValueSpecifiedUnits(type, s);
6436 teas.appendItem(tea);
6442 this.addEventListener("DOMNodeInserted", function(evt){
6443 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6444 var tar = evt.target;
6445 if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
6447 evt.currentTarget._list = null;
6454 SVGTextPositioningElement.constructor = SVGTextContentElement;
6455 SVGTextPositioningElement.prototype = new SVGTextContentElement();
6457 function SVGTextElement(_doc) {
6458 SVGTextPositioningElement.apply(this, arguments);
6459 this._tar = _doc.createElement("v:group");
6460 this.addEventListener("DOMNodeInserted", function(evt){
6461 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6464 var tar = evt.target,
6465 tnext = tar.nextSibling,
6466 tpart = tar.parentNode._tar,
6468 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
6469 tpart.insertBefore(tar._tar, tnext._tar);
6470 } else if (tnext && !tnext._tar && tpart) {
6471 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
6472 *use要素や実体参照などは_tarプロパティがないことに注意
6475 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
6476 tpart.insertBefore(tar._tar, tnext._tar);
6479 tnext = tnext.nextSibling;
6482 tpart.appendChild(tar._tar);
6484 } else if (!tnext && tpart) {
6485 tpart.appendChild(tar._tar);
6487 tnext = tpart = isLast = void 0;
6488 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6489 var tar = evt.target,
6490 ti = tar.firstChild,
6492 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
6493 n = parseFloat(style.getPropertyValue("font-size")) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
6494 tod = tar.ownerDocument.documentElement,
6495 ttpc = ttp, //ttpcはttpのキャッシュ
6496 tlen = tar.getComputedTextLength(),
6497 anchor = style.getPropertyValue("text-anchor"),
6498 tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
6501 ttps.fontSize = n + "px";
6502 ttps.fontFamily = style.getPropertyValue("font-family");
6503 ttps.fontStyle = style.getPropertyValue("font-style");
6504 ttps.fontWeight = style.getPropertyValue("font-weight");
6505 /*ここでの変数jは前回ノードまでの総文字数*/
6506 for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
6508 if (!!ti._tars && (ti._tars.length !== 0)) {
6509 var ij = (i > j) ? i - j : j - i
6510 var sty = ti._tars[ij].style,
6511 p = tar.getStartPositionOfChar(i);
6512 sty.position = "absolute";
6513 if (tar._isYokogaki) {
6514 if (anchor === "middle") {
6516 } else if (anchor === "end") {
6520 if (anchor === "middle") {
6522 } else if (anchor === "end") {
6526 sty.left = p.x + "px";
6527 sty.top = p.y + "px";
6530 sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
6531 sty.lineHeight = n+10+ "px";
6532 sty.textDecoration = tedeco;
6533 sty.display = "none"
6534 ttp.appendChild(ti._tars[ij]);
6537 if (ti.nodeName === "#text") {
6538 if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
6539 j = j + ti.data.length;
6540 if (ti.parentNode.localName === "a") {
6544 ti = ti.nextSibling;
6546 } else if (!!ti.getNumberOfChars) {
6547 if ((ti.getNumberOfChars()+j) <= i+1) {
6548 j = j + ti.getNumberOfChars();
6549 ti = ti.nextSibling;
6551 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
6559 var color = style.getPropertyValue("fill"),
6560 cursor = style.getPropertyCSSValue("cursor"),
6561 vis = style.getPropertyCSSValue("visibility"),
6562 disp = style.getPropertyCSSValue("display"),
6563 tts = tar._tar.style,
6564 tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
6565 ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
6567 if (color === "none"){
6568 tts.color = "transparent";
6569 } else if (color.indexOf("url") === -1) {
6572 tts.color = "black";
6574 if (cursor && !cursor._isDefault) { //初期値でないならば
6575 var tc = cursor.cssText;
6576 tts.cursor = tc.split(":")[1];
6579 if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
6580 && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
6581 /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
6582 *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
6584 for (var i=1, tli=tft.length;i<tli;++i) {
6586 ttt += tfti.innerText;
6587 tfti.parentNode.removeChild(tfti);
6589 //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
6590 if (tft[0] && tft[0].replaceChild) {
6591 tft[0].replaceChild(_doc.createTextNode(ttt), tft[0].firstChild);
6597 if (ttp.lastChild) {
6598 if (ttp.lastChild.nodeName !== "rect") {
6605 var backr = _doc.createElement("v:rect"),
6606 backrs = backr.style; //ずれを修正するためのもの
6607 backrs.width = backrs.height = "1px";
6608 backrs.left = backrs.top = "0px";
6609 backr.stroked = backr.filled = "false";
6610 ttp.appendChild(backr);
6612 if (vis && !vis._isDefault) {
6613 tts.visibility = vis.cssText.split(":")[1];
6615 /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
6616 *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
6618 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
6620 } else if (disp && !disp._isDefault) {
6623 var jt = tar._tar.firstChild,
6626 jt.style.display = di;
6627 jt = jt.nextSibling;
6629 while (ae[j]) { //要素内部にあるa要素の処理
6630 for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
6631 ae[j]._tars[l].style.display = di;
6636 delete tar._cacheMatrix;
6637 ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = void 0;
6643 SVGTextElement.constructor = SVGTextPositioningElement;
6644 SVGTextElement.prototype = new SVGTextPositioningElement();
6646 function SVGTSpanElement() {
6647 SVGTextElement.apply(this, arguments);
6650 SVGTSpanElement.constructor = SVGTextPositioningElement;
6651 SVGTSpanElement.prototype = new SVGTextPositioningElement();
6653 function SVGTRefElement(_doc) {
6654 SVGTextPositioningElement.apply(this, arguments);
6655 SVGURIReference.apply(this, arguments);
6658 SVGTRefElement.constructor = SVGTextPositioningElement;
6659 SVGTRefElement.prototype = new SVGTextPositioningElement();
6661 function SVGTextPathElement() {
6662 SVGTextContentElement.apply(this, arguments);
6663 /*readonly SVGAnimatedLength*/ this.startOffset;
6664 /*readonly SVGAnimatedEnumeration*/ this.method;
6665 /*readonly SVGAnimatedEnumeration*/ this.spacing;
6666 SVGURIReference.apply(this, arguments);
6669 SVGTextPathElement.constructor = SVGTextContentElement;
6670 SVGTextPathElement.prototype = new SVGTextContentElement();
6673 // textPath Method Types
6674 /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN = 0;
6675 /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN = 1;
6676 /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH = 2;
6677 // textPath Spacing Types
6678 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN = 0;
6679 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO = 1;
6680 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT = 2;
6681 })(SVGTextPathElement);
6683 function SVGAltGlyphElement() {
6684 SVGTextPositioningElement.apply(this, arguments);
6685 /*DOMString*/ this.glyphRef;
6686 /*DOMString*/ this.format;
6687 SVGURIReference.apply(this, arguments);
6690 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
6691 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
6693 function SVGAltGlyphDefElement() {
6694 SVGElement.apply(this, arguments);
6697 SVGAltGlyphDefElement.constructor = SVGElement;
6698 SVGAltGlyphDefElement.prototype = new SVGElement();
6700 function SVGAltGlyphItemElement() {
6701 SVGElement.apply(this, arguments);
6704 SVGAltGlyphItemElement.constructor = SVGElement;
6705 SVGAltGlyphItemElement.prototype = new SVGElement();
6707 function SVGGlyphRefElement() {
6708 SVGElement.apply(this, arguments);
6709 /*DOMString*/ this.glyphRef;
6710 /*DOMString*/ this.format;
6715 SVGURIReference.apply(this, arguments);
6718 SVGGlyphRefElement.constructor = SVGElement;
6719 SVGGlyphRefElement.prototype = new SVGElement();
6721 function SVGPaint() {
6722 SVGColor.apply(this, arguments);
6727 t.constructor = SVGColor;
6728 t.prototype = new SVGColor();
6730 /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN = 0;
6731 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR = 1;
6732 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
6733 /*unsigned short*/ t.SVG_PAINTTYPE_NONE = 101;
6734 /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR = 102;
6735 /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE = 103;
6736 /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
6737 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR = 105;
6738 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
6739 /*unsigned short*/ t.SVG_PAINTTYPE_URI = 107;
6740 /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
6741 /*readonly DOMString*/ t.prototype.uri = null;
6742 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
6743 this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
6745 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
6746 if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
6747 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
6750 this.paintType = paintType;
6751 if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
6752 paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
6754 this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
6756 // raises( SVGException );
6760 function SVGMarkerElement(){
6761 SVGElement.apply(this);
6762 var sl = SVGAnimatedLength;
6763 /*readonly SVGAnimatedLength*/ this.refX = new sl();
6764 /*readonly SVGAnimatedLength*/ this.refY = new sl();
6765 /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
6766 /*readonly SVGAnimatedLength*/ this.markerWidth = new sl();
6767 /*readonly SVGAnimatedLength*/ this.markerHeight = new sl();
6769 /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
6770 /*readonly SVGAnimatedAngle*/ this.orientAngle = new SVGAnimatedAngle();
6771 //SVGFitToViewBoxのインターフェースを用いる
6772 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
6773 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
6774 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
6778 // Marker Unit Types
6779 /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN = 0;
6780 /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
6781 /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH = 2;
6782 // Marker Orientation Types
6783 /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN = 0;
6784 /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO = 1;
6785 /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE = 2;
6786 t.constructor = SVGElement;
6787 t.prototype = new SVGElement();
6788 /*void*/ t.prototype.setOrientToAuto = function() {
6791 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
6794 })(SVGMarkerElement);
6795 function SVGColorProfileElement() {
6796 SVGElement.apply(this);
6797 /*DOMString*/ this._local;
6798 // raises DOMException on setting
6799 // (NOTE: is prefixed by "_"
6800 // as "local" is an IDL keyword. The
6801 // prefix will be removed upon processing)
6802 /*DOMString*/ this.name;
6803 /*unsigned short*/ this.renderingIntent;
6804 SVGURIReference.apply(this, arguments);
6807 SVGColorProfileElement.constructor = SVGElement;
6808 SVGColorProfileElement.prototype = new SVGElement();
6810 function SVGColorProfileRule() {
6811 SVGCSSRule.apply(this);
6812 /*DOMString*/ this.src;
6813 /*DOMString*/ this.name;
6814 /*unsigned short*/ this.renderingIntent;
6817 SVGColorProfileRule.constructor = SVGCSSRule;
6818 SVGColorProfileRule.prototype = new SVGCSSRule();
6820 function SVGGradientElement() {
6821 SVGElement.apply(this);
6822 SVGURIReference.apply(this);
6823 /*readonly SVGAnimatedEnumeration*/ this.gradientUnits = new SVGAnimatedEnumeration();
6824 /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
6825 /*readonly SVGAnimatedEnumeration*/ this.spreadMethod = new SVGAnimatedEnumeration();
6826 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6827 var grad = evt.target,
6829 t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
6831 href, stops, length,
6836 if (!ele || !grad) { //まだ、path要素などが設定されていない場合
6837 grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
6840 if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
6841 grad2 = grad._instance;
6843 stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
6845 ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
6848 length = stops.length;
6849 for (var i = 0; i < length; ++i) {
6851 sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
6852 ci = sstyle.getPropertyCSSValue("stop-color");
6853 if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
6854 /*再度、設定。css.jsのsetPropertyを参照*/
6855 sstyle.setProperty("color", sstyle.getPropertyValue("color"));
6857 color[i] = "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
6858 colors[i] = stop.offset.baseVal + " " + color[i];
6859 opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
6861 ele["method"] = "none";
6862 ele["color"] = color[0];
6863 ele["color2"] = color[length-1];
6864 ele["colors"] = colors.join(",");
6865 // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
6866 ele["opacity"] = opacity[length-1]+ "";
6867 ele["o:opacity2"] = opacity[0]+ "";
6868 /*SVGRadialGradientElementインターフェースで利用する*/
6869 grad._color = color;
6870 var gt = grad2.getAttributeNS(null, "gradientTransform");
6872 grad.setAttributeNS(null, "transform", gt);
6874 grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
6878 SVGGradientElement.constructor = SVGElement;
6879 SVGGradientElement.prototype = new SVGElement();
6880 // Spread Method Types
6881 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
6882 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD = 1;
6883 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
6884 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT = 3;
6886 function SVGLinearGradientElement() {
6887 SVGGradientElement.apply(this);
6888 var sl = SVGAnimatedLength;
6889 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
6890 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
6891 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
6892 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
6894 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6895 var grad = evt.target, ele = evt._tar, angle = 270;
6896 if (!!!ele) { //まだ、path要素などが設定されていない場合
6899 var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
6900 var fontSize = parseFloat(style.getPropertyValue("font-size"));
6901 grad.x1.baseVal._emToUnit(fontSize);
6902 grad.y1.baseVal._emToUnit(fontSize);
6903 grad.x2.baseVal._emToUnit(fontSize);
6904 grad.y2.baseVal._emToUnit(fontSize);
6905 angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
6909 ele.setAttribute("type", "gradient");
6910 ele.setAttribute("angle", angle + "");
6911 evt = ele = grad = angle = style = fontSize = void 0;
6915 SVGLinearGradientElement.constructor = SVGGradientElement;
6916 SVGLinearGradientElement.prototype = new SVGGradientElement();
6918 function SVGRadialGradientElement(_doc) {
6919 SVGGradientElement.apply(this);
6920 var sl = SVGAnimatedLength;
6921 /*readonly SVGAnimatedLength*/ this.cx = new sl();
6922 /*readonly SVGAnimatedLength*/ this.cy = new sl();
6923 /*readonly SVGAnimatedLength*/ this.r = new sl();
6924 /*readonly SVGAnimatedLength*/ this.fx = new sl();
6925 /*readonly SVGAnimatedLength*/ this.fy = new sl();
6927 this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
6928 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
6929 var grad = evt.target,
6931 tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
6932 if (!!!ele) { //まだ、path要素などが設定されていない場合
6935 ele.setAttribute("type", "gradientTitle");
6936 ele.setAttribute("focus", "100%");
6937 ele.setAttribute("focusposition", "0.5 0.5");
6938 if (tar.localName === "rect") {
6939 /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
6940 *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
6942 var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
6943 fontSize = parseFloat(style.getPropertyValue("font-size"));
6944 grad.cx.baseVal._emToUnit(fontSize);
6945 grad.cy.baseVal._emToUnit(fontSize);
6946 grad.r.baseVal._emToUnit(fontSize);
6947 grad.fx.baseVal._emToUnit(fontSize);
6948 grad.fy.baseVal._emToUnit(fontSize);
6949 var cx = grad.cx.baseVal.value,
6950 cy = grad.cy.baseVal.value,
6951 r = grad.r.baseVal.value,
6955 var tarrect = tar.getBBox(),
6956 vi = tar.ownerDocument.documentElement.viewport,
6961 units = grad.getAttributeNS(null, "gradientUnits");
6962 if (!units || units === "objectBoundingBox") {
6963 //%の場合は小数点に変換(10% -> 0.1)
6964 cx = cx > 1 ? cx/100 : cx;
6965 cy = cy > 1 ? cy/100 : cy;
6966 r = r > 1 ? r/100 : r;
6967 //要素の境界領域を求める(四隅の座標を求める)
6970 wid = tarrect.width,
6971 hei = tarrect.height;
6976 nx = ny = wid = hei = void 0;
6978 var matrix = tar.getScreenCTM().multiply(grad.getCTM());
6983 var rrx = rx * 0.55228,
6985 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"];
6986 for (var i = 0, lili = list.length; i < lili;) {
6987 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
6991 var p = grad.ownerDocument.documentElement.createSVGPoint();
6992 p.x = parseFloat(list[i]);
6993 p.y = parseFloat(list[i+1]);
6994 var pmt = p.matrixTransform(matrix);
6995 list[i] = mr(pmt.x);
6997 list[i] = mr(pmt.y);
7001 var ellipse = list.join(" "),
7002 outline = _doc.getElementById("_NAIBU_outline"),
7003 background = _doc.createElement("div"),
7004 bstyle = background.style;
7005 bstyle.position = "absolute";
7006 bstyle.display = "inline-block";
7009 bstyle.textAlign = "left";
7011 bstyle.left = "0px";
7012 bstyle.width = w+ "px";
7013 bstyle.height = h+ "px";
7014 outline.appendChild(background);
7015 bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
7016 background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
7017 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>',
7018 data = tar._tar.path.value;
7019 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>';
7020 background.filters[0].apply();
7021 background.innerHTML = circle;
7022 background.filters[0].play();
7023 tar._tar.parentNode.insertBefore(background, tar._tar);
7024 tar._tar.filled = "false";
7025 ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
7026 } else if (!ele.parentNode){
7027 tar._tar.appendChild(ele);
7029 evt = tar = ele = gard = void 0;
7033 SVGRadialGradientElement.constructor = SVGGradientElement;
7034 SVGRadialGradientElement.prototype = new SVGGradientElement();
7036 function SVGStopElement() {
7037 SVGElement.apply(this, arguments);
7038 /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
7039 this.addEventListener("DOMAttrModified", function(evt) {
7040 if (evt.attrName === "offset") {
7041 evt.target.offset.baseVal = parseFloat(evt.newValue);
7047 SVGStopElement.constructor = SVGElement;
7048 SVGStopElement.prototype = new SVGElement();
7050 function SVGPatternElement() {
7051 SVGElement.apply(this);
7052 var sl = SVGAnimatedLength;
7053 /*readonly SVGAnimatedEnumeration*/ this.patternUnits = new SVGAnimatedEnumeration();
7054 /*readonly SVGAnimatedEnumeration*/ this.patternContentUnits = new SVGAnimatedEnumeration();
7055 /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
7056 /*readonly SVGAnimatedLength*/ this.x = new sl();
7057 /*readonly SVGAnimatedLength*/ this.y = new sl();
7058 /*readonly SVGAnimatedLength*/ this.width = new sl();
7059 /*readonly SVGAnimatedLength*/ this.height = new sl();
7061 SVGURIReference.apply(this, arguments);
7062 //SVGFitToViewBoxのインターフェースを用いる
7063 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7064 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7065 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7068 SVGPatternElement.constructor = SVGElement;
7069 SVGPatternElement.prototype = new SVGElement();
7071 function SVGClipPathElement() {
7072 SVGElement.apply(this, arguments);
7073 /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
7076 SVGClipPathElement.constructor = SVGElement;
7077 SVGClipPathElement.prototype = new SVGElement();
7079 function SVGMaskElement() {
7080 SVGElement.apply(this);
7081 var sl = SVGAnimatedLength;
7082 /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
7083 /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
7084 /*readonly SVGAnimatedLength*/ this.x = new sl();
7085 /*readonly SVGAnimatedLength*/ this.y = new sl();
7086 /*readonly SVGAnimatedLength*/ this.width = new sl();
7087 /*readonly SVGAnimatedLength*/ this.height = new sl();
7091 SVGMaskElement.constructor = SVGElement;
7092 SVGMaskElement.prototype = new SVGElement();
7094 function SVGFilterElement() {
7095 SVGElement.apply(this);
7096 var sl = SVGAnimatedLength;
7097 /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
7098 /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
7099 /*readonly SVGAnimatedLength*/ this.x = new sl();
7100 /*readonly SVGAnimatedLength*/ this.y = new sl();
7101 /*readonly SVGAnimatedLength*/ this.width = new sl();
7102 /*readonly SVGAnimatedLength*/ this.height = new sl();
7104 /*readonly SVGAnimatedInteger*/ this.filterResX = new SVGAnimatedInteger();
7105 /*readonly SVGAnimatedInteger*/ this.filterResY = new SVGAnimatedInteger();
7106 SVGURIReference.apply(this, arguments);
7107 //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
7110 SVGFilterElement.constructor = SVGElement;
7111 SVGFilterElement.prototype = new SVGElement();
7113 function SVGFilterPrimitiveStandardAttributes(ele) {
7114 SVGStylable.apply(this, arguments);
7116 var sl = SVGAnimatedLength;
7117 /*readonly SVGAnimatedLength*/ this.x = new sl();
7118 /*readonly SVGAnimatedLength*/ this.y = new sl();
7119 /*readonly SVGAnimatedLength*/ this.width = new sl();
7120 /*readonly SVGAnimatedLength*/ this.height = new sl();
7121 /*readonly SVGAnimatedString*/ this.result = new sl();
7124 SVGFilterPrimitiveStandardAttributes.constructor = SVGStylable;
7125 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
7127 function SVGFEBlendElement() {
7128 SVGElement.apply(this, arguments);
7129 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7130 /*readonly SVGAnimatedString*/ this.in2 = new SVGAnimatedString();
7131 /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
7132 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7135 SVGFEBlendElement.constructor = SVGElement;
7136 SVGFEBlendElement.prototype = new SVGElement();
7138 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN = 0;
7139 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL = 1;
7140 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
7141 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN = 3;
7142 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN = 4;
7143 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN = 5;
7145 function SVGFEGaussianBlurElement() {
7146 SVGElement.apply(this, arguments);
7147 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
7148 /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
7149 /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
7150 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
7153 SVGFEGaussianBlurElement.constructor = SVGElement;
7154 SVGFEGaussianBlurElement.prototype = new SVGElement();
7155 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
7159 function SVGCursorElement() {
7160 SVGElement.apply(this, arguments);
7161 /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
7162 /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
7163 SVGURIReference.apply(this, arguments);
7166 SVGCursorElement.constructor = SVGElement;
7167 SVGCursorElement.prototype = new SVGElement();
7169 function SVGAElement(_doc) {
7170 SVGElement.apply(this);
7171 this._tar = _doc.createElement("a");
7173 /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
7174 this.target.baseVal = "_self";
7175 this.addEventListener("DOMAttrModified", function(evt){
7176 var tar = evt.target;
7177 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7180 if (evt.attrName === "target") {
7181 tar.target.baseVal = evt.newValue;
7182 } else if (evt.attrName === "xlink:title") {
7183 tar._tar.setAttribute("title", evt.newValue);
7187 this.addEventListener("DOMNodeInserted", function(evt){
7188 var tar = evt.target;
7189 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7192 if (tar.nextSibling) {
7193 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
7194 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
7196 } else if (!!tar.parentNode._tar){
7197 tar.parentNode._tar.appendChild(tar._tar);
7199 var txts = tar._tar.style;
7200 txts.cursor = "hand";
7203 txts.textDecoration = "none";
7205 var t = tar.target.baseVal;
7207 if (t === "_blank") {
7210 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
7211 tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
7214 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7215 var tar = evt.target;
7216 if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
7217 var txts = tar._tar.style;
7218 txts.cursor = "hand";
7219 txts.textDecoration = "none";
7225 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7226 var tar = evt.target;
7227 tar._tar.setAttribute("target", tar.target.baseVal);
7228 if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
7229 tar.addEventListener("click", function(evt){
7230 var tar = evt.target,
7233 sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
7234 if (tar.target.baseVal === "_self") {
7235 nd = tar.ownerDocument._iframe;
7236 nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
7237 ob = nd.nextSibling;
7238 if (ob && (ob.tagName === "OBJECT")) {
7239 nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
7240 nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
7241 nd.parentNode.removeChild(ob);
7243 ob = NAIBU._search([nd.previousSibling]);
7244 nd.parentNode.removeChild(nd);
7246 sd.appendChild(sd.lastChild.firstChild);
7247 while (sd.firstChild !== sd.lastChild) { //オブジェクト要素以外を除去
7248 sd.removeChild(sd.firstChild);
7250 ob = NAIBU._search([sd.lastChild]);
7252 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
7253 evt.preventDefault();
7255 _init: (function (ob) {
7257 document.title = ob.getSVGDocument().title;
7263 sd = ob = nd = void 0;
7268 SVGURIReference.apply(this, arguments);
7271 SVGAElement.constructor = SVGElement;
7272 SVGAElement.prototype = new SVGElement();
7274 function SVGViewElement() {
7275 SVGElement.apply(this, arguments);
7276 /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
7277 //SVGFitToViewBoxのインターフェースを用いる
7278 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
7279 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
7280 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
7283 SVGViewElement.constructor = SVGElement;
7284 SVGViewElement.prototype = new SVGElement();
7286 function SVGScriptElement() {
7287 SVGElement.apply(this);
7288 /*DOMString*/ this.type;
7289 SVGURIReference.apply(this, arguments);
7290 this.addEventListener("DOMAttrModified", function(evt){
7291 if (evt.attrName === "type") {
7292 evt.target.type = evt.newValue;
7296 this.addEventListener("S_Load", function(evt){
7297 var tar = evt.target, script = tar._text;
7298 var tod = tar.ownerDocument;
7299 NAIBU._temp_doc = tod;
7300 script = script.replace(/function\s+(\w+)/g, "$1 = function");
7301 script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
7304 } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
7305 script = script.replace(/function\(document\){/, "function() {");
7308 tar = evt = script = void 0;
7310 this.addEventListener("DOMNodeInserted", function(evt){
7311 var tar = evt.target;
7312 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7313 if (tar.nodeName === "#cdata-section") {
7314 evt.currentTarget._text = tar.data;
7318 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7319 var tar = evt.target;
7320 if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7321 var evtt = tar.ownerDocument.createEvent("SVGEvents");
7322 evtt.initEvent("S_Load", false, false);
7323 evt.currentTarget.dispatchEvent(evtt);
7330 SVGScriptElement.constructor = SVGElement;
7331 SVGScriptElement.prototype = new SVGElement();
7333 function SVGEvent() {
7334 Event.apply(this, arguments);
7337 SVGEvent.constructor = Event;
7338 SVGEvent.prototype = new Event();
7340 function SVGZoomEvent() {
7341 UIEvent.apply(this, arguments);
7342 /*readonly SVGRect*/ this.zoomRectScreen = new SVGRect();
7343 /*readonly float*/ this.previousScale = 1;
7344 /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
7345 /*readonly float*/ this.newScale = 1;
7346 /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
7349 SVGZoomEvent.constructor = UIEvent;
7350 SVGZoomEvent.prototype = new UIEvent();
7352 function SVGAnimationElement(es) {
7356 SVGElement.apply(this);
7357 /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
7358 *styleのsetPropertyメソッドを無効化させておく必要がある
7360 this.style.setProperty = function(){};
7362 /*readonly SVGElement*/ this.targetElement;
7363 this._beginValue = "0ms";
7364 this._endValue = null;
7365 this._currentFrame = 0;
7366 this._currentCount = 0;
7367 /*_maxCountはrepeatCount属性で指定された数値
7368 *_maxDurはrepeatDur属性で指定された数値
7372 this._isRepeat = false;
7373 /*_simpleDurationプロパティは
7374 *dur属性の数値を収納しておく。属性がなければnullのまま
7376 this._simpleDuration = null;
7377 /*_beginと_endプロパティはミリ秒数を収納する。リピート時に書き換えられることがある。
7378 *_beginはアニメ開始時の秒数。_endはアニメ終了時の秒数。
7379 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
7383 this._from = this._to = this._values = this._by = null;
7384 this._keyTimes = null;
7385 this.addEventListener("beginEvent", function(evt) {
7386 var tar = evt.target;
7387 if (!tar.isRepeat) {
7388 tar.endElementAt(tar.getSimpleDuration());
7390 tar.beginElementAt(tar.getSimpleDuration());
7391 if (tar.getCurrentTime() !== 0) {
7392 var ttd = tar.ownerDocument, evt = ttd.createEvent("TimeEvents");
7393 tar._currentCount++;
7394 evt.initTimeEvent("repeatEvent", ttd.defaultView, tar._currentCount);
7395 tar.dispatchEvent(evt);
7399 this.addEventListener("DOMAttrModified", function(evt){
7400 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7403 var tar = evt.target, name = evt.attrName;
7404 if (name === "begin") {
7405 tar._beginValue = evt.newValue;
7406 } else if (name === "end") {
7407 tar._endValue = evt.newValue;
7408 } else if (name === "dur") {
7409 tar._simpleDuration = tar._getOffset(evt.newValue);
7410 } else if (name === "repeatCount") {
7411 tar._maxCount = parseFloat(evt.newValue);
7412 tar._isRepeat = true;
7413 } else if (name === "repeatDur") {
7414 tar._maxDur = parseFloat(evt.newValue);
7415 tar._isRepeat = true;
7416 } else if (name === "from") {
7417 tar._from = evt.newValue;
7418 } else if (name === "to") {
7419 tar._to = evt.newValue;
7420 } else if (name === "values") {
7421 tar._values = evt.newValue.split(";");
7422 } else if (name === "by") {
7423 tar._by = evt.newValue;
7424 } else if (name === "keyTimes") {
7425 var s = evt.newValue.split(";");
7426 tar._keyTimes = []; //_keyTimesプロパティを初期化
7427 for (var i=0;i<s.length;++i) {
7428 tar._keyTimes[i] = parseFloat(s[i]);
7434 this.addEventListener("DOMNodeInserted", function(evt){
7435 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7438 var tar = evt.target;
7439 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7440 var tar = evt.target;
7441 /*以降の場合分けルールに関しては、下記の仕様を参照
7442 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
7445 } else if (tar._from && tar._to) {
7446 tar._values = [tar._from, tar._to];
7447 } else if (tar._from && tar._by) {
7448 var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
7449 tar._values = [tar._from, n+tanni[0]];
7450 } else if (tar._to) {
7451 tar._values = [null, tar._to];
7452 } else if (tar._by) {
7453 tar._values = [null, null, tar._by];
7454 } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
7455 /*アニメーションの効果が出ないように調整する
7458 *>if none of the from, to, by or values attributes are specified, the animation will have no effect
7459 *「3.2.2. Animation function values」より引用
7460 *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
7464 if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
7465 tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").substring(1))
7467 tar.targetElement = tar.parentNode;
7469 tar._eventSync(tar._beginValue,
7470 (function(te, offse, ta, t) {
7471 ta.addEventListener( t.match(te._eventRegExp)[0],
7474 te.beginElementAt(offse);
7476 te._begin = NAIBU.Time.currentFrame;
7481 }), "beginElementAt");
7482 if (tar._endValue) {
7483 tar._eventSync(tar._endValue,
7484 (function(te, offse, ta, t) {
7485 ta.addEventListener( t.match(te._eventRegExp)[0],
7487 te.endElementAt(offse);
7489 }), "endElementAt");
7495 this.addEventListener("repeatEvent", function(evt) {
7496 var tar = evt.target;
7497 if ((tar._currentCount >= tar._maxCount) || (tar.getCurrentTime() >= (tar._maxDur+tar.getStartTime()))) {
7498 tar._isRepeat = false;
7503 SVGAnimationElement.constructor = SVGElement;
7504 SVGAnimationElement.prototype = new SVGElement();
7505 /*以下のメソッド(beginElementなど)については、
7506 *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
7508 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
7509 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
7510 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
7511 this.dispatchEvent(evt);
7513 /*void*/ SVGAnimationElement.prototype.endElement = function() {
7514 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
7515 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
7516 this.dispatchEvent(evt);
7518 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
7519 var ntc = this.ownerDocument.documentElement.getCurrentTime();
7520 this._begin = offset + ntc;
7522 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
7523 var ntc = this.ownerDocument.documentElement.getCurrentTime();
7524 this._end = offset + ntc;
7526 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
7527 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?/;
7528 SVGAnimationElement.prototype._unit = {
7535 * どれだけズレの時間があるかを計測するメソッド
7536 *tに数値が使われていないときは0を返す
7537 *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
7538 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
7539 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
7540 ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
7542 SVGAnimationElement.prototype._getOffset = function(/*string*/ t) {
7543 var n = parseFloat(t.match(this._timeRegExp));
7544 if (!isNaN(n) && RegExp.$1) {
7545 var offset = n * this._unit[RegExp.$1]
7546 } else if (!isNaN(n)) {
7555 *イベントがある場合とない場合とで、別々の処理に分けるメソッド
7557 SVGAnimationElement.prototype._eventSync = function(/*string*/ t, /*function*/ f, /*string*/ methodName) {
7558 var offset = this._getOffset(t);
7559 this._begin = NAIBU.Time.Max;
7560 if ( /(mouse|activ|click|begin|end)/.test(t) ) { //イベントがある場合
7562 if ( /([^;]+)\.\D/.test(t) ) {
7563 tar = this.ownerDocument.getElementById(RegExp.$1);
7565 tar = this.targetElement;
7567 if (!offset && offset !== 0) {
7568 offset = NAIBU.Time.Max;
7570 f(this, offset, tar, t);
7571 } else if (!offset && (t !== "undefined") && (offset !== 0)) {
7574 this[methodName](offset);
7577 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
7578 if (!!this._begin || (this._begin === 0)) {
7579 return (this._begin);
7581 throw new DOMException(DOMException.INVALID_STATE_ERR);
7584 /*getCurrentTimeメソッド
7586 *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
7588 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
7589 return (this._currentFrame * 125 * 0.8);
7591 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
7592 if (!!!this._simpleDuration && !!!this._end && (this._simpleDuration !== 0)) {
7593 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
7594 } else if (!!this._simpleDuration && !!this._end) {
7595 var s = (this._simpleDuration > this._end - this._begin) ? this._end - this._begin : this._simpleDuration;
7597 var s = !!this._end ? this._end - this._begin : this._simpleDuration;
7601 //raises( DOMException );
7605 start : function() {
7606 if (NAIBU.Clip.length > 0) {
7607 screen.updateInterval = 42; //24fpsとして描画処理
7608 window.onscroll = function () {
7609 screen.updateInterval = 0;
7610 screen.updateInterval = 42;
7612 NAIBU.stop = setInterval( (function() {
7614 var ntc = NAIBU.Time.currentFrame++;
7615 var nc = NAIBU.Clip;
7616 var s = ntc * 100; //フレーム数ntcをミリ秒数sに変換
7617 if (ntc > NAIBU.Time.Max) {
7618 clearInterval(NAIBU.stop);
7620 for (var i=0,ncli=nc.length;i<ncli;++i) {
7622 nci.ownerDocument.documentElement.setCurrentTime(s);
7623 if ("_begin" in nci) {
7624 if (nci.getStartTime() <= s) {
7625 if (nci.getCurrentTime() === 0) {
7628 nci._currentFrame++;
7630 if (nci._end && (nci._end <= s) && (nci.getCurrentTime() !== 0)) {
7632 nci._frame && nci._frame();
7633 nci._currentFrame = 0;
7636 } else if (!!nci._frame) {
7649 window.onscroll = function () {
7650 screen.updateInterval = 0;
7651 window.onscroll = NAIBU.emptyFunction;
7658 function SVGAnimateElement(){
7659 SVGAnimationElement.apply(this);
7660 /*NAIBU.Clipについては、NAIBU.Timeで使う
7661 *くわしくはNAIBU.Time.start関数のコードを参照
7663 NAIBU.Clip[NAIBU.Clip.length] = this;
7665 *機械が理解できる形で保管されているvalueの値の配列リスト
7667 this._valueList = [];
7668 this._isDiscrete = false;
7669 this.addEventListener("DOMAttrModified", function(evt){
7670 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7673 if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
7674 evt.target._isDiscrete = true;
7677 this.addEventListener("DOMNodeInserted", function(evt){
7678 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7681 var tar = evt.target;
7682 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7683 var tar = evt.target,
7684 attrName = tar.getAttributeNS(null, "attributeName"),
7685 ttr = tar.targetElement,
7686 tta = ttr[attrName];
7687 /*tar.valuesのリスト: ["12px", "13px"]
7688 *tar._valueList: [(new SVGPoint()), (new SVGPoint())]
7689 * tar.valuesを機械が理解できるように変換したものがtar._valueList
7690 *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
7692 var vi = ttr.cloneNode(false);
7693 if (!tar._values[0]) { //to属性か、by属性が設定されている場合
7694 var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
7695 tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
7696 if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
7697 var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
7698 tar._values[1] = v2 + tanni[0];
7700 v2 = tanni = void 0;
7703 if ("animatedPoints" in ttr) {
7704 ttr.animatedPoints = vi.points;
7705 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7706 var vir = ttr.cloneNode(false);
7708 vir.setAttributeNS(null, "points", tav[i]);
7709 tar._valueList[tar._valueList.length] = vir.points;
7712 tta.animVal = vi[attrName].baseVal;
7713 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7714 var vir = ttr.cloneNode(false); //仮の要素
7716 vir.setAttributeNS(null, attrName, tav[i]);
7717 tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
7719 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7720 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7721 if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
7722 tar._valueList[i] = new SVGPaint();
7723 tar._valueList[i].setPaint(1, null, tav[i], null)
7725 tar._valueList[i] = parseFloat(tav[i]);
7728 } else if ("normalizedPathSegList" in ttr) {
7729 ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
7730 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7731 var vir = ttr.cloneNode(false);
7733 vir.setAttributeNS(null, "d", tav[i]);
7734 tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
7740 evt = tta = vir = vi = void 0;
7743 this.addEventListener("beginEvent", function(evt) {
7744 var tar = evt.target;
7745 var attrName = tar.getAttributeNS(null, "attributeName"), newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName);
7746 var ttr = tar.targetElement, tta = ttr[attrName];
7747 tar._frame = function() {
7748 var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length-1, tg = tar.getCurrentTime();
7749 if ((n !== -1) && (d !== 0) && (tg <= d)) {
7750 if (tar._isDiscrete) {
7751 ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
7753 var ii = Math.floor((tg*n) / d);
7754 if (ii === n) { //iiが境い目のときは、n-2を適用
7760 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
7762 * 参照:アニメーションサンドイッチモデル
7763 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
7764 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
7766 var evt = tar.ownerDocument.createEvent("MutationEvents");
7767 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7768 if (tar._keyTimes) {
7769 var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
7770 var ti = tar._keyTimes[ii];
7772 var di = d / n; //keyTimesがなければ均等に時間を配分しておく
7775 if ("animatedPoints" in ttr) {
7776 var base = ttr.points;
7777 ttr.points = ttr.animatedPoints;
7778 ttr.dispatchEvent(evt);
7779 ttr.animatedPoints = ttr.points;
7782 var base = tta.baseVal, tanim = tta.animVal;
7783 var v1 = tar._valueList[ii].value;
7784 /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
7785 * 3.4.2 Specifying the simple animation function f(t)
7786 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
7788 if (!tar._isDiscrete) {
7789 var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
7793 tanim.newValueSpecifiedUnits(base.unitType, v);
7794 tta.baseVal = tanim;
7796 ttr.dispatchEvent(evt);
7797 /*変化値はanimValプロパティに収納しておき、
7798 *変化する前の、元の値はbaseValプロパティに再び収納しておく
7800 tta.animVal = tta.baseVal;
7803 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7805 var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
7806 if (!tar._isDiscrete) {
7807 var v = v1 + (v2-v1) * (tg-ti*d) / di;
7811 } else if ("normalizedPathSegList" in ttr) {
7812 var base = ttr.normalizedPathSegList;
7813 ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
7814 ttr.dispatchEvent(evt);
7815 ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
7816 ttr.normalizedPathSegList = base;
7818 evt = v1 = v2 = v = d = n = ii = tg = void 0;
7822 this.addEventListener("endEvent", function(evt) {
7823 var tar = evt.target, fill = tar.getAttributeNS(null, "fill");
7824 if (!fill || (fill === "remove")) {
7825 var evt = tar.ownerDocument.createEvent("MutationEvents");
7826 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7827 tar.targetElement.dispatchEvent(evt);
7831 this.addEventListener("repeatEvent", function(evt) {
7832 var tar = evt.target;
7836 SVGAnimateElement.constructor = SVGAnimationElement;
7837 SVGAnimateElement.prototype = new SVGAnimationElement(1);
7839 function SVGSetElement(){
7840 SVGAnimationElement.apply(this);
7841 NAIBU.Clip[NAIBU.Clip.length] = this;
7843 this.addEventListener("DOMAttrModified", function(evt) {
7844 var tar = evt.target, name = evt.attrName;
7845 if (name === "to") {
7846 tar._to = evt.newValue;
7848 tar = name = void 0;
7850 this.addEventListener("beginEvent", function(evt) {
7851 var tar = evt.target;
7852 if (tar.targetElement) {
7853 var attrName = tar.getAttributeNS(null, "attributeName"),
7854 newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
7855 tta = tar.targetElement[attrName];
7856 if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
7857 var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
7858 style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
7861 var base = tta.baseVal;
7862 if (base instanceof SVGLength) {
7863 tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
7864 } else if (base instanceof SVGRect) {
7865 tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
7867 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
7869 * 参照:アニメーションサンドイッチモデル
7870 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
7871 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
7873 var evt = tar.ownerDocument.createEvent("MutationEvents");
7874 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
7875 tar.targetElement.dispatchEvent(evt);
7877 /*変化値はanimValプロパティに収納しておき、
7878 *変化する前の、元の値はbaseValプロパティに再び収納しておく
7880 tta.animVal = tta.baseVal;
7884 evt = tar = attrName = void 0;
7886 this.addEventListener("endEvent", function(evt) {
7887 var tar = evt.target,
7888 fill = tar.getAttributeNS(null, "fill");
7889 if (!fill || (fill === "remove")) {
7890 var attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
7891 tar.targetElement.style.setProperty(attrName, style.getPropertyValue(attrName), null);
7892 var evtt = tar.ownerDocument.createEvent("MutationEvents");
7893 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7894 tar.targetElement.dispatchEvent(evtt);
7895 attrName = style = evtt = void 0;
7897 tar = fill = void 0;
7899 this.addEventListener("repeatEvent", function(evt) {
7900 var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
7904 SVGSetElement.constructor = SVGAnimationElement;
7905 SVGSetElement.prototype = new SVGAnimationElement(1);
7907 function SVGAnimateMotionElement(){
7908 SVGAnimationElement.apply(this);
7909 NAIBU.Clip[NAIBU.Clip.length] = this;
7910 this.addEventListener("DOMAttrModified", function(evt){
7911 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7914 var tar = evt.target,
7915 name = evt.attrName;
7916 if (name === "path") {
7917 var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
7918 d.setAttributeNS(null, "d", evt.newValue);
7923 this.addEventListener("DOMNodeInserted", function(evt){
7924 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
7927 var tar = evt.target;
7928 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
7932 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
7935 vlist[i] = [+ti[0], +ti[1]];
7937 tar._valueList = vlist;
7941 this.addEventListener("beginEvent", function(evt) {
7942 var tar = evt.target,
7943 trans = tar.targetElement.transform;
7944 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
7947 trans.animVal = new SVGTransformList();
7948 if (trans.baseVal.numberOfItems !== 0) {
7949 trans.baseVal.consolidate();
7950 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
7952 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
7954 tar._frame = function() {
7957 tgsd = _tar.getSimpleDuration(),
7959 tg = _tar.getCurrentTime(),
7965 if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
7966 var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
7967 p = tpn.getPointAtLength(st),
7968 trans = _tar.targetElement.transform;
7969 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
7970 var base = trans.baseVal;
7971 trans.baseVal = trans.animVal;
7972 _tar.targetElement._cacheMatrix = null;
7973 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
7974 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
7975 _tar.targetElement.dispatchEvent(evtt);
7976 trans.baseVal = base;
7977 evtt = base = trans = st = p = void 0;
7978 } else if (tar._valueList) {
7979 var total = 0, //totalは総距離
7980 st = 0, //stは現在にいたるまでの距離
7981 tav = tar._valueList,
7983 if ((n !== -1) && (d !== 0) && (tg <= d)) {
7984 ii = Math.floor((tg*n) / d);
7985 if (ii === n) { //iiが境い目のときは、n-2を適用
7991 for (var i=1, tvli=tav.length;i<tvli;i+=2) {
7992 total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
7994 for (var i=1;i<ii;i+=2) {
7995 st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
7997 var p = tar.ownerDocument.documentElement.createSVGPoint(),
7998 trans = _tar.targetElement.transform;
7999 st = (st / total) * d;
8000 p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
8001 p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
8002 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
8003 var base = trans.baseVal;
8004 trans.baseVal = trans.animVal;
8005 _tar.targetElement._cacheMatrix = void 0;
8006 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
8007 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8008 _tar.targetElement.dispatchEvent(evtt);
8009 trans.baseVal = base;
8010 evtt = base = trans = st = p = void 0;
8013 evt = trans = tpn = tgsd = void 0;
8015 this.addEventListener("endEvent", function(evt) {
8016 var tar = evt.target,
8017 trans = tar.targetElement.transform,
8018 fill = tar.getAttributeNS(null, "fill");
8019 if (!fill || (fill === "remove")) {
8020 trans.animVal = trans.baseVal;
8021 var evtt = tar.ownerDocument.createEvent("MutationEvents");
8022 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8023 tar.targetElement.dispatchEvent(evtt);
8025 tar._frame = evt = evtt = void 0;
8027 this.addEventListener("repeatEvent", function(evt) {
8028 var tar = evt.target;
8032 SVGAnimateMotionElement.constructor = SVGAnimationElement;
8033 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
8035 function SVGMPathElement() /* :
8038 SVGExternalResourcesRequired*/ {
8039 SVGElement.apply(this);
8040 SVGURIReference.apply(this);
8043 SVGMPathElement.constructor = SVGElement;
8044 SVGMPathElement.prototype = new SVGElement();
8046 function SVGAnimateColorElement() {
8047 SVGAnimationElement.apply(this);
8048 NAIBU.Clip[NAIBU.Clip.length] = this;
8049 this._valueList = [];
8050 this.addEventListener("DOMNodeInserted", function(evt){
8051 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8054 var tar = evt.target;
8055 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8056 var tar = evt.target,
8057 attrName = tar.getAttributeNS(null, "attributeName"),
8058 ttr = tar.targetElement,
8059 fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
8061 if (!tar._values[0]) {
8062 tar._values[0] = fstyle.getPropertyValue(attrName);
8064 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
8065 var to = new SVGColor();
8066 if (tar._values[i] === "currentColor") {
8067 to.setRGBColor(fstyle.getPropertyValue("color") || "black");
8068 } else if (tar._values[i] === "inherit") {
8069 /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
8070 css = fstyle.getPropertyCSSValue(attrName);
8071 n = css.cssValueType;
8072 css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
8073 to = fstyle.getPropertyCSSValue(attrName);
8074 css.cssValueType = n;
8076 to.setRGBColor(tar._values[i]);
8078 tar._valueList[tar._valueList.length] = to;
8081 tar = ttr = fstyle = css = n = attrName = void 0;
8084 this.addEventListener("beginEvent", function(evt) {
8085 var tar = evt.target,
8086 attrName = tar.getAttributeNS(null, "attributeName"),
8087 style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
8088 fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
8089 tar._frame = function() {
8091 /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
8092 * 3.4.2 Specifying the simple animation function f(t)
8093 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
8095 var d = _tar.getSimpleDuration() * 0.8,
8096 n = _tar._valueList.length - 1,
8097 tg = _tar.getCurrentTime(),
8099 if ((n !== -1) && (d !== 0) && (tg <= d)) {
8100 ii = Math.floor((tg*n) / d);
8101 if (ii === n) { //iiが境い目のときは、n-2を適用
8107 if (tar._keyTimes) {
8108 di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
8109 ti = tar._keyTimes[ii];
8111 di = d / n; //keyTimesがなければ均等に時間を配分しておく
8114 var fc = _tar._valueList[ii].rgbColor,
8115 tc = _tar._valueList[ii+1].rgbColor,
8116 durd = (tg-ti*d) / di,
8117 num = CSSPrimitiveValue.CSS_NUMBER,
8118 fr = fc.red.getFloatValue(num),
8119 fg = fc.green.getFloatValue(num),
8120 fb = fc.blue.getFloatValue(num),
8121 r = fr + (tc.red.getFloatValue(num) - fr) * durd,
8122 g = fg + (tc.green.getFloatValue(num) - fg) * durd,
8123 b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
8124 style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
8125 _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = void 0;
8129 this.addEventListener("endEvent", function(evt) {
8130 var tar = evt.target;
8131 if (!fill || (fill === "remove")) {
8132 var evtt = tar.ownerDocument.createEvent("MutationEvents");
8133 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
8134 tar.targetElement.dispatchEvent(evtt);
8136 tar._frame = evt = evtt = void 0;
8138 this.addEventListener("repeatEvent", function(evt) {
8139 var tar = evt.target;
8143 SVGAnimateColorElement.constructor = SVGAnimationElement;
8144 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
8146 function SVGAnimateTransformElement() {
8147 SVGAnimationElement.apply(this);
8148 NAIBU.Clip[NAIBU.Clip.length] = this;
8149 this.addEventListener("beginEvent", function(evt) {
8150 var tar = evt.target, trans = tar.targetElement.transform;
8151 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
8154 trans.animVal = new SVGTransformList();
8155 if (trans.baseVal.numberOfItems !== 0) {
8156 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
8158 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
8160 this.addEventListener("endEvent", function(evt) {
8161 var tar = evt.target;
8163 this.addEventListener("repeatEvent", function(evt) {
8164 var tar = evt.target;
8168 SVGAnimateTransformElement.constructor = SVGAnimationElement;
8169 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
8171 function SVGFontElement() /*:
8173 SVGExternalResourcesRequired,
8175 SVGElement.apply(this);
8176 /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
8177 /*boolean or number*/ this._isExternal = 0;
8178 this.addEventListener("DOMNodeInserted", function(evt){
8179 var tar = evt.target;
8180 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8183 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
8184 var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
8185 var nefunc = function(evt){
8186 var svg = evt.target;
8188 var familyName = fontFace.getAttributeNS(null, "font-family");
8189 var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
8190 for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
8191 var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
8192 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8193 NAIBU._noie_createFont(ti, _tar, true);
8196 evt = tar = svg = curt = textElments = svgns = _tar = void 0;
8198 if (!fontFace.__isLinked || tar._isExternal) {
8199 tar.ownerDocument.documentElement._svgload_limited = 0;
8200 tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
8206 SVGFontElement.constructor = SVGElement;
8207 SVGFontElement.prototype = new SVGElement();
8209 function SVGGlyphElement() /*:
8212 SVGElement.apply(this);
8215 SVGGlyphElement.constructor = SVGElement;
8216 SVGGlyphElement.prototype = new SVGElement();
8218 function SVGMissingGlyphElement() /*:
8221 SVGElement.apply(this);
8224 SVGMissingGlyphElement.constructor = SVGElement;
8225 SVGMissingGlyphElement.prototype = new SVGElement();
8227 function SVGHKernElement() {
8228 SVGElement.apply(this);
8231 SVGHKernElement.constructor = SVGElement;
8232 SVGHKernElement.prototype = new SVGElement();
8234 function SVGVKernElement() {
8235 SVGElement.apply(this);
8238 SVGVKernElement.constructor = SVGElement;
8239 SVGVKernElement.prototype = new SVGElement();
8241 function SVGFontFaceElement() {
8242 SVGElement.apply(this);
8243 /*boolean(or number)*/ this._isLinked = 0;
8244 this.addEventListener("DOMNodeInserted", function(evt){
8245 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8246 if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
8247 evt.currentTarget._isLinked = 1;
8254 SVGFontFaceElement.constructor = SVGElement;
8255 SVGFontFaceElement.prototype = new SVGElement();
8257 function SVGFontFaceSrcElement() {
8258 SVGElement.apply(this);
8261 SVGFontFaceSrcElement.constructor = SVGElement;
8262 SVGFontFaceSrcElement.prototype = new SVGElement();
8264 function SVGFontFaceUriElement() {
8265 SVGElement.apply(this);
8266 this.addEventListener("DOMNodeInserted", function(evt){
8267 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
8270 evt.target.ownerDocument.documentElement._svgload_limited--
8271 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
8273 this.addEventListener("S_Load", function(evt){
8274 var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
8275 if (tpp.localName === "defs") {
8276 tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
8278 tar._instance._isExternal = 1;
8279 tpp.parentNode.appendChild(tar._instance);
8280 evt = tar = tpp = void 0;
8282 SVGURIReference.apply(this);
8285 SVGFontFaceUriElement.constructor = SVGElement;
8286 SVGFontFaceUriElement.prototype = new SVGElement();
8288 function SVGFontFaceFormatElement() {
8289 SVGElement.apply(this);
8292 SVGFontFaceFormatElement.constructor = SVGElement;
8293 SVGFontFaceFormatElement.prototype = new SVGElement();
8295 function SVGFontFaceNameElement() {
8296 SVGElement.apply(this);
8299 SVGFontFaceNameElement.constructor = SVGElement;
8300 SVGFontFaceNameElement.prototype = new SVGElement();
8302 function SVGDefinitionSrcElement() {
8303 SVGElement.apply(this);
8306 SVGDefinitionSrcElement.constructor = SVGElement;
8307 SVGDefinitionSrcElement.prototype = new SVGElement();
8309 function SVGMetadataElement() {
8310 SVGElement.apply(this);
8313 SVGMetadataElement.constructor = SVGElement;
8314 SVGMetadataElement.prototype = new SVGElement();
8316 function SVGForeignObjectElement() /*:
8320 SVGExternalResourcesRequired,
8323 events::EventTarget*/ {
8324 SVGElement.apply(this);
8325 var sl = SVGAnimatedLength;
8326 /*readonly SVGAnimatedLength*/ this.x = new sl();
8327 /*readonly SVGAnimatedLength*/ this.y = new sl();
8328 /*readonly SVGAnimatedLength*/ this.width = new sl();
8329 /*readonly SVGAnimatedLength*/ this.height = new sl();
8333 SVGForeignObjectElement.constructor = SVGElement;
8334 SVGForeignObjectElement.prototype = new SVGElement();
8337 /*SVGの要素マッピング(DOMでは定められていないが、必須)
8338 *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
8339 *SIEでは軽量化のために、マッピングを用いた
8341 DOMImplementation["http://www.w3.org/2000/svg"] = {
8342 Document: SVGDocument,
8345 path: NAIBU.SVGPathElement,
8346 title: SVGTitleElement,
8347 desc: SVGDescElement,
8348 defs: SVGDefsElement,
8349 linearGradient: SVGLinearGradientElement,
8350 radialGradient: SVGRadialGradientElement,
8351 stop: SVGStopElement,
8352 rect: SVGRectElement,
8353 circle: SVGCircleElement,
8354 ellipse: SVGEllipseElement,
8355 polyline: SVGPolylineElement,
8356 polygon: SVGPolygonElement,
8357 text: SVGTextElement,
8358 tspan: SVGTSpanElement,
8359 image: SVGImageElement,
8360 line: SVGLineElement,
8362 altGlyphDef: SVGAltGlyphDefElement,
8363 altGlyph: SVGAltGlyphElement,
8364 altGlyphItem: SVGAltGlyphItemElement,
8365 animateColor: SVGAnimateColorElement,
8366 animate: SVGAnimateElement,
8367 animateMotion: SVGAnimateMotionElement,
8368 animateTransform:SVGAnimateTransformElement,
8369 clipPath: SVGClipPathElement,
8370 colorProfile: SVGColorProfileElement,
8371 cursor: SVGCursorElement,
8372 definitionSrc: SVGDefinitionSrcElement,
8373 feBlend: SVGFEBlendElement,
8374 feGaussianBlur: SVGFEGaussianBlurElement,
8375 filter: SVGFilterElement,
8376 font: SVGFontElement,
8377 "font-face": SVGFontFaceElement,
8378 "font-face-format":SVGFontFaceFormatElement,
8379 "font-face-name":SVGFontFaceNameElement,
8380 "font-face-src": SVGFontFaceSrcElement,
8381 "font-face-uri": SVGFontFaceUriElement,
8382 foreignObject: SVGForeignObjectElement,
8383 glyph: SVGGlyphElement,
8384 glyphRef: SVGGlyphRefElement,
8385 hkern: SVGHKernElement,
8386 marker: SVGMarkerElement,
8387 mask: SVGMaskElement,
8388 metadata: SVGMetadataElement,
8389 missingGlyph: SVGMissingGlyphElement,
8390 mpath: SVGMPathElement,
8391 script: SVGScriptElement,
8393 style: SVGStyleElement,
8394 "switch": SVGSwitchElement,
8395 textPath: SVGTextPathElement,
8396 tref: SVGTRefElement,
8398 view: SVGViewElement,
8399 vkern: SVGVKernElement,
8400 pattern: SVGPatternElement
8403 NAIBU._fontSearchURI = function(evt){
8404 var doc = evt.target.ownerDocument;
8405 var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
8406 for (var i=0;i<tsrc.length;++i) {
8407 var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
8408 ids = src.split(":")[1],
8409 xmlhttp = NAIBU.xmlhttp;
8410 xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
8411 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
8412 xmlhttp.onreadystatechange = function() {
8413 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
8414 var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
8415 NAIBU._font({document:doce, docu:doc, id:ids});
8416 xmlhttp = doc = doce = void 0;
8422 /*_font関数は、SVGFontで使う*/
8423 NAIBU._font = function (data) {
8424 var doc = data.document, svgns = "http://www.w3.org/2000/svg";
8425 //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
8426 var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
8427 var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
8428 if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
8429 var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
8430 for (var i=0,tli=textElements.length;i<tli;++i) {
8431 var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
8432 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
8433 NAIBU._noie_createFont(ti, font, false);
8437 doc = data = void 0;
8439 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
8440 var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
8441 svgns = "http://www.w3.org/2000/svg",
8442 //isTategakiは縦書きならば真
8443 isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
8444 horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
8445 node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
8446 em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
8447 advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
8448 dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
8449 dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
8450 fontSize = parseFloat(style.getPropertyValue("font-size")),
8452 ds = false, npdlist = ["fill",
8458 "stroke-miterlimit",
8463 if (/a/[-1] === 'a') { //Firefoxならば
8465 } else if (isMSIE || isTategaki) {
8474 if (data !== void 0) { //dataがある場合
8475 var advanceX = [], glyphData = [];
8476 for (var i=0,gli=glyphs.length;i<gli;++i) {
8477 var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
8478 var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
8480 if (orientation === "h") {
8484 isOrientationAttribute = false;
8486 if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
8487 //indexは該当する文字が何番目にあるかの数字
8488 var index = data.indexOf(unicode);
8489 while (index > -1) {
8490 advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
8491 glyphData[index] = glyph.getAttributeNS(null, "d");
8492 index = data.indexOf(unicode, index+1);
8496 for (var i=0,adv=0;i<data.length;++i) {
8497 if (advanceX[i] !== void 0) { //配列に含まれていれば
8498 var path = ti.ownerDocument.createElementNS(svgns, "path");
8499 //advance、すなわち字幅の長さ分、ずらしていく
8500 var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
8503 for (var j=0;j<npdlist.length;++j){
8504 var nj = npdlist[j],
8505 tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
8506 if (nj === "stroke-width") {
8507 tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
8511 path.setAttributeNS(null, nj, tg);
8515 var y= dy + adv*fe, x = dx;
8516 if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
8517 var fms = fontSize / Math.SQRT2;
8525 matrix.e = dx + adv*fe;
8528 path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
8529 path.setAttributeNS(null, "d", glyphData[i]);
8530 ti.parentNode.insertBefore(path, ti);
8535 adv = advanceX = glyphData = void 0;
8536 } else if ("tspan|a".indexOf(node.localName) > -1){
8537 NAIBU._noie_createFont(node, font, isMSIE);
8539 node = node.nextSibling;
8542 var style = ti.ownerDocument.getOverrideStyle(ti, null);
8543 style.setProperty("visibility", "hidden");
8546 ti.setAttributeNS(null, "opacity", "0");
8549 data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
8552 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
8553 *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
8556 var s = new CSSStyleDeclaration(),
8562 for (var i in CSS2Properties) {
8563 if(CSS2Properties.hasOwnProperty(i)) {
8564 t = i.replace(regAZ, "-");
8566 u = "-" +RegExp.$1.toLowerCase();
8570 t = t.replace(regm, u);
8571 s.setProperty(t, CSS2Properties[i]);
8572 slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
8573 slis[n]._isDefault = 1;
8579 slis._fontSize = 12;
8580 CSS2Properties._list = slis;
8581 Document.prototype.defaultView._defaultCSS = slis;
8582 s = n = regAZ = regm = slis =null;
8585 NAIBU.addEvent = function(evt,lis){
8586 if (window.addEventListener) {
8587 window.addEventListener(evt, lis, false);
8588 } else if (window.attachEvent) {
8589 window.attachEvent('on'+evt, lis);
8591 window['on'+evt] = lis;
8599 function unsvgtovml() {
8601 if ("stop" in NAIBU) {
8602 clearInterval(NAIBU.stop);
8604 window.onscroll = NAIBU.emptyFunction;
8605 window.detachEvent("onload", NAIBU._main);
8607 Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
8608 Array = ActiveXObject = void 0;
8614 NAIBU._main = (function() {
8615 stlog = new STLog(false);
8616 var xmlhttp, //XMLHttpオブジェクトを生成
8617 _doc = document; //documentのエイリアスを作成
8619 if (XMLHttpRequest) {
8622 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
8626 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
8633 xmlhttp = new XMLHttpRequest();
8638 NAIBU.xmlhttp = xmlhttp;
8640 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
8642 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
8647 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
8648 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
8649 var st = _doc.createStyleSheet();
8650 var vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
8651 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
8652 + "dn\\:defs{display:none}"
8653 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
8654 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
8656 var ary = _doc.getElementsByTagName("script");
8657 //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
8658 for (var i=0; ary[i]; ++i) {
8661 if (ai.type === "image/svg+xml") {
8663 if (sieb_s && ait.match(/<svg/)) {
8665 ait = ait.replace(/<.+?>/g, "");
8667 ait = ait.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
8670 var gsd = new GetSVGDocument(ai);
8674 responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
8678 var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
8679 ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
8680 var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
8681 ai.parentNode.insertBefore(s,ai);
8689 if (xmlhttp && NAIBU.isMSIE) {
8690 if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
8692 var ob = _doc.getElementsByTagName("object"),
8693 em = _doc.getElementsByTagName("embed"),
8695 _search = function(_ob) {
8697 s || (s = []); //NAIBU._searchで呼ばれたときに必要
8698 _doc || (_doc = document);
8699 for (var i=0;_ob[i];++i) {
8701 s[s.length] = new GetSVGDocument(obi);
8702 ifr = _doc.createElement("iframe");
8703 ifr.style.background = "black";
8704 n = obi.getAttribute("width");
8705 n && ifr.setAttribute("width", n);
8706 n = obi.getAttribute("height");
8707 n && ifr.setAttribute("height", n);
8708 ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
8709 ifr.scrolling = "no";
8710 ifr.frameBorder = "0";
8711 /*iframe要素を使って、描画のプロセスを分離する
8712 *したがって、_docはdocumentとは別のオブジェクトとなる
8714 obi.parentNode.insertBefore(ifr, obi);
8716 i = obi = ifr = _ob = void 0;
8717 return s[s.length-1];
8721 NAIBU._search = _search; //a要素がクリックされたときに使う関数
8722 ob = em = _search = void 0;
8723 for (var i=0;i<s.length;++i) {
8724 if (i < s.length-1) {
8729 s[0]._init(); //初期化作業を開始
8734 var ob = _doc.getElementsByTagName("object");
8735 for (var i=0;i<ob.length;++i) {
8736 if (ob[i].contentDocument) {
8737 NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
8738 } else if (ob[i].getSVGDocument) {
8739 ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
8744 xmlhttp = _doc = void 0;
8746 NAIBU.addEvent("load", NAIBU._main);
8747 NAIBU.utf16 = function ( /*string*/ s) {
8750 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
8751 return s.replace(/%u\w\w\w\w/g, NAIBU.utf16);
8753 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
8754 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
8755 /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
8758 if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
8759 var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
8760 var ob = document.createElement("object");
8761 ob.setAttribute("data",data);
8762 ob.setAttribute("width",w);
8763 ob.setAttribute("height",h);
8764 ob.setAttribute("type","image/svg+xml");
8767 var doc = (new DOMParser()).parseFromString(source, "text/xml");
8768 return (document.importNode(doc.documentElement, true));
8771 NAIBU.addEvent("unload", unsvgtovml);
8773 NAIBU.isMSIE = /*@cc_on!@*/false;